@ssgoi/core 2.3.0 → 2.4.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.
- package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +293 -291
- package/dist/utils/prepare-outgoing.d.ts +2 -1
- package/dist/utils/prepare-outgoing.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/view-transitions/film.d.ts +3 -0
- package/dist/view-transitions/film.d.ts.map +1 -1
- package/dist/view-transitions/hero-rotate.d.ts +28 -0
- package/dist/view-transitions/hero-rotate.d.ts.map +1 -0
- package/dist/view-transitions/index.cjs +15 -15
- package/dist/view-transitions/index.d.ts +1 -0
- package/dist/view-transitions/index.d.ts.map +1 -1
- package/dist/view-transitions/index.js +483 -327
- package/dist/view-transitions/jaemin.d.ts +21 -0
- package/dist/view-transitions/jaemin.d.ts.map +1 -0
- package/dist/view-transitions/scroll.d.ts.map +1 -1
- package/package.json +9 -10
|
@@ -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;
|
|
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;AAyJjB;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,WAAW,GACnB,YAAY,CAwId"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).map(
|
|
1
|
+
"use strict";var I=Object.defineProperty;var N=(o,t,n)=>t in o?I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var g=(o,t,n)=>N(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("popmotion");class E{constructor(t){g(this,"options");g(this,"currentValue");g(this,"velocity");g(this,"isAnimating",!1);g(this,"controls",null);g(this,"animationMap",null);g(this,"activeAnimations",new Set);g(this,"completedAnimations",new Set);g(this,"updatedProperties",new Set);g(this,"animate",(t=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const n=t?this.options.from:this.options.to;if(typeof this.currentValue=="object"&&this.currentValue!==null){this.animateObject(n);return}let e=this.currentValue,i=performance.now();const f={from:this.currentValue,to:n,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1};typeof this.velocity=="number"&&(f.velocity=this.velocity*1e3),this.controls=R.animate({...f,onUpdate:l=>{const h=performance.now(),a=(h-i)/1e3;if(a>0){if(typeof l=="number"&&typeof e=="number"){const p=(l-e)/a;this.velocity=p/1e3}else if(typeof l=="object"&&l!==null){const p={};Object.keys(l).forEach(c=>{const s=l[c],u=e[c];if(typeof s=="number"&&typeof u=="number"){const d=(s-u)/a;p[c]=d/1e3}}),this.velocity=p}e=l,i=h}this.currentValue=l,this.options.onUpdate(l)},onComplete:()=>{this.currentValue=n,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()}})});g(this,"animateObject",t=>{const n=this.currentValue,e=Object.keys(n);this.animationMap=new Map,this.activeAnimations.clear(),this.completedAnimations.clear(),this.updatedProperties.clear();const i={...n},f={};let l=!1;const h=()=>{const a=e.filter(c=>!this.completedAnimations.has(c));if(a.every(c=>this.updatedProperties.has(c))&&a.length>0){if(typeof this.velocity=="object"&&this.velocity){const c=performance.now();Object.keys(i).forEach(s=>{if(f[s]){const u=(c-f[s])/1e3,d=this.currentValue[s],r=i[s];typeof d=="number"&&typeof r=="number"&&u>0&&(this.velocity[s]=(r-d)/u/1e3)}f[s]=c})}this.currentValue={...i},this.options.onUpdate(this.currentValue),this.updatedProperties.clear(),!l&&this.options.onStart&&(l=!0,this.options.onStart())}};e.forEach(a=>{this.activeAnimations.add(a);const p={from:n[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&&(p.velocity=this.velocity[a]*1e3);const c=R.animate({...p,onUpdate:s=>{i[a]=s,this.updatedProperties.add(a),h()},onComplete:()=>{this.completedAnimations.add(a),this.updatedProperties.delete(a),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(s=>{this.velocity[s]=0}),this.options.onComplete())}});this.animationMap.set(a,c)})});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 n={};Object.keys(this.options.from).forEach(e=>{n[e]=0}),this.velocity=n}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 n=this.shouldReverse();this.stop(),this.animate(!n)}}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 n=this.shouldReverse();this.stop(),this.animate(!n)}}static fromState(t,n){const e=new E(n);return e.setValue(t.position),e.setVelocity(t.velocity),e}}const V=Symbol.for("TRANSITION_STRATEGY"),j=o=>({runIn:async t=>{const{currentAnimation:n}=o;if(n&&n.direction==="out"){const l=n.animator.getCurrentState();if(n.animator.stop(),t.out){const h=await t.out,{from:a=1,to:p=0}=h;return{config:h,state:l,from:a,to:p,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:f=1}=e;return{config:e,state:{position:i,velocity:0},from:i,to:f,direction:"forward"}},runOut:async t=>{const{currentAnimation:n}=o;if(n&&n.direction==="in"){const l=n.animator.getCurrentState();if(n.animator.stop(),t.in){const h=await t.in,{from:a=0,to:p=1}=h;return{config:h,state:{position:l.position,velocity:l.velocity},from:a,to:p,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:f=0}=e;return{config:e,state:{position:i,velocity:0},from:i,to:f,direction:"forward"}}}),M=()=>({runIn:async o=>{const t=await o.in;if(!t)return{state:{position:0,velocity:0},from:0,to:1,direction:"forward"};const{from:n=0,to:e=1}=t;return{config:t,state:{position:n,velocity:0},from:n,to:e,direction:"forward"}},runOut:async o=>{const t=await o.out;if(!t)return{state:{position:1,velocity:0},from:1,to:0,direction:"forward"};const{from:n=1,to:e=0}=t;return{config:t,state:{position:n,velocity:0},from:n,to:e,direction:"forward"}}});function D(o,t){var c;let n=null,e=null,i=null,f=null;const l={get currentAnimation(){return n}},h=((c=t==null?void 0:t.strategy)==null?void 0:c.call(t,l))||j(l),a=async s=>{var y,v;e&&(e.remove(),e=null);const u=o(),d={in:u.in&&Promise.resolve(u.in(s)),out:u.out&&Promise.resolve(u.out(s))},r=await h.runIn(d);if(!r.config)return;(v=(y=r.config).prepare)==null||v.call(y,s),r.config.wait&&await r.config.wait();const m=E.fromState(r.state,{from:r.from,to:r.to,spring:r.config.spring,onStart:r.config.onStart,onUpdate:r.config.tick,onComplete:()=>{var w,S;n=null,(S=(w=r.config)==null?void 0:w.onEnd)==null||S.call(w)}});n={animator:m,direction:"in"},r.direction==="forward"?m.forward():m.backward()},p=async s=>{var v,w;e=s;const u=o(),d={in:u.in&&Promise.resolve(u.in(s)),out:u.out&&Promise.resolve(u.out(s))},r=await h.runOut(d);if(!r.config)return;(w=(v=r.config).prepare)==null||w.call(v,s),y(),r.config.wait&&await r.config.wait();const m=E.fromState(r.state,{from:r.from,to:r.to,spring:r.config.spring,onStart:r.config.onStart,onUpdate:r.config.tick,onComplete:()=>{var S,C,b;(C=(S=r.config)==null?void 0:S.onEnd)==null||C.call(S),e&&(e.remove(),e=null),n=null,(b=t==null?void 0:t.onCleanupEnd)==null||b.call(t)}});n={animator:m,direction:"out"},r.direction==="forward"?m.forward():m.backward();function y(){!i||!e||(f&&i.contains(f)?i.insertBefore(e,f):i.appendChild(e))}};return s=>{if(s)return i=s.parentElement,f=s.nextElementSibling,a(s),()=>{const u=s.cloneNode(!0);p(u)}}}const z=3,K=o=>{if(!o)return null;const t=o.split(`
|
|
2
|
+
`).map(n=>n.trim());for(let n=z;n<Math.min(t.length,6);n++){const e=t[n],i=e==null?void 0:e.match(/\(?([^):]+):(\d+):(\d+)\)?$/);if(!i)continue;const f=i[1]??"",l=i[2]??"0",h=i[3]??"0";return{file:f.split(/[\\/]/).pop()||f,line:l,column:h}}return null},T=new Map,P=new Map;function $(o,t,n){T.set(o,t);let e=P.get(o);return e||(e=D(()=>{const i=T.get(o);return i||(console.warn(`Transition "${String(o)}" not found`),{})},{strategy:n,onCleanupEnd:()=>U(o)}),P.set(o,e),e)}function U(o){T.delete(o),P.delete(o)}function _(){const o=K(new Error().stack);return o?`auto_${o.file}_${o.line}_${o.column}`:Symbol(`ssgoi_auto_${Date.now()}`)}const O=globalThis.FinalizationRegistry,x=O?new O(o=>{try{U(o)}catch{}}):void 0;function F(o){const t=o.key??_();if(o.ref&&x)try{x.register(o.ref,t)}catch{}return $(t,{in:o.in,out:o.out},o[V])}const W=o=>{let t=o.parentElement;for(;t&&t!==document.body;){const n=window.getComputedStyle(t),e=n.overflow+n.overflowY+n.overflowX;if(e.includes("auto")||e.includes("scroll")||t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.parentElement}return document.documentElement},k=o=>{let t=o.parentElement;for(;t&&t!==document.body;){const n=window.getComputedStyle(t).position;if(n==="relative"||n==="absolute"||n==="fixed"||n==="sticky")return t;t=t.parentElement}return document.body};function L(o){const t=o.filter(n=>n.symmetric).map(n=>({from:n.to,to:n.from,transition:n.transition}));return[...o,...t]}function Y(){let o=null,t=null;const n=new Map;let e=null;const i=()=>{o&&e&&n.set(e,{x:o.scrollLeft,y:o.scrollTop})};return{initializeContext:(c,s)=>{t=c,o||(o=W(c),(o===document.documentElement?window:o).addEventListener("scroll",i,{passive:!0})),e=s},calculateScrollOffset:(c,s)=>{const u=c&&n.has(c)?n.get(c):{x:0,y:0},d=s&&n.has(s)?n.get(s):{x:0,y:0};return{x:-d.x+u.x,y:-d.y+u.y}},getScrollContainer:()=>o,getPositionedParentElement:()=>t?k(t):document.body,getScrollPosition:c=>c&&n.has(c)?n.get(c):{x:0,y:0}}}function G(o){const{transitions:t=[],defaultTransition:n,middleware:e=(r,m)=>({from:r,to:m})}=o;let i=null;const f=L(t),{initializeContext:l,calculateScrollOffset:h,getScrollContainer:a,getPositionedParentElement:p,getScrollPosition:c}=Y();function s(){if(i!=null&&i.from&&(i!=null&&i.to)){const{from:r,to:m}=e(i.from,i.to),v=H(r,m,f)||n,w=h(i.from,i.to),S={scrollOffset:w,scroll:c(i.from),get scrollingElement(){return a()||document.documentElement},get positionedParent(){return p()}},C={scrollOffset:w,get scroll(){return i?c(i.to):{x:0,y:0}},get scrollingElement(){return a()||document.documentElement},get positionedParent(){return p()}};v&&(v.out&&i.outResolve&&i.outResolve(b=>v.out(b,S)),v.in&&i.inResolve&&i.inResolve(b=>v.in(b,C))),i=null}}const u=async(r,m)=>m==="in"&&(!i||!i.from)?()=>({}):(i||(i={}),m==="out"?(i.from=r,new Promise(y=>{i.outResolve=y,s()})):(i.to=r,new Promise(y=>{i.inResolve=y,s()})));return r=>({key:r,in:async m=>(l(m,r),(await u(r,"in"))(m)),out:async m=>(await u(r,"out"))(m),[V]:M})}function H(o,t,n){for(const e of n)if(A(o,e.from)&&A(t,e.to))return e.transition;for(const e of n)if((e.from==="*"||A(o,e.from))&&(e.to==="*"||A(t,e.to)))return e.transition;return null}function A(o,t){if(t==="*")return!0;if(t.endsWith("/*")){const n=t.slice(0,-2);return o===n||o.startsWith(n+"/")}return o===t}exports.TRANSITION_STRATEGY=V;exports.createDefaultStrategy=j;exports.createPageTransitionStrategy=M;exports.createSggoiTransitionContext=G;exports.generateAutoKey=_;exports.transition=F;
|