pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
9 lines (8 loc) • 14.9 kB
JavaScript
/*!
* PixiJS - v8.17.1
* Compiled Mon, 16 Mar 2026 09:23:43 UTC
*
* PixiJS is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/this.PIXI=this.PIXI||{};var gif_js=(function(D){"use strict";var ve=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ne(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function ye(a){return a&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function me(a){return a&&Object.prototype.hasOwnProperty.call(a,"default")&&Object.keys(a).length===1?a.default:a}function _e(a){if(Object.prototype.hasOwnProperty.call(a,"__esModule"))return a;var t=a.default;if(typeof t=="function"){var e=function i(){var l=!1;try{l=this instanceof i}catch(f){}return l?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(a).forEach(function(i){var l=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(e,i,l.get?l:{enumerable:!0,get:function(){return a[i]}})}),e}var T={},z={},F={},E;function q(){if(E)return F;E=1,Object.defineProperty(F,"__esModule",{value:!0}),F.loop=F.conditional=F.parse=void 0;var a=function i(l,f){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:p;if(Array.isArray(f))f.forEach(function(v){return i(l,v,p,h)});else if(typeof f=="function")f(l,p,h,i);else{var d=Object.keys(f)[0];Array.isArray(f[d])?(h[d]={},i(l,f[d],p,h[d])):h[d]=f[d](l,p,h,i)}return p};F.parse=a;var t=function(l,f){return function(p,h,d,v){f(p,h,d)&&v(p,l,h,d)}};F.conditional=t;var e=function(l,f){return function(p,h,d,v){for(var c=[],r=p.pos;f(p,h,d);){var n={};if(v(p,l,h,n),p.pos===r)break;r=p.pos,c.push(n)}return c}};return F.loop=e,F}var m={},G;function $(){if(G)return m;G=1,Object.defineProperty(m,"__esModule",{value:!0}),m.readBits=m.readArray=m.readUnsigned=m.readString=m.peekBytes=m.readBytes=m.peekByte=m.readByte=m.buildStream=void 0;var a=function(r){return{data:r,pos:0}};m.buildStream=a;var t=function(){return function(r){return r.data[r.pos++]}};m.readByte=t;var e=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(n){return n.data[n.pos+r]}};m.peekByte=e;var i=function(r){return function(n){return n.data.subarray(n.pos,n.pos+=r)}};m.readBytes=i;var l=function(r){return function(n){return n.data.subarray(n.pos,n.pos+r)}};m.peekBytes=l;var f=function(r){return function(n){return Array.from(i(r)(n)).map(function(u){return String.fromCharCode(u)}).join("")}};m.readString=f;var p=function(r){return function(n){var u=i(2)(n);return r?(u[1]<<8)+u[0]:(u[0]<<8)+u[1]}};m.readUnsigned=p;var h=function(r,n){return function(u,s,o){for(var y=typeof n=="function"?n(u,s,o):n,g=i(r),x=new Array(y),b=0;b<y;b++)x[b]=g(u);return x}};m.readArray=h;var d=function(r,n,u){for(var s=0,o=0;o<u;o++)s+=r[n+o]&&Math.pow(2,u-o-1);return s},v=function(r){return function(n){for(var u=t()(n),s=new Array(8),o=0;o<8;o++)s[7-o]=!!(u&1<<o);return Object.keys(r).reduce(function(y,g){var x=r[g];return x.length?y[g]=d(s,x.index,x.length):y[g]=s[x.index],y},{})}};return m.readBits=v,m}var N;function ie(){return N||(N=1,(function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var t=q(),e=$(),i={blocks:function(n){for(var u=0,s=[],o=n.data.length,y=0,g=(0,e.readByte)()(n);g!==u&&g;g=(0,e.readByte)()(n)){if(n.pos+g>=o){var x=o-n.pos;s.push((0,e.readBytes)(x)(n)),y+=x;break}s.push((0,e.readBytes)(g)(n)),y+=g}for(var b=new Uint8Array(y),I=0,_=0;_<s.length;_++)b.set(s[_],I),I+=s[_].length;return b}},l=(0,t.conditional)({gce:[{codes:(0,e.readBytes)(2)},{byteSize:(0,e.readByte)()},{extras:(0,e.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,e.readUnsigned)(!0)},{transparentColorIndex:(0,e.readByte)()},{terminator:(0,e.readByte)()}]},function(r){var n=(0,e.peekBytes)(2)(r);return n[0]===33&&n[1]===249}),f=(0,t.conditional)({image:[{code:(0,e.readByte)()},{descriptor:[{left:(0,e.readUnsigned)(!0)},{top:(0,e.readUnsigned)(!0)},{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{lct:(0,e.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,e.readArray)(3,function(r,n,u){return Math.pow(2,u.descriptor.lct.size+1)})},function(r,n,u){return u.descriptor.lct.exists}),{data:[{minCodeSize:(0,e.readByte)()},i]}]},function(r){return(0,e.peekByte)()(r)===44}),p=(0,t.conditional)({text:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{preData:function(n,u,s){return(0,e.readBytes)(s.text.blockSize)(n)}},i]},function(r){var n=(0,e.peekBytes)(2)(r);return n[0]===33&&n[1]===1}),h=(0,t.conditional)({application:[{codes:(0,e.readBytes)(2)},{blockSize:(0,e.readByte)()},{id:function(n,u,s){return(0,e.readString)(s.blockSize)(n)}},i]},function(r){var n=(0,e.peekBytes)(2)(r);return n[0]===33&&n[1]===255}),d=(0,t.conditional)({comment:[{codes:(0,e.readBytes)(2)},i]},function(r){var n=(0,e.peekBytes)(2)(r);return n[0]===33&&n[1]===254}),v=[{header:[{signature:(0,e.readString)(3)},{version:(0,e.readString)(3)}]},{lsd:[{width:(0,e.readUnsigned)(!0)},{height:(0,e.readUnsigned)(!0)},{gct:(0,e.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,e.readByte)()},{pixelAspectRatio:(0,e.readByte)()}]},(0,t.conditional)({gct:(0,e.readArray)(3,function(r,n){return Math.pow(2,n.lsd.gct.size+1)})},function(r,n){return n.lsd.gct.exists}),{frames:(0,t.loop)([l,h,d,f,p],function(r){var n=(0,e.peekByte)()(r);return n===33||n===44})}],c=v;a.default=c})(z)),z}var k={},H;function oe(){if(H)return k;H=1,Object.defineProperty(k,"__esModule",{value:!0}),k.deinterlace=void 0;var a=function(e,i){for(var l=new Array(e.length),f=e.length/i,p=function(u,s){var o=e.slice(s*i,(s+1)*i);l.splice.apply(l,[u*i,i].concat(o))},h=[0,4,2,1],d=[8,8,4,2],v=0,c=0;c<4;c++)for(var r=h[c];r<f;r+=d[c])p(r,v),v++;return l};return k.deinterlace=a,k}var A={},Y;function se(){if(Y)return A;Y=1,Object.defineProperty(A,"__esModule",{value:!0}),A.lzw=void 0;var a=function(e,i,l){var f=4096,p=-1,h=l,d,v,c,r,n,u,s,B,o,y,w,g,O,P,S,C,x=new Array(l),b=new Array(f),I=new Array(f),_=new Array(f+1);for(g=e,v=1<<g,n=v+1,d=v+2,s=p,r=g+1,c=(1<<r)-1,o=0;o<v;o++)b[o]=0,I[o]=o;var w,B,j,O,P,C,S;for(w=B=j=O=P=C=S=0,y=0;y<h;){if(P===0){if(B<r){w+=i[S]<<B,B+=8,S++;continue}if(o=w&c,w>>=r,B-=r,o>d||o==n)break;if(o==v){r=g+1,c=(1<<r)-1,d=v+2,s=p;continue}if(s==p){_[P++]=I[o],s=o,O=o;continue}for(u=o,o==d&&(_[P++]=O,o=s);o>v;)_[P++]=I[o],o=b[o];O=I[o]&255,_[P++]=O,d<f&&(b[d]=s,I[d]=O,d++,(d&c)===0&&d<f&&(r++,c+=d)),s=u}P--,x[C++]=_[P],y++}for(y=C;y<h;y++)x[y]=0;return x};return A.lzw=a,A}var K;function ue(){if(K)return T;K=1,Object.defineProperty(T,"__esModule",{value:!0}),T.decompressFrames=T.decompressFrame=T.parseGIF=void 0;var a=f(ie()),t=q(),e=$(),i=oe(),l=se();function f(c){return c&&c.__esModule?c:{default:c}}var p=function(r){var n=new Uint8Array(r);return(0,t.parse)((0,e.buildStream)(n),a.default)};T.parseGIF=p;var h=function(r){for(var n=r.pixels.length,u=new Uint8ClampedArray(n*4),s=0;s<n;s++){var o=s*4,y=r.pixels[s],g=r.colorTable[y]||[0,0,0];u[o]=g[0],u[o+1]=g[1],u[o+2]=g[2],u[o+3]=y!==r.transparentIndex?255:0}return u},d=function(r,n,u){if(!r.image){console.warn("gif frame does not have associated image.");return}var s=r.image,o=s.descriptor.width*s.descriptor.height,y=(0,l.lzw)(s.data.minCodeSize,s.data.blocks,o);s.descriptor.lct.interlaced&&(y=(0,i.deinterlace)(y,s.descriptor.width));var g={pixels:y,dims:{top:r.image.descriptor.top,left:r.image.descriptor.left,width:r.image.descriptor.width,height:r.image.descriptor.height}};return s.descriptor.lct&&s.descriptor.lct.exists?g.colorTable=s.lct:g.colorTable=n,r.gce&&(g.delay=(r.gce.delay||10)*10,g.disposalType=r.gce.extras.disposal,r.gce.extras.transparentColorGiven&&(g.transparentIndex=r.gce.transparentColorIndex)),u&&(g.patch=h(g)),g};T.decompressFrame=d;var v=function(r,n){return r.frames.filter(function(u){return u.image}).map(function(u){return d(u,r.gct,n)})};return T.decompressFrames=v,T}var L=ue(),xe=ne(L),de=Object.defineProperty,M=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,J=(a,t,e)=>t in a?de(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,ce=(a,t)=>{for(var e in t||(t={}))W.call(t,e)&&J(a,e,t[e]);if(M)for(var e of M(t))Z.call(t,e)&&J(a,e,t[e]);return a},le=(a,t)=>{var e={};for(var i in a)W.call(a,i)&&t.indexOf(i)<0&&(e[i]=a[i]);if(a!=null&&M)for(var i of M(a))t.indexOf(i)<0&&Z.call(a,i)&&(e[i]=a[i]);return e};class U{constructor(t){const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(l=>l.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(t,e){if(!t||t.byteLength===0)throw new Error("Invalid buffer");const i=b=>{var I;let _=null;for(const w of b.frames)_=(I=w.gce)!=null?I:_,"image"in w&&!("gce"in w)&&(w.gce=_)},l=L.parseGIF(t);i(l);const f=L.decompressFrames(l,!0),p=[],h=l.lsd.width,d=l.lsd.height,v=PIXI.DOMAdapter.get().createCanvas(h,d),c=v.getContext("2d",{willReadFrequently:!0}),r=PIXI.DOMAdapter.get().createCanvas(),n=r.getContext("2d");let u=0,s=null;const o=e!=null?e:{},{fps:y=30}=o,g=le(o,["fps"]),x=1e3/y;for(let b=0;b<f.length;b++){const{disposalType:I=2,delay:_=x,patch:w,dims:{width:B,height:j,left:O,top:P}}=f[b];r.width=B,r.height=j,n.clearRect(0,0,B,j);const C=n.createImageData(B,j);C.data.set(w),n.putImageData(C,0,0),I===3&&(s=c.getImageData(0,0,h,d)),c.drawImage(r,O,P);const S=c.getImageData(0,0,h,d);I===2?c.clearRect(0,0,h,d):I===3&&c.putImageData(s,0,0);const ae=PIXI.DOMAdapter.get().createCanvas(S.width,S.height);ae.getContext("2d").putImageData(S,0,0),p.push({start:u,end:u+_,texture:new PIXI.Texture({source:new PIXI.CanvasSource(ce({resource:ae},g))})}),u+=_}return v.width=v.height=0,r.width=r.height=0,new U(p)}}const Q={extension:PIXI.ExtensionType.Asset,detection:{test:async()=>!0,add:async a=>[...a,"gif"],remove:async a=>a.filter(t=>t!=="gif")},loader:{name:"gifLoader",id:"gif",test:a=>PIXI.path.extname(a)===".gif"||a.startsWith("data:image/gif"),load:async(a,t)=>{const e=await(await PIXI.DOMAdapter.get().fetch(a)).arrayBuffer();return U.from(e,t==null?void 0:t.data)},unload:async a=>{a.destroy()}}};var pe=Object.defineProperty,X=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,te=(a,t,e)=>t in a?pe(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,fe=(a,t)=>{for(var e in t||(t={}))V.call(t,e)&&te(a,e,t[e]);if(X)for(var e of X(t))ee.call(t,e)&&te(a,e,t[e]);return a},he=(a,t)=>{var e={};for(var i in a)V.call(a,i)&&t.indexOf(i)<0&&(e[i]=a[i]);if(a!=null&&X)for(var i of X(a))t.indexOf(i)<0&&ee.call(a,i)&&(e[i]=a[i]);return e};const re=class R extends PIXI.Sprite{constructor(...t){const e=t[0]instanceof U?{source:t[0]}:t[0],i=Object.assign({},R.defaultOptions,e),{source:l,fps:f,loop:p,animationSpeed:h,autoPlay:d,autoUpdate:v,onComplete:c,onFrameChange:r,onLoop:n}=i,u=he(i,["source","fps","loop","animationSpeed","autoPlay","autoUpdate","onComplete","onFrameChange","onLoop"]);super(fe({texture:PIXI.Texture.EMPTY},u)),this.animationSpeed=1,this.loop=!0,this.duration=0,this.autoPlay=!0,this.dirty=!1,this._currentFrame=0,this._autoUpdate=!1,this._isConnectedToTicker=!1,this._playing=!1,this._currentTime=0,this.onRender=()=>this._updateFrame(),this.texture=l.textures[0],this.duration=l.frames[l.frames.length-1].end,this._source=l,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:f,loop:p,animationSpeed:h,autoPlay:d,autoUpdate:v,onComplete:c,onFrameChange:r,onLoop:n}),this.currentFrame=0,d&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(PIXI.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(PIXI.Ticker.shared.add(this.update,this,PIXI.UPDATE_PRIORITY.HIGH),this._isConnectedToTicker=!0),!this.loop&&this.currentFrame===this._source.frames.length-1&&(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(t){var e,i;if(!this._playing)return;const l=this.animationSpeed*t.deltaTime/PIXI.Ticker.targetFPMS,f=this._currentTime+l,p=f%this.duration,h=this._source.frames.findIndex(d=>d.start<=p&&d.end>p);f>=this.duration?this.loop?(this._currentTime=p,this._updateFrameIndex(h),(e=this.onLoop)==null||e.call(this)):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),(i=this.onComplete)==null||i.call(this),this.stop()):(this._currentTime=p,this._updateFrameIndex(h))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(PIXI.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(PIXI.Ticker.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){var e;if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,(e=this.onFrameChange)==null||e.call(this,t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const t=new R({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return t.dirty=!0,t}};re.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let ge=re;return PIXI.extensions.add(Q),D.GifAsset=Q,D.GifSource=U,D.GifSprite=ge,D})({});Object.assign(this.PIXI,gif_js);
//# sourceMappingURL=gif.min.js.map