@ssgoi/core 7.1.0-beta.0 → 7.1.0-beta.1

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/internal.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var _t=Object.defineProperty;var Nt=(n,e,t)=>e in n?_t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var K=(n,e,t)=>Nt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("./resolve-transition-rule-BL12rDDu.cjs"),ot=require("./multi-animation-B5hEmEgN.cjs");class Mt extends ot.Animation{constructor(){super(...arguments);K(this,"child",null);K(this,"_state","idle");K(this,"_settled",!1);K(this,"listeners",new Set)}attach(t){const i=this.child;if(this.child=t,this._settled=!1,i){const f=i.getPose();i.complete(),t.matchInto(f)}t.playbackRate=this.playbackRate;const c=t.onComplete;t.onComplete=()=>{c==null||c(),this.child===t&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const r=t.onUpdate;t.onUpdate=f=>{var u;r==null||r(f),(u=this.onUpdate)==null||u.call(this,f),this.notify()},this._state==="paused"?t.pause():this._state==="reversing"?t.reverse():(this._state="playing",t.play()),this.notify()}play(){var t;this._state="playing",this._settled=!1,(t=this.child)==null||t.play(),this.notify()}reverse(){var t;this._state="reversing",this._settled=!1,(t=this.child)==null||t.reverse(),this.notify()}pause(){var t;this._state="paused",(t=this.child)==null||t.pause(),this.notify()}complete(){var t;(t=this.child)==null||t.complete(),this.notify()}get isAnimating(){var t;return((t=this.child)==null?void 0:t.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var t;return((t=this.child)==null?void 0:t.isReversing)??this._state==="reversing"}get progress(){var t;return((t=this.child)==null?void 0:t.progress)??0}findTimeForProgress(t){var i;return((i=this.child)==null?void 0:i.findTimeForProgress(t))??null}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.child&&(this.child.playbackRate=t),this.notify()}getPose(){var t;return((t=this.child)==null?void 0:t.getPose())??[]}getTimeline(){var t;return((t=this.child)==null?void 0:t.getTimeline())??[]}matchInto(t){var i;(i=this.child)==null||i.matchInto(t)}get activeChild(){return this.child}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(const t of this.listeners)t()}}const It=(n,e)=>{var t;n.style.position="absolute",n.style.width="100%",n.style.top=`${-1*(((t=e==null?void 0:e.scrollOffset)==null?void 0:t.y)??0)}px`,n.style.left="0"},vt=new Set(["auto","scroll","overlay"]),Ft=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e);if(vt.has(t.overflowY)||vt.has(t.overflowX))return e;e=e.parentElement}return document.documentElement},Bt=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e).position;if(t==="relative"||t==="absolute"||t==="fixed"||t==="sticky")return e;e=e.parentElement}return document.body};function Wt(n){const e=Object.keys(n);return Promise.all(e.map(t=>n[t])).then(t=>{const i={};return e.forEach((c,r)=>{i[c]=t[r]}),i})}const Xt=768,qt=10,zt=10;function Gt(n={}){const{resolvePath:e=h=>h}=n;let t=null,i=!1,c=!1;const r=()=>{const h=(t==null?void 0:t.clientWidth)??0,p=h>0?h:typeof window<"u"?window.innerWidth:0;return p>0&&p<Xt},f=()=>(c||(i=r(),c=!0),i),u=h=>`path:${e(h)}`;let v=null;const d=new Map;let g=null,S=!1,C=0,L=0,H=0;const Y=()=>{t&&g&&!S&&d.set(u(g),{x:t.scrollLeft,y:t.scrollTop})},$=(h,p,T)=>{if(!t)return;const M=++L,x=u(h),A=p&&d.has(x)?d.get(x):{x:0,y:0};let k=0;const _=()=>{if(!t||T!==C||M!==L)return;p||d.set(x,A),t.scrollTo({top:A.y,left:A.x}),!(Math.abs(t.scrollTop-A.y)<1&&Math.abs(t.scrollLeft-A.x)<1)&&k<qt&&(k++,requestAnimationFrame(_))};requestAnimationFrame(_)};return{initializeContext:(h,p,T)=>{S=!0;const M=g===p?C:++C;v=h,t||(t=Ft(h),i=r(),c=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{i=r()}).observe(t),(t===document.documentElement?window:t).addEventListener("scroll",Y,{passive:!0})),g=p;const x=u(p),A=d.get(x),k=F=>{M===C&&(H=M,F&&A&&d.set(x,A),$(p,F,M))};T!==void 0?k(T):requestAnimationFrame(()=>{H!==M&&M===C&&k(!1)});let _=0;const G=()=>{M===C&&(_++,_>=zt?S=!1:requestAnimationFrame(G))};return requestAnimationFrame(G),k},calculateScrollOffset:(h,p,T=!1)=>{const M=h?u(h):null,x=M&&d.has(M)?d.get(M):{x:0,y:0},A=p&&T?u(p):null,k=A&&d.has(A)?d.get(A):{x:0,y:0};return{x:-k.x+x.x,y:-k.y+x.y}},evictScrollPosition:h=>{d.delete(u(h))},getScrollContainer:()=>t,getPositionedParentElement:()=>v?Bt(v):document.body,getScrollPosition:(h,p=!0)=>{if(!p)return{x:0,y:0};const T=h?u(h):null;return T&&d.has(T)?d.get(T):{x:0,y:0}},getIsMobile:f}}const bt=30,Et=8,wt=1.2,St=30,Vt=600;function Kt(){let n=null,e=!1,t=!1,i=null,c=null,r=!1;const f=(y,b)=>{for(let P=0;P<y.length;P++){const O=y.item(P);if(O&&O.identifier===b)return O}return null},u=()=>{i!==null&&(clearTimeout(i),i=null)},v=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{e=!0,t=!0,u(),v(),i=setTimeout(()=>{e=!1,t=!1,i=null},Vt)},g=y=>{if(y.touches.length!==1){n=null;return}const b=y.touches.item(0);if(!b){n=null;return}const P=window.innerWidth,O=b.clientX<=bt,I=b.clientX>=P-bt;if(!O&&!I){n=null;return}n={identifier:b.identifier,startX:b.clientX,startY:b.clientY,fromLeftEdge:O,moved:!1}},S=y=>{if(!n)return;if(y.touches.length!==1){n=null;return}const b=f(y.touches,n.identifier);if(!b){n=null;return}const P=b.clientX-n.startX,O=b.clientY-n.startY,I=Math.abs(P),h=Math.abs(O);if(h>Et&&h>I*wt){n=null;return}const p=n.fromLeftEdge?P>0:P<0;I>Et&&I>h*wt&&p&&(n.moved=!0)},C=y=>{if(!n)return;const b=f(y.changedTouches,n.identifier);if(!b){n=null;return}const P=b.clientX-n.startX,O=n.fromLeftEdge?P>0:P<0;if(n.moved&&O&&Math.abs(P)>=St){d(),n=null;return}n.moved&&Math.abs(P)>=St&&d(),n=null},L=()=>{n&&(n.moved&&d(),n=null)};return{initialize:()=>{if(typeof window>"u"||r)return;r=!0;const y={passive:!0,capture:!0};window.addEventListener("touchstart",g,y),window.addEventListener("touchmove",S,y),window.addEventListener("touchend",C,y),window.addEventListener("touchcancel",L,y)},destroy:()=>{if(typeof window>"u"||!r)return;r=!1;const y={capture:!0};window.removeEventListener("touchstart",g,y),window.removeEventListener("touchmove",S,y),window.removeEventListener("touchend",C,y),window.removeEventListener("touchcancel",L,y),u(),v(),n=null,e=!1,t=!1},isSwipeBack:()=>{const y=e||t;return y&&u(),y},onPageEnter:()=>{e=!1,u(),v(),c=setTimeout(()=>{t=!1,c=null},0)}}}function Ut(){let n=!1;const e=()=>{n=!0};return typeof window<"u"&&window.addEventListener("popstate",e),{resolve(t,i){const c=n?"backward":"forward";return n=!1,c},dispose(){typeof window<"u"&&window.removeEventListener("popstate",e)}}}function Yt(n={}){let e=null,t=null;function i(){var r,f;e&&((r=e.out)==null||r.resolve(null),(f=e.in)==null||f.resolve(null),e=null)}function c(){if(e!=null&&e.out&&e.in){if(e.out.path===e.in.path){i();return}const r={from:e.out.path,to:e.in.path,out:e.out.payload,in:e.in.payload};t=r,e.out.resolve(r),e.in.resolve(r),e=null}}return{arrive(r,f,u){return new Promise(v=>{var C,L;const d=t===null?null:f==="out"?{path:t.from,payload:t.out}:{path:t.to,payload:t.in};if((d==null?void 0:d.path)===r){v(null);return}f==="out"&&((C=e==null?void 0:e.in)==null?void 0:C.path)===r&&!e.out&&(e.in.resolve(null),e.in=void 0);const g=e==null?void 0:e[f];g&&g.path!==r&&i(),e||(e={});const S=e[f];if(S){if(((L=n.keepCurrent)==null?void 0:L.call(n,{type:f,path:r,current:S.payload,next:u}))??!1){v(null);return}S.resolve(null)}e[f]={path:r,payload:u,resolve:v},c()})},cancel(r){(e!=null&&e.out&&r(e.out.payload)||e!=null&&e.in&&r(e.in.payload))&&i(),(t&&r(t.out)||t&&r(t.in))&&(t=null)}}}const $t={},z=new Map;let Q=null,Pt=!1;function Ot(n,e,t){n instanceof HTMLElement&&z.has(n)&&!n.isConnected&&t.set(n,{entry:z.get(n),anchor:e});for(const i of Array.from(n.childNodes))Ot(i,e,t)}function jt(n){const e=new Set(Array.from(n.values(),({entry:t})=>t));for(const[t,{entry:i,anchor:c}]of n){z.delete(t);let r=i.parent,f=!1;for(;r;){if(r.group===i.group&&e.has(r)){f=!0;break}r=r.parent}queueMicrotask(()=>i.callback(c,{emit:!f}))}}function Zt(){if(Pt||typeof document>"u")return;Pt=!0,Q=new MutationObserver(e=>{const t=new Map;for(const i of e){const c={parent:i.target,nextSibling:i.nextSibling};for(const r of Array.from(i.removedNodes))Ot(r,c,t)}jt(t)});const n=()=>{Q==null||Q.observe(document.body,{childList:!0,subtree:!0})};document.body?n():document.addEventListener("DOMContentLoaded",n,{once:!0})}function Jt(n,e,t=$t){Zt();let i=n.parentElement,c=null;for(;i;){const r=z.get(i);if((r==null?void 0:r.group)===t){c=r;break}i=i.parentElement}return z.set(n,{element:n,callback:e,group:t,parent:c}),()=>{z.delete(n)}}const ut=new WeakMap;let tt=null;const et="none !important";function U(n){const e=n.style.getPropertyValue("display");return n.style.getPropertyPriority("display")?`${e} !important`:e}function Qt(){return tt||(tt=new MutationObserver(n=>{for(const e of n){const t=e.target,i=ut.get(t);if(!i)continue;const c=U(t);c!==i.accounted&&(i.accounted=c,c===et?(i.reactHidden=!0,i.onHide()):c!=="none"&&i.reactHidden&&(i.reactHidden=!1,i.onShow()))}}),tt)}function te(n,e){const t=U(n),i={accounted:t,reactHidden:t===et,onHide:e.onHide,onShow:e.onShow};return ut.set(n,i),Qt().observe(n,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return U(n)===et},setDisplay(c,r=!1){c===null?n.style.removeProperty("display"):n.style.setProperty("display",c,r?"important":""),i.accounted=U(n)},sync(){i.accounted=U(n),i.reactHidden=i.accounted===et},stop(){ut.delete(n)}}}function ee(n,e={}){const{transitions:t=[],middleware:i=(o,s)=>({from:o,to:s})}=n,c=e.host??new Mt,r={},f=Yt({keepCurrent:({current:o,next:s})=>o.element.contains(s.element)}),u=Ut(),v=typeof t=="function"?t:()=>t,d=Kt();d.initialize();const g=new Map,S=o=>{let s=g.get(o);return s===void 0&&(s=i(o,o).from,g.set(o,s)),s},{initializeContext:C,calculateScrollOffset:L,evictScrollPosition:H,getScrollContainer:Y,getPositionedParentElement:$,getScrollPosition:j,getIsMobile:y}=Gt({resolvePath:S}),b=new Map,P=()=>{const o=y();let s=b.get(o);return s||(s=v({isMobile:o}),b.set(o,s)),s},O=new WeakMap,I=o=>{O.set(o,{parent:o.parentNode,nextSibling:o.nextSibling})},h=o=>{const s=O.get(o);return s||{parent:o.parentNode,nextSibling:o.nextSibling}},p=new WeakMap,T=new WeakMap;let M=0;const x=o=>{const s=typeof getComputedStyle<"u"?getComputedStyle(o).display:"";return s&&s!=="none"?s:"block"},A=(o,s)=>{s.visibleDisplay=o.style.getPropertyValue("display"),s.computedDisplay=x(o)},k=(o,s)=>{if(T.get(o)!==s)return;T.delete(o);const l=p.get(o);l&&(l.savedCss!==null&&(o.style.cssText=l.savedCss,l.savedCss=null),l.intent==="hidden"?l.vis.setDisplay("none",!0):l.visibleDisplay?(l.vis.setDisplay(l.visibleDisplay,!1),A(o,l)):(l.vis.setDisplay(null),A(o,l)))},_=(o,s)=>{if(o.mode!=="hidden")return;const l=Array.from(new Set([o.element,s==null?void 0:s.element].filter(Boolean))),w=++M;for(const a of l)T.set(a,w);c.complete();for(const a of l)k(a,w)},G=(o,s,l,w,a,m,E)=>{const N=a.element,R=m.element,B=(a.mode??"unmount")==="hidden",{parent:W,nextSibling:q}=a.parent?{parent:a.parent,nextSibling:a.nextSibling}:h(N),Z=L(l,w,E.to),st={direction:s,scrollOffset:Z,from:{scroll:j(l)},to:{scroll:j(w,E.to)},get scrollingElement(){return Y()||document.documentElement},get positionedParent(){return $()}};let D;if(B){D=N,D.style.top=`${-1*((Z==null?void 0:Z.y)??0)}px`;const X=p.get(R);X&&X.savedCss===null&&(X.savedCss=R.style.cssText)}else D=N,It(D,st);E.from||H(l);const J=B?++M:0;B&&(T.set(R,J),T.set(N,J));const yt=Promise.resolve(D),mt=Promise.resolve(R),gt=[],Lt={from:yt,to:mt,context:st,createElement:((X,rt="div")=>{const V=document.createElement(rt);return V.setAttribute("data-ssgoi-id",X),gt.push(V),V})},Dt=Promise.resolve(o.prepare?o.prepare(Lt):{});Wt({from:yt,to:mt,extras:Dt}).then(({from:X,to:rt,extras:V})=>{!B&&W&&(q&&W.contains(q)?W.insertBefore(D,q):W.appendChild(D));const lt=o.animation({from:X,to:rt,context:st,...V}),ct=lt.onComplete;lt.onComplete=()=>{ct==null||ct(),B?(k(N,J),k(R,J)):D.parentNode&&D.parentNode.removeChild(D);for(const at of gt)at.parentNode&&at.parentNode.removeChild(at)},c.attach(lt)})},F=(o,s,l)=>{const w=d.isSwipeBack();f.arrive(o,s,l).then(a=>{var it,B,W,q;if(s==="in"&&d.onPageEnter(),!a){s==="out"&&_(l);return}if(s!=="in")return;const{from:m,to:E}=i(a.from,a.to),N=u.resolve(m,E),R=Ht.resolveTransitionRule(m,E,P(),N);if(!R){(B=(it=a.in).applyScrollPolicy)==null||B.call(it,!1),H(a.from),_(a.out,a.in);return}if((q=(W=a.in).applyScrollPolicy)==null||q.call(W,R.preserveScroll.to),w){R.preserveScroll.from||H(a.from),_(a.out,a.in);return}G(R.transition,R.direction,a.from,a.to,a.out,a.in,R.preserveScroll)})},dt=(o,s)=>{const l=p.get(o);if(!l)return;const w=l.intent==="hidden";if(l.intent="hidden",l.savedCss===null&&(l.savedCss=o.style.cssText),l.vis.setDisplay(l.computedDisplay||"block",!0),o.style.position="absolute",o.style.width="100%",o.style.left="0",w)return;const a=h(o),m={element:o,parent:a.parent,nextSibling:a.nextSibling,mode:"hidden"},E=l.pendingOutPath??l.currentPath??s;l.pendingOutPath=null,F(E,"out",m)},kt=(o,s)=>{const l=p.get(o);if(!l||l.intent==="visible")return;l.intent="visible",l.currentPath=o.getAttribute("data-ssgoi-transition")??l.currentPath??s,l.pendingOutPath=null,l.pathRevision++,A(o,l),l.savedCss!==null&&(o.style.cssText=l.savedCss,l.visibleDisplay?l.vis.setDisplay(l.visibleDisplay,!1):l.vis.setDisplay(null));const w=l.currentPath,a=C(o,w),m={element:o,parent:o.parentElement,nextSibling:o.nextElementSibling,applyScrollPolicy:a};F(w,"in",m)},xt=(o,s,l,w=!0)=>{const a=p.get(o),m=(a==null?void 0:a.pendingOutPath)??(a==null?void 0:a.currentPath)??s;if(a&&(a.vis.stop(),p.delete(o),T.delete(o),a.intent==="hidden")){f.cancel(R=>R.element===o);return}if(!w)return;const E=l??h(o),N={element:o,parent:E.parent,nextSibling:E.nextSibling,mode:"unmount"};F(m,"out",N)},ft=new WeakSet,ht=(o,s,{enter:l=!0}={})=>{if(ft.has(s)){const m=p.get(s);if(m&&m.currentPath!==o){m.intent==="visible"&&m.pendingOutPath===null&&(m.pendingOutPath=m.currentPath),m.currentPath=o;const E=++m.pathRevision;queueMicrotask(()=>{m.pathRevision===E&&(m.pendingOutPath=null)})}return}ft.add(s),I(s);const w=te(s,{onHide:()=>dt(s,o),onShow:()=>kt(s,o)}),a={vis:w,savedCss:null,intent:w.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:o,pendingOutPath:null,pathRevision:0};if(p.set(s,a),!w.isHidden&&(A(s,a),l)){const m=C(s,o),E={element:s,parent:s.parentElement,nextSibling:s.nextElementSibling,applyScrollPolicy:m};F(o,"in",E)}Jt(s,(m,E)=>xt(s,o,m,(E==null?void 0:E.emit)??!0),r)},pt=new Map;return{register:ht,refFor:o=>{let s=pt.get(o);return s||(s=l=>{l&&ht(o,l)},pt.set(o,s)),s}}}const Rt="data-ssgoi-root",ne=`[${Rt}]`,nt="data-ssgoi-transition",Tt=`[${nt}]`,oe="[data-ssgoi-clone]";function ie(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function se(n){return n.nodeType===Node.ELEMENT_NODE}function re(n){return n instanceof HTMLElement}function At(n){let e=0,t=n.parentElement;for(;t;)e++,t=t.parentElement;return e}function Ct(n,e,t=n){const i=Array.from(n).sort((c,r)=>At(c)-At(r));for(const c of i){const r=c.getAttribute(nt);if(r===null)continue;let f=c.parentElement,u=!1;for(;f;){if(t.has(f)){u=!0;break}f=f.parentElement}e.register(r,c,{enter:!u})}}function le(n,e){if(!ie())return()=>{};n.setAttribute(Rt,"");const t=u=>u.closest(ne)===n,i=u=>!re(u)||!t(u)||u.closest(oe)||u.getAttribute(nt)===null?null:u,c=(u,v)=>{if(se(u)){if(u.matches(Tt)){const d=i(u);d&&v.add(d)}for(const d of u.querySelectorAll(Tt)){const g=i(d);g&&v.add(g)}}},r=new MutationObserver(u=>{const v=new Set,d=new Set;for(const g of u){if(g.type==="attributes"){const S=i(g.target);S&&v.add(S);continue}for(const S of g.addedNodes)c(S,d)}for(const g of d)v.add(g);Ct(v,e,d)});r.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[nt]});const f=new Set;return c(n,f),Ct(f,e),()=>r.disconnect()}exports.Animation=ot.Animation;exports.MultiAnimation=ot.MultiAnimation;exports.WebAnimation=ot.WebAnimation;exports.HostAnimation=Mt;exports.createSggoiTransitionContext=ee;exports.observeSsgoiTransitions=le;
1
+ "use strict";var _t=Object.defineProperty;var Nt=(n,e,t)=>e in n?_t(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var K=(n,e,t)=>Nt(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("./resolve-transition-rule-BL12rDDu.cjs"),ot=require("./multi-animation-B5hEmEgN.cjs");class Mt extends ot.Animation{constructor(){super(...arguments);K(this,"child",null);K(this,"_state","idle");K(this,"_settled",!1);K(this,"listeners",new Set)}attach(t){const i=this.child;if(this.child=t,this._settled=!1,i){const f=i.getPose();i.complete(),t.matchInto(f)}t.playbackRate=this.playbackRate;const c=t.onComplete;t.onComplete=()=>{c==null||c(),this.child===t&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const r=t.onUpdate;t.onUpdate=f=>{var u;r==null||r(f),(u=this.onUpdate)==null||u.call(this,f),this.notify()},this._state==="paused"?t.pause():this._state==="reversing"?t.reverse():(this._state="playing",t.play()),this.notify()}play(){var t;this._state="playing",this._settled=!1,(t=this.child)==null||t.play(),this.notify()}reverse(){var t;this._state="reversing",this._settled=!1,(t=this.child)==null||t.reverse(),this.notify()}pause(){var t;this._state="paused",(t=this.child)==null||t.pause(),this.notify()}complete(){var t;(t=this.child)==null||t.complete(),this.notify()}get isAnimating(){var t;return((t=this.child)==null?void 0:t.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var t;return((t=this.child)==null?void 0:t.isReversing)??this._state==="reversing"}get progress(){var t;return((t=this.child)==null?void 0:t.progress)??0}findTimeForProgress(t){var i;return((i=this.child)==null?void 0:i.findTimeForProgress(t))??null}get playbackRate(){return super.playbackRate}set playbackRate(t){super.playbackRate=t,this.child&&(this.child.playbackRate=t),this.notify()}getPose(){var t;return((t=this.child)==null?void 0:t.getPose())??[]}getTimeline(){var t;return((t=this.child)==null?void 0:t.getTimeline())??[]}matchInto(t){var i;(i=this.child)==null||i.matchInto(t)}get activeChild(){return this.child}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(const t of this.listeners)t()}}const It=(n,e)=>{var t;n.style.position="absolute",n.style.width="100%",n.style.top=`${-1*(((t=e==null?void 0:e.scrollOffset)==null?void 0:t.y)??0)}px`,n.style.left="0"},vt=new Set(["auto","scroll","overlay"]),Ft=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e);if(vt.has(t.overflowY)||vt.has(t.overflowX))return e;e=e.parentElement}return document.documentElement},Bt=n=>{let e=n.parentElement;for(;e&&e!==document.body;){const t=window.getComputedStyle(e).position;if(t==="relative"||t==="absolute"||t==="fixed"||t==="sticky")return e;e=e.parentElement}return document.body};function Wt(n){const e=Object.keys(n);return Promise.all(e.map(t=>n[t])).then(t=>{const i={};return e.forEach((c,r)=>{i[c]=t[r]}),i})}const Xt=768,qt=10,zt=10;function Gt(n={}){const{resolvePath:e=h=>h}=n;let t=null,i=!1,c=!1;const r=()=>{const h=(t==null?void 0:t.clientWidth)??0,p=h>0?h:typeof window<"u"?window.innerWidth:0;return p>0&&p<Xt},f=()=>(c||(i=r(),c=!0),i),u=h=>`path:${e(h)}`;let v=null;const d=new Map;let g=null,S=!1,C=0,L=0,H=0;const Y=()=>{t&&g&&!S&&d.set(u(g),{x:t.scrollLeft,y:t.scrollTop})},$=(h,p,T)=>{if(!t)return;const M=++L,x=u(h),A=p&&d.has(x)?d.get(x):{x:0,y:0};let k=0;const _=()=>{if(!t||T!==C||M!==L)return;p||d.set(x,A),t.scrollTo({top:A.y,left:A.x}),!(Math.abs(t.scrollTop-A.y)<1&&Math.abs(t.scrollLeft-A.x)<1)&&k<qt&&(k++,requestAnimationFrame(_))};requestAnimationFrame(_)};return{initializeContext:(h,p,T)=>{S=!0;const M=g===p?C:++C;v=h,t||(t=Ft(h),i=r(),c=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{i=r()}).observe(t),(t===document.documentElement?window:t).addEventListener("scroll",Y,{passive:!0})),g=p;const x=u(p),A=d.get(x),k=F=>{M===C&&(H=M,F&&A&&d.set(x,A),$(p,F,M))};T!==void 0?k(T):requestAnimationFrame(()=>{H!==M&&M===C&&k(!1)});let _=0;const G=()=>{M===C&&(_++,_>=zt?S=!1:requestAnimationFrame(G))};return requestAnimationFrame(G),k},calculateScrollOffset:(h,p,T=!1)=>{const M=h?u(h):null,x=M&&d.has(M)?d.get(M):{x:0,y:0},A=p&&T?u(p):null,k=A&&d.has(A)?d.get(A):{x:0,y:0};return{x:-k.x+x.x,y:-k.y+x.y}},evictScrollPosition:h=>{d.delete(u(h))},getScrollContainer:()=>t,getPositionedParentElement:()=>v?Bt(v):document.body,getScrollPosition:(h,p=!0)=>{if(!p)return{x:0,y:0};const T=h?u(h):null;return T&&d.has(T)?d.get(T):{x:0,y:0}},getIsMobile:f}}const bt=30,Et=8,wt=1.2,St=30,Vt=600;function Kt(){let n=null,e=!1,t=!1,i=null,c=null,r=!1;const f=(y,b)=>{for(let P=0;P<y.length;P++){const O=y.item(P);if(O&&O.identifier===b)return O}return null},u=()=>{i!==null&&(clearTimeout(i),i=null)},v=()=>{c!==null&&(clearTimeout(c),c=null)},d=()=>{e=!0,t=!0,u(),v(),i=setTimeout(()=>{e=!1,t=!1,i=null},Vt)},g=y=>{if(y.touches.length!==1){n=null;return}const b=y.touches.item(0);if(!b){n=null;return}const P=window.innerWidth,O=b.clientX<=bt,I=b.clientX>=P-bt;if(!O&&!I){n=null;return}n={identifier:b.identifier,startX:b.clientX,startY:b.clientY,fromLeftEdge:O,moved:!1}},S=y=>{if(!n)return;if(y.touches.length!==1){n=null;return}const b=f(y.touches,n.identifier);if(!b){n=null;return}const P=b.clientX-n.startX,O=b.clientY-n.startY,I=Math.abs(P),h=Math.abs(O);if(h>Et&&h>I*wt){n=null;return}const p=n.fromLeftEdge?P>0:P<0;I>Et&&I>h*wt&&p&&(n.moved=!0)},C=y=>{if(!n)return;const b=f(y.changedTouches,n.identifier);if(!b){n=null;return}const P=b.clientX-n.startX,O=n.fromLeftEdge?P>0:P<0;if(n.moved&&O&&Math.abs(P)>=St){d(),n=null;return}n.moved&&Math.abs(P)>=St&&d(),n=null},L=()=>{n&&(n.moved&&d(),n=null)};return{initialize:()=>{if(typeof window>"u"||r)return;r=!0;const y={passive:!0,capture:!0};window.addEventListener("touchstart",g,y),window.addEventListener("touchmove",S,y),window.addEventListener("touchend",C,y),window.addEventListener("touchcancel",L,y)},destroy:()=>{if(typeof window>"u"||!r)return;r=!1;const y={capture:!0};window.removeEventListener("touchstart",g,y),window.removeEventListener("touchmove",S,y),window.removeEventListener("touchend",C,y),window.removeEventListener("touchcancel",L,y),u(),v(),n=null,e=!1,t=!1},isSwipeBack:()=>{const y=e||t;return y&&u(),y},onPageEnter:()=>{e=!1,u(),v(),c=setTimeout(()=>{t=!1,c=null},0)}}}function Ut(){let n=!1;const e=()=>{n=!0};return typeof window<"u"&&window.addEventListener("popstate",e,!0),{resolve(t,i){const c=n?"backward":"forward";return n=!1,c},dispose(){typeof window<"u"&&window.removeEventListener("popstate",e,!0)}}}function Yt(n={}){let e=null,t=null;function i(){var r,f;e&&((r=e.out)==null||r.resolve(null),(f=e.in)==null||f.resolve(null),e=null)}function c(){if(e!=null&&e.out&&e.in){if(e.out.path===e.in.path){i();return}const r={from:e.out.path,to:e.in.path,out:e.out.payload,in:e.in.payload};t=r,e.out.resolve(r),e.in.resolve(r),e=null}}return{arrive(r,f,u){return new Promise(v=>{var C,L;const d=t===null?null:f==="out"?{path:t.from,payload:t.out}:{path:t.to,payload:t.in};if((d==null?void 0:d.path)===r){v(null);return}f==="out"&&((C=e==null?void 0:e.in)==null?void 0:C.path)===r&&!e.out&&(e.in.resolve(null),e.in=void 0);const g=e==null?void 0:e[f];g&&g.path!==r&&i(),e||(e={});const S=e[f];if(S){if(((L=n.keepCurrent)==null?void 0:L.call(n,{type:f,path:r,current:S.payload,next:u}))??!1){v(null);return}S.resolve(null)}e[f]={path:r,payload:u,resolve:v},c()})},cancel(r){(e!=null&&e.out&&r(e.out.payload)||e!=null&&e.in&&r(e.in.payload))&&i(),(t&&r(t.out)||t&&r(t.in))&&(t=null)}}}const $t={},z=new Map;let Q=null,Pt=!1;function Ot(n,e,t){n instanceof HTMLElement&&z.has(n)&&!n.isConnected&&t.set(n,{entry:z.get(n),anchor:e});for(const i of Array.from(n.childNodes))Ot(i,e,t)}function jt(n){const e=new Set(Array.from(n.values(),({entry:t})=>t));for(const[t,{entry:i,anchor:c}]of n){z.delete(t);let r=i.parent,f=!1;for(;r;){if(r.group===i.group&&e.has(r)){f=!0;break}r=r.parent}queueMicrotask(()=>i.callback(c,{emit:!f}))}}function Zt(){if(Pt||typeof document>"u")return;Pt=!0,Q=new MutationObserver(e=>{const t=new Map;for(const i of e){const c={parent:i.target,nextSibling:i.nextSibling};for(const r of Array.from(i.removedNodes))Ot(r,c,t)}jt(t)});const n=()=>{Q==null||Q.observe(document.body,{childList:!0,subtree:!0})};document.body?n():document.addEventListener("DOMContentLoaded",n,{once:!0})}function Jt(n,e,t=$t){Zt();let i=n.parentElement,c=null;for(;i;){const r=z.get(i);if((r==null?void 0:r.group)===t){c=r;break}i=i.parentElement}return z.set(n,{element:n,callback:e,group:t,parent:c}),()=>{z.delete(n)}}const ut=new WeakMap;let tt=null;const et="none !important";function U(n){const e=n.style.getPropertyValue("display");return n.style.getPropertyPriority("display")?`${e} !important`:e}function Qt(){return tt||(tt=new MutationObserver(n=>{for(const e of n){const t=e.target,i=ut.get(t);if(!i)continue;const c=U(t);c!==i.accounted&&(i.accounted=c,c===et?(i.reactHidden=!0,i.onHide()):c!=="none"&&i.reactHidden&&(i.reactHidden=!1,i.onShow()))}}),tt)}function te(n,e){const t=U(n),i={accounted:t,reactHidden:t===et,onHide:e.onHide,onShow:e.onShow};return ut.set(n,i),Qt().observe(n,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return U(n)===et},setDisplay(c,r=!1){c===null?n.style.removeProperty("display"):n.style.setProperty("display",c,r?"important":""),i.accounted=U(n)},sync(){i.accounted=U(n),i.reactHidden=i.accounted===et},stop(){ut.delete(n)}}}function ee(n,e={}){const{transitions:t=[],middleware:i=(o,s)=>({from:o,to:s})}=n,c=e.host??new Mt,r={},f=Yt({keepCurrent:({current:o,next:s})=>o.element.contains(s.element)}),u=Ut(),v=typeof t=="function"?t:()=>t,d=Kt();d.initialize();const g=new Map,S=o=>{let s=g.get(o);return s===void 0&&(s=i(o,o).from,g.set(o,s)),s},{initializeContext:C,calculateScrollOffset:L,evictScrollPosition:H,getScrollContainer:Y,getPositionedParentElement:$,getScrollPosition:j,getIsMobile:y}=Gt({resolvePath:S}),b=new Map,P=()=>{const o=y();let s=b.get(o);return s||(s=v({isMobile:o}),b.set(o,s)),s},O=new WeakMap,I=o=>{O.set(o,{parent:o.parentNode,nextSibling:o.nextSibling})},h=o=>{const s=O.get(o);return s||{parent:o.parentNode,nextSibling:o.nextSibling}},p=new WeakMap,T=new WeakMap;let M=0;const x=o=>{const s=typeof getComputedStyle<"u"?getComputedStyle(o).display:"";return s&&s!=="none"?s:"block"},A=(o,s)=>{s.visibleDisplay=o.style.getPropertyValue("display"),s.computedDisplay=x(o)},k=(o,s)=>{if(T.get(o)!==s)return;T.delete(o);const l=p.get(o);l&&(l.savedCss!==null&&(o.style.cssText=l.savedCss,l.savedCss=null),l.intent==="hidden"?l.vis.setDisplay("none",!0):l.visibleDisplay?(l.vis.setDisplay(l.visibleDisplay,!1),A(o,l)):(l.vis.setDisplay(null),A(o,l)))},_=(o,s)=>{if(o.mode!=="hidden")return;const l=Array.from(new Set([o.element,s==null?void 0:s.element].filter(Boolean))),w=++M;for(const a of l)T.set(a,w);c.complete();for(const a of l)k(a,w)},G=(o,s,l,w,a,m,E)=>{const N=a.element,R=m.element,B=(a.mode??"unmount")==="hidden",{parent:W,nextSibling:q}=a.parent?{parent:a.parent,nextSibling:a.nextSibling}:h(N),Z=L(l,w,E.to),st={direction:s,scrollOffset:Z,from:{scroll:j(l)},to:{scroll:j(w,E.to)},get scrollingElement(){return Y()||document.documentElement},get positionedParent(){return $()}};let D;if(B){D=N,D.style.top=`${-1*((Z==null?void 0:Z.y)??0)}px`;const X=p.get(R);X&&X.savedCss===null&&(X.savedCss=R.style.cssText)}else D=N,It(D,st);E.from||H(l);const J=B?++M:0;B&&(T.set(R,J),T.set(N,J));const yt=Promise.resolve(D),mt=Promise.resolve(R),gt=[],Lt={from:yt,to:mt,context:st,createElement:((X,rt="div")=>{const V=document.createElement(rt);return V.setAttribute("data-ssgoi-id",X),gt.push(V),V})},Dt=Promise.resolve(o.prepare?o.prepare(Lt):{});Wt({from:yt,to:mt,extras:Dt}).then(({from:X,to:rt,extras:V})=>{!B&&W&&(q&&W.contains(q)?W.insertBefore(D,q):W.appendChild(D));const lt=o.animation({from:X,to:rt,context:st,...V}),ct=lt.onComplete;lt.onComplete=()=>{ct==null||ct(),B?(k(N,J),k(R,J)):D.parentNode&&D.parentNode.removeChild(D);for(const at of gt)at.parentNode&&at.parentNode.removeChild(at)},c.attach(lt)})},F=(o,s,l)=>{const w=d.isSwipeBack();f.arrive(o,s,l).then(a=>{var it,B,W,q;if(s==="in"&&d.onPageEnter(),!a){s==="out"&&_(l);return}if(s!=="in")return;const{from:m,to:E}=i(a.from,a.to),N=u.resolve(m,E),R=Ht.resolveTransitionRule(m,E,P(),N);if(!R){(B=(it=a.in).applyScrollPolicy)==null||B.call(it,!1),H(a.from),_(a.out,a.in);return}if((q=(W=a.in).applyScrollPolicy)==null||q.call(W,R.preserveScroll.to),w){R.preserveScroll.from||H(a.from),_(a.out,a.in);return}G(R.transition,R.direction,a.from,a.to,a.out,a.in,R.preserveScroll)})},dt=(o,s)=>{const l=p.get(o);if(!l)return;const w=l.intent==="hidden";if(l.intent="hidden",l.savedCss===null&&(l.savedCss=o.style.cssText),l.vis.setDisplay(l.computedDisplay||"block",!0),o.style.position="absolute",o.style.width="100%",o.style.left="0",w)return;const a=h(o),m={element:o,parent:a.parent,nextSibling:a.nextSibling,mode:"hidden"},E=l.pendingOutPath??l.currentPath??s;l.pendingOutPath=null,F(E,"out",m)},kt=(o,s)=>{const l=p.get(o);if(!l||l.intent==="visible")return;l.intent="visible",l.currentPath=o.getAttribute("data-ssgoi-transition")??l.currentPath??s,l.pendingOutPath=null,l.pathRevision++,A(o,l),l.savedCss!==null&&(o.style.cssText=l.savedCss,l.visibleDisplay?l.vis.setDisplay(l.visibleDisplay,!1):l.vis.setDisplay(null));const w=l.currentPath,a=C(o,w),m={element:o,parent:o.parentElement,nextSibling:o.nextElementSibling,applyScrollPolicy:a};F(w,"in",m)},xt=(o,s,l,w=!0)=>{const a=p.get(o),m=(a==null?void 0:a.pendingOutPath)??(a==null?void 0:a.currentPath)??s;if(a&&(a.vis.stop(),p.delete(o),T.delete(o),a.intent==="hidden")){f.cancel(R=>R.element===o);return}if(!w)return;const E=l??h(o),N={element:o,parent:E.parent,nextSibling:E.nextSibling,mode:"unmount"};F(m,"out",N)},ft=new WeakSet,ht=(o,s,{enter:l=!0}={})=>{if(ft.has(s)){const m=p.get(s);if(m&&m.currentPath!==o){m.intent==="visible"&&m.pendingOutPath===null&&(m.pendingOutPath=m.currentPath),m.currentPath=o;const E=++m.pathRevision;queueMicrotask(()=>{m.pathRevision===E&&(m.pendingOutPath=null)})}return}ft.add(s),I(s);const w=te(s,{onHide:()=>dt(s,o),onShow:()=>kt(s,o)}),a={vis:w,savedCss:null,intent:w.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block",currentPath:o,pendingOutPath:null,pathRevision:0};if(p.set(s,a),!w.isHidden&&(A(s,a),l)){const m=C(s,o),E={element:s,parent:s.parentElement,nextSibling:s.nextElementSibling,applyScrollPolicy:m};F(o,"in",E)}Jt(s,(m,E)=>xt(s,o,m,(E==null?void 0:E.emit)??!0),r)},pt=new Map;return{register:ht,refFor:o=>{let s=pt.get(o);return s||(s=l=>{l&&ht(o,l)},pt.set(o,s)),s}}}const Rt="data-ssgoi-root",ne=`[${Rt}]`,nt="data-ssgoi-transition",Tt=`[${nt}]`,oe="[data-ssgoi-clone]";function ie(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function se(n){return n.nodeType===Node.ELEMENT_NODE}function re(n){return n instanceof HTMLElement}function At(n){let e=0,t=n.parentElement;for(;t;)e++,t=t.parentElement;return e}function Ct(n,e,t=n){const i=Array.from(n).sort((c,r)=>At(c)-At(r));for(const c of i){const r=c.getAttribute(nt);if(r===null)continue;let f=c.parentElement,u=!1;for(;f;){if(t.has(f)){u=!0;break}f=f.parentElement}e.register(r,c,{enter:!u})}}function le(n,e){if(!ie())return()=>{};n.setAttribute(Rt,"");const t=u=>u.closest(ne)===n,i=u=>!re(u)||!t(u)||u.closest(oe)||u.getAttribute(nt)===null?null:u,c=(u,v)=>{if(se(u)){if(u.matches(Tt)){const d=i(u);d&&v.add(d)}for(const d of u.querySelectorAll(Tt)){const g=i(d);g&&v.add(g)}}},r=new MutationObserver(u=>{const v=new Set,d=new Set;for(const g of u){if(g.type==="attributes"){const S=i(g.target);S&&v.add(S);continue}for(const S of g.addedNodes)c(S,d)}for(const g of d)v.add(g);Ct(v,e,d)});r.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[nt]});const f=new Set;return c(n,f),Ct(f,e),()=>r.disconnect()}exports.Animation=ot.Animation;exports.MultiAnimation=ot.MultiAnimation;exports.WebAnimation=ot.WebAnimation;exports.HostAnimation=Mt;exports.createSggoiTransitionContext=ee;exports.observeSsgoiTransitions=le;
package/dist/internal.js CHANGED
@@ -299,13 +299,13 @@ function Ut() {
299
299
  const e = () => {
300
300
  n = !0;
301
301
  };
302
- return typeof window < "u" && window.addEventListener("popstate", e), {
302
+ return typeof window < "u" && window.addEventListener("popstate", e, !0), {
303
303
  resolve(t, i) {
304
304
  const c = n ? "backward" : "forward";
305
305
  return n = !1, c;
306
306
  },
307
307
  dispose() {
308
- typeof window < "u" && window.removeEventListener("popstate", e);
308
+ typeof window < "u" && window.removeEventListener("popstate", e, !0);
309
309
  }
310
310
  };
311
311
  }
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-direction.d.ts","sourceRoot":"","sources":["../../src/lib/ssgoi-transition/navigation-direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAElD,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,IAAI,0BAA0B,CAwB7E"}
1
+ {"version":3,"file":"navigation-direction.d.ts","sourceRoot":"","sources":["../../src/lib/ssgoi-transition/navigation-direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAElD,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAAC;IACvD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,IAAI,0BAA0B,CA2B7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/core",
3
- "version": "7.1.0-beta.0",
3
+ "version": "7.1.0-beta.1",
4
4
  "description": "Core animation engine for SSGOI - Native app-like page transitions with spring physics",
5
5
  "private": false,
6
6
  "type": "module",