@ssgoi/core 2.4.0 → 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.
- package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +284 -258
- package/dist/jaemin-BAi8PTrj.js +130 -0
- package/dist/jaemin-DL1-g_B5.cjs +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/view-transitions/film.d.ts.map +1 -1
- package/dist/view-transitions/hero.d.ts +1 -0
- package/dist/view-transitions/hero.d.ts.map +1 -1
- package/dist/view-transitions/index.cjs +19 -19
- package/dist/view-transitions/index.d.ts +2 -1
- package/dist/view-transitions/index.d.ts.map +1 -1
- package/dist/view-transitions/index.js +484 -522
- package/dist/view-transitions/jaemin.d.ts +4 -0
- package/dist/view-transitions/jaemin.d.ts.map +1 -1
- package/dist/view-transitions/strip.d.ts +3 -0
- package/dist/view-transitions/strip.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -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;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
|
|
2
|
-
`).map(
|
|
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
package/dist/index.d.ts.map
CHANGED
|
@@ -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"}
|