@taole/giftstage 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gift-stage.cjs.js +1 -1
- package/dist/gift-stage.es.js +1 -1
- package/package.json +1 -1
package/dist/gift-stage.cjs.js
CHANGED
|
@@ -8635,5 +8635,5 @@ async function xu(r) {
|
|
|
8635
8635
|
v_texcoord = a_texCoord;
|
|
8636
8636
|
v_alpha_texCoord = a_alpha_texCoord;
|
|
8637
8637
|
}
|
|
8638
|
-
`;function hf(i,A,t,e){const g=new Float32Array(t.size*dn),I=A.get(e);if(!I||I.length===0)return g;const[s,n]=i.info.rgbFrame;let B=0;for(const C of I){const Q=t.get(String(C.srcId));if(!Q)continue;if(B+dn>g.length)break;const[a,E,r,o]=C.frame,[h,c,f,l]=C.mFrame,u=fn(a+s,E+n,r,o,i.info.videoW,i.info.videoH),w=fn(h,c,f,l,i.info.videoW,i.info.videoH);g[B++]=Q,g[B++]=u[0],g[B++]=u[1],g[B++]=u[2],g[B++]=u[3],g[B++]=w[0],g[B++]=w[1],g[B++]=w[2],g[B++]=w[3]}return g}class cf{constructor(A,t,e,g,I){this.config=A,this.frameMap=t,dA(this,"canvas"),dA(this,"gl"),dA(this,"program"),dA(this,"vertexShader"),dA(this,"fragmentShader"),dA(this,"vertexBuffer"),dA(this,"videoTexture"),dA(this,"imagePosLoc"),dA(this,"resourceEntries"),dA(this,"textureUnitBySrcId",new Map);var s;if(e.size===0)throw new Error("VAP mix composer requires at least one slot resource");this.canvas=Qf(g,I);const n=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1})||this.canvas.getContext("webgl",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1})||this.canvas.getContext("experimental-webgl");if(!n)throw new Error("VAP mixed rendering requires WebGL support");this.gl=n;const B=Math.max(1,n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS)),C=Math.max(0,B-1),Q=[];let a=1;for(const u of(s=A.src)!=null?s:[]){const w=e.get(String(u.srcId));if(!w)continue;if(a>C){console.warn("[GiftStage] VAP mixed resources exceed texture unit limit, skipping",{srcId:u.srcId,srcTag:u.srcTag,maxUnits:B});continue}const y=QC(n,a,w.source,!0),m={srcId:String(u.srcId),unit:a,texture:y};Q.push(m),this.textureUnitBySrcId.set(m.srcId,m.unit),a++}if(Q.length===0)throw new Error("VAP mixed rendering could not bind any slot resources");this.resourceEntries=Q;const E=af(n,of,rf(this.resourceEntries.length));this.program=E.program,this.vertexShader=E.vertexShader,this.fragmentShader=E.fragmentShader,this.imagePosLoc=n.getUniformLocation(this.program,"image_pos"),this.videoTexture=QC(n,0);const r=n.getUniformLocation(this.program,"u_image_video");r!==null&&n.uniform1i(r,0);for(const u of this.resourceEntries){const w=n.getUniformLocation(this.program,`u_image${u.unit}`);w!==null&&n.uniform1i(w,u.unit)}const o=n.createBuffer();if(!o)throw new Error("Failed to create VAP mix vertex buffer");this.vertexBuffer=o,n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bufferData(n.ARRAY_BUFFER,Ef(A.info),n.STATIC_DRAW);const h=6*Float32Array.BYTES_PER_ELEMENT,c=n.getAttribLocation(this.program,"a_position"),f=n.getAttribLocation(this.program,"a_texCoord"),l=n.getAttribLocation(this.program,"a_alpha_texCoord");n.enableVertexAttribArray(c),n.vertexAttribPointer(c,2,n.FLOAT,!1,h,0),n.enableVertexAttribArray(f),n.vertexAttribPointer(f,2,n.FLOAT,!1,h,2*Float32Array.BYTES_PER_ELEMENT),n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,h,4*Float32Array.BYTES_PER_ELEMENT),n.viewport(0,0,this.canvas.width,this.canvas.height),n.disable(n.BLEND),n.disable(n.DEPTH_TEST),n.clearColor(0,0,0,0),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE)}render(A,t){const e=this.gl;e.useProgram(this.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.videoTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,A),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,0);const g=hf(this.config,this.frameMap,this.textureUnitBySrcId,t);return this.imagePosLoc!==null&&e.uniform1fv(this.imagePosLoc,g),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_STRIP,0,4),this.canvas}destroy(){const A=this.gl;for(const e of this.resourceEntries)A.deleteTexture(e.texture);A.deleteTexture(this.videoTexture),A.deleteBuffer(this.vertexBuffer),A.deleteProgram(this.program),A.deleteShader(this.vertexShader),A.deleteShader(this.fragmentShader);const t=A.getExtension("WEBGL_lose_context");t==null||t.loseContext()}}var lf=Object.defineProperty,df=(i,A,t)=>A in i?lf(i,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[A]=t,GA=(i,A,t)=>df(i,typeof A!="symbol"?A+"":A,t);const _Q=1397178947,JQ=12,ff=8;class uf{constructor(A=1024){GA(this,"buffer"),GA(this,"view"),GA(this,"bytes"),GA(this,"offset",0),GA(this,"encoder",new TextEncoder),this.buffer=new ArrayBuffer(A),this.view=new DataView(this.buffer),this.bytes=new Uint8Array(this.buffer)}ensure(A){const t=this.offset+A;if(t<=this.buffer.byteLength)return;let e=this.buffer.byteLength;for(;e<t;)e*=2;const g=new ArrayBuffer(e);new Uint8Array(g).set(this.bytes.subarray(0,this.offset)),this.buffer=g,this.view=new DataView(this.buffer),this.bytes=new Uint8Array(this.buffer)}u8(A){this.ensure(1),this.view.setUint8(this.offset,A),this.offset+=1}u16(A){this.ensure(2),this.view.setUint16(this.offset,A,!0),this.offset+=2}u32(A){this.ensure(4),this.view.setUint32(this.offset,A,!0),this.offset+=4}f32(A){this.ensure(4),this.view.setFloat32(this.offset,A,!0),this.offset+=4}bytesValue(A){this.u32(A.byteLength),this.ensure(A.byteLength),this.bytes.set(A,this.offset),this.offset+=A.byteLength}string(A){this.bytesValue(this.encoder.encode(A))}finish(){return this.buffer.slice(0,this.offset)}}class wf{constructor(A){GA(this,"view"),GA(this,"bytes"),GA(this,"offset",0),GA(this,"decoder",new TextDecoder),this.view=new DataView(A),this.bytes=new Uint8Array(A)}u8(){const A=this.view.getUint8(this.offset);return this.offset+=1,A}u16(){const A=this.view.getUint16(this.offset,!0);return this.offset+=2,A}u32(){const A=this.view.getUint32(this.offset,!0);return this.offset+=4,A}f32(){const A=this.view.getFloat32(this.offset,!0);return this.offset+=4,A}bytesValue(){const A=this.u32(),t=this.bytes.slice(this.offset,this.offset+A);return this.offset+=A,t}string(){return this.decoder.decode(this.bytesValue())}}function Df(i){var A,t;let e=0;for(const g of i.atlasPages)e+=g.imageBytes.byteLength;for(const[g,I]of i.audioBlobs)e+=g.length*2+I.byteLength;for(const[g]of i.atlasRects)e+=g.length*2+20;for(const g of i.sprites){e+=g.imageKey.length*2+g.frames.length*64;for(const I of g.frames)if(e+=I.clipPath.length*2,I.shapes)for(const s of I.shapes)e+=((t=(A=s.pathData)==null?void 0:A.length)!=null?t:0)*2+96}return e}function pf(i,A){var t;let e=0;A.fill&&(e|=1),A.stroke&&(e|=2),i.u8(e),A.fill&&(i.f32(A.fill.r),i.f32(A.fill.g),i.f32(A.fill.b),i.f32(A.fill.a)),A.stroke&&(i.f32(A.stroke.r),i.f32(A.stroke.g),i.f32(A.stroke.b),i.f32(A.stroke.a)),i.f32((t=A.strokeWidth)!=null?t:0)}function yf(i){const A=i.u8(),t=A&1?{r:i.f32(),g:i.f32(),b:i.f32(),a:i.f32()}:null,e=A&2?{r:i.f32(),g:i.f32(),b:i.f32(),a:i.f32()}:null;return{fill:t,stroke:e,strokeWidth:i.f32()}}function mf(i,A){var t,e,g,I;i.u8(A.kind==="path"?0:A.kind==="rect"?1:2),i.string((t=A.pathData)!=null?t:"");const s=(e=A.rect)!=null?e:{x:0,y:0,width:0,height:0,cornerRadius:0};i.f32(s.x),i.f32(s.y),i.f32(s.width),i.f32(s.height),i.f32((g=s.cornerRadius)!=null?g:0);const n=(I=A.ellipse)!=null?I:{x:0,y:0,radiusX:0,radiusY:0};i.f32(n.x),i.f32(n.y),i.f32(n.radiusX),i.f32(n.radiusY),pf(i,A.style),i.f32(A.transform.a),i.f32(A.transform.b),i.f32(A.transform.c),i.f32(A.transform.d),i.f32(A.transform.tx),i.f32(A.transform.ty)}function Gf(i){const A=i.u8(),t=i.string(),e={x:i.f32(),y:i.f32(),width:i.f32(),height:i.f32(),cornerRadius:i.f32()},g={x:i.f32(),y:i.f32(),radiusX:i.f32(),radiusY:i.f32()},I=yf(i),s={a:i.f32(),b:i.f32(),c:i.f32(),d:i.f32(),tx:i.f32(),ty:i.f32()};return A===1?{kind:"rect",rect:e,style:I,transform:s}:A===2?{kind:"ellipse",ellipse:g,style:I,transform:s}:{kind:"path",pathData:t,style:I,transform:s}}function aC(i){const A=new Uint8Array(i.byteLength);return A.set(i),A.buffer}function Ff(i){var A;const t=new uf(ff+i.atlasPages.reduce((e,g)=>e+g.imageBytes.byteLength+12,0)+i.sprites.length*64+i.audioBlobs.size*32+i.atlasRects.size*32);t.u32(_Q),t.u16(JQ),t.u16(0),t.f32(i.params.viewBoxWidth),t.f32(i.params.viewBoxHeight),t.f32(i.params.fps),t.u32(i.params.frames),t.u32(i.atlasPages.length);for(const e of i.atlasPages)t.u32(e.width),t.u32(e.height),t.bytesValue(new Uint8Array(e.imageBytes));t.u32(i.atlasRects.size);for(const[e,g]of i.atlasRects)t.string(e),t.u32((A=g.textureIndex)!=null?A:0),t.f32(g.x),t.f32(g.y),t.f32(g.w),t.f32(g.h);t.u32(i.audios.length);for(const e of i.audios)t.string(e.audioKey),t.u32(e.startFrame),t.u32(e.endFrame),t.f32(e.startTime),t.f32(e.totalTime);t.u32(i.audioBlobs.size);for(const[e,g]of i.audioBlobs)t.string(e),t.bytesValue(new Uint8Array(g));t.u32(i.sprites.length);for(const e of i.sprites){t.string(e.imageKey),t.u32(e.frames.length);for(const g of e.frames){let I=0;if(g.layout&&(I|=1),g.transform&&(I|=2),g.clipPath&&(I|=4),g.shapes&&g.shapes.length>0&&(I|=8),t.u8(I),t.f32(g.alpha),g.layout&&(t.f32(g.layout.x),t.f32(g.layout.y),t.f32(g.layout.width),t.f32(g.layout.height)),g.transform&&(t.f32(g.transform.a),t.f32(g.transform.b),t.f32(g.transform.c),t.f32(g.transform.d),t.f32(g.transform.tx),t.f32(g.transform.ty)),g.clipPath&&t.string(g.clipPath),g.shapes&&g.shapes.length>0){t.u32(g.shapes.length);for(const s of g.shapes)mf(t,s)}}}return t.finish()}function Sf(i){const A=new wf(i);if(A.u32()!==_Q)throw new Error("Invalid SVGA cache binary magic");if(A.u16()!==JQ)throw new Error("Unsupported SVGA cache binary version");A.u16();const t={viewBoxWidth:A.f32(),viewBoxHeight:A.f32(),fps:A.f32(),frames:A.u32()},e=A.u32(),g=[];for(let r=0;r<e;r++)g.push({width:A.u32(),height:A.u32(),imageBytes:aC(A.bytesValue())});const I=A.u32(),s=new Map;for(let r=0;r<I;r++){const o=A.string(),h=A.u32();s.set(o,{textureIndex:h,x:A.f32(),y:A.f32(),w:A.f32(),h:A.f32()})}const n=A.u32(),B=[];for(let r=0;r<n;r++)B.push({audioKey:A.string(),startFrame:A.u32(),endFrame:A.u32(),startTime:A.f32(),totalTime:A.f32()});const C=A.u32(),Q=new Map;for(let r=0;r<C;r++){const o=A.string();Q.set(o,aC(A.bytesValue()))}const a=A.u32(),E=[];for(let r=0;r<a;r++){const o=A.string(),h=A.u32(),c=[];for(let f=0;f<h;f++){const l=A.u8(),u=A.f32(),w=l&1?{x:A.f32(),y:A.f32(),width:A.f32(),height:A.f32()}:null,y=l&2?{a:A.f32(),b:A.f32(),c:A.f32(),d:A.f32(),tx:A.f32(),ty:A.f32()}:null,m=l&4?A.string():"";let p=null;if(l&8){const N=A.u32();p=[];for(let U=0;U<N;U++)p.push(Gf(A))}c.push({alpha:u,layout:w,transform:y,clipPath:m,shapes:p})}E.push({imageKey:o,frames:c})}return{params:t,sprites:E,audios:B,audioBlobs:Q,atlasRects:s,atlasPages:g}}function oB(i){return`svga-asset:${i}`}function hB(i){return`svga-asset-bin:${i}`}async function Nf(i){const A=nE(oB(i),"svga-asset");if(A)return A;const t=await BE(hB(i));if(!t)return null;try{const e=Sf(t);return FC(oB(i),"svga-asset",e,t.byteLength),e}catch(e){return QE(hB(i)),null}}async function Pn(i,A){const t=Ff(A);FC(oB(i),"svga-asset",A,Math.max(t.byteLength,Df(A))),await CE(hB(i),t)}function bA(i){return typeof i=="number"&&Number.isFinite(i)&&i>0}function Rf(i,A){const t=bA(i)?i*.5:0,e=bA(A)?A:0;return{width:t,height:e}}function Uf(i,A,t,e){const g=bA(A.width)?A.width:void 0,I=bA(A.height)?A.height:void 0,s=bA(i.width)?i.width:void 0,n=bA(i.height)?i.height:void 0,B=i.useOriginalSize===!0;if(s&&n)return{width:s,height:n};if(s)return g&&I?{width:s,height:s*I/g}:{width:s,height:s};if(n)return g&&I?{width:n*g/I,height:n}:{width:n,height:n};let C=g!=null?g:0,Q=I!=null?I:0;if(C>0&&Q>0&&bA(t)&&bA(e)&&(!B||C>t||Q>e)){const a=Math.min(t/C,e/Q);C*=a,Q*=a}return{width:C,height:Q}}var kf=Object.defineProperty,Mf=(i,A,t)=>A in i?kf(i,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[A]=t,z=(i,A,t)=>Mf(i,typeof A!="symbol"?A+"":A,t);function EC(i){return Number.isFinite(i)?Math.max(0,Math.min(1,i)):1}function xf(i){return"delayMs"in i}const ls=class OA{constructor(A){z(this,"sharedSVGAEntities",new Map),z(this,"pendingSharedSVGAEntities",new Map),z(this,"sharedVideoSources",new Map),z(this,"sharedHtmlVideos",new Map),z(this,"sharedVideoTextures",new Map),z(this,"pendingSharedHtmlVideos",new Map),z(this,"completedPlaybackSlots",new Set),z(this,"playbackCompleteWaiters",new Map),z(this,"canvas"),z(this,"backend",null),z(this,"manager",null),z(this,"options"),z(this,"ready"),z(this,"destroyed",!1),z(this,"resizeObserver",null),z(this,"nextRenderOrder",0),z(this,"onWindowLayout",()=>{this.destroyed||this.syncCanvasSize()}),this.options=A,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position:fixed;inset:0;width:100vw;height:100vh;pointer-events:none;z-index:9999;",A.container.appendChild(this.canvas),this.ready=this.init()}backingStoreDpr(){const A=this.options.resolution;return A!=null&&A>0&&Number.isFinite(A)?A:typeof window!="undefined"&&window.devicePixelRatio>0?window.devicePixelRatio:1}syncCanvasSize(){var A;da(this.canvas,this.backingStoreDpr()),(A=this.manager)==null||A.syncSlotLayoutFromOptions()}resourcePipelineConcurrency(){if(this.options.maxConcurrentParse!=null)return Math.max(1,Math.max(4,this.options.maxConcurrentParse));const A=typeof navigator!="undefined"&&typeof navigator.hardwareConcurrency=="number"?navigator.hardwareConcurrency/2:4;return Math.max(1,Math.max(4,A))}async init(){var A;this.syncCanvasSize(),await new Promise(I=>requestAnimationFrame(()=>I())),this.syncCanvasSize(),IE({maxConcurrent:this.resourcePipelineConcurrency(),maxMemoryBytes:OA.DEFAULT_RESOURCE_CACHE_MEMORY_BYTES,maxPersistentBytes:OA.DEFAULT_RESOURCE_CACHE_PERSISTENT_BYTES});const t=(A=this.options.preferWebGPU)!=null?A:!0,e=this.options.antialias,[g]=await Promise.all([cC(this.canvas,t,e,this.options.forceWebGL1===!0),pC()]);this.backend=g,this.manager=new LC(this.backend),this.resizeObserver=new ResizeObserver(()=>{this.destroyed||this.syncCanvasSize()}),this.resizeObserver.observe(this.canvas),window.addEventListener("resize",this.onWindowLayout),window.addEventListener("orientationchange",this.onWindowLayout)}currentCanvasCssSize(){const A=this.canvas.clientWidth||this.options.container.clientWidth||window.innerWidth||0,t=this.canvas.clientHeight||this.options.container.clientHeight||window.innerHeight||0;return{width:A,height:t}}async resolveGiftIntrinsicSize(A){switch(A.type){case"svga":{const t=await Fr(A.source,{useWorker:this.options.svgaParseInWorker!==!1});return{width:t.viewBoxWidth,height:t.viewBoxHeight}}case"vap":{if(!A.config)throw new Error("VAP requires config");const t=await IB(A.config),e=et(t.info);return{width:e.w,height:e.h}}case"alphaVideo":return this.probeVideoNaturalSize(A.source,"alphaVideo")}}async normalizeAddGiftOptions(A){if(A.width!=null&&A.height!=null)return A;const t=this.currentCanvasCssSize();if(A.objectFit==="cover"&&A.width==null&&A.height==null&&t.width>0&&t.height>0)return{...A,width:t.width,height:t.height};const e=await this.resolveGiftIntrinsicSize(A),g=Uf({width:A.width,height:A.height,useOriginalSize:A.useOriginalSize},e,t.width,t.height);return{...A,width:g.width,height:g.height}}resolveAnimationStepTarget(A,t){var e,g,I,s;const{sx:n,sy:B}=AB(this.canvas),C=(e=t.scaleTo)!=null?e:A.scale,Q=t.flyTo!=null?t.flyTo.x*n:A.x+A.width*A.scale/2,a=t.flyTo!=null?t.flyTo.y*B:A.y+A.height*A.scale/2;return{targetX:Q-A.width*C/2,targetY:a-A.height*C/2,targetScale:C,targetOpacity:EC((g=t.opacity)!=null?g:A.opacity),duration:Math.max(1,(I=t.duration)!=null?I:600),easing:(s=t.easing)!=null?s:zC}}runGiftAnimationStep(A,t,e){const g=this.resolveAnimationStepTarget(A,e);return this.manager.postAnimator.startTweenPromise(A,g.targetX,g.targetY,g.targetScale,g.duration,g.easing,()=>{var I;return(I=e.onComplete)==null?void 0:I.call(e,t)},g.targetOpacity)}createGiftAnimationChain(A,t,e){const g=Array.isArray(e)?[...e]:e?[e]:[],I=[];let s=!1,n=!1,B=null,C=null;const Q=E=>new Promise(r=>{if(n){r();return}C=r,B=setTimeout(()=>{B=null,C=null,r()},Math.max(0,E))}),a={to:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push(E),a},then:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push(E),a},delay:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push({delayMs:Math.max(0,E)}),a},onComplete:E=>{if(s)throw new Error("Gift animation chain has already started");return I.push(E),a},start:async(E="immediate")=>{var r,o;s=!0;const h=(r=this.manager)==null?void 0:r.getSlot(A.id);if(!h||h.state==="finished")return t;E==="afterGiftComplete"&&await this.waitForGiftPlaybackComplete(A.id);let c=!1;for(const f of g){if(n||!((o=this.manager)!=null&&o.getSlot(A.id))||A.state==="finished"){c=!0;break}xf(f)?await Q(f.delayMs):await this.runGiftAnimationStep(A,t,f)}if(!c&&!n)for(const f of I)f(t);return t},cancel:()=>{var E;n=!0,B!=null&&(clearTimeout(B),B=null),C==null||C(),C=null,(E=this.manager)==null||E.postAnimator.cancelForGift(A.id)}};return a}async addGift(A){var t,e,g,I;if(console.info("[GiftStage] addGift await ready…",A.type),await this.ready,console.info("[GiftStage] addGift ready, loading…",A.type),this.destroyed)throw new Error("GiftStage is destroyed");const s=await this.normalizeAddGiftOptions(A),n=mC(),{sx:B,sy:C}=AB(this.canvas),Q=YC(s.x,s.y,s.width,s.height,this.canvas.clientWidth,this.canvas.clientHeight),a={id:n,type:s.type,state:"loading",options:s,zIndex:(t=s.zIndex)!=null?t:0,renderOrder:this.nextRenderOrder++,x:Q.x*B,y:Q.y*C,width:s.width*B,height:s.height*C,scale:1,opacity:EC((e=s.opacity)!=null?e:1),paused:!1,currentFrame:0,accumulatedTime:0,lastTickTime:0,loopCount:0,videoEntity:null,svgaSlotTextures:void 0,videoElement:null,releaseMediaSource:null,releaseSharedSVGAAsset:null,releaseSharedVideoPlayback:null,releaseSharedVideoTexture:null,webcodecsPlayback:null,wcPlaybackTime:0,videoTextureHandle:null,vapMixState:null,onComplete:void 0};let E;E={id:n,type:s.type,pause:()=>{a.paused=!0},resume:()=>{a.paused=!1},destroy:()=>{this.removeGift(n)},animate:o=>this.createGiftAnimationChain(a,E,o)};const r=s.onComplete;a.onComplete=o=>{this.markGiftPlaybackComplete(a.id),r==null||r(o)},this.manager.addSlot(a,E);try{switch(s.type){case"svga":await this.loadSVGA(a);break;case"vap":await this.loadVAP(a,s);break;case"alphaVideo":await this.loadAlphaVideo(a,s);break}a.state="playing",s.type==="svga"&&a.videoEntity&&this.manager.audioManager.tickFrame(a,a.currentFrame,E),a.webcodecsPlayback&&console.info("[GiftStage:WC] gift playing",{giftId:a.id,type:a.type,layoutBufPx:{x:a.x,y:a.y,w:a.width,h:a.height}})}catch(o){a.state="finished",(I=(g=this.options).onError)==null||I.call(g,o instanceof Error?o:new Error(String(o)))}return E}async loadSVGA(A){var t,e,g;const I=typeof A.options.source=="string"?A.options.source:null;if(I){const a=await this.acquireSharedSVGAEntity(I);if(A.state==="finished"){a.release();return}A.releaseSharedSVGAAsset=a.release,await this.finishLoadSVGA(A,a.entity,a.audioBlobs);return}const{movie:s,imageBitmaps:n,audioBlobs:B}=await nB(A.options.source,{useWorker:this.options.svgaParseInWorker!==!1});if(A.state==="finished")return;const C=await this.buildSVGAAtlasIfNeeded(n,!!I);if(A.state==="finished"){for(const a of n.values())a.close();return}const Q={params:s.params,sprites:s.sprites,audios:s.audios,atlasTextureHandle:(t=C==null?void 0:C.textureHandle)!=null?t:null,atlasTextureHandles:(e=C==null?void 0:C.textureHandles)!=null?e:[],atlasRects:(g=C==null?void 0:C.rects)!=null?g:new Map,audioBuffers:new Map};await this.finishLoadSVGA(A,Q,B),I&&(C!=null&&C.encodedPngBytesPromises)&&Promise.all(C.encodedPngBytesPromises).then(a=>{a.some(E=>!E)||Pn(I,{params:s.params,sprites:s.sprites,audios:s.audios,audioBlobs:B,atlasRects:C.rects,atlasPages:C.pages.map((E,r)=>({width:E.atlasWidth,height:E.atlasHeight,imageBytes:a[r]}))})});for(const a of n.values())a.close()}async acquireSharedSVGAEntity(A){const t=A,e=this.sharedSVGAEntities.get(t);if(e)return e.refs++,{entity:e.entity,audioBlobs:e.audioBlobs,release:()=>this.releaseSharedSVGAEntity(t)};let g=this.pendingSharedSVGAEntities.get(t);g||(g=this.buildSharedSVGAEntity(A),this.pendingSharedSVGAEntities.set(t,g));let I;try{I=await g}catch(n){throw this.pendingSharedSVGAEntities.delete(t),n}let s=this.sharedSVGAEntities.get(t);return s?s.refs++:(s={refs:1,entity:I.entity,audioBlobs:I.audioBlobs},this.sharedSVGAEntities.set(t,s)),this.pendingSharedSVGAEntities.delete(t),{entity:s.entity,audioBlobs:s.audioBlobs,release:()=>this.releaseSharedSVGAEntity(t)}}async buildSharedSVGAEntity(A){var t,e,g,I;const s=await Nf(A);if(s){const Q=await this.createCachedSVGAAtlasTextures(s.atlasPages);return{entity:{params:s.params,sprites:s.sprites,audios:s.audios,atlasTextureHandle:(t=Q[0])!=null?t:null,atlasTextureHandles:Q,atlasRects:s.atlasRects,audioBuffers:new Map},audioBlobs:s.audioBlobs}}const{movie:n,imageBitmaps:B,audioBlobs:C}=await nB(A,{useWorker:this.options.svgaParseInWorker!==!1});try{const Q=await this.buildSVGAAtlasIfNeeded(B,!0);return Q!=null&&Q.encodedPngBytesPromises?Promise.all(Q.encodedPngBytesPromises).then(a=>{a.some(E=>!E)||Pn(A,{params:n.params,sprites:n.sprites,audios:n.audios,audioBlobs:C,atlasRects:Q.rects,atlasPages:Q.pages.map((E,r)=>({width:E.atlasWidth,height:E.atlasHeight,imageBytes:a[r]}))})}):Q||Pn(A,{params:n.params,sprites:n.sprites,audios:n.audios,audioBlobs:C,atlasRects:new Map,atlasPages:[]}),{entity:{params:n.params,sprites:n.sprites,audios:n.audios,atlasTextureHandle:(e=Q==null?void 0:Q.textureHandle)!=null?e:null,atlasTextureHandles:(g=Q==null?void 0:Q.textureHandles)!=null?g:[],atlasRects:(I=Q==null?void 0:Q.rects)!=null?I:new Map,audioBuffers:new Map},audioBlobs:C}}finally{for(const Q of B.values())Q.close()}}releaseSharedSVGAEntity(A){const t=this.sharedSVGAEntities.get(A);t&&(t.refs=Math.max(0,t.refs-1),!(t.refs>0)&&(this.deleteSVGAAtlasTextures(t.entity),this.sharedSVGAEntities.delete(A)))}async createCachedSVGAAtlasTextures(A){const t=[];for(const e of A){const g=await createImageBitmap(new Blob([e.imageBytes],{type:"image/png"}),{premultiplyAlpha:"premultiply"}),I=this.backend.createTexture(g,{width:e.width,height:e.height,filter:"linear",premultiplyAlpha:!0,sourcePremultiplied:!0});g.close(),t.push(I)}return t}deleteSVGAAtlasTextures(A){var t,e;const g=(t=A.atlasTextureHandles)!=null&&t.length?A.atlasTextureHandles:A.atlasTextureHandle?[A.atlasTextureHandle]:[],I=new Set;for(const s of g)I.has(s.id)||(I.add(s.id),(e=this.backend)==null||e.deleteTexture(s))}async finishLoadSVGA(A,t,e){let g=0;for(const[I,s]of e)await this.manager.audioManager.decodeAudio(I,s),g++,g<e.size&&await new Promise(n=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>n());return}setTimeout(n,0)});A.videoEntity=t,A.options.svgaSlots&&(A.svgaSlotTextures=await pE(this.backend,A.videoEntity,A.options.svgaSlots))}svgaAtlasMaxSize(){var A,t,e;const g=(A=this.options.svgaAtlasMaxSize)!=null?A:OA.SVGA_ATLAS_MAX_SIZE,I=(e=(t=this.backend)==null?void 0:t.maxTextureSize)!=null?e:g;return Math.max(64,Math.min(I,g))}async buildSVGAAtlasIfNeeded(A,t){return A.size===0?null:VC(A,this.backend,this.svgaAtlasMaxSize(),OA.SVGA_ATLAS_PADDING,{captureEncodedPng:t,maxPages:this.svgaAtlasMaxPages()})}svgaAtlasMaxPages(){var A;return Math.max(1,Math.floor((A=this.options.svgaAtlasMaxPages)!=null?A:4))}shouldTryWebCodecs(){return this.options.preferWebCodecs===!0&&typeof VideoDecoder!="undefined"}logPlaybackBackend(A,t,e){const g=t==="webcodecs"?"WebCodecs (mp4box decode)":"HTMLVideoElement",I=e?` — ${e}`:"";console.info(`[GiftStage] ${A.type} [${A.id}]: ${g}${I}`)}async tryWebCodecsPlayback(A){if(!this.shouldTryWebCodecs())return null;try{const t=typeof A=="string"?await _s(A):A;return await vA.create(t,void 0,{useWorker:this.options.webCodecsDecodeInWorker!==!1,maxDecodedFrames:this.options.webCodecsMaxDecodedFrames,decodeAheadFrames:this.options.webCodecsDecodeAheadFrames})}catch(t){const e=t instanceof Error?t.message:String(t);return console.warn(`[GiftStage] WebCodecs path failed, falling back to <video>: ${e}`),null}}async loadVAP(A,t){var e;if(!t.config)throw new Error("VAP requires config");const g=await IB(t.config);A.vapConfig=g;const I=await SE(g,t.vapSlots);if(I.size>0){const Q=et(g.info),a=NE(g);let E=null,r=null;try{E=new cf(g,a,I,Q.w,Q.h)}catch(o){console.warn("[GiftStage] VAP mixed rendering fell back to CPU compositor",o),r=RE(Q.w,Q.h)}A.vapMixState={texture:this.backend.createEmptyTexture(Q.w,Q.h,{filter:"linear"}),width:Q.w,height:Q.h,composer:E,frameMap:a,resources:I,lastFrameIndex:-1,lastSourceRef:null,...r!=null?r:{}},A.videoTextureHandle=A.vapMixState.texture}console.info("[GiftStage:WC] loadVAP: try WebCodecs / video…");const n=await this.tryWebCodecsPlayback(t.source);if(n){A.webcodecsPlayback=n,A.wcPlaybackTime=0;const Q=n.getFrameForTime(0);if(!Q)throw n.destroy(),A.webcodecsPlayback=null,new Error("WebCodecs: missing first frame");if(!A.vapMixState){const E=Q.displayWidth||Q.codedWidth,r=Q.displayHeight||Q.codedHeight,{w:o,h}=BC(A,E,r,"vap",g),c=this.manager.tryAllocateWebCodecsAtlas(A.id,o,h,this.options.webCodecsVideoAtlas);if(c)A.videoTextureHandle=c.handle,A.wcAtlasRect=c.rect,this.backend.updateTextureRegion(c.handle,Q,c.rect.x,c.rect.y,o,h);else{const f=this.backend.createTexture(Q,{width:E,height:r,filter:"linear"});A.videoTextureHandle=f}}A.videoElement=null;const a=A.videoTextureHandle;console.info("[GiftStage:WC] VAP texture",{giftId:A.id,atlas:!!A.wcAtlasRect&&!A.vapMixState,mixed:!!A.vapMixState,tex:`${a.width}x${a.height}`,frame0:`${Q.displayWidth}x${Q.displayHeight}`,atlasCell:A.wcAtlasRect?`${A.wcAtlasRect.w}x${A.wcAtlasRect.h}`:void 0}),this.logPlaybackBackend(A,"webcodecs");return}const B=await this.tryAcquireSharedHtmlVideo(A,t);if(B)A.videoElement=B.video,A.releaseSharedVideoPlayback=B.release;else{const Q=await this.acquireVideoPlaybackSource(t.source);A.releaseMediaSource=(e=Q.release)!=null?e:null;const a=this.createVideo(Q.src,t.loop===0);A.videoElement=a}const C=A.videoElement;if(B){await B.ready;const Q=this.acquireSharedVideoTexture(B.cacheKey,C);A.videoTextureHandle=Q.texture,A.releaseSharedVideoTexture=Q.release}else await this.waitVideoReady(C),A.vapMixState||(A.videoTextureHandle=this.backend.createTexture(C,{width:C.videoWidth,height:C.videoHeight,filter:"linear"}));A.releaseSharedVideoPlayback||this.bindVideoLoopOnEnded(A,C),this.logPlaybackBackend(A,"video",this.shouldTryWebCodecs()?"fallback after WebCodecs unavailable or failed":"preferWebCodecs off or no VideoDecoder")}async loadAlphaVideo(A,t){var e;console.info("[GiftStage:WC] loadAlphaVideo: try WebCodecs / video…");const g=await this.tryWebCodecsPlayback(t.source);if(g){A.webcodecsPlayback=g,A.wcPlaybackTime=0;const n=g.getFrameForTime(0);if(!n)throw g.destroy(),A.webcodecsPlayback=null,new Error("WebCodecs: missing first frame");const B=n.displayWidth||n.codedWidth,C=n.displayHeight||n.codedHeight,{w:Q,h:a}=BC(A,B,C,"alphaVideo",void 0),E=this.manager.tryAllocateWebCodecsAtlas(A.id,Q,a,this.options.webCodecsVideoAtlas);if(E)A.videoTextureHandle=E.handle,A.wcAtlasRect=E.rect,this.backend.updateTextureRegion(E.handle,n,E.rect.x,E.rect.y,Q,a);else{const o=this.backend.createTexture(n,{width:B,height:C,filter:"linear"});A.videoTextureHandle=o}A.videoElement=null;const r=A.videoTextureHandle;console.info("[GiftStage:WC] alphaVideo texture",{giftId:A.id,atlas:!!A.wcAtlasRect,tex:`${r.width}x${r.height}`,frame0:`${n.displayWidth}x${n.displayHeight}`,atlasCell:A.wcAtlasRect?`${A.wcAtlasRect.w}x${A.wcAtlasRect.h}`:void 0}),this.logPlaybackBackend(A,"webcodecs");return}const I=await this.tryAcquireSharedHtmlVideo(A,t);if(I)A.videoElement=I.video,A.releaseSharedVideoPlayback=I.release;else{const n=await this.acquireVideoPlaybackSource(t.source);A.releaseMediaSource=(e=n.release)!=null?e:null;const B=this.createVideo(n.src,t.loop===0);A.videoElement=B}const s=A.videoElement;if(I){await I.ready;const n=this.acquireSharedVideoTexture(I.cacheKey,s);A.videoTextureHandle=n.texture,A.releaseSharedVideoTexture=n.release}else await this.waitVideoReady(s),A.videoTextureHandle=this.backend.createTexture(s,{width:s.videoWidth,height:s.videoHeight,filter:"linear"});A.releaseSharedVideoPlayback||this.bindVideoLoopOnEnded(A,s),this.logPlaybackBackend(A,"video",this.shouldTryWebCodecs()?"fallback after WebCodecs unavailable or failed":"preferWebCodecs off or no VideoDecoder")}bindVideoLoopOnEnded(A,t){t.addEventListener("ended",()=>{var e,g;if(A.state!=="playing")return;const I=(e=A.options.loop)!=null?e:1;if(I===0){t.currentTime=0,t.play();return}if(A.loopCount++,A.loopCount>=I){let s;s={id:A.id,type:A.type,pause:()=>{},resume:()=>{},destroy:()=>this.removeGift(A.id),animate:n=>this.createGiftAnimationChain(A,s,n)},(g=A.onComplete)==null||g.call(A,s),A.state=A.options.clearsAfterStop===!1?"stopped":"finished";return}t.currentTime=0,t.play()})}createVideo(A,t){const e=document.createElement("video");return e.crossOrigin="anonymous",e.autoplay=!0,e.preload="auto",e.muted=!0,e.playsInline=!0,e.setAttribute("playsinline",""),e.setAttribute("webkit-playsinline","true"),e.loop=t,e.style.cssText="display:none;",e.src=A,document.body.appendChild(e),e.load(),e}waitVideoMetadata(A){return new Promise((t,e)=>{const g=()=>{A.removeEventListener("loadedmetadata",I),A.removeEventListener("error",s)},I=()=>{g(),t()},s=()=>{g(),e(new Error("Video metadata load failed"))};A.addEventListener("loadedmetadata",I),A.addEventListener("error",s),A.readyState>=HTMLMediaElement.HAVE_METADATA&&(g(),t())})}async probeVideoNaturalSize(A,t="video"){var e;const g=await this.acquireVideoPlaybackSource(A),I=document.createElement("video");I.crossOrigin="anonymous",I.preload="metadata",I.muted=!0,I.playsInline=!0,I.setAttribute("playsinline",""),I.setAttribute("webkit-playsinline","true"),I.style.cssText="display:none;",I.src=g.src,document.body.appendChild(I),I.load();try{return await this.waitVideoMetadata(I),t==="alphaVideo"?Rf(I.videoWidth,I.videoHeight):{width:I.videoWidth,height:I.videoHeight}}finally{try{I.pause(),I.removeAttribute("src"),I.load(),I.remove()}catch(s){}(e=g.release)==null||e.call(g)}}async acquireVideoPlaybackSource(A){if(typeof A!="string"){const g=URL.createObjectURL(new Blob([A]));return{src:g,release:()=>URL.revokeObjectURL(g)}}const t=this.normalizeSharedVideoSourceKey(A);if(!t)return{src:A};let e=this.sharedVideoSources.get(t);e||(e={refs:0,objectUrl:null,promise:this.fetchSharedVideoSource(t)},this.sharedVideoSources.set(t,e)),e.refs++;try{return{src:await e.promise,release:()=>this.releaseSharedVideoSource(t)}}catch(g){return this.releaseSharedVideoSource(t),console.warn("[GiftStage] shared video prefetch failed, using original url",g),{src:A}}}normalizeSharedVideoSourceKey(A){try{const t=new URL(A,window.location.href);return t.protocol==="blob:"||t.protocol==="data:"?null:t.href}catch(t){return null}}async fetchSharedVideoSource(A){const t=new Blob([await _s(A)]),e=this.sharedVideoSources.get(A),g=URL.createObjectURL(t);return e&&(e.objectUrl=g,e.refs===0&&(URL.revokeObjectURL(g),this.sharedVideoSources.delete(A))),g}releaseSharedVideoSource(A){const t=this.sharedVideoSources.get(A);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&t.objectUrl&&(URL.revokeObjectURL(t.objectUrl),this.sharedVideoSources.delete(A)))}async tryAcquireSharedHtmlVideo(A,t){var e,g;if(this.options.shareIdenticalVideoPlayback===!1||t.loop!==0||typeof t.source!="string"||A.type==="vap"&&A.vapMixState)return null;const I=this.normalizeSharedVideoSourceKey(t.source);if(!I)return null;const s=(e=this.options.sharedVideoPlaybackWindowMs)!=null?e:OA.DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS,n=Math.max(0,s)/1e3,B=this.sharedHtmlVideos.get(I);if(B)return B.video.currentTime>n?null:(B.refs++,{cacheKey:I,video:B.video,ready:B.ready,release:()=>this.releaseSharedHtmlVideo(I)});let C=this.pendingSharedHtmlVideos.get(I);C||(C=(async()=>{var E;const r=await this.acquireVideoPlaybackSource(t.source),o=this.createVideo(r.src,!0),h=this.waitVideoReady(o);return{video:o,ready:h,releaseSource:(E=r.release)!=null?E:null}})(),this.pendingSharedHtmlVideos.set(I,C));let Q;try{Q=await C}catch(E){throw this.pendingSharedHtmlVideos.delete(I),E}let a=this.sharedHtmlVideos.get(I);return a?a.refs++:(a={refs:1,video:Q.video,ready:Q.ready,releaseSource:(g=Q.releaseSource)!=null?g:null},this.sharedHtmlVideos.set(I,a)),this.pendingSharedHtmlVideos.delete(I),{cacheKey:I,video:a.video,ready:a.ready,release:()=>this.releaseSharedHtmlVideo(I)}}acquireSharedVideoTexture(A,t){const e=this.sharedVideoTextures.get(A);if(e)return e.refs++,{texture:e.texture,release:()=>this.releaseSharedVideoTexture(A)};const g=this.backend.createTexture(t,{width:t.videoWidth,height:t.videoHeight,filter:"linear"});return this.sharedVideoTextures.set(A,{refs:1,texture:g}),{texture:g,release:()=>this.releaseSharedVideoTexture(A)}}releaseSharedVideoTexture(A){var t;const e=this.sharedVideoTextures.get(A);e&&(e.refs=Math.max(0,e.refs-1),!(e.refs>0)&&((t=this.backend)==null||t.deleteTexture(e.texture),this.sharedVideoTextures.delete(A)))}releaseSharedHtmlVideo(A){var t;const e=this.sharedHtmlVideos.get(A);if(e&&(e.refs=Math.max(0,e.refs-1),!(e.refs>0))){try{e.video.pause(),e.video.removeAttribute("src"),e.video.load(),e.video.remove()}catch(g){}(t=e.releaseSource)==null||t.call(e),this.sharedHtmlVideos.delete(A)}}waitForFirstVideoFrame(A){return new Promise(t=>{typeof A.requestVideoFrameCallback=="function"?A.requestVideoFrameCallback(()=>t()):requestAnimationFrame(()=>t())})}waitVideoReady(A){return new Promise((t,e)=>{const g=()=>{A.removeEventListener("canplay",s),A.removeEventListener("error",n)},I=async()=>{try{await A.play(),await this.waitForFirstVideoFrame(A),t()}catch(B){e(B)}},s=()=>{g(),I()},n=()=>{g(),e(new Error("Video load failed"))};A.addEventListener("canplay",s),A.addEventListener("error",n),A.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA&&(g(),I())})}removeGift(A){var t;this.resolveGiftPlaybackWaiters(A),this.completedPlaybackSlots.delete(A),this.playbackCompleteWaiters.delete(A),(t=this.manager)==null||t.removeSlot(A)}removeAll(){if(this.manager)for(const A of this.manager.getSlotIds())this.manager.removeSlot(A)}pause(){var A;(A=this.manager)==null||A.pause()}resume(){var A;(A=this.manager)==null||A.resume()}get activeCount(){var A,t;return(t=(A=this.manager)==null?void 0:A.activeCount)!=null?t:0}get backendType(){var A,t;return(t=(A=this.backend)==null?void 0:A.type)!=null?t:"webgl2"}destroy(){var A,t;this.destroyed=!0,(A=this.resizeObserver)==null||A.disconnect(),this.resizeObserver=null,window.removeEventListener("resize",this.onWindowLayout),window.removeEventListener("orientationchange",this.onWindowLayout),(t=this.manager)==null||t.destroy();for(const[e]of this.sharedHtmlVideos)this.releaseSharedHtmlVideo(e);for(const[e]of this.sharedSVGAEntities)this.releaseSharedSVGAEntity(e);for(const[e]of this.sharedVideoTextures)this.releaseSharedVideoTexture(e);this.pendingSharedSVGAEntities.clear(),this.pendingSharedHtmlVideos.clear(),this.completedPlaybackSlots.clear(),this.playbackCompleteWaiters.clear();for(const[e,g]of this.sharedVideoSources)g.objectUrl&&URL.revokeObjectURL(g.objectUrl),this.sharedVideoSources.delete(e);this.canvas.remove(),this.backend=null,this.manager=null}markGiftPlaybackComplete(A){this.completedPlaybackSlots.add(A),this.resolveGiftPlaybackWaiters(A)}resolveGiftPlaybackWaiters(A){const t=this.playbackCompleteWaiters.get(A);if(!(!t||t.size===0)){for(const e of t)e();this.playbackCompleteWaiters.delete(A)}}waitForGiftPlaybackComplete(A){var t;return this.completedPlaybackSlots.has(A)||!((t=this.manager)!=null&&t.getSlot(A))?Promise.resolve():new Promise(e=>{let g=this.playbackCompleteWaiters.get(A);g||(g=new Set,this.playbackCompleteWaiters.set(A,g)),g.add(e)})}};z(ls,"SVGA_ATLAS_MAX_SIZE",2048);z(ls,"SVGA_ATLAS_PADDING",2);z(ls,"DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS",100);z(ls,"DEFAULT_RESOURCE_CACHE_MEMORY_BYTES",128*1024*1024);z(ls,"DEFAULT_RESOURCE_CACHE_PERSISTENT_BYTES",2048*1024*1024);let bf=ls;exports.AlphaVideoRenderer=MC;exports.AudioManager=bC;exports.BufferPool=yC;exports.GiftStage=bf;exports.PostAnimator=xC;exports.RenderManager=LC;exports.SVGABatchRenderer=GC;exports.VAPRenderer=kC;exports.WebCodecsMp4Playback=vA;exports.WebGL1Backend=$n;exports.WebGL2Backend=oC;exports.WebGPUBackend=rC;exports.buildAtlas=VC;exports.buildBatchVerticesJS=Ps;exports.canSharedArrayBuffer=ca;exports.canWebGL1=ha;exports.canWebGL2=oa;exports.canWebGPU=ra;exports.clamp=eB;exports.createBackend=cC;exports.decodeSVGAProto=HC;exports.easeInOutCubic=Kr;exports.easeInOutQuad=Hr;exports.easeInQuad=_r;exports.easeOutBack=vr;exports.easeOutCubic=zC;exports.easeOutQuad=Jr;exports.generateId=mC;exports.inflateJS=_C;exports.initWasm=pC;exports.isWasmReady=At;exports.lerp=Gs;exports.linear=Lr;exports.ortho=TA;exports.parseSVGA=nB;exports.parseVAPConfig=IB;
|
|
8638
|
+
`;function hf(i,A,t,e){const g=new Float32Array(t.size*dn),I=A.get(e);if(!I||I.length===0)return g;const[s,n]=i.info.rgbFrame;let B=0;for(const C of I){const Q=t.get(String(C.srcId));if(!Q)continue;if(B+dn>g.length)break;const[a,E,r,o]=C.frame,[h,c,f,l]=C.mFrame,u=fn(a+s,E+n,r,o,i.info.videoW,i.info.videoH),w=fn(h,c,f,l,i.info.videoW,i.info.videoH);g[B++]=Q,g[B++]=u[0],g[B++]=u[1],g[B++]=u[2],g[B++]=u[3],g[B++]=w[0],g[B++]=w[1],g[B++]=w[2],g[B++]=w[3]}return g}class cf{constructor(A,t,e,g,I){this.config=A,this.frameMap=t,dA(this,"canvas"),dA(this,"gl"),dA(this,"program"),dA(this,"vertexShader"),dA(this,"fragmentShader"),dA(this,"vertexBuffer"),dA(this,"videoTexture"),dA(this,"imagePosLoc"),dA(this,"resourceEntries"),dA(this,"textureUnitBySrcId",new Map);var s;if(e.size===0)throw new Error("VAP mix composer requires at least one slot resource");this.canvas=Qf(g,I);const n=this.canvas.getContext("webgl2",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1})||this.canvas.getContext("webgl",{alpha:!0,antialias:!1,depth:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,stencil:!1})||this.canvas.getContext("experimental-webgl");if(!n)throw new Error("VAP mixed rendering requires WebGL support");this.gl=n;const B=Math.max(1,n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS)),C=Math.max(0,B-1),Q=[];let a=1;for(const u of(s=A.src)!=null?s:[]){const w=e.get(String(u.srcId));if(!w)continue;if(a>C){console.warn("[GiftStage] VAP mixed resources exceed texture unit limit, skipping",{srcId:u.srcId,srcTag:u.srcTag,maxUnits:B});continue}const y=QC(n,a,w.source,!0),m={srcId:String(u.srcId),unit:a,texture:y};Q.push(m),this.textureUnitBySrcId.set(m.srcId,m.unit),a++}if(Q.length===0)throw new Error("VAP mixed rendering could not bind any slot resources");this.resourceEntries=Q;const E=af(n,of,rf(this.resourceEntries.length));this.program=E.program,this.vertexShader=E.vertexShader,this.fragmentShader=E.fragmentShader,this.imagePosLoc=n.getUniformLocation(this.program,"image_pos"),this.videoTexture=QC(n,0);const r=n.getUniformLocation(this.program,"u_image_video");r!==null&&n.uniform1i(r,0);for(const u of this.resourceEntries){const w=n.getUniformLocation(this.program,`u_image${u.unit}`);w!==null&&n.uniform1i(w,u.unit)}const o=n.createBuffer();if(!o)throw new Error("Failed to create VAP mix vertex buffer");this.vertexBuffer=o,n.bindBuffer(n.ARRAY_BUFFER,this.vertexBuffer),n.bufferData(n.ARRAY_BUFFER,Ef(A.info),n.STATIC_DRAW);const h=6*Float32Array.BYTES_PER_ELEMENT,c=n.getAttribLocation(this.program,"a_position"),f=n.getAttribLocation(this.program,"a_texCoord"),l=n.getAttribLocation(this.program,"a_alpha_texCoord");n.enableVertexAttribArray(c),n.vertexAttribPointer(c,2,n.FLOAT,!1,h,0),n.enableVertexAttribArray(f),n.vertexAttribPointer(f,2,n.FLOAT,!1,h,2*Float32Array.BYTES_PER_ELEMENT),n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,h,4*Float32Array.BYTES_PER_ELEMENT),n.viewport(0,0,this.canvas.width,this.canvas.height),n.disable(n.BLEND),n.disable(n.DEPTH_TEST),n.clearColor(0,0,0,0),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,n.NONE)}render(A,t){const e=this.gl;e.useProgram(this.program),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.videoTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,A),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,0);const g=hf(this.config,this.frameMap,this.textureUnitBySrcId,t);return this.imagePosLoc!==null&&e.uniform1fv(this.imagePosLoc,g),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_STRIP,0,4),this.canvas}destroy(){const A=this.gl;for(const e of this.resourceEntries)A.deleteTexture(e.texture);A.deleteTexture(this.videoTexture),A.deleteBuffer(this.vertexBuffer),A.deleteProgram(this.program),A.deleteShader(this.vertexShader),A.deleteShader(this.fragmentShader);const t=A.getExtension("WEBGL_lose_context");t==null||t.loseContext()}}var lf=Object.defineProperty,df=(i,A,t)=>A in i?lf(i,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[A]=t,GA=(i,A,t)=>df(i,typeof A!="symbol"?A+"":A,t);const _Q=1397178947,JQ=12,ff=8;class uf{constructor(A=1024){GA(this,"buffer"),GA(this,"view"),GA(this,"bytes"),GA(this,"offset",0),GA(this,"encoder",new TextEncoder),this.buffer=new ArrayBuffer(A),this.view=new DataView(this.buffer),this.bytes=new Uint8Array(this.buffer)}ensure(A){const t=this.offset+A;if(t<=this.buffer.byteLength)return;let e=this.buffer.byteLength;for(;e<t;)e*=2;const g=new ArrayBuffer(e);new Uint8Array(g).set(this.bytes.subarray(0,this.offset)),this.buffer=g,this.view=new DataView(this.buffer),this.bytes=new Uint8Array(this.buffer)}u8(A){this.ensure(1),this.view.setUint8(this.offset,A),this.offset+=1}u16(A){this.ensure(2),this.view.setUint16(this.offset,A,!0),this.offset+=2}u32(A){this.ensure(4),this.view.setUint32(this.offset,A,!0),this.offset+=4}f32(A){this.ensure(4),this.view.setFloat32(this.offset,A,!0),this.offset+=4}bytesValue(A){this.u32(A.byteLength),this.ensure(A.byteLength),this.bytes.set(A,this.offset),this.offset+=A.byteLength}string(A){this.bytesValue(this.encoder.encode(A))}finish(){return this.buffer.slice(0,this.offset)}}class wf{constructor(A){GA(this,"view"),GA(this,"bytes"),GA(this,"offset",0),GA(this,"decoder",new TextDecoder),this.view=new DataView(A),this.bytes=new Uint8Array(A)}u8(){const A=this.view.getUint8(this.offset);return this.offset+=1,A}u16(){const A=this.view.getUint16(this.offset,!0);return this.offset+=2,A}u32(){const A=this.view.getUint32(this.offset,!0);return this.offset+=4,A}f32(){const A=this.view.getFloat32(this.offset,!0);return this.offset+=4,A}bytesValue(){const A=this.u32(),t=this.bytes.slice(this.offset,this.offset+A);return this.offset+=A,t}string(){return this.decoder.decode(this.bytesValue())}}function Df(i){var A,t;let e=0;for(const g of i.atlasPages)e+=g.imageBytes.byteLength;for(const[g,I]of i.audioBlobs)e+=g.length*2+I.byteLength;for(const[g]of i.atlasRects)e+=g.length*2+20;for(const g of i.sprites){e+=g.imageKey.length*2+g.frames.length*64;for(const I of g.frames)if(e+=I.clipPath.length*2,I.shapes)for(const s of I.shapes)e+=((t=(A=s.pathData)==null?void 0:A.length)!=null?t:0)*2+96}return e}function pf(i,A){var t;let e=0;A.fill&&(e|=1),A.stroke&&(e|=2),i.u8(e),A.fill&&(i.f32(A.fill.r),i.f32(A.fill.g),i.f32(A.fill.b),i.f32(A.fill.a)),A.stroke&&(i.f32(A.stroke.r),i.f32(A.stroke.g),i.f32(A.stroke.b),i.f32(A.stroke.a)),i.f32((t=A.strokeWidth)!=null?t:0)}function yf(i){const A=i.u8(),t=A&1?{r:i.f32(),g:i.f32(),b:i.f32(),a:i.f32()}:null,e=A&2?{r:i.f32(),g:i.f32(),b:i.f32(),a:i.f32()}:null;return{fill:t,stroke:e,strokeWidth:i.f32()}}function mf(i,A){var t,e,g,I;i.u8(A.kind==="path"?0:A.kind==="rect"?1:2),i.string((t=A.pathData)!=null?t:"");const s=(e=A.rect)!=null?e:{x:0,y:0,width:0,height:0,cornerRadius:0};i.f32(s.x),i.f32(s.y),i.f32(s.width),i.f32(s.height),i.f32((g=s.cornerRadius)!=null?g:0);const n=(I=A.ellipse)!=null?I:{x:0,y:0,radiusX:0,radiusY:0};i.f32(n.x),i.f32(n.y),i.f32(n.radiusX),i.f32(n.radiusY),pf(i,A.style),i.f32(A.transform.a),i.f32(A.transform.b),i.f32(A.transform.c),i.f32(A.transform.d),i.f32(A.transform.tx),i.f32(A.transform.ty)}function Gf(i){const A=i.u8(),t=i.string(),e={x:i.f32(),y:i.f32(),width:i.f32(),height:i.f32(),cornerRadius:i.f32()},g={x:i.f32(),y:i.f32(),radiusX:i.f32(),radiusY:i.f32()},I=yf(i),s={a:i.f32(),b:i.f32(),c:i.f32(),d:i.f32(),tx:i.f32(),ty:i.f32()};return A===1?{kind:"rect",rect:e,style:I,transform:s}:A===2?{kind:"ellipse",ellipse:g,style:I,transform:s}:{kind:"path",pathData:t,style:I,transform:s}}function aC(i){const A=new Uint8Array(i.byteLength);return A.set(i),A.buffer}function Ff(i){var A;const t=new uf(ff+i.atlasPages.reduce((e,g)=>e+g.imageBytes.byteLength+12,0)+i.sprites.length*64+i.audioBlobs.size*32+i.atlasRects.size*32);t.u32(_Q),t.u16(JQ),t.u16(0),t.f32(i.params.viewBoxWidth),t.f32(i.params.viewBoxHeight),t.f32(i.params.fps),t.u32(i.params.frames),t.u32(i.atlasPages.length);for(const e of i.atlasPages)t.u32(e.width),t.u32(e.height),t.bytesValue(new Uint8Array(e.imageBytes));t.u32(i.atlasRects.size);for(const[e,g]of i.atlasRects)t.string(e),t.u32((A=g.textureIndex)!=null?A:0),t.f32(g.x),t.f32(g.y),t.f32(g.w),t.f32(g.h);t.u32(i.audios.length);for(const e of i.audios)t.string(e.audioKey),t.u32(e.startFrame),t.u32(e.endFrame),t.f32(e.startTime),t.f32(e.totalTime);t.u32(i.audioBlobs.size);for(const[e,g]of i.audioBlobs)t.string(e),t.bytesValue(new Uint8Array(g));t.u32(i.sprites.length);for(const e of i.sprites){t.string(e.imageKey),t.u32(e.frames.length);for(const g of e.frames){let I=0;if(g.layout&&(I|=1),g.transform&&(I|=2),g.clipPath&&(I|=4),g.shapes&&g.shapes.length>0&&(I|=8),t.u8(I),t.f32(g.alpha),g.layout&&(t.f32(g.layout.x),t.f32(g.layout.y),t.f32(g.layout.width),t.f32(g.layout.height)),g.transform&&(t.f32(g.transform.a),t.f32(g.transform.b),t.f32(g.transform.c),t.f32(g.transform.d),t.f32(g.transform.tx),t.f32(g.transform.ty)),g.clipPath&&t.string(g.clipPath),g.shapes&&g.shapes.length>0){t.u32(g.shapes.length);for(const s of g.shapes)mf(t,s)}}}return t.finish()}function Sf(i){const A=new wf(i);if(A.u32()!==_Q)throw new Error("Invalid SVGA cache binary magic");if(A.u16()!==JQ)throw new Error("Unsupported SVGA cache binary version");A.u16();const t={viewBoxWidth:A.f32(),viewBoxHeight:A.f32(),fps:A.f32(),frames:A.u32()},e=A.u32(),g=[];for(let r=0;r<e;r++)g.push({width:A.u32(),height:A.u32(),imageBytes:aC(A.bytesValue())});const I=A.u32(),s=new Map;for(let r=0;r<I;r++){const o=A.string(),h=A.u32();s.set(o,{textureIndex:h,x:A.f32(),y:A.f32(),w:A.f32(),h:A.f32()})}const n=A.u32(),B=[];for(let r=0;r<n;r++)B.push({audioKey:A.string(),startFrame:A.u32(),endFrame:A.u32(),startTime:A.f32(),totalTime:A.f32()});const C=A.u32(),Q=new Map;for(let r=0;r<C;r++){const o=A.string();Q.set(o,aC(A.bytesValue()))}const a=A.u32(),E=[];for(let r=0;r<a;r++){const o=A.string(),h=A.u32(),c=[];for(let f=0;f<h;f++){const l=A.u8(),u=A.f32(),w=l&1?{x:A.f32(),y:A.f32(),width:A.f32(),height:A.f32()}:null,y=l&2?{a:A.f32(),b:A.f32(),c:A.f32(),d:A.f32(),tx:A.f32(),ty:A.f32()}:null,m=l&4?A.string():"";let p=null;if(l&8){const N=A.u32();p=[];for(let U=0;U<N;U++)p.push(Gf(A))}c.push({alpha:u,layout:w,transform:y,clipPath:m,shapes:p})}E.push({imageKey:o,frames:c})}return{params:t,sprites:E,audios:B,audioBlobs:Q,atlasRects:s,atlasPages:g}}function oB(i){return`svga-asset:${i}`}function hB(i){return`svga-asset-bin:${i}`}async function Nf(i){const A=nE(oB(i),"svga-asset");if(A)return A;const t=await BE(hB(i));if(!t)return null;try{const e=Sf(t);return FC(oB(i),"svga-asset",e,t.byteLength),e}catch(e){return QE(hB(i)),null}}async function Pn(i,A){const t=Ff(A);FC(oB(i),"svga-asset",A,Math.max(t.byteLength,Df(A))),await CE(hB(i),t)}function bA(i){return typeof i=="number"&&Number.isFinite(i)&&i>0}function Rf(i,A){const t=bA(i)?i*.5:0,e=bA(A)?A:0;return{width:t,height:e}}function Uf(i,A,t,e){const g=bA(A.width)?A.width:void 0,I=bA(A.height)?A.height:void 0,s=bA(i.width)?i.width:void 0,n=bA(i.height)?i.height:void 0,B=i.useOriginalSize===!0;if(s&&n)return{width:s,height:n};if(s)return g&&I?{width:s,height:s*I/g}:{width:s,height:s};if(n)return g&&I?{width:n*g/I,height:n}:{width:n,height:n};let C=g!=null?g:0,Q=I!=null?I:0;if(C>0&&Q>0&&bA(t)&&bA(e)&&(!B||C>t||Q>e)){const a=Math.min(t/C,e/Q);C*=a,Q*=a}return{width:C,height:Q}}var kf=Object.defineProperty,Mf=(i,A,t)=>A in i?kf(i,A,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[A]=t,z=(i,A,t)=>Mf(i,typeof A!="symbol"?A+"":A,t);function EC(i){return Number.isFinite(i)?Math.max(0,Math.min(1,i)):1}function xf(i){return"delayMs"in i}const ls=class OA{constructor(A){z(this,"sharedSVGAEntities",new Map),z(this,"pendingSharedSVGAEntities",new Map),z(this,"sharedVideoSources",new Map),z(this,"sharedHtmlVideos",new Map),z(this,"sharedVideoTextures",new Map),z(this,"pendingSharedHtmlVideos",new Map),z(this,"completedPlaybackSlots",new Set),z(this,"playbackCompleteWaiters",new Map),z(this,"canvas"),z(this,"backend",null),z(this,"manager",null),z(this,"options"),z(this,"ready"),z(this,"destroyed",!1),z(this,"resizeObserver",null),z(this,"nextRenderOrder",0),z(this,"onWindowLayout",()=>{this.destroyed||this.syncCanvasSize()}),this.options=A,this.canvas=document.createElement("canvas"),this.canvas.style.cssText="position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:9999;",A.container.appendChild(this.canvas),this.ready=this.init()}backingStoreDpr(){const A=this.options.resolution;return A!=null&&A>0&&Number.isFinite(A)?A:typeof window!="undefined"&&window.devicePixelRatio>0?window.devicePixelRatio:1}syncCanvasSize(){var A;da(this.canvas,this.backingStoreDpr()),(A=this.manager)==null||A.syncSlotLayoutFromOptions()}resourcePipelineConcurrency(){if(this.options.maxConcurrentParse!=null)return Math.max(1,Math.max(4,this.options.maxConcurrentParse));const A=typeof navigator!="undefined"&&typeof navigator.hardwareConcurrency=="number"?navigator.hardwareConcurrency/2:4;return Math.max(1,Math.max(4,A))}async init(){var A;this.syncCanvasSize(),await new Promise(I=>requestAnimationFrame(()=>I())),this.syncCanvasSize(),IE({maxConcurrent:this.resourcePipelineConcurrency(),maxMemoryBytes:OA.DEFAULT_RESOURCE_CACHE_MEMORY_BYTES,maxPersistentBytes:OA.DEFAULT_RESOURCE_CACHE_PERSISTENT_BYTES});const t=(A=this.options.preferWebGPU)!=null?A:!0,e=this.options.antialias,[g]=await Promise.all([cC(this.canvas,t,e,this.options.forceWebGL1===!0),pC()]);this.backend=g,this.manager=new LC(this.backend),this.resizeObserver=new ResizeObserver(()=>{this.destroyed||this.syncCanvasSize()}),this.resizeObserver.observe(this.canvas),window.addEventListener("resize",this.onWindowLayout),window.addEventListener("orientationchange",this.onWindowLayout)}currentCanvasCssSize(){const A=this.canvas.clientWidth||this.options.container.clientWidth||window.innerWidth||0,t=this.canvas.clientHeight||this.options.container.clientHeight||window.innerHeight||0;return{width:A,height:t}}async resolveGiftIntrinsicSize(A){switch(A.type){case"svga":{const t=await Fr(A.source,{useWorker:this.options.svgaParseInWorker!==!1});return{width:t.viewBoxWidth,height:t.viewBoxHeight}}case"vap":{if(!A.config)throw new Error("VAP requires config");const t=await IB(A.config),e=et(t.info);return{width:e.w,height:e.h}}case"alphaVideo":return this.probeVideoNaturalSize(A.source,"alphaVideo")}}async normalizeAddGiftOptions(A){if(A.width!=null&&A.height!=null)return A;const t=this.currentCanvasCssSize();if(A.objectFit==="cover"&&A.width==null&&A.height==null&&t.width>0&&t.height>0)return{...A,width:t.width,height:t.height};const e=await this.resolveGiftIntrinsicSize(A),g=Uf({width:A.width,height:A.height,useOriginalSize:A.useOriginalSize},e,t.width,t.height);return{...A,width:g.width,height:g.height}}resolveAnimationStepTarget(A,t){var e,g,I,s;const{sx:n,sy:B}=AB(this.canvas),C=(e=t.scaleTo)!=null?e:A.scale,Q=t.flyTo!=null?t.flyTo.x*n:A.x+A.width*A.scale/2,a=t.flyTo!=null?t.flyTo.y*B:A.y+A.height*A.scale/2;return{targetX:Q-A.width*C/2,targetY:a-A.height*C/2,targetScale:C,targetOpacity:EC((g=t.opacity)!=null?g:A.opacity),duration:Math.max(1,(I=t.duration)!=null?I:600),easing:(s=t.easing)!=null?s:zC}}runGiftAnimationStep(A,t,e){const g=this.resolveAnimationStepTarget(A,e);return this.manager.postAnimator.startTweenPromise(A,g.targetX,g.targetY,g.targetScale,g.duration,g.easing,()=>{var I;return(I=e.onComplete)==null?void 0:I.call(e,t)},g.targetOpacity)}createGiftAnimationChain(A,t,e){const g=Array.isArray(e)?[...e]:e?[e]:[],I=[];let s=!1,n=!1,B=null,C=null;const Q=E=>new Promise(r=>{if(n){r();return}C=r,B=setTimeout(()=>{B=null,C=null,r()},Math.max(0,E))}),a={to:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push(E),a},then:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push(E),a},delay:E=>{if(s)throw new Error("Gift animation chain has already started");return g.push({delayMs:Math.max(0,E)}),a},onComplete:E=>{if(s)throw new Error("Gift animation chain has already started");return I.push(E),a},start:async(E="immediate")=>{var r,o;s=!0;const h=(r=this.manager)==null?void 0:r.getSlot(A.id);if(!h||h.state==="finished")return t;E==="afterGiftComplete"&&await this.waitForGiftPlaybackComplete(A.id);let c=!1;for(const f of g){if(n||!((o=this.manager)!=null&&o.getSlot(A.id))||A.state==="finished"){c=!0;break}xf(f)?await Q(f.delayMs):await this.runGiftAnimationStep(A,t,f)}if(!c&&!n)for(const f of I)f(t);return t},cancel:()=>{var E;n=!0,B!=null&&(clearTimeout(B),B=null),C==null||C(),C=null,(E=this.manager)==null||E.postAnimator.cancelForGift(A.id)}};return a}async addGift(A){var t,e,g,I;if(console.info("[GiftStage] addGift await ready…",A.type),await this.ready,console.info("[GiftStage] addGift ready, loading…",A.type),this.destroyed)throw new Error("GiftStage is destroyed");const s=await this.normalizeAddGiftOptions(A),n=mC(),{sx:B,sy:C}=AB(this.canvas),Q=YC(s.x,s.y,s.width,s.height,this.canvas.clientWidth,this.canvas.clientHeight),a={id:n,type:s.type,state:"loading",options:s,zIndex:(t=s.zIndex)!=null?t:0,renderOrder:this.nextRenderOrder++,x:Q.x*B,y:Q.y*C,width:s.width*B,height:s.height*C,scale:1,opacity:EC((e=s.opacity)!=null?e:1),paused:!1,currentFrame:0,accumulatedTime:0,lastTickTime:0,loopCount:0,videoEntity:null,svgaSlotTextures:void 0,videoElement:null,releaseMediaSource:null,releaseSharedSVGAAsset:null,releaseSharedVideoPlayback:null,releaseSharedVideoTexture:null,webcodecsPlayback:null,wcPlaybackTime:0,videoTextureHandle:null,vapMixState:null,onComplete:void 0};let E;E={id:n,type:s.type,pause:()=>{a.paused=!0},resume:()=>{a.paused=!1},destroy:()=>{this.removeGift(n)},animate:o=>this.createGiftAnimationChain(a,E,o)};const r=s.onComplete;a.onComplete=o=>{this.markGiftPlaybackComplete(a.id),r==null||r(o)},this.manager.addSlot(a,E);try{switch(s.type){case"svga":await this.loadSVGA(a);break;case"vap":await this.loadVAP(a,s);break;case"alphaVideo":await this.loadAlphaVideo(a,s);break}a.state="playing",s.type==="svga"&&a.videoEntity&&this.manager.audioManager.tickFrame(a,a.currentFrame,E),a.webcodecsPlayback&&console.info("[GiftStage:WC] gift playing",{giftId:a.id,type:a.type,layoutBufPx:{x:a.x,y:a.y,w:a.width,h:a.height}})}catch(o){a.state="finished",(I=(g=this.options).onError)==null||I.call(g,o instanceof Error?o:new Error(String(o)))}return E}async loadSVGA(A){var t,e,g;const I=typeof A.options.source=="string"?A.options.source:null;if(I){const a=await this.acquireSharedSVGAEntity(I);if(A.state==="finished"){a.release();return}A.releaseSharedSVGAAsset=a.release,await this.finishLoadSVGA(A,a.entity,a.audioBlobs);return}const{movie:s,imageBitmaps:n,audioBlobs:B}=await nB(A.options.source,{useWorker:this.options.svgaParseInWorker!==!1});if(A.state==="finished")return;const C=await this.buildSVGAAtlasIfNeeded(n,!!I);if(A.state==="finished"){for(const a of n.values())a.close();return}const Q={params:s.params,sprites:s.sprites,audios:s.audios,atlasTextureHandle:(t=C==null?void 0:C.textureHandle)!=null?t:null,atlasTextureHandles:(e=C==null?void 0:C.textureHandles)!=null?e:[],atlasRects:(g=C==null?void 0:C.rects)!=null?g:new Map,audioBuffers:new Map};await this.finishLoadSVGA(A,Q,B),I&&(C!=null&&C.encodedPngBytesPromises)&&Promise.all(C.encodedPngBytesPromises).then(a=>{a.some(E=>!E)||Pn(I,{params:s.params,sprites:s.sprites,audios:s.audios,audioBlobs:B,atlasRects:C.rects,atlasPages:C.pages.map((E,r)=>({width:E.atlasWidth,height:E.atlasHeight,imageBytes:a[r]}))})});for(const a of n.values())a.close()}async acquireSharedSVGAEntity(A){const t=A,e=this.sharedSVGAEntities.get(t);if(e)return e.refs++,{entity:e.entity,audioBlobs:e.audioBlobs,release:()=>this.releaseSharedSVGAEntity(t)};let g=this.pendingSharedSVGAEntities.get(t);g||(g=this.buildSharedSVGAEntity(A),this.pendingSharedSVGAEntities.set(t,g));let I;try{I=await g}catch(n){throw this.pendingSharedSVGAEntities.delete(t),n}let s=this.sharedSVGAEntities.get(t);return s?s.refs++:(s={refs:1,entity:I.entity,audioBlobs:I.audioBlobs},this.sharedSVGAEntities.set(t,s)),this.pendingSharedSVGAEntities.delete(t),{entity:s.entity,audioBlobs:s.audioBlobs,release:()=>this.releaseSharedSVGAEntity(t)}}async buildSharedSVGAEntity(A){var t,e,g,I;const s=await Nf(A);if(s){const Q=await this.createCachedSVGAAtlasTextures(s.atlasPages);return{entity:{params:s.params,sprites:s.sprites,audios:s.audios,atlasTextureHandle:(t=Q[0])!=null?t:null,atlasTextureHandles:Q,atlasRects:s.atlasRects,audioBuffers:new Map},audioBlobs:s.audioBlobs}}const{movie:n,imageBitmaps:B,audioBlobs:C}=await nB(A,{useWorker:this.options.svgaParseInWorker!==!1});try{const Q=await this.buildSVGAAtlasIfNeeded(B,!0);return Q!=null&&Q.encodedPngBytesPromises?Promise.all(Q.encodedPngBytesPromises).then(a=>{a.some(E=>!E)||Pn(A,{params:n.params,sprites:n.sprites,audios:n.audios,audioBlobs:C,atlasRects:Q.rects,atlasPages:Q.pages.map((E,r)=>({width:E.atlasWidth,height:E.atlasHeight,imageBytes:a[r]}))})}):Q||Pn(A,{params:n.params,sprites:n.sprites,audios:n.audios,audioBlobs:C,atlasRects:new Map,atlasPages:[]}),{entity:{params:n.params,sprites:n.sprites,audios:n.audios,atlasTextureHandle:(e=Q==null?void 0:Q.textureHandle)!=null?e:null,atlasTextureHandles:(g=Q==null?void 0:Q.textureHandles)!=null?g:[],atlasRects:(I=Q==null?void 0:Q.rects)!=null?I:new Map,audioBuffers:new Map},audioBlobs:C}}finally{for(const Q of B.values())Q.close()}}releaseSharedSVGAEntity(A){const t=this.sharedSVGAEntities.get(A);t&&(t.refs=Math.max(0,t.refs-1),!(t.refs>0)&&(this.deleteSVGAAtlasTextures(t.entity),this.sharedSVGAEntities.delete(A)))}async createCachedSVGAAtlasTextures(A){const t=[];for(const e of A){const g=await createImageBitmap(new Blob([e.imageBytes],{type:"image/png"}),{premultiplyAlpha:"premultiply"}),I=this.backend.createTexture(g,{width:e.width,height:e.height,filter:"linear",premultiplyAlpha:!0,sourcePremultiplied:!0});g.close(),t.push(I)}return t}deleteSVGAAtlasTextures(A){var t,e;const g=(t=A.atlasTextureHandles)!=null&&t.length?A.atlasTextureHandles:A.atlasTextureHandle?[A.atlasTextureHandle]:[],I=new Set;for(const s of g)I.has(s.id)||(I.add(s.id),(e=this.backend)==null||e.deleteTexture(s))}async finishLoadSVGA(A,t,e){let g=0;for(const[I,s]of e)await this.manager.audioManager.decodeAudio(I,s),g++,g<e.size&&await new Promise(n=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>n());return}setTimeout(n,0)});A.videoEntity=t,A.options.svgaSlots&&(A.svgaSlotTextures=await pE(this.backend,A.videoEntity,A.options.svgaSlots))}svgaAtlasMaxSize(){var A,t,e;const g=(A=this.options.svgaAtlasMaxSize)!=null?A:OA.SVGA_ATLAS_MAX_SIZE,I=(e=(t=this.backend)==null?void 0:t.maxTextureSize)!=null?e:g;return Math.max(64,Math.min(I,g))}async buildSVGAAtlasIfNeeded(A,t){return A.size===0?null:VC(A,this.backend,this.svgaAtlasMaxSize(),OA.SVGA_ATLAS_PADDING,{captureEncodedPng:t,maxPages:this.svgaAtlasMaxPages()})}svgaAtlasMaxPages(){var A;return Math.max(1,Math.floor((A=this.options.svgaAtlasMaxPages)!=null?A:4))}shouldTryWebCodecs(){return this.options.preferWebCodecs===!0&&typeof VideoDecoder!="undefined"}logPlaybackBackend(A,t,e){const g=t==="webcodecs"?"WebCodecs (mp4box decode)":"HTMLVideoElement",I=e?` — ${e}`:"";console.info(`[GiftStage] ${A.type} [${A.id}]: ${g}${I}`)}async tryWebCodecsPlayback(A){if(!this.shouldTryWebCodecs())return null;try{const t=typeof A=="string"?await _s(A):A;return await vA.create(t,void 0,{useWorker:this.options.webCodecsDecodeInWorker!==!1,maxDecodedFrames:this.options.webCodecsMaxDecodedFrames,decodeAheadFrames:this.options.webCodecsDecodeAheadFrames})}catch(t){const e=t instanceof Error?t.message:String(t);return console.warn(`[GiftStage] WebCodecs path failed, falling back to <video>: ${e}`),null}}async loadVAP(A,t){var e;if(!t.config)throw new Error("VAP requires config");const g=await IB(t.config);A.vapConfig=g;const I=await SE(g,t.vapSlots);if(I.size>0){const Q=et(g.info),a=NE(g);let E=null,r=null;try{E=new cf(g,a,I,Q.w,Q.h)}catch(o){console.warn("[GiftStage] VAP mixed rendering fell back to CPU compositor",o),r=RE(Q.w,Q.h)}A.vapMixState={texture:this.backend.createEmptyTexture(Q.w,Q.h,{filter:"linear"}),width:Q.w,height:Q.h,composer:E,frameMap:a,resources:I,lastFrameIndex:-1,lastSourceRef:null,...r!=null?r:{}},A.videoTextureHandle=A.vapMixState.texture}console.info("[GiftStage:WC] loadVAP: try WebCodecs / video…");const n=await this.tryWebCodecsPlayback(t.source);if(n){A.webcodecsPlayback=n,A.wcPlaybackTime=0;const Q=n.getFrameForTime(0);if(!Q)throw n.destroy(),A.webcodecsPlayback=null,new Error("WebCodecs: missing first frame");if(!A.vapMixState){const E=Q.displayWidth||Q.codedWidth,r=Q.displayHeight||Q.codedHeight,{w:o,h}=BC(A,E,r,"vap",g),c=this.manager.tryAllocateWebCodecsAtlas(A.id,o,h,this.options.webCodecsVideoAtlas);if(c)A.videoTextureHandle=c.handle,A.wcAtlasRect=c.rect,this.backend.updateTextureRegion(c.handle,Q,c.rect.x,c.rect.y,o,h);else{const f=this.backend.createTexture(Q,{width:E,height:r,filter:"linear"});A.videoTextureHandle=f}}A.videoElement=null;const a=A.videoTextureHandle;console.info("[GiftStage:WC] VAP texture",{giftId:A.id,atlas:!!A.wcAtlasRect&&!A.vapMixState,mixed:!!A.vapMixState,tex:`${a.width}x${a.height}`,frame0:`${Q.displayWidth}x${Q.displayHeight}`,atlasCell:A.wcAtlasRect?`${A.wcAtlasRect.w}x${A.wcAtlasRect.h}`:void 0}),this.logPlaybackBackend(A,"webcodecs");return}const B=await this.tryAcquireSharedHtmlVideo(A,t);if(B)A.videoElement=B.video,A.releaseSharedVideoPlayback=B.release;else{const Q=await this.acquireVideoPlaybackSource(t.source);A.releaseMediaSource=(e=Q.release)!=null?e:null;const a=this.createVideo(Q.src,t.loop===0);A.videoElement=a}const C=A.videoElement;if(B){await B.ready;const Q=this.acquireSharedVideoTexture(B.cacheKey,C);A.videoTextureHandle=Q.texture,A.releaseSharedVideoTexture=Q.release}else await this.waitVideoReady(C),A.vapMixState||(A.videoTextureHandle=this.backend.createTexture(C,{width:C.videoWidth,height:C.videoHeight,filter:"linear"}));A.releaseSharedVideoPlayback||this.bindVideoLoopOnEnded(A,C),this.logPlaybackBackend(A,"video",this.shouldTryWebCodecs()?"fallback after WebCodecs unavailable or failed":"preferWebCodecs off or no VideoDecoder")}async loadAlphaVideo(A,t){var e;console.info("[GiftStage:WC] loadAlphaVideo: try WebCodecs / video…");const g=await this.tryWebCodecsPlayback(t.source);if(g){A.webcodecsPlayback=g,A.wcPlaybackTime=0;const n=g.getFrameForTime(0);if(!n)throw g.destroy(),A.webcodecsPlayback=null,new Error("WebCodecs: missing first frame");const B=n.displayWidth||n.codedWidth,C=n.displayHeight||n.codedHeight,{w:Q,h:a}=BC(A,B,C,"alphaVideo",void 0),E=this.manager.tryAllocateWebCodecsAtlas(A.id,Q,a,this.options.webCodecsVideoAtlas);if(E)A.videoTextureHandle=E.handle,A.wcAtlasRect=E.rect,this.backend.updateTextureRegion(E.handle,n,E.rect.x,E.rect.y,Q,a);else{const o=this.backend.createTexture(n,{width:B,height:C,filter:"linear"});A.videoTextureHandle=o}A.videoElement=null;const r=A.videoTextureHandle;console.info("[GiftStage:WC] alphaVideo texture",{giftId:A.id,atlas:!!A.wcAtlasRect,tex:`${r.width}x${r.height}`,frame0:`${n.displayWidth}x${n.displayHeight}`,atlasCell:A.wcAtlasRect?`${A.wcAtlasRect.w}x${A.wcAtlasRect.h}`:void 0}),this.logPlaybackBackend(A,"webcodecs");return}const I=await this.tryAcquireSharedHtmlVideo(A,t);if(I)A.videoElement=I.video,A.releaseSharedVideoPlayback=I.release;else{const n=await this.acquireVideoPlaybackSource(t.source);A.releaseMediaSource=(e=n.release)!=null?e:null;const B=this.createVideo(n.src,t.loop===0);A.videoElement=B}const s=A.videoElement;if(I){await I.ready;const n=this.acquireSharedVideoTexture(I.cacheKey,s);A.videoTextureHandle=n.texture,A.releaseSharedVideoTexture=n.release}else await this.waitVideoReady(s),A.videoTextureHandle=this.backend.createTexture(s,{width:s.videoWidth,height:s.videoHeight,filter:"linear"});A.releaseSharedVideoPlayback||this.bindVideoLoopOnEnded(A,s),this.logPlaybackBackend(A,"video",this.shouldTryWebCodecs()?"fallback after WebCodecs unavailable or failed":"preferWebCodecs off or no VideoDecoder")}bindVideoLoopOnEnded(A,t){t.addEventListener("ended",()=>{var e,g;if(A.state!=="playing")return;const I=(e=A.options.loop)!=null?e:1;if(I===0){t.currentTime=0,t.play();return}if(A.loopCount++,A.loopCount>=I){let s;s={id:A.id,type:A.type,pause:()=>{},resume:()=>{},destroy:()=>this.removeGift(A.id),animate:n=>this.createGiftAnimationChain(A,s,n)},(g=A.onComplete)==null||g.call(A,s),A.state=A.options.clearsAfterStop===!1?"stopped":"finished";return}t.currentTime=0,t.play()})}createVideo(A,t){const e=document.createElement("video");return e.crossOrigin="anonymous",e.autoplay=!0,e.preload="auto",e.muted=!0,e.playsInline=!0,e.setAttribute("playsinline",""),e.setAttribute("webkit-playsinline","true"),e.loop=t,e.style.cssText="display:none;",e.src=A,document.body.appendChild(e),e.load(),e}waitVideoMetadata(A){return new Promise((t,e)=>{const g=()=>{A.removeEventListener("loadedmetadata",I),A.removeEventListener("error",s)},I=()=>{g(),t()},s=()=>{g(),e(new Error("Video metadata load failed"))};A.addEventListener("loadedmetadata",I),A.addEventListener("error",s),A.readyState>=HTMLMediaElement.HAVE_METADATA&&(g(),t())})}async probeVideoNaturalSize(A,t="video"){var e;const g=await this.acquireVideoPlaybackSource(A),I=document.createElement("video");I.crossOrigin="anonymous",I.preload="metadata",I.muted=!0,I.playsInline=!0,I.setAttribute("playsinline",""),I.setAttribute("webkit-playsinline","true"),I.style.cssText="display:none;",I.src=g.src,document.body.appendChild(I),I.load();try{return await this.waitVideoMetadata(I),t==="alphaVideo"?Rf(I.videoWidth,I.videoHeight):{width:I.videoWidth,height:I.videoHeight}}finally{try{I.pause(),I.removeAttribute("src"),I.load(),I.remove()}catch(s){}(e=g.release)==null||e.call(g)}}async acquireVideoPlaybackSource(A){if(typeof A!="string"){const g=URL.createObjectURL(new Blob([A]));return{src:g,release:()=>URL.revokeObjectURL(g)}}const t=this.normalizeSharedVideoSourceKey(A);if(!t)return{src:A};let e=this.sharedVideoSources.get(t);e||(e={refs:0,objectUrl:null,promise:this.fetchSharedVideoSource(t)},this.sharedVideoSources.set(t,e)),e.refs++;try{return{src:await e.promise,release:()=>this.releaseSharedVideoSource(t)}}catch(g){return this.releaseSharedVideoSource(t),console.warn("[GiftStage] shared video prefetch failed, using original url",g),{src:A}}}normalizeSharedVideoSourceKey(A){try{const t=new URL(A,window.location.href);return t.protocol==="blob:"||t.protocol==="data:"?null:t.href}catch(t){return null}}async fetchSharedVideoSource(A){const t=new Blob([await _s(A)]),e=this.sharedVideoSources.get(A),g=URL.createObjectURL(t);return e&&(e.objectUrl=g,e.refs===0&&(URL.revokeObjectURL(g),this.sharedVideoSources.delete(A))),g}releaseSharedVideoSource(A){const t=this.sharedVideoSources.get(A);t&&(t.refs=Math.max(0,t.refs-1),t.refs===0&&t.objectUrl&&(URL.revokeObjectURL(t.objectUrl),this.sharedVideoSources.delete(A)))}async tryAcquireSharedHtmlVideo(A,t){var e,g;if(this.options.shareIdenticalVideoPlayback===!1||t.loop!==0||typeof t.source!="string"||A.type==="vap"&&A.vapMixState)return null;const I=this.normalizeSharedVideoSourceKey(t.source);if(!I)return null;const s=(e=this.options.sharedVideoPlaybackWindowMs)!=null?e:OA.DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS,n=Math.max(0,s)/1e3,B=this.sharedHtmlVideos.get(I);if(B)return B.video.currentTime>n?null:(B.refs++,{cacheKey:I,video:B.video,ready:B.ready,release:()=>this.releaseSharedHtmlVideo(I)});let C=this.pendingSharedHtmlVideos.get(I);C||(C=(async()=>{var E;const r=await this.acquireVideoPlaybackSource(t.source),o=this.createVideo(r.src,!0),h=this.waitVideoReady(o);return{video:o,ready:h,releaseSource:(E=r.release)!=null?E:null}})(),this.pendingSharedHtmlVideos.set(I,C));let Q;try{Q=await C}catch(E){throw this.pendingSharedHtmlVideos.delete(I),E}let a=this.sharedHtmlVideos.get(I);return a?a.refs++:(a={refs:1,video:Q.video,ready:Q.ready,releaseSource:(g=Q.releaseSource)!=null?g:null},this.sharedHtmlVideos.set(I,a)),this.pendingSharedHtmlVideos.delete(I),{cacheKey:I,video:a.video,ready:a.ready,release:()=>this.releaseSharedHtmlVideo(I)}}acquireSharedVideoTexture(A,t){const e=this.sharedVideoTextures.get(A);if(e)return e.refs++,{texture:e.texture,release:()=>this.releaseSharedVideoTexture(A)};const g=this.backend.createTexture(t,{width:t.videoWidth,height:t.videoHeight,filter:"linear"});return this.sharedVideoTextures.set(A,{refs:1,texture:g}),{texture:g,release:()=>this.releaseSharedVideoTexture(A)}}releaseSharedVideoTexture(A){var t;const e=this.sharedVideoTextures.get(A);e&&(e.refs=Math.max(0,e.refs-1),!(e.refs>0)&&((t=this.backend)==null||t.deleteTexture(e.texture),this.sharedVideoTextures.delete(A)))}releaseSharedHtmlVideo(A){var t;const e=this.sharedHtmlVideos.get(A);if(e&&(e.refs=Math.max(0,e.refs-1),!(e.refs>0))){try{e.video.pause(),e.video.removeAttribute("src"),e.video.load(),e.video.remove()}catch(g){}(t=e.releaseSource)==null||t.call(e),this.sharedHtmlVideos.delete(A)}}waitForFirstVideoFrame(A){return new Promise(t=>{typeof A.requestVideoFrameCallback=="function"?A.requestVideoFrameCallback(()=>t()):requestAnimationFrame(()=>t())})}waitVideoReady(A){return new Promise((t,e)=>{const g=()=>{A.removeEventListener("canplay",s),A.removeEventListener("error",n)},I=async()=>{try{await A.play(),await this.waitForFirstVideoFrame(A),t()}catch(B){e(B)}},s=()=>{g(),I()},n=()=>{g(),e(new Error("Video load failed"))};A.addEventListener("canplay",s),A.addEventListener("error",n),A.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA&&(g(),I())})}removeGift(A){var t;this.resolveGiftPlaybackWaiters(A),this.completedPlaybackSlots.delete(A),this.playbackCompleteWaiters.delete(A),(t=this.manager)==null||t.removeSlot(A)}removeAll(){if(this.manager)for(const A of this.manager.getSlotIds())this.manager.removeSlot(A)}pause(){var A;(A=this.manager)==null||A.pause()}resume(){var A;(A=this.manager)==null||A.resume()}get activeCount(){var A,t;return(t=(A=this.manager)==null?void 0:A.activeCount)!=null?t:0}get backendType(){var A,t;return(t=(A=this.backend)==null?void 0:A.type)!=null?t:"webgl2"}destroy(){var A,t;this.destroyed=!0,(A=this.resizeObserver)==null||A.disconnect(),this.resizeObserver=null,window.removeEventListener("resize",this.onWindowLayout),window.removeEventListener("orientationchange",this.onWindowLayout),(t=this.manager)==null||t.destroy();for(const[e]of this.sharedHtmlVideos)this.releaseSharedHtmlVideo(e);for(const[e]of this.sharedSVGAEntities)this.releaseSharedSVGAEntity(e);for(const[e]of this.sharedVideoTextures)this.releaseSharedVideoTexture(e);this.pendingSharedSVGAEntities.clear(),this.pendingSharedHtmlVideos.clear(),this.completedPlaybackSlots.clear(),this.playbackCompleteWaiters.clear();for(const[e,g]of this.sharedVideoSources)g.objectUrl&&URL.revokeObjectURL(g.objectUrl),this.sharedVideoSources.delete(e);this.canvas.remove(),this.backend=null,this.manager=null}markGiftPlaybackComplete(A){this.completedPlaybackSlots.add(A),this.resolveGiftPlaybackWaiters(A)}resolveGiftPlaybackWaiters(A){const t=this.playbackCompleteWaiters.get(A);if(!(!t||t.size===0)){for(const e of t)e();this.playbackCompleteWaiters.delete(A)}}waitForGiftPlaybackComplete(A){var t;return this.completedPlaybackSlots.has(A)||!((t=this.manager)!=null&&t.getSlot(A))?Promise.resolve():new Promise(e=>{let g=this.playbackCompleteWaiters.get(A);g||(g=new Set,this.playbackCompleteWaiters.set(A,g)),g.add(e)})}};z(ls,"SVGA_ATLAS_MAX_SIZE",2048);z(ls,"SVGA_ATLAS_PADDING",2);z(ls,"DEFAULT_SHARED_VIDEO_PLAYBACK_WINDOW_MS",100);z(ls,"DEFAULT_RESOURCE_CACHE_MEMORY_BYTES",128*1024*1024);z(ls,"DEFAULT_RESOURCE_CACHE_PERSISTENT_BYTES",2048*1024*1024);let bf=ls;exports.AlphaVideoRenderer=MC;exports.AudioManager=bC;exports.BufferPool=yC;exports.GiftStage=bf;exports.PostAnimator=xC;exports.RenderManager=LC;exports.SVGABatchRenderer=GC;exports.VAPRenderer=kC;exports.WebCodecsMp4Playback=vA;exports.WebGL1Backend=$n;exports.WebGL2Backend=oC;exports.WebGPUBackend=rC;exports.buildAtlas=VC;exports.buildBatchVerticesJS=Ps;exports.canSharedArrayBuffer=ca;exports.canWebGL1=ha;exports.canWebGL2=oa;exports.canWebGPU=ra;exports.clamp=eB;exports.createBackend=cC;exports.decodeSVGAProto=HC;exports.easeInOutCubic=Kr;exports.easeInOutQuad=Hr;exports.easeInQuad=_r;exports.easeOutBack=vr;exports.easeOutCubic=zC;exports.easeOutQuad=Jr;exports.generateId=mC;exports.inflateJS=_C;exports.initWasm=pC;exports.isWasmReady=At;exports.lerp=Gs;exports.linear=Lr;exports.ortho=TA;exports.parseSVGA=nB;exports.parseVAPConfig=IB;
|
|
8639
8639
|
//# sourceMappingURL=gift-stage.cjs.js.map
|
package/dist/gift-stage.es.js
CHANGED
|
@@ -22080,7 +22080,7 @@ const cs = class WA {
|
|
|
22080
22080
|
constructor(A) {
|
|
22081
22081
|
z(this, "sharedSVGAEntities", /* @__PURE__ */ new Map()), z(this, "pendingSharedSVGAEntities", /* @__PURE__ */ new Map()), z(this, "sharedVideoSources", /* @__PURE__ */ new Map()), z(this, "sharedHtmlVideos", /* @__PURE__ */ new Map()), z(this, "sharedVideoTextures", /* @__PURE__ */ new Map()), z(this, "pendingSharedHtmlVideos", /* @__PURE__ */ new Map()), z(this, "completedPlaybackSlots", /* @__PURE__ */ new Set()), z(this, "playbackCompleteWaiters", /* @__PURE__ */ new Map()), z(this, "canvas"), z(this, "backend", null), z(this, "manager", null), z(this, "options"), z(this, "ready"), z(this, "destroyed", !1), z(this, "resizeObserver", null), z(this, "nextRenderOrder", 0), z(this, "onWindowLayout", () => {
|
|
22082
22082
|
this.destroyed || this.syncCanvasSize();
|
|
22083
|
-
}), this.options = A, this.canvas = document.createElement("canvas"), this.canvas.style.cssText = "position:
|
|
22083
|
+
}), this.options = A, this.canvas = document.createElement("canvas"), this.canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:9999;", A.container.appendChild(this.canvas), this.ready = this.init();
|
|
22084
22084
|
}
|
|
22085
22085
|
backingStoreDpr() {
|
|
22086
22086
|
const A = this.options.resolution;
|
package/package.json
CHANGED