@vkontakte/videoplayer-shared 1.0.19 → 1.0.20
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/index.d.ts +235 -4
- package/package.json +1 -1
- package/Logger/Logger.d.ts +0 -10
- package/Logger/index.d.ts +0 -2
- package/Logger/types.d.ts +0 -30
- package/es2015.cjs.d.ts +0 -4
- package/es2015.esm.d.ts +0 -4
- package/es2018.cjs.d.ts +0 -4
- package/es2018.esm.d.ts +0 -4
- package/esnext.esm.d.ts +0 -4
- package/reactive/Observable.d.ts +0 -7
- package/reactive/Subject.d.ts +0 -10
- package/reactive/Subscription.d.ts +0 -6
- package/reactive/ValueSubject.d.ts +0 -10
- package/reactive/combine.d.ts +0 -10
- package/reactive/fromEvent.d.ts +0 -7
- package/reactive/index.d.ts +0 -20
- package/reactive/interval.d.ts +0 -4
- package/reactive/merge.d.ts +0 -12
- package/reactive/observableFrom.d.ts +0 -3
- package/reactive/operators/debounce.d.ts +0 -6
- package/reactive/operators/filter.d.ts +0 -3
- package/reactive/operators/filterChanged.d.ts +0 -5
- package/reactive/operators/map.d.ts +0 -2
- package/reactive/operators/mapTo.d.ts +0 -2
- package/reactive/operators/once.d.ts +0 -5
- package/reactive/operators/pairwise.d.ts +0 -4
- package/reactive/operators/tap.d.ts +0 -2
- package/reactive/operators/throttle.d.ts +0 -5
- package/reactive/timeout.d.ts +0 -4
- package/reactive/types.d.ts +0 -29
- package/types/index.d.ts +0 -35
- package/utils/abortable.d.ts +0 -3
- package/utils/addScript.d.ts +0 -1
- package/utils/exponentialBackoff.d.ts +0 -9
- package/utils/index.d.ts +0 -8
- package/utils/never.d.ts +0 -2
- package/utils/noop.d.ts +0 -1
- package/utils/now.d.ts +0 -2
- package/utils/nullable.d.ts +0 -6
- package/utils/semanticTypes.d.ts +0 -6
package/es2015.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
"use strict";class b{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach(e=>typeof e=="function"?e():e.unsubscribe())}add(t){return this.subscriptions.push(t),this}}const m=i=>{throw new Error(`${i} is value of unexpected type`)},E=i=>{},h=()=>{};class c{constructor(t){t&&(this._subscribe=t)}subscribe(t,e){var n;let a;e?typeof e=="function"?a={next:e,error:h}:a={next:o=>e.next(o),error:o=>{var u;return(u=e.error)===null||u===void 0?void 0:u.call(e,o)}}:a={next:h,error:h};const s=typeof t=="function"?{next:o=>{try{t(o)}catch(u){a.next(u)}},error:o=>a.next(o)}:{next:o=>t.next(o),error:o=>t.error?t.error(o):a.next(o)};let r;try{r=this._subscribe(s)}catch(o){(n=s.error)===null||n===void 0||n.call(s,o)}return new b().add(()=>{switch(s.next=h,s.error=h,typeof r){case"function":r();return;case"object":r.unsubscribe();return;case"undefined":return;default:return m(r)}})}pipe(...t){return t.reduce((e,n)=>n(e),this)}_subscribe(t){}}class v extends c{constructor(){super(),this.keyCounter=0,this.subscribers=new Map}next(t){this.subscribers.forEach(e=>e.next(t))}error(t){this.subscribers.forEach(e=>{var n;return(n=e.error)===null||n===void 0?void 0:n.call(e,t)})}_subscribe(t){const e=this.keyCounter++;return this.subscribers.set(e,t),new b().add(()=>this.subscribers.delete(e))}}class y{constructor(){this.log$=new v,this.logs=[],this.log=t=>{const e=Object.assign(Object.assign({},t),{timestamp:Date.now()});this.logs.push(e),this.log$.next(e)},this.getAllLogs=()=>this.logs}createCustomLog(t){return(...e)=>{let n;try{n=t(...e)}catch(a){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(t){return this.createCustomLog(e=>Object.assign({component:t},e))}}function L(i,t='Assertion "value is not nullable" failed'){if(i==null)throw new Error(t)}function N(i,t='Assertion "value is nullable" failed'){if(i!=null)throw new Error(t)}function x(i){return typeof i!="undefined"&&i!==null}function g(i){return i==null}const T=(i,t,e)=>new Promise((n,a)=>{t.addEventListener("abort",()=>{o(),l.remove()});const s=()=>{o(),a()},r=()=>{o(),n()},o=()=>{u&&clearTimeout(u),l.removeEventListener("load",r),l.removeEventListener("error",s)};let u;e&&(u=window.setTimeout(s,e));const l=document.createElement("script");l.addEventListener("load",r),l.addEventListener("error",s),l.src=i,document.head.appendChild(l)});var w;const V=typeof((w=window.performance)===null||w===void 0?void 0:w.now)=="function"?()=>window.performance.now():()=>Date.now();function C(i,t,e,n){function a(s){return s instanceof e?s:new e(function(r){r(s)})}return new(e||(e=Promise))(function(s,r){function o(d){try{l(n.next(d))}catch(f){r(f)}}function u(d){try{l(n.throw(d))}catch(f){r(f)}}function l(d){d.done?s(d.value):a(d.value).then(o,u)}l((n=n.apply(i,t||[])).next())})}const O=(i,t)=>(...e)=>C(void 0,void 0,void 0,function*(){var n;const a=t(...e);let s=i.aborted,r;for(;!s&&!i.aborted;){const o=yield a.next(r);s=(n=o.done)!==null&&n!==void 0?n:!1,r=o.value}return r}),j=(i,{start:t=0,factor:e=2,max:n=1/0,min:a=t,random:s=0}={})=>{let r=t;return r*=Math.pow(e,i),r*=1+(Math.random()*s*2-s),r=Math.round(r),r=Math.min(r,n),r=Math.max(r,a),r};class M extends v{constructor(t){super(),this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){const e=super._subscribe(t);return t.next(this.value),e}}function S(i){return new c(t=>{const e={};let n=Object.keys(i).length;const a=s=>r=>{s in e||n--,e[s]=r,n===0&&t.next(e)};return Object.entries(i).reduce((s,[r,o])=>s.add(o.subscribe(a(r))),new b)})}function A(...i){return new c(t=>i.reduce((e,n)=>e.add(n.subscribe(t)),new b))}var D=i=>new c(t=>{const e=window.setTimeout(()=>{try{t.next()}catch(n){if(t.error)t.error(n);else throw n}},i);return()=>window.clearTimeout(e)}),F=i=>new c(t=>{const e=window.setInterval(()=>t.next(),i);return()=>window.clearInterval(e)}),I=i=>new c(t=>{i.forEach(e=>t.next(e))}),k=(i,t)=>new c(e=>{const n=a=>e.next(a);return i.addEventListener(t,n),()=>i.removeEventListener(t,n)});const R={leading:!1,trailing:!0};function $(i,t=R){return e=>new c(n=>e.subscribe(new P(n,i,t)))}class P{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,x(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}const K={leading:!0,trailing:!1};function W(i,t=K){return e=>new c(n=>e.subscribe(new U(n,i,t)))}class U{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,g(this.timeout)&&(this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function X(i){return t=>new c(e=>t.subscribe(new q(e,i)))}class q{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function z(i=(t,e)=>t===e){return t=>new c(e=>t.subscribe(new B(e,i)))}const p={};class B{constructor(t,e){this.destination=t,this.predicate=e,this.lastValue=p}next(t){let e;try{e=this.lastValue===p||!this.predicate(this.lastValue,t),this.lastValue=t}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function _(i){return t=>new c(e=>t.subscribe(new G(e,i)))}let G=class{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(n){throw this.error(n),n}this.destination.next(e)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}};function H(i){return _(()=>i)}function J(){return i=>new c(t=>{let e=!1,n=!1;const a=i.subscribe(s=>{e||(e=!0,t.next(s)),n&&a.unsubscribe()},s=>{var r;e=!0,(r=t.error)===null||r===void 0||r.call(t,s),n&&a.unsubscribe()});return n=!0,e&&a.unsubscribe(),a})}function Q(){return i=>new c(t=>i.subscribe(new Y(t)))}class Y{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;if(this.last=t,!this.hasLast){this.hasLast=!0;return}this.destination.next([e,t])}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function Z(i){return t=>new c(e=>t.subscribe(new tt(e,i)))}class tt{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(e){throw this.error(e),e}this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}exports.ErrorCategory=void 0;(function(i){i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf"})(exports.ErrorCategory||(exports.ErrorCategory={}));exports.Logger=y;exports.Observable=c;exports.Subject=v;exports.Subscription=b;exports.ValueSubject=M;exports.abortable=O;exports.addScript=T;exports.assertNever=m;exports.assertNonNullable=L;exports.assertNullable=N;exports.checkNever=E;exports.combine=S;exports.debounce=$;exports.filter=X;exports.filterChanged=z;exports.fromEvent=k;exports.getExponentialDelay=j;exports.interval=F;exports.isNonNullable=x;exports.isNullable=g;exports.map=_;exports.mapTo=H;exports.merge=A;exports.noop=h;exports.now=V;exports.observableFrom=I;exports.once=J;exports.pairwise=Q;exports.tap=Z;exports.throttle=W;exports.timeout=D;
|
package/es2015.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
class
|
|
6
|
+
class f{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach(e=>typeof e=="function"?e():e.unsubscribe())}add(t){return this.subscriptions.push(t),this}}const x=i=>{throw new Error(`${i} is value of unexpected type`)},I=i=>{},h=()=>{};class c{constructor(t){t&&(this._subscribe=t)}subscribe(t,e){var n;let a;e?typeof e=="function"?a={next:e,error:h}:a={next:o=>e.next(o),error:o=>{var u;return(u=e.error)===null||u===void 0?void 0:u.call(e,o)}}:a={next:h,error:h};const s=typeof t=="function"?{next:o=>{try{t(o)}catch(u){a.next(u)}},error:o=>a.next(o)}:{next:o=>t.next(o),error:o=>t.error?t.error(o):a.next(o)};let r;try{r=this._subscribe(s)}catch(o){(n=s.error)===null||n===void 0||n.call(s,o)}return new f().add(()=>{switch(s.next=h,s.error=h,typeof r){case"function":r();return;case"object":r.unsubscribe();return;case"undefined":return;default:return x(r)}})}pipe(...t){return t.reduce((e,n)=>n(e),this)}_subscribe(t){}}class m extends c{constructor(){super(),this.keyCounter=0,this.subscribers=new Map}next(t){this.subscribers.forEach(e=>e.next(t))}error(t){this.subscribers.forEach(e=>{var n;return(n=e.error)===null||n===void 0?void 0:n.call(e,t)})}_subscribe(t){const e=this.keyCounter++;return this.subscribers.set(e,t),new f().add(()=>this.subscribers.delete(e))}}class D{constructor(){this.log$=new m,this.logs=[],this.log=t=>{const e=Object.assign(Object.assign({},t),{timestamp:Date.now()});this.logs.push(e),this.log$.next(e)},this.getAllLogs=()=>this.logs}createCustomLog(t){return(...e)=>{let n;try{n=t(...e)}catch(a){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(t){return this.createCustomLog(e=>Object.assign({component:t},e))}}function F(i,t='Assertion "value is not nullable" failed'){if(i==null)throw new Error(t)}function S(i,t='Assertion "value is nullable" failed'){if(i!=null)throw new Error(t)}function g(i){return typeof i!="undefined"&&i!==null}function _(i){return i==null}const k=(i,t,e)=>new Promise((n,a)=>{t.addEventListener("abort",()=>{o(),l.remove()});const s=()=>{o(),a()},r=()=>{o(),n()},o=()=>{u&&clearTimeout(u),l.removeEventListener("load",r),l.removeEventListener("error",s)};let u;e&&(u=window.setTimeout(s,e));const l=document.createElement("script");l.addEventListener("load",r),l.addEventListener("error",s),l.src=i,document.head.appendChild(l)});var w;const R=typeof((w=window.performance)===null||w===void 0?void 0:w.now)=="function"?()=>window.performance.now():()=>Date.now();function E(i,t,e,n){function a(s){return s instanceof e?s:new e(function(r){r(s)})}return new(e||(e=Promise))(function(s,r){function o(d){try{l(n.next(d))}catch(b){r(b)}}function u(d){try{l(n.throw(d))}catch(b){r(b)}}function l(d){d.done?s(d.value):a(d.value).then(o,u)}l((n=n.apply(i,t||[])).next())})}const $=(i,t)=>(...e)=>E(void 0,void 0,void 0,function*(){var n;const a=t(...e);let s=i.aborted,r;for(;!s&&!i.aborted;){const o=yield a.next(r);s=(n=o.done)!==null&&n!==void 0?n:!1,r=o.value}return r}),P=(i,{start:t=0,factor:e=2,max:n=1/0,min:a=t,random:s=0}={})=>{let r=t;return r*=Math.pow(e,i),r*=1+(Math.random()*s*2-s),r=Math.round(r),r=Math.min(r,n),r=Math.max(r,a),r};class K extends m{constructor(t){super(),this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){const e=super._subscribe(t);return t.next(this.value),e}}function W(i){return new c(t=>{const e={};let n=Object.keys(i).length;const a=s=>r=>{s in e||n--,e[s]=r,n===0&&t.next(e)};return Object.entries(i).reduce((s,[r,o])=>s.add(o.subscribe(a(r))),new f)})}function U(...i){return new c(t=>i.reduce((e,n)=>e.add(n.subscribe(t)),new f))}var X=i=>new c(t=>{const e=window.setTimeout(()=>{try{t.next()}catch(n){if(t.error)t.error(n);else throw n}},i);return()=>window.clearTimeout(e)}),q=i=>new c(t=>{const e=window.setInterval(()=>t.next(),i);return()=>window.clearInterval(e)}),z=i=>new c(t=>{i.forEach(e=>t.next(e))}),B=(i,t)=>new c(e=>{const n=a=>e.next(a);return i.addEventListener(t,n),()=>i.removeEventListener(t,n)});const y={leading:!1,trailing:!0};function G(i,t=y){return e=>new c(n=>e.subscribe(new L(n,i,t)))}class L{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,g(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}const T={leading:!0,trailing:!1};function H(i,t=T){return e=>new c(n=>e.subscribe(new V(n,i,t)))}class V{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,_(this.timeout)&&(this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function J(i){return t=>new c(e=>t.subscribe(new N(e,i)))}class N{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function Q(i=(t,e)=>t===e){return t=>new c(e=>t.subscribe(new M(e,i)))}const v={};class M{constructor(t,e){this.destination=t,this.predicate=e,this.lastValue=v}next(t){let e;try{e=this.lastValue===v||!this.predicate(this.lastValue,t),this.lastValue=t}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function O(i){return t=>new c(e=>t.subscribe(new j(e,i)))}let j=class{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(n){throw this.error(n),n}this.destination.next(e)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}};function Z(i){return O(()=>i)}function tt(){return i=>new c(t=>{let e=!1,n=!1;const a=i.subscribe(s=>{e||(e=!0,t.next(s)),n&&a.unsubscribe()},s=>{var r;e=!0,(r=t.error)===null||r===void 0||r.call(t,s),n&&a.unsubscribe()});return n=!0,e&&a.unsubscribe(),a})}function et(){return i=>new c(t=>i.subscribe(new C(t)))}class C{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;if(this.last=t,!this.hasLast){this.hasLast=!0;return}this.destination.next([e,t])}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function nt(i){return t=>new c(e=>t.subscribe(new A(e,i)))}class A{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(e){throw this.error(e),e}this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}var p;(function(i){i.NETWORK="network",i.VIDEO_PIPELINE="video_pipeline",i.EXTERNAL_API="external_api",i.PARSER="parser",i.DOM="dom",i.WTF="wtf"})(p||(p={}));export{p as ErrorCategory,D as Logger,c as Observable,m as Subject,f as Subscription,K as ValueSubject,$ as abortable,k as addScript,x as assertNever,F as assertNonNullable,S as assertNullable,I as checkNever,W as combine,G as debounce,J as filter,Q as filterChanged,B as fromEvent,P as getExponentialDelay,q as interval,g as isNonNullable,_ as isNullable,O as map,Z as mapTo,U as merge,h as noop,R as now,z as observableFrom,tt as once,et as pairwise,nt as tap,H as throttle,X as timeout};
|
package/es2018.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
"use strict";class h{constructor(){this.subscriptions=[]}unsubscribe(){const e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}}const v=n=>{throw new Error(`${n} is value of unexpected type`)},g=n=>{},d=()=>{};class c{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){var r;let a;t?typeof t=="function"?a={next:t,error:d}:a={next:o=>t.next(o),error:o=>{var u;return(u=t.error)===null||u===void 0?void 0:u.call(t,o)}}:a={next:d,error:d};const s=typeof e=="function"?{next:o=>{try{e(o)}catch(u){a.next(u)}},error:o=>a.next(o)}:{next:o=>e.next(o),error:o=>e.error?e.error(o):a.next(o)};let i;try{i=this._subscribe(s)}catch(o){(r=s.error)===null||r===void 0||r.call(s,o)}return new h().add(()=>{switch(s.next=d,s.error=d,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return v(i)}})}pipe(...e){return e.reduce((t,r)=>r(t),this)}_subscribe(e){}}class f extends c{constructor(){super(),this.keyCounter=0,this.subscribers=new Map}next(e){this.subscribers.forEach(t=>t.next(e))}error(e){this.subscribers.forEach(t=>{var r;return(r=t.error)===null||r===void 0?void 0:r.call(t,e)})}_subscribe(e){const t=this.keyCounter++;return this.subscribers.set(t,e),new h().add(()=>this.subscribers.delete(t))}}class E{constructor(){this.log$=new f,this.logs=[],this.log=e=>{const t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)},this.getAllLogs=()=>this.logs}createCustomLog(e){return(...t)=>{let r;try{r=e(...t)}catch(a){r={message:"error in `createCustomLog`",component:"Logger"}}this.log(r)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}}function _(n,e='Assertion "value is not nullable" failed'){if(n==null)throw new Error(e)}function y(n,e='Assertion "value is nullable" failed'){if(n!=null)throw new Error(e)}function p(n){return typeof n!="undefined"&&n!==null}function m(n){return n==null}const L=(n,e,t)=>new Promise((r,a)=>{e.addEventListener("abort",()=>{o(),l.remove()});const s=()=>{o(),a()},i=()=>{o(),r()},o=()=>{u&&clearTimeout(u),l.removeEventListener("load",i),l.removeEventListener("error",s)};let u;t&&(u=window.setTimeout(s,t));const l=document.createElement("script");l.addEventListener("load",i),l.addEventListener("error",s),l.src=n,document.head.appendChild(l)});var b;const N=typeof((b=window.performance)===null||b===void 0?void 0:b.now)=="function"?()=>window.performance.now():()=>Date.now(),T=(n,e)=>async(...t)=>{var r;const a=e(...t);let s=n.aborted,i;for(;!s&&!n.aborted;){const o=await a.next(i);s=(r=o.done)!==null&&r!==void 0?r:!1,i=o.value}return i},V=(n,{start:e=0,factor:t=2,max:r=1/0,min:a=e,random:s=0}={})=>{let i=e;return i*=t**n,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,r),i=Math.max(i,a),i};class C extends f{constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){const t=super._subscribe(e);return e.next(this.value),t}}function S(n){return new c(e=>{const t={};let r=Object.keys(n).length;const a=s=>i=>{s in t||r--,t[s]=i,r===0&&e.next(t)};return Object.entries(n).reduce((s,[i,o])=>s.add(o.subscribe(a(i))),new h)})}function M(...n){return new c(e=>n.reduce((t,r)=>t.add(r.subscribe(e)),new h))}var O=n=>new c(e=>{const t=window.setTimeout(()=>{try{e.next()}catch(r){if(e.error)e.error(r);else throw r}},n);return()=>window.clearTimeout(t)}),j=n=>new c(e=>{const t=window.setInterval(()=>e.next(),n);return()=>window.clearInterval(t)}),A=n=>new c(e=>{n.forEach(t=>e.next(t))}),D=(n,e)=>new c(t=>{const r=a=>t.next(a);return n.addEventListener(e,r),()=>n.removeEventListener(e,r)});const F={leading:!1,trailing:!0};function I(n,e=F){return t=>new c(r=>t.subscribe(new k(r,n,e)))}class k{constructor(e,t,r){this.destination=e,this.time=t,this.config=r}next(e){this.lastValue=e,p(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}const P={leading:!0,trailing:!1};function R(n,e=P){return t=>new c(r=>t.subscribe(new $(r,n,e)))}class ${constructor(e,t,r){this.destination=e,this.time=t,this.config=r}next(e){this.lastValue=e,m(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}function K(n){return e=>new c(t=>e.subscribe(new W(t,n)))}class W{constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(r){throw this.error(r),r}t&&this.destination.next(e)}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}function U(n=(e,t)=>e===t){return e=>new c(t=>e.subscribe(new X(t,n)))}const w={};class X{constructor(e,t){this.destination=e,this.predicate=t,this.lastValue=w}next(e){let t;try{t=this.lastValue===w||!this.predicate(this.lastValue,e),this.lastValue=e}catch(r){throw this.error(r),r}t&&this.destination.next(e)}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}function x(n){return e=>new c(t=>e.subscribe(new q(t,n)))}let q=class{constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(r){throw this.error(r),r}this.destination.next(t)}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}};function z(n){return x(()=>n)}function B(){return n=>new c(e=>{let t=!1,r=!1;const a=n.subscribe(s=>{t||(t=!0,e.next(s)),r&&a.unsubscribe()},s=>{var i;t=!0,(i=e.error)===null||i===void 0||i.call(e,s),r&&a.unsubscribe()});return r=!0,t&&a.unsubscribe(),a})}function G(){return n=>new c(e=>n.subscribe(new H(e)))}class H{constructor(e){this.destination=e,this.hasLast=!1}next(e){const t=this.last;if(this.last=e,!this.hasLast){this.hasLast=!0;return}this.destination.next([t,e])}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}function J(n){return e=>new c(t=>e.subscribe(new Q(t,n)))}class Q{constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){var t,r;(r=(t=this.destination).error)===null||r===void 0||r.call(t,e)}}exports.ErrorCategory=void 0;(function(n){n.NETWORK="network",n.VIDEO_PIPELINE="video_pipeline",n.EXTERNAL_API="external_api",n.PARSER="parser",n.DOM="dom",n.WTF="wtf"})(exports.ErrorCategory||(exports.ErrorCategory={}));exports.Logger=E;exports.Observable=c;exports.Subject=f;exports.Subscription=h;exports.ValueSubject=C;exports.abortable=T;exports.addScript=L;exports.assertNever=v;exports.assertNonNullable=_;exports.assertNullable=y;exports.checkNever=g;exports.combine=S;exports.debounce=I;exports.filter=K;exports.filterChanged=U;exports.fromEvent=D;exports.getExponentialDelay=V;exports.interval=j;exports.isNonNullable=p;exports.isNullable=m;exports.map=x;exports.mapTo=z;exports.merge=M;exports.noop=d;exports.now=N;exports.observableFrom=A;exports.once=B;exports.pairwise=G;exports.tap=J;exports.throttle=R;exports.timeout=O;
|
package/es2018.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
class
|
|
6
|
+
class h{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach(e=>typeof e=="function"?e():e.unsubscribe())}add(t){return this.subscriptions.push(t),this}}const p=r=>{throw new Error(`${r} is value of unexpected type`)},A=r=>{},d=()=>{};class c{constructor(t){t&&(this._subscribe=t)}subscribe(t,e){var n;let a;e?typeof e=="function"?a={next:e,error:d}:a={next:o=>e.next(o),error:o=>{var u;return(u=e.error)===null||u===void 0?void 0:u.call(e,o)}}:a={next:d,error:d};const s=typeof t=="function"?{next:o=>{try{t(o)}catch(u){a.next(u)}},error:o=>a.next(o)}:{next:o=>t.next(o),error:o=>t.error?t.error(o):a.next(o)};let i;try{i=this._subscribe(s)}catch(o){(n=s.error)===null||n===void 0||n.call(s,o)}return new h().add(()=>{switch(s.next=d,s.error=d,typeof i){case"function":i();return;case"object":i.unsubscribe();return;case"undefined":return;default:return p(i)}})}pipe(...t){return t.reduce((e,n)=>n(e),this)}_subscribe(t){}}class v extends c{constructor(){super(),this.keyCounter=0,this.subscribers=new Map}next(t){this.subscribers.forEach(e=>e.next(t))}error(t){this.subscribers.forEach(e=>{var n;return(n=e.error)===null||n===void 0?void 0:n.call(e,t)})}_subscribe(t){const e=this.keyCounter++;return this.subscribers.set(e,t),new h().add(()=>this.subscribers.delete(e))}}class I{constructor(){this.log$=new v,this.logs=[],this.log=t=>{const e={...t,timestamp:Date.now()};this.logs.push(e),this.log$.next(e)},this.getAllLogs=()=>this.logs}createCustomLog(t){return(...e)=>{let n;try{n=t(...e)}catch(a){n={message:"error in `createCustomLog`",component:"Logger"}}this.log(n)}}createComponentLog(t){return this.createCustomLog(e=>({component:t,...e}))}}function O(r,t='Assertion "value is not nullable" failed'){if(r==null)throw new Error(t)}function D(r,t='Assertion "value is nullable" failed'){if(r!=null)throw new Error(t)}function m(r){return typeof r!="undefined"&&r!==null}function x(r){return r==null}const F=(r,t,e)=>new Promise((n,a)=>{t.addEventListener("abort",()=>{o(),l.remove()});const s=()=>{o(),a()},i=()=>{o(),n()},o=()=>{u&&clearTimeout(u),l.removeEventListener("load",i),l.removeEventListener("error",s)};let u;e&&(u=window.setTimeout(s,e));const l=document.createElement("script");l.addEventListener("load",i),l.addEventListener("error",s),l.src=r,document.head.appendChild(l)});var f;const P=typeof((f=window.performance)===null||f===void 0?void 0:f.now)=="function"?()=>window.performance.now():()=>Date.now(),S=(r,t)=>async(...e)=>{var n;const a=t(...e);let s=r.aborted,i;for(;!s&&!r.aborted;){const o=await a.next(i);s=(n=o.done)!==null&&n!==void 0?n:!1,i=o.value}return i},j=(r,{start:t=0,factor:e=2,max:n=1/0,min:a=t,random:s=0}={})=>{let i=t;return i*=e**r,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,n),i=Math.max(i,a),i};class k extends v{constructor(t){super(),this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){const e=super._subscribe(t);return t.next(this.value),e}}function R(r){return new c(t=>{const e={};let n=Object.keys(r).length;const a=s=>i=>{s in e||n--,e[s]=i,n===0&&t.next(e)};return Object.entries(r).reduce((s,[i,o])=>s.add(o.subscribe(a(i))),new h)})}function $(...r){return new c(t=>r.reduce((e,n)=>e.add(n.subscribe(t)),new h))}var K=r=>new c(t=>{const e=window.setTimeout(()=>{try{t.next()}catch(n){if(t.error)t.error(n);else throw n}},r);return()=>window.clearTimeout(e)}),W=r=>new c(t=>{const e=window.setInterval(()=>t.next(),r);return()=>window.clearInterval(e)}),U=r=>new c(t=>{r.forEach(e=>t.next(e))}),X=(r,t)=>new c(e=>{const n=a=>e.next(a);return r.addEventListener(t,n),()=>r.removeEventListener(t,n)});const g={leading:!1,trailing:!0};function q(r,t=g){return e=>new c(n=>e.subscribe(new _(n,r,t)))}class _{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,m(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}const E={leading:!0,trailing:!1};function z(r,t=E){return e=>new c(n=>e.subscribe(new L(n,r,t)))}class L{constructor(t,e,n){this.destination=t,this.time=e,this.config=n}next(t){this.lastValue=t,x(this.timeout)&&(this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function B(r){return t=>new c(e=>t.subscribe(new y(e,r)))}class y{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function G(r=(t,e)=>t===e){return t=>new c(e=>t.subscribe(new T(e,r)))}const b={};class T{constructor(t,e){this.destination=t,this.predicate=e,this.lastValue=b}next(t){let e;try{e=this.lastValue===b||!this.predicate(this.lastValue,t),this.lastValue=t}catch(n){throw this.error(n),n}e&&this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function V(r){return t=>new c(e=>t.subscribe(new N(e,r)))}let N=class{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(n){throw this.error(n),n}this.destination.next(e)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}};function J(r){return V(()=>r)}function Q(){return r=>new c(t=>{let e=!1,n=!1;const a=r.subscribe(s=>{e||(e=!0,t.next(s)),n&&a.unsubscribe()},s=>{var i;e=!0,(i=t.error)===null||i===void 0||i.call(t,s),n&&a.unsubscribe()});return n=!0,e&&a.unsubscribe(),a})}function Y(){return r=>new c(t=>r.subscribe(new M(t)))}class M{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;if(this.last=t,!this.hasLast){this.hasLast=!0;return}this.destination.next([e,t])}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}function Z(r){return t=>new c(e=>t.subscribe(new C(e,r)))}class C{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(e){throw this.error(e),e}this.destination.next(t)}error(t){var e,n;(n=(e=this.destination).error)===null||n===void 0||n.call(e,t)}}var w;(function(r){r.NETWORK="network",r.VIDEO_PIPELINE="video_pipeline",r.EXTERNAL_API="external_api",r.PARSER="parser",r.DOM="dom",r.WTF="wtf"})(w||(w={}));export{w as ErrorCategory,I as Logger,c as Observable,v as Subject,h as Subscription,k as ValueSubject,S as abortable,F as addScript,p as assertNever,O as assertNonNullable,D as assertNullable,A as checkNever,R as combine,q as debounce,B as filter,G as filterChanged,X as fromEvent,j as getExponentialDelay,W as interval,m as isNonNullable,x as isNullable,V as map,J as mapTo,$ as merge,d as noop,P as now,U as observableFrom,Q as once,Y as pairwise,Z as tap,z as throttle,K as timeout};
|
package/esnext.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
"use strict";class h{subscriptions=[];unsubscribe(){const e=this.subscriptions;this.subscriptions=[],e.forEach(t=>typeof t=="function"?t():t.unsubscribe())}add(e){return this.subscriptions.push(e),this}}const w=n=>{throw new Error(`${n} is value of unexpected type`)},g=n=>{},l=()=>{};class a{constructor(e){e&&(this._subscribe=e)}subscribe(e,t){let r;t?typeof t=="function"?r={next:t,error:l}:r={next:i=>t.next(i),error:i=>t.error?.(i)}:r={next:l,error:l};const o=typeof e=="function"?{next:i=>{try{e(i)}catch(c){r.next(c)}},error:i=>r.next(i)}:{next:i=>e.next(i),error:i=>e.error?e.error(i):r.next(i)};let s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new h().add(()=>{switch(o.next=l,o.error=l,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return w(s)}})}pipe(...e){return e.reduce((t,r)=>r(t),this)}_subscribe(e){}}class b extends a{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){const t=this.keyCounter++;return this.subscribers.set(t,e),new h().add(()=>this.subscribers.delete(t))}}class E{log$=new b;logs=[];log=e=>{const t={...e,timestamp:Date.now()};this.logs.push(t),this.log$.next(t)};createCustomLog(e){return(...t)=>{let r;try{r=e(...t)}catch{r={message:"error in `createCustomLog`",component:"Logger"}}this.log(r)}}createComponentLog(e){return this.createCustomLog(t=>({component:e,...t}))}getAllLogs=()=>this.logs}function v(n,e='Assertion "value is not nullable" failed'){if(n==null)throw new Error(e)}function y(n,e='Assertion "value is nullable" failed'){if(n!=null)throw new Error(e)}function p(n){return typeof n<"u"&&n!==null}function m(n){return n==null}const L=(n,e,t)=>new Promise((r,o)=>{e.addEventListener("abort",()=>{c(),u.remove()});const s=()=>{c(),o()},i=()=>{c(),r()},c=()=>{d&&clearTimeout(d),u.removeEventListener("load",i),u.removeEventListener("error",s)};let d;t&&(d=window.setTimeout(s,t));const u=document.createElement("script");u.addEventListener("load",i),u.addEventListener("error",s),u.src=n,document.head.appendChild(u)}),N=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now(),V=(n,e)=>async(...t)=>{const r=e(...t);let o=n.aborted,s;for(;!o&&!n.aborted;){const i=await r.next(s);o=i.done??!1,s=i.value}return s},T=(n,{start:e=0,factor:t=2,max:r=1/0,min:o=e,random:s=0}={})=>{let i=e;return i*=t**n,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,r),i=Math.max(i,o),i};class _ extends b{value;constructor(e){super(),this.value=e}next(e){super.next(this.value=e)}error(e){super.error(this.value=e)}getValue(){return this.value}_subscribe(e){const t=super._subscribe(e);return e.next(this.value),t}}function C(n){return new a(e=>{const t={};let r=Object.keys(n).length;const o=s=>i=>{s in t||r--,t[s]=i,r===0&&e.next(t)};return Object.entries(n).reduce((s,[i,c])=>s.add(c.subscribe(o(i))),new h)})}function S(...n){return new a(e=>n.reduce((t,r)=>t.add(r.subscribe(e)),new h))}var M=n=>new a(e=>{const t=window.setTimeout(()=>{try{e.next()}catch(r){if(e.error)e.error(r);else throw r}},n);return()=>window.clearTimeout(t)}),O=n=>new a(e=>{const t=window.setInterval(()=>e.next(),n);return()=>window.clearInterval(t)}),j=n=>new a(e=>{n.forEach(t=>e.next(t))}),A=(n,e)=>new a(t=>{const r=o=>t.next(o);return n.addEventListener(e,r),()=>n.removeEventListener(e,r)});const D={leading:!1,trailing:!0};function F(n,e=D){return t=>new a(r=>t.subscribe(new I(r,n,e)))}class I{destination;time;config;lastValue;timeout;constructor(e,t,r){this.destination=e,this.time=t,this.config=r}next(e){this.lastValue=e,p(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(t){if(this.destination.error)this.destination.error(t);else throw t}this.timeout=void 0},this.time)}error(e){this.destination.error?.(e)}}const k={leading:!0,trailing:!1};function P(n,e=k){return t=>new a(r=>t.subscribe(new R(r,n,e)))}class R{destination;time;config;lastValue;timeout;constructor(e,t,r){this.destination=e,this.time=t,this.config=r}next(e){this.lastValue=e,m(this.timeout)&&(this.config.leading&&this.destination.next(e),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(e){this.destination.error?.(e)}}function $(n){return e=>new a(t=>e.subscribe(new K(t,n)))}class K{destination;predicate;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.predicate(e)}catch(r){throw this.error(r),r}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function W(n=(e,t)=>e===t){return e=>new a(t=>e.subscribe(new U(t,n)))}const f={};class U{destination;predicate;lastValue=f;constructor(e,t){this.destination=e,this.predicate=t}next(e){let t;try{t=this.lastValue===f||!this.predicate(this.lastValue,e),this.lastValue=e}catch(r){throw this.error(r),r}t&&this.destination.next(e)}error(e){this.destination.error?.(e)}}function x(n){return e=>new a(t=>e.subscribe(new X(t,n)))}let X=class{destination;mapper;constructor(e,t){this.destination=e,this.mapper=t}next(e){let t;try{t=this.mapper(e)}catch(r){throw this.error(r),r}this.destination.next(t)}error(e){this.destination.error?.(e)}};function q(n){return x(()=>n)}function z(){return n=>new a(e=>{let t=!1,r=!1;const o=n.subscribe(s=>{t||(t=!0,e.next(s)),r&&o.unsubscribe()},s=>{t=!0,e.error?.(s),r&&o.unsubscribe()});return r=!0,t&&o.unsubscribe(),o})}function B(){return n=>new a(e=>n.subscribe(new G(e)))}class G{destination;last;hasLast=!1;constructor(e){this.destination=e}next(e){const 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 H(n){return e=>new a(t=>e.subscribe(new J(t,n)))}class J{destination;effect;constructor(e,t){this.destination=e,this.effect=t}next(e){try{this.effect(e)}catch(t){throw this.error(t),t}this.destination.next(e)}error(e){this.destination.error?.(e)}}exports.ErrorCategory=void 0;(function(n){n.NETWORK="network",n.VIDEO_PIPELINE="video_pipeline",n.EXTERNAL_API="external_api",n.PARSER="parser",n.DOM="dom",n.WTF="wtf"})(exports.ErrorCategory||(exports.ErrorCategory={}));exports.Logger=E;exports.Observable=a;exports.Subject=b;exports.Subscription=h;exports.ValueSubject=_;exports.abortable=V;exports.addScript=L;exports.assertNever=w;exports.assertNonNullable=v;exports.assertNullable=y;exports.checkNever=g;exports.combine=C;exports.debounce=F;exports.filter=$;exports.filterChanged=W;exports.fromEvent=A;exports.getExponentialDelay=T;exports.interval=O;exports.isNonNullable=p;exports.isNullable=m;exports.map=x;exports.mapTo=q;exports.merge=S;exports.noop=l;exports.now=N;exports.observableFrom=j;exports.once=z;exports.pairwise=B;exports.tap=H;exports.throttle=P;exports.timeout=M;
|
package/esnext.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vkontakte/videoplayer-shared v1.0.
|
|
3
|
-
*
|
|
4
|
-
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-
|
|
2
|
+
* @vkontakte/videoplayer-shared v1.0.20
|
|
3
|
+
* Thu, 02 Feb 2023 10:06:08 GMT
|
|
4
|
+
* https://st.mycdn.me/static/vkontakte-videoplayer/1-0-20/doc/
|
|
5
5
|
*/
|
|
6
|
-
class
|
|
6
|
+
class h{subscriptions=[];unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach(e=>typeof e=="function"?e():e.unsubscribe())}add(t){return this.subscriptions.push(t),this}}const p=n=>{throw new Error(`${n} is value of unexpected type`)},C=n=>{},l=()=>{};class a{constructor(t){t&&(this._subscribe=t)}subscribe(t,e){let r;e?typeof e=="function"?r={next:e,error:l}:r={next:i=>e.next(i),error:i=>e.error?.(i)}:r={next:l,error:l};const o=typeof t=="function"?{next:i=>{try{t(i)}catch(c){r.next(c)}},error:i=>r.next(i)}:{next:i=>t.next(i),error:i=>t.error?t.error(i):r.next(i)};let s;try{s=this._subscribe(o)}catch(i){o.error?.(i)}return new h().add(()=>{switch(o.next=l,o.error=l,typeof s){case"function":s();return;case"object":s.unsubscribe();return;case"undefined":return;default:return p(s)}})}pipe(...t){return t.reduce((e,r)=>r(e),this)}_subscribe(t){}}class w extends a{keyCounter=0;subscribers=new Map;constructor(){super()}next(t){this.subscribers.forEach(e=>e.next(t))}error(t){this.subscribers.forEach(e=>e.error?.(t))}_subscribe(t){const e=this.keyCounter++;return this.subscribers.set(e,t),new h().add(()=>this.subscribers.delete(e))}}class A{log$=new w;logs=[];log=t=>{const e={...t,timestamp:Date.now()};this.logs.push(e),this.log$.next(e)};createCustomLog(t){return(...e)=>{let r;try{r=t(...e)}catch{r={message:"error in `createCustomLog`",component:"Logger"}}this.log(r)}}createComponentLog(t){return this.createCustomLog(e=>({component:t,...e}))}getAllLogs=()=>this.logs}function I(n,t='Assertion "value is not nullable" failed'){if(n==null)throw new Error(t)}function O(n,t='Assertion "value is nullable" failed'){if(n!=null)throw new Error(t)}function m(n){return typeof n<"u"&&n!==null}function x(n){return n==null}const D=(n,t,e)=>new Promise((r,o)=>{t.addEventListener("abort",()=>{c(),u.remove()});const s=()=>{c(),o()},i=()=>{c(),r()},c=()=>{d&&clearTimeout(d),u.removeEventListener("load",i),u.removeEventListener("error",s)};let d;e&&(d=window.setTimeout(s,e));const u=document.createElement("script");u.addEventListener("load",i),u.addEventListener("error",s),u.src=n,document.head.appendChild(u)}),F=typeof window.performance?.now=="function"?()=>window.performance.now():()=>Date.now(),P=(n,t)=>async(...e)=>{const r=t(...e);let o=n.aborted,s;for(;!o&&!n.aborted;){const i=await r.next(s);o=i.done??!1,s=i.value}return s},S=(n,{start:t=0,factor:e=2,max:r=1/0,min:o=t,random:s=0}={})=>{let i=t;return i*=e**n,i*=1+(Math.random()*s*2-s),i=Math.round(i),i=Math.min(i,r),i=Math.max(i,o),i};class j extends w{value;constructor(t){super(),this.value=t}next(t){super.next(this.value=t)}error(t){super.error(this.value=t)}getValue(){return this.value}_subscribe(t){const e=super._subscribe(t);return t.next(this.value),e}}function k(n){return new a(t=>{const e={};let r=Object.keys(n).length;const o=s=>i=>{s in e||r--,e[s]=i,r===0&&t.next(e)};return Object.entries(n).reduce((s,[i,c])=>s.add(c.subscribe(o(i))),new h)})}function R(...n){return new a(t=>n.reduce((e,r)=>e.add(r.subscribe(t)),new h))}var $=n=>new a(t=>{const e=window.setTimeout(()=>{try{t.next()}catch(r){if(t.error)t.error(r);else throw r}},n);return()=>window.clearTimeout(e)}),K=n=>new a(t=>{const e=window.setInterval(()=>t.next(),n);return()=>window.clearInterval(e)}),W=n=>new a(t=>{n.forEach(e=>t.next(e))}),U=(n,t)=>new a(e=>{const r=o=>e.next(o);return n.addEventListener(t,r),()=>n.removeEventListener(t,r)});const g={leading:!1,trailing:!0};function X(n,t=g){return e=>new a(r=>e.subscribe(new E(r,n,t)))}class E{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,m(this.timeout)?window.clearTimeout(this.timeout):this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{if(this.config.trailing)try{this.destination.next(this.lastValue)}catch(e){if(this.destination.error)this.destination.error(e);else throw e}this.timeout=void 0},this.time)}error(t){this.destination.error?.(t)}}const v={leading:!0,trailing:!1};function q(n,t=v){return e=>new a(r=>e.subscribe(new L(r,n,t)))}class L{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,x(this.timeout)&&(this.config.leading&&this.destination.next(t),this.timeout=window.setTimeout(()=>{this.config.trailing&&this.destination.next(this.lastValue),this.timeout=void 0},this.time))}error(t){this.destination.error?.(t)}}function z(n){return t=>new a(e=>t.subscribe(new y(e,n)))}class y{destination;predicate;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(r){throw this.error(r),r}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function B(n=(t,e)=>t===e){return t=>new a(e=>t.subscribe(new V(e,n)))}const f={};class V{destination;predicate;lastValue=f;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.lastValue===f||!this.predicate(this.lastValue,t),this.lastValue=t}catch(r){throw this.error(r),r}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function T(n){return t=>new a(e=>t.subscribe(new _(e,n)))}let _=class{destination;mapper;constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(r){throw this.error(r),r}this.destination.next(e)}error(t){this.destination.error?.(t)}};function H(n){return T(()=>n)}function J(){return n=>new a(t=>{let e=!1,r=!1;const o=n.subscribe(s=>{e||(e=!0,t.next(s)),r&&o.unsubscribe()},s=>{e=!0,t.error?.(s),r&&o.unsubscribe()});return r=!0,e&&o.unsubscribe(),o})}function Q(){return n=>new a(t=>n.subscribe(new N(t)))}class N{destination;last;hasLast=!1;constructor(t){this.destination=t}next(t){const e=this.last;if(this.last=t,!this.hasLast){this.hasLast=!0;return}this.destination.next([e,t])}error(t){this.destination.error?.(t)}}function Y(n){return t=>new a(e=>t.subscribe(new M(e,n)))}class M{destination;effect;constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(e){throw this.error(e),e}this.destination.next(t)}error(t){this.destination.error?.(t)}}var b;(function(n){n.NETWORK="network",n.VIDEO_PIPELINE="video_pipeline",n.EXTERNAL_API="external_api",n.PARSER="parser",n.DOM="dom",n.WTF="wtf"})(b||(b={}));export{b as ErrorCategory,A as Logger,a as Observable,w as Subject,h as Subscription,j as ValueSubject,P as abortable,D as addScript,p as assertNever,I as assertNonNullable,O as assertNullable,C as checkNever,k as combine,X as debounce,z as filter,B as filterChanged,U as fromEvent,S as getExponentialDelay,K as interval,m as isNonNullable,x as isNullable,T as map,H as mapTo,R as merge,l as noop,F as now,W as observableFrom,J as once,Q as pairwise,Y as tap,q as throttle,$ as timeout};
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,235 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type IUnsubscriber = () => void;
|
|
2
|
+
interface ISubscription {
|
|
3
|
+
unsubscribe: IUnsubscriber;
|
|
4
|
+
add(item: ISubscription | IUnsubscriber): ISubscription;
|
|
5
|
+
}
|
|
6
|
+
interface IObservable<T> {
|
|
7
|
+
subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
|
|
8
|
+
pipe<T1>(op1: IOperator<T, T1>): IObservable<T1>;
|
|
9
|
+
pipe<T1, T2>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>): IObservable<T2>;
|
|
10
|
+
pipe<T1, T2, T3>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>): IObservable<T3>;
|
|
11
|
+
pipe<T1, T2, T3, T4>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>): IObservable<T4>;
|
|
12
|
+
pipe<T1, T2, T3, T4, T5>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>, op5: IOperator<T4, T5>): IObservable<T5>;
|
|
13
|
+
}
|
|
14
|
+
interface IValue<T> {
|
|
15
|
+
getValue(): T;
|
|
16
|
+
}
|
|
17
|
+
interface IEmitter<T> {
|
|
18
|
+
next(value: T): void;
|
|
19
|
+
error?(value: Error | unknown): void;
|
|
20
|
+
}
|
|
21
|
+
interface IValueObservable<T> extends IObservable<T>, IValue<T> {
|
|
22
|
+
}
|
|
23
|
+
interface ISubject<T> extends IEmitter<T>, IObservable<T> {
|
|
24
|
+
}
|
|
25
|
+
interface IValueSubject<T> extends IEmitter<T>, IObservable<T>, IValue<T> {
|
|
26
|
+
}
|
|
27
|
+
type IListener<T> = IEmitter<T> | ((value: T) => void);
|
|
28
|
+
type IOperator<TInput, TOutput = TInput> = (input: IObservable<TInput>) => IObservable<TOutput>;
|
|
29
|
+
type TypeOfObservable<TObservable> = TObservable extends IObservable<infer TType> ? TType : never;
|
|
30
|
+
|
|
31
|
+
declare class Observable<T> implements IObservable<T> {
|
|
32
|
+
constructor(subscribe?: (emitter: IEmitter<T>) => IUnsubscriber | ISubscription | void);
|
|
33
|
+
subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
|
|
34
|
+
pipe(...operators: IOperator<unknown, unknown>[]): IObservable<unknown>;
|
|
35
|
+
protected _subscribe(_emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare class Subject<T> extends Observable<T> implements ISubject<T> {
|
|
39
|
+
private keyCounter;
|
|
40
|
+
private subscribers;
|
|
41
|
+
constructor();
|
|
42
|
+
next(value: T): void;
|
|
43
|
+
error(value: T): void;
|
|
44
|
+
protected _subscribe(emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface ILogger {
|
|
48
|
+
log: (entry: ILogInputEntry) => void;
|
|
49
|
+
createCustomLog: <TArgs extends unknown[]>(transform: (...args: TArgs) => ILogInputEntry) => (...args: TArgs) => void;
|
|
50
|
+
createComponentLog: (component: string) => IComponentLogger;
|
|
51
|
+
getAllLogs: () => ILogEntry[];
|
|
52
|
+
log$: IObservable<ILogEntry>;
|
|
53
|
+
}
|
|
54
|
+
interface ILogEntry {
|
|
55
|
+
/**
|
|
56
|
+
* Сообщение.
|
|
57
|
+
*/
|
|
58
|
+
message: string;
|
|
59
|
+
/**
|
|
60
|
+
* Компонент, в котором залогировано событие. (модуль, класс или функция)
|
|
61
|
+
*/
|
|
62
|
+
component: string;
|
|
63
|
+
/**
|
|
64
|
+
* Время, в которое случилось логируемое событие
|
|
65
|
+
*/
|
|
66
|
+
timestamp: number;
|
|
67
|
+
}
|
|
68
|
+
type IComponentLogger = (entry: IComponentLogEntry) => void;
|
|
69
|
+
type ILogInputEntry = Omit<ILogEntry, 'timestamp'>;
|
|
70
|
+
interface IComponentLogEntry extends Omit<ILogInputEntry, 'component'>, IOptionalComponent {
|
|
71
|
+
}
|
|
72
|
+
interface IOptionalComponent {
|
|
73
|
+
component?: ILogInputEntry['component'];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare class Logger implements ILogger {
|
|
77
|
+
log$: Subject<ILogEntry>;
|
|
78
|
+
private logs;
|
|
79
|
+
log: (inputEntry: ILogInputEntry) => void;
|
|
80
|
+
createCustomLog<TArgs extends unknown[]>(transform: (...args: TArgs) => ILogInputEntry): (...args: TArgs) => void;
|
|
81
|
+
createComponentLog(component: string): IComponentLogger;
|
|
82
|
+
getAllLogs: () => ILogEntry[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare const noop: () => void;
|
|
86
|
+
|
|
87
|
+
declare const assertNever: (x: never) => never;
|
|
88
|
+
declare const checkNever: (_x: never) => void;
|
|
89
|
+
|
|
90
|
+
declare function assertNonNullable<T>(value: T, failMessage?: string): asserts value is NonNullable<T>;
|
|
91
|
+
declare function assertNullable<T extends INullable = INullable>(value: unknown, failMessage?: string): asserts value is T;
|
|
92
|
+
declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
93
|
+
declare function isNullable<T extends INullable = INullable>(value: unknown): value is T;
|
|
94
|
+
type INullable = null | undefined;
|
|
95
|
+
|
|
96
|
+
declare const addScript: (scriptSrc: string, abortSignal: AbortSignal, timeout?: number) => Promise<void>;
|
|
97
|
+
|
|
98
|
+
type Seconds = number;
|
|
99
|
+
type Milliseconds = number;
|
|
100
|
+
type bps = number;
|
|
101
|
+
type Kbps = number;
|
|
102
|
+
type Mbps = number;
|
|
103
|
+
type Byte = number;
|
|
104
|
+
|
|
105
|
+
declare const now: () => Milliseconds;
|
|
106
|
+
|
|
107
|
+
type AbortableDecorator = <Params extends unknown[] = void[], Return = void>(signal: AbortSignal, createGenerator: (...param: Params) => AsyncGenerator<unknown, Return, unknown>) => (...param: Params) => Promise<Return | undefined>;
|
|
108
|
+
declare const abortable: AbortableDecorator;
|
|
109
|
+
|
|
110
|
+
type ExponentialBackoffConfig = Partial<{
|
|
111
|
+
start: Milliseconds;
|
|
112
|
+
factor: number;
|
|
113
|
+
min: Milliseconds;
|
|
114
|
+
max: Milliseconds;
|
|
115
|
+
random: number;
|
|
116
|
+
}>;
|
|
117
|
+
declare const getExponentialDelay: (errorsCount: number, { start, factor, max, min, random }?: ExponentialBackoffConfig) => Milliseconds;
|
|
118
|
+
|
|
119
|
+
declare class Subscription implements ISubscription {
|
|
120
|
+
private subscriptions;
|
|
121
|
+
unsubscribe(): void;
|
|
122
|
+
add(item: ISubscription | IUnsubscriber): ISubscription;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class ValueSubject<T> extends Subject<T> implements IValueSubject<T> {
|
|
126
|
+
private value;
|
|
127
|
+
constructor(initialValue: T);
|
|
128
|
+
next(value: T): void;
|
|
129
|
+
error(value: T): void;
|
|
130
|
+
getValue(): T;
|
|
131
|
+
protected _subscribe(emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Создаёт Observable, который состоит из объектов, ключами которых являются последние значения исходных Observable.
|
|
136
|
+
* Первое событие возникает тогда, когда каждый исходный Observable выдал хотя бы одно значение.
|
|
137
|
+
*/
|
|
138
|
+
type CombineObservables<T extends Record<string, IObservable<unknown>>> = {
|
|
139
|
+
[key in keyof T]: TypeOfObservable<T[key]>;
|
|
140
|
+
};
|
|
141
|
+
declare function combine<T extends Record<string, IObservable<unknown>>>(observables: T): IObservable<CombineObservables<T>>;
|
|
142
|
+
|
|
143
|
+
declare function merge<T1, T2>(v1: IObservable<T1>, v2: IObservable<T2>): IObservable<T1 | T2>;
|
|
144
|
+
declare function merge<T1, T2, T3>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>): IObservable<T1 | T2 | T3>;
|
|
145
|
+
declare function merge<T1, T2, T3, T4>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>): IObservable<T1 | T2 | T3 | T4>;
|
|
146
|
+
declare function merge<T1, T2, T3, T4, T5>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>): IObservable<T1 | T2 | T3 | T4 | T5>;
|
|
147
|
+
declare function merge<T1, T2, T3, T4, T5, T6>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>): IObservable<T1 | T2 | T3 | T4 | T5 | T6>;
|
|
148
|
+
declare function merge<T1, T2, T3, T4, T5, T6>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>): IObservable<T1 | T2 | T3 | T4 | T5 | T6>;
|
|
149
|
+
declare function merge<T1, T2, T3, T4, T5, T6, T7>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
|
|
150
|
+
declare function merge<T1, T2, T3, T4, T5, T6, T7, T8>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
|
151
|
+
declare function merge<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>, v9: IObservable<T9>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
|
152
|
+
declare function merge<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>, v9: IObservable<T9>, v10: IObservable<T10>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
|
|
153
|
+
declare function merge<R>(...observables: IObservable<unknown>[]): IObservable<R>;
|
|
154
|
+
|
|
155
|
+
declare const _default$3: (time: Milliseconds) => IObservable<void>;
|
|
156
|
+
|
|
157
|
+
declare const _default$2: (time: Milliseconds) => IObservable<void>;
|
|
158
|
+
|
|
159
|
+
declare const _default$1: <T>(values: T[]) => IObservable<T>;
|
|
160
|
+
|
|
161
|
+
interface IEventTarget {
|
|
162
|
+
addEventListener(type: string, handler: (...params: any[]) => void): void;
|
|
163
|
+
removeEventListener(type: string, handler: (...params: any[]) => void): void;
|
|
164
|
+
}
|
|
165
|
+
declare const _default: <T>(target: IEventTarget, eventName: string) => IObservable<T>;
|
|
166
|
+
|
|
167
|
+
declare function debounce<T>(time: Milliseconds, config?: {
|
|
168
|
+
leading: boolean;
|
|
169
|
+
trailing: boolean;
|
|
170
|
+
}): IOperator<T>;
|
|
171
|
+
|
|
172
|
+
declare function throttle<T>(time: number, config?: {
|
|
173
|
+
leading: boolean;
|
|
174
|
+
trailing: boolean;
|
|
175
|
+
}): IOperator<T>;
|
|
176
|
+
|
|
177
|
+
declare function filter<T, S extends T>(predicate: (value: T) => value is S): IOperator<T, S>;
|
|
178
|
+
declare function filter<T>(predicate: (value: T) => boolean): IOperator<T>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Пропускает только события, содержащие значения, отличные от предыдущего
|
|
182
|
+
*/
|
|
183
|
+
declare function filterChanged<T>(equal?: (prev: T, next: T) => boolean): IOperator<T>;
|
|
184
|
+
|
|
185
|
+
declare function map<T, S>(mapper: (value: T) => S): IOperator<T, S>;
|
|
186
|
+
|
|
187
|
+
declare function mapTo<T, S>(value: S): IOperator<T, S>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Отписывается от исходного потока после получения первого события.
|
|
191
|
+
*/
|
|
192
|
+
declare function once<T>(): IOperator<T>;
|
|
193
|
+
|
|
194
|
+
type IPair<T> = [previous: T, current: T];
|
|
195
|
+
declare function pairwise<T>(): IOperator<T, IPair<T>>;
|
|
196
|
+
|
|
197
|
+
declare function tap<T>(effect: (value: T) => void): IOperator<T>;
|
|
198
|
+
|
|
199
|
+
interface IError {
|
|
200
|
+
/**
|
|
201
|
+
* Код или другой идентификатор для статистики
|
|
202
|
+
*/
|
|
203
|
+
id: string;
|
|
204
|
+
category: ErrorCategory;
|
|
205
|
+
/**
|
|
206
|
+
* Сообщение по которому можно разобрать что случилось
|
|
207
|
+
*/
|
|
208
|
+
message: string;
|
|
209
|
+
/**
|
|
210
|
+
* Данные, полезные для отладки
|
|
211
|
+
*/
|
|
212
|
+
data?: any;
|
|
213
|
+
/**
|
|
214
|
+
* Возникшее исключение
|
|
215
|
+
*/
|
|
216
|
+
thrown?: Error | unknown;
|
|
217
|
+
}
|
|
218
|
+
declare enum ErrorCategory {
|
|
219
|
+
NETWORK = "network",
|
|
220
|
+
VIDEO_PIPELINE = "video_pipeline",
|
|
221
|
+
EXTERNAL_API = "external_api",
|
|
222
|
+
PARSER = "parser",
|
|
223
|
+
DOM = "dom",
|
|
224
|
+
WTF = "wtf"
|
|
225
|
+
}
|
|
226
|
+
interface IRange<Unit extends number = number> {
|
|
227
|
+
from: Unit;
|
|
228
|
+
to: Unit;
|
|
229
|
+
}
|
|
230
|
+
interface IRectangle<Unit extends number = number> {
|
|
231
|
+
width: Unit;
|
|
232
|
+
height: Unit;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { Byte, ErrorCategory, ExponentialBackoffConfig, IComponentLogEntry, IComponentLogger, IEmitter, IError, IListener, ILogEntry, ILogInputEntry, ILogger, IObservable, IOperator, IRange, IRectangle, ISubject, ISubscription, IUnsubscriber, IValue, IValueObservable, IValueSubject, Kbps, Logger, Mbps, Milliseconds, Observable, Seconds, Subject, Subscription, ValueSubject, abortable, addScript, assertNever, assertNonNullable, assertNullable, bps, checkNever, combine, debounce, filter, filterChanged, _default as fromEvent, getExponentialDelay, _default$2 as interval, isNonNullable, isNullable, map, mapTo, merge, noop, now, _default$1 as observableFrom, once, pairwise, tap, throttle, _default$3 as timeout };
|
package/package.json
CHANGED
package/Logger/Logger.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import Subject from '../reactive/Subject';
|
|
2
|
-
import type { ILogger, ILogInputEntry, IComponentLogger, ILogEntry } from './types';
|
|
3
|
-
export declare class Logger implements ILogger {
|
|
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
|
-
}
|
package/Logger/index.d.ts
DELETED
package/Logger/types.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { IObservable } from '../reactive/types';
|
|
2
|
-
export interface ILogger {
|
|
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
|
-
}
|
|
9
|
-
export interface ILogEntry {
|
|
10
|
-
/**
|
|
11
|
-
* Сообщение.
|
|
12
|
-
*/
|
|
13
|
-
message: string;
|
|
14
|
-
/**
|
|
15
|
-
* Компонент, в котором залогировано событие. (модуль, класс или функция)
|
|
16
|
-
*/
|
|
17
|
-
component: string;
|
|
18
|
-
/**
|
|
19
|
-
* Время, в которое случилось логируемое событие
|
|
20
|
-
*/
|
|
21
|
-
timestamp: number;
|
|
22
|
-
}
|
|
23
|
-
export declare type IComponentLogger = (entry: IComponentLogEntry) => void;
|
|
24
|
-
export declare type ILogInputEntry = Omit<ILogEntry, 'timestamp'>;
|
|
25
|
-
export interface IComponentLogEntry extends Omit<ILogInputEntry, 'component'>, IOptionalComponent {
|
|
26
|
-
}
|
|
27
|
-
interface IOptionalComponent {
|
|
28
|
-
component?: ILogInputEntry['component'];
|
|
29
|
-
}
|
|
30
|
-
export {};
|
package/es2015.cjs.d.ts
DELETED
package/es2015.esm.d.ts
DELETED
package/es2018.cjs.d.ts
DELETED
package/es2018.esm.d.ts
DELETED
package/esnext.esm.d.ts
DELETED
package/reactive/Observable.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { IEmitter, IListener, IObservable, IOperator, ISubscription, IUnsubscriber } from './types';
|
|
2
|
-
export default class Observable<T> implements IObservable<T> {
|
|
3
|
-
constructor(subscribe?: (emitter: IEmitter<T>) => IUnsubscriber | ISubscription | void);
|
|
4
|
-
subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
|
|
5
|
-
pipe(...operators: IOperator<unknown, unknown>[]): IObservable<unknown>;
|
|
6
|
-
protected _subscribe(_emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
7
|
-
}
|
package/reactive/Subject.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IEmitter, ISubject, ISubscription, IUnsubscriber } from './types';
|
|
2
|
-
import Observable from './Observable';
|
|
3
|
-
export default class Subject<T> extends Observable<T> implements ISubject<T> {
|
|
4
|
-
private keyCounter;
|
|
5
|
-
private subscribers;
|
|
6
|
-
constructor();
|
|
7
|
-
next(value: T): void;
|
|
8
|
-
error(value: T): void;
|
|
9
|
-
protected _subscribe(emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IEmitter, ISubscription, IUnsubscriber, IValueSubject } from './types';
|
|
2
|
-
import Subject from './Subject';
|
|
3
|
-
export default class ValueSubject<T> extends Subject<T> implements IValueSubject<T> {
|
|
4
|
-
private value;
|
|
5
|
-
constructor(initialValue: T);
|
|
6
|
-
next(value: T): void;
|
|
7
|
-
error(value: T): void;
|
|
8
|
-
getValue(): T;
|
|
9
|
-
protected _subscribe(emitter: IEmitter<T>): IUnsubscriber | ISubscription | void;
|
|
10
|
-
}
|
package/reactive/combine.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IObservable, TypeOfObservable } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Создаёт Observable, который состоит из объектов, ключами которых являются последние значения исходных Observable.
|
|
4
|
-
* Первое событие возникает тогда, когда каждый исходный Observable выдал хотя бы одно значение.
|
|
5
|
-
*/
|
|
6
|
-
declare type CombineObservables<T extends Record<string, IObservable<unknown>>> = {
|
|
7
|
-
[key in keyof T]: TypeOfObservable<T[key]>;
|
|
8
|
-
};
|
|
9
|
-
export default function combine<T extends Record<string, IObservable<unknown>>>(observables: T): IObservable<CombineObservables<T>>;
|
|
10
|
-
export {};
|
package/reactive/fromEvent.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { IObservable } from './types';
|
|
2
|
-
interface IEventTarget {
|
|
3
|
-
addEventListener(type: string, handler: (...params: any[]) => void): void;
|
|
4
|
-
removeEventListener(type: string, handler: (...params: any[]) => void): void;
|
|
5
|
-
}
|
|
6
|
-
declare const _default: <T>(target: IEventTarget, eventName: string) => IObservable<T>;
|
|
7
|
-
export default _default;
|
package/reactive/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export { default as Subscription } from './Subscription';
|
|
2
|
-
export { default as Observable } from './Observable';
|
|
3
|
-
export { default as Subject } from './Subject';
|
|
4
|
-
export { default as ValueSubject } from './ValueSubject';
|
|
5
|
-
export { default as combine } from './combine';
|
|
6
|
-
export { default as merge } from './merge';
|
|
7
|
-
export { default as timeout } from './timeout';
|
|
8
|
-
export { default as interval } from './interval';
|
|
9
|
-
export { default as observableFrom } from './observableFrom';
|
|
10
|
-
export { default as fromEvent } from './fromEvent';
|
|
11
|
-
export { default as debounce } from './operators/debounce';
|
|
12
|
-
export { default as throttle } from './operators/throttle';
|
|
13
|
-
export { default as filter } from './operators/filter';
|
|
14
|
-
export { default as filterChanged } from './operators/filterChanged';
|
|
15
|
-
export { default as map } from './operators/map';
|
|
16
|
-
export { default as mapTo } from './operators/mapTo';
|
|
17
|
-
export { default as once } from './operators/once';
|
|
18
|
-
export { default as pairwise } from './operators/pairwise';
|
|
19
|
-
export { default as tap } from './operators/tap';
|
|
20
|
-
export type { ISubscription, IUnsubscriber, IObservable, ISubject, IValueSubject, IValueObservable, IListener, IEmitter, IValue, IOperator, } from './types';
|
package/reactive/interval.d.ts
DELETED
package/reactive/merge.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IObservable } from './types';
|
|
2
|
-
export default function merge<T1, T2>(v1: IObservable<T1>, v2: IObservable<T2>): IObservable<T1 | T2>;
|
|
3
|
-
export default function merge<T1, T2, T3>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>): IObservable<T1 | T2 | T3>;
|
|
4
|
-
export default function merge<T1, T2, T3, T4>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>): IObservable<T1 | T2 | T3 | T4>;
|
|
5
|
-
export default function merge<T1, T2, T3, T4, T5>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>): IObservable<T1 | T2 | T3 | T4 | T5>;
|
|
6
|
-
export default function merge<T1, T2, T3, T4, T5, T6>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>): IObservable<T1 | T2 | T3 | T4 | T5 | T6>;
|
|
7
|
-
export default function merge<T1, T2, T3, T4, T5, T6>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>): IObservable<T1 | T2 | T3 | T4 | T5 | T6>;
|
|
8
|
-
export default function merge<T1, T2, T3, T4, T5, T6, T7>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
|
|
9
|
-
export default function merge<T1, T2, T3, T4, T5, T6, T7, T8>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
|
10
|
-
export default function merge<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>, v9: IObservable<T9>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
|
11
|
-
export default function merge<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1: IObservable<T1>, v2: IObservable<T2>, v3: IObservable<T3>, v4: IObservable<T4>, v5: IObservable<T5>, v6: IObservable<T6>, v7: IObservable<T7>, v8: IObservable<T8>, v9: IObservable<T9>, v10: IObservable<T10>): IObservable<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
|
|
12
|
-
export default function merge<R>(...observables: IObservable<unknown>[]): IObservable<R>;
|
package/reactive/timeout.d.ts
DELETED
package/reactive/types.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare type IUnsubscriber = () => void;
|
|
2
|
-
export interface ISubscription {
|
|
3
|
-
unsubscribe: IUnsubscriber;
|
|
4
|
-
add(item: ISubscription | IUnsubscriber): ISubscription;
|
|
5
|
-
}
|
|
6
|
-
export interface IObservable<T> {
|
|
7
|
-
subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
|
|
8
|
-
pipe<T1>(op1: IOperator<T, T1>): IObservable<T1>;
|
|
9
|
-
pipe<T1, T2>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>): IObservable<T2>;
|
|
10
|
-
pipe<T1, T2, T3>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>): IObservable<T3>;
|
|
11
|
-
pipe<T1, T2, T3, T4>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>): IObservable<T4>;
|
|
12
|
-
pipe<T1, T2, T3, T4, T5>(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>, op5: IOperator<T4, T5>): IObservable<T5>;
|
|
13
|
-
}
|
|
14
|
-
export interface IValue<T> {
|
|
15
|
-
getValue(): T;
|
|
16
|
-
}
|
|
17
|
-
export interface IEmitter<T> {
|
|
18
|
-
next(value: T): void;
|
|
19
|
-
error?(value: Error | unknown): void;
|
|
20
|
-
}
|
|
21
|
-
export interface IValueObservable<T> extends IObservable<T>, IValue<T> {
|
|
22
|
-
}
|
|
23
|
-
export interface ISubject<T> extends IEmitter<T>, IObservable<T> {
|
|
24
|
-
}
|
|
25
|
-
export interface IValueSubject<T> extends IEmitter<T>, IObservable<T>, IValue<T> {
|
|
26
|
-
}
|
|
27
|
-
export declare type IListener<T> = IEmitter<T> | ((value: T) => void);
|
|
28
|
-
export declare type IOperator<TInput, TOutput = TInput> = (input: IObservable<TInput>) => IObservable<TOutput>;
|
|
29
|
-
export declare type TypeOfObservable<TObservable> = TObservable extends IObservable<infer TType> ? TType : never;
|
package/types/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface IError {
|
|
2
|
-
/**
|
|
3
|
-
* Код или другой идентификатор для статистики
|
|
4
|
-
*/
|
|
5
|
-
id: string;
|
|
6
|
-
category: ErrorCategory;
|
|
7
|
-
/**
|
|
8
|
-
* Сообщение по которому можно разобрать что случилось
|
|
9
|
-
*/
|
|
10
|
-
message: string;
|
|
11
|
-
/**
|
|
12
|
-
* Данные, полезные для отладки
|
|
13
|
-
*/
|
|
14
|
-
data?: any;
|
|
15
|
-
/**
|
|
16
|
-
* Возникшее исключение
|
|
17
|
-
*/
|
|
18
|
-
thrown?: Error | unknown;
|
|
19
|
-
}
|
|
20
|
-
export declare enum ErrorCategory {
|
|
21
|
-
NETWORK = "network",
|
|
22
|
-
VIDEO_PIPELINE = "video_pipeline",
|
|
23
|
-
EXTERNAL_API = "external_api",
|
|
24
|
-
PARSER = "parser",
|
|
25
|
-
DOM = "dom",
|
|
26
|
-
WTF = "wtf"
|
|
27
|
-
}
|
|
28
|
-
export interface IRange<Unit extends number = number> {
|
|
29
|
-
from: Unit;
|
|
30
|
-
to: Unit;
|
|
31
|
-
}
|
|
32
|
-
export interface IRectangle<Unit extends number = number> {
|
|
33
|
-
width: Unit;
|
|
34
|
-
height: Unit;
|
|
35
|
-
}
|
package/utils/abortable.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare type AbortableDecorator = <Params extends unknown[] = void[], Return = void>(signal: AbortSignal, createGenerator: (...param: Params) => AsyncGenerator<unknown, Return, unknown>) => (...param: Params) => Promise<Return | undefined>;
|
|
2
|
-
export declare const abortable: AbortableDecorator;
|
|
3
|
-
export {};
|
package/utils/addScript.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const addScript: (scriptSrc: string, abortSignal: AbortSignal, timeout?: number) => Promise<void>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Milliseconds } from './semanticTypes';
|
|
2
|
-
export declare type ExponentialBackoffConfig = Partial<{
|
|
3
|
-
start: Milliseconds;
|
|
4
|
-
factor: number;
|
|
5
|
-
min: Milliseconds;
|
|
6
|
-
max: Milliseconds;
|
|
7
|
-
random: number;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const getExponentialDelay: (errorsCount: number, { start, factor, max, min, random }?: ExponentialBackoffConfig) => Milliseconds;
|
package/utils/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { noop } from './noop';
|
|
2
|
-
export { assertNever, checkNever } from './never';
|
|
3
|
-
export { isNonNullable, isNullable, assertNonNullable, assertNullable } from './nullable';
|
|
4
|
-
export { addScript } from './addScript';
|
|
5
|
-
export type { Milliseconds, bps, Byte, Seconds, Kbps, Mbps } from './semanticTypes';
|
|
6
|
-
export { now } from './now';
|
|
7
|
-
export { abortable } from './abortable';
|
|
8
|
-
export { getExponentialDelay, ExponentialBackoffConfig } from './exponentialBackoff';
|
package/utils/never.d.ts
DELETED
package/utils/noop.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const noop: () => void;
|
package/utils/now.d.ts
DELETED
package/utils/nullable.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare function assertNonNullable<T>(value: T, failMessage?: string): asserts value is NonNullable<T>;
|
|
2
|
-
export declare function assertNullable<T extends INullable = INullable>(value: unknown, failMessage?: string): asserts value is T;
|
|
3
|
-
export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
|
|
4
|
-
export declare function isNullable<T extends INullable = INullable>(value: unknown): value is T;
|
|
5
|
-
declare type INullable = null | undefined;
|
|
6
|
-
export {};
|
package/utils/semanticTypes.d.ts
DELETED