@ssgoi/core 7.3.0-beta.3 → 7.3.0-beta.4
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/animation/host-animation.d.ts +3 -0
- package/dist/animation/host-animation.d.ts.map +1 -1
- package/dist/animation/web-animation.d.ts +11 -1
- package/dist/animation/web-animation.d.ts.map +1 -1
- package/dist/animation/web-presentation.d.ts +14 -1
- package/dist/animation/web-presentation.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +727 -709
- package/dist/{retain-opacity-Bp_Y__-B.js → retain-opacity-BVcRlLr1.js} +348 -331
- package/dist/retain-opacity-BrtENsD0.cjs +1 -0
- package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/retain-opacity-5kqI1OCo.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ut=Object.defineProperty;var dt=(s,n,t)=>n in s?ut(s,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[n]=t;var h=(s,n,t)=>dt(s,typeof n!="symbol"?n+"":n,t);const _=require("./provider-JDtJ5Jzf.cjs"),V={reason:"finished",owns:()=>!0};class Z extends _.Animation{constructor(){super(...arguments);h(this,"_startCondition");h(this,"onDispose");h(this,"deferDisposal",!1)}getMotionTracks(){return[]}validate(){}get supportsInterruption(){return!1}stop(){this.pause()}cancel(t){var e;this.isComplete||this.complete(),(e=this.onDispose)==null||e.call(this,t)}get startCondition(){return this._startCondition}set(t){if(t.startAt){const{after:e,at:i}=t.startAt;if(e===this)throw new Error("An animation cannot start after itself");if(i!=="settled"&&(!Number.isFinite(i)||i<0||i>1))throw new Error("startAt.at must be a progress from 0 to 1 or settled")}if(t.integrator!==void 0){if(typeof t.integrator.step!="function"||typeof t.integrator.isSettled!="function")throw new Error("An integrator must implement step and isSettled");this.setIntegrator(t.integrator)}return t.startAt!==void 0&&(this._startCondition=t.startAt?{...t.startAt}:void 0),this}setIntegrator(t){throw new Error("This animation does not support replacing its integrator")}}const H=[1,0,0,1,0,0],at=(s,n)=>[s[0]*n[0]+s[2]*n[1],s[1]*n[0]+s[3]*n[1],s[0]*n[2]+s[2]*n[3],s[1]*n[2]+s[3]*n[3],s[0]*n[4]+s[2]*n[5]+s[4],s[1]*n[4]+s[3]*n[5]+s[5]];function et(s){const n=s[0]*s[3]-s[1]*s[2];return Math.abs(n)<1e-10?null:[s[3]/n,-s[1]/n,-s[2]/n,s[0]/n,(s[2]*s[5]-s[3]*s[4])/n,(s[1]*s[4]-s[0]*s[5])/n]}const B=(s,n)=>[1,0,0,1,s,n],U=(s,n)=>[s,0,0,n,0,0];function ft(s,n,t){if(!s||s==="none")return[...H];let e=[...H];const i=/([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;let l="";for(const c of s.matchAll(i)){l+=c[0];const u=c[1].toLowerCase(),d=c[2].trim().split(/\s*,\s*|\s+/);if(d.some(r=>!/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(r)))return null;const m=d.map(Number.parseFloat);if(m.some(r=>!Number.isFinite(r)))return null;const y=(r,g)=>{var a;return m[r]*((a=d[r])!=null&&a.endsWith("%")?g/100:1)},f=r=>{var g,a;return m[r]*((g=d[r])!=null&&g.endsWith("rad")?1:(a=d[r])!=null&&a.endsWith("turn")?2*Math.PI:Math.PI/180)};let o;if(u==="matrix"&&m.length===6)o=m;else if(u==="translate"||u==="translate3d"){if(u==="translate3d"&&m[2]!==0)return null;o=B(y(0,n),d[1]?y(1,t):0)}else if(u==="translatex")o=B(y(0,n),0);else if(u==="translatey")o=B(0,y(0,t));else if(u==="translatez"&&m[0]===0)o=[...H];else if(u==="scale")o=U(m[0],m[1]??m[0]);else if(u==="scalex")o=U(m[0],1);else if(u==="scaley")o=U(1,m[0]);else if(u==="rotate"||u==="rotatez"){const r=f(0);o=[Math.cos(r),Math.sin(r),-Math.sin(r),Math.cos(r),0,0]}else return null;e=at(e,o)}return l.replace(/\s/g,"")===s.replace(/\s/g,"")?e:null}function st(s,n){return{schema:s,value:n,velocity:n.map(()=>0)}}const it=/[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi,A=s=>[s[0],s[2],s[4],s[1],s[3],s[5],0,0,1];function T(s,n){return Array.from({length:9},(t,e)=>{const i=Math.floor(e/3),l=e%3;return s[i*3]*n[l]+s[i*3+1]*n[l+3]+s[i*3+2]*n[l+6]})}function lt(s){return Math.abs(s[8])<1e-8||!s.every(Number.isFinite)?null:s.map(n=>n/s[8])}function nt(s,n,t){const e=ft(s,n,t);if(e)return A(e);if(typeof DOMMatrix>"u")return null;const i=s.replace(/(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,(l,c,u)=>{const d=u.split(/\s*,\s*|\s+/).map((m,y)=>{if(!m.endsWith("%"))return m;const f=c.toLowerCase()==="translatey"||y===1?t:n;return`${Number.parseFloat(m)*f/100}px`});return`${c}(${d.join(",")})`});try{const l=new DOMMatrix(i);return lt([l.m11,l.m21,l.m41,l.m12,l.m22,l.m42,l.m14,l.m24,l.m44])}catch{return null}}const rt="viewport-plane-v1";function O(s,n){var J;const t=s.offsetWidth||1,e=s.offsetHeight||1,i=typeof getComputedStyle=="function"?getComputedStyle(s):null,l=((i==null?void 0:i.transformOrigin)||`${t/2}px ${e/2}px`).split(" "),c=Number.parseFloat(l[0])||0,u=Number.parseFloat(l[1])||0;let d=!0,m=!!n&&n.container!==s&&n.container.contains(s)&&(i==null?void 0:i.position)!=="fixed";if(typeof getComputedStyle=="function"){let S=m;for(let C=s.parentElement;C;C=C.parentElement){C===(n==null?void 0:n.container)&&(S=!1);const w=getComputedStyle(C);if(S&&w.position==="fixed"&&(m=!1),w.transform&&w.transform!=="none"||w.perspective&&w.perspective!=="none"){d=!1;break}}}const y=m?n.container.scrollLeft-n.x:0,f=m?n.container.scrollTop-n.y:0,o=(J=s.getBoundingClientRect)==null?void 0:J.call(s),r=nt((i==null?void 0:i.transform)||"",t,e)??A(H),g=T(T(A(B(c,u)),r),A(B(-c,-u))),a=[[0,0],[t,0],[0,e],[t,e]].map(([S,C])=>{const w=g[6]*S+g[7]*C+g[8];return[(g[0]*S+g[1]*C+g[2])/w,(g[3]*S+g[4]*C+g[5])/w]}),p=((o==null?void 0:o.left)??0)+y-Math.min(...a.map(S=>S[0])),b=((o==null?void 0:o.top)??0)+f-Math.min(...a.map(S=>S[1])),k=B(p+c,b+u),G=at(B(-c,-u),U(t,e)),ht=A(et(k)),ct=A(et(G));return{frame:d?{left:p,top:b,width:t,height:e}:void 0,read(S){const C={};for(const[w,F]of Object.entries(S)){const M=String(F);if(w==="transform"){if(!d)continue;const I=nt(M,t,e),D=I&<(T(T(A(k),I),A(G)));if(D){const[N,W,x,E,j,P,q,v]=D,z=N-x*q,$=E-P*q,Q=W-x*v,tt=j-P*v,L=Math.hypot(z,$);if(L>1e-8){C[w]=st(rt,[x,P,Math.atan2($,z),L,(z*tt-$*Q)/L,(z*Q+$*tt)/L,q,v]);continue}}}const R=[...M.matchAll(it)].map(I=>Number(I[0]));R.length&&R.every(Number.isFinite)&&(C[w]=st(`css:${M.replace(it,"#")}`,R))}return C},write(S){const C={};for(const[w,F]of Object.entries(S))if(w==="transform"&&F.schema===rt){const[M,R,I,D,N,W,x,E]=F.value,j=Math.cos(I),P=Math.sin(I),q=[j*D+M*x,j*W-P*N+M*E,M,P*D+R*x,P*W+j*N+R*E,R,x,E,1],v=T(T(ht,q),ct);Math.abs(v[6])+Math.abs(v[7])<1e-10&&Math.abs(v[8]-1)<1e-10?C[w]=`matrix(${[v[0],v[3],v[1],v[4],v[2],v[5]].join(",")})`:C[w]=`matrix3d(${[v[0],v[3],0,v[6],v[1],v[4],0,v[7],0,0,1,0,v[2],v[5],0,v[8]].join(",")})`}else if(F.schema.startsWith("css:")){let M=0;C[w]=F.schema.slice(4).replace(/#/g,()=>String(F.value[M++]))}return C}}}const pt=1e3/60;class X extends Z{constructor(t){super();h(this,"_element");h(this,"_integrator");h(this,"label");h(this,"styleFn");h(this,"lowerBound");h(this,"upperBound");h(this,"currentValue");h(this,"currentVelocity",0);h(this,"solverState");h(this,"solverTarget",1);h(this,"presentationTime",0);h(this,"renderedStyles",[]);h(this,"frames",[]);h(this,"waapi",null);h(this,"runId",0);h(this,"running",!1);h(this,"paused",!1);h(this,"settled",!1);h(this,"reversing",!1);h(this,"disposed",!1);h(this,"legacyCompletionCleanup");h(this,"motion");h(this,"codec");h(this,"viewport");h(this,"adopted");h(this,"presentationFrames",[]);h(this,"hold",null);h(this,"fallbackCopy",null);h(this,"fallbackChannels",new Set);h(this,"fallbackMode");this._element=t.element,this._integrator=t.integrator,this.label=t.label,this.styleFn=t.style,this.lowerBound=t.lowerBound??0,this.upperBound=t.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=t.onUpdate,this.legacyCompletionCleanup=!!t.onComplete&&!t.onDispose,this.onComplete=t.onComplete,this.onDispose=t.onDispose,this.motion=t.motion??{}}get handoffFallbackMode(){return this.fallbackMode}get handoffFallbacks(){return[...this.fallbackChannels]}get element(){return this._element}get integrator(){return this._integrator}set integrator(t){this._integrator=t,this.solverState=void 0}setIntegrator(t){this._integrator=t,this.solverState=void 0}play(){var e;const t=this.reversing;if(this.reversing=!1,this.paused&&this.waapi&&!t){this.paused=!1,this.running=!0,this.waapi.play(),(e=this.fallbackCopy)==null||e.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),(e=this.fallbackCopy)==null||e.pause(),this.running=!1,this.paused=!0)}complete(){this.settled||(this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,this.finish())}validate(){const t=this.motion.handoffDuration??280;if(!Number.isFinite(t)||t<0||t>1e4)throw new Error("handoffDuration must be finite and between 0 and 10000 ms")}getMotionTracks(){return[this]}get supportsInterruption(){return!this.legacyCompletionCleanup}stop(){var t,e;this.captureLiveState(),this.clearWaapi(),(t=this.hold)==null||t.cancel(),this.hold=null,(e=this.fallbackCopy)==null||e.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.running=!1,this.paused=!1}cancel(t){this.stop(),this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed&&(this.disposed=!0,t.owns(this.element)))try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] animation cleanup failed",i)}}finish(){var t,e,i,l;this.presentationTime=((t=this.frames[this.frames.length-1])==null?void 0:t.time)??0,this.solverState=void 0,(e=this.hold)==null||e.cancel(),this.hold=null,this.applyStyleAt(this.currentValue),this.clearWaapi(),(i=this.fallbackCopy)==null||i.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.deferDisposal||this.disposeResources(V),(l=this.onComplete)==null||l.call(this)}get motionIdentity(){return{target:this.element,key:this.motion.key,role:this.motion.role,space:this.motion.space,lifetime:this.motion.lifetime}}measure(t){if(this.viewport=t??this.viewport,this.codec)return;const e=this._element;!e.isConnected||!(e.offsetWidth||e.offsetHeight)||(this.codec=this.motion.codec??O(e,this.viewport))}getMotionSnapshot(){var l,c;this.running&&this.captureLiveState();const t=this.samplePresentation(ot(this.waapi)??this.presentationTime),e=this.paused?0:this.playbackRate,i={...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),...(l=this.codec)==null?void 0:l.write(t)};return{...this.motionIdentity,displayStyle:i,inlineStyle:this.element.style.cssText,frame:(c=this.codec)==null?void 0:c.frame,channels:Object.fromEntries(Object.entries(t).map(([u,d])=>[u,{...d,velocity:d.velocity.map(m=>m*e)}]))}}adopt(t){var u,d,m,y,f;this.codec??(this.codec=this.motion.codec??O(this.element,this.viewport)),this.adopted=t;const e=this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)});this.fallbackChannels.clear(),this.fallbackMode=void 0;const i=this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),l=t.displayStyle;for(const[o,r]of Object.entries(l??{}))o in i&&String(r)!==String(i[o])&&(!t.channels[o]||!e[o])&&this.fallbackChannels.add(o);for(const[o,r]of Object.entries(t.channels)){const g=e[o];g&&!_.compatibleChannel(r,g)&&this.fallbackChannels.add(o)}if(this.fallbackChannels.size&&(this.fallbackMode="finish"),this.fallbackChannels.size&&this.motion.fallback!=="finish"){const o=t;if(o.frame&&o.displayStyle&&t.target.cloneNode&&t.target.parentElement&&!t.target.shadowRoot&&!((d=(u=t.target).matches)!=null&&d.call(u,"canvas, video, audio, iframe, object, embed"))&&!((y=(m=t.target).querySelector)!=null&&y.call(m,"canvas, video, audio, iframe, object, embed"))){this.fallbackMode="crossfade";const r=t.target.cloneNode(!0);r.removeAttribute("id"),r.removeAttribute("data-ssgoi-transition");for(const a of r.querySelectorAll("[id], [data-ssgoi-transition]"))a.removeAttribute("id"),a.removeAttribute("data-ssgoi-transition");r.style.cssText=o.inlineStyle??"",Object.assign(r.style,o.displayStyle,{position:"fixed",left:`${o.frame.left}px`,top:`${o.frame.top}px`,width:`${o.frame.width}px`,height:`${o.frame.height}px`,margin:"0",pointerEvents:"none",zIndex:"2147483646"}),r.setAttribute("aria-hidden","true"),r.inert=!0,t.target.parentElement.appendChild(r);const g=Number(o.displayStyle.opacity??1);this.fallbackCopy=new X({element:r,integrator:{step:(a,p,b)=>({position:Math.min(p,a.position+b/.18),velocity:0}),isSettled:(a,p)=>a.position>=p},style:(a,p)=>({opacity:g*p}),onDispose:()=>r.remove()}),this.adopted={...t,channels:{...t.channels,opacity:{schema:"css:#",value:[0],velocity:[0]}}}}}const c=this.codec.write(this.adopted.channels);(f=this.hold)==null||f.cancel(),Object.keys(c).length&&(this.hold=this.element.animate([c,c],{duration:1,fill:"both"}),this.hold.pause(),this.hold.currentTime=0)}channelsAt(t){const e=this.presentationFrames[t];if(e)return e.channels;const i=this.frames[t];return this.codec??(this.codec=this.motion.codec??O(this.element,this.viewport)),this.codec.read({transform:"none",opacity:1,...this.styleFn(i.position,this.lowerBound+this.upperBound-i.position)})}samplePresentation(t){const e=this.frames;if(!e.length)return this.adopted?{...this.adopted.channels}:(this.codec??(this.codec=this.motion.codec??O(this.element,this.viewport)),this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)}));let i=e.findIndex(r=>r.time>t);i<0&&(i=e.length-1);const l=Math.max(0,i-1),c=e[l],u=e[i],d=this.channelsAt(l),m=l===i?d:this.channelsAt(i),y=(u.time-c.time)/1e3,f=y?Math.max(0,Math.min(1,(t-c.time)/(y*1e3))):0,o={};for(const[r,g]of Object.entries(d)){const a=m[r];if(!a||!_.compatibleChannel(g,a)){o[r]=g;continue}o[r]={schema:g.schema,value:g.value.map((p,b)=>p+(a.value[b]-p)*f),velocity:g.value.map((p,b)=>t>=e[e.length-1].time||!y?0:(a.value[b]-p)/y)}}return o}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const i of this.frames)if((i.position-this.lowerBound)/e>=t)return i.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this._element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map((e,i)=>{const l=e.position,c=this.lowerBound+this.upperBound-l;return{time:e.time,value:e.position,velocity:e.velocity,style:this.renderedStyles[i]??this.styleFn(l,c)}});return[{element:this._element,frames:t}]}matchInto(t){const e=t.find(i=>i.element===this._element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity,this.solverState=void 0)}runToward(t){var m,y;if(this.validate(),this.running||this.paused){const f=this.getMotionSnapshot();this.captureLiveState(),this.adopted=f}if(this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.disposed=!1,this.presentationTime=0,this.presentationFrames=[],this.solverTarget=t,this.frames=_.simulate(this._integrator,this.currentValue,t,this.currentVelocity,this.solverState,!0),this.frames.length===0&&this.adopted&&(this.frames=[{time:0,position:t,velocity:0}]),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,this.finish();return}const e=f=>this.styleFn(f.position,this.lowerBound+this.upperBound-f.position),i=this.adopted?this.bridgeKeyframes(e):this.frames.map(f=>e(f));this.renderedStyles=i,this.adopted=void 0;const l=i[0],c=this.frames[this.frames.length-1],u=c.time;this.runId++;const d=this._element.animate(i,{duration:u,fill:"both",easing:"linear",composite:"replace"});d.playbackRate=this.playbackRate,this.waapi=d,(m=this.fallbackCopy)==null||m.play(),(y=this.hold)==null||y.cancel(),this.hold=null,this.running=!0,d.onfinish=()=>{!this.running||this.waapi!==d||(this.running=!1,this.settled=!0,this.currentValue=c.position,this.currentVelocity=0,this.finish())},this.clearInlineStyle(l),this.beginPlayback(d,u)}bridgeKeyframes(t){var y;this.codec=this.motion.codec??O(this.element,this.viewport);const e=this.codec,i=Math.max(16,this.motion.handoffDuration??280),l=this.frames[this.frames.length-1];for(let f=l.time+1e3/60;f<i+1e3/60;f+=1e3/60)this.frames.push({time:f,position:l.position,velocity:0});const c=this.frames.map(f=>e.read({transform:"none",opacity:1,...t(f)}));for(let f=1;f<c.length;f++){const o=c[f-1].transform,r=c[f].transform;if((o==null?void 0:o.schema)==="viewport-plane-v1"&&(r==null?void 0:r.schema)===o.schema){const g=[...r.value];g[2]=o.value[2]+Math.atan2(Math.sin(g[2]-o.value[2]),Math.cos(g[2]-o.value[2])),c[f].transform={...r,value:g}}}const u=c[0],d=c[1]??u,m={};for(const[f,o]of Object.entries(((y=this.adopted)==null?void 0:y.channels)??{})){let r=u[f];if(!r){const a=f==="transform"?{transform:"none"}:f==="opacity"?{opacity:1}:{};if(r=e.read(a)[f],r)for(const p of c)p[f]=r}if(!r||!_.compatibleChannel(o,r))continue;const g=d[f]??r;m[f]={offset:o.value.map((a,p)=>{let b=a-r.value[p];return f==="transform"&&o.schema==="viewport-plane-v1"&&p===2&&(b=Math.atan2(Math.sin(b),Math.cos(b))),b}),velocity:o.velocity.map((a,p)=>a/Math.max(Math.abs(this.playbackRate),1e-4)-(g.value[p]-r.value[p])*60)}}return this.presentationFrames=this.frames.map((f,o)=>{const r={...c[o]};for(const[g,a]of Object.entries(m)){const p=r[g];r[g]={...p,value:p.value.map((b,k)=>b+_.residualAt(a.offset[k],a.velocity[k],f.time/1e3,i/1e3).value)}}return{time:f.time,channels:r}}),this.frames.map((f,o)=>{const r=this.presentationFrames[o].channels;return{...t(f),...e.write(Object.fromEntries(Object.keys(m).map(g=>[g,r[g]])))}})}clearWaapi(){var t;this.runId++,(t=this.waapi)==null||t.cancel(),this.waapi=null}captureLiveState(){if(this.frames.length===0)return;const t=ot(this.waapi);if(t===null)return;this.presentationTime=t;const{position:e,velocity:i}=_.interpolateFrame(this.frames,t);this.currentValue=e,this.currentVelocity=i,this.solverState=_.sampleIntegratorState(this.frames,t,this._integrator,this.solverTarget)}beginPlayback(t,e){const i=this.playbackRate;if(i<0){t.play();return}i>0&&(t.currentTime=Math.min(e,pt*i))}clearInlineStyle(t){if(t)for(const e of Object.keys(t))this._element.style[e]=""}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,i=this.styleFn(t,e);for(const[l,c]of Object.entries(i))this._element.style[l]=typeof c=="number"?String(c):c}}function ot(s){const n=s==null?void 0:s.currentTime;return typeof n=="number"?n:null}class mt{constructor(){h(this,"callbacks",new Set);h(this,"frameRequest",null);h(this,"tick",()=>{this.frameRequest=null;for(const n of[...this.callbacks])this.callbacks.has(n)&&n();this.requestFrame()})}subscribe(n){return this.callbacks.add(n),this.requestFrame(),()=>{this.callbacks.delete(n),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||this.callbacks.size===0||(this.frameRequest=requestAnimationFrame(this.tick))}stopIfIdle(){this.callbacks.size>0||this.frameRequest===null||(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameRequest),this.frameRequest=null)}}const gt=new mt;function yt(s){return typeof s.step=="function"?s:_.IntegratorProvider.from(s)}class Y extends Z{constructor(t,e={}){super();h(this,"_children");h(this,"progressChildren");h(this,"_startAt");h(this,"namedChildren");h(this,"restoreChildCallbacks",[]);h(this,"runId",0);h(this,"pendingComplete",0);h(this,"running",!1);h(this,"disposed",!1);h(this,"settled",!1);h(this,"startedChildren",new Set);h(this,"lastMethod","play");h(this,"pausedRun",!1);h(this,"pendingStartObservers",[]);this.namedChildren=new Map(Array.isArray(t)?[]:Object.entries(t)),this._children=Array.isArray(t)?[...t]:[...this.namedChildren.values()];for(const i of this._children)i.deferDisposal=!0;this.progressChildren=this._children.filter(i=>!(i instanceof Y)||i.progressChildren.length>0),(e.mode??"parallel")==="sequence"?this._startAt=this._children.map((i,l)=>l===0?0:1):this._startAt=e.startAt??[]}get children(){return this._children}get startAt(){return this._startAt}set startAt(t){this._startAt=t}tracks(){return this._children.flatMap(t=>[...t.getMotionTracks()])}getMotionTracks(){return this.tracks()}validate(){this.buildDependencies();for(const t of this._children)t.validate()}select(t){const e=this.namedChildren.get(t);if(!e)throw new Error(`Unknown animation child: ${t}`);return e}set(t,e){if(typeof t=="string"){const i=this.select(t);return(e==null?void 0:e.integrator)!==void 0&&i.set({integrator:yt(e.integrator)}),this}return super.set(t)}setIntegrator(t){for(const e of this._children)e.set({integrator:t})}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.pausedRun=this.running||this.pausedRun,this.running=!1,this.clearPendingStartObservers();for(const t of this._children)t.pause()}complete(){var t;if(!this.settled){this.settled=!0,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const e of this._children)e.complete();if(!this.deferDisposal){for(const e of this._children)e.cancel(V);this.disposeResources(V)}(t=this.onComplete)==null||t.call(this)}}get supportsInterruption(){return this._children.every(t=>t.supportsInterruption)}stop(){this.runId++,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const t of this._children)t.stop()}cancel(t){this.stop();for(const e of this._children)e.cancel(t);this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed){this.disposed=!0;try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] composite cleanup failed",i)}}}get progress(){if(this.progressChildren.length===0)return 0;let t=0;for(const e of this.progressChildren)t+=e.progress;return t/this.progressChildren.length}getPose(){return this._children.flatMap(t=>t.getPose())}getTimeline(){return this._children.flatMap(t=>t.getTimeline())}matchInto(t){for(const e of this._children)e.matchInto(t)}get isAnimating(){return this._children.some(t=>t.isAnimating)}get isPaused(){return this._children.some(t=>t.isPaused)&&this._children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.settled}get isReversing(){return this._children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this._children)e.playbackRate=t}startRun(t){const e=this.buildDependencies(),i=this.pausedRun&&t===this.lastMethod,l=t!==this.lastMethod,c=new Set(this.startedChildren),u=new Set(this._children.filter(a=>a.isComplete)),d=t==="reverse"&&c.size?this._children.filter(a=>c.has(a)):[...this._children],m=t==="reverse"?[...d].reverse():d,y=new Map;if(t==="reverse")for(const[a,p]of e){if(!d.includes(a)||!d.includes(p.after))continue;const b=y.get(p.after)??[];b.push({after:a,at:p.at==="settled"?"settled":1-p.at}),y.set(p.after,b)}else for(const[a,p]of e)y.set(a,[p]);if(l||i)for(const a of c)u.has(a)||y.delete(a);this.running&&this.pause(),this.restoreCompletionHandlers();const f=++this.runId;if(this.running=!0,this.pausedRun=!1,this.lastMethod=t,this.disposed=!1,this.settled=!1,this.pendingComplete=d.length,!i&&!l&&this.startedChildren.clear(),this.pendingComplete===0){this.handleFinished();return}const o=new Set,r=new Set;if(i)for(const a of d)c.has(a)&&u.has(a)&&(r.add(a),o.add(a),this.pendingComplete--);for(const a of d){const p=a.onComplete,b=()=>{if(!(this.runId!==f||!this.running||o.has(a))){try{p==null||p()}catch(k){console.error("[ssgoi] animation completion failed",k)}o.add(a),--this.pendingComplete===0&&this.handleFinished()}};a.onComplete=b,this.restoreChildCallbacks.push(()=>{a.onComplete===b&&(a.onComplete=p)})}const g=()=>{let a=!0;for(;this.running&&this.runId===f&&a;){a=!1;for(const p of m)!this.running||r.has(p)||(y.get(p)??[]).some(k=>!r.has(k.after)||!this.hasReachedThreshold(k.after,k.at,t))||(r.add(p),this.startedChildren.add(p),p[t](),a=!0)}r.size===d.length&&this.clearPendingStartObservers()};g(),this.pendingComplete===0&&this.handleFinished(),this.running&&r.size!==d.length&&this.pendingStartObservers.push(gt.subscribe(g))}buildDependencies(){const t=new Map,e=new Set(this._children);if(e.size!==this._children.length)throw new Error("Each child animation must occur once in a MultiAnimation");this._children.forEach((u,d)=>{const m=u.startCondition;if(m){if(!e.has(m.after))throw new Error("startAt.after must reference a sibling in the same MultiAnimation");t.set(u,{...m})}else d>0&&this._startAt.some(y=>y>0)&&t.set(u,{after:this._children[d-1],at:this._startAt[d]??0})});const i=new Set,l=new Set,c=u=>{if(l.has(u))throw new Error("Animation startAt dependencies form a cycle");if(i.has(u))return;l.add(u);const d=t.get(u);d&&c(d.after),l.delete(u),i.add(u)};return this._children.forEach(c),t}hasReachedThreshold(t,e,i){return t.isComplete?!0:e==="settled"?!1:e<=0?!0:(i==="play"?t.progress:1-t.progress)>=e}clearPendingStartObservers(){for(const t of this.pendingStartObservers)t();this.pendingStartObservers=[]}restoreCompletionHandlers(){for(const t of this.restoreChildCallbacks)t();this.restoreChildCallbacks=[]}handleFinished(){var t;if(this.running){if(this.running=!1,this.settled=!0,this.clearPendingStartObservers(),this.restoreCompletionHandlers(),!this.deferDisposal){for(const e of this._children)e.cancel(V);this.disposeResources(V)}(t=this.onComplete)==null||t.call(this)}}findTimeForProgress(t){return null}}const K=new WeakMap;function bt(s){const n=K.get(s)??{value:s.style.getPropertyValue("opacity"),priority:s.style.getPropertyPriority("opacity"),opacity:typeof getComputedStyle=="function"?Number.parseFloat(getComputedStyle(s).opacity):Number.NaN,users:new Set},t={};n.users.add(t),K.set(s,n);let e=!1;return{opacity:Number.isFinite(n.opacity)?n.opacity:1,set:i=>{t.value=i,s.style.opacity=String(i)},restore:()=>{if(!e){if(e=!0,n.users.delete(t),n.users.size>0){const i=Array.from(n.users),l=i[i.length-1];(l==null?void 0:l.value)!==void 0&&(s.style.opacity=String(l.value));return}n.value?s.style.setProperty("opacity",n.value,n.priority):s.style.removeProperty("opacity"),K.delete(s)}}}}exports.Animation=Z;exports.MultiAnimation=Y;exports.WebAnimation=X;exports.createWebPresentationCodec=O;exports.finishedDisposal=V;exports.retainOpacity=bt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-ssgoi-transition-context.d.ts","sourceRoot":"","sources":["../../src/lib/ssgoi-transition/create-ssgoi-transition-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,YAAY,EAQb,MAAM,QAAQ,CAAC;AAShB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAuC5D;;;;;;;;;GASG;AACH,MAAM,WAAW,mCAAmC;IAClD;;;;OAIG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,EACpB,cAAc,GAAE,mCAAwC,GACvD,YAAY,
|
|
1
|
+
{"version":3,"file":"create-ssgoi-transition-context.d.ts","sourceRoot":"","sources":["../../src/lib/ssgoi-transition/create-ssgoi-transition-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,YAAY,EAQb,MAAM,QAAQ,CAAC;AAShB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAuC5D;;;;;;;;;GASG;AACH,MAAM,WAAW,mCAAmC;IAClD;;;;OAIG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,EACpB,cAAc,GAAE,mCAAwC,GACvD,YAAY,CAs2Bd"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var at=Object.defineProperty;var lt=(s,n,t)=>n in s?at(s,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[n]=t;var h=(s,n,t)=>lt(s,typeof n!="symbol"?n+"":n,t);const _=require("./provider-JDtJ5Jzf.cjs"),x={reason:"finished",owns:()=>!0};class Z extends _.Animation{constructor(){super(...arguments);h(this,"_startCondition");h(this,"onDispose");h(this,"deferDisposal",!1)}getMotionTracks(){return[]}validate(){}get supportsInterruption(){return!1}stop(){this.pause()}cancel(t){var e;this.isComplete||this.complete(),(e=this.onDispose)==null||e.call(this,t)}get startCondition(){return this._startCondition}set(t){if(t.startAt){const{after:e,at:i}=t.startAt;if(e===this)throw new Error("An animation cannot start after itself");if(i!=="settled"&&(!Number.isFinite(i)||i<0||i>1))throw new Error("startAt.at must be a progress from 0 to 1 or settled")}if(t.integrator!==void 0){if(typeof t.integrator.step!="function"||typeof t.integrator.isSettled!="function")throw new Error("An integrator must implement step and isSettled");this.setIntegrator(t.integrator)}return t.startAt!==void 0&&(this._startCondition=t.startAt?{...t.startAt}:void 0),this}setIntegrator(t){throw new Error("This animation does not support replacing its integrator")}}const H=[1,0,0,1,0,0],rt=(s,n)=>[s[0]*n[0]+s[2]*n[1],s[1]*n[0]+s[3]*n[1],s[0]*n[2]+s[2]*n[3],s[1]*n[2]+s[3]*n[3],s[0]*n[4]+s[2]*n[5]+s[4],s[1]*n[4]+s[3]*n[5]+s[5]];function Q(s){const n=s[0]*s[3]-s[1]*s[2];return Math.abs(n)<1e-10?null:[s[3]/n,-s[1]/n,-s[2]/n,s[0]/n,(s[2]*s[5]-s[3]*s[4])/n,(s[1]*s[4]-s[0]*s[5])/n]}const T=(s,n)=>[1,0,0,1,s,n],U=(s,n)=>[s,0,0,n,0,0];function ht(s,n,t){if(!s||s==="none")return[...H];let e=[...H];const i=/([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;let o="";for(const d of s.matchAll(i)){o+=d[0];const p=d[1].toLowerCase(),c=d[2].trim().split(/\s*,\s*|\s+/);if(c.some(r=>!/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(r)))return null;const m=c.map(Number.parseFloat);if(m.some(r=>!Number.isFinite(r)))return null;const g=(r,y)=>{var a;return m[r]*((a=c[r])!=null&&a.endsWith("%")?y/100:1)},u=r=>{var y,a;return m[r]*((y=c[r])!=null&&y.endsWith("rad")?1:(a=c[r])!=null&&a.endsWith("turn")?2*Math.PI:Math.PI/180)};let l;if(p==="matrix"&&m.length===6)l=m;else if(p==="translate"||p==="translate3d"){if(p==="translate3d"&&m[2]!==0)return null;l=T(g(0,n),c[1]?g(1,t):0)}else if(p==="translatex")l=T(g(0,n),0);else if(p==="translatey")l=T(0,g(0,t));else if(p==="translatez"&&m[0]===0)l=[...H];else if(p==="scale")l=U(m[0],m[1]??m[0]);else if(p==="scalex")l=U(m[0],1);else if(p==="scaley")l=U(1,m[0]);else if(p==="rotate"||p==="rotatez"){const r=u(0);l=[Math.cos(r),Math.sin(r),-Math.sin(r),Math.cos(r),0,0]}else return null;e=rt(e,l)}return o.replace(/\s/g,"")===s.replace(/\s/g,"")?e:null}function tt(s,n){return{schema:s,value:n,velocity:n.map(()=>0)}}const et=/[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi,A=s=>[s[0],s[2],s[4],s[1],s[3],s[5],0,0,1];function O(s,n){return Array.from({length:9},(t,e)=>{const i=Math.floor(e/3),o=e%3;return s[i*3]*n[o]+s[i*3+1]*n[o+3]+s[i*3+2]*n[o+6]})}function ot(s){return Math.abs(s[8])<1e-8||!s.every(Number.isFinite)?null:s.map(n=>n/s[8])}function st(s,n,t){const e=ht(s,n,t);if(e)return A(e);if(typeof DOMMatrix>"u")return null;const i=s.replace(/(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,(o,d,p)=>{const c=p.split(/\s*,\s*|\s+/).map((m,g)=>{if(!m.endsWith("%"))return m;const u=d.toLowerCase()==="translatey"||g===1?t:n;return`${Number.parseFloat(m)*u/100}px`});return`${d}(${c.join(",")})`});try{const o=new DOMMatrix(i);return ot([o.m11,o.m21,o.m41,o.m12,o.m22,o.m42,o.m14,o.m24,o.m44])}catch{return null}}const it="viewport-plane-v1";function q(s){var S;const n=s.offsetWidth||1,t=s.offsetHeight||1,e=typeof getComputedStyle=="function"?getComputedStyle(s):null,i=((e==null?void 0:e.transformOrigin)||`${n/2}px ${t/2}px`).split(" "),o=Number.parseFloat(i[0])||0,d=Number.parseFloat(i[1])||0;let p=!0;if(typeof getComputedStyle=="function")for(let C=s.parentElement;C;C=C.parentElement){const w=getComputedStyle(C);if(w.transform&&w.transform!=="none"||w.perspective&&w.perspective!=="none"){p=!1;break}}const c=(S=s.getBoundingClientRect)==null?void 0:S.call(s),m=st((e==null?void 0:e.transform)||"",n,t)??A(H),g=O(O(A(T(o,d)),m),A(T(-o,-d))),u=[[0,0],[n,0],[0,t],[n,t]].map(([C,w])=>{const k=g[6]*C+g[7]*w+g[8];return[(g[0]*C+g[1]*w+g[2])/k,(g[3]*C+g[4]*w+g[5])/k]}),l=((c==null?void 0:c.left)??0)-Math.min(...u.map(C=>C[0])),r=((c==null?void 0:c.top)??0)-Math.min(...u.map(C=>C[1])),y=T(l+o,r+d),a=rt(T(-o,-d),U(n,t)),f=A(Q(y)),b=A(Q(a));return{frame:p?{left:l,top:r,width:n,height:t}:void 0,read(C){const w={};for(const[k,F]of Object.entries(C)){const M=String(F);if(k==="transform"){if(!p)continue;const I=st(M,n,t),V=I&&ot(O(O(A(y),I),A(a)));if(V){const[N,z,P,D,E,B,j,v]=V,W=N-P*j,$=D-B*j,G=z-P*v,J=E-B*v,L=Math.hypot(W,$);if(L>1e-8){w[k]=tt(it,[P,B,Math.atan2($,W),L,(W*J-$*G)/L,(W*G+$*J)/L,j,v]);continue}}}const R=[...M.matchAll(et)].map(I=>Number(I[0]));R.length&&R.every(Number.isFinite)&&(w[k]=tt(`css:${M.replace(et,"#")}`,R))}return w},write(C){const w={};for(const[k,F]of Object.entries(C))if(k==="transform"&&F.schema===it){const[M,R,I,V,N,z,P,D]=F.value,E=Math.cos(I),B=Math.sin(I),j=[E*V+M*P,E*z-B*N+M*D,M,B*V+R*P,B*z+E*N+R*D,R,P,D,1],v=O(O(f,j),b);Math.abs(v[6])+Math.abs(v[7])<1e-10&&Math.abs(v[8]-1)<1e-10?w[k]=`matrix(${[v[0],v[3],v[1],v[4],v[2],v[5]].join(",")})`:w[k]=`matrix3d(${[v[0],v[3],0,v[6],v[1],v[4],0,v[7],0,0,1,0,v[2],v[5],0,v[8]].join(",")})`}else if(F.schema.startsWith("css:")){let M=0;w[k]=F.schema.slice(4).replace(/#/g,()=>String(F.value[M++]))}return w}}}const ct=1e3/60;class X extends Z{constructor(t){super();h(this,"_element");h(this,"_integrator");h(this,"label");h(this,"styleFn");h(this,"lowerBound");h(this,"upperBound");h(this,"currentValue");h(this,"currentVelocity",0);h(this,"solverState");h(this,"solverTarget",1);h(this,"presentationTime",0);h(this,"renderedStyles",[]);h(this,"frames",[]);h(this,"waapi",null);h(this,"runId",0);h(this,"running",!1);h(this,"paused",!1);h(this,"settled",!1);h(this,"reversing",!1);h(this,"disposed",!1);h(this,"legacyCompletionCleanup");h(this,"motion");h(this,"codec");h(this,"adopted");h(this,"presentationFrames",[]);h(this,"hold",null);h(this,"fallbackCopy",null);h(this,"fallbackChannels",new Set);h(this,"fallbackMode");this._element=t.element,this._integrator=t.integrator,this.label=t.label,this.styleFn=t.style,this.lowerBound=t.lowerBound??0,this.upperBound=t.upperBound??1,this.currentValue=this.lowerBound,this.onUpdate=t.onUpdate,this.legacyCompletionCleanup=!!t.onComplete&&!t.onDispose,this.onComplete=t.onComplete,this.onDispose=t.onDispose,this.motion=t.motion??{}}get handoffFallbackMode(){return this.fallbackMode}get handoffFallbacks(){return[...this.fallbackChannels]}get element(){return this._element}get integrator(){return this._integrator}set integrator(t){this._integrator=t,this.solverState=void 0}setIntegrator(t){this._integrator=t,this.solverState=void 0}play(){var e;const t=this.reversing;if(this.reversing=!1,this.paused&&this.waapi&&!t){this.paused=!1,this.running=!0,this.waapi.play(),(e=this.fallbackCopy)==null||e.play();return}this.runToward(this.upperBound)}reverse(){this.reversing=!0,this.runToward(this.lowerBound)}pause(){var t,e;this.running&&(this.captureLiveState(),(t=this.waapi)==null||t.pause(),(e=this.fallbackCopy)==null||e.pause(),this.running=!1,this.paused=!0)}complete(){this.settled||(this.clearWaapi(),this.running=!1,this.paused=!1,this.currentValue=this.upperBound,this.currentVelocity=0,this.applyStyleAt(this.currentValue),this.settled=!0,this.finish())}validate(){const t=this.motion.handoffDuration??280;if(!Number.isFinite(t)||t<0||t>1e4)throw new Error("handoffDuration must be finite and between 0 and 10000 ms")}getMotionTracks(){return[this]}get supportsInterruption(){return!this.legacyCompletionCleanup}stop(){var t,e;this.captureLiveState(),this.clearWaapi(),(t=this.hold)==null||t.cancel(),this.hold=null,(e=this.fallbackCopy)==null||e.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.running=!1,this.paused=!1}cancel(t){this.stop(),this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed&&(this.disposed=!0,t.owns(this.element)))try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] animation cleanup failed",i)}}finish(){var t,e,i,o;this.presentationTime=((t=this.frames[this.frames.length-1])==null?void 0:t.time)??0,this.solverState=void 0,(e=this.hold)==null||e.cancel(),this.hold=null,this.applyStyleAt(this.currentValue),this.clearWaapi(),(i=this.fallbackCopy)==null||i.cancel({reason:"disposed",owns:()=>!0}),this.fallbackCopy=null,this.deferDisposal||this.disposeResources(x),(o=this.onComplete)==null||o.call(this)}get motionIdentity(){return{target:this.element,key:this.motion.key,role:this.motion.role,space:this.motion.space,lifetime:this.motion.lifetime}}getMotionSnapshot(){var o,d;this.running&&this.captureLiveState();const t=this.samplePresentation(nt(this.waapi)??this.presentationTime),e=this.paused?0:this.playbackRate,i={...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),...(o=this.codec)==null?void 0:o.write(t)};return{...this.motionIdentity,displayStyle:i,inlineStyle:this.element.style.cssText,frame:(d=this.codec)==null?void 0:d.frame,channels:Object.fromEntries(Object.entries(t).map(([p,c])=>[p,{...c,velocity:c.velocity.map(m=>m*e)}]))}}adopt(t){var p,c,m,g,u;this.codec??(this.codec=this.motion.codec??q(this.element)),this.adopted=t;const e=this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)});this.fallbackChannels.clear(),this.fallbackMode=void 0;const i=this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue),o=t.displayStyle;for(const[l,r]of Object.entries(o??{}))l in i&&String(r)!==String(i[l])&&(!t.channels[l]||!e[l])&&this.fallbackChannels.add(l);for(const[l,r]of Object.entries(t.channels)){const y=e[l];y&&!_.compatibleChannel(r,y)&&this.fallbackChannels.add(l)}if(this.fallbackChannels.size&&(this.fallbackMode="finish"),this.fallbackChannels.size&&this.motion.fallback!=="finish"){const l=t;if(l.frame&&l.displayStyle&&t.target.cloneNode&&t.target.parentElement&&!t.target.shadowRoot&&!((c=(p=t.target).matches)!=null&&c.call(p,"canvas, video, audio, iframe, object, embed"))&&!((g=(m=t.target).querySelector)!=null&&g.call(m,"canvas, video, audio, iframe, object, embed"))){this.fallbackMode="crossfade";const r=t.target.cloneNode(!0);r.removeAttribute("id"),r.removeAttribute("data-ssgoi-transition");for(const a of r.querySelectorAll("[id], [data-ssgoi-transition]"))a.removeAttribute("id"),a.removeAttribute("data-ssgoi-transition");r.style.cssText=l.inlineStyle??"",Object.assign(r.style,l.displayStyle,{position:"fixed",left:`${l.frame.left}px`,top:`${l.frame.top}px`,width:`${l.frame.width}px`,height:`${l.frame.height}px`,margin:"0",pointerEvents:"none",zIndex:"2147483646"}),r.setAttribute("aria-hidden","true"),r.inert=!0,t.target.parentElement.appendChild(r);const y=Number(l.displayStyle.opacity??1);this.fallbackCopy=new X({element:r,integrator:{step:(a,f,b)=>({position:Math.min(f,a.position+b/.18),velocity:0}),isSettled:(a,f)=>a.position>=f},style:(a,f)=>({opacity:y*f}),onDispose:()=>r.remove()}),this.adopted={...t,channels:{...t.channels,opacity:{schema:"css:#",value:[0],velocity:[0]}}}}}const d=this.codec.write(this.adopted.channels);(u=this.hold)==null||u.cancel(),Object.keys(d).length&&(this.hold=this.element.animate([d],{duration:1,fill:"both"}),this.hold.pause(),this.hold.currentTime=0)}channelsAt(t){const e=this.presentationFrames[t];if(e)return e.channels;const i=this.frames[t];return this.codec??(this.codec=this.motion.codec??q(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(i.position,this.lowerBound+this.upperBound-i.position)})}samplePresentation(t){const e=this.frames;if(!e.length)return this.adopted?{...this.adopted.channels}:(this.codec??(this.codec=this.motion.codec??q(this.element)),this.codec.read({transform:"none",opacity:1,...this.styleFn(this.currentValue,this.lowerBound+this.upperBound-this.currentValue)}));let i=e.findIndex(r=>r.time>t);i<0&&(i=e.length-1);const o=Math.max(0,i-1),d=e[o],p=e[i],c=this.channelsAt(o),m=o===i?c:this.channelsAt(i),g=(p.time-d.time)/1e3,u=g?Math.max(0,Math.min(1,(t-d.time)/(g*1e3))):0,l={};for(const[r,y]of Object.entries(c)){const a=m[r];if(!a||!_.compatibleChannel(y,a)){l[r]=y;continue}l[r]={schema:y.schema,value:y.value.map((f,b)=>f+(a.value[b]-f)*u),velocity:y.value.map((f,b)=>t>=e[e.length-1].time||!g?0:(a.value[b]-f)/g)}}return l}releaseFill(){this.clearWaapi()}get isAnimating(){return this.running}get isPaused(){return this.paused}get isComplete(){return this.settled}get isReversing(){return this.reversing}get progress(){this.running&&this.captureLiveState();const t=this.upperBound-this.lowerBound;if(t===0)return 0;const e=(this.currentValue-this.lowerBound)/t;return e<0?0:e>1?1:e}findTimeForProgress(t){if(this.frames.length<2)return null;const e=this.upperBound-this.lowerBound;if(e===0)return 0;for(const i of this.frames)if((i.position-this.lowerBound)/e>=t)return i.time;return this.frames[this.frames.length-1].time}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.waapi&&(this.waapi.playbackRate=t)}getPose(){return this.running&&this.captureLiveState(),[{element:this._element,value:this.currentValue,velocity:this.currentVelocity}]}getTimeline(){const t=this.frames.map((e,i)=>{const o=e.position,d=this.lowerBound+this.upperBound-o;return{time:e.time,value:e.position,velocity:e.velocity,style:this.renderedStyles[i]??this.styleFn(o,d)}});return[{element:this._element,frames:t}]}matchInto(t){const e=t.find(i=>i.element===this._element);e&&(this.currentValue=e.value,this.currentVelocity=e.velocity,this.solverState=void 0)}runToward(t){var m,g;if(this.validate(),this.running||this.paused){const u=this.getMotionSnapshot();this.captureLiveState(),this.adopted=u}if(this.clearWaapi(),this.running=!1,this.paused=!1,this.settled=!1,this.disposed=!1,this.presentationTime=0,this.presentationFrames=[],this.solverTarget=t,this.frames=_.simulate(this._integrator,this.currentValue,t,this.currentVelocity,this.solverState,!0),this.frames.length===0&&this.adopted&&(this.frames=[{time:0,position:t,velocity:0}]),this.frames.length===0){this.currentValue=t,this.currentVelocity=0,this.applyStyleAt(t),this.settled=!0,this.finish();return}const e=u=>this.styleFn(u.position,this.lowerBound+this.upperBound-u.position),i=this.adopted?this.bridgeKeyframes(e):this.frames.map(u=>e(u));this.renderedStyles=i,this.adopted=void 0;const o=i[0],d=this.frames[this.frames.length-1],p=d.time;this.runId++;const c=this._element.animate(i,{duration:p,fill:"both",easing:"linear",composite:"replace"});c.playbackRate=this.playbackRate,this.waapi=c,(m=this.fallbackCopy)==null||m.play(),(g=this.hold)==null||g.cancel(),this.hold=null,this.running=!0,c.onfinish=()=>{!this.running||this.waapi!==c||(this.running=!1,this.settled=!0,this.currentValue=d.position,this.currentVelocity=0,this.finish())},this.clearInlineStyle(o),this.beginPlayback(c,p)}bridgeKeyframes(t){var g;this.codec=this.motion.codec??q(this.element);const e=this.codec,i=Math.max(16,this.motion.handoffDuration??280),o=this.frames[this.frames.length-1];for(let u=o.time+1e3/60;u<i+1e3/60;u+=1e3/60)this.frames.push({time:u,position:o.position,velocity:0});const d=this.frames.map(u=>e.read({transform:"none",opacity:1,...t(u)}));for(let u=1;u<d.length;u++){const l=d[u-1].transform,r=d[u].transform;if((l==null?void 0:l.schema)==="viewport-plane-v1"&&(r==null?void 0:r.schema)===l.schema){const y=[...r.value];y[2]=l.value[2]+Math.atan2(Math.sin(y[2]-l.value[2]),Math.cos(y[2]-l.value[2])),d[u].transform={...r,value:y}}}const p=d[0],c=d[1]??p,m={};for(const[u,l]of Object.entries(((g=this.adopted)==null?void 0:g.channels)??{})){let r=p[u];if(!r){const a=u==="transform"?{transform:"none"}:u==="opacity"?{opacity:1}:{};if(r=e.read(a)[u],r)for(const f of d)f[u]=r}if(!r||!_.compatibleChannel(l,r))continue;const y=c[u]??r;m[u]={offset:l.value.map((a,f)=>{let b=a-r.value[f];return u==="transform"&&l.schema==="viewport-plane-v1"&&f===2&&(b=Math.atan2(Math.sin(b),Math.cos(b))),b}),velocity:l.velocity.map((a,f)=>a/Math.max(Math.abs(this.playbackRate),1e-4)-(y.value[f]-r.value[f])*60)}}return this.presentationFrames=this.frames.map((u,l)=>{const r={...d[l]};for(const[y,a]of Object.entries(m)){const f=r[y];r[y]={...f,value:f.value.map((b,S)=>b+_.residualAt(a.offset[S],a.velocity[S],u.time/1e3,i/1e3).value)}}return{time:u.time,channels:r}}),this.frames.map((u,l)=>{const r=this.presentationFrames[l].channels;return{...t(u),...e.write(Object.fromEntries(Object.keys(m).map(y=>[y,r[y]])))}})}clearWaapi(){var t;this.runId++,(t=this.waapi)==null||t.cancel(),this.waapi=null}captureLiveState(){if(this.frames.length===0)return;const t=nt(this.waapi);if(t===null)return;this.presentationTime=t;const{position:e,velocity:i}=_.interpolateFrame(this.frames,t);this.currentValue=e,this.currentVelocity=i,this.solverState=_.sampleIntegratorState(this.frames,t,this._integrator,this.solverTarget)}beginPlayback(t,e){const i=this.playbackRate;if(i<0){t.play();return}i>0&&(t.currentTime=Math.min(e,ct*i))}clearInlineStyle(t){if(t)for(const e of Object.keys(t))this._element.style[e]=""}applyStyleAt(t){const e=this.lowerBound+this.upperBound-t,i=this.styleFn(t,e);for(const[o,d]of Object.entries(i))this._element.style[o]=typeof d=="number"?String(d):d}}function nt(s){const n=s==null?void 0:s.currentTime;return typeof n=="number"?n:null}class ut{constructor(){h(this,"callbacks",new Set);h(this,"frameRequest",null);h(this,"tick",()=>{this.frameRequest=null;for(const n of[...this.callbacks])this.callbacks.has(n)&&n();this.requestFrame()})}subscribe(n){return this.callbacks.add(n),this.requestFrame(),()=>{this.callbacks.delete(n),this.stopIfIdle()}}requestFrame(){this.frameRequest!==null||this.callbacks.size===0||(this.frameRequest=requestAnimationFrame(this.tick))}stopIfIdle(){this.callbacks.size>0||this.frameRequest===null||(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(this.frameRequest),this.frameRequest=null)}}const dt=new ut;function pt(s){return typeof s.step=="function"?s:_.IntegratorProvider.from(s)}class Y extends Z{constructor(t,e={}){super();h(this,"_children");h(this,"progressChildren");h(this,"_startAt");h(this,"namedChildren");h(this,"restoreChildCallbacks",[]);h(this,"runId",0);h(this,"pendingComplete",0);h(this,"running",!1);h(this,"disposed",!1);h(this,"settled",!1);h(this,"startedChildren",new Set);h(this,"lastMethod","play");h(this,"pausedRun",!1);h(this,"pendingStartObservers",[]);this.namedChildren=new Map(Array.isArray(t)?[]:Object.entries(t)),this._children=Array.isArray(t)?[...t]:[...this.namedChildren.values()];for(const i of this._children)i.deferDisposal=!0;this.progressChildren=this._children.filter(i=>!(i instanceof Y)||i.progressChildren.length>0),(e.mode??"parallel")==="sequence"?this._startAt=this._children.map((i,o)=>o===0?0:1):this._startAt=e.startAt??[]}get children(){return this._children}get startAt(){return this._startAt}set startAt(t){this._startAt=t}tracks(){return this._children.flatMap(t=>[...t.getMotionTracks()])}getMotionTracks(){return this.tracks()}validate(){this.buildDependencies();for(const t of this._children)t.validate()}select(t){const e=this.namedChildren.get(t);if(!e)throw new Error(`Unknown animation child: ${t}`);return e}set(t,e){if(typeof t=="string"){const i=this.select(t);return(e==null?void 0:e.integrator)!==void 0&&i.set({integrator:pt(e.integrator)}),this}return super.set(t)}setIntegrator(t){for(const e of this._children)e.set({integrator:t})}play(){this.startRun("play")}reverse(){this.startRun("reverse")}pause(){this.pausedRun=this.running||this.pausedRun,this.running=!1,this.clearPendingStartObservers();for(const t of this._children)t.pause()}complete(){var t;if(!this.settled){this.settled=!0,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const e of this._children)e.complete();if(!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}get supportsInterruption(){return this._children.every(t=>t.supportsInterruption)}stop(){this.runId++,this.running=!1,this.clearPendingStartObservers(),this.restoreCompletionHandlers();for(const t of this._children)t.stop()}cancel(t){this.stop();for(const e of this._children)e.cancel(t);this.disposeResources(t)}disposeResources(t){var e;if(!this.disposed){this.disposed=!0;try{(e=this.onDispose)==null||e.call(this,t)}catch(i){console.error("[ssgoi] composite cleanup failed",i)}}}get progress(){if(this.progressChildren.length===0)return 0;let t=0;for(const e of this.progressChildren)t+=e.progress;return t/this.progressChildren.length}getPose(){return this._children.flatMap(t=>t.getPose())}getTimeline(){return this._children.flatMap(t=>t.getTimeline())}matchInto(t){for(const e of this._children)e.matchInto(t)}get isAnimating(){return this._children.some(t=>t.isAnimating)}get isPaused(){return this._children.some(t=>t.isPaused)&&this._children.every(t=>t.isPaused||t.isComplete)}get isComplete(){return this.settled}get isReversing(){return this._children.some(t=>t.isReversing)}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t;for(const e of this._children)e.playbackRate=t}startRun(t){const e=this.buildDependencies(),i=this.pausedRun&&t===this.lastMethod,o=t!==this.lastMethod,d=new Set(this.startedChildren),p=new Set(this._children.filter(a=>a.isComplete)),c=t==="reverse"&&d.size?this._children.filter(a=>d.has(a)):[...this._children],m=t==="reverse"?[...c].reverse():c,g=new Map;if(t==="reverse")for(const[a,f]of e){if(!c.includes(a)||!c.includes(f.after))continue;const b=g.get(f.after)??[];b.push({after:a,at:f.at==="settled"?"settled":1-f.at}),g.set(f.after,b)}else for(const[a,f]of e)g.set(a,[f]);if(o||i)for(const a of d)p.has(a)||g.delete(a);this.running&&this.pause(),this.restoreCompletionHandlers();const u=++this.runId;if(this.running=!0,this.pausedRun=!1,this.lastMethod=t,this.disposed=!1,this.settled=!1,this.pendingComplete=c.length,!i&&!o&&this.startedChildren.clear(),this.pendingComplete===0){this.handleFinished();return}const l=new Set,r=new Set;if(i)for(const a of c)d.has(a)&&p.has(a)&&(r.add(a),l.add(a),this.pendingComplete--);for(const a of c){const f=a.onComplete,b=()=>{if(!(this.runId!==u||!this.running||l.has(a))){try{f==null||f()}catch(S){console.error("[ssgoi] animation completion failed",S)}l.add(a),--this.pendingComplete===0&&this.handleFinished()}};a.onComplete=b,this.restoreChildCallbacks.push(()=>{a.onComplete===b&&(a.onComplete=f)})}const y=()=>{let a=!0;for(;this.running&&this.runId===u&&a;){a=!1;for(const f of m)!this.running||r.has(f)||(g.get(f)??[]).some(S=>!r.has(S.after)||!this.hasReachedThreshold(S.after,S.at,t))||(r.add(f),this.startedChildren.add(f),f[t](),a=!0)}r.size===c.length&&this.clearPendingStartObservers()};y(),this.pendingComplete===0&&this.handleFinished(),this.running&&r.size!==c.length&&this.pendingStartObservers.push(dt.subscribe(y))}buildDependencies(){const t=new Map,e=new Set(this._children);if(e.size!==this._children.length)throw new Error("Each child animation must occur once in a MultiAnimation");this._children.forEach((p,c)=>{const m=p.startCondition;if(m){if(!e.has(m.after))throw new Error("startAt.after must reference a sibling in the same MultiAnimation");t.set(p,{...m})}else c>0&&this._startAt.some(g=>g>0)&&t.set(p,{after:this._children[c-1],at:this._startAt[c]??0})});const i=new Set,o=new Set,d=p=>{if(o.has(p))throw new Error("Animation startAt dependencies form a cycle");if(i.has(p))return;o.add(p);const c=t.get(p);c&&d(c.after),o.delete(p),i.add(p)};return this._children.forEach(d),t}hasReachedThreshold(t,e,i){return t.isComplete?!0:e==="settled"?!1:e<=0?!0:(i==="play"?t.progress:1-t.progress)>=e}clearPendingStartObservers(){for(const t of this.pendingStartObservers)t();this.pendingStartObservers=[]}restoreCompletionHandlers(){for(const t of this.restoreChildCallbacks)t();this.restoreChildCallbacks=[]}handleFinished(){var t;if(this.running){if(this.running=!1,this.settled=!0,this.clearPendingStartObservers(),this.restoreCompletionHandlers(),!this.deferDisposal){for(const e of this._children)e.cancel(x);this.disposeResources(x)}(t=this.onComplete)==null||t.call(this)}}findTimeForProgress(t){return null}}const K=new WeakMap;function ft(s){const n=K.get(s)??{value:s.style.getPropertyValue("opacity"),priority:s.style.getPropertyPriority("opacity"),opacity:typeof getComputedStyle=="function"?Number.parseFloat(getComputedStyle(s).opacity):Number.NaN,users:new Set},t={};n.users.add(t),K.set(s,n);let e=!1;return{opacity:Number.isFinite(n.opacity)?n.opacity:1,set:i=>{t.value=i,s.style.opacity=String(i)},restore:()=>{if(!e){if(e=!0,n.users.delete(t),n.users.size>0){const i=Array.from(n.users),o=i[i.length-1];(o==null?void 0:o.value)!==void 0&&(s.style.opacity=String(o.value));return}n.value?s.style.setProperty("opacity",n.value,n.priority):s.style.removeProperty("opacity"),K.delete(s)}}}}exports.Animation=Z;exports.MultiAnimation=Y;exports.WebAnimation=X;exports.createWebPresentationCodec=q;exports.finishedDisposal=x;exports.retainOpacity=ft;
|