@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.
Files changed (47) hide show
  1. package/es2015.cjs.js +4 -4
  2. package/es2015.esm.js +4 -4
  3. package/es2018.cjs.js +4 -4
  4. package/es2018.esm.js +4 -4
  5. package/esnext.cjs.js +4 -4
  6. package/esnext.esm.js +4 -4
  7. package/index.d.ts +235 -4
  8. package/package.json +1 -1
  9. package/Logger/Logger.d.ts +0 -10
  10. package/Logger/index.d.ts +0 -2
  11. package/Logger/types.d.ts +0 -30
  12. package/es2015.cjs.d.ts +0 -4
  13. package/es2015.esm.d.ts +0 -4
  14. package/es2018.cjs.d.ts +0 -4
  15. package/es2018.esm.d.ts +0 -4
  16. package/esnext.esm.d.ts +0 -4
  17. package/reactive/Observable.d.ts +0 -7
  18. package/reactive/Subject.d.ts +0 -10
  19. package/reactive/Subscription.d.ts +0 -6
  20. package/reactive/ValueSubject.d.ts +0 -10
  21. package/reactive/combine.d.ts +0 -10
  22. package/reactive/fromEvent.d.ts +0 -7
  23. package/reactive/index.d.ts +0 -20
  24. package/reactive/interval.d.ts +0 -4
  25. package/reactive/merge.d.ts +0 -12
  26. package/reactive/observableFrom.d.ts +0 -3
  27. package/reactive/operators/debounce.d.ts +0 -6
  28. package/reactive/operators/filter.d.ts +0 -3
  29. package/reactive/operators/filterChanged.d.ts +0 -5
  30. package/reactive/operators/map.d.ts +0 -2
  31. package/reactive/operators/mapTo.d.ts +0 -2
  32. package/reactive/operators/once.d.ts +0 -5
  33. package/reactive/operators/pairwise.d.ts +0 -4
  34. package/reactive/operators/tap.d.ts +0 -2
  35. package/reactive/operators/throttle.d.ts +0 -5
  36. package/reactive/timeout.d.ts +0 -4
  37. package/reactive/types.d.ts +0 -29
  38. package/types/index.d.ts +0 -35
  39. package/utils/abortable.d.ts +0 -3
  40. package/utils/addScript.d.ts +0 -1
  41. package/utils/exponentialBackoff.d.ts +0 -9
  42. package/utils/index.d.ts +0 -8
  43. package/utils/never.d.ts +0 -2
  44. package/utils/noop.d.ts +0 -1
  45. package/utils/now.d.ts +0 -2
  46. package/utils/nullable.d.ts +0 -6
  47. package/utils/semanticTypes.d.ts +0 -6
package/es2015.cjs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @vkontakte/videoplayer-shared v1.0.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});class t{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=()=>{};class n{constructor(t){t&&(this._subscribe=t)}subscribe(n,s){var i;let o;o=s?'function'==typeof s?{next:s,error:r}:{next:t=>s.next(t),error:t=>{var e;return null===(e=s.error)||void 0===e?void 0:e.call(s,t)}}:{next:r,error:r};const a='function'==typeof n?{next:t=>{try{n(t)}catch(t){o.next(t)}},error:t=>o.next(t)}:{next:t=>n.next(t),error:t=>n.error?n.error(t):o.next(t)};let c;try{c=this._subscribe(a)}catch(t){null===(i=a.error)||void 0===i||i.call(a,t)}return(new t).add((()=>{switch(a.next=r,a.error=r,typeof c){case'function':return void c();case'object':return void c.unsubscribe();case'undefined':return;default:return e(c)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class s extends n{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 r;return null===(r=e.error)||void 0===r?void 0:r.call(e,t)}))}_subscribe(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}function i(t){return null!=t}function o(t){return null==t}var a;const c='function'==typeof(null===(a=window.performance)||void 0===a?void 0:a.now)?()=>window.performance.now():()=>Date.now();function u(t,e,r,n){return new(r||(r=Promise))((function(s,i){function o(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}const l={leading:!1,trailing:!0};class h{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,i(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const d={leading:!0,trailing:!1};class p{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,o(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,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class b{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const x={};class w{constructor(t,e){this.destination=t,this.predicate=e,this.lastValue=x}next(t){let e;try{e=this.lastValue===x||!this.predicate(this.lastValue,t),this.lastValue=t}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function v(t){return e=>new n((r=>e.subscribe(new f(r,t))))}class f{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class m{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class g{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}var y;exports.ErrorCategory=void 0,(y=exports.ErrorCategory||(exports.ErrorCategory={})).NETWORK='network',y.VIDEO_PIPELINE='video_pipeline',y.EXTERNAL_API='external_api',y.PARSER='parser',y.DOM='dom',y.WTF='wtf',exports.Logger=class{constructor(){this.log$=new s,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 r;try{r=t(...e)}catch(t){r={message:'error in `createCustomLog`',component:'Logger'}}this.log(r)}}createComponentLog(t){return this.createCustomLog((e=>Object.assign({component:t},e)))}},exports.Observable=n,exports.Subject=s,exports.Subscription=t,exports.ValueSubject=class extends s{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}},exports.abortable=(t,e)=>(...r)=>u(void 0,void 0,void 0,(function*(){var n;const s=e(...r);let i,o=t.aborted;for(;!o&&!t.aborted;){const t=yield s.next(i);o=null!==(n=t.done)&&void 0!==n&&n,i=t.value}return i})),exports.addScript=(t,e,r)=>new Promise(((n,s)=>{e.addEventListener('abort',(()=>{a(),u.remove()}));const i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{c&&clearTimeout(c),u.removeEventListener('load',o),u.removeEventListener('error',i)};let c;r&&(c=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)})),exports.assertNever=e,exports.assertNonNullable=function(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)},exports.assertNullable=function(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)},exports.checkNever=t=>{},exports.combine=function(e){return new n((r=>{const n={};let s=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in n||s--,n[t]=e,0===s&&r.next(n)})(e)))),new t)}))},exports.debounce=function(t,e=l){return r=>new n((n=>r.subscribe(new h(n,t,e))))},exports.filter=function(t){return e=>new n((r=>e.subscribe(new b(r,t))))},exports.filterChanged=function(t=((t,e)=>t===e)){return e=>new n((r=>e.subscribe(new w(r,t))))},exports.fromEvent=(t,e)=>new n((r=>{const n=t=>r.next(t);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)})),exports.getExponentialDelay=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=Math.pow(r,t),o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o},exports.interval=t=>new n((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),exports.isNonNullable=i,exports.isNullable=o,exports.map=v,exports.mapTo=function(t){return v((()=>t))},exports.merge=function(...e){return new n((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))},exports.noop=r,exports.now=c,exports.observableFrom=t=>new n((e=>{t.forEach((t=>e.next(t)))})),exports.once=function(){return t=>new n((e=>{let r=!1,n=!1;const s=t.subscribe((t=>{r||(r=!0,e.next(t)),n&&s.unsubscribe()}),(t=>{var i;r=!0,null===(i=e.error)||void 0===i||i.call(e,t),n&&s.unsubscribe()}));return n=!0,r&&s.unsubscribe(),s}))},exports.pairwise=function(){return t=>new n((e=>t.subscribe(new m(e))))},exports.tap=function(t){return e=>new n((r=>e.subscribe(new g(r,t))))},exports.throttle=function(t,e=d){return r=>new n((n=>r.subscribe(new p(n,t,e))))},exports.timeout=t=>new n((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)}));
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.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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 t{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=t=>{},n=()=>{};class s{constructor(t){t&&(this._subscribe=t)}subscribe(r,s){var i;let o;o=s?'function'==typeof s?{next:s,error:n}:{next:t=>s.next(t),error:t=>{var e;return null===(e=s.error)||void 0===e?void 0:e.call(s,t)}}:{next:n,error:n};const c='function'==typeof r?{next:t=>{try{r(t)}catch(t){o.next(t)}},error:t=>o.next(t)}:{next:t=>r.next(t),error:t=>r.error?r.error(t):o.next(t)};let a;try{a=this._subscribe(c)}catch(t){null===(i=c.error)||void 0===i||i.call(c,t)}return(new t).add((()=>{switch(c.next=n,c.error=n,typeof a){case'function':return void a();case'object':return void a.unsubscribe();case'undefined':return;default:return e(a)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class i extends s{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 r;return null===(r=e.error)||void 0===r?void 0:r.call(e,t)}))}_subscribe(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}class o{constructor(){this.log$=new i,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 r;try{r=t(...e)}catch(t){r={message:'error in `createCustomLog`',component:'Logger'}}this.log(r)}}createComponentLog(t){return this.createCustomLog((e=>Object.assign({component:t},e)))}}function c(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)}function a(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)}function u(t){return null!=t}function l(t){return null==t}const h=(t,e,r)=>new Promise(((n,s)=>{e.addEventListener('abort',(()=>{c(),u.remove()}));const i=()=>{c(),s()},o=()=>{c(),n()},c=()=>{a&&clearTimeout(a),u.removeEventListener('load',o),u.removeEventListener('error',i)};let a;r&&(a=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)}));var d;const b='function'==typeof(null===(d=window.performance)||void 0===d?void 0:d.now)?()=>window.performance.now():()=>Date.now();function w(t,e,r,n){return new(r||(r=Promise))((function(s,i){function o(t){try{a(n.next(t))}catch(t){i(t)}}function c(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,c)}a((n=n.apply(t,e||[])).next())}))}const v=(t,e)=>(...r)=>w(void 0,void 0,void 0,(function*(){var n;const s=e(...r);let i,o=t.aborted;for(;!o&&!t.aborted;){const t=yield s.next(i);o=null!==(n=t.done)&&void 0!==n&&n,i=t.value}return i})),f=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=Math.pow(r,t),o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};class x extends i{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 m(e){return new s((r=>{const n={};let s=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in n||s--,n[t]=e,0===s&&r.next(n)})(e)))),new t)}))}function p(...e){return new s((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))}var g=t=>new s((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)})),y=t=>new s((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),E=t=>new s((e=>{t.forEach((t=>e.next(t)))})),L=(t,e)=>new s((r=>{const n=t=>r.next(t);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}));const T={leading:!1,trailing:!0};function V(t,e=T){return r=>new s((n=>r.subscribe(new _(n,t,e))))}class _{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,u(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const O={leading:!0,trailing:!1};function C(t,e=O){return r=>new s((n=>r.subscribe(new M(n,t,e))))}class M{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,l(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,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function j(t){return e=>new s((r=>e.subscribe(new A(r,t))))}class A{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function I(t=((t,e)=>t===e)){return e=>new s((r=>e.subscribe(new k(r,t))))}const P={};class k{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(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function D(t){return e=>new s((r=>e.subscribe(new R(r,t))))}class R{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function N(t){return D((()=>t))}function $(){return t=>new s((e=>{let r=!1,n=!1;const s=t.subscribe((t=>{r||(r=!0,e.next(t)),n&&s.unsubscribe()}),(t=>{var i;r=!0,null===(i=e.error)||void 0===i||i.call(e,t),n&&s.unsubscribe()}));return n=!0,r&&s.unsubscribe(),s}))}function W(){return t=>new s((e=>t.subscribe(new F(e))))}class F{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function K(t){return e=>new s((r=>e.subscribe(new S(r,t))))}class S{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}var X;!function(t){t.NETWORK='network',t.VIDEO_PIPELINE='video_pipeline',t.EXTERNAL_API='external_api',t.PARSER='parser',t.DOM='dom',t.WTF='wtf'}(X||(X={}));export{X as ErrorCategory,o as Logger,s as Observable,i as Subject,t as Subscription,x as ValueSubject,v as abortable,h as addScript,e as assertNever,c as assertNonNullable,a as assertNullable,r as checkNever,m as combine,V as debounce,j as filter,I as filterChanged,L as fromEvent,f as getExponentialDelay,y as interval,u as isNonNullable,l as isNullable,D as map,N as mapTo,p as merge,n as noop,b as now,E as observableFrom,$ as once,W as pairwise,K as tap,C as throttle,g as timeout};
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.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});class t{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=()=>{};class s{constructor(t){t&&(this._subscribe=t)}subscribe(s,n){var i;let o;o=n?'function'==typeof n?{next:n,error:r}:{next:t=>n.next(t),error:t=>{var e;return null===(e=n.error)||void 0===e?void 0:e.call(n,t)}}:{next:r,error:r};const a='function'==typeof s?{next:t=>{try{s(t)}catch(t){o.next(t)}},error:t=>o.next(t)}:{next:t=>s.next(t),error:t=>s.error?s.error(t):o.next(t)};let c;try{c=this._subscribe(a)}catch(t){null===(i=a.error)||void 0===i||i.call(a,t)}return(new t).add((()=>{switch(a.next=r,a.error=r,typeof c){case'function':return void c();case'object':return void c.unsubscribe();case'undefined':return;default:return e(c)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class n extends s{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 r;return null===(r=e.error)||void 0===r?void 0:r.call(e,t)}))}_subscribe(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}function i(t){return null!=t}function o(t){return null==t}var a;const c='function'==typeof(null===(a=window.performance)||void 0===a?void 0:a.now)?()=>window.performance.now():()=>Date.now();const u={leading:!1,trailing:!0};class l{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,i(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const h={leading:!0,trailing:!1};class d{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,o(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,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class p{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const b={};class x{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(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function w(t){return e=>new s((r=>e.subscribe(new v(r,t))))}class v{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class f{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}class m{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}var g;exports.ErrorCategory=void 0,(g=exports.ErrorCategory||(exports.ErrorCategory={})).NETWORK='network',g.VIDEO_PIPELINE='video_pipeline',g.EXTERNAL_API='external_api',g.PARSER='parser',g.DOM='dom',g.WTF='wtf',exports.Logger=class{constructor(){this.log$=new n,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 r;try{r=t(...e)}catch(t){r={message:'error in `createCustomLog`',component:'Logger'}}this.log(r)}}createComponentLog(t){return this.createCustomLog((e=>({component:t,...e})))}},exports.Observable=s,exports.Subject=n,exports.Subscription=t,exports.ValueSubject=class extends n{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}},exports.abortable=(t,e)=>async(...r)=>{var s;const n=e(...r);let i,o=t.aborted;for(;!o&&!t.aborted;){const t=await n.next(i);o=null!==(s=t.done)&&void 0!==s&&s,i=t.value}return i},exports.addScript=(t,e,r)=>new Promise(((s,n)=>{e.addEventListener('abort',(()=>{a(),u.remove()}));const i=()=>{a(),n()},o=()=>{a(),s()},a=()=>{c&&clearTimeout(c),u.removeEventListener('load',o),u.removeEventListener('error',i)};let c;r&&(c=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)})),exports.assertNever=e,exports.assertNonNullable=function(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)},exports.assertNullable=function(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)},exports.checkNever=t=>{},exports.combine=function(e){return new s((r=>{const s={};let n=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in s||n--,s[t]=e,0===n&&r.next(s)})(e)))),new t)}))},exports.debounce=function(t,e=u){return r=>new s((s=>r.subscribe(new l(s,t,e))))},exports.filter=function(t){return e=>new s((r=>e.subscribe(new p(r,t))))},exports.filterChanged=function(t=((t,e)=>t===e)){return e=>new s((r=>e.subscribe(new x(r,t))))},exports.fromEvent=(t,e)=>new s((r=>{const s=t=>r.next(t);return t.addEventListener(e,s),()=>t.removeEventListener(e,s)})),exports.getExponentialDelay=(t,{start:e=0,factor:r=2,max:s=1/0,min:n=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,s),o=Math.max(o,n),o},exports.interval=t=>new s((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),exports.isNonNullable=i,exports.isNullable=o,exports.map=w,exports.mapTo=function(t){return w((()=>t))},exports.merge=function(...e){return new s((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))},exports.noop=r,exports.now=c,exports.observableFrom=t=>new s((e=>{t.forEach((t=>e.next(t)))})),exports.once=function(){return t=>new s((e=>{let r=!1,s=!1;const n=t.subscribe((t=>{r||(r=!0,e.next(t)),s&&n.unsubscribe()}),(t=>{var i;r=!0,null===(i=e.error)||void 0===i||i.call(e,t),s&&n.unsubscribe()}));return s=!0,r&&n.unsubscribe(),n}))},exports.pairwise=function(){return t=>new s((e=>t.subscribe(new f(e))))},exports.tap=function(t){return e=>new s((r=>e.subscribe(new m(r,t))))},exports.throttle=function(t,e=h){return r=>new s((s=>r.subscribe(new d(s,t,e))))},exports.timeout=t=>new s((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)}));
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.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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 t{constructor(){this.subscriptions=[]}unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=t=>{},n=()=>{};class s{constructor(t){t&&(this._subscribe=t)}subscribe(r,s){var i;let o;o=s?'function'==typeof s?{next:s,error:n}:{next:t=>s.next(t),error:t=>{var e;return null===(e=s.error)||void 0===e?void 0:e.call(s,t)}}:{next:n,error:n};const c='function'==typeof r?{next:t=>{try{r(t)}catch(t){o.next(t)}},error:t=>o.next(t)}:{next:t=>r.next(t),error:t=>r.error?r.error(t):o.next(t)};let a;try{a=this._subscribe(c)}catch(t){null===(i=c.error)||void 0===i||i.call(c,t)}return(new t).add((()=>{switch(c.next=n,c.error=n,typeof a){case'function':return void a();case'object':return void a.unsubscribe();case'undefined':return;default:return e(a)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class i extends s{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 r;return null===(r=e.error)||void 0===r?void 0:r.call(e,t)}))}_subscribe(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}class o{constructor(){this.log$=new i,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 r;try{r=t(...e)}catch(t){r={message:'error in `createCustomLog`',component:'Logger'}}this.log(r)}}createComponentLog(t){return this.createCustomLog((e=>({component:t,...e})))}}function c(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)}function a(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)}function u(t){return null!=t}function l(t){return null==t}const h=(t,e,r)=>new Promise(((n,s)=>{e.addEventListener('abort',(()=>{c(),u.remove()}));const i=()=>{c(),s()},o=()=>{c(),n()},c=()=>{a&&clearTimeout(a),u.removeEventListener('load',o),u.removeEventListener('error',i)};let a;r&&(a=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)}));var d;const b='function'==typeof(null===(d=window.performance)||void 0===d?void 0:d.now)?()=>window.performance.now():()=>Date.now(),w=(t,e)=>async(...r)=>{var n;const s=e(...r);let i,o=t.aborted;for(;!o&&!t.aborted;){const t=await s.next(i);o=null!==(n=t.done)&&void 0!==n&&n,i=t.value}return i},v=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};class f extends i{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 x(e){return new s((r=>{const n={};let s=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in n||s--,n[t]=e,0===s&&r.next(n)})(e)))),new t)}))}function m(...e){return new s((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))}var p=t=>new s((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)})),g=t=>new s((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),E=t=>new s((e=>{t.forEach((t=>e.next(t)))})),y=(t,e)=>new s((r=>{const n=t=>r.next(t);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}));const L={leading:!1,trailing:!0};function T(t,e=L){return r=>new s((n=>r.subscribe(new V(n,t,e))))}class V{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,u(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}const _={leading:!0,trailing:!1};function C(t,e=_){return r=>new s((n=>r.subscribe(new A(n,t,e))))}class A{constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,l(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,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function I(t){return e=>new s((r=>e.subscribe(new M(r,t))))}class M{constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function O(t=((t,e)=>t===e)){return e=>new s((r=>e.subscribe(new k(r,t))))}const P={};class k{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(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function D(t){return e=>new s((r=>e.subscribe(new R(r,t))))}class R{constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function j(t){return D((()=>t))}function N(){return t=>new s((e=>{let r=!1,n=!1;const s=t.subscribe((t=>{r||(r=!0,e.next(t)),n&&s.unsubscribe()}),(t=>{var i;r=!0,null===(i=e.error)||void 0===i||i.call(e,t),n&&s.unsubscribe()}));return n=!0,r&&s.unsubscribe(),s}))}function $(){return t=>new s((e=>t.subscribe(new W(e))))}class W{constructor(t){this.destination=t,this.hasLast=!1}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}function F(t){return e=>new s((r=>e.subscribe(new K(r,t))))}class K{constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){var e,r;null===(r=(e=this.destination).error)||void 0===r||r.call(e,t)}}var S;!function(t){t.NETWORK='network',t.VIDEO_PIPELINE='video_pipeline',t.EXTERNAL_API='external_api',t.PARSER='parser',t.DOM='dom',t.WTF='wtf'}(S||(S={}));export{S as ErrorCategory,o as Logger,s as Observable,i as Subject,t as Subscription,f as ValueSubject,w as abortable,h as addScript,e as assertNever,c as assertNonNullable,a as assertNullable,r as checkNever,x as combine,T as debounce,I as filter,O as filterChanged,y as fromEvent,v as getExponentialDelay,g as interval,u as isNonNullable,l as isNullable,D as map,j as mapTo,m as merge,n as noop,b as now,E as observableFrom,N as once,$ as pairwise,F as tap,C as throttle,p as timeout};
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.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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
- 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});class t{subscriptions=[];unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=()=>{};class s{constructor(t){t&&(this._subscribe=t)}subscribe(s,n){let i;i=n?'function'==typeof n?{next:n,error:r}:{next:t=>n.next(t),error:t=>n.error?.(t)}:{next:r,error:r};const o='function'==typeof s?{next:t=>{try{s(t)}catch(t){i.next(t)}},error:t=>i.next(t)}:{next:t=>s.next(t),error:t=>s.error?s.error(t):i.next(t)};let a;try{a=this._subscribe(o)}catch(t){o.error?.(t)}return(new t).add((()=>{switch(o.next=r,o.error=r,typeof a){case'function':return void a();case'object':return void a.unsubscribe();case'undefined':return;default:return e(a)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class n extends s{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(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}function i(t){return null!=t}function o(t){return null==t}const a='function'==typeof window.performance?.now?()=>window.performance.now():()=>Date.now();const c={leading:!1,trailing:!0};class u{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,i(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){this.destination.error?.(t)}}const l={leading:!0,trailing:!1};class h{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,o(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)}}class d{destination;predicate;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}const p={};class b{destination;predicate;lastValue=p;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.lastValue===p||!this.predicate(this.lastValue,t),this.lastValue=t}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function x(t){return e=>new s((r=>e.subscribe(new w(r,t))))}class w{destination;mapper;constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){this.destination.error?.(t)}}class f{destination;last;hasLast=!1;constructor(t){this.destination=t}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){this.destination.error?.(t)}}class m{destination;effect;constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){this.destination.error?.(t)}}var g;exports.ErrorCategory=void 0,(g=exports.ErrorCategory||(exports.ErrorCategory={})).NETWORK='network',g.VIDEO_PIPELINE='video_pipeline',g.EXTERNAL_API='external_api',g.PARSER='parser',g.DOM='dom',g.WTF='wtf',exports.Logger=class{log$=new n;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},exports.Observable=s,exports.Subject=n,exports.Subscription=t,exports.ValueSubject=class extends n{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}},exports.abortable=(t,e)=>async(...r)=>{const s=e(...r);let n,i=t.aborted;for(;!i&&!t.aborted;){const t=await s.next(n);i=t.done??!1,n=t.value}return n},exports.addScript=(t,e,r)=>new Promise(((s,n)=>{e.addEventListener('abort',(()=>{a(),u.remove()}));const i=()=>{a(),n()},o=()=>{a(),s()},a=()=>{c&&clearTimeout(c),u.removeEventListener('load',o),u.removeEventListener('error',i)};let c;r&&(c=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)})),exports.assertNever=e,exports.assertNonNullable=function(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)},exports.assertNullable=function(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)},exports.checkNever=t=>{},exports.combine=function(e){return new s((r=>{const s={};let n=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in s||n--,s[t]=e,0===n&&r.next(s)})(e)))),new t)}))},exports.debounce=function(t,e=c){return r=>new s((s=>r.subscribe(new u(s,t,e))))},exports.filter=function(t){return e=>new s((r=>e.subscribe(new d(r,t))))},exports.filterChanged=function(t=((t,e)=>t===e)){return e=>new s((r=>e.subscribe(new b(r,t))))},exports.fromEvent=(t,e)=>new s((r=>{const s=t=>r.next(t);return t.addEventListener(e,s),()=>t.removeEventListener(e,s)})),exports.getExponentialDelay=(t,{start:e=0,factor:r=2,max:s=1/0,min:n=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,s),o=Math.max(o,n),o},exports.interval=t=>new s((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),exports.isNonNullable=i,exports.isNullable=o,exports.map=x,exports.mapTo=function(t){return x((()=>t))},exports.merge=function(...e){return new s((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))},exports.noop=r,exports.now=a,exports.observableFrom=t=>new s((e=>{t.forEach((t=>e.next(t)))})),exports.once=function(){return t=>new s((e=>{let r=!1,s=!1;const n=t.subscribe((t=>{r||(r=!0,e.next(t)),s&&n.unsubscribe()}),(t=>{r=!0,e.error?.(t),s&&n.unsubscribe()}));return s=!0,r&&n.unsubscribe(),n}))},exports.pairwise=function(){return t=>new s((e=>t.subscribe(new f(e))))},exports.tap=function(t){return e=>new s((r=>e.subscribe(new m(r,t))))},exports.throttle=function(t,e=l){return r=>new s((s=>r.subscribe(new h(s,t,e))))},exports.timeout=t=>new s((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)}));
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.19
3
- * Wed, 14 Dec 2022 00:43:47 GMT
4
- * https://st.mycdn.me/static/vkontakte-videoplayer/1-0-19/doc/
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 t{subscriptions=[];unsubscribe(){const t=this.subscriptions;this.subscriptions=[],t.forEach((t=>'function'==typeof t?t():t.unsubscribe()))}add(t){return this.subscriptions.push(t),this}}const e=t=>{throw new Error(`${t} is value of unexpected type`)},r=t=>{},n=()=>{};class s{constructor(t){t&&(this._subscribe=t)}subscribe(r,s){let i;i=s?'function'==typeof s?{next:s,error:n}:{next:t=>s.next(t),error:t=>s.error?.(t)}:{next:n,error:n};const o='function'==typeof r?{next:t=>{try{r(t)}catch(t){i.next(t)}},error:t=>i.next(t)}:{next:t=>r.next(t),error:t=>r.error?r.error(t):i.next(t)};let a;try{a=this._subscribe(o)}catch(t){o.error?.(t)}return(new t).add((()=>{switch(o.next=n,o.error=n,typeof a){case'function':return void a();case'object':return void a.unsubscribe();case'undefined':return;default:return e(a)}}))}pipe(...t){return t.reduce(((t,e)=>e(t)),this)}_subscribe(t){}}class i extends s{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(e){const r=this.keyCounter++;return this.subscribers.set(r,e),(new t).add((()=>this.subscribers.delete(r)))}}class o{log$=new i;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 a(t,e='Assertion "value is not nullable" failed'){if(null==t)throw new Error(e)}function c(t,e='Assertion "value is nullable" failed'){if(null!=t)throw new Error(e)}function u(t){return null!=t}function h(t){return null==t}const l=(t,e,r)=>new Promise(((n,s)=>{e.addEventListener('abort',(()=>{a(),u.remove()}));const i=()=>{a(),s()},o=()=>{a(),n()},a=()=>{c&&clearTimeout(c),u.removeEventListener('load',o),u.removeEventListener('error',i)};let c;r&&(c=window.setTimeout(i,r));const u=document.createElement('script');u.addEventListener('load',o),u.addEventListener('error',i),u.src=t,document.head.appendChild(u)})),d='function'==typeof window.performance?.now?()=>window.performance.now():()=>Date.now(),b=(t,e)=>async(...r)=>{const n=e(...r);let s,i=t.aborted;for(;!i&&!t.aborted;){const t=await n.next(s);i=t.done??!1,s=t.value}return s},w=(t,{start:e=0,factor:r=2,max:n=1/0,min:s=e,random:i=0}={})=>{let o=e;return o*=r**t,o*=Math.random()*i*2-i+1,o=Math.round(o),o=Math.min(o,n),o=Math.max(o,s),o};class f extends i{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 m(e){return new s((r=>{const n={};let s=Object.keys(e).length;return Object.entries(e).reduce(((t,[e,i])=>t.add(i.subscribe((t=>e=>{t in n||s--,n[t]=e,0===s&&r.next(n)})(e)))),new t)}))}function p(...e){return new s((r=>e.reduce(((t,e)=>t.add(e.subscribe(r))),new t)))}var x=t=>new s((e=>{const r=window.setTimeout((()=>{try{e.next()}catch(t){if(!e.error)throw t;e.error(t)}}),t);return()=>window.clearTimeout(r)})),g=t=>new s((e=>{const r=window.setInterval((()=>e.next()),t);return()=>window.clearInterval(r)})),v=t=>new s((e=>{t.forEach((t=>e.next(t)))})),E=(t,e)=>new s((r=>{const n=t=>r.next(t);return t.addEventListener(e,n),()=>t.removeEventListener(e,n)}));const y={leading:!1,trailing:!0};function L(t,e=y){return r=>new s((n=>r.subscribe(new V(n,t,e))))}class V{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,u(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(t){if(!this.destination.error)throw t;this.destination.error(t)}this.timeout=void 0}),this.time)}error(t){this.destination.error?.(t)}}const T={leading:!0,trailing:!1};function _(t,e=T){return r=>new s((n=>r.subscribe(new C(n,t,e))))}class C{destination;time;config;lastValue;timeout;constructor(t,e,r){this.destination=t,this.time=e,this.config=r}next(t){this.lastValue=t,h(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 A(t){return e=>new s((r=>e.subscribe(new I(r,t))))}class I{destination;predicate;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.predicate(t)}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function M(t=((t,e)=>t===e)){return e=>new s((r=>e.subscribe(new P(r,t))))}const O={};class P{destination;predicate;lastValue=O;constructor(t,e){this.destination=t,this.predicate=e}next(t){let e;try{e=this.lastValue===O||!this.predicate(this.lastValue,t),this.lastValue=t}catch(t){throw this.error(t),t}e&&this.destination.next(t)}error(t){this.destination.error?.(t)}}function k(t){return e=>new s((r=>e.subscribe(new D(r,t))))}class D{destination;mapper;constructor(t,e){this.destination=t,this.mapper=e}next(t){let e;try{e=this.mapper(t)}catch(t){throw this.error(t),t}this.destination.next(e)}error(t){this.destination.error?.(t)}}function R(t){return k((()=>t))}function j(){return t=>new s((e=>{let r=!1,n=!1;const s=t.subscribe((t=>{r||(r=!0,e.next(t)),n&&s.unsubscribe()}),(t=>{r=!0,e.error?.(t),n&&s.unsubscribe()}));return n=!0,r&&s.unsubscribe(),s}))}function N(){return t=>new s((e=>t.subscribe(new $(e))))}class ${destination;last;hasLast=!1;constructor(t){this.destination=t}next(t){const e=this.last;this.last=t,this.hasLast?this.destination.next([e,t]):this.hasLast=!0}error(t){this.destination.error?.(t)}}function W(t){return e=>new s((r=>e.subscribe(new F(r,t))))}class F{destination;effect;constructor(t,e){this.destination=t,this.effect=e}next(t){try{this.effect(t)}catch(t){throw this.error(t),t}this.destination.next(t)}error(t){this.destination.error?.(t)}}var K;!function(t){t.NETWORK='network',t.VIDEO_PIPELINE='video_pipeline',t.EXTERNAL_API='external_api',t.PARSER='parser',t.DOM='dom',t.WTF='wtf'}(K||(K={}));export{K as ErrorCategory,o as Logger,s as Observable,i as Subject,t as Subscription,f as ValueSubject,b as abortable,l as addScript,e as assertNever,a as assertNonNullable,c as assertNullable,r as checkNever,m as combine,L as debounce,A as filter,M as filterChanged,E as fromEvent,w as getExponentialDelay,g as interval,u as isNonNullable,h as isNullable,k as map,R as mapTo,p as merge,n as noop,d as now,v as observableFrom,j as once,N as pairwise,W as tap,_ as throttle,x as timeout};
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
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-shared",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "author": "vk.com",
5
5
  "description": "Shared code for vk.com videoplayer",
6
6
  "homepage": "https://vk.com",
@@ -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
@@ -1,2 +0,0 @@
1
- export { Logger } from './Logger';
2
- export type { ILogger, ILogInputEntry, IComponentLogEntry, IComponentLogger, ILogEntry } from './types';
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
@@ -1,4 +0,0 @@
1
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
package/es2015.esm.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
package/es2018.cjs.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
package/es2018.esm.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
package/esnext.esm.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './Logger';
2
- export * from './utils';
3
- export * from './reactive';
4
- export * from './types';
@@ -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
- }
@@ -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,6 +0,0 @@
1
- import type { ISubscription, IUnsubscriber } from './types';
2
- export default class Subscription implements ISubscription {
3
- private subscriptions;
4
- unsubscribe(): void;
5
- add(item: ISubscription | IUnsubscriber): ISubscription;
6
- }
@@ -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
- }
@@ -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 {};
@@ -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;
@@ -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';
@@ -1,4 +0,0 @@
1
- import { Milliseconds } from '../utils';
2
- import type { IObservable } from './types';
3
- declare const _default: (time: Milliseconds) => IObservable<void>;
4
- export default _default;
@@ -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>;
@@ -1,3 +0,0 @@
1
- import type { IObservable } from './types';
2
- declare const _default: <T>(values: T[]) => IObservable<T>;
3
- export default _default;
@@ -1,6 +0,0 @@
1
- import type { Milliseconds } from '../../utils/semanticTypes';
2
- import type { IOperator } from '../types';
3
- export default function debounce<T>(time: Milliseconds, config?: {
4
- leading: boolean;
5
- trailing: boolean;
6
- }): IOperator<T>;
@@ -1,3 +0,0 @@
1
- import type { IOperator } from '../types';
2
- export default function filter<T, S extends T>(predicate: (value: T) => value is S): IOperator<T, S>;
3
- export default function filter<T>(predicate: (value: T) => boolean): IOperator<T>;
@@ -1,5 +0,0 @@
1
- import type { IOperator } from '../types';
2
- /**
3
- * Пропускает только события, содержащие значения, отличные от предыдущего
4
- */
5
- export default function filterChanged<T>(equal?: (prev: T, next: T) => boolean): IOperator<T>;
@@ -1,2 +0,0 @@
1
- import type { IOperator } from '../types';
2
- export default function map<T, S>(mapper: (value: T) => S): IOperator<T, S>;
@@ -1,2 +0,0 @@
1
- import type { IOperator } from '../types';
2
- export default function mapTo<T, S>(value: S): IOperator<T, S>;
@@ -1,5 +0,0 @@
1
- import type { IOperator } from '../types';
2
- /**
3
- * Отписывается от исходного потока после получения первого события.
4
- */
5
- export default function once<T>(): IOperator<T>;
@@ -1,4 +0,0 @@
1
- import type { IOperator } from '../types';
2
- declare type IPair<T> = [previous: T, current: T];
3
- export default function pairwise<T>(): IOperator<T, IPair<T>>;
4
- export {};
@@ -1,2 +0,0 @@
1
- import type { IOperator } from '../types';
2
- export default function tap<T>(effect: (value: T) => void): IOperator<T>;
@@ -1,5 +0,0 @@
1
- import type { IOperator } from '../types';
2
- export default function throttle<T>(time: number, config?: {
3
- leading: boolean;
4
- trailing: boolean;
5
- }): IOperator<T>;
@@ -1,4 +0,0 @@
1
- import { Milliseconds } from '../utils';
2
- import type { IObservable } from './types';
3
- declare const _default: (time: Milliseconds) => IObservable<void>;
4
- export default _default;
@@ -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
- }
@@ -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 {};
@@ -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
@@ -1,2 +0,0 @@
1
- export declare const assertNever: (x: never) => never;
2
- export declare const checkNever: (_x: never) => void;
package/utils/noop.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const noop: () => void;
package/utils/now.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Milliseconds } from './semanticTypes';
2
- export declare const now: () => Milliseconds;
@@ -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 {};
@@ -1,6 +0,0 @@
1
- export declare type Seconds = number;
2
- export declare type Milliseconds = number;
3
- export declare type bps = number;
4
- export declare type Kbps = number;
5
- export declare type Mbps = number;
6
- export declare type Byte = number;