@lazycatcloud/vue-router-stack 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import type { StackTransitionContext, StackTransitionFactory, StackTransitionName, StackTransitionRegistry } from "./types";
2
2
  export declare const DEFAULT_STACK_TRANSITION = "slide";
3
- export declare const DEFAULT_STACK_TRANSITION_EASING = "cubic-bezier(0.2, 0, 0, 1)";
3
+ export declare const DEFAULT_STACK_TRANSITION_EASING = "cubic-bezier(0.3, 0, 0.66, 1)";
4
4
  export declare function defineStackTransition(factory: StackTransitionFactory): StackTransitionFactory;
5
5
  export declare const builtinStackTransitions: StackTransitionRegistry;
6
6
  export declare function resolveStackTransition(name: StackTransitionName, transitions: StackTransitionRegistry): StackTransitionFactory;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),b=require("vue-router"),J={};function z(e="route"){const r=(J[e]??0)+1;return J[e]=r,`${e}-${r}`}const v="slide",re="cubic-bezier(0.2, 0, 0, 1)";function oe(e){return e}const ne=({direction:e})=>{const r=e==="back";return{entering:r?[{transform:"translateX(-18%)",opacity:.96},{transform:"translateX(0)",opacity:1}]:[{transform:"translateX(100%)"},{transform:"translateX(0)"}],leaving:r?[{transform:"translateX(0)",opacity:1},{transform:"translateX(100%)",opacity:1}]:[{transform:"translateX(0)",opacity:1},{transform:"translateX(-18%)",opacity:.96}]}},ae=()=>({entering:[{opacity:0},{opacity:1}],leaving:[{opacity:1},{opacity:0}]}),ce=({direction:e})=>{const r=e==="back";return{entering:r?[{transform:"scale(0.98)",opacity:0},{transform:"scale(1)",opacity:1}]:[{transform:"scale(1.04)",opacity:0},{transform:"scale(1)",opacity:1}],leaving:r?[{transform:"scale(1)",opacity:1},{transform:"scale(1.04)",opacity:0}]:[{transform:"scale(1)",opacity:1},{transform:"scale(0.98)",opacity:0}]}},ie=()=>({}),se={slide:ne,fade:ae,scale:ce,none:ie};function ue(e,r){const n=r[e];return n||r[v]}function Q(e,r,n){if(!r||!e.animate||Number(n.duration)<=0)return Promise.resolve();const l=e.animate(r,n);return l.finished.then(()=>l.cancel())}async function le(e,r){const n=e(r),l={duration:r.duration,easing:r.easing,fill:"both",...n.options};await Promise.all([Q(r.enteringElement,n.entering,l),Q(r.leavingElement,n.leaving,l)])}const H=Symbol("stack-router");function fe(){const e=window.history.state;return typeof(e==null?void 0:e.position)=="number"?e.position:window.history.length}function M(e,r){return r||(e==="pop"?"back":e==="replace"?"none":"forward")}function de(e){const r=b.createRouter(e),n=[],l=i.shallowRef(),f=e.transitionDuration??240,T=e.transitionEasing??re,S=e.transition??v,p={...se,...e.transitions},E=e.maxStackSize??30;let d=-1,s,g=!1;const P=(c,a,u,h,k=!1,w="stack")=>{s={action:c,direction:M(c,a),source:w,delta:u,transition:h==null?void 0:h.transition,duration:h==null?void 0:h.duration,easing:h==null?void 0:h.easing,resetRoot:k}},F=(c,a)=>{const u=(s==null?void 0:s.action)??"push",h=M(u,s==null?void 0:s.direction),k=l.value,w=u==="push"&&h==="forward",te=L(c);return{id:z("route"),key:c.fullPath,fullPath:c.fullPath,pathname:c.path,params:c.params,query:c.query,action:u,direction:h,source:(s==null?void 0:s.source)??"stack",entryDirection:h,lastPathname:(k==null?void 0:k.pathname)||(a.name?a.path:void 0),pushedByRoute:w?k==null?void 0:k.pathname:k==null?void 0:k.pushedByRoute,position:fe(),delta:s==null?void 0:s.delta,transition:(s==null?void 0:s.transition)??S,transitionDuration:(s==null?void 0:s.duration)??f,transitionEasing:(s==null?void 0:s.easing)??T,cache:te}},L=c=>{const a=c.meta.stack;return c.meta.stackCache!==!1&&(a==null?void 0:a.cache)!==!1},x=()=>{if(E<=0||n.length<=E)return;const c=n.length-E;n.splice(0,c),d=Math.max(0,d-c)},W=c=>{if(c.action==="pop"){let a=-1;if(c.direction==="forward"||(c.delta??0)>0){for(let u=d+1;u<n.length;u++)if(n[u].key===c.key){a=u;break}}else for(let u=d-1;u>=0;u--)if(n[u].key===c.key){a=u;break}if(a>=0){const u=n[a];n[a]={...u,...c,id:u.id,source:c.source,entryDirection:u.entryDirection,transition:u.transition,transitionDuration:u.transitionDuration,transitionEasing:u.transitionEasing},d=a}else n.push({...c,direction:"none",entryDirection:"none",transition:"none",isStackFallback:!0}),d=n.length-1}else if(c.action==="replace"){if(s!=null&&s.resetRoot){n.splice(0,n.length,c),d=0,l.value=n[d];return}d>=0?n[d]=c:(n.push(c),d=0)}else d<n.length-1&&n.splice(d+1),n.push(c),d=n.length-1;x(),l.value=n[d]};e.history.listen((c,a,u)=>{const h="delta"in u?u.delta:void 0,k=u.direction==="back"?"back":u.direction==="forward"?"forward":void 0;s?(s.delta=h,s.direction=M(s.action,s.direction??k)):P(u.type==="pop"?"pop":u.type,k,h,void 0,!1,"external")}),r.beforeEach(c=>!((s==null?void 0:s.action)==="pop"&&g&&!n.some(a=>a.fullPath===c.fullPath))),r.afterEach((c,a,u)=>{if(u){s=void 0;return}W(F(c,a)),s=void 0});const B=r.push.bind(r),A=r.replace.bind(r),G=r.back.bind(r),V=r.forward.bind(r),$=r.go.bind(r),j=(c,a)=>(P("push",(a==null?void 0:a.direction)??"forward",void 0,a),B(c)),K=(c,a)=>(P("replace",(a==null?void 0:a.direction)??"root",void 0,a),A(c)),t=(c,a)=>{const u=r.resolve(c).fullPath;let h=-1;for(let w=d;w>=0;w--)if(n[w].fullPath===u){h=w;break}if(h<0)return!1;const k=h-d;return k===0||(P("pop",(a==null?void 0:a.direction)??"back",k,a),$(k)),!0},o=(c,a)=>{const u=r.resolve(c).fullPath;if(d>=0&&r.currentRoute.value.fullPath===u){const h=n[d],k={...h,id:z("route"),action:"replace",direction:(a==null?void 0:a.direction)??"root",source:"stack",entryDirection:(a==null?void 0:a.direction)??"root",delta:void 0,transition:(a==null?void 0:a.transition)??h.transition,transitionDuration:(a==null?void 0:a.duration)??h.transitionDuration,transitionEasing:(a==null?void 0:a.easing)??h.transitionEasing,cache:!0,isStackFallback:!1};return n.splice(0,n.length,k),d=0,g=!0,l.value=k,Promise.resolve(void 0)}return P("replace",(a==null?void 0:a.direction)??"root",void 0,a,!0),g=!0,A(c)},m=()=>{P("pop","back",-1),G()},R=()=>{P("pop","forward",1),V()},y=r;y.push=j,y.replace=K,y.popTo=t,y.resetRoot=o,y.back=m,y.forward=R;const _={router:y,transitionDuration:f,transitionEasing:T,transition:S,transitions:p,maxStackSize:E,shouldTransition:e.shouldTransition,current:l,get history(){return n},canGoBack:(c=1)=>d-c>=0,push:j,replace:K,popTo:t,resetRoot:o,back:m,forward:R},X=r.install.bind(r);return r.install=c=>{c.provide(H,_),X(c)},y}const Y="onPageWillEnter",U="onPageDidEnter",Z="onPageWillLeave",N="onPageDidLeave";function he(e,r,n){if(!n)throw new Error(`${e} must be called inside setup().`);const l=n.proxy,f=l[e]??[];f.push(()=>{n.isUnmounted||r()}),l[e]=f,n.exposed&&(n.exposed[e]=f)}function C(e){return(r,n=i.getCurrentInstance())=>he(e,r,n)}const me=C(Y),ye=C(U),ke=C(Z),pe=C(N);function Re(){const e=i.inject(H);if(!e)throw new Error("useStackRouter must be used after createStackRouter().");return{router:e.router,canGoBack:e.canGoBack,push:e.push,replace:e.replace,popTo:e.popTo,resetRoot:e.resetRoot,back:e.back,forward:e.forward}}function O(){const e=i.inject(H);if(!e)throw new Error("RouterOutlet must be used with createStackRouter().");return e}function D(e,r){const n=e.value;if(!n)return;const l=n[r];Array.isArray(l)?l.forEach(f=>f()):typeof l=="function"&&l.call(n)}function I(e){e.classList.remove("rs-page-hidden","rs-page-invisible"),e.removeAttribute("aria-hidden")}function q(e){e.classList.add("rs-page-hidden"),e.setAttribute("aria-hidden","true")}function ee(e){var r;return(r=e.components)==null?void 0:r.default}function be(e){const r=ee(e);return r!==void 0&&typeof r=="object"&&"name"in r&&r.name==="RouterView"}const Pe=i.defineComponent({name:"RouterOutlet",setup(){const e=O(),r=b.useRoute(),n=i.inject(b.routeLocationKey),l=i.inject(b.matchedRouteKey,void 0),f=i.computed(()=>{const t=l==null?void 0:l.value;if(!t)return 0;const o=r.matched.findIndex(m=>m===t);return o>=0?o+1:0}),T=i.computed(()=>r.matched[f.value]),S=i.computed(()=>{for(let t=f.value;t<r.matched.length;t++){const o=r.matched[t];if(!be(o))return o}return T.value}),p=i.shallowRef([]),E=i.ref("");let d=0;i.provide(b.matchedRouteKey,S);const s=t=>p.value.find(o=>o.key===t),g=t=>{p.value.forEach(o=>{o.pageElement&&(o===t?I(o.pageElement):q(o.pageElement))})},P=t=>{const o=p.value.findIndex(m=>m===t);o>=0&&(p.value=p.value.slice(0,o+1))},F=t=>{p.value=p.value.filter(o=>o!==t)},L=t=>{const o=new Set(e.history.map(m=>m.key));p.value=p.value.filter(m=>m===t||m.routeInfo.cache&&o.has(m.key))},x=t=>{var m;const o=t.props.default;return o?o===!0?((m=e.current.value)==null?void 0:m.params)??{}:typeof o=="function"?o(n):o:{}},W=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transition??t.routeInfo.transition??e.transition:t.routeInfo.transition??e.transition,B=(t,o)=>!(t.routeInfo.isStackFallback||t.routeInfo.direction==="none"||t.routeInfo.direction==="root"||t.routeInfo.action==="pop"&&(o.routeInfo.entryDirection==="none"||o.routeInfo.entryDirection==="root"||o.routeInfo.transition==="none")),A=(t,o)=>{var R;const m=B(t,o);return((R=e.shouldTransition)==null?void 0:R.call(e,{action:t.routeInfo.action,direction:t.routeInfo.direction,source:t.routeInfo.source,entering:t.routeInfo,leaving:o.routeInfo,defaultResult:m}))??m},G=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionDuration??t.routeInfo.transitionDuration??e.transitionDuration:t.routeInfo.transitionDuration??e.transitionDuration,V=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionEasing??t.routeInfo.transitionEasing??e.transitionEasing:t.routeInfo.transitionEasing??e.transitionEasing,$=async(t,o)=>{const m=++d;await i.nextTick();const R=t.pageElement;if(!R)return;if(D(t.componentRef,Y),!o||o===t||!o.pageElement){I(R),D(t.componentRef,U),L(t),g(t);return}const y=o.pageElement,_=A(t,o),X=_?W(t,o):"none",c=_?G(t,o):0,a=V(t,o),u=ue(X||v,e.transitions);D(o.componentRef,Z),I(R),I(y),await le(u,{direction:t.routeInfo.direction,action:t.routeInfo.action,routeInfo:t.routeInfo,enteringElement:R,leavingElement:y,duration:c,easing:a}),m===d&&(q(y),D(o.componentRef,N),D(t.componentRef,U),t.routeInfo.action==="pop"?P(t):t.routeInfo.action==="replace"&&F(o),L(t),g(t))},j=async()=>{const t=S.value,o=e.current.value;if(!t||!o)return;const m=ee(t);if(!m)return;const R=s(E.value);let y=s(o.key);y?(y.routeInfo=o,y.matchedRoute=t,y.component=m,y.props=x(t),y.mounted=!0):(y={id:z("view"),key:o.key,routeInfo:o,matchedRoute:t,component:m,props:x(t),componentRef:i.ref(),mounted:!0},p.value=[...p.value,y]),E.value=y.key,await $(y,R)};return i.watch(()=>{var t;return[(t=e.current.value)==null?void 0:t.id,S.value]},()=>{j()},{immediate:!0}),i.onUnmounted(()=>{d++,p.value=[]}),{injectedRoute:n,viewItems:p,registerStackPage:(t,o)=>{t.pageElement=o,t.key===E.value?I(o):q(o)}}},render(){return i.h("div",{class:"rs-outlet"},this.viewItems.filter(e=>e.mounted).map(e=>i.h(e.component,{key:e.id,ref:e.componentRef,...e.props,registerStackPage:r=>this.registerStackPage(e,r)})))}}),Ee=i.defineComponent({name:"RouterPage",props:{registerStackPage:{type:Function,default:void 0}},setup(e,{attrs:r,slots:n}){const l=i.ref();return i.onMounted(()=>{var f;l.value&&((f=e.registerStackPage)==null||f.call(e,l.value))}),()=>{var f;return i.h("section",{...r,ref:l,class:["rs-page",r.class]},(f=n.default)==null?void 0:f.call(n))}}}),we=i.defineComponent({name:"StackRouterDebugPanel",props:{initialOpen:{type:Boolean,default:!1}},setup(e){const r=O(),n=i.ref(e.initialOpen);return()=>{const l=r.current.value;return i.h("aside",{class:"rs-debug-panel"},[i.h("button",{class:"rs-debug-toggle",type:"button",onClick:()=>{n.value=!n.value}},n.value?"Stack x":"Stack"),n.value?i.h("section",{class:"rs-debug-body"},[i.h("header",[i.h("strong","Router Stack"),i.h("span",`${r.history.length} pages`)]),i.h("dl",[i.h("dt","current"),i.h("dd",(l==null?void 0:l.fullPath)??"-"),i.h("dt","canGoBack"),i.h("dd",String(r.canGoBack()))]),i.h("ol",r.history.map(f=>i.h("li",{key:f.id,class:{"rs-debug-active":f.id===(l==null?void 0:l.id),"rs-debug-no-cache":!f.cache}},[i.h("code",f.fullPath),i.h("span",[`${f.action}/${f.direction}`,` source:${f.source}`,` entry:${f.entryDirection}`,` cache:${f.cache?"yes":"no"}`,` transition:${f.transition??"-"}`])])))]):void 0])}}});Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>b.RouterLink});Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>b.RouterView});Object.defineProperty(exports,"createMemoryHistory",{enumerable:!0,get:()=>b.createMemoryHistory});Object.defineProperty(exports,"createWebHashHistory",{enumerable:!0,get:()=>b.createWebHashHistory});Object.defineProperty(exports,"createWebHistory",{enumerable:!0,get:()=>b.createWebHistory});Object.defineProperty(exports,"useRoute",{enumerable:!0,get:()=>b.useRoute});Object.defineProperty(exports,"useRouter",{enumerable:!0,get:()=>b.useRouter});exports.RouterOutlet=Pe;exports.RouterPage=Ee;exports.StackRouterDebugPanel=we;exports.createStackRouter=de;exports.defineStackTransition=oe;exports.onPageDidEnter=ye;exports.onPageDidLeave=pe;exports.onPageWillEnter=me;exports.onPageWillLeave=ke;exports.stackRouterKey=H;exports.useStackRouter=Re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("vue"),b=require("vue-router"),J={};function U(e="route"){const r=(J[e]??0)+1;return J[e]=r,`${e}-${r}`}const v="slide",re="cubic-bezier(0.3, 0, 0.66, 1)";function oe(e){return e}const ne=({direction:e})=>e==="back"?{leaving:[{transform:"translateX(0)"},{transform:"translateX(100%)"}]}:{entering:[{transform:"translateX(100%)"},{transform:"translateX(0)"}]},ae=()=>({entering:[{opacity:0},{opacity:1}],leaving:[{opacity:1},{opacity:0}]}),ce=({direction:e})=>{const r=e==="back";return{entering:r?[{transform:"scale(0.98)",opacity:0},{transform:"scale(1)",opacity:1}]:[{transform:"scale(1.04)",opacity:0},{transform:"scale(1)",opacity:1}],leaving:r?[{transform:"scale(1)",opacity:1},{transform:"scale(1.04)",opacity:0}]:[{transform:"scale(1)",opacity:1},{transform:"scale(0.98)",opacity:0}]}},ie=()=>({}),se={slide:ne,fade:ae,scale:ce,none:ie};function ue(e,r){const n=r[e];return n||r[v]}function Q(e,r,n){if(!r||!e.animate||Number(n.duration)<=0)return Promise.resolve();const l=e.animate(r,n);return l.finished.then(()=>l.cancel())}async function le(e,r){const n=e(r),l={duration:r.duration,easing:r.easing,fill:"both",...n.options};await Promise.all([Q(r.enteringElement,n.entering,l),Q(r.leavingElement,n.leaving,l)])}const H=Symbol("stack-router");function fe(){const e=window.history.state;return typeof(e==null?void 0:e.position)=="number"?e.position:window.history.length}function q(e,r){return r||(e==="pop"?"back":e==="replace"?"none":"forward")}function de(e){const r=b.createRouter(e),n=[],l=i.shallowRef(),f=e.transitionDuration??210,T=e.transitionEasing??re,S=e.transition??v,p={...se,...e.transitions},E=e.maxStackSize??30;let d=-1,s,g=!1;const P=(c,a,u,h,k=!1,w="stack")=>{s={action:c,direction:q(c,a),source:w,delta:u,transition:h==null?void 0:h.transition,duration:h==null?void 0:h.duration,easing:h==null?void 0:h.easing,resetRoot:k}},C=(c,a)=>{const u=(s==null?void 0:s.action)??"push",h=q(u,s==null?void 0:s.direction),k=l.value,w=u==="push"&&h==="forward",te=L(c);return{id:U("route"),key:c.fullPath,fullPath:c.fullPath,pathname:c.path,params:c.params,query:c.query,action:u,direction:h,source:(s==null?void 0:s.source)??"stack",entryDirection:h,lastPathname:(k==null?void 0:k.pathname)||(a.name?a.path:void 0),pushedByRoute:w?k==null?void 0:k.pathname:k==null?void 0:k.pushedByRoute,position:fe(),delta:s==null?void 0:s.delta,transition:(s==null?void 0:s.transition)??S,transitionDuration:(s==null?void 0:s.duration)??f,transitionEasing:(s==null?void 0:s.easing)??T,cache:te}},L=c=>{const a=c.meta.stack;return c.meta.stackCache!==!1&&(a==null?void 0:a.cache)!==!1},x=()=>{if(E<=0||n.length<=E)return;const c=n.length-E;n.splice(0,c),d=Math.max(0,d-c)},F=c=>{if(c.action==="pop"){let a=-1;if(c.direction==="forward"||(c.delta??0)>0){for(let u=d+1;u<n.length;u++)if(n[u].key===c.key){a=u;break}}else for(let u=d-1;u>=0;u--)if(n[u].key===c.key){a=u;break}if(a>=0){const u=n[a];n[a]={...u,...c,id:u.id,source:c.source,entryDirection:u.entryDirection,transition:u.transition,transitionDuration:u.transitionDuration,transitionEasing:u.transitionEasing},d=a}else n.push({...c,direction:"none",entryDirection:"none",transition:"none",isStackFallback:!0}),d=n.length-1}else if(c.action==="replace"){if(s!=null&&s.resetRoot){n.splice(0,n.length,c),d=0,l.value=n[d];return}d>=0?n[d]=c:(n.push(c),d=0)}else d<n.length-1&&n.splice(d+1),n.push(c),d=n.length-1;x(),l.value=n[d]};e.history.listen((c,a,u)=>{const h="delta"in u?u.delta:void 0,k=u.direction==="back"?"back":u.direction==="forward"?"forward":void 0;s?(s.delta=h,s.direction=q(s.action,s.direction??k)):P(u.type==="pop"?"pop":u.type,k,h,void 0,!1,"external")}),r.beforeEach(c=>!((s==null?void 0:s.action)==="pop"&&g&&!n.some(a=>a.fullPath===c.fullPath))),r.afterEach((c,a,u)=>{if(u){s=void 0;return}F(C(c,a)),s=void 0});const W=r.push.bind(r),A=r.replace.bind(r),G=r.back.bind(r),V=r.forward.bind(r),$=r.go.bind(r),j=(c,a)=>(P("push",(a==null?void 0:a.direction)??"forward",void 0,a),W(c)),K=(c,a)=>(P("replace",(a==null?void 0:a.direction)??"root",void 0,a),A(c)),t=(c,a)=>{const u=r.resolve(c).fullPath;let h=-1;for(let w=d;w>=0;w--)if(n[w].fullPath===u){h=w;break}if(h<0)return!1;const k=h-d;return k===0||(P("pop",(a==null?void 0:a.direction)??"back",k,a),$(k)),!0},o=(c,a)=>{const u=r.resolve(c).fullPath;if(d>=0&&r.currentRoute.value.fullPath===u){const h=n[d],k={...h,id:U("route"),action:"replace",direction:(a==null?void 0:a.direction)??"root",source:"stack",entryDirection:(a==null?void 0:a.direction)??"root",delta:void 0,transition:(a==null?void 0:a.transition)??h.transition,transitionDuration:(a==null?void 0:a.duration)??h.transitionDuration,transitionEasing:(a==null?void 0:a.easing)??h.transitionEasing,cache:!0,isStackFallback:!1};return n.splice(0,n.length,k),d=0,g=!0,l.value=k,Promise.resolve(void 0)}return P("replace",(a==null?void 0:a.direction)??"root",void 0,a,!0),g=!0,A(c)},m=()=>{P("pop","back",-1),G()},R=()=>{P("pop","forward",1),V()},y=r;y.push=j,y.replace=K,y.popTo=t,y.resetRoot=o,y.back=m,y.forward=R;const _={router:y,transitionDuration:f,transitionEasing:T,transition:S,transitions:p,maxStackSize:E,shouldTransition:e.shouldTransition,current:l,get history(){return n},canGoBack:(c=1)=>d-c>=0,push:j,replace:K,popTo:t,resetRoot:o,back:m,forward:R},M=r.install.bind(r);return r.install=c=>{c.provide(H,_),M(c)},y}const Y="onPageWillEnter",X="onPageDidEnter",Z="onPageWillLeave",N="onPageDidLeave";function he(e,r,n){if(!n)throw new Error(`${e} must be called inside setup().`);const l=n.proxy,f=l[e]??[];f.push(()=>{n.isUnmounted||r()}),l[e]=f,n.exposed&&(n.exposed[e]=f)}function B(e){return(r,n=i.getCurrentInstance())=>he(e,r,n)}const me=B(Y),ye=B(X),ke=B(Z),pe=B(N);function Re(){const e=i.inject(H);if(!e)throw new Error("useStackRouter must be used after createStackRouter().");return{router:e.router,canGoBack:e.canGoBack,push:e.push,replace:e.replace,popTo:e.popTo,resetRoot:e.resetRoot,back:e.back,forward:e.forward}}function O(){const e=i.inject(H);if(!e)throw new Error("RouterOutlet must be used with createStackRouter().");return e}function D(e,r){const n=e.value;if(!n)return;const l=n[r];Array.isArray(l)?l.forEach(f=>f()):typeof l=="function"&&l.call(n)}function I(e){e.classList.remove("rs-page-hidden","rs-page-invisible"),e.removeAttribute("aria-hidden")}function z(e){e.classList.add("rs-page-hidden"),e.setAttribute("aria-hidden","true")}function ee(e){var r;return(r=e.components)==null?void 0:r.default}function be(e){const r=ee(e);return r!==void 0&&typeof r=="object"&&"name"in r&&r.name==="RouterView"}const Pe=i.defineComponent({name:"RouterOutlet",setup(){const e=O(),r=b.useRoute(),n=i.inject(b.routeLocationKey),l=i.inject(b.matchedRouteKey,void 0),f=i.computed(()=>{const t=l==null?void 0:l.value;if(!t)return 0;const o=r.matched.findIndex(m=>m===t);return o>=0?o+1:0}),T=i.computed(()=>r.matched[f.value]),S=i.computed(()=>{for(let t=f.value;t<r.matched.length;t++){const o=r.matched[t];if(!be(o))return o}return T.value}),p=i.shallowRef([]),E=i.ref("");let d=0;i.provide(b.matchedRouteKey,S);const s=t=>p.value.find(o=>o.key===t),g=t=>{p.value.forEach(o=>{o.pageElement&&(o===t?I(o.pageElement):z(o.pageElement))})},P=t=>{const o=p.value.findIndex(m=>m===t);o>=0&&(p.value=p.value.slice(0,o+1))},C=t=>{p.value=p.value.filter(o=>o!==t)},L=t=>{const o=new Set(e.history.map(m=>m.key));p.value=p.value.filter(m=>m===t||m.routeInfo.cache&&o.has(m.key))},x=t=>{var m;const o=t.props.default;return o?o===!0?((m=e.current.value)==null?void 0:m.params)??{}:typeof o=="function"?o(n):o:{}},F=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transition??t.routeInfo.transition??e.transition:t.routeInfo.transition??e.transition,W=(t,o)=>!(t.routeInfo.isStackFallback||t.routeInfo.direction==="none"||t.routeInfo.direction==="root"||t.routeInfo.action==="pop"&&(o.routeInfo.entryDirection==="none"||o.routeInfo.entryDirection==="root"||o.routeInfo.transition==="none")),A=(t,o)=>{var R;const m=W(t,o);return((R=e.shouldTransition)==null?void 0:R.call(e,{action:t.routeInfo.action,direction:t.routeInfo.direction,source:t.routeInfo.source,entering:t.routeInfo,leaving:o.routeInfo,defaultResult:m}))??m},G=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionDuration??t.routeInfo.transitionDuration??e.transitionDuration:t.routeInfo.transitionDuration??e.transitionDuration,V=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionEasing??t.routeInfo.transitionEasing??e.transitionEasing:t.routeInfo.transitionEasing??e.transitionEasing,$=async(t,o)=>{const m=++d;await i.nextTick();const R=t.pageElement;if(!R)return;if(D(t.componentRef,Y),!o||o===t||!o.pageElement){I(R),D(t.componentRef,X),L(t),g(t);return}const y=o.pageElement,_=A(t,o),M=_?F(t,o):"none",c=_?G(t,o):0,a=V(t,o),u=ue(M||v,e.transitions);D(o.componentRef,Z),I(R),I(y),await le(u,{direction:t.routeInfo.direction,action:t.routeInfo.action,routeInfo:t.routeInfo,enteringElement:R,leavingElement:y,duration:c,easing:a}),m===d&&(z(y),D(o.componentRef,N),D(t.componentRef,X),t.routeInfo.action==="pop"?P(t):t.routeInfo.action==="replace"&&C(o),L(t),g(t))},j=async()=>{const t=S.value,o=e.current.value;if(!t||!o)return;const m=ee(t);if(!m)return;const R=s(E.value);let y=s(o.key);y?(y.routeInfo=o,y.matchedRoute=t,y.component=m,y.props=x(t),y.mounted=!0):(y={id:U("view"),key:o.key,routeInfo:o,matchedRoute:t,component:m,props:x(t),componentRef:i.ref(),mounted:!0},p.value=[...p.value,y]),E.value=y.key,await $(y,R)};return i.watch(()=>{var t;return[(t=e.current.value)==null?void 0:t.id,S.value]},()=>{j()},{immediate:!0}),i.onUnmounted(()=>{d++,p.value=[]}),{injectedRoute:n,viewItems:p,registerStackPage:(t,o)=>{t.pageElement=o,t.key===E.value?I(o):z(o)}}},render(){return i.h("div",{class:"rs-outlet"},this.viewItems.filter(e=>e.mounted).map(e=>i.h(e.component,{key:e.id,ref:e.componentRef,...e.props,registerStackPage:r=>this.registerStackPage(e,r)})))}}),Ee=i.defineComponent({name:"RouterPage",props:{registerStackPage:{type:Function,default:void 0}},setup(e,{attrs:r,slots:n}){const l=i.ref();return i.onMounted(()=>{var f;l.value&&((f=e.registerStackPage)==null||f.call(e,l.value))}),()=>{var f;return i.h("section",{...r,ref:l,class:["rs-page",r.class]},(f=n.default)==null?void 0:f.call(n))}}}),we=i.defineComponent({name:"StackRouterDebugPanel",props:{initialOpen:{type:Boolean,default:!1}},setup(e){const r=O(),n=i.ref(e.initialOpen);return()=>{const l=r.current.value;return i.h("aside",{class:"rs-debug-panel"},[i.h("button",{class:"rs-debug-toggle",type:"button",onClick:()=>{n.value=!n.value}},n.value?"Stack x":"Stack"),n.value?i.h("section",{class:"rs-debug-body"},[i.h("header",[i.h("strong","Router Stack"),i.h("span",`${r.history.length} pages`)]),i.h("dl",[i.h("dt","current"),i.h("dd",(l==null?void 0:l.fullPath)??"-"),i.h("dt","canGoBack"),i.h("dd",String(r.canGoBack()))]),i.h("ol",r.history.map(f=>i.h("li",{key:f.id,class:{"rs-debug-active":f.id===(l==null?void 0:l.id),"rs-debug-no-cache":!f.cache}},[i.h("code",f.fullPath),i.h("span",[`${f.action}/${f.direction}`,` source:${f.source}`,` entry:${f.entryDirection}`,` cache:${f.cache?"yes":"no"}`,` transition:${f.transition??"-"}`])])))]):void 0])}}});Object.defineProperty(exports,"RouterLink",{enumerable:!0,get:()=>b.RouterLink});Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>b.RouterView});Object.defineProperty(exports,"createMemoryHistory",{enumerable:!0,get:()=>b.createMemoryHistory});Object.defineProperty(exports,"createWebHashHistory",{enumerable:!0,get:()=>b.createWebHashHistory});Object.defineProperty(exports,"createWebHistory",{enumerable:!0,get:()=>b.createWebHistory});Object.defineProperty(exports,"useRoute",{enumerable:!0,get:()=>b.useRoute});Object.defineProperty(exports,"useRouter",{enumerable:!0,get:()=>b.useRouter});exports.RouterOutlet=Pe;exports.RouterPage=Ee;exports.StackRouterDebugPanel=we;exports.createStackRouter=de;exports.defineStackTransition=oe;exports.onPageDidEnter=ye;exports.onPageDidLeave=pe;exports.onPageWillEnter=me;exports.onPageWillLeave=ke;exports.stackRouterKey=H;exports.useStackRouter=Re;
@@ -1 +1 @@
1
- .rs-outlet{position:relative;display:block;width:100%;height:100%;overflow:hidden;contain:layout size style}.rs-page{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;min-width:0;min-height:0;flex-direction:column;overflow:hidden;background:var(--rs-page-background, #fff);z-index:0}.rs-page-hidden,[hidden].rs-page{display:none!important}.rs-page-invisible{opacity:0}.rs-debug-panel{position:fixed;right:12px;bottom:12px;z-index:9999;color:#d9e5ef;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,monospace}.rs-debug-toggle{min-width:72px;border:0;border-radius:6px;padding:8px 10px;color:#f8fafc;background:#111827;cursor:pointer}.rs-debug-body{width:min(420px,calc(100vw - 24px));max-height:min(520px,calc(100vh - 96px));overflow:auto;margin-top:8px;border:1px solid rgb(148 163 184 / 28%);border-radius:8px;padding:12px;background:#0f172af0;box-shadow:0 18px 48px #0f172a4d}.rs-debug-body header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}.rs-debug-body dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px;margin:0 0 10px}.rs-debug-body dt{color:#94a3b8}.rs-debug-body dd{min-width:0;margin:0;overflow-wrap:anywhere}.rs-debug-body ol{display:grid;gap:6px;margin:0;padding:0;list-style:none}.rs-debug-body li{display:grid;gap:3px;border-radius:6px;padding:7px;background:#ffffff0f}.rs-debug-body code{overflow-wrap:anywhere;color:#f8fafc}.rs-debug-body li span{color:#a7b7c8}.rs-debug-body .rs-debug-active{background:#14b8a638}.rs-debug-body .rs-debug-no-cache{outline:1px solid rgb(248 113 113 / 55%)}
1
+ .rs-outlet{position:relative;display:block;width:100%;height:100%;overflow:hidden;contain:layout size style}.rs-page{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;min-width:0;min-height:0;flex-direction:column;overflow:hidden;z-index:0}.rs-page-hidden,[hidden].rs-page{display:none!important}.rs-page-invisible{opacity:0}.rs-debug-panel{position:fixed;right:12px;bottom:12px;z-index:9999;color:#d9e5ef;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,monospace}.rs-debug-toggle{min-width:72px;border:0;border-radius:6px;padding:8px 10px;color:#f8fafc;background:#111827;cursor:pointer}.rs-debug-body{width:min(420px,calc(100vw - 24px));max-height:min(520px,calc(100vh - 96px));overflow:auto;margin-top:8px;border:1px solid rgb(148 163 184 / 28%);border-radius:8px;padding:12px;background:#0f172af0;box-shadow:0 18px 48px #0f172a4d}.rs-debug-body header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:10px}.rs-debug-body dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px;margin:0 0 10px}.rs-debug-body dt{color:#94a3b8}.rs-debug-body dd{min-width:0;margin:0;overflow-wrap:anywhere}.rs-debug-body ol{display:grid;gap:6px;margin:0;padding:0;list-style:none}.rs-debug-body li{display:grid;gap:3px;border-radius:6px;padding:7px;background:#ffffff0f}.rs-debug-body code{overflow-wrap:anywhere;color:#f8fafc}.rs-debug-body li span{color:#a7b7c8}.rs-debug-body .rs-debug-active{background:#14b8a638}.rs-debug-body .rs-debug-no-cache{outline:1px solid rgb(248 113 113 / 55%)}
@@ -1,44 +1,39 @@
1
- import { shallowRef as tt, getCurrentInstance as st, inject as F, defineComponent as Q, h as k, computed as z, ref as B, provide as it, watch as ut, onUnmounted as lt, nextTick as ft, onMounted as dt } from "vue";
2
- import { createRouter as ht, useRoute as mt, routeLocationKey as yt, matchedRouteKey as v } from "vue-router";
3
- import { RouterLink as Kt, RouterView as jt, createMemoryHistory as zt, createWebHashHistory as Ut, createWebHistory as Mt, useRoute as qt, useRouter as Jt } from "vue-router";
1
+ import { shallowRef as tt, getCurrentInstance as it, inject as B, defineComponent as Q, h as y, computed as U, ref as F, provide as st, watch as ut, onUnmounted as lt, nextTick as ft, onMounted as dt } from "vue";
2
+ import { createRouter as ht, useRoute as mt, routeLocationKey as kt, matchedRouteKey as v } from "vue-router";
3
+ import { RouterLink as jt, RouterView as zt, createMemoryHistory as Ut, createWebHashHistory as Xt, createWebHistory as Mt, useRoute as qt, useRouter as Jt } from "vue-router";
4
4
  const N = {};
5
5
  function q(t = "route") {
6
- const r = (N[t] ?? 0) + 1;
7
- return N[t] = r, `${t}-${r}`;
6
+ const o = (N[t] ?? 0) + 1;
7
+ return N[t] = o, `${t}-${o}`;
8
8
  }
9
- const Y = "slide", kt = "cubic-bezier(0.2, 0, 0, 1)";
9
+ const Y = "slide", yt = "cubic-bezier(0.3, 0, 0.66, 1)";
10
10
  function Lt(t) {
11
11
  return t;
12
12
  }
13
- const pt = ({ direction: t }) => {
14
- const r = t === "back";
15
- return {
16
- entering: r ? [
17
- { transform: "translateX(-18%)", opacity: 0.96 },
18
- { transform: "translateX(0)", opacity: 1 }
19
- ] : [{ transform: "translateX(100%)" }, { transform: "translateX(0)" }],
20
- leaving: r ? [
21
- { transform: "translateX(0)", opacity: 1 },
22
- { transform: "translateX(100%)", opacity: 1 }
23
- ] : [
24
- { transform: "translateX(0)", opacity: 1 },
25
- { transform: "translateX(-18%)", opacity: 0.96 }
26
- ]
27
- };
13
+ const pt = ({ direction: t }) => t === "back" ? {
14
+ leaving: [
15
+ { transform: "translateX(0)" },
16
+ { transform: "translateX(100%)" }
17
+ ]
18
+ } : {
19
+ entering: [
20
+ { transform: "translateX(100%)" },
21
+ { transform: "translateX(0)" }
22
+ ]
28
23
  }, Rt = () => ({
29
24
  entering: [{ opacity: 0 }, { opacity: 1 }],
30
25
  leaving: [{ opacity: 1 }, { opacity: 0 }]
31
26
  }), bt = ({ direction: t }) => {
32
- const r = t === "back";
27
+ const o = t === "back";
33
28
  return {
34
- entering: r ? [
29
+ entering: o ? [
35
30
  { transform: "scale(0.98)", opacity: 0 },
36
31
  { transform: "scale(1)", opacity: 1 }
37
32
  ] : [
38
33
  { transform: "scale(1.04)", opacity: 0 },
39
34
  { transform: "scale(1)", opacity: 1 }
40
35
  ],
41
- leaving: r ? [
36
+ leaving: o ? [
42
37
  { transform: "scale(1)", opacity: 1 },
43
38
  { transform: "scale(1.04)", opacity: 0 }
44
39
  ] : [
@@ -52,26 +47,26 @@ const pt = ({ direction: t }) => {
52
47
  scale: bt,
53
48
  none: Et
54
49
  };
55
- function wt(t, r) {
56
- const n = r[t];
57
- return n || r[Y];
50
+ function wt(t, o) {
51
+ const n = o[t];
52
+ return n || o[Y];
58
53
  }
59
- function O(t, r, n) {
60
- if (!r || !t.animate || Number(n.duration) <= 0)
54
+ function O(t, o, n) {
55
+ if (!o || !t.animate || Number(n.duration) <= 0)
61
56
  return Promise.resolve();
62
- const u = t.animate(r, n);
57
+ const u = t.animate(o, n);
63
58
  return u.finished.then(() => u.cancel());
64
59
  }
65
- async function It(t, r) {
66
- const n = t(r), u = {
67
- duration: r.duration,
68
- easing: r.easing,
60
+ async function It(t, o) {
61
+ const n = t(o), u = {
62
+ duration: o.duration,
63
+ easing: o.easing,
69
64
  fill: "both",
70
65
  ...n.options
71
66
  };
72
67
  await Promise.all([
73
- O(r.enteringElement, n.entering, u),
74
- O(r.leavingElement, n.leaving, u)
68
+ O(o.enteringElement, n.entering, u),
69
+ O(o.leavingElement, n.leaving, u)
75
70
  ]);
76
71
  }
77
72
  const Z = Symbol("stack-router");
@@ -79,28 +74,28 @@ function St() {
79
74
  const t = window.history.state;
80
75
  return typeof (t == null ? void 0 : t.position) == "number" ? t.position : window.history.length;
81
76
  }
82
- function U(t, r) {
83
- return r || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
77
+ function X(t, o) {
78
+ return o || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
84
79
  }
85
80
  function At(t) {
86
- const r = ht(t), n = [], u = tt(), l = t.transitionDuration ?? 240, T = t.transitionEasing ?? kt, w = t.transition ?? Y, p = {
81
+ const o = ht(t), n = [], u = tt(), l = t.transitionDuration ?? 210, T = t.transitionEasing ?? yt, w = t.transition ?? Y, p = {
87
82
  ...Pt,
88
83
  ...t.transitions
89
84
  }, E = t.maxStackSize ?? 30;
90
- let f = -1, s, I = !1;
91
- const b = (c, a, i, d, y = !1, P = "stack") => {
92
- s = {
85
+ let f = -1, i, I = !1;
86
+ const b = (c, a, s, d, k = !1, P = "stack") => {
87
+ i = {
93
88
  action: c,
94
- direction: U(c, a),
89
+ direction: X(c, a),
95
90
  source: P,
96
- delta: i,
91
+ delta: s,
97
92
  transition: d == null ? void 0 : d.transition,
98
93
  duration: d == null ? void 0 : d.duration,
99
94
  easing: d == null ? void 0 : d.easing,
100
- resetRoot: y
95
+ resetRoot: k
101
96
  };
102
97
  }, C = (c, a) => {
103
- const i = (s == null ? void 0 : s.action) ?? "push", d = U(i, s == null ? void 0 : s.direction), y = u.value, P = i === "push" && d === "forward", ct = g(c);
98
+ const s = (i == null ? void 0 : i.action) ?? "push", d = X(s, i == null ? void 0 : i.direction), k = u.value, P = s === "push" && d === "forward", ct = g(c);
104
99
  return {
105
100
  id: q("route"),
106
101
  key: c.fullPath,
@@ -108,17 +103,17 @@ function At(t) {
108
103
  pathname: c.path,
109
104
  params: c.params,
110
105
  query: c.query,
111
- action: i,
106
+ action: s,
112
107
  direction: d,
113
- source: (s == null ? void 0 : s.source) ?? "stack",
108
+ source: (i == null ? void 0 : i.source) ?? "stack",
114
109
  entryDirection: d,
115
- lastPathname: (y == null ? void 0 : y.pathname) || (a.name ? a.path : void 0),
116
- pushedByRoute: P ? y == null ? void 0 : y.pathname : y == null ? void 0 : y.pushedByRoute,
110
+ lastPathname: (k == null ? void 0 : k.pathname) || (a.name ? a.path : void 0),
111
+ pushedByRoute: P ? k == null ? void 0 : k.pathname : k == null ? void 0 : k.pushedByRoute,
117
112
  position: St(),
118
- delta: s == null ? void 0 : s.delta,
119
- transition: (s == null ? void 0 : s.transition) ?? w,
120
- transitionDuration: (s == null ? void 0 : s.duration) ?? l,
121
- transitionEasing: (s == null ? void 0 : s.easing) ?? T,
113
+ delta: i == null ? void 0 : i.delta,
114
+ transition: (i == null ? void 0 : i.transition) ?? w,
115
+ transitionDuration: (i == null ? void 0 : i.duration) ?? l,
116
+ transitionEasing: (i == null ? void 0 : i.easing) ?? T,
122
117
  cache: ct
123
118
  };
124
119
  }, g = (c) => {
@@ -132,28 +127,28 @@ function At(t) {
132
127
  if (c.action === "pop") {
133
128
  let a = -1;
134
129
  if (c.direction === "forward" || (c.delta ?? 0) > 0) {
135
- for (let i = f + 1; i < n.length; i++)
136
- if (n[i].key === c.key) {
137
- a = i;
130
+ for (let s = f + 1; s < n.length; s++)
131
+ if (n[s].key === c.key) {
132
+ a = s;
138
133
  break;
139
134
  }
140
135
  } else
141
- for (let i = f - 1; i >= 0; i--)
142
- if (n[i].key === c.key) {
143
- a = i;
136
+ for (let s = f - 1; s >= 0; s--)
137
+ if (n[s].key === c.key) {
138
+ a = s;
144
139
  break;
145
140
  }
146
141
  if (a >= 0) {
147
- const i = n[a];
142
+ const s = n[a];
148
143
  n[a] = {
149
- ...i,
144
+ ...s,
150
145
  ...c,
151
- id: i.id,
146
+ id: s.id,
152
147
  source: c.source,
153
- entryDirection: i.entryDirection,
154
- transition: i.transition,
155
- transitionDuration: i.transitionDuration,
156
- transitionEasing: i.transitionEasing
148
+ entryDirection: s.entryDirection,
149
+ transition: s.transition,
150
+ transitionDuration: s.transitionDuration,
151
+ transitionEasing: s.transitionEasing
157
152
  }, f = a;
158
153
  } else
159
154
  n.push({
@@ -164,7 +159,7 @@ function At(t) {
164
159
  isStackFallback: !0
165
160
  }), f = n.length - 1;
166
161
  } else if (c.action === "replace") {
167
- if (s != null && s.resetRoot) {
162
+ if (i != null && i.resetRoot) {
168
163
  n.splice(0, n.length, c), f = 0, u.value = n[f];
169
164
  return;
170
165
  }
@@ -173,56 +168,56 @@ function At(t) {
173
168
  f < n.length - 1 && n.splice(f + 1), n.push(c), f = n.length - 1;
174
169
  x(), u.value = n[f];
175
170
  };
176
- t.history.listen((c, a, i) => {
177
- const d = "delta" in i ? i.delta : void 0, y = i.direction === "back" ? "back" : i.direction === "forward" ? "forward" : void 0;
178
- s ? (s.delta = d, s.direction = U(
179
- s.action,
180
- s.direction ?? y
171
+ t.history.listen((c, a, s) => {
172
+ const d = "delta" in s ? s.delta : void 0, k = s.direction === "back" ? "back" : s.direction === "forward" ? "forward" : void 0;
173
+ i ? (i.delta = d, i.direction = X(
174
+ i.action,
175
+ i.direction ?? k
181
176
  )) : b(
182
- i.type === "pop" ? "pop" : i.type,
183
- y,
177
+ s.type === "pop" ? "pop" : s.type,
178
+ k,
184
179
  d,
185
180
  void 0,
186
181
  !1,
187
182
  "external"
188
183
  );
189
- }), r.beforeEach((c) => !((s == null ? void 0 : s.action) === "pop" && I && !n.some((a) => a.fullPath === c.fullPath))), r.afterEach((c, a, i) => {
190
- if (i) {
191
- s = void 0;
184
+ }), o.beforeEach((c) => !((i == null ? void 0 : i.action) === "pop" && I && !n.some((a) => a.fullPath === c.fullPath))), o.afterEach((c, a, s) => {
185
+ if (s) {
186
+ i = void 0;
192
187
  return;
193
188
  }
194
- H(C(c, a)), s = void 0;
189
+ H(C(c, a)), i = void 0;
195
190
  });
196
- const V = r.push.bind(r), L = r.replace.bind(r), $ = r.back.bind(r), W = r.forward.bind(r), X = r.go.bind(r), A = (c, a) => (b(
191
+ const V = o.push.bind(o), L = o.replace.bind(o), $ = o.back.bind(o), W = o.forward.bind(o), K = o.go.bind(o), A = (c, a) => (b(
197
192
  "push",
198
193
  (a == null ? void 0 : a.direction) ?? "forward",
199
194
  void 0,
200
195
  a
201
- ), V(c)), K = (c, a) => (b(
196
+ ), V(c)), j = (c, a) => (b(
202
197
  "replace",
203
198
  (a == null ? void 0 : a.direction) ?? "root",
204
199
  void 0,
205
200
  a
206
201
  ), L(c)), e = (c, a) => {
207
- const i = r.resolve(c).fullPath;
202
+ const s = o.resolve(c).fullPath;
208
203
  let d = -1;
209
204
  for (let P = f; P >= 0; P--)
210
- if (n[P].fullPath === i) {
205
+ if (n[P].fullPath === s) {
211
206
  d = P;
212
207
  break;
213
208
  }
214
209
  if (d < 0) return !1;
215
- const y = d - f;
216
- return y === 0 || (b(
210
+ const k = d - f;
211
+ return k === 0 || (b(
217
212
  "pop",
218
213
  (a == null ? void 0 : a.direction) ?? "back",
219
- y,
214
+ k,
220
215
  a
221
- ), X(y)), !0;
222
- }, o = (c, a) => {
223
- const i = r.resolve(c).fullPath;
224
- if (f >= 0 && r.currentRoute.value.fullPath === i) {
225
- const d = n[f], y = {
216
+ ), K(k)), !0;
217
+ }, r = (c, a) => {
218
+ const s = o.resolve(c).fullPath;
219
+ if (f >= 0 && o.currentRoute.value.fullPath === s) {
220
+ const d = n[f], k = {
226
221
  ...d,
227
222
  id: q("route"),
228
223
  action: "replace",
@@ -236,7 +231,7 @@ function At(t) {
236
231
  cache: !0,
237
232
  isStackFallback: !1
238
233
  };
239
- return n.splice(0, n.length, y), f = 0, I = !0, u.value = y, Promise.resolve(void 0);
234
+ return n.splice(0, n.length, k), f = 0, I = !0, u.value = k, Promise.resolve(void 0);
240
235
  }
241
236
  return b(
242
237
  "replace",
@@ -249,8 +244,8 @@ function At(t) {
249
244
  b("pop", "back", -1), $();
250
245
  }, R = () => {
251
246
  b("pop", "forward", 1), W();
252
- }, m = r;
253
- m.push = A, m.replace = K, m.popTo = e, m.resetRoot = o, m.back = h, m.forward = R;
247
+ }, m = o;
248
+ m.push = A, m.replace = j, m.popTo = e, m.resetRoot = r, m.back = h, m.forward = R;
254
249
  const _ = {
255
250
  router: m,
256
251
  transitionDuration: l,
@@ -265,31 +260,31 @@ function At(t) {
265
260
  },
266
261
  canGoBack: (c = 1) => f - c >= 0,
267
262
  push: A,
268
- replace: K,
263
+ replace: j,
269
264
  popTo: e,
270
- resetRoot: o,
265
+ resetRoot: r,
271
266
  back: h,
272
267
  forward: R
273
- }, j = r.install.bind(r);
274
- return r.install = (c) => {
275
- c.provide(Z, _), j(c);
268
+ }, z = o.install.bind(o);
269
+ return o.install = (c) => {
270
+ c.provide(Z, _), z(c);
276
271
  }, m;
277
272
  }
278
- const et = "onPageWillEnter", J = "onPageDidEnter", rt = "onPageWillLeave", ot = "onPageDidLeave";
279
- function Dt(t, r, n) {
273
+ const et = "onPageWillEnter", J = "onPageDidEnter", ot = "onPageWillLeave", rt = "onPageDidLeave";
274
+ function Dt(t, o, n) {
280
275
  if (!n)
281
276
  throw new Error(`${t} must be called inside setup().`);
282
277
  const u = n.proxy, l = u[t] ?? [];
283
278
  l.push(() => {
284
- n.isUnmounted || r();
279
+ n.isUnmounted || o();
285
280
  }), u[t] = l, n.exposed && (n.exposed[t] = l);
286
281
  }
287
282
  function G(t) {
288
- return (r, n = st()) => Dt(t, r, n);
283
+ return (o, n = it()) => Dt(t, o, n);
289
284
  }
290
- const _t = G(et), Ft = G(J), Bt = G(rt), Gt = G(ot);
285
+ const _t = G(et), Bt = G(J), Ft = G(ot), Gt = G(rt);
291
286
  function Ct() {
292
- const t = F(Z);
287
+ const t = B(Z);
293
288
  if (!t)
294
289
  throw new Error("useStackRouter must be used after createStackRouter().");
295
290
  return {
@@ -304,15 +299,15 @@ function Ct() {
304
299
  };
305
300
  }
306
301
  function nt() {
307
- const t = F(Z);
302
+ const t = B(Z);
308
303
  if (!t)
309
304
  throw new Error("RouterOutlet must be used with createStackRouter().");
310
305
  return t;
311
306
  }
312
- function S(t, r) {
307
+ function S(t, o) {
313
308
  const n = t.value;
314
309
  if (!n) return;
315
- const u = n[r];
310
+ const u = n[o];
316
311
  Array.isArray(u) ? u.forEach((l) => l()) : typeof u == "function" && u.call(n);
317
312
  }
318
313
  function D(t) {
@@ -322,78 +317,78 @@ function M(t) {
322
317
  t.classList.add("rs-page-hidden"), t.setAttribute("aria-hidden", "true");
323
318
  }
324
319
  function at(t) {
325
- var r;
326
- return (r = t.components) == null ? void 0 : r.default;
320
+ var o;
321
+ return (o = t.components) == null ? void 0 : o.default;
327
322
  }
328
323
  function Tt(t) {
329
- const r = at(t);
330
- return r !== void 0 && typeof r == "object" && "name" in r && r.name === "RouterView";
324
+ const o = at(t);
325
+ return o !== void 0 && typeof o == "object" && "name" in o && o.name === "RouterView";
331
326
  }
332
327
  const Ht = Q({
333
328
  name: "RouterOutlet",
334
329
  setup() {
335
- const t = nt(), r = mt(), n = F(yt), u = F(v, void 0), l = z(() => {
330
+ const t = nt(), o = mt(), n = B(kt), u = B(v, void 0), l = U(() => {
336
331
  const e = u == null ? void 0 : u.value;
337
332
  if (!e) return 0;
338
- const o = r.matched.findIndex(
333
+ const r = o.matched.findIndex(
339
334
  (h) => h === e
340
335
  );
341
- return o >= 0 ? o + 1 : 0;
342
- }), T = z(() => r.matched[l.value]), w = z(() => {
343
- for (let e = l.value; e < r.matched.length; e++) {
344
- const o = r.matched[e];
345
- if (!Tt(o))
346
- return o;
336
+ return r >= 0 ? r + 1 : 0;
337
+ }), T = U(() => o.matched[l.value]), w = U(() => {
338
+ for (let e = l.value; e < o.matched.length; e++) {
339
+ const r = o.matched[e];
340
+ if (!Tt(r))
341
+ return r;
347
342
  }
348
343
  return T.value;
349
- }), p = tt([]), E = B("");
344
+ }), p = tt([]), E = F("");
350
345
  let f = 0;
351
- it(v, w);
352
- const s = (e) => p.value.find((o) => o.key === e), I = (e) => {
353
- p.value.forEach((o) => {
354
- o.pageElement && (o === e ? D(o.pageElement) : M(o.pageElement));
346
+ st(v, w);
347
+ const i = (e) => p.value.find((r) => r.key === e), I = (e) => {
348
+ p.value.forEach((r) => {
349
+ r.pageElement && (r === e ? D(r.pageElement) : M(r.pageElement));
355
350
  });
356
351
  }, b = (e) => {
357
- const o = p.value.findIndex((h) => h === e);
358
- o >= 0 && (p.value = p.value.slice(0, o + 1));
352
+ const r = p.value.findIndex((h) => h === e);
353
+ r >= 0 && (p.value = p.value.slice(0, r + 1));
359
354
  }, C = (e) => {
360
- p.value = p.value.filter((o) => o !== e);
355
+ p.value = p.value.filter((r) => r !== e);
361
356
  }, g = (e) => {
362
- const o = new Set(
357
+ const r = new Set(
363
358
  t.history.map((h) => h.key)
364
359
  );
365
360
  p.value = p.value.filter(
366
- (h) => h === e || h.routeInfo.cache && o.has(h.key)
361
+ (h) => h === e || h.routeInfo.cache && r.has(h.key)
367
362
  );
368
363
  }, x = (e) => {
369
364
  var h;
370
- const o = e.props.default;
371
- return o ? o === !0 ? ((h = t.current.value) == null ? void 0 : h.params) ?? {} : typeof o == "function" ? o(n) : o : {};
372
- }, H = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transition ?? e.routeInfo.transition ?? t.transition : e.routeInfo.transition ?? t.transition, V = (e, o) => !(e.routeInfo.isStackFallback || e.routeInfo.direction === "none" || e.routeInfo.direction === "root" || e.routeInfo.action === "pop" && (o.routeInfo.entryDirection === "none" || o.routeInfo.entryDirection === "root" || o.routeInfo.transition === "none")), L = (e, o) => {
365
+ const r = e.props.default;
366
+ return r ? r === !0 ? ((h = t.current.value) == null ? void 0 : h.params) ?? {} : typeof r == "function" ? r(n) : r : {};
367
+ }, H = (e, r) => e.routeInfo.action === "pop" ? r.routeInfo.transition ?? e.routeInfo.transition ?? t.transition : e.routeInfo.transition ?? t.transition, V = (e, r) => !(e.routeInfo.isStackFallback || e.routeInfo.direction === "none" || e.routeInfo.direction === "root" || e.routeInfo.action === "pop" && (r.routeInfo.entryDirection === "none" || r.routeInfo.entryDirection === "root" || r.routeInfo.transition === "none")), L = (e, r) => {
373
368
  var R;
374
- const h = V(e, o);
369
+ const h = V(e, r);
375
370
  return ((R = t.shouldTransition) == null ? void 0 : R.call(t, {
376
371
  action: e.routeInfo.action,
377
372
  direction: e.routeInfo.direction,
378
373
  source: e.routeInfo.source,
379
374
  entering: e.routeInfo,
380
- leaving: o.routeInfo,
375
+ leaving: r.routeInfo,
381
376
  defaultResult: h
382
377
  })) ?? h;
383
- }, $ = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionDuration ?? e.routeInfo.transitionDuration ?? t.transitionDuration : e.routeInfo.transitionDuration ?? t.transitionDuration, W = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionEasing ?? e.routeInfo.transitionEasing ?? t.transitionEasing : e.routeInfo.transitionEasing ?? t.transitionEasing, X = async (e, o) => {
378
+ }, $ = (e, r) => e.routeInfo.action === "pop" ? r.routeInfo.transitionDuration ?? e.routeInfo.transitionDuration ?? t.transitionDuration : e.routeInfo.transitionDuration ?? t.transitionDuration, W = (e, r) => e.routeInfo.action === "pop" ? r.routeInfo.transitionEasing ?? e.routeInfo.transitionEasing ?? t.transitionEasing : e.routeInfo.transitionEasing ?? t.transitionEasing, K = async (e, r) => {
384
379
  const h = ++f;
385
380
  await ft();
386
381
  const R = e.pageElement;
387
382
  if (!R) return;
388
- if (S(e.componentRef, et), !o || o === e || !o.pageElement) {
383
+ if (S(e.componentRef, et), !r || r === e || !r.pageElement) {
389
384
  D(R), S(e.componentRef, J), g(e), I(e);
390
385
  return;
391
386
  }
392
- const m = o.pageElement, _ = L(e, o), j = _ ? H(e, o) : "none", c = _ ? $(e, o) : 0, a = W(e, o), i = wt(
393
- j || Y,
387
+ const m = r.pageElement, _ = L(e, r), z = _ ? H(e, r) : "none", c = _ ? $(e, r) : 0, a = W(e, r), s = wt(
388
+ z || Y,
394
389
  t.transitions
395
390
  );
396
- S(o.componentRef, rt), D(R), D(m), await It(i, {
391
+ S(r.componentRef, ot), D(R), D(m), await It(s, {
397
392
  direction: e.routeInfo.direction,
398
393
  action: e.routeInfo.action,
399
394
  routeInfo: e.routeInfo,
@@ -401,24 +396,24 @@ const Ht = Q({
401
396
  leavingElement: m,
402
397
  duration: c,
403
398
  easing: a
404
- }), h === f && (M(m), S(o.componentRef, ot), S(e.componentRef, J), e.routeInfo.action === "pop" ? b(e) : e.routeInfo.action === "replace" && C(o), g(e), I(e));
399
+ }), h === f && (M(m), S(r.componentRef, rt), S(e.componentRef, J), e.routeInfo.action === "pop" ? b(e) : e.routeInfo.action === "replace" && C(r), g(e), I(e));
405
400
  }, A = async () => {
406
- const e = w.value, o = t.current.value;
407
- if (!e || !o) return;
401
+ const e = w.value, r = t.current.value;
402
+ if (!e || !r) return;
408
403
  const h = at(e);
409
404
  if (!h) return;
410
- const R = s(E.value);
411
- let m = s(o.key);
412
- m ? (m.routeInfo = o, m.matchedRoute = e, m.component = h, m.props = x(e), m.mounted = !0) : (m = {
405
+ const R = i(E.value);
406
+ let m = i(r.key);
407
+ m ? (m.routeInfo = r, m.matchedRoute = e, m.component = h, m.props = x(e), m.mounted = !0) : (m = {
413
408
  id: q("view"),
414
- key: o.key,
415
- routeInfo: o,
409
+ key: r.key,
410
+ routeInfo: r,
416
411
  matchedRoute: e,
417
412
  component: h,
418
413
  props: x(e),
419
- componentRef: B(),
414
+ componentRef: F(),
420
415
  mounted: !0
421
- }, p.value = [...p.value, m]), E.value = m.key, await X(m, R);
416
+ }, p.value = [...p.value, m]), E.value = m.key, await K(m, R);
422
417
  };
423
418
  return ut(
424
419
  () => {
@@ -434,21 +429,21 @@ const Ht = Q({
434
429
  }), {
435
430
  injectedRoute: n,
436
431
  viewItems: p,
437
- registerStackPage: (e, o) => {
438
- e.pageElement = o, e.key === E.value ? D(o) : M(o);
432
+ registerStackPage: (e, r) => {
433
+ e.pageElement = r, e.key === E.value ? D(r) : M(r);
439
434
  }
440
435
  };
441
436
  },
442
437
  render() {
443
- return k(
438
+ return y(
444
439
  "div",
445
440
  { class: "rs-outlet" },
446
441
  this.viewItems.filter((t) => t.mounted).map(
447
- (t) => k(t.component, {
442
+ (t) => y(t.component, {
448
443
  key: t.id,
449
444
  ref: t.componentRef,
450
445
  ...t.props,
451
- registerStackPage: (r) => this.registerStackPage(t, r)
446
+ registerStackPage: (o) => this.registerStackPage(t, o)
452
447
  })
453
448
  )
454
449
  );
@@ -461,19 +456,19 @@ const Ht = Q({
461
456
  default: void 0
462
457
  }
463
458
  },
464
- setup(t, { attrs: r, slots: n }) {
465
- const u = B();
459
+ setup(t, { attrs: o, slots: n }) {
460
+ const u = F();
466
461
  return dt(() => {
467
462
  var l;
468
463
  u.value && ((l = t.registerStackPage) == null || l.call(t, u.value));
469
464
  }), () => {
470
465
  var l;
471
- return k(
466
+ return y(
472
467
  "section",
473
468
  {
474
- ...r,
469
+ ...o,
475
470
  ref: u,
476
- class: ["rs-page", r.class]
471
+ class: ["rs-page", o.class]
477
472
  },
478
473
  (l = n.default) == null ? void 0 : l.call(n)
479
474
  );
@@ -488,11 +483,11 @@ const Ht = Q({
488
483
  }
489
484
  },
490
485
  setup(t) {
491
- const r = nt(), n = B(t.initialOpen);
486
+ const o = nt(), n = F(t.initialOpen);
492
487
  return () => {
493
- const u = r.current.value;
494
- return k("aside", { class: "rs-debug-panel" }, [
495
- k(
488
+ const u = o.current.value;
489
+ return y("aside", { class: "rs-debug-panel" }, [
490
+ y(
496
491
  "button",
497
492
  {
498
493
  class: "rs-debug-toggle",
@@ -503,21 +498,21 @@ const Ht = Q({
503
498
  },
504
499
  n.value ? "Stack x" : "Stack"
505
500
  ),
506
- n.value ? k("section", { class: "rs-debug-body" }, [
507
- k("header", [
508
- k("strong", "Router Stack"),
509
- k("span", `${r.history.length} pages`)
501
+ n.value ? y("section", { class: "rs-debug-body" }, [
502
+ y("header", [
503
+ y("strong", "Router Stack"),
504
+ y("span", `${o.history.length} pages`)
510
505
  ]),
511
- k("dl", [
512
- k("dt", "current"),
513
- k("dd", (u == null ? void 0 : u.fullPath) ?? "-"),
514
- k("dt", "canGoBack"),
515
- k("dd", String(r.canGoBack()))
506
+ y("dl", [
507
+ y("dt", "current"),
508
+ y("dd", (u == null ? void 0 : u.fullPath) ?? "-"),
509
+ y("dt", "canGoBack"),
510
+ y("dd", String(o.canGoBack()))
516
511
  ]),
517
- k(
512
+ y(
518
513
  "ol",
519
- r.history.map(
520
- (l) => k(
514
+ o.history.map(
515
+ (l) => y(
521
516
  "li",
522
517
  {
523
518
  key: l.id,
@@ -527,8 +522,8 @@ const Ht = Q({
527
522
  }
528
523
  },
529
524
  [
530
- k("code", l.fullPath),
531
- k("span", [
525
+ y("code", l.fullPath),
526
+ y("span", [
532
527
  `${l.action}/${l.direction}`,
533
528
  ` source:${l.source}`,
534
529
  ` entry:${l.entryDirection}`,
@@ -545,20 +540,20 @@ const Ht = Q({
545
540
  }
546
541
  });
547
542
  export {
548
- Kt as RouterLink,
543
+ jt as RouterLink,
549
544
  Ht as RouterOutlet,
550
545
  Vt as RouterPage,
551
- jt as RouterView,
546
+ zt as RouterView,
552
547
  $t as StackRouterDebugPanel,
553
- zt as createMemoryHistory,
548
+ Ut as createMemoryHistory,
554
549
  At as createStackRouter,
555
- Ut as createWebHashHistory,
550
+ Xt as createWebHashHistory,
556
551
  Mt as createWebHistory,
557
552
  Lt as defineStackTransition,
558
- Ft as onPageDidEnter,
553
+ Bt as onPageDidEnter,
559
554
  Gt as onPageDidLeave,
560
555
  _t as onPageWillEnter,
561
- Bt as onPageWillLeave,
556
+ Ft as onPageWillLeave,
562
557
  Z as stackRouterKey,
563
558
  qt as useRoute,
564
559
  Jt as useRouter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/vue-router-stack",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Page stack, caching, transitions, and lifecycle utilities built on vue-router.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -32,13 +32,17 @@
32
32
  "keep-alive"
33
33
  ],
34
34
  "scripts": {
35
- "dev": "vite --config demo/vite.config.ts --port 2244 --host",
35
+ "dev": "vite --config demo/vite.config.ts --port 2389 --host",
36
36
  "build": "pnpm run type-check && pnpm run build:lib && pnpm run build:demo",
37
37
  "build:lib": "vite build && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.build.json",
38
38
  "build:demo": "vite build --config demo/vite.config.ts",
39
39
  "type-check": "vue-tsc --noEmit -p tsconfig.app.json",
40
40
  "test": "vitest run"
41
41
  },
42
+ "publishConfig": {
43
+ "access": "public",
44
+ "registry": "https://registry.npmjs.org/"
45
+ },
42
46
  "peerDependencies": {
43
47
  "vue": "^3.3.0",
44
48
  "vue-router": "^4.2.0"