@ssgoi/core 6.3.1 → 6.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/README.md CHANGED
@@ -33,31 +33,27 @@ npm install @ssgoi/svelte
33
33
  #### 1. Wrap your app
34
34
 
35
35
  ```tsx
36
- import { Ssgoi } from '@ssgoi/react';
37
- import { fade } from '@ssgoi/react/view-transitions';
36
+ import { Ssgoi } from "@ssgoi/react";
37
+ import { fade } from "@ssgoi/react/view-transitions";
38
38
 
39
39
  export default function App() {
40
40
  return (
41
- <Ssgoi config={{ transitions: fade({ paths: ['/', '/about'] }) }}>
42
- <div style={{ position: 'relative' }}>
43
- {/* Your app */}
44
- </div>
41
+ <Ssgoi config={{ transitions: fade({ paths: ["/", "/about"] }) }}>
42
+ <div style={{ position: "relative" }}>{/* Your app */}</div>
45
43
  </Ssgoi>
46
44
  );
47
45
  }
48
46
  ```
49
47
 
50
- #### 2. Wrap your pages
48
+ #### 2. Mark your pages
51
49
 
52
50
  ```tsx
53
- import { SsgoiTransition } from '@ssgoi/react';
54
-
55
51
  export default function HomePage() {
56
52
  return (
57
- <SsgoiTransition id="/">
53
+ <main data-ssgoi-transition="/">
58
54
  <h1>Welcome</h1>
59
55
  {/* Page content */}
60
- </SsgoiTransition>
56
+ </main>
61
57
  );
62
58
  }
63
59
  ```
@@ -74,15 +70,19 @@ Define different transitions for different routes:
74
70
  const config = {
75
71
  transitions: [
76
72
  // Scroll between tabs
77
- { from: '/home', to: '/about', transition: scroll({ direction: 'up' }) },
78
- { from: '/about', to: '/home', transition: scroll({ direction: 'down' }) },
79
-
73
+ { from: "/home", to: "/about", transition: scroll({ direction: "up" }) },
74
+ { from: "/about", to: "/home", transition: scroll({ direction: "down" }) },
75
+
80
76
  // Drill in when entering details
81
- { from: '/products', to: '/products/*', transition: drill({ direction: 'enter' }) },
82
-
77
+ {
78
+ from: "/products",
79
+ to: "/products/*",
80
+ transition: drill({ direction: "enter" }),
81
+ },
82
+
83
83
  // Pinterest-style image transitions
84
- { from: '/gallery', to: '/photo/*', transition: pinterest() }
85
- ]
84
+ { from: "/gallery", to: "/photo/*", transition: pinterest() },
85
+ ],
86
86
  };
87
87
  ```
88
88
 
@@ -93,7 +93,7 @@ Automatically create bidirectional transitions:
93
93
  ```tsx
94
94
  {
95
95
  from: '/home',
96
- to: '/about',
96
+ to: '/about',
97
97
  transition: scroll({ direction: 'up' }),
98
98
  symmetric: true // Automatically creates reverse transition
99
99
  }
@@ -104,16 +104,18 @@ Automatically create bidirectional transitions:
104
104
  Animate specific elements during mount/unmount:
105
105
 
106
106
  ```tsx
107
- import { transition } from '@ssgoi/react';
108
- import { fade, slide } from '@ssgoi/react/transitions';
107
+ import { transition } from "@ssgoi/react";
108
+ import { fade, slide } from "@ssgoi/react/transitions";
109
109
 
110
110
  function Card() {
111
111
  return (
112
- <div ref={transition({
113
- key: 'card',
114
- in: fade(),
115
- out: slide({ direction: 'up' })
116
- })}>
112
+ <div
113
+ ref={transition({
114
+ key: "card",
115
+ in: fade(),
116
+ out: slide({ direction: "up" }),
117
+ })}
118
+ >
117
119
  <h2>Animated Card</h2>
118
120
  </div>
119
121
  );
@@ -123,6 +125,7 @@ function Card() {
123
125
  ## Built-in Transitions
124
126
 
125
127
  ### Page Transitions
128
+
126
129
  - `fade` - Smooth opacity transition
127
130
  - `scroll` - Vertical scrolling (up/down)
128
131
  - `drill` - Drill in/out effect (enter/exit)
@@ -130,6 +133,7 @@ function Card() {
130
133
  - `pinterest` - Pinterest-style expand effect
131
134
 
132
135
  ### Element Transitions
136
+
133
137
  - `fade` - Fade in/out
134
138
  - `scale` - Scale in/out
135
139
  - `slide` - Slide (direction: up/down/left/right)
@@ -144,17 +148,19 @@ function Card() {
144
148
 
145
149
  ```tsx
146
150
  // app/layout.tsx
147
- import { Ssgoi } from '@ssgoi/react';
148
- import { scroll } from '@ssgoi/react/view-transitions';
151
+ import { Ssgoi } from "@ssgoi/react";
152
+ import { scroll } from "@ssgoi/react/view-transitions";
149
153
 
150
154
  export default function RootLayout({ children }) {
151
155
  return (
152
156
  <html>
153
157
  <body>
154
- <Ssgoi config={{
155
- transitions: scroll({ paths: ['/', '/about'] })
156
- }}>
157
- <div style={{ position: 'relative', minHeight: '100vh' }}>
158
+ <Ssgoi
159
+ config={{
160
+ transitions: scroll({ paths: ["/", "/about"] }),
161
+ }}
162
+ >
163
+ <div style={{ position: "relative", minHeight: "100vh" }}>
158
164
  {children}
159
165
  </div>
160
166
  </Ssgoi>
@@ -163,15 +169,8 @@ export default function RootLayout({ children }) {
163
169
  );
164
170
  }
165
171
 
166
- // app/page.tsx
167
- import { SsgoiTransition } from '@ssgoi/react';
168
-
169
172
  export default function Page() {
170
- return (
171
- <SsgoiTransition id="/">
172
- {/* Your page content */}
173
- </SsgoiTransition>
174
- );
173
+ return <main data-ssgoi-transition="/">{/* Your page content */}</main>;
175
174
  }
176
175
  ```
177
176
 
@@ -192,23 +191,24 @@ export default function Page() {
192
191
 
193
192
  <!-- +page.svelte -->
194
193
  <script>
195
- import { SsgoiTransition } from '@ssgoi/svelte';
196
194
  import { page } from '$app/stores';
197
195
  </script>
198
196
 
199
- <SsgoiTransition id={$page.url.pathname}>
197
+ <main data-ssgoi-transition={$page.url.pathname}>
200
198
  <!-- Your page content -->
201
- </SsgoiTransition>
199
+ </main>
202
200
  ```
203
201
 
204
202
  ## Why SSGOI?
205
203
 
206
204
  ### vs View Transition API
205
+
207
206
  - ✅ Works in all browsers, not just Chrome
208
207
  - ✅ More animation options with spring physics
209
208
  - ✅ Better developer experience
210
209
 
211
210
  ### vs Other Animation Libraries
211
+
212
212
  - ✅ Built specifically for page transitions
213
213
  - ✅ SSR-first design
214
214
  - ✅ No router lock-in
@@ -230,17 +230,21 @@ All powered by a spring physics engine for natural, smooth motion.
230
230
  Try out SSGOI with our framework-specific demo applications:
231
231
 
232
232
  ### React Demo
233
+
233
234
  ```bash
234
235
  pnpm react-demo:dev
235
236
  # Opens at http://localhost:3001
236
237
  ```
238
+
237
239
  Explore Next.js App Router integration with various transition effects.
238
240
 
239
241
  ### Svelte Demo
242
+
240
243
  ```bash
241
244
  pnpm svelte-demo:dev
242
245
  # Opens at http://localhost:5174
243
246
  ```
247
+
244
248
  See SvelteKit integration with smooth page transitions.
245
249
 
246
250
  Visit the `/apps` directory to explore the demo source code and learn how to implement SSGOI in your own projects.
@@ -248,6 +252,7 @@ Visit the `/apps` directory to explore the demo source code and learn how to imp
248
252
  ## Documentation
249
253
 
250
254
  Visit [https://ssgoi.dev](https://ssgoi.dev) for:
255
+
251
256
  - Detailed API reference
252
257
  - Interactive examples
253
258
  - Framework integration guides
package/dist/internal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ut=Object.defineProperty;var ft=(t,n,e)=>n in t?ut(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>ft(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./multi-animation-Dw2JTJI2.cjs");class st extends H.Animation{constructor(){super(...arguments);W(this,"child",null);W(this,"_state","idle");W(this,"_settled",!1);W(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const m=o.getPose();o.complete(),e.matchInto(m)}e.playbackRate=this.playbackRate;const c=e.onComplete;e.onComplete=()=>{c==null||c(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const d=e.onUpdate;e.onUpdate=m=>{var S;d==null||d(m),(S=this.onUpdate)==null||S.call(this,m),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var o;return((o=this.child)==null?void 0:o.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var o;(o=this.child)==null||o.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const dt=(t,n)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=n==null?void 0:n.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},Q=new Set(["auto","scroll","overlay"]),mt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(Q.has(e.overflowY)||Q.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},ht=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return n;n=n.parentElement}return document.body};function gt(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const o={};return n.forEach((c,d)=>{o[c]=e[d]}),o})}function yt(t){const n=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...n]}function F(t,n){if(n==="*")return!0;if(n.endsWith("/*")){const e=n.slice(0,-1);return t.startsWith(e)&&t.length>e.length}return t===n}function pt(t,n,e){for(const o of e)if(F(t,o.from)&&F(n,o.to))return o.transition;for(const o of e)if((o.from==="*"||F(t,o.from))&&(o.to==="*"||F(n,o.to)))return o.transition;return null}const vt=768,Et=10,wt=10;function St(t={}){const{preserveScroll:n=i=>i}=t,e=typeof n=="function"?n:()=>n;let o=null,c=!1,d=!1;const m=()=>{const i=(o==null?void 0:o.clientWidth)??0,l=i>0?i:typeof window<"u"?window.innerWidth:0;return l>0&&l<vt},S=()=>(d||(c=m(),d=!0),c),y=i=>{var v;const l=e(S());if(l===!1)return{preserves:!1,shared:!1,storageKey:`path:${i}`};if(l===!0)return{preserves:!0,shared:!1,storageKey:`path:${i}`};const g=((v=l.exclude)==null?void 0:v.some(r=>F(i,r)))??!1,p=!g&&!!l.key;return{preserves:!g,shared:p,storageKey:p?`shared:${l.key}`:`path:${i}`}},x=i=>y(i).preserves;let R=null;const h=new Map;let T=null,A=!1,O=0;const I=()=>{o&&T&&!A&&h.set(y(T).storageKey,{x:o.scrollLeft,y:o.scrollTop})},L=i=>{if(!o)return;const l=y(i);if(l.preserves&&l.shared&&!h.has(l.storageKey))return;const g=l.preserves&&h.has(l.storageKey)?h.get(l.storageKey):{x:0,y:0};let p=0;const v=()=>{if(!o)return;o.scrollTo({top:g.y,left:g.x}),!(Math.abs(o.scrollTop-g.y)<1&&Math.abs(o.scrollLeft-g.x)<1)&&p<Et&&(p++,requestAnimationFrame(v))};requestAnimationFrame(v)};return{initializeContext:(i,l)=>{A=!0;const g=++O;R=i,o||(o=mt(i),c=m(),d=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{c=m()}).observe(o),(o===document.documentElement?window:o).addEventListener("scroll",I,{passive:!0})),T=l,L(l);let p=0;const v=()=>{g===O&&(p++,p>=wt?A=!1:requestAnimationFrame(v))};requestAnimationFrame(v)},calculateScrollOffset:(i,l)=>{const g=i?y(i).storageKey:null,p=g&&h.has(g)?h.get(g):{x:0,y:0},v=l?y(l):null,r=v!=null&&v.preserves?v.storageKey:null,s=r&&h.has(r)?h.get(r):{x:0,y:0};return{x:-s.x+p.x,y:-s.y+p.y}},evictScrollPosition:i=>{h.delete(y(i).storageKey)},shouldPreserve:x,getScrollContainer:()=>o,getPositionedParentElement:()=>R?ht(R):document.body,getScrollPosition:i=>{const l=i?y(i).storageKey:null;return l&&h.has(l)?h.get(l):{x:0,y:0}}}}const tt=30,et=8,nt=1.2,ot=30,bt=600;function Tt(){let t=null,n=!1,e=!1,o=null,c=null,d=!1;const m=(a,u)=>{for(let f=0;f<a.length;f++){const E=a.item(f);if(E&&E.identifier===u)return E}return null},S=()=>{o!==null&&(clearTimeout(o),o=null)},y=()=>{c!==null&&(clearTimeout(c),c=null)},x=()=>{n=!0,e=!0,S(),y(),o=setTimeout(()=>{n=!1,e=!1,o=null},bt)},R=a=>{if(a.touches.length!==1){t=null;return}const u=a.touches.item(0);if(!u){t=null;return}const f=window.innerWidth,E=u.clientX<=tt,P=u.clientX>=f-tt;if(!E&&!P){t=null;return}t={identifier:u.identifier,startX:u.clientX,startY:u.clientY,fromLeftEdge:E,moved:!1}},h=a=>{if(!t)return;if(a.touches.length!==1){t=null;return}const u=m(a.touches,t.identifier);if(!u){t=null;return}const f=u.clientX-t.startX,E=u.clientY-t.startY,P=Math.abs(f),i=Math.abs(E);if(i>et&&i>P*nt){t=null;return}const l=t.fromLeftEdge?f>0:f<0;P>et&&P>i*nt&&l&&(t.moved=!0)},T=a=>{if(!t)return;const u=m(a.changedTouches,t.identifier);if(!u){t=null;return}const f=u.clientX-t.startX,E=t.fromLeftEdge?f>0:f<0;if(t.moved&&E&&Math.abs(f)>=ot){x(),t=null;return}t.moved&&Math.abs(f)>=ot&&x(),t=null},A=()=>{t&&(t.moved&&x(),t=null)};return{initialize:()=>{if(typeof window>"u"||d)return;d=!0;const a={passive:!0,capture:!0};window.addEventListener("touchstart",R,a),window.addEventListener("touchmove",h,a),window.addEventListener("touchend",T,a),window.addEventListener("touchcancel",A,a)},destroy:()=>{if(typeof window>"u"||!d)return;d=!1;const a={capture:!0};window.removeEventListener("touchstart",R,a),window.removeEventListener("touchmove",h,a),window.removeEventListener("touchend",T,a),window.removeEventListener("touchcancel",A,a),S(),y(),t=null,n=!1,e=!1},isSwipeBack:()=>{const a=n||e;return a&&S(),a},onPageEnter:()=>{n=!1,S(),y(),c=setTimeout(()=>{e=!1,c=null},0)}}}function Pt(){let t=null;function n(){var o,c;t&&((o=t.outResolve)==null||o.call(t,null),(c=t.inResolve)==null||c.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){n();return}const o={from:t.from,to:t.to};t.outResolve(o),t.inResolve(o),t=null}}return{trigger(o,c){var m;c==="out"&&(t==null?void 0:t.to)===o&&!t.from&&((m=t.inResolve)==null||m.call(t,null),t={}),t&&(c==="out"&&t.from&&t.from!==o||c==="in"&&t.to&&t.to!==o)&&n(),t||(t={}),c==="out"?t.from=o:t.to=o},get(o){return new Promise(c=>{t||(t={}),o==="out"?t.outResolve=c:t.inResolve=c,e()})}}}const X=new Map;let z=null,rt=!1;function it(t){if(t instanceof HTMLElement&&X.has(t)){const n=X.get(t);X.delete(t),queueMicrotask(n)}for(const n of Array.from(t.childNodes))it(n)}function Rt(){if(rt||typeof document>"u")return;rt=!0,z=new MutationObserver(n=>{for(const e of n)for(const o of Array.from(e.removedNodes))it(o)});const t=()=>{z==null||z.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function At(t,n){return Rt(),X.set(t,n),()=>{X.delete(t)}}function xt(t){return Array.isArray(t)}function lt(t){const n=[];for(const e of t)xt(e)?n.push(...lt(e)):n.push(e);return n}function Lt(t,n={}){const{transitions:e=[],middleware:o=(r,s)=>({from:r,to:s}),preserveScroll:c=r=>r}=t,d=n.host??new st,m=Pt(),S=yt(lt(e)),y=Tt();y.initialize();const{initializeContext:x,calculateScrollOffset:R,evictScrollPosition:h,shouldPreserve:T,getScrollContainer:A,getPositionedParentElement:O,getScrollPosition:I}=St({preserveScroll:c});let L=null,k=null;const a=new WeakMap,u=r=>{a.set(r,{parent:r.parentElement,nextSibling:r.nextElementSibling})},f=r=>{const s=a.get(r);return s||{parent:r.parentElement,nextSibling:r.nextElementSibling}},E=(r,s,b,w,B)=>{const K=w.element,D=B.element,{parent:M,nextSibling:C}=w.parent?{parent:w.parent,nextSibling:w.nextSibling}:f(K),_=K.cloneNode(!0),q={scrollOffset:R(s,b),from:{scroll:I(s)},to:{scroll:I(b)},get scrollingElement(){return A()||document.documentElement},get positionedParent(){return O()}};dt(_,q),T(s)||h(s);const j=Promise.resolve(_),Z=Promise.resolve(D),J=[],ct={from:j,to:Z,context:q,createElement:((Y,$="div")=>{const N=document.createElement($);return N.setAttribute("data-ssgoi-id",Y),J.push(N),N})},at=Promise.resolve(r.prepare?r.prepare(ct):{});gt({from:j,to:Z,extras:at}).then(({from:Y,to:$,extras:N})=>{M&&(C&&M.contains(C)?M.insertBefore(_,C):M.appendChild(_));const G=r.animation({from:Y,to:$,context:q,...N}),U=G.onComplete;G.onComplete=()=>{U==null||U(),_.parentElement&&_.parentElement.removeChild(_);for(const V of J)V.parentElement&&V.parentElement.removeChild(V)},d.attach(G)})},P=(r,s)=>{const b=y.isSwipeBack();m.trigger(r,s),m.get(s).then(w=>{if(s==="in"&&y.onPageEnter(),!w)return;if(b){s==="out"&&w.from&&!T(w.from)&&h(w.from),L=null,k=null;return}if(s!=="in")return;const{from:B,to:K}=o(w.from,w.to),D=pt(B,K,S),M=L,C=k;L=null,k=null,!(!D||!M||!C)&&E(D,B,K,M,C)})},i=(r,s)=>{const b=f(r);L={element:r,parent:b.parent,nextSibling:b.nextSibling};const w=r.getAttribute("data-ssgoi-transition")??s;P(w,"out")},l=new WeakSet,g=(r,s)=>{l.has(s)||(l.add(s),u(s),x(s,r),k={element:s,parent:s.parentElement,nextSibling:s.nextElementSibling},P(r,"in"),At(s,()=>i(s,r)))},p=new Map;return{register:g,refFor:r=>{let s=p.get(r);return s||(s=b=>{b&&g(r,b)},p.set(r,s)),s}}}exports.Animation=H.Animation;exports.MultiAnimation=H.MultiAnimation;exports.WebAnimation=H.WebAnimation;exports.HostAnimation=st;exports.createSggoiTransitionContext=Lt;
1
+ "use strict";var mt=Object.defineProperty;var ht=(t,n,e)=>n in t?mt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var F=(t,n,e)=>ht(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("./multi-animation-Dw2JTJI2.cjs");class lt extends z.Animation{constructor(){super(...arguments);F(this,"child",null);F(this,"_state","idle");F(this,"_settled",!1);F(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const l=o.getPose();o.complete(),e.matchInto(l)}e.playbackRate=this.playbackRate;const i=e.onComplete;e.onComplete=()=>{i==null||i(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const f=e.onUpdate;e.onUpdate=l=>{var d;f==null||f(l),(d=this.onUpdate)==null||d.call(this,l),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var o;return((o=this.child)==null?void 0:o.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var o;(o=this.child)==null||o.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const gt=(t,n)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=n==null?void 0:n.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},tt=new Set(["auto","scroll","overlay"]),yt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(tt.has(e.overflowY)||tt.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},vt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return n;n=n.parentElement}return document.body};function pt(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const o={};return n.forEach((i,f)=>{o[i]=e[f]}),o})}function Et(t){const n=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...n]}function W(t,n){if(n==="*")return!0;if(n.endsWith("/*")){const e=n.slice(0,-1);return t.startsWith(e)&&t.length>e.length}return t===n}function Tt(t,n,e){for(const o of e)if(W(t,o.from)&&W(n,o.to))return o.transition;for(const o of e)if((o.from==="*"||W(t,o.from))&&(o.to==="*"||W(n,o.to)))return o.transition;return null}const bt=768,St=10,wt=10;function Rt(t={}){const{preserveScroll:n=c=>c}=t,e=typeof n=="function"?n:()=>n;let o=null,i=!1,f=!1;const l=()=>{const c=(o==null?void 0:o.clientWidth)??0,a=c>0?c:typeof window<"u"?window.innerWidth:0;return a>0&&a<bt},d=()=>(f||(i=l(),f=!0),i),g=c=>{var E;const a=e(d());if(a===!1)return{preserves:!1,shared:!1,storageKey:`path:${c}`};if(a===!0)return{preserves:!0,shared:!1,storageKey:`path:${c}`};const v=((E=a.exclude)==null?void 0:E.some(r=>W(c,r)))??!1,p=!v&&!!a.key;return{preserves:!v,shared:p,storageKey:p?`shared:${a.key}`:`path:${c}`}},L=c=>g(c).preserves;let A=null;const y=new Map;let w=null,O=!1,k=0;const I=()=>{o&&w&&!O&&y.set(g(w).storageKey,{x:o.scrollLeft,y:o.scrollTop})},M=c=>{if(!o)return;const a=g(c);if(a.preserves&&a.shared&&!y.has(a.storageKey))return;const v=a.preserves&&y.has(a.storageKey)?y.get(a.storageKey):{x:0,y:0};let p=0;const E=()=>{if(!o)return;o.scrollTo({top:v.y,left:v.x}),!(Math.abs(o.scrollTop-v.y)<1&&Math.abs(o.scrollLeft-v.x)<1)&&p<St&&(p++,requestAnimationFrame(E))};requestAnimationFrame(E)};return{initializeContext:(c,a)=>{O=!0;const v=++k;A=c,o||(o=yt(c),i=l(),f=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{i=l()}).observe(o),(o===document.documentElement?window:o).addEventListener("scroll",I,{passive:!0})),w=a,M(a);let p=0;const E=()=>{v===k&&(p++,p>=wt?O=!1:requestAnimationFrame(E))};requestAnimationFrame(E)},calculateScrollOffset:(c,a)=>{const v=c?g(c).storageKey:null,p=v&&y.has(v)?y.get(v):{x:0,y:0},E=a?g(a):null,r=E!=null&&E.preserves?E.storageKey:null,s=r&&y.has(r)?y.get(r):{x:0,y:0};return{x:-s.x+p.x,y:-s.y+p.y}},evictScrollPosition:c=>{y.delete(g(c).storageKey)},shouldPreserve:L,getScrollContainer:()=>o,getPositionedParentElement:()=>A?vt(A):document.body,getScrollPosition:c=>{const a=c?g(c).storageKey:null;return a&&y.has(a)?y.get(a):{x:0,y:0}}}}const et=30,nt=8,ot=1.2,rt=30,At=600;function Ot(){let t=null,n=!1,e=!1,o=null,i=null,f=!1;const l=(u,m)=>{for(let h=0;h<u.length;h++){const T=u.item(h);if(T&&T.identifier===m)return T}return null},d=()=>{o!==null&&(clearTimeout(o),o=null)},g=()=>{i!==null&&(clearTimeout(i),i=null)},L=()=>{n=!0,e=!0,d(),g(),o=setTimeout(()=>{n=!1,e=!1,o=null},At)},A=u=>{if(u.touches.length!==1){t=null;return}const m=u.touches.item(0);if(!m){t=null;return}const h=window.innerWidth,T=m.clientX<=et,R=m.clientX>=h-et;if(!T&&!R){t=null;return}t={identifier:m.identifier,startX:m.clientX,startY:m.clientY,fromLeftEdge:T,moved:!1}},y=u=>{if(!t)return;if(u.touches.length!==1){t=null;return}const m=l(u.touches,t.identifier);if(!m){t=null;return}const h=m.clientX-t.startX,T=m.clientY-t.startY,R=Math.abs(h),c=Math.abs(T);if(c>nt&&c>R*ot){t=null;return}const a=t.fromLeftEdge?h>0:h<0;R>nt&&R>c*ot&&a&&(t.moved=!0)},w=u=>{if(!t)return;const m=l(u.changedTouches,t.identifier);if(!m){t=null;return}const h=m.clientX-t.startX,T=t.fromLeftEdge?h>0:h<0;if(t.moved&&T&&Math.abs(h)>=rt){L(),t=null;return}t.moved&&Math.abs(h)>=rt&&L(),t=null},O=()=>{t&&(t.moved&&L(),t=null)};return{initialize:()=>{if(typeof window>"u"||f)return;f=!0;const u={passive:!0,capture:!0};window.addEventListener("touchstart",A,u),window.addEventListener("touchmove",y,u),window.addEventListener("touchend",w,u),window.addEventListener("touchcancel",O,u)},destroy:()=>{if(typeof window>"u"||!f)return;f=!1;const u={capture:!0};window.removeEventListener("touchstart",A,u),window.removeEventListener("touchmove",y,u),window.removeEventListener("touchend",w,u),window.removeEventListener("touchcancel",O,u),d(),g(),t=null,n=!1,e=!1},isSwipeBack:()=>{const u=n||e;return u&&d(),u},onPageEnter:()=>{n=!1,d(),g(),i=setTimeout(()=>{e=!1,i=null},0)}}}function Pt(){let t=null;function n(){var o,i;t&&((o=t.outResolve)==null||o.call(t,null),(i=t.inResolve)==null||i.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){n();return}const o={from:t.from,to:t.to};t.outResolve(o),t.inResolve(o),t=null}}return{trigger(o,i){var l;i==="out"&&(t==null?void 0:t.to)===o&&!t.from&&((l=t.inResolve)==null||l.call(t,null),t={}),t&&(i==="out"&&t.from&&t.from!==o||i==="in"&&t.to&&t.to!==o)&&n(),t||(t={}),i==="out"?t.from=o:t.to=o},get(o){return new Promise(i=>{t||(t={}),o==="out"?t.outResolve=i:t.inResolve=i,e()})}}}const B=new Map;let H=null,st=!1;function ct(t){if(t instanceof HTMLElement&&B.has(t)){const n=B.get(t);B.delete(t),queueMicrotask(n)}for(const n of Array.from(t.childNodes))ct(n)}function Lt(){if(st||typeof document>"u")return;st=!0,H=new MutationObserver(n=>{for(const e of n)for(const o of Array.from(e.removedNodes))ct(o)});const t=()=>{H==null||H.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function Mt(t,n){return Lt(),B.set(t,n),()=>{B.delete(t)}}function _t(t){return Array.isArray(t)}function at(t){const n=[];for(const e of t)_t(e)?n.push(...at(e)):n.push(e);return n}function xt(t,n={}){const{transitions:e=[],middleware:o=(r,s)=>({from:r,to:s}),preserveScroll:i=r=>r}=t,f=n.host??new lt,l=Pt(),d=Et(at(e)),g=Ot();g.initialize();const{initializeContext:L,calculateScrollOffset:A,evictScrollPosition:y,shouldPreserve:w,getScrollContainer:O,getPositionedParentElement:k,getScrollPosition:I}=Rt({preserveScroll:i});let M=null,x=null;const u=new WeakMap,m=r=>{u.set(r,{parent:r.parentElement,nextSibling:r.nextElementSibling})},h=r=>{const s=u.get(r);return s||{parent:r.parentElement,nextSibling:r.nextElementSibling}},T=(r,s,S,b,D)=>{const N=b.element,X=D.element,{parent:_,nextSibling:C}=b.parent?{parent:b.parent,nextSibling:b.nextSibling}:h(N),P=N.cloneNode(!0);P.setAttribute("data-ssgoi-clone","");const q={scrollOffset:A(s,S),from:{scroll:I(s)},to:{scroll:I(S)},get scrollingElement(){return O()||document.documentElement},get positionedParent(){return k()}};gt(P,q),w(s)||y(s);const Z=Promise.resolve(P),J=Promise.resolve(X),Q=[],ft={from:Z,to:J,context:q,createElement:(($,U="div")=>{const K=document.createElement(U);return K.setAttribute("data-ssgoi-id",$),Q.push(K),K})},dt=Promise.resolve(r.prepare?r.prepare(ft):{});pt({from:Z,to:J,extras:dt}).then(({from:$,to:U,extras:K})=>{_&&(C&&_.contains(C)?_.insertBefore(P,C):_.appendChild(P));const Y=r.animation({from:$,to:U,context:q,...K}),G=Y.onComplete;Y.onComplete=()=>{G==null||G(),P.parentElement&&P.parentElement.removeChild(P);for(const V of Q)V.parentElement&&V.parentElement.removeChild(V)},f.attach(Y)})},R=(r,s)=>{const S=g.isSwipeBack();l.trigger(r,s),l.get(s).then(b=>{if(s==="in"&&g.onPageEnter(),!b)return;if(S){s==="out"&&b.from&&!w(b.from)&&y(b.from),M=null,x=null;return}if(s!=="in")return;const{from:D,to:N}=o(b.from,b.to),X=Tt(D,N,d),_=M,C=x;M=null,x=null,!(!X||!_||!C)&&T(X,D,N,_,C)})},c=(r,s)=>{const S=h(r);M={element:r,parent:S.parent,nextSibling:S.nextSibling};const b=r.getAttribute("data-ssgoi-transition")??s;R(b,"out")},a=new WeakSet,v=(r,s)=>{a.has(s)||(a.add(s),m(s),L(s,r),x={element:s,parent:s.parentElement,nextSibling:s.nextElementSibling},R(r,"in"),Mt(s,()=>c(s,r)))},p=new Map;return{register:v,refFor:r=>{let s=p.get(r);return s||(s=S=>{S&&v(r,S)},p.set(r,s)),s}}}const ut="data-ssgoi-root",Ct=`[${ut}]`,j="data-ssgoi-transition",it=`[${j}]`,kt="[data-ssgoi-clone]";function It(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Nt(t){return t.nodeType===Node.ELEMENT_NODE}function Kt(t){return t instanceof HTMLElement}function Ft(t,n){if(!It())return()=>{};t.setAttribute(ut,"");const e=l=>l.closest(Ct)===t,o=l=>{if(!Kt(l)||!e(l)||l.closest(kt))return;const d=l.getAttribute(j);d!==null&&n.register(d,l)},i=l=>{if(Nt(l)){l.matches(it)&&o(l);for(const d of l.querySelectorAll(it))o(d)}},f=new MutationObserver(l=>{for(const d of l){if(d.type==="attributes"){o(d.target);continue}for(const g of d.addedNodes)i(g)}});return f.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[j]}),i(t),()=>f.disconnect()}exports.Animation=z.Animation;exports.MultiAnimation=z.MultiAnimation;exports.WebAnimation=z.WebAnimation;exports.HostAnimation=lt;exports.createSggoiTransitionContext=xt;exports.observeSsgoiTransitions=Ft;
@@ -1,4 +1,5 @@
1
1
  export { createSggoiTransitionContext } from './ssgoi-transition/create-ssgoi-transition-context';
2
+ export { observeSsgoiTransitions } from './ssgoi-transition/observe-ssgoi-transitions';
2
3
  export { Animation, WebAnimation, MultiAnimation, HostAnimation, } from './animation';
3
4
  export type { SsgoiConfig, SsgoiContext, SsgoiPathTransition, SsgoiPathTransitionInput, TransitionConfig, PrepareArgs, AnimationFactoryArgs, CreateElement, SsgoiTransitionContext, Pose, Timeline, } from './types/index.ts';
4
5
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/lib/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/lib/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,QAAQ,CAAC"}
package/dist/internal.js CHANGED
@@ -1,52 +1,52 @@
1
- var ce = Object.defineProperty;
2
- var ae = (e, n, t) => n in e ? ce(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
- var W = (e, n, t) => ae(e, typeof n != "symbol" ? n + "" : n, t);
4
- import { A as ue } from "./multi-animation-CnxqLEka.js";
5
- import { M as Ke, W as Ne } from "./multi-animation-CnxqLEka.js";
6
- class fe extends ue {
1
+ var ft = Object.defineProperty;
2
+ var dt = (t, n, e) => n in t ? ft(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
3
+ var F = (t, n, e) => dt(t, typeof n != "symbol" ? n + "" : n, e);
4
+ import { A as ht } from "./multi-animation-CnxqLEka.js";
5
+ import { M as $t, W as qt } from "./multi-animation-CnxqLEka.js";
6
+ class mt extends ht {
7
7
  constructor() {
8
8
  super(...arguments);
9
- W(this, "child", null);
10
- W(this, "_state", "idle");
11
- W(this, "_settled", !1);
12
- W(this, "listeners", /* @__PURE__ */ new Set());
9
+ F(this, "child", null);
10
+ F(this, "_state", "idle");
11
+ F(this, "_settled", !1);
12
+ F(this, "listeners", /* @__PURE__ */ new Set());
13
13
  }
14
- attach(t) {
14
+ attach(e) {
15
15
  const o = this.child;
16
- if (this.child = t, this._settled = !1, o) {
17
- const h = o.getPose();
18
- o.complete(), t.matchInto(h);
16
+ if (this.child = e, this._settled = !1, o) {
17
+ const l = o.getPose();
18
+ o.complete(), e.matchInto(l);
19
19
  }
20
- t.playbackRate = this.playbackRate;
21
- const c = t.onComplete;
22
- t.onComplete = () => {
23
- c == null || c(), this.child === t && (this.child = null, this._state = "idle", this._settled = !0), this.notify();
20
+ e.playbackRate = this.playbackRate;
21
+ const i = e.onComplete;
22
+ e.onComplete = () => {
23
+ i == null || i(), this.child === e && (this.child = null, this._state = "idle", this._settled = !0), this.notify();
24
24
  };
25
- const d = t.onUpdate;
26
- t.onUpdate = (h) => {
27
- var S;
28
- d == null || d(h), (S = this.onUpdate) == null || S.call(this, h), this.notify();
29
- }, this._state === "paused" ? t.pause() : this._state === "reversing" ? t.reverse() : (this._state = "playing", t.play()), this.notify();
25
+ const f = e.onUpdate;
26
+ e.onUpdate = (l) => {
27
+ var d;
28
+ f == null || f(l), (d = this.onUpdate) == null || d.call(this, l), this.notify();
29
+ }, this._state === "paused" ? e.pause() : this._state === "reversing" ? e.reverse() : (this._state = "playing", e.play()), this.notify();
30
30
  }
31
31
  play() {
32
- var t;
33
- this._state = "playing", this._settled = !1, (t = this.child) == null || t.play(), this.notify();
32
+ var e;
33
+ this._state = "playing", this._settled = !1, (e = this.child) == null || e.play(), this.notify();
34
34
  }
35
35
  reverse() {
36
- var t;
37
- this._state = "reversing", this._settled = !1, (t = this.child) == null || t.reverse(), this.notify();
36
+ var e;
37
+ this._state = "reversing", this._settled = !1, (e = this.child) == null || e.reverse(), this.notify();
38
38
  }
39
39
  pause() {
40
- var t;
41
- this._state = "paused", (t = this.child) == null || t.pause(), this.notify();
40
+ var e;
41
+ this._state = "paused", (e = this.child) == null || e.pause(), this.notify();
42
42
  }
43
43
  complete() {
44
- var t;
45
- (t = this.child) == null || t.complete(), this.notify();
44
+ var e;
45
+ (e = this.child) == null || e.complete(), this.notify();
46
46
  }
47
47
  get isAnimating() {
48
- var t;
49
- return ((t = this.child) == null ? void 0 : t.isAnimating) ?? !1;
48
+ var e;
49
+ return ((e = this.child) == null ? void 0 : e.isAnimating) ?? !1;
50
50
  }
51
51
  get isPaused() {
52
52
  return this._state === "paused";
@@ -55,459 +55,504 @@ class fe extends ue {
55
55
  return this._settled && !this.child;
56
56
  }
57
57
  get isReversing() {
58
- var t;
59
- return ((t = this.child) == null ? void 0 : t.isReversing) ?? this._state === "reversing";
58
+ var e;
59
+ return ((e = this.child) == null ? void 0 : e.isReversing) ?? this._state === "reversing";
60
60
  }
61
61
  get progress() {
62
- var t;
63
- return ((t = this.child) == null ? void 0 : t.progress) ?? 0;
62
+ var e;
63
+ return ((e = this.child) == null ? void 0 : e.progress) ?? 0;
64
64
  }
65
- findTimeForProgress(t) {
65
+ findTimeForProgress(e) {
66
66
  var o;
67
- return ((o = this.child) == null ? void 0 : o.findTimeForProgress(t)) ?? null;
67
+ return ((o = this.child) == null ? void 0 : o.findTimeForProgress(e)) ?? null;
68
68
  }
69
69
  get playbackRate() {
70
70
  return super.playbackRate;
71
71
  }
72
- set playbackRate(t) {
73
- super.playbackRate = t, this.child && (this.child.playbackRate = t), this.notify();
72
+ set playbackRate(e) {
73
+ super.playbackRate = e, this.child && (this.child.playbackRate = e), this.notify();
74
74
  }
75
75
  getPose() {
76
- var t;
77
- return ((t = this.child) == null ? void 0 : t.getPose()) ?? [];
76
+ var e;
77
+ return ((e = this.child) == null ? void 0 : e.getPose()) ?? [];
78
78
  }
79
79
  getTimeline() {
80
- var t;
81
- return ((t = this.child) == null ? void 0 : t.getTimeline()) ?? [];
80
+ var e;
81
+ return ((e = this.child) == null ? void 0 : e.getTimeline()) ?? [];
82
82
  }
83
- matchInto(t) {
83
+ matchInto(e) {
84
84
  var o;
85
- (o = this.child) == null || o.matchInto(t);
85
+ (o = this.child) == null || o.matchInto(e);
86
86
  }
87
87
  /** Currently attached child, or null when nothing is playing. */
88
88
  get activeChild() {
89
89
  return this.child;
90
90
  }
91
91
  /** Subscribe to host state changes. Returns an unsubscribe fn. */
92
- subscribe(t) {
93
- return this.listeners.add(t), () => {
94
- this.listeners.delete(t);
92
+ subscribe(e) {
93
+ return this.listeners.add(e), () => {
94
+ this.listeners.delete(e);
95
95
  };
96
96
  }
97
97
  notify() {
98
- for (const t of this.listeners) t();
98
+ for (const e of this.listeners) e();
99
99
  }
100
100
  }
101
- const de = (e, n) => {
102
- var t;
103
- e.style.position = "absolute", e.style.width = "100%", e.style.top = `${-1 * (((t = n == null ? void 0 : n.scrollOffset) == null ? void 0 : t.y) ?? 0)}px`, e.style.left = "0";
104
- }, J = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]), he = (e) => {
105
- let n = e.parentElement;
101
+ const gt = (t, n) => {
102
+ var e;
103
+ t.style.position = "absolute", t.style.width = "100%", t.style.top = `${-1 * (((e = n == null ? void 0 : n.scrollOffset) == null ? void 0 : e.y) ?? 0)}px`, t.style.left = "0";
104
+ }, Q = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]), yt = (t) => {
105
+ let n = t.parentElement;
106
106
  for (; n && n !== document.body; ) {
107
- const t = window.getComputedStyle(n);
108
- if (J.has(t.overflowY) || J.has(t.overflowX))
107
+ const e = window.getComputedStyle(n);
108
+ if (Q.has(e.overflowY) || Q.has(e.overflowX))
109
109
  return n;
110
110
  n = n.parentElement;
111
111
  }
112
112
  return document.documentElement;
113
- }, me = (e) => {
114
- let n = e.parentElement;
113
+ }, pt = (t) => {
114
+ let n = t.parentElement;
115
115
  for (; n && n !== document.body; ) {
116
- const t = window.getComputedStyle(n).position;
117
- if (t === "relative" || t === "absolute" || t === "fixed" || t === "sticky")
116
+ const e = window.getComputedStyle(n).position;
117
+ if (e === "relative" || e === "absolute" || e === "fixed" || e === "sticky")
118
118
  return n;
119
119
  n = n.parentElement;
120
120
  }
121
121
  return document.body;
122
122
  };
123
- function ge(e) {
124
- const n = Object.keys(e);
125
- return Promise.all(n.map((t) => e[t])).then((t) => {
123
+ function Et(t) {
124
+ const n = Object.keys(t);
125
+ return Promise.all(n.map((e) => t[e])).then((e) => {
126
126
  const o = {};
127
- return n.forEach((c, d) => {
128
- o[c] = t[d];
127
+ return n.forEach((i, f) => {
128
+ o[i] = e[f];
129
129
  }), o;
130
130
  });
131
131
  }
132
- function ye(e) {
133
- const n = e.filter((t) => t.symmetric).map((t) => ({
134
- from: t.to,
135
- to: t.from,
136
- transition: t.transition
132
+ function vt(t) {
133
+ const n = t.filter((e) => e.symmetric).map((e) => ({
134
+ from: e.to,
135
+ to: e.from,
136
+ transition: e.transition
137
137
  }));
138
- return [...e, ...n];
138
+ return [...t, ...n];
139
139
  }
140
- function F(e, n) {
140
+ function W(t, n) {
141
141
  if (n === "*")
142
142
  return !0;
143
143
  if (n.endsWith("/*")) {
144
- const t = n.slice(0, -1);
145
- return e.startsWith(t) && e.length > t.length;
144
+ const e = n.slice(0, -1);
145
+ return t.startsWith(e) && t.length > e.length;
146
146
  }
147
- return e === n;
147
+ return t === n;
148
148
  }
149
- function pe(e, n, t) {
150
- for (const o of t)
151
- if (F(e, o.from) && F(n, o.to))
149
+ function Tt(t, n, e) {
150
+ for (const o of e)
151
+ if (W(t, o.from) && W(n, o.to))
152
152
  return o.transition;
153
- for (const o of t)
154
- if ((o.from === "*" || F(e, o.from)) && (o.to === "*" || F(n, o.to)))
153
+ for (const o of e)
154
+ if ((o.from === "*" || W(t, o.from)) && (o.to === "*" || W(n, o.to)))
155
155
  return o.transition;
156
156
  return null;
157
157
  }
158
- const ve = 768, Ee = 10, we = 10;
159
- function Se(e = {}) {
160
- const { preserveScroll: n = (i) => i } = e, t = typeof n == "function" ? n : () => n;
161
- let o = null, c = !1, d = !1;
162
- const h = () => {
163
- const i = (o == null ? void 0 : o.clientWidth) ?? 0, l = i > 0 ? i : typeof window < "u" ? window.innerWidth : 0;
164
- return l > 0 && l < ve;
165
- }, S = () => (d || (c = h(), d = !0), c), y = (i) => {
158
+ const bt = 768, wt = 10, St = 10;
159
+ function Rt(t = {}) {
160
+ const { preserveScroll: n = (c) => c } = t, e = typeof n == "function" ? n : () => n;
161
+ let o = null, i = !1, f = !1;
162
+ const l = () => {
163
+ const c = (o == null ? void 0 : o.clientWidth) ?? 0, a = c > 0 ? c : typeof window < "u" ? window.innerWidth : 0;
164
+ return a > 0 && a < bt;
165
+ }, d = () => (f || (i = l(), f = !0), i), g = (c) => {
166
166
  var v;
167
- const l = t(S());
168
- if (l === !1)
169
- return { preserves: !1, shared: !1, storageKey: `path:${i}` };
170
- if (l === !0)
171
- return { preserves: !0, shared: !1, storageKey: `path:${i}` };
172
- const g = ((v = l.exclude) == null ? void 0 : v.some((r) => F(i, r))) ?? !1, p = !g && !!l.key;
167
+ const a = e(d());
168
+ if (a === !1)
169
+ return { preserves: !1, shared: !1, storageKey: `path:${c}` };
170
+ if (a === !0)
171
+ return { preserves: !0, shared: !1, storageKey: `path:${c}` };
172
+ const p = ((v = a.exclude) == null ? void 0 : v.some((r) => W(c, r))) ?? !1, E = !p && !!a.key;
173
173
  return {
174
- preserves: !g,
175
- shared: p,
176
- storageKey: p ? `shared:${l.key}` : `path:${i}`
174
+ preserves: !p,
175
+ shared: E,
176
+ storageKey: E ? `shared:${a.key}` : `path:${c}`
177
177
  };
178
- }, x = (i) => y(i).preserves;
179
- let R = null;
180
- const m = /* @__PURE__ */ new Map();
181
- let T = null, A = !1, O = 0;
178
+ }, L = (c) => g(c).preserves;
179
+ let A = null;
180
+ const y = /* @__PURE__ */ new Map();
181
+ let S = null, O = !1, k = 0;
182
182
  const I = () => {
183
- o && T && !A && m.set(y(T).storageKey, {
183
+ o && S && !O && y.set(g(S).storageKey, {
184
184
  x: o.scrollLeft,
185
185
  y: o.scrollTop
186
186
  });
187
- }, L = (i) => {
187
+ }, _ = (c) => {
188
188
  if (!o) return;
189
- const l = y(i);
190
- if (l.preserves && l.shared && !m.has(l.storageKey))
189
+ const a = g(c);
190
+ if (a.preserves && a.shared && !y.has(a.storageKey))
191
191
  return;
192
- const g = l.preserves && m.has(l.storageKey) ? m.get(l.storageKey) : { x: 0, y: 0 };
193
- let p = 0;
192
+ const p = a.preserves && y.has(a.storageKey) ? y.get(a.storageKey) : { x: 0, y: 0 };
193
+ let E = 0;
194
194
  const v = () => {
195
195
  if (!o) return;
196
196
  o.scrollTo({
197
- top: g.y,
198
- left: g.x
199
- }), !(Math.abs(o.scrollTop - g.y) < 1 && Math.abs(o.scrollLeft - g.x) < 1) && p < Ee && (p++, requestAnimationFrame(v));
197
+ top: p.y,
198
+ left: p.x
199
+ }), !(Math.abs(o.scrollTop - p.y) < 1 && Math.abs(o.scrollLeft - p.x) < 1) && E < wt && (E++, requestAnimationFrame(v));
200
200
  };
201
201
  requestAnimationFrame(v);
202
202
  };
203
203
  return {
204
- initializeContext: (i, l) => {
205
- A = !0;
206
- const g = ++O;
207
- R = i, o || (o = he(i), c = h(), d = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
208
- c = h();
204
+ initializeContext: (c, a) => {
205
+ O = !0;
206
+ const p = ++k;
207
+ A = c, o || (o = yt(c), i = l(), f = !0, typeof ResizeObserver < "u" && new ResizeObserver(() => {
208
+ i = l();
209
209
  }).observe(o), (o === document.documentElement ? window : o).addEventListener("scroll", I, {
210
210
  passive: !0
211
- })), T = l, L(l);
212
- let p = 0;
211
+ })), S = a, _(a);
212
+ let E = 0;
213
213
  const v = () => {
214
- g === O && (p++, p >= we ? A = !1 : requestAnimationFrame(v));
214
+ p === k && (E++, E >= St ? O = !1 : requestAnimationFrame(v));
215
215
  };
216
216
  requestAnimationFrame(v);
217
217
  },
218
- calculateScrollOffset: (i, l) => {
219
- const g = i ? y(i).storageKey : null, p = g && m.has(g) ? m.get(g) : { x: 0, y: 0 }, v = l ? y(l) : null, r = v != null && v.preserves ? v.storageKey : null, s = r && m.has(r) ? m.get(r) : { x: 0, y: 0 };
218
+ calculateScrollOffset: (c, a) => {
219
+ const p = c ? g(c).storageKey : null, E = p && y.has(p) ? y.get(p) : { x: 0, y: 0 }, v = a ? g(a) : null, r = v != null && v.preserves ? v.storageKey : null, s = r && y.has(r) ? y.get(r) : { x: 0, y: 0 };
220
220
  return {
221
- x: -s.x + p.x,
222
- y: -s.y + p.y
221
+ x: -s.x + E.x,
222
+ y: -s.y + E.y
223
223
  };
224
224
  },
225
- evictScrollPosition: (i) => {
226
- m.delete(y(i).storageKey);
225
+ evictScrollPosition: (c) => {
226
+ y.delete(g(c).storageKey);
227
227
  },
228
- shouldPreserve: x,
228
+ shouldPreserve: L,
229
229
  getScrollContainer: () => o,
230
- getPositionedParentElement: () => R ? me(R) : document.body,
231
- getScrollPosition: (i) => {
232
- const l = i ? y(i).storageKey : null;
233
- return l && m.has(l) ? m.get(l) : { x: 0, y: 0 };
230
+ getPositionedParentElement: () => A ? pt(A) : document.body,
231
+ getScrollPosition: (c) => {
232
+ const a = c ? g(c).storageKey : null;
233
+ return a && y.has(a) ? y.get(a) : { x: 0, y: 0 };
234
234
  }
235
235
  };
236
236
  }
237
- const Q = 30, ee = 8, te = 1.2, ne = 30, be = 600;
238
- function Te() {
239
- let e = null, n = !1, t = !1, o = null, c = null, d = !1;
240
- const h = (a, u) => {
241
- for (let f = 0; f < a.length; f++) {
242
- const E = a.item(f);
243
- if (E && E.identifier === u) return E;
237
+ const tt = 30, et = 8, nt = 1.2, ot = 30, At = 600;
238
+ function Ot() {
239
+ let t = null, n = !1, e = !1, o = null, i = null, f = !1;
240
+ const l = (u, h) => {
241
+ for (let m = 0; m < u.length; m++) {
242
+ const T = u.item(m);
243
+ if (T && T.identifier === h) return T;
244
244
  }
245
245
  return null;
246
- }, S = () => {
246
+ }, d = () => {
247
247
  o !== null && (clearTimeout(o), o = null);
248
- }, y = () => {
249
- c !== null && (clearTimeout(c), c = null);
250
- }, x = () => {
251
- n = !0, t = !0, S(), y(), o = setTimeout(() => {
252
- n = !1, t = !1, o = null;
253
- }, be);
254
- }, R = (a) => {
255
- if (a.touches.length !== 1) {
256
- e = null;
248
+ }, g = () => {
249
+ i !== null && (clearTimeout(i), i = null);
250
+ }, L = () => {
251
+ n = !0, e = !0, d(), g(), o = setTimeout(() => {
252
+ n = !1, e = !1, o = null;
253
+ }, At);
254
+ }, A = (u) => {
255
+ if (u.touches.length !== 1) {
256
+ t = null;
257
257
  return;
258
258
  }
259
- const u = a.touches.item(0);
260
- if (!u) {
261
- e = null;
259
+ const h = u.touches.item(0);
260
+ if (!h) {
261
+ t = null;
262
262
  return;
263
263
  }
264
- const f = window.innerWidth, E = u.clientX <= Q, P = u.clientX >= f - Q;
265
- if (!E && !P) {
266
- e = null;
264
+ const m = window.innerWidth, T = h.clientX <= tt, R = h.clientX >= m - tt;
265
+ if (!T && !R) {
266
+ t = null;
267
267
  return;
268
268
  }
269
- e = {
270
- identifier: u.identifier,
271
- startX: u.clientX,
272
- startY: u.clientY,
273
- fromLeftEdge: E,
269
+ t = {
270
+ identifier: h.identifier,
271
+ startX: h.clientX,
272
+ startY: h.clientY,
273
+ fromLeftEdge: T,
274
274
  moved: !1
275
275
  };
276
- }, m = (a) => {
277
- if (!e) return;
278
- if (a.touches.length !== 1) {
279
- e = null;
276
+ }, y = (u) => {
277
+ if (!t) return;
278
+ if (u.touches.length !== 1) {
279
+ t = null;
280
280
  return;
281
281
  }
282
- const u = h(a.touches, e.identifier);
283
- if (!u) {
284
- e = null;
282
+ const h = l(u.touches, t.identifier);
283
+ if (!h) {
284
+ t = null;
285
285
  return;
286
286
  }
287
- const f = u.clientX - e.startX, E = u.clientY - e.startY, P = Math.abs(f), i = Math.abs(E);
288
- if (i > ee && i > P * te) {
289
- e = null;
287
+ const m = h.clientX - t.startX, T = h.clientY - t.startY, R = Math.abs(m), c = Math.abs(T);
288
+ if (c > et && c > R * nt) {
289
+ t = null;
290
290
  return;
291
291
  }
292
- const l = e.fromLeftEdge ? f > 0 : f < 0;
293
- P > ee && P > i * te && l && (e.moved = !0);
294
- }, T = (a) => {
295
- if (!e) return;
296
- const u = h(a.changedTouches, e.identifier);
297
- if (!u) {
298
- e = null;
292
+ const a = t.fromLeftEdge ? m > 0 : m < 0;
293
+ R > et && R > c * nt && a && (t.moved = !0);
294
+ }, S = (u) => {
295
+ if (!t) return;
296
+ const h = l(u.changedTouches, t.identifier);
297
+ if (!h) {
298
+ t = null;
299
299
  return;
300
300
  }
301
- const f = u.clientX - e.startX, E = e.fromLeftEdge ? f > 0 : f < 0;
302
- if (e.moved && E && Math.abs(f) >= ne) {
303
- x(), e = null;
301
+ const m = h.clientX - t.startX, T = t.fromLeftEdge ? m > 0 : m < 0;
302
+ if (t.moved && T && Math.abs(m) >= ot) {
303
+ L(), t = null;
304
304
  return;
305
305
  }
306
- e.moved && Math.abs(f) >= ne && x(), e = null;
307
- }, A = () => {
308
- e && (e.moved && x(), e = null);
306
+ t.moved && Math.abs(m) >= ot && L(), t = null;
307
+ }, O = () => {
308
+ t && (t.moved && L(), t = null);
309
309
  };
310
310
  return { initialize: () => {
311
- if (typeof window > "u" || d) return;
312
- d = !0;
313
- const a = { passive: !0, capture: !0 };
314
- window.addEventListener("touchstart", R, a), window.addEventListener("touchmove", m, a), window.addEventListener("touchend", T, a), window.addEventListener("touchcancel", A, a);
311
+ if (typeof window > "u" || f) return;
312
+ f = !0;
313
+ const u = { passive: !0, capture: !0 };
314
+ window.addEventListener("touchstart", A, u), window.addEventListener("touchmove", y, u), window.addEventListener("touchend", S, u), window.addEventListener("touchcancel", O, u);
315
315
  }, destroy: () => {
316
- if (typeof window > "u" || !d) return;
317
- d = !1;
318
- const a = { capture: !0 };
319
- window.removeEventListener("touchstart", R, a), window.removeEventListener("touchmove", m, a), window.removeEventListener("touchend", T, a), window.removeEventListener("touchcancel", A, a), S(), y(), e = null, n = !1, t = !1;
316
+ if (typeof window > "u" || !f) return;
317
+ f = !1;
318
+ const u = { capture: !0 };
319
+ window.removeEventListener("touchstart", A, u), window.removeEventListener("touchmove", y, u), window.removeEventListener("touchend", S, u), window.removeEventListener("touchcancel", O, u), d(), g(), t = null, n = !1, e = !1;
320
320
  }, isSwipeBack: () => {
321
- const a = n || t;
322
- return a && S(), a;
321
+ const u = n || e;
322
+ return u && d(), u;
323
323
  }, onPageEnter: () => {
324
- n = !1, S(), y(), c = setTimeout(() => {
325
- t = !1, c = null;
324
+ n = !1, d(), g(), i = setTimeout(() => {
325
+ e = !1, i = null;
326
326
  }, 0);
327
327
  } };
328
328
  }
329
- function Pe() {
330
- let e = null;
329
+ function Pt() {
330
+ let t = null;
331
331
  function n() {
332
- var o, c;
333
- e && ((o = e.outResolve) == null || o.call(e, null), (c = e.inResolve) == null || c.call(e, null), e = null);
332
+ var o, i;
333
+ t && ((o = t.outResolve) == null || o.call(t, null), (i = t.inResolve) == null || i.call(t, null), t = null);
334
334
  }
335
- function t() {
336
- if (e != null && e.from && (e != null && e.to) && (e != null && e.outResolve) && (e != null && e.inResolve)) {
337
- if (e.from === e.to) {
335
+ function e() {
336
+ if (t != null && t.from && (t != null && t.to) && (t != null && t.outResolve) && (t != null && t.inResolve)) {
337
+ if (t.from === t.to) {
338
338
  n();
339
339
  return;
340
340
  }
341
- const o = { from: e.from, to: e.to };
342
- e.outResolve(o), e.inResolve(o), e = null;
341
+ const o = { from: t.from, to: t.to };
342
+ t.outResolve(o), t.inResolve(o), t = null;
343
343
  }
344
344
  }
345
345
  return {
346
- trigger(o, c) {
347
- var h;
348
- c === "out" && (e == null ? void 0 : e.to) === o && !e.from && ((h = e.inResolve) == null || h.call(e, null), e = {}), e && (c === "out" && e.from && e.from !== o || c === "in" && e.to && e.to !== o) && n(), e || (e = {}), c === "out" ? e.from = o : e.to = o;
346
+ trigger(o, i) {
347
+ var l;
348
+ i === "out" && (t == null ? void 0 : t.to) === o && !t.from && ((l = t.inResolve) == null || l.call(t, null), t = {}), t && (i === "out" && t.from && t.from !== o || i === "in" && t.to && t.to !== o) && n(), t || (t = {}), i === "out" ? t.from = o : t.to = o;
349
349
  },
350
350
  get(o) {
351
- return new Promise((c) => {
352
- e || (e = {}), o === "out" ? e.outResolve = c : e.inResolve = c, t();
351
+ return new Promise((i) => {
352
+ t || (t = {}), o === "out" ? t.outResolve = i : t.inResolve = i, e();
353
353
  });
354
354
  }
355
355
  };
356
356
  }
357
- const X = /* @__PURE__ */ new Map();
358
- let z = null, oe = !1;
359
- function re(e) {
360
- if (e instanceof HTMLElement && X.has(e)) {
361
- const n = X.get(e);
362
- X.delete(e), queueMicrotask(n);
357
+ const B = /* @__PURE__ */ new Map();
358
+ let H = null, rt = !1;
359
+ function it(t) {
360
+ if (t instanceof HTMLElement && B.has(t)) {
361
+ const n = B.get(t);
362
+ B.delete(t), queueMicrotask(n);
363
363
  }
364
- for (const n of Array.from(e.childNodes))
365
- re(n);
364
+ for (const n of Array.from(t.childNodes))
365
+ it(n);
366
366
  }
367
- function Re() {
368
- if (oe || typeof document > "u") return;
369
- oe = !0, z = new MutationObserver((n) => {
370
- for (const t of n)
371
- for (const o of Array.from(t.removedNodes))
372
- re(o);
367
+ function Lt() {
368
+ if (rt || typeof document > "u") return;
369
+ rt = !0, H = new MutationObserver((n) => {
370
+ for (const e of n)
371
+ for (const o of Array.from(e.removedNodes))
372
+ it(o);
373
373
  });
374
- const e = () => {
375
- z == null || z.observe(document.body, { childList: !0, subtree: !0 });
374
+ const t = () => {
375
+ H == null || H.observe(document.body, { childList: !0, subtree: !0 });
376
376
  };
377
- document.body ? e() : document.addEventListener("DOMContentLoaded", e, { once: !0 });
377
+ document.body ? t() : document.addEventListener("DOMContentLoaded", t, { once: !0 });
378
378
  }
379
- function Ae(e, n) {
380
- return Re(), X.set(e, n), () => {
381
- X.delete(e);
379
+ function _t(t, n) {
380
+ return Lt(), B.set(t, n), () => {
381
+ B.delete(t);
382
382
  };
383
383
  }
384
- function xe(e) {
385
- return Array.isArray(e);
384
+ function Mt(t) {
385
+ return Array.isArray(t);
386
386
  }
387
- function se(e) {
387
+ function lt(t) {
388
388
  const n = [];
389
- for (const t of e)
390
- xe(t) ? n.push(...se(t)) : n.push(t);
389
+ for (const e of t)
390
+ Mt(e) ? n.push(...lt(e)) : n.push(e);
391
391
  return n;
392
392
  }
393
- function Ce(e, n = {}) {
393
+ function Dt(t, n = {}) {
394
394
  const {
395
- transitions: t = [],
395
+ transitions: e = [],
396
396
  middleware: o = (r, s) => ({ from: r, to: s }),
397
- preserveScroll: c = (r) => r
398
- } = e, d = n.host ?? new fe(), h = Pe(), S = ye(
399
- se(t)
400
- ), y = Te();
401
- y.initialize();
397
+ preserveScroll: i = (r) => r
398
+ } = t, f = n.host ?? new mt(), l = Pt(), d = vt(
399
+ lt(e)
400
+ ), g = Ot();
401
+ g.initialize();
402
402
  const {
403
- initializeContext: x,
404
- calculateScrollOffset: R,
405
- evictScrollPosition: m,
406
- shouldPreserve: T,
407
- getScrollContainer: A,
408
- getPositionedParentElement: O,
403
+ initializeContext: L,
404
+ calculateScrollOffset: A,
405
+ evictScrollPosition: y,
406
+ shouldPreserve: S,
407
+ getScrollContainer: O,
408
+ getPositionedParentElement: k,
409
409
  getScrollPosition: I
410
- } = Se({ preserveScroll: c });
411
- let L = null, k = null;
412
- const a = /* @__PURE__ */ new WeakMap(), u = (r) => {
413
- a.set(r, {
410
+ } = Rt({ preserveScroll: i });
411
+ let _ = null, x = null;
412
+ const u = /* @__PURE__ */ new WeakMap(), h = (r) => {
413
+ u.set(r, {
414
414
  parent: r.parentElement,
415
415
  nextSibling: r.nextElementSibling
416
416
  });
417
- }, f = (r) => {
418
- const s = a.get(r);
417
+ }, m = (r) => {
418
+ const s = u.get(r);
419
419
  return s || {
420
420
  parent: r.parentElement,
421
421
  nextSibling: r.nextElementSibling
422
422
  };
423
- }, E = (r, s, b, w, B) => {
424
- const K = w.element, D = B.element, { parent: _, nextSibling: C } = w.parent ? { parent: w.parent, nextSibling: w.nextSibling } : f(K), M = K.cloneNode(!0), H = {
425
- scrollOffset: R(s, b),
423
+ }, T = (r, s, w, b, D) => {
424
+ const N = b.element, X = D.element, { parent: M, nextSibling: C } = b.parent ? { parent: b.parent, nextSibling: b.nextSibling } : m(N), P = N.cloneNode(!0);
425
+ P.setAttribute("data-ssgoi-clone", "");
426
+ const z = {
427
+ scrollOffset: A(s, w),
426
428
  from: { scroll: I(s) },
427
- to: { scroll: I(b) },
429
+ to: { scroll: I(w) },
428
430
  get scrollingElement() {
429
- return A() || document.documentElement;
431
+ return O() || document.documentElement;
430
432
  },
431
433
  get positionedParent() {
432
- return O();
434
+ return k();
433
435
  }
434
436
  };
435
- de(M, H), T(s) || m(s);
436
- const V = Promise.resolve(M), Z = Promise.resolve(D), j = [], ie = {
437
- from: V,
438
- to: Z,
439
- context: H,
440
- createElement: ((q, Y = "div") => {
441
- const N = document.createElement(Y);
442
- return N.setAttribute("data-ssgoi-id", q), j.push(N), N;
437
+ gt(P, z), S(s) || y(s);
438
+ const Z = Promise.resolve(P), j = Promise.resolve(X), J = [], at = {
439
+ from: Z,
440
+ to: j,
441
+ context: z,
442
+ createElement: (($, q = "div") => {
443
+ const K = document.createElement(q);
444
+ return K.setAttribute("data-ssgoi-id", $), J.push(K), K;
443
445
  })
444
- }, le = Promise.resolve(
445
- r.prepare ? r.prepare(ie) : {}
446
+ }, ut = Promise.resolve(
447
+ r.prepare ? r.prepare(at) : {}
446
448
  );
447
- ge({
448
- from: V,
449
- to: Z,
450
- extras: le
451
- }).then(({ from: q, to: Y, extras: N }) => {
452
- _ && (C && _.contains(C) ? _.insertBefore(M, C) : _.appendChild(M));
453
- const $ = r.animation({
454
- from: q,
455
- to: Y,
456
- context: H,
457
- ...N
458
- }), G = $.onComplete;
459
- $.onComplete = () => {
460
- G == null || G(), M.parentElement && M.parentElement.removeChild(M);
461
- for (const U of j)
462
- U.parentElement && U.parentElement.removeChild(U);
463
- }, d.attach($);
449
+ Et({
450
+ from: Z,
451
+ to: j,
452
+ extras: ut
453
+ }).then(({ from: $, to: q, extras: K }) => {
454
+ M && (C && M.contains(C) ? M.insertBefore(P, C) : M.appendChild(P));
455
+ const U = r.animation({
456
+ from: $,
457
+ to: q,
458
+ context: z,
459
+ ...K
460
+ }), Y = U.onComplete;
461
+ U.onComplete = () => {
462
+ Y == null || Y(), P.parentElement && P.parentElement.removeChild(P);
463
+ for (const G of J)
464
+ G.parentElement && G.parentElement.removeChild(G);
465
+ }, f.attach(U);
464
466
  });
465
- }, P = (r, s) => {
466
- const b = y.isSwipeBack();
467
- h.trigger(r, s), h.get(s).then((w) => {
468
- if (s === "in" && y.onPageEnter(), !w) return;
469
- if (b) {
470
- s === "out" && w.from && !T(w.from) && m(w.from), L = null, k = null;
467
+ }, R = (r, s) => {
468
+ const w = g.isSwipeBack();
469
+ l.trigger(r, s), l.get(s).then((b) => {
470
+ if (s === "in" && g.onPageEnter(), !b) return;
471
+ if (w) {
472
+ s === "out" && b.from && !S(b.from) && y(b.from), _ = null, x = null;
471
473
  return;
472
474
  }
473
475
  if (s !== "in") return;
474
- const { from: B, to: K } = o(
475
- w.from,
476
- w.to
477
- ), D = pe(
478
- B,
479
- K,
480
- S
481
- ), _ = L, C = k;
482
- L = null, k = null, !(!D || !_ || !C) && E(D, B, K, _, C);
476
+ const { from: D, to: N } = o(
477
+ b.from,
478
+ b.to
479
+ ), X = Tt(
480
+ D,
481
+ N,
482
+ d
483
+ ), M = _, C = x;
484
+ _ = null, x = null, !(!X || !M || !C) && T(X, D, N, M, C);
483
485
  });
484
- }, i = (r, s) => {
485
- const b = f(r);
486
- L = {
486
+ }, c = (r, s) => {
487
+ const w = m(r);
488
+ _ = {
487
489
  element: r,
488
- parent: b.parent,
489
- nextSibling: b.nextSibling
490
+ parent: w.parent,
491
+ nextSibling: w.nextSibling
490
492
  };
491
- const w = r.getAttribute("data-ssgoi-transition") ?? s;
492
- P(w, "out");
493
- }, l = /* @__PURE__ */ new WeakSet(), g = (r, s) => {
494
- l.has(s) || (l.add(s), u(s), x(s, r), k = {
493
+ const b = r.getAttribute("data-ssgoi-transition") ?? s;
494
+ R(b, "out");
495
+ }, a = /* @__PURE__ */ new WeakSet(), p = (r, s) => {
496
+ a.has(s) || (a.add(s), h(s), L(s, r), x = {
495
497
  element: s,
496
498
  parent: s.parentElement,
497
499
  nextSibling: s.nextElementSibling
498
- }, P(r, "in"), Ae(s, () => i(s, r)));
499
- }, p = /* @__PURE__ */ new Map();
500
- return { register: g, refFor: (r) => {
501
- let s = p.get(r);
502
- return s || (s = (b) => {
503
- b && g(r, b);
504
- }, p.set(r, s)), s;
500
+ }, R(r, "in"), _t(s, () => c(s, r)));
501
+ }, E = /* @__PURE__ */ new Map();
502
+ return { register: p, refFor: (r) => {
503
+ let s = E.get(r);
504
+ return s || (s = (w) => {
505
+ w && p(r, w);
506
+ }, E.set(r, s)), s;
505
507
  } };
506
508
  }
509
+ const ct = "data-ssgoi-root", xt = `[${ct}]`, V = "data-ssgoi-transition", st = `[${V}]`, Ct = "[data-ssgoi-clone]";
510
+ function kt() {
511
+ return typeof MutationObserver < "u" && typeof HTMLElement < "u" && typeof Node < "u";
512
+ }
513
+ function It(t) {
514
+ return t.nodeType === Node.ELEMENT_NODE;
515
+ }
516
+ function Nt(t) {
517
+ return t instanceof HTMLElement;
518
+ }
519
+ function Xt(t, n) {
520
+ if (!kt()) return () => {
521
+ };
522
+ t.setAttribute(ct, "");
523
+ const e = (l) => l.closest(xt) === t, o = (l) => {
524
+ if (!Nt(l) || !e(l) || l.closest(Ct))
525
+ return;
526
+ const d = l.getAttribute(V);
527
+ d !== null && n.register(d, l);
528
+ }, i = (l) => {
529
+ if (It(l)) {
530
+ l.matches(st) && o(l);
531
+ for (const d of l.querySelectorAll(st))
532
+ o(d);
533
+ }
534
+ }, f = new MutationObserver((l) => {
535
+ for (const d of l) {
536
+ if (d.type === "attributes") {
537
+ o(d.target);
538
+ continue;
539
+ }
540
+ for (const g of d.addedNodes)
541
+ i(g);
542
+ }
543
+ });
544
+ return f.observe(t, {
545
+ childList: !0,
546
+ subtree: !0,
547
+ attributes: !0,
548
+ attributeFilter: [V]
549
+ }), i(t), () => f.disconnect();
550
+ }
507
551
  export {
508
- ue as Animation,
509
- fe as HostAnimation,
510
- Ke as MultiAnimation,
511
- Ne as WebAnimation,
512
- Ce as createSggoiTransitionContext
552
+ ht as Animation,
553
+ mt as HostAnimation,
554
+ $t as MultiAnimation,
555
+ qt as WebAnimation,
556
+ Dt as createSggoiTransitionContext,
557
+ Xt as observeSsgoiTransitions
513
558
  };
@@ -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,EAMb,MAAM,QAAQ,CAAC;AAQhB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAiC5D;;;;;;;;;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,CA2Pd"}
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,EAMb,MAAM,QAAQ,CAAC;AAQhB,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAiC5D;;;;;;;;;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,CA4Pd"}
@@ -0,0 +1,3 @@
1
+ import { SsgoiContext } from '../types/index.ts';
2
+ export declare function observeSsgoiTransitions(root: Element, ssgoi: SsgoiContext): () => void;
3
+ //# sourceMappingURL=observe-ssgoi-transitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-ssgoi-transitions.d.ts","sourceRoot":"","sources":["../../src/lib/ssgoi-transition/observe-ssgoi-transitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAwB3C,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,YAAY,GAClB,MAAM,IAAI,CAyDZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/core",
3
- "version": "6.3.1",
3
+ "version": "6.4.0",
4
4
  "description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
5
5
  "private": false,
6
6
  "type": "module",