@lazycatcloud/vue-router-stack 0.0.2 → 0.0.3

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.
@@ -3,7 +3,7 @@ import type { RouteLocationMatched } from "vue-router";
3
3
  import type { RouteInfo } from "../router/types";
4
4
  interface ViewItem {
5
5
  id: string;
6
- key: string;
6
+ stackEntryId: string;
7
7
  routeInfo: RouteInfo;
8
8
  matchedRoute: RouteLocationMatched;
9
9
  component: Component;
@@ -1 +1 @@
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
+ "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 C=Symbol("stack-router");function de(){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 fe(e){const r=b.createRouter(e),n=[],l=i.shallowRef(),d=e.transitionDuration??210,T=e.transitionEasing??re,S=e.transition??v,R={...se,...e.transitions},E=e.maxStackSize??30;let h=-1,s,g=!1;const P=(c,a,u,f,y=!1,w="stack")=>{s={action:c,direction:q(c,a),source:w,delta:u,transition:f==null?void 0:f.transition,duration:f==null?void 0:f.duration,easing:f==null?void 0:f.easing,resetRoot:y}},W=(c,a)=>{const u=(s==null?void 0:s.action)??"push",f=q(u,s==null?void 0:s.direction),y=l.value,w=u==="push"&&f==="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:f,source:(s==null?void 0:s.source)??"stack",entryDirection:f,lastPathname:(y==null?void 0:y.pathname)||(a.name?a.path:void 0),pushedByRoute:w?y==null?void 0:y.pathname:y==null?void 0:y.pushedByRoute,position:de(),delta:s==null?void 0:s.delta,transition:(s==null?void 0:s.transition)??S,transitionDuration:(s==null?void 0:s.duration)??d,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),h=Math.max(0,h-c)},G=c=>{if(c.action==="pop"){let a=-1;if(c.direction==="forward"||(c.delta??0)>0){for(let u=h+1;u<n.length;u++)if(n[u].key===c.key){a=u;break}}else for(let u=h-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},h=a}else n.push({...c,direction:"none",entryDirection:"none",transition:"none",isStackFallback:!0}),h=n.length-1}else if(c.action==="replace"){if(s!=null&&s.resetRoot){n.splice(0,n.length,c),h=0,l.value=n[h];return}h>=0?n[h]=c:(n.push(c),h=0)}else h<n.length-1&&n.splice(h+1),n.push(c),h=n.length-1;x(),l.value=n[h]};e.history.listen((c,a,u)=>{const f="delta"in u?u.delta:void 0,y=u.direction==="back"?"back":u.direction==="forward"?"forward":void 0;s?(s.delta=f,s.direction=q(s.action,s.direction??y)):P(u.type==="pop"?"pop":u.type,y,f,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}G(W(c,a)),s=void 0});const A=r.push.bind(r),j=r.replace.bind(r),V=r.back.bind(r),$=r.forward.bind(r),K=r.go.bind(r),_=(c,a)=>(P("push",(a==null?void 0:a.direction)??"forward",void 0,a),A(c)),H=(c,a)=>(P("replace",(a==null?void 0:a.direction)??"root",void 0,a),j(c)),M=(c,a)=>{const u=r.resolve(c).fullPath;let f=-1;for(let w=h;w>=0;w--)if(n[w].fullPath===u){f=w;break}if(f<0)return!1;const y=f-h;return y===0||(P("pop",(a==null?void 0:a.direction)??"back",y,a),K(y)),!0},t=(c,a)=>{const u=r.resolve(c).fullPath;if(h>=0&&r.currentRoute.value.fullPath===u){const f=n[h],y={...f,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)??f.transition,transitionDuration:(a==null?void 0:a.duration)??f.transitionDuration,transitionEasing:(a==null?void 0:a.easing)??f.transitionEasing,cache:!0,isStackFallback:!1};return n.splice(0,n.length,y),h=0,g=!0,l.value=y,Promise.resolve(void 0)}return P("replace",(a==null?void 0:a.direction)??"root",void 0,a,!0),g=!0,j(c)},o=()=>{P("pop","back",-1),V()},m=()=>{P("pop","forward",1),$()},k=r;k.push=_,k.replace=H,k.popTo=M,k.resetRoot=t,k.back=o,k.forward=m;const p={router:k,transitionDuration:d,transitionEasing:T,transition:S,transitions:R,maxStackSize:E,shouldTransition:e.shouldTransition,current:l,get history(){return n},canGoBack:(c=1)=>h-c>=0,push:_,replace:H,popTo:M,resetRoot:t,back:o,forward:m},B=r.install.bind(r);return r.install=c=>{c.provide(C,p),B(c)},k}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,d=l[e]??[];d.push(()=>{n.isUnmounted||r()}),l[e]=d,n.exposed&&(n.exposed[e]=d)}function F(e){return(r,n=i.getCurrentInstance())=>he(e,r,n)}const me=F(Y),ye=F(X),ke=F(Z),pe=F(N);function Re(){const e=i.inject(C);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(C);if(!e)throw new Error("RouterOutlet must be used with createStackRouter().");return e}function I(e,r){const n=e.value;if(!n)return;const l=n[r];Array.isArray(l)?l.forEach(d=>d()):typeof l=="function"&&l.call(n)}function D(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),d=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[d.value]),S=i.computed(()=>{for(let t=d.value;t<r.matched.length;t++){const o=r.matched[t];if(!be(o))return o}return T.value}),R=i.shallowRef([]),E=i.ref("");let h=0;i.provide(b.matchedRouteKey,S);const s=t=>R.value.find(o=>o.stackEntryId===t),g=t=>{R.value.forEach(o=>{o.pageElement&&(o===t?D(o.pageElement):z(o.pageElement))})},P=t=>{const o=R.value.findIndex(m=>m===t);o>=0&&(R.value=R.value.slice(0,o+1))},W=t=>{R.value=R.value.filter(o=>o!==t)},L=t=>{const o=new Set(e.history.map(m=>m.id));R.value=R.value.filter(m=>m===t||m.routeInfo.cache&&o.has(m.stackEntryId))},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:{}},G=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transition??t.routeInfo.transition??e.transition:t.routeInfo.transition??e.transition,A=t=>t.entryDirection==="none"||t.entryDirection==="root"||t.transition==="none",j=(t,o)=>!(t.routeInfo.isStackFallback||t.routeInfo.direction==="none"||t.routeInfo.direction==="root"||t.routeInfo.action==="pop"&&(A(t.routeInfo)||A(o.routeInfo))),V=(t,o)=>{var k;const m=j(t,o);return((k=e.shouldTransition)==null?void 0:k.call(e,{action:t.routeInfo.action,direction:t.routeInfo.direction,source:t.routeInfo.source,entering:t.routeInfo,leaving:o.routeInfo,defaultResult:m}))??m},$=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionDuration??t.routeInfo.transitionDuration??e.transitionDuration:t.routeInfo.transitionDuration??e.transitionDuration,K=(t,o)=>t.routeInfo.action==="pop"?o.routeInfo.transitionEasing??t.routeInfo.transitionEasing??e.transitionEasing:t.routeInfo.transitionEasing??e.transitionEasing,_=async(t,o)=>{const m=++h;await i.nextTick();const k=t.pageElement;if(!k)return;if(I(t.componentRef,Y),!o||o===t||!o.pageElement){D(k),I(t.componentRef,X),L(t),g(t);return}const p=o.pageElement,B=V(t,o),c=B?G(t,o):"none",a=B?$(t,o):0,u=K(t,o),f=ue(c||v,e.transitions);I(o.componentRef,Z),D(k),D(p),await le(f,{direction:t.routeInfo.direction,action:t.routeInfo.action,routeInfo:t.routeInfo,enteringElement:k,leavingElement:p,duration:a,easing:u}),m===h&&(z(p),I(o.componentRef,N),I(t.componentRef,X),t.routeInfo.action==="pop"?P(t):t.routeInfo.action==="replace"&&W(o),L(t),g(t))},H=async()=>{const t=S.value,o=e.current.value;if(!t||!o)return;const m=ee(t);if(!m)return;const k=s(E.value);let p=s(o.id);p?(p.routeInfo=o,p.matchedRoute=t,p.component=m,p.props=x(t),p.mounted=!0):(p={id:U("view"),stackEntryId:o.id,routeInfo:o,matchedRoute:t,component:m,props:x(t),componentRef:i.ref(),mounted:!0},R.value=[...R.value,p]),E.value=p.stackEntryId,await _(p,k)};return i.watch(()=>{var t;return[(t=e.current.value)==null?void 0:t.id,S.value]},()=>{H()},{immediate:!0}),i.onUnmounted(()=>{h++,R.value=[]}),{injectedRoute:n,viewItems:R,registerStackPage:(t,o)=>{t.pageElement=o,t.stackEntryId===E.value?D(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 d;l.value&&((d=e.registerStackPage)==null||d.call(e,l.value))}),()=>{var d;return i.h("section",{...r,ref:l,class:["rs-page",r.class]},(d=n.default)==null?void 0:d.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(d=>i.h("li",{key:d.id,class:{"rs-debug-active":d.id===(l==null?void 0:l.id),"rs-debug-no-cache":!d.cache}},[i.h("code",d.fullPath),i.h("span",[`${d.action}/${d.direction}`,` source:${d.source}`,` entry:${d.entryDirection}`,` cache:${d.cache?"yes":"no"}`,` transition:${d.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=fe;exports.defineStackTransition=oe;exports.onPageDidEnter=ye;exports.onPageDidLeave=pe;exports.onPageWillEnter=me;exports.onPageWillLeave=ke;exports.stackRouterKey=C;exports.useStackRouter=Re;
@@ -1,10 +1,10 @@
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";
1
+ import { shallowRef as tt, getCurrentInstance as it, inject as G, defineComponent as Q, h as y, computed as U, ref as C, provide as st, watch as ut, onUnmounted as lt, nextTick as dt, onMounted as ft } from "vue";
2
2
  import { createRouter as ht, useRoute as mt, routeLocationKey as kt, matchedRouteKey as v } from "vue-router";
3
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 o = (N[t] ?? 0) + 1;
7
- return N[t] = o, `${t}-${o}`;
6
+ const r = (N[t] ?? 0) + 1;
7
+ return N[t] = r, `${t}-${r}`;
8
8
  }
9
9
  const Y = "slide", yt = "cubic-bezier(0.3, 0, 0.66, 1)";
10
10
  function Lt(t) {
@@ -23,17 +23,17 @@ const pt = ({ direction: t }) => t === "back" ? {
23
23
  }, Rt = () => ({
24
24
  entering: [{ opacity: 0 }, { opacity: 1 }],
25
25
  leaving: [{ opacity: 1 }, { opacity: 0 }]
26
- }), bt = ({ direction: t }) => {
27
- const o = t === "back";
26
+ }), Et = ({ direction: t }) => {
27
+ const r = t === "back";
28
28
  return {
29
- entering: o ? [
29
+ entering: r ? [
30
30
  { transform: "scale(0.98)", opacity: 0 },
31
31
  { transform: "scale(1)", opacity: 1 }
32
32
  ] : [
33
33
  { transform: "scale(1.04)", opacity: 0 },
34
34
  { transform: "scale(1)", opacity: 1 }
35
35
  ],
36
- leaving: o ? [
36
+ leaving: r ? [
37
37
  { transform: "scale(1)", opacity: 1 },
38
38
  { transform: "scale(1.04)", opacity: 0 }
39
39
  ] : [
@@ -41,32 +41,32 @@ const pt = ({ direction: t }) => t === "back" ? {
41
41
  { transform: "scale(0.98)", opacity: 0 }
42
42
  ]
43
43
  };
44
- }, Et = () => ({}), Pt = {
44
+ }, bt = () => ({}), Pt = {
45
45
  slide: pt,
46
46
  fade: Rt,
47
- scale: bt,
48
- none: Et
47
+ scale: Et,
48
+ none: bt
49
49
  };
50
- function wt(t, o) {
51
- const n = o[t];
52
- return n || o[Y];
50
+ function wt(t, r) {
51
+ const n = r[t];
52
+ return n || r[Y];
53
53
  }
54
- function O(t, o, n) {
55
- if (!o || !t.animate || Number(n.duration) <= 0)
54
+ function O(t, r, n) {
55
+ if (!r || !t.animate || Number(n.duration) <= 0)
56
56
  return Promise.resolve();
57
- const u = t.animate(o, n);
57
+ const u = t.animate(r, n);
58
58
  return u.finished.then(() => u.cancel());
59
59
  }
60
- async function It(t, o) {
61
- const n = t(o), u = {
62
- duration: o.duration,
63
- easing: o.easing,
60
+ async function It(t, r) {
61
+ const n = t(r), u = {
62
+ duration: r.duration,
63
+ easing: r.easing,
64
64
  fill: "both",
65
65
  ...n.options
66
66
  };
67
67
  await Promise.all([
68
- O(o.enteringElement, n.entering, u),
69
- O(o.leavingElement, n.leaving, u)
68
+ O(r.enteringElement, n.entering, u),
69
+ O(r.leavingElement, n.leaving, u)
70
70
  ]);
71
71
  }
72
72
  const Z = Symbol("stack-router");
@@ -74,16 +74,16 @@ function St() {
74
74
  const t = window.history.state;
75
75
  return typeof (t == null ? void 0 : t.position) == "number" ? t.position : window.history.length;
76
76
  }
77
- function X(t, o) {
78
- return o || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
77
+ function X(t, r) {
78
+ return r || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
79
79
  }
80
80
  function At(t) {
81
- const o = ht(t), n = [], u = tt(), l = t.transitionDuration ?? 210, T = t.transitionEasing ?? yt, w = t.transition ?? Y, p = {
81
+ const r = ht(t), n = [], u = tt(), l = t.transitionDuration ?? 210, T = t.transitionEasing ?? yt, w = t.transition ?? Y, R = {
82
82
  ...Pt,
83
83
  ...t.transitions
84
- }, E = t.maxStackSize ?? 30;
84
+ }, b = t.maxStackSize ?? 30;
85
85
  let f = -1, i, I = !1;
86
- const b = (c, a, s, d, k = !1, P = "stack") => {
86
+ const E = (c, a, s, d, m = !1, P = "stack") => {
87
87
  i = {
88
88
  action: c,
89
89
  direction: X(c, a),
@@ -92,10 +92,10 @@ function At(t) {
92
92
  transition: d == null ? void 0 : d.transition,
93
93
  duration: d == null ? void 0 : d.duration,
94
94
  easing: d == null ? void 0 : d.easing,
95
- resetRoot: k
95
+ resetRoot: m
96
96
  };
97
- }, C = (c, a) => {
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);
97
+ }, V = (c, a) => {
98
+ const s = (i == null ? void 0 : i.action) ?? "push", d = X(s, i == null ? void 0 : i.direction), m = u.value, P = s === "push" && d === "forward", ct = g(c);
99
99
  return {
100
100
  id: q("route"),
101
101
  key: c.fullPath,
@@ -107,8 +107,8 @@ function At(t) {
107
107
  direction: d,
108
108
  source: (i == null ? void 0 : i.source) ?? "stack",
109
109
  entryDirection: d,
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,
110
+ lastPathname: (m == null ? void 0 : m.pathname) || (a.name ? a.path : void 0),
111
+ pushedByRoute: P ? m == null ? void 0 : m.pathname : m == null ? void 0 : m.pushedByRoute,
112
112
  position: St(),
113
113
  delta: i == null ? void 0 : i.delta,
114
114
  transition: (i == null ? void 0 : i.transition) ?? w,
@@ -120,10 +120,10 @@ function At(t) {
120
120
  const a = c.meta.stack;
121
121
  return c.meta.stackCache !== !1 && (a == null ? void 0 : a.cache) !== !1;
122
122
  }, x = () => {
123
- if (E <= 0 || n.length <= E) return;
124
- const c = n.length - E;
123
+ if (b <= 0 || n.length <= b) return;
124
+ const c = n.length - b;
125
125
  n.splice(0, c), f = Math.max(0, f - c);
126
- }, H = (c) => {
126
+ }, $ = (c) => {
127
127
  if (c.action === "pop") {
128
128
  let a = -1;
129
129
  if (c.direction === "forward" || (c.delta ?? 0) > 0) {
@@ -169,37 +169,37 @@ function At(t) {
169
169
  x(), u.value = n[f];
170
170
  };
171
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;
172
+ const d = "delta" in s ? s.delta : void 0, m = s.direction === "back" ? "back" : s.direction === "forward" ? "forward" : void 0;
173
173
  i ? (i.delta = d, i.direction = X(
174
174
  i.action,
175
- i.direction ?? k
176
- )) : b(
175
+ i.direction ?? m
176
+ )) : E(
177
177
  s.type === "pop" ? "pop" : s.type,
178
- k,
178
+ m,
179
179
  d,
180
180
  void 0,
181
181
  !1,
182
182
  "external"
183
183
  );
184
- }), o.beforeEach((c) => !((i == null ? void 0 : i.action) === "pop" && I && !n.some((a) => a.fullPath === c.fullPath))), o.afterEach((c, a, s) => {
184
+ }), r.beforeEach((c) => !((i == null ? void 0 : i.action) === "pop" && I && !n.some((a) => a.fullPath === c.fullPath))), r.afterEach((c, a, s) => {
185
185
  if (s) {
186
186
  i = void 0;
187
187
  return;
188
188
  }
189
- H(C(c, a)), i = void 0;
189
+ $(V(c, a)), i = void 0;
190
190
  });
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(
191
+ const L = r.push.bind(r), A = r.replace.bind(r), W = r.back.bind(r), K = r.forward.bind(r), j = r.go.bind(r), _ = (c, a) => (E(
192
192
  "push",
193
193
  (a == null ? void 0 : a.direction) ?? "forward",
194
194
  void 0,
195
195
  a
196
- ), V(c)), j = (c, a) => (b(
196
+ ), L(c)), B = (c, a) => (E(
197
197
  "replace",
198
198
  (a == null ? void 0 : a.direction) ?? "root",
199
199
  void 0,
200
200
  a
201
- ), L(c)), e = (c, a) => {
202
- const s = o.resolve(c).fullPath;
201
+ ), A(c)), z = (c, a) => {
202
+ const s = r.resolve(c).fullPath;
203
203
  let d = -1;
204
204
  for (let P = f; P >= 0; P--)
205
205
  if (n[P].fullPath === s) {
@@ -207,17 +207,17 @@ function At(t) {
207
207
  break;
208
208
  }
209
209
  if (d < 0) return !1;
210
- const k = d - f;
211
- return k === 0 || (b(
210
+ const m = d - f;
211
+ return m === 0 || (E(
212
212
  "pop",
213
213
  (a == null ? void 0 : a.direction) ?? "back",
214
- k,
214
+ m,
215
215
  a
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 = {
216
+ ), j(m)), !0;
217
+ }, e = (c, a) => {
218
+ const s = r.resolve(c).fullPath;
219
+ if (f >= 0 && r.currentRoute.value.fullPath === s) {
220
+ const d = n[f], m = {
221
221
  ...d,
222
222
  id: q("route"),
223
223
  action: "replace",
@@ -231,60 +231,60 @@ function At(t) {
231
231
  cache: !0,
232
232
  isStackFallback: !1
233
233
  };
234
- return n.splice(0, n.length, k), f = 0, I = !0, u.value = k, Promise.resolve(void 0);
234
+ return n.splice(0, n.length, m), f = 0, I = !0, u.value = m, Promise.resolve(void 0);
235
235
  }
236
- return b(
236
+ return E(
237
237
  "replace",
238
238
  (a == null ? void 0 : a.direction) ?? "root",
239
239
  void 0,
240
240
  a,
241
241
  !0
242
- ), I = !0, L(c);
242
+ ), I = !0, A(c);
243
+ }, o = () => {
244
+ E("pop", "back", -1), W();
243
245
  }, h = () => {
244
- b("pop", "back", -1), $();
245
- }, R = () => {
246
- b("pop", "forward", 1), W();
247
- }, m = o;
248
- m.push = A, m.replace = j, m.popTo = e, m.resetRoot = r, m.back = h, m.forward = R;
249
- const _ = {
250
- router: m,
246
+ E("pop", "forward", 1), K();
247
+ }, k = r;
248
+ k.push = _, k.replace = B, k.popTo = z, k.resetRoot = e, k.back = o, k.forward = h;
249
+ const p = {
250
+ router: k,
251
251
  transitionDuration: l,
252
252
  transitionEasing: T,
253
253
  transition: w,
254
- transitions: p,
255
- maxStackSize: E,
254
+ transitions: R,
255
+ maxStackSize: b,
256
256
  shouldTransition: t.shouldTransition,
257
257
  current: u,
258
258
  get history() {
259
259
  return n;
260
260
  },
261
261
  canGoBack: (c = 1) => f - c >= 0,
262
- push: A,
263
- replace: j,
264
- popTo: e,
265
- resetRoot: r,
266
- back: h,
267
- forward: R
268
- }, z = o.install.bind(o);
269
- return o.install = (c) => {
270
- c.provide(Z, _), z(c);
271
- }, m;
262
+ push: _,
263
+ replace: B,
264
+ popTo: z,
265
+ resetRoot: e,
266
+ back: o,
267
+ forward: h
268
+ }, F = r.install.bind(r);
269
+ return r.install = (c) => {
270
+ c.provide(Z, p), F(c);
271
+ }, k;
272
272
  }
273
- const et = "onPageWillEnter", J = "onPageDidEnter", ot = "onPageWillLeave", rt = "onPageDidLeave";
274
- function Dt(t, o, n) {
273
+ const et = "onPageWillEnter", J = "onPageDidEnter", rt = "onPageWillLeave", ot = "onPageDidLeave";
274
+ function Dt(t, r, n) {
275
275
  if (!n)
276
276
  throw new Error(`${t} must be called inside setup().`);
277
277
  const u = n.proxy, l = u[t] ?? [];
278
278
  l.push(() => {
279
- n.isUnmounted || o();
279
+ n.isUnmounted || r();
280
280
  }), u[t] = l, n.exposed && (n.exposed[t] = l);
281
281
  }
282
- function G(t) {
283
- return (o, n = it()) => Dt(t, o, n);
282
+ function H(t) {
283
+ return (r, n = it()) => Dt(t, r, n);
284
284
  }
285
- const _t = G(et), Bt = G(J), Ft = G(ot), Gt = G(rt);
285
+ const _t = H(et), Bt = H(J), Ft = H(rt), Gt = H(ot);
286
286
  function Ct() {
287
- const t = B(Z);
287
+ const t = G(Z);
288
288
  if (!t)
289
289
  throw new Error("useStackRouter must be used after createStackRouter().");
290
290
  return {
@@ -299,15 +299,15 @@ function Ct() {
299
299
  };
300
300
  }
301
301
  function nt() {
302
- const t = B(Z);
302
+ const t = G(Z);
303
303
  if (!t)
304
304
  throw new Error("RouterOutlet must be used with createStackRouter().");
305
305
  return t;
306
306
  }
307
- function S(t, o) {
307
+ function S(t, r) {
308
308
  const n = t.value;
309
309
  if (!n) return;
310
- const u = n[o];
310
+ const u = n[r];
311
311
  Array.isArray(u) ? u.forEach((l) => l()) : typeof u == "function" && u.call(n);
312
312
  }
313
313
  function D(t) {
@@ -317,103 +317,103 @@ function M(t) {
317
317
  t.classList.add("rs-page-hidden"), t.setAttribute("aria-hidden", "true");
318
318
  }
319
319
  function at(t) {
320
- var o;
321
- return (o = t.components) == null ? void 0 : o.default;
320
+ var r;
321
+ return (r = t.components) == null ? void 0 : r.default;
322
322
  }
323
323
  function Tt(t) {
324
- const o = at(t);
325
- return o !== void 0 && typeof o == "object" && "name" in o && o.name === "RouterView";
324
+ const r = at(t);
325
+ return r !== void 0 && typeof r == "object" && "name" in r && r.name === "RouterView";
326
326
  }
327
327
  const Ht = Q({
328
328
  name: "RouterOutlet",
329
329
  setup() {
330
- const t = nt(), o = mt(), n = B(kt), u = B(v, void 0), l = U(() => {
330
+ const t = nt(), r = mt(), n = G(kt), u = G(v, void 0), l = U(() => {
331
331
  const e = u == null ? void 0 : u.value;
332
332
  if (!e) return 0;
333
- const r = o.matched.findIndex(
333
+ const o = r.matched.findIndex(
334
334
  (h) => h === e
335
335
  );
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;
336
+ return o >= 0 ? o + 1 : 0;
337
+ }), T = U(() => r.matched[l.value]), w = U(() => {
338
+ for (let e = l.value; e < r.matched.length; e++) {
339
+ const o = r.matched[e];
340
+ if (!Tt(o))
341
+ return o;
342
342
  }
343
343
  return T.value;
344
- }), p = tt([]), E = F("");
344
+ }), R = tt([]), b = C("");
345
345
  let f = 0;
346
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));
347
+ const i = (e) => R.value.find((o) => o.stackEntryId === e), I = (e) => {
348
+ R.value.forEach((o) => {
349
+ o.pageElement && (o === e ? D(o.pageElement) : M(o.pageElement));
350
350
  });
351
- }, b = (e) => {
352
- const r = p.value.findIndex((h) => h === e);
353
- r >= 0 && (p.value = p.value.slice(0, r + 1));
354
- }, C = (e) => {
355
- p.value = p.value.filter((r) => r !== e);
351
+ }, E = (e) => {
352
+ const o = R.value.findIndex((h) => h === e);
353
+ o >= 0 && (R.value = R.value.slice(0, o + 1));
354
+ }, V = (e) => {
355
+ R.value = R.value.filter((o) => o !== e);
356
356
  }, g = (e) => {
357
- const r = new Set(
358
- t.history.map((h) => h.key)
357
+ const o = new Set(
358
+ t.history.map((h) => h.id)
359
359
  );
360
- p.value = p.value.filter(
361
- (h) => h === e || h.routeInfo.cache && r.has(h.key)
360
+ R.value = R.value.filter(
361
+ (h) => h === e || h.routeInfo.cache && o.has(h.stackEntryId)
362
362
  );
363
363
  }, x = (e) => {
364
364
  var h;
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) => {
368
- var R;
369
- const h = V(e, r);
370
- return ((R = t.shouldTransition) == null ? void 0 : R.call(t, {
365
+ const o = e.props.default;
366
+ return o ? o === !0 ? ((h = t.current.value) == null ? void 0 : h.params) ?? {} : typeof o == "function" ? o(n) : o : {};
367
+ }, $ = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transition ?? e.routeInfo.transition ?? t.transition : e.routeInfo.transition ?? t.transition, L = (e) => e.entryDirection === "none" || e.entryDirection === "root" || e.transition === "none", A = (e, o) => !(e.routeInfo.isStackFallback || e.routeInfo.direction === "none" || e.routeInfo.direction === "root" || e.routeInfo.action === "pop" && (L(e.routeInfo) || L(o.routeInfo))), W = (e, o) => {
368
+ var k;
369
+ const h = A(e, o);
370
+ return ((k = t.shouldTransition) == null ? void 0 : k.call(t, {
371
371
  action: e.routeInfo.action,
372
372
  direction: e.routeInfo.direction,
373
373
  source: e.routeInfo.source,
374
374
  entering: e.routeInfo,
375
- leaving: r.routeInfo,
375
+ leaving: o.routeInfo,
376
376
  defaultResult: h
377
377
  })) ?? h;
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) => {
378
+ }, K = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionDuration ?? e.routeInfo.transitionDuration ?? t.transitionDuration : e.routeInfo.transitionDuration ?? t.transitionDuration, j = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionEasing ?? e.routeInfo.transitionEasing ?? t.transitionEasing : e.routeInfo.transitionEasing ?? t.transitionEasing, _ = async (e, o) => {
379
379
  const h = ++f;
380
- await ft();
381
- const R = e.pageElement;
382
- if (!R) return;
383
- if (S(e.componentRef, et), !r || r === e || !r.pageElement) {
384
- D(R), S(e.componentRef, J), g(e), I(e);
380
+ await dt();
381
+ const k = e.pageElement;
382
+ if (!k) return;
383
+ if (S(e.componentRef, et), !o || o === e || !o.pageElement) {
384
+ D(k), S(e.componentRef, J), g(e), I(e);
385
385
  return;
386
386
  }
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,
387
+ const p = o.pageElement, F = W(e, o), c = F ? $(e, o) : "none", a = F ? K(e, o) : 0, s = j(e, o), d = wt(
388
+ c || Y,
389
389
  t.transitions
390
390
  );
391
- S(r.componentRef, ot), D(R), D(m), await It(s, {
391
+ S(o.componentRef, rt), D(k), D(p), await It(d, {
392
392
  direction: e.routeInfo.direction,
393
393
  action: e.routeInfo.action,
394
394
  routeInfo: e.routeInfo,
395
- enteringElement: R,
396
- leavingElement: m,
397
- duration: c,
398
- easing: a
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));
400
- }, A = async () => {
401
- const e = w.value, r = t.current.value;
402
- if (!e || !r) return;
395
+ enteringElement: k,
396
+ leavingElement: p,
397
+ duration: a,
398
+ easing: s
399
+ }), h === f && (M(p), S(o.componentRef, ot), S(e.componentRef, J), e.routeInfo.action === "pop" ? E(e) : e.routeInfo.action === "replace" && V(o), g(e), I(e));
400
+ }, B = async () => {
401
+ const e = w.value, o = t.current.value;
402
+ if (!e || !o) return;
403
403
  const h = at(e);
404
404
  if (!h) return;
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 = {
405
+ const k = i(b.value);
406
+ let p = i(o.id);
407
+ p ? (p.routeInfo = o, p.matchedRoute = e, p.component = h, p.props = x(e), p.mounted = !0) : (p = {
408
408
  id: q("view"),
409
- key: r.key,
410
- routeInfo: r,
409
+ stackEntryId: o.id,
410
+ routeInfo: o,
411
411
  matchedRoute: e,
412
412
  component: h,
413
413
  props: x(e),
414
- componentRef: F(),
414
+ componentRef: C(),
415
415
  mounted: !0
416
- }, p.value = [...p.value, m]), E.value = m.key, await K(m, R);
416
+ }, R.value = [...R.value, p]), b.value = p.stackEntryId, await _(p, k);
417
417
  };
418
418
  return ut(
419
419
  () => {
@@ -421,16 +421,16 @@ const Ht = Q({
421
421
  return [(e = t.current.value) == null ? void 0 : e.id, w.value];
422
422
  },
423
423
  () => {
424
- A();
424
+ B();
425
425
  },
426
426
  { immediate: !0 }
427
427
  ), lt(() => {
428
- f++, p.value = [];
428
+ f++, R.value = [];
429
429
  }), {
430
430
  injectedRoute: n,
431
- viewItems: p,
432
- registerStackPage: (e, r) => {
433
- e.pageElement = r, e.key === E.value ? D(r) : M(r);
431
+ viewItems: R,
432
+ registerStackPage: (e, o) => {
433
+ e.pageElement = o, e.stackEntryId === b.value ? D(o) : M(o);
434
434
  }
435
435
  };
436
436
  },
@@ -443,7 +443,7 @@ const Ht = Q({
443
443
  key: t.id,
444
444
  ref: t.componentRef,
445
445
  ...t.props,
446
- registerStackPage: (o) => this.registerStackPage(t, o)
446
+ registerStackPage: (r) => this.registerStackPage(t, r)
447
447
  })
448
448
  )
449
449
  );
@@ -456,9 +456,9 @@ const Ht = Q({
456
456
  default: void 0
457
457
  }
458
458
  },
459
- setup(t, { attrs: o, slots: n }) {
460
- const u = F();
461
- return dt(() => {
459
+ setup(t, { attrs: r, slots: n }) {
460
+ const u = C();
461
+ return ft(() => {
462
462
  var l;
463
463
  u.value && ((l = t.registerStackPage) == null || l.call(t, u.value));
464
464
  }), () => {
@@ -466,9 +466,9 @@ const Ht = Q({
466
466
  return y(
467
467
  "section",
468
468
  {
469
- ...o,
469
+ ...r,
470
470
  ref: u,
471
- class: ["rs-page", o.class]
471
+ class: ["rs-page", r.class]
472
472
  },
473
473
  (l = n.default) == null ? void 0 : l.call(n)
474
474
  );
@@ -483,9 +483,9 @@ const Ht = Q({
483
483
  }
484
484
  },
485
485
  setup(t) {
486
- const o = nt(), n = F(t.initialOpen);
486
+ const r = nt(), n = C(t.initialOpen);
487
487
  return () => {
488
- const u = o.current.value;
488
+ const u = r.current.value;
489
489
  return y("aside", { class: "rs-debug-panel" }, [
490
490
  y(
491
491
  "button",
@@ -501,17 +501,17 @@ const Ht = Q({
501
501
  n.value ? y("section", { class: "rs-debug-body" }, [
502
502
  y("header", [
503
503
  y("strong", "Router Stack"),
504
- y("span", `${o.history.length} pages`)
504
+ y("span", `${r.history.length} pages`)
505
505
  ]),
506
506
  y("dl", [
507
507
  y("dt", "current"),
508
508
  y("dd", (u == null ? void 0 : u.fullPath) ?? "-"),
509
509
  y("dt", "canGoBack"),
510
- y("dd", String(o.canGoBack()))
510
+ y("dd", String(r.canGoBack()))
511
511
  ]),
512
512
  y(
513
513
  "ol",
514
- o.history.map(
514
+ r.history.map(
515
515
  (l) => y(
516
516
  "li",
517
517
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazycatcloud/vue-router-stack",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Page stack, caching, transitions, and lifecycle utilities built on vue-router.",
5
5
  "private": false,
6
6
  "type": "module",