mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-06 05:59:36 +01:00
2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
|
"use strict";(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[941],{7941:(t,e,i)=>{i.r(e),i.d(e,{default:()=>g});var s=i(7361),n=i(6926);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class a{constructor(t){this.worker=t,r(this,"requestStates",new Map),r(this,"requestStatesByCallback",new Map),this.subscribe()}request(t){const{worker:e,requestStates:i,requestStatesByCallback:s}=this,r=(0,n.Z)(i),a={type:"callMethod",messageId:r,...t},h={messageId:r},o=new Promise(((t,e)=>{Object.assign(h,{resolve:t,reject:e})}));if("function"==typeof a.args[a.args.length-1]){const t=a.args.pop();h.callback=t,s.set(t,h)}return i.set(r,h),o.catch((()=>{})).finally((()=>{i.delete(r),h.callback&&s.delete(h.callback)})),e.postMessage(a),o}cancelCallback(t){t.isCanceled=!0;const{messageId:e}=this.requestStatesByCallback.get(t)||{};e&&this.worker.postMessage({type:"cancelProgress",messageId:e})}subscribe(){const{worker:t,requestStates:e}=this;t.addEventListener("message",(({data:t})=>{if("methodResponse"===t.type){const i=e.get(t.messageId);i&&(t.error?i.reject(t.error):i.resolve(t.response))}else if("methodCallback"===t.type){const i=e.get(t.messageId);i&&i.callback&&i.callback(...t.callbackArgs)}else if("unhandledError"===t.type)throw t.error}))}}var h=i(9933),o=i(3570);function d(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const c=s.wB?.75:1,u=.75,m=s.s$?2:4,l=new Array(4).fill(void 0).map((()=>new a(new Worker(new URL(i.p+i.u(354),i.b)))));let p=-1;const g=class{constructor(t,e,i,s={},n){this.id=t,this.container=e,this.animationData=i,this.params=s,this.onLoad=n,d(this,"imgSize",void 0),d(this,"key",void 0),d(this,"msPerFrame",void 0),d(this,"reduceFactor",void 0),d(this,"cacheModulo",void 0),d(this,"chunkSize",void 0),d(this,"workerIndex",void 0),d(this,"chunks",[]),d(this,"framesCount",void 0),d(this,"chunksCount",void 0),d(this,"canvas",document.createElement("canvas")),d(this,"ctx",this.canvas.getContext("2d")),d(this,"isAnimating",!1),d(this,"isWaiting",!0),d(this,"isOnLoadFired",!1),d(this,"isDestroyed",!1),d(this,"approxFrameIndex",0),d(this,"prevFrameIndex",-1),d(this,"stopFrameIndex",0),d(this,"speed",1),d(this,"direction",1),d(this,"lastRenderAt",void 0),this.initContainer(),this.initConfig(),this.initRenderer()}isPlaying(){return this.isAnimating||this.isWaiting}play(){this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}pause(){this.isWaiting?this.stopFrameIndex=this.approxFrameIndex:this.isAnimating=!1;const t=this.getChunkIndex(this.approxFrameIndex);this.chunks=this.chunks.map(((e,i)=>i===t?e:void 0))}goToAndPlay(t){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=void 0,this.direction=1,this.doPlay()}goToAndStop(t){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=Math.floor(t/this.reduceFactor),this.direction=1,this.doPlay()}playSegment([t,e]){this.approxFrameIndex=Math.floor(t/this.reduceFactor),this.stopFrameIndex=Math.floor(e/this.reduceFactor),this.direction=t<e?1:-1,this.doPlay()}setSpeed(t){this.speed=t}destroy(){this.isDestroyed=!0,this.pause(),this.destroyRenderer(),this.destroyContainer()}initContainer(){if(!(this.container.parentNode instanceof HTMLElement))throw new Error("[RLottie] Container is not mounted");let{size:t}=this.params;if(!t&&(t=this.container.offsetWidth||parseInt(this.container.style.width,10)||this.container.parentNode.offsetWidth,!t))throw new Error("[RLottie] Failed to detect width from container");this.canvas.style.width=`${t}px`,this.canvas.style.height=`${t}px`;const{isLowPriority:e,quality:i=(e?u:c)}=this.params,n=Math.round(t*Math.max(s.cL*i,1));this.canvas.width=n,this.canvas.height=n,this.container.appendChild(this.canvas),this.imgSize=n}initConfig(){this.key=`${this.id}_${this.imgSize}`;const{isLowPriority:t}=this.params,e=t?30:60,i=this.animationData.fr||e;this.reduceFactor=i%e==0?i/e:1,this.msPerFrame=1e3/(i/this.reduceFactor),this.cacheModulo=t?0:m,this.chunkSize=1}destroyCo
|
||
|
//# sourceMappingURL=941.74ee93d332e344855ed7.js.map
|