@ssgoi/core 2.3.1 → 2.5.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"create-ssgoi-transition-context.d.ts","sourceRoot":"","sources":["../src/lib/create-ssgoi-transition-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGb,MAAM,SAAS,CAAC;AA6IjB;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,GACnB,YAAY,CAwId"}
1
+ {"version":3,"file":"create-ssgoi-transition-context.d.ts","sourceRoot":"","sources":["../src/lib/create-ssgoi-transition-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAGb,MAAM,SAAS,CAAC;AAmNjB;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,GACnB,YAAY,CAkJd"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var N=Object.defineProperty;var D=(n,t,o)=>t in n?N(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var y=(n,t,o)=>D(n,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("popmotion");class C{constructor(t){y(this,"options");y(this,"currentValue");y(this,"velocity");y(this,"isAnimating",!1);y(this,"controls",null);y(this,"animationMap",null);y(this,"activeAnimations",new Set);y(this,"completedAnimations",new Set);y(this,"updatedProperties",new Set);y(this,"animate",(t=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const o=t?this.options.from:this.options.to;if(typeof this.currentValue=="object"&&this.currentValue!==null){this.animateObject(o);return}let e=this.currentValue,i=performance.now();const m={from:this.currentValue,to:o,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1};typeof this.velocity=="number"&&(m.velocity=this.velocity*1e3),this.controls=R.animate({...m,onUpdate:l=>{const p=performance.now(),r=(p-i)/1e3;if(r>0){if(typeof l=="number"&&typeof e=="number"){const u=(l-e)/r;this.velocity=u/1e3}else if(typeof l=="object"&&l!==null){const u={};Object.keys(l).forEach(f=>{const c=l[f],a=e[f];if(typeof c=="number"&&typeof a=="number"){const h=(c-a)/r;u[f]=h/1e3}}),this.velocity=u}e=l,i=p}this.currentValue=l,this.options.onUpdate(l)},onComplete:()=>{this.currentValue=o,this.isAnimating=!1,this.controls=null,typeof this.velocity=="object"&&this.velocity!==null?Object.keys(this.velocity).forEach(l=>{this.velocity[l]=0}):this.velocity=0,this.options.onComplete()}})});y(this,"animateObject",t=>{const o=this.currentValue,e=Object.keys(o);this.animationMap=new Map,this.activeAnimations.clear(),this.completedAnimations.clear(),this.updatedProperties.clear();const i={...o},m={};let l=!1;const p=()=>{const r=e.filter(f=>!this.completedAnimations.has(f));if(r.every(f=>this.updatedProperties.has(f))&&r.length>0){if(typeof this.velocity=="object"&&this.velocity){const f=performance.now();Object.keys(i).forEach(c=>{if(m[c]){const a=(f-m[c])/1e3,h=this.currentValue[c],s=i[c];typeof h=="number"&&typeof s=="number"&&a>0&&(this.velocity[c]=(s-h)/a/1e3)}m[c]=f})}this.currentValue={...i},this.options.onUpdate(this.currentValue),this.updatedProperties.clear(),!l&&this.options.onStart&&(l=!0,this.options.onStart())}};e.forEach(r=>{this.activeAnimations.add(r);const u={from:o[r],to:t[r],stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1};typeof this.velocity=="object"&&this.velocity&&r in this.velocity&&(u.velocity=this.velocity[r]*1e3);const f=R.animate({...u,onUpdate:c=>{i[r]=c,this.updatedProperties.add(r),p()},onComplete:()=>{this.completedAnimations.add(r),this.updatedProperties.delete(r),this.completedAnimations.size===e.length&&(this.currentValue=t,this.isAnimating=!1,this.animationMap=null,typeof this.velocity=="object"&&this.velocity&&Object.keys(this.velocity).forEach(c=>{this.velocity[c]=0}),this.options.onComplete())}});this.animationMap.set(r,f)})});if(this.options={from:t.from??0,to:t.to??1,spring:t.spring??{stiffness:100,damping:10},onUpdate:t.onUpdate??(()=>{}),onComplete:t.onComplete??(()=>{}),onStart:t.onStart},this.currentValue=this.options.from,typeof this.options.from=="object"&&this.options.from!==null){const o={};Object.keys(this.options.from).forEach(e=>{o[e]=0}),this.velocity=o}else this.velocity=0}forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const t=this.options.from;if(this.options.from=this.options.to,this.options.to=t,this.isAnimating){const o=this.shouldReverse();this.stop(),this.animate(!o)}}shouldReverse(){return typeof this.currentValue=="number"&&typeof this.options.from=="number"&&typeof this.options.to=="number"?this.currentValue>(this.options.from+this.options.to)/2:!1}stop(){this.isAnimating=!1,this.controls&&(this.controls.stop(),this.controls=null),this.animationMap&&(this.animationMap.forEach(t=>{t.stop()}),this.animationMap.clear(),this.animationMap=null),this.updatedProperties.clear()}getVelocity(){return this.velocity}getCurrentValue(){return this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.currentValue,velocity:this.velocity,from:this.options.from,to:this.options.to}}setVelocity(t){this.velocity=t}setValue(t){this.currentValue=t}updateOptions(t){if(this.options={...this.options,...t},this.isAnimating&&this.controls){const o=this.shouldReverse();this.stop(),this.animate(!o)}}static fromState(t,o){const e=new C(o);return e.setValue(t.position),e.setVelocity(t.velocity),e}}const E=Symbol.for("TRANSITION_STRATEGY"),x=n=>({runIn:async t=>{const{currentAnimation:o}=n;if(o&&o.direction==="out"){const l=o.animator.getCurrentState();if(o.animator.stop(),t.out){const p=await t.out,{from:r=1,to:u=0}=p;return{config:p,state:l,from:r,to:u,direction:"backward"}}}const e=await t.in;if(!e)return{state:{position:0,velocity:0},from:0,to:1,direction:"forward"};const{from:i=0,to:m=1}=e;return{config:e,state:{position:i,velocity:0},from:i,to:m,direction:"forward"}},runOut:async t=>{const{currentAnimation:o}=n;if(o&&o.direction==="in"){const l=o.animator.getCurrentState();if(o.animator.stop(),t.in){const p=await t.in,{from:r=0,to:u=1}=p;return{config:p,state:{position:l.position,velocity:l.velocity},from:r,to:u,direction:"backward"}}}const e=await t.out;if(!e)return{state:{position:1,velocity:0},from:1,to:0,direction:"forward"};const{from:i=1,to:m=0}=e;return{config:e,state:{position:i,velocity:0},from:i,to:m,direction:"forward"}}}),U=()=>({runIn:async n=>{const t=await n.in;if(!t)return{state:{position:0,velocity:0},from:0,to:1,direction:"forward"};const{from:o=0,to:e=1}=t;return{config:t,state:{position:o,velocity:0},from:o,to:e,direction:"forward"}},runOut:async n=>{const t=await n.out;if(!t)return{state:{position:1,velocity:0},from:1,to:0,direction:"forward"};const{from:o=1,to:e=0}=t;return{config:t,state:{position:o,velocity:0},from:o,to:e,direction:"forward"}}});function k(n,t){var f;let o=null,e=null,i=null,m=null;const l={get currentAnimation(){return o}},p=((f=t==null?void 0:t.strategy)==null?void 0:f.call(t,l))||x(l),r=async c=>{var w,S;e&&(e.remove(),e=null);const a=n(),h={in:a.in&&Promise.resolve(a.in(c)),out:a.out&&Promise.resolve(a.out(c))},s=await p.runIn(h);if(!s.config)return;(S=(w=s.config).prepare)==null||S.call(w,c),s.config.wait&&await s.config.wait();const g=C.fromState(s.state,{from:s.from,to:s.to,spring:s.config.spring,onStart:s.config.onStart,onUpdate:s.config.tick,onComplete:()=>{var v,d;o=null,(d=(v=s.config)==null?void 0:v.onEnd)==null||d.call(v)}});o={animator:g,direction:"in"},s.direction==="forward"?g.forward():g.backward()},u=async c=>{var S,v;e=c;const a=n(),h={in:a.in&&Promise.resolve(a.in(c)),out:a.out&&Promise.resolve(a.out(c))},s=await p.runOut(h);if(!s.config)return;(v=(S=s.config).prepare)==null||v.call(S,c),w(),s.config.wait&&await s.config.wait();const g=C.fromState(s.state,{from:s.from,to:s.to,spring:s.config.spring,onStart:s.config.onStart,onUpdate:s.config.tick,onComplete:()=>{var d,V,P;(V=(d=s.config)==null?void 0:d.onEnd)==null||V.call(d),e&&(e.remove(),e=null),o=null,(P=t==null?void 0:t.onCleanupEnd)==null||P.call(t)}});o={animator:g,direction:"out"},s.direction==="forward"?g.forward():g.backward();function w(){!i||!e||(m&&i.contains(m)?i.insertBefore(e,m):i.appendChild(e))}};return c=>{if(c)return i=c.parentElement,m=c.nextElementSibling,r(c),()=>{const a=c.cloneNode(!0);u(a)}}}const K=3,$=n=>{if(!n)return null;const t=n.split(`
2
- `).map(o=>o.trim());for(let o=K;o<Math.min(t.length,6);o++){const e=t[o],i=e==null?void 0:e.match(/\(?([^):]+):(\d+):(\d+)\)?$/);if(!i)continue;const m=i[1]??"",l=i[2]??"0",p=i[3]??"0";return{file:m.split(/[\\/]/).pop()||m,line:l,column:p}}return null},A=new Map,T=new Map;function F(n,t,o){A.set(n,t);let e=T.get(n);return e||(e=k(()=>{const i=A.get(n);return i||(console.warn(`Transition "${String(n)}" not found`),{})},{strategy:o,onCleanupEnd:()=>_(n)}),T.set(n,e),e)}function _(n){A.delete(n),T.delete(n)}function I(){const n=$(new Error().stack);return n?`auto_${n.file}_${n.line}_${n.column}`:Symbol(`ssgoi_auto_${Date.now()}`)}const O=globalThis.FinalizationRegistry,j=O?new O(n=>{try{_(n)}catch{}}):void 0;function W(n){const t=n.key??I();if(n.ref&&j)try{j.register(n.ref,t)}catch{}return F(t,{in:n.in,out:n.out},n[E])}const L=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const o=window.getComputedStyle(t),e=o.overflow+o.overflowY+o.overflowX;if(e.includes("auto")||e.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement},M=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const o=window.getComputedStyle(t).position;if(o==="relative"||o==="absolute"||o==="fixed"||o==="sticky")return t;t=t.parentElement}return document.body};function Y(n){const t=n.filter(o=>o.symmetric).map(o=>({from:o.to,to:o.from,transition:o.transition}));return[...n,...t]}function z(){let n=null;const t=new Map;let o=null;const e=()=>{n&&o&&t.set(o,{x:n.scrollLeft,y:n.scrollTop})};return{startScrollTracking:(r,u)=>{n||(n=L(r),(n===document.documentElement?window:n).addEventListener("scroll",e,{passive:!0})),o=u},calculateScrollOffset:(r,u)=>{const f=r&&t.has(r)?t.get(r):{x:0,y:0},c=u&&t.has(u)?t.get(u):{x:0,y:0};return{x:-c.x+f.x,y:-c.y+f.y}},getScrollContainer:()=>n,getScrollPosition:r=>r&&t.has(r)?t.get(r):{x:0,y:0}}}function G(n){const{transitions:t=[],defaultTransition:o,middleware:e=(a,h)=>({from:a,to:h})}=n;let i=null;const m=Y(t),{startScrollTracking:l,calculateScrollOffset:p,getScrollContainer:r,getScrollPosition:u}=z();function f(){if(i!=null&&i.from&&(i!=null&&i.to)){const{from:a,to:h}=e(i.from,i.to),g=H(a,h,m)||o,w=p(i.from,i.to),S={scrollOffset:w,scroll:u(i.from),get scrollingElement(){return r()||document.documentElement},get positionedParent(){const d=r();return d?M(d):document.body}},v={scrollOffset:w,scroll:u(i.to),get scrollingElement(){return r()||document.documentElement},get positionedParent(){const d=r();return d?M(d):document.body}};g&&(g.out&&i.outResolve&&i.outResolve(d=>g.out(d,S)),g.in&&i.inResolve&&i.inResolve(d=>g.in(d,v))),i=null}}const c=async(a,h)=>h==="in"&&(!i||!i.from)?()=>({}):(i||(i={}),h==="out"?(i.from=a,new Promise(s=>{i.outResolve=s,f()})):(i.to=a,new Promise(s=>{i.inResolve=s,f()})));return a=>({key:a,in:async h=>(l(h,a),(await c(a,"in"))(h)),out:async h=>(await c(a,"out"))(h),[E]:U})}function H(n,t,o){for(const e of o)if(b(n,e.from)&&b(t,e.to))return e.transition;for(const e of o)if((e.from==="*"||b(n,e.from))&&(e.to==="*"||b(t,e.to)))return e.transition;return null}function b(n,t){if(t==="*")return!0;if(t.endsWith("/*")){const o=t.slice(0,-2);return n===o||n.startsWith(o+"/")}return n===t}exports.TRANSITION_STRATEGY=E;exports.createDefaultStrategy=x;exports.createPageTransitionStrategy=U;exports.createSggoiTransitionContext=G;exports.generateAutoKey=I;exports.transition=W;
1
+ "use strict";var N=Object.defineProperty;var z=(n,t,e)=>t in n?N(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var v=(n,t,e)=>z(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("popmotion"),L=require("./jaemin-DL1-g_B5.cjs");class T{constructor(t){v(this,"options");v(this,"currentValue");v(this,"velocity");v(this,"isAnimating",!1);v(this,"controls",null);v(this,"animationMap",null);v(this,"activeAnimations",new Set);v(this,"completedAnimations",new Set);v(this,"updatedProperties",new Set);v(this,"animate",(t=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const e=t?this.options.from:this.options.to;if(typeof this.currentValue=="object"&&this.currentValue!==null){this.animateObject(e);return}let i=this.currentValue,s=performance.now();const o={from:this.currentValue,to:e,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1};typeof this.velocity=="number"&&(o.velocity=this.velocity*1e3),this.controls=R.animate({...o,onUpdate:u=>{const d=performance.now(),a=(d-s)/1e3;if(a>0){if(typeof u=="number"&&typeof i=="number"){const m=(u-i)/a;this.velocity=m/1e3}else if(typeof u=="object"&&u!==null){const m={};Object.keys(u).forEach(l=>{const r=u[l],f=i[l];if(typeof r=="number"&&typeof f=="number"){const g=(r-f)/a;m[l]=g/1e3}}),this.velocity=m}i=u,s=d}this.currentValue=u,this.options.onUpdate(u)},onComplete:()=>{this.currentValue=e,this.isAnimating=!1,this.controls=null,typeof this.velocity=="object"&&this.velocity!==null?Object.keys(this.velocity).forEach(u=>{this.velocity[u]=0}):this.velocity=0,this.options.onComplete()}})});v(this,"animateObject",t=>{const e=this.currentValue,i=Object.keys(e);this.animationMap=new Map,this.activeAnimations.clear(),this.completedAnimations.clear(),this.updatedProperties.clear();const s={...e},o={};let u=!1;const d=()=>{const a=i.filter(l=>!this.completedAnimations.has(l));if(a.every(l=>this.updatedProperties.has(l))&&a.length>0){if(typeof this.velocity=="object"&&this.velocity){const l=performance.now();Object.keys(s).forEach(r=>{if(o[r]){const f=(l-o[r])/1e3,g=this.currentValue[r],c=s[r];typeof g=="number"&&typeof c=="number"&&f>0&&(this.velocity[r]=(c-g)/f/1e3)}o[r]=l})}this.currentValue={...s},this.options.onUpdate(this.currentValue),this.updatedProperties.clear(),!u&&this.options.onStart&&(u=!0,this.options.onStart())}};i.forEach(a=>{this.activeAnimations.add(a);const m={from:e[a],to:t[a],stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1};typeof this.velocity=="object"&&this.velocity&&a in this.velocity&&(m.velocity=this.velocity[a]*1e3);const l=R.animate({...m,onUpdate:r=>{s[a]=r,this.updatedProperties.add(a),d()},onComplete:()=>{this.completedAnimations.add(a),this.updatedProperties.delete(a),this.completedAnimations.size===i.length&&(this.currentValue=t,this.isAnimating=!1,this.animationMap=null,typeof this.velocity=="object"&&this.velocity&&Object.keys(this.velocity).forEach(r=>{this.velocity[r]=0}),this.options.onComplete())}});this.animationMap.set(a,l)})});if(this.options={from:t.from??0,to:t.to??1,spring:t.spring??{stiffness:100,damping:10},onUpdate:t.onUpdate??(()=>{}),onComplete:t.onComplete??(()=>{}),onStart:t.onStart},this.currentValue=this.options.from,typeof this.options.from=="object"&&this.options.from!==null){const e={};Object.keys(this.options.from).forEach(i=>{e[i]=0}),this.velocity=e}else this.velocity=0}forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const t=this.options.from;if(this.options.from=this.options.to,this.options.to=t,this.isAnimating){const e=this.shouldReverse();this.stop(),this.animate(!e)}}shouldReverse(){return typeof this.currentValue=="number"&&typeof this.options.from=="number"&&typeof this.options.to=="number"?this.currentValue>(this.options.from+this.options.to)/2:!1}stop(){this.isAnimating=!1,this.controls&&(this.controls.stop(),this.controls=null),this.animationMap&&(this.animationMap.forEach(t=>{t.stop()}),this.animationMap.clear(),this.animationMap=null),this.updatedProperties.clear()}getVelocity(){return this.velocity}getCurrentValue(){return this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.currentValue,velocity:this.velocity,from:this.options.from,to:this.options.to}}setVelocity(t){this.velocity=t}setValue(t){this.currentValue=t}updateOptions(t){if(this.options={...this.options,...t},this.isAnimating&&this.controls){const e=this.shouldReverse();this.stop(),this.animate(!e)}}static fromState(t,e){const i=new T(e);return i.setValue(t.position),i.setVelocity(t.velocity),i}}const O=Symbol.for("TRANSITION_STRATEGY"),M=n=>({runIn:async t=>{const{currentAnimation:e}=n;if(e&&e.direction==="out"){const u=e.animator.getCurrentState();if(e.animator.stop(),t.out){const d=await t.out,{from:a=1,to:m=0}=d;return{config:d,state:u,from:a,to:m,direction:"backward"}}}const i=await t.in;if(!i)return{state:{position:0,velocity:0},from:0,to:1,direction:"forward"};const{from:s=0,to:o=1}=i;return{config:i,state:{position:s,velocity:0},from:s,to:o,direction:"forward"}},runOut:async t=>{const{currentAnimation:e}=n;if(e&&e.direction==="in"){const u=e.animator.getCurrentState();if(e.animator.stop(),t.in){const d=await t.in,{from:a=0,to:m=1}=d;return{config:d,state:{position:u.position,velocity:u.velocity},from:a,to:m,direction:"backward"}}}const i=await t.out;if(!i)return{state:{position:1,velocity:0},from:1,to:0,direction:"forward"};const{from:s=1,to:o=0}=i;return{config:i,state:{position:s,velocity:0},from:s,to:o,direction:"forward"}}}),I=()=>({runIn:async n=>{const t=await n.in;if(!t)return{state:{position:0,velocity:0},from:0,to:1,direction:"forward"};const{from:e=0,to:i=1}=t;return{config:t,state:{position:e,velocity:0},from:e,to:i,direction:"forward"}},runOut:async n=>{const t=await n.out;if(!t)return{state:{position:1,velocity:0},from:1,to:0,direction:"forward"};const{from:e=1,to:i=0}=t;return{config:t,state:{position:e,velocity:0},from:e,to:i,direction:"forward"}}});function K(n,t){var l;let e=null,i=null,s=null,o=null;const u={get currentAnimation(){return e}},d=((l=t==null?void 0:t.strategy)==null?void 0:l.call(t,u))||M(u),a=async r=>{var p,h;i&&(i.remove(),i=null);const f=n(),g={in:f.in&&Promise.resolve(f.in(r)),out:f.out&&Promise.resolve(f.out(r))},c=await d.runIn(g);if(!c.config)return;(h=(p=c.config).prepare)==null||h.call(p,r),c.config.wait&&await c.config.wait();const S=T.fromState(c.state,{from:c.from,to:c.to,spring:c.config.spring,onStart:c.config.onStart,onUpdate:c.config.tick,onComplete:()=>{var y,w;e=null,(w=(y=c.config)==null?void 0:y.onEnd)==null||w.call(y)}});e={animator:S,direction:"in"},c.direction==="forward"?S.forward():S.backward()},m=async r=>{var h,y;i=r;const f=n(),g={in:f.in&&Promise.resolve(f.in(r)),out:f.out&&Promise.resolve(f.out(r))},c=await d.runOut(g);if(!c.config)return;(y=(h=c.config).prepare)==null||y.call(h,r),p(),c.config.wait&&await c.config.wait();const S=T.fromState(c.state,{from:c.from,to:c.to,spring:c.config.spring,onStart:c.config.onStart,onUpdate:c.config.tick,onComplete:()=>{var w,b,C;(b=(w=c.config)==null?void 0:w.onEnd)==null||b.call(w),i&&(i.remove(),i=null),e=null,(C=t==null?void 0:t.onCleanupEnd)==null||C.call(t)}});e={animator:S,direction:"out"},c.direction==="forward"?S.forward():S.backward();function p(){!s||!i||(o&&s.contains(o)?s.insertBefore(i,o):s.appendChild(i))}};return r=>{if(r)return s=r.parentElement,o=r.nextElementSibling,a(r),()=>{const f=r.cloneNode(!0);m(f)}}}const $=3,k=n=>{if(!n)return null;const t=n.split(`
2
+ `).map(e=>e.trim());for(let e=$;e<Math.min(t.length,6);e++){const i=t[e],s=i==null?void 0:i.match(/\(?([^):]+):(\d+):(\d+)\)?$/);if(!s)continue;const o=s[1]??"",u=s[2]??"0",d=s[3]??"0";return{file:o.split(/[\\/]/).pop()||o,line:u,column:d}}return null},P=new Map,V=new Map;function F(n,t,e){P.set(n,t);let i=V.get(n);return i||(i=K(()=>{const s=P.get(n);return s||(console.warn(`Transition "${String(n)}" not found`),{})},{strategy:e,onCleanupEnd:()=>U(n)}),V.set(n,i),i)}function U(n){P.delete(n),V.delete(n)}function _(){const n=k(new Error().stack);return n?`auto_${n.file}_${n.line}_${n.column}`:Symbol(`ssgoi_auto_${Date.now()}`)}const x=globalThis.FinalizationRegistry,j=x?new x(n=>{try{U(n)}catch{}}):void 0;function W(n){const t=n.key??_();if(n.ref&&j)try{j.register(n.ref,t)}catch{}return F(t,{in:n.in,out:n.out},n[O])}const Y=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const e=window.getComputedStyle(t),i=e.overflow+e.overflowY+e.overflowX;if(i.includes("auto")||i.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement},G=n=>{let t=n.parentElement;for(;t&&t!==document.body;){const e=window.getComputedStyle(t).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return t;t=t.parentElement}return document.body};function X(n){const t=n.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...n,...t]}function q(n){let t=!1,e=!1;const i=a=>{if(!n)return;const m=a.touches[0];m&&(e=m.clientX<50)},s=()=>{n&&(e&&(t=!0,setTimeout(()=>{t=!1},500)),e=!1)};return{initialize:()=>{typeof window>"u"||n&&(window.addEventListener("touchstart",i,{passive:!0}),window.addEventListener("touchend",s,{passive:!0}))},cleanup:()=>{typeof window>"u"||(window.removeEventListener("touchstart",i),window.removeEventListener("touchend",s))},isSwipePending:()=>t}}function H(){let n=null,t=null;const e=new Map;let i=null;const s=()=>{n&&i&&e.set(i,{x:n.scrollLeft,y:n.scrollTop})};return{initializeContext:(l,r)=>{t=l,n||(n=Y(l),(n===document.documentElement?window:n).addEventListener("scroll",s,{passive:!0})),i=r},calculateScrollOffset:(l,r)=>{const f=l&&e.has(l)?e.get(l):{x:0,y:0},g=r&&e.has(r)?e.get(r):{x:0,y:0};return{x:-g.x+f.x,y:-g.y+f.y}},getScrollContainer:()=>n,getPositionedParentElement:()=>t?G(t):document.body,getScrollPosition:l=>l&&e.has(l)?e.get(l):{x:0,y:0}}}function B(n){const{transitions:t=[],defaultTransition:e,middleware:i=(p,h)=>({from:p,to:h}),skipOnIosSwipe:s=!0}=n;let o=null;const u=X(t),{initializeContext:d,calculateScrollOffset:a,getScrollContainer:m,getPositionedParentElement:l,getScrollPosition:r}=H(),f=q(s);f.initialize();function g(){if(o!=null&&o.from&&(o!=null&&o.to)){const{from:p,to:h}=i(o.from,o.to),w=J(p,h,u)||e,b=a(o.from,o.to),C={scrollOffset:b,scroll:r(o.from),get scrollingElement(){return m()||document.documentElement},get positionedParent(){return l()}},D={scrollOffset:b,get scroll(){return o?r(o.to):{x:0,y:0}},get scrollingElement(){return m()||document.documentElement},get positionedParent(){return l()}};w&&(w.out&&o.outResolve&&o.outResolve(A=>w.out(A,C)),w.in&&o.inResolve&&o.inResolve(A=>w.in(A,D))),o=null}}const c=async(p,h)=>f.isSwipePending()?()=>({}):h==="in"&&(!o||!o.from)?()=>({}):(o||(o={}),h==="out"?(o.from=p,new Promise(y=>{o.outResolve=y,g()})):(o.to=p,new Promise(y=>{o.inResolve=y,g()})));return p=>({key:p,in:async h=>(d(h,p),(await c(p,"in"))(h)),out:async h=>(await c(p,"out"))(h),[O]:I})}function J(n,t,e){for(const i of e)if(E(n,i.from)&&E(t,i.to))return i.transition;for(const i of e)if((i.from==="*"||E(n,i.from))&&(i.to==="*"||E(t,i.to)))return i.transition;return null}function E(n,t){if(t==="*")return!0;if(t.endsWith("/*")){const e=t.slice(0,-2);return n===e||n.startsWith(e+"/")}return n===t}exports.jaeminInternal=L.jaeminInternal;exports.TRANSITION_STRATEGY=O;exports.createDefaultStrategy=M;exports.createPageTransitionStrategy=I;exports.createSggoiTransitionContext=B;exports.generateAutoKey=_;exports.transition=W;
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export * from './types';
2
2
  export * from './transition';
3
3
  export * from './create-ssgoi-transition-context';
4
4
  export * from './transition-strategy';
5
+ export { jaeminInternal } from './view-transitions/jaemin';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}