@lazycatcloud/vue-router-stack 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/components/RouterOutlet.d.ts +2 -1
- package/dist/router/types.d.ts +3 -0
- package/dist/vue-router-stack.cjs +1 -1
- package/dist/vue-router-stack.js +355 -334
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,7 +101,7 @@ stackRouter.popTo("/album/detail");
|
|
|
101
101
|
stackRouter.resetRoot("/");
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
单次导航可以控制页面复用、方向、动画、时长和缓动:
|
|
105
105
|
|
|
106
106
|
```ts
|
|
107
107
|
stackRouter.push("/search/result", {
|
|
@@ -112,6 +112,11 @@ stackRouter.push("/timeline", {
|
|
|
112
112
|
direction: "none",
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
stackRouter.push("/album", {
|
|
116
|
+
reuse: true,
|
|
117
|
+
transition: "fade",
|
|
118
|
+
});
|
|
119
|
+
|
|
115
120
|
stackRouter.push("/detail", {
|
|
116
121
|
transition: "sheet",
|
|
117
122
|
duration: 300,
|
|
@@ -119,7 +124,9 @@ stackRouter.push("/detail", {
|
|
|
119
124
|
});
|
|
120
125
|
```
|
|
121
126
|
|
|
122
|
-
`direction: "none"`
|
|
127
|
+
`direction: "none"` 保持原有语义:重复进入相同 `fullPath` 时会复用已有页面实例,并强制不播放转场,适合无需动画的 tab 切换。`direction: "root"` 也会强制关闭转场。
|
|
128
|
+
|
|
129
|
+
`reuse: true` 可以让普通的 `forward` 导航在重复进入相同 `fullPath` 时复用已有页面实例,并且不会关闭转场。PC tab 可以将它与 `transition: "fade"` 组合使用。
|
|
123
130
|
|
|
124
131
|
## 转场动画
|
|
125
132
|
|
|
@@ -3,7 +3,8 @@ import type { RouteLocationMatched } from "vue-router";
|
|
|
3
3
|
import type { RouteInfo } from "../router/types";
|
|
4
4
|
interface ViewItem {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
routeKey: string;
|
|
7
|
+
routeIds: Set<string>;
|
|
7
8
|
routeInfo: RouteInfo;
|
|
8
9
|
matchedRoute: RouteLocationMatched;
|
|
9
10
|
component: Component;
|
package/dist/router/types.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export type StackTransitionFactory = (context: StackTransitionContext) => StackT
|
|
|
38
38
|
export type StackTransitionRegistry = Record<string, StackTransitionFactory>;
|
|
39
39
|
export interface StackNavigationOptions {
|
|
40
40
|
direction?: RouteDirection;
|
|
41
|
+
reuse?: boolean;
|
|
41
42
|
transition?: StackTransitionName;
|
|
42
43
|
duration?: number;
|
|
43
44
|
easing?: string;
|
|
@@ -51,6 +52,7 @@ export interface RouteInfo {
|
|
|
51
52
|
query: RouteLocationNormalizedLoaded["query"];
|
|
52
53
|
action: RouteAction;
|
|
53
54
|
direction: RouteDirection;
|
|
55
|
+
reuse?: boolean;
|
|
54
56
|
source: StackNavigationSource;
|
|
55
57
|
entryDirection: RouteDirection;
|
|
56
58
|
lastPathname?: string;
|
|
@@ -76,6 +78,7 @@ export interface PendingNavigation {
|
|
|
76
78
|
direction: RouteDirection;
|
|
77
79
|
source: StackNavigationSource;
|
|
78
80
|
delta?: number;
|
|
81
|
+
reuse?: boolean;
|
|
79
82
|
transition?: StackTransitionName;
|
|
80
83
|
duration?: number;
|
|
81
84
|
easing?: string;
|
|
@@ -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 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
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),R=require("vue-router"),Y={};function X(t="route"){const n=(Y[t]??0)+1;return Y[t]=n,`${t}-${n}`}const Q="slide",re="cubic-bezier(0.3, 0, 0.66, 1)";function oe(t){return t}const ne=({direction:t})=>t==="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:t})=>{const n=t==="back";return{entering:n?[{transform:"scale(0.98)",opacity:0},{transform:"scale(1)",opacity:1}]:[{transform:"scale(1.04)",opacity:0},{transform:"scale(1)",opacity:1}],leaving:n?[{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(t,n){const c=n[t];return c||n[Q]}function Z(t,n,c){if(!n||!t.animate||Number(c.duration)<=0)return Promise.resolve();const l=t.animate(n,c);return l.finished.then(()=>l.cancel())}async function le(t,n){const c=t(n),l={duration:n.duration,easing:n.easing,fill:"both",...c.options};await Promise.all([Z(n.enteringElement,c.entering,l),Z(n.leavingElement,c.leaving,l)])}const H=Symbol("stack-router");function de(){const t=window.history.state;return typeof(t==null?void 0:t.position)=="number"?t.position:window.history.length}function q(t,n){return n||(t==="pop"?"back":t==="replace"?"none":"forward")}function fe(t){const n=R.createRouter(t),c=[],l=s.shallowRef(),f=t.transitionDuration??210,g=t.transitionEasing??re,w=t.transition??Q,k={...se,...t.transitions},P=t.maxStackSize??30;let m=-1,i,E=!1;const p=(a,r,u,d,y=!1,b="stack")=>{i={action:a,direction:q(a,r),source:b,delta:u,reuse:d==null?void 0:d.reuse,transition:d==null?void 0:d.transition,duration:d==null?void 0:d.duration,easing:d==null?void 0:d.easing,resetRoot:y}},F=(a,r)=>{const u=(i==null?void 0:i.action)??"push",d=q(u,i==null?void 0:i.direction),y=l.value,b=u==="push"&&d==="forward",M=T(a);return{id:X("route"),key:a.fullPath,fullPath:a.fullPath,pathname:a.path,params:a.params,query:a.query,action:u,direction:d,reuse:(i==null?void 0:i.reuse)??!1,source:(i==null?void 0:i.source)??"stack",entryDirection:d,lastPathname:(y==null?void 0:y.pathname)||(r.name?r.path:void 0),pushedByRoute:b?y==null?void 0:y.pathname:y==null?void 0:y.pushedByRoute,position:de(),delta:i==null?void 0:i.delta,transition:(i==null?void 0:i.transition)??w,transitionDuration:(i==null?void 0:i.duration)??f,transitionEasing:(i==null?void 0:i.easing)??g,cache:M}},T=a=>{const r=a.meta.stack;return a.meta.stackCache!==!1&&(r==null?void 0:r.cache)!==!1},K=()=>{if(P<=0||c.length<=P)return;const a=c.length-P;c.splice(0,a),m=Math.max(0,m-a)},W=a=>{if(a.action==="pop"){let r=-1;if(a.direction==="forward"||(a.delta??0)>0){for(let u=m+1;u<c.length;u++)if(c[u].key===a.key){r=u;break}}else for(let u=m-1;u>=0;u--)if(c[u].key===a.key){r=u;break}if(r>=0){const u=c[r];c[r]={...u,...a,id:u.id,reuse:u.reuse,source:a.source,entryDirection:u.entryDirection,transition:u.transition,transitionDuration:u.transitionDuration,transitionEasing:u.transitionEasing},m=r}else c.push({...a,direction:"none",entryDirection:"none",transition:"none",isStackFallback:!0}),m=c.length-1}else if(a.action==="replace"){if(i!=null&&i.resetRoot){c.splice(0,c.length,a),m=0,l.value=c[m];return}m>=0?c[m]=a:(c.push(a),m=0)}else m<c.length-1&&c.splice(m+1),c.push(a),m=c.length-1;K(),l.value=c[m]};t.history.listen((a,r,u)=>{const d="delta"in u?u.delta:void 0,y=u.direction==="back"?"back":u.direction==="forward"?"forward":void 0;i?(i.delta=d,i.direction=q(i.action,i.direction??y)):p(u.type==="pop"?"pop":u.type,y,d,void 0,!1,"external")}),n.beforeEach(a=>!((i==null?void 0:i.action)==="pop"&&E&&!c.some(r=>r.fullPath===a.fullPath))),n.afterEach((a,r,u)=>{if(u){i=void 0;return}W(F(a,r)),i=void 0});const L=n.push.bind(n),I=n.replace.bind(n),G=n.back.bind(n),x=n.forward.bind(n),$=n.go.bind(n),A=(a,r)=>(p("push",(r==null?void 0:r.direction)??"forward",void 0,r),L(a)),j=(a,r)=>(p("replace",(r==null?void 0:r.direction)??"root",void 0,r),I(a)),B=(a,r)=>{const u=n.resolve(a).fullPath;let d=-1;for(let b=m;b>=0;b--)if(c[b].fullPath===u){d=b;break}if(d<0)return!1;const y=d-m;return y===0||(p("pop",(r==null?void 0:r.direction)??"back",y,r),$(y)),!0},V=(a,r)=>{const u=n.resolve(a).fullPath;if(m>=0&&n.currentRoute.value.fullPath===u){const d=c[m],y={...d,id:X("route"),action:"replace",direction:(r==null?void 0:r.direction)??"root",source:"stack",entryDirection:(r==null?void 0:r.direction)??"root",delta:void 0,reuse:(r==null?void 0:r.reuse)??d.reuse,transition:(r==null?void 0:r.transition)??d.transition,transitionDuration:(r==null?void 0:r.duration)??d.transitionDuration,transitionEasing:(r==null?void 0:r.easing)??d.transitionEasing,cache:!0,isStackFallback:!1};return c.splice(0,c.length,y),m=0,E=!0,l.value=y,Promise.resolve(void 0)}return p("replace",(r==null?void 0:r.direction)??"root",void 0,r,!0),E=!0,I(a)},_=()=>{p("pop","back",-1),G()},z=()=>{p("pop","forward",1),x()},e=n;e.push=A,e.replace=j,e.popTo=B,e.resetRoot=V,e.back=_,e.forward=z;const o={router:e,transitionDuration:f,transitionEasing:g,transition:w,transitions:k,maxStackSize:P,shouldTransition:t.shouldTransition,current:l,get history(){return c},canGoBack:(a=1)=>m-a>=0,push:A,replace:j,popTo:B,resetRoot:V,back:_,forward:z},h=n.install.bind(n);return n.install=a=>{a.provide(H,o),h(a)},e}const v="onPageWillEnter",J="onPageDidEnter",N="onPageWillLeave",O="onPageDidLeave";function he(t,n,c){if(!c)throw new Error(`${t} must be called inside setup().`);const l=c.proxy,f=l[t]??[];f.push(()=>{c.isUnmounted||n()}),l[t]=f,c.exposed&&(c.exposed[t]=f)}function C(t){return(n,c=s.getCurrentInstance())=>he(t,n,c)}const me=C(v),ye=C(J),ke=C(N),Re=C(O);function be(){const t=s.inject(H);if(!t)throw new Error("useStackRouter must be used after createStackRouter().");return{router:t.router,canGoBack:t.canGoBack,push:t.push,replace:t.replace,popTo:t.popTo,resetRoot:t.resetRoot,back:t.back,forward:t.forward}}function ee(){const t=s.inject(H);if(!t)throw new Error("RouterOutlet must be used with createStackRouter().");return t}function S(t,n){const c=t.value;if(!c)return;const l=c[n];Array.isArray(l)?l.forEach(f=>f()):typeof l=="function"&&l.call(c)}function D(t){t.classList.remove("rs-page-hidden","rs-page-invisible"),t.removeAttribute("aria-hidden")}function U(t){t.classList.add("rs-page-hidden"),t.setAttribute("aria-hidden","true")}function te(t){var n;return(n=t.components)==null?void 0:n.default}function pe(t){const n=te(t);return n!==void 0&&typeof n=="object"&&"name"in n&&n.name==="RouterView"}const Pe=s.defineComponent({name:"RouterOutlet",setup(){const t=ee(),n=R.useRoute(),c=s.inject(R.routeLocationKey),l=s.inject(R.matchedRouteKey,void 0),f=s.computed(()=>{const e=l==null?void 0:l.value;if(!e)return 0;const o=n.matched.findIndex(h=>h===e);return o>=0?o+1:0}),g=s.computed(()=>n.matched[f.value]),w=s.computed(()=>{for(let e=f.value;e<n.matched.length;e++){const o=n.matched[e];if(!pe(o))return o}return g.value}),k=s.shallowRef([]),P=s.ref("");let m=0;s.provide(R.matchedRouteKey,w);const i=e=>k.value.find(o=>o.id===e),E=e=>k.value.find(o=>o.routeIds.has(e)),p=e=>k.value.find(o=>o.routeKey===e),F=e=>e.action==="push"&&e.direction==="forward"&&!e.reuse&&k.value.some(o=>o.routeKey===e.key),T=e=>{k.value.forEach(o=>{o.pageElement&&(o===e?D(o.pageElement):U(o.pageElement))})},K=e=>{const o=t.history.findIndex(a=>a.id===e.routeInfo.id);if(o<0)return;const h=new Set(t.history.slice(0,o+1).map(a=>a.id));k.value.forEach(a=>{a.routeIds=new Set([...a.routeIds].filter(r=>h.has(r)))}),k.value=k.value.filter(a=>a===e||a.routeIds.size>0)},W=e=>{k.value=k.value.filter(o=>o!==e)},L=e=>{const o=new Set(t.history.map(h=>h.id));k.value.forEach(h=>{h.routeIds=new Set([...h.routeIds].filter(a=>o.has(a)))}),k.value=k.value.filter(h=>h===e||h.routeInfo.cache&&h.routeIds.size>0)},I=e=>{var h;const o=e.props.default;return o?o===!0?((h=t.current.value)==null?void 0:h.params)??{}:typeof o=="function"?o(c):o:{}},G=(e,o)=>e.routeInfo.action==="pop"?o.routeInfo.transition??e.routeInfo.transition??t.transition:e.routeInfo.transition??t.transition,x=e=>e.entryDirection==="none"||e.entryDirection==="root"||e.transition==="none",$=(e,o)=>!(e.routeInfo.isStackFallback||e.routeInfo.direction==="none"||e.routeInfo.direction==="root"||e.routeInfo.action==="pop"&&(x(e.routeInfo)||x(o.routeInfo))),A=(e,o)=>{var a;const h=$(e,o);return((a=t.shouldTransition)==null?void 0:a.call(t,{action:e.routeInfo.action,direction:e.routeInfo.direction,source:e.routeInfo.source,entering:e.routeInfo,leaving:o.routeInfo,defaultResult:h}))??h},j=(e,o)=>e.routeInfo.action==="pop"?o.routeInfo.transitionDuration??e.routeInfo.transitionDuration??t.transitionDuration:e.routeInfo.transitionDuration??t.transitionDuration,B=(e,o)=>e.routeInfo.action==="pop"?o.routeInfo.transitionEasing??e.routeInfo.transitionEasing??t.transitionEasing:e.routeInfo.transitionEasing??t.transitionEasing,V=async(e,o)=>{const h=++m;await s.nextTick();const a=e.pageElement;if(!a)return;if(S(e.componentRef,v),!o||o===e||!o.pageElement){D(a),S(e.componentRef,J),L(e),T(e);return}const r=o.pageElement,u=A(e,o),d=u?G(e,o):"none",y=u?j(e,o):0,b=B(e,o),M=ue(d||Q,t.transitions);S(o.componentRef,N),D(a),D(r),await le(M,{direction:e.routeInfo.direction,action:e.routeInfo.action,routeInfo:e.routeInfo,enteringElement:a,leavingElement:r,duration:y,easing:b}),h===m&&(U(r),S(o.componentRef,O),S(e.componentRef,J),e.routeInfo.action==="pop"?K(e):e.routeInfo.action==="replace"&&W(o),L(e),T(e))},_=async()=>{const e=w.value,o=t.current.value;if(!e||!o)return;const h=te(e);if(!h)return;const a=i(P.value);let r=E(o.id);!r&&!F(o)&&(r=p(o.key)),r?(r.routeIds.add(o.id),r.routeKey=o.key,r.routeInfo=o,r.matchedRoute=e,r.component=h,r.props=I(e),r.mounted=!0):(r={id:X("view"),routeKey:o.key,routeIds:new Set([o.id]),routeInfo:o,matchedRoute:e,component:h,props:I(e),componentRef:s.ref(),mounted:!0},k.value=[...k.value,r]),P.value=r.id,await V(r,a)};return s.watch(()=>{var e;return[(e=t.current.value)==null?void 0:e.id,w.value]},()=>{_()},{immediate:!0}),s.onUnmounted(()=>{m++,k.value=[]}),{injectedRoute:c,viewItems:k,registerStackPage:(e,o)=>{e.pageElement=o,e.id===P.value?D(o):U(o)}}},render(){return s.h("div",{class:"rs-outlet"},this.viewItems.filter(t=>t.mounted).map(t=>s.h(t.component,{key:t.id,ref:t.componentRef,...t.props,registerStackPage:n=>this.registerStackPage(t,n)})))}}),we=s.defineComponent({name:"RouterPage",props:{registerStackPage:{type:Function,default:void 0}},setup(t,{attrs:n,slots:c}){const l=s.ref();return s.onMounted(()=>{var f;l.value&&((f=t.registerStackPage)==null||f.call(t,l.value))}),()=>{var f;return s.h("section",{...n,ref:l,class:["rs-page",n.class]},(f=c.default)==null?void 0:f.call(c))}}}),Ee=s.defineComponent({name:"StackRouterDebugPanel",props:{initialOpen:{type:Boolean,default:!1}},setup(t){const n=ee(),c=s.ref(t.initialOpen);return()=>{const l=n.current.value;return s.h("aside",{class:"rs-debug-panel"},[s.h("button",{class:"rs-debug-toggle",type:"button",onClick:()=>{c.value=!c.value}},c.value?"Stack x":"Stack"),c.value?s.h("section",{class:"rs-debug-body"},[s.h("header",[s.h("strong","Router Stack"),s.h("span",`${n.history.length} pages`)]),s.h("dl",[s.h("dt","current"),s.h("dd",(l==null?void 0:l.fullPath)??"-"),s.h("dt","canGoBack"),s.h("dd",String(n.canGoBack()))]),s.h("ol",n.history.map(f=>s.h("li",{key:f.id,class:{"rs-debug-active":f.id===(l==null?void 0:l.id),"rs-debug-no-cache":!f.cache}},[s.h("code",f.fullPath),s.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:()=>R.RouterLink});Object.defineProperty(exports,"RouterView",{enumerable:!0,get:()=>R.RouterView});Object.defineProperty(exports,"createMemoryHistory",{enumerable:!0,get:()=>R.createMemoryHistory});Object.defineProperty(exports,"createWebHashHistory",{enumerable:!0,get:()=>R.createWebHashHistory});Object.defineProperty(exports,"createWebHistory",{enumerable:!0,get:()=>R.createWebHistory});Object.defineProperty(exports,"useRoute",{enumerable:!0,get:()=>R.useRoute});Object.defineProperty(exports,"useRouter",{enumerable:!0,get:()=>R.useRouter});exports.RouterOutlet=Pe;exports.RouterPage=we;exports.StackRouterDebugPanel=Ee;exports.createStackRouter=fe;exports.defineStackTransition=oe;exports.onPageDidEnter=ye;exports.onPageDidLeave=Re;exports.onPageWillEnter=me;exports.onPageWillLeave=ke;exports.stackRouterKey=H;exports.useStackRouter=be;
|
package/dist/vue-router-stack.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { shallowRef as
|
|
2
|
-
import { createRouter as
|
|
3
|
-
import { RouterLink as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
return
|
|
1
|
+
import { shallowRef as te, getCurrentInstance as se, inject as F, defineComponent as Y, h as k, computed as X, ref as C, provide as ie, watch as ue, onUnmounted as le, nextTick as de, onMounted as fe } from "vue";
|
|
2
|
+
import { createRouter as he, useRoute as me, routeLocationKey as ye, matchedRouteKey as v } from "vue-router";
|
|
3
|
+
import { RouterLink as ze, RouterView as je, createMemoryHistory as Ue, createWebHashHistory as Xe, createWebHistory as Me, useRoute as qe, useRouter as Je } from "vue-router";
|
|
4
|
+
const O = {};
|
|
5
|
+
function J(t = "route") {
|
|
6
|
+
const n = (O[t] ?? 0) + 1;
|
|
7
|
+
return O[t] = n, `${t}-${n}`;
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
function
|
|
9
|
+
const Z = "slide", ke = "cubic-bezier(0.3, 0, 0.66, 1)";
|
|
10
|
+
function Le(t) {
|
|
11
11
|
return t;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const Re = ({ direction: t }) => t === "back" ? {
|
|
14
14
|
leaving: [
|
|
15
15
|
{ transform: "translateX(0)" },
|
|
16
16
|
{ transform: "translateX(100%)" }
|
|
@@ -20,20 +20,20 @@ const pt = ({ direction: t }) => t === "back" ? {
|
|
|
20
20
|
{ transform: "translateX(100%)" },
|
|
21
21
|
{ transform: "translateX(0)" }
|
|
22
22
|
]
|
|
23
|
-
},
|
|
23
|
+
}, pe = () => ({
|
|
24
24
|
entering: [{ opacity: 0 }, { opacity: 1 }],
|
|
25
25
|
leaving: [{ opacity: 1 }, { opacity: 0 }]
|
|
26
|
-
}),
|
|
27
|
-
const
|
|
26
|
+
}), we = ({ direction: t }) => {
|
|
27
|
+
const n = t === "back";
|
|
28
28
|
return {
|
|
29
|
-
entering:
|
|
29
|
+
entering: n ? [
|
|
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:
|
|
36
|
+
leaving: n ? [
|
|
37
37
|
{ transform: "scale(1)", opacity: 1 },
|
|
38
38
|
{ transform: "scale(1.04)", opacity: 0 }
|
|
39
39
|
] : [
|
|
@@ -41,250 +41,254 @@ const pt = ({ direction: t }) => t === "back" ? {
|
|
|
41
41
|
{ transform: "scale(0.98)", opacity: 0 }
|
|
42
42
|
]
|
|
43
43
|
};
|
|
44
|
-
},
|
|
45
|
-
slide:
|
|
46
|
-
fade:
|
|
47
|
-
scale:
|
|
48
|
-
none:
|
|
44
|
+
}, Ee = () => ({}), be = {
|
|
45
|
+
slide: Re,
|
|
46
|
+
fade: pe,
|
|
47
|
+
scale: we,
|
|
48
|
+
none: Ee
|
|
49
49
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
return
|
|
50
|
+
function Ie(t, n) {
|
|
51
|
+
const c = n[t];
|
|
52
|
+
return c || n[Z];
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
if (!
|
|
54
|
+
function ee(t, n, c) {
|
|
55
|
+
if (!n || !t.animate || Number(c.duration) <= 0)
|
|
56
56
|
return Promise.resolve();
|
|
57
|
-
const u = t.animate(
|
|
57
|
+
const u = t.animate(n, c);
|
|
58
58
|
return u.finished.then(() => u.cancel());
|
|
59
59
|
}
|
|
60
|
-
async function
|
|
61
|
-
const
|
|
62
|
-
duration:
|
|
63
|
-
easing:
|
|
60
|
+
async function Pe(t, n) {
|
|
61
|
+
const c = t(n), u = {
|
|
62
|
+
duration: n.duration,
|
|
63
|
+
easing: n.easing,
|
|
64
64
|
fill: "both",
|
|
65
|
-
...
|
|
65
|
+
...c.options
|
|
66
66
|
};
|
|
67
67
|
await Promise.all([
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
ee(n.enteringElement, c.entering, u),
|
|
69
|
+
ee(n.leavingElement, c.leaving, u)
|
|
70
70
|
]);
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
function
|
|
72
|
+
const N = Symbol("stack-router");
|
|
73
|
+
function Se() {
|
|
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
|
|
78
|
-
return
|
|
77
|
+
function M(t, n) {
|
|
78
|
+
return n || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const
|
|
82
|
-
...
|
|
80
|
+
function Ae(t) {
|
|
81
|
+
const n = he(t), c = [], u = te(), d = t.transitionDuration ?? 210, D = t.transitionEasing ?? ke, E = t.transition ?? Z, y = {
|
|
82
|
+
...be,
|
|
83
83
|
...t.transitions
|
|
84
|
-
},
|
|
85
|
-
let
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
action:
|
|
89
|
-
direction:
|
|
90
|
-
source:
|
|
91
|
-
delta:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
}, w = t.maxStackSize ?? 30;
|
|
85
|
+
let h = -1, s, b = !1;
|
|
86
|
+
const p = (a, r, i, l, m = !1, R = "stack") => {
|
|
87
|
+
s = {
|
|
88
|
+
action: a,
|
|
89
|
+
direction: M(a, r),
|
|
90
|
+
source: R,
|
|
91
|
+
delta: i,
|
|
92
|
+
reuse: l == null ? void 0 : l.reuse,
|
|
93
|
+
transition: l == null ? void 0 : l.transition,
|
|
94
|
+
duration: l == null ? void 0 : l.duration,
|
|
95
|
+
easing: l == null ? void 0 : l.easing,
|
|
95
96
|
resetRoot: m
|
|
96
97
|
};
|
|
97
|
-
},
|
|
98
|
-
const
|
|
98
|
+
}, H = (a, r) => {
|
|
99
|
+
const i = (s == null ? void 0 : s.action) ?? "push", l = M(i, s == null ? void 0 : s.direction), m = u.value, R = i === "push" && l === "forward", U = T(a);
|
|
99
100
|
return {
|
|
100
|
-
id:
|
|
101
|
-
key:
|
|
102
|
-
fullPath:
|
|
103
|
-
pathname:
|
|
104
|
-
params:
|
|
105
|
-
query:
|
|
106
|
-
action:
|
|
107
|
-
direction:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
id: J("route"),
|
|
102
|
+
key: a.fullPath,
|
|
103
|
+
fullPath: a.fullPath,
|
|
104
|
+
pathname: a.path,
|
|
105
|
+
params: a.params,
|
|
106
|
+
query: a.query,
|
|
107
|
+
action: i,
|
|
108
|
+
direction: l,
|
|
109
|
+
reuse: (s == null ? void 0 : s.reuse) ?? !1,
|
|
110
|
+
source: (s == null ? void 0 : s.source) ?? "stack",
|
|
111
|
+
entryDirection: l,
|
|
112
|
+
lastPathname: (m == null ? void 0 : m.pathname) || (r.name ? r.path : void 0),
|
|
113
|
+
pushedByRoute: R ? m == null ? void 0 : m.pathname : m == null ? void 0 : m.pushedByRoute,
|
|
114
|
+
position: Se(),
|
|
115
|
+
delta: s == null ? void 0 : s.delta,
|
|
116
|
+
transition: (s == null ? void 0 : s.transition) ?? E,
|
|
117
|
+
transitionDuration: (s == null ? void 0 : s.duration) ?? d,
|
|
118
|
+
transitionEasing: (s == null ? void 0 : s.easing) ?? D,
|
|
119
|
+
cache: U
|
|
118
120
|
};
|
|
119
|
-
},
|
|
120
|
-
const
|
|
121
|
-
return
|
|
122
|
-
},
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
}, $ = (
|
|
127
|
-
if (
|
|
128
|
-
let
|
|
129
|
-
if (
|
|
130
|
-
for (let
|
|
131
|
-
if (
|
|
132
|
-
|
|
121
|
+
}, T = (a) => {
|
|
122
|
+
const r = a.meta.stack;
|
|
123
|
+
return a.meta.stackCache !== !1 && (r == null ? void 0 : r.cache) !== !1;
|
|
124
|
+
}, K = () => {
|
|
125
|
+
if (w <= 0 || c.length <= w) return;
|
|
126
|
+
const a = c.length - w;
|
|
127
|
+
c.splice(0, a), h = Math.max(0, h - a);
|
|
128
|
+
}, $ = (a) => {
|
|
129
|
+
if (a.action === "pop") {
|
|
130
|
+
let r = -1;
|
|
131
|
+
if (a.direction === "forward" || (a.delta ?? 0) > 0) {
|
|
132
|
+
for (let i = h + 1; i < c.length; i++)
|
|
133
|
+
if (c[i].key === a.key) {
|
|
134
|
+
r = i;
|
|
133
135
|
break;
|
|
134
136
|
}
|
|
135
137
|
} else
|
|
136
|
-
for (let
|
|
137
|
-
if (
|
|
138
|
-
|
|
138
|
+
for (let i = h - 1; i >= 0; i--)
|
|
139
|
+
if (c[i].key === a.key) {
|
|
140
|
+
r = i;
|
|
139
141
|
break;
|
|
140
142
|
}
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
...
|
|
145
|
-
...
|
|
146
|
-
id:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
if (r >= 0) {
|
|
144
|
+
const i = c[r];
|
|
145
|
+
c[r] = {
|
|
146
|
+
...i,
|
|
147
|
+
...a,
|
|
148
|
+
id: i.id,
|
|
149
|
+
reuse: i.reuse,
|
|
150
|
+
source: a.source,
|
|
151
|
+
entryDirection: i.entryDirection,
|
|
152
|
+
transition: i.transition,
|
|
153
|
+
transitionDuration: i.transitionDuration,
|
|
154
|
+
transitionEasing: i.transitionEasing
|
|
155
|
+
}, h = r;
|
|
153
156
|
} else
|
|
154
|
-
|
|
155
|
-
...
|
|
157
|
+
c.push({
|
|
158
|
+
...a,
|
|
156
159
|
direction: "none",
|
|
157
160
|
entryDirection: "none",
|
|
158
161
|
transition: "none",
|
|
159
162
|
isStackFallback: !0
|
|
160
|
-
}),
|
|
161
|
-
} else if (
|
|
162
|
-
if (
|
|
163
|
-
|
|
163
|
+
}), h = c.length - 1;
|
|
164
|
+
} else if (a.action === "replace") {
|
|
165
|
+
if (s != null && s.resetRoot) {
|
|
166
|
+
c.splice(0, c.length, a), h = 0, u.value = c[h];
|
|
164
167
|
return;
|
|
165
168
|
}
|
|
166
|
-
|
|
169
|
+
h >= 0 ? c[h] = a : (c.push(a), h = 0);
|
|
167
170
|
} else
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
h < c.length - 1 && c.splice(h + 1), c.push(a), h = c.length - 1;
|
|
172
|
+
K(), u.value = c[h];
|
|
170
173
|
};
|
|
171
|
-
t.history.listen((
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)) :
|
|
177
|
-
|
|
174
|
+
t.history.listen((a, r, i) => {
|
|
175
|
+
const l = "delta" in i ? i.delta : void 0, m = i.direction === "back" ? "back" : i.direction === "forward" ? "forward" : void 0;
|
|
176
|
+
s ? (s.delta = l, s.direction = M(
|
|
177
|
+
s.action,
|
|
178
|
+
s.direction ?? m
|
|
179
|
+
)) : p(
|
|
180
|
+
i.type === "pop" ? "pop" : i.type,
|
|
178
181
|
m,
|
|
179
|
-
|
|
182
|
+
l,
|
|
180
183
|
void 0,
|
|
181
184
|
!1,
|
|
182
185
|
"external"
|
|
183
186
|
);
|
|
184
|
-
}),
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
+
}), n.beforeEach((a) => !((s == null ? void 0 : s.action) === "pop" && b && !c.some((r) => r.fullPath === a.fullPath))), n.afterEach((a, r, i) => {
|
|
188
|
+
if (i) {
|
|
189
|
+
s = void 0;
|
|
187
190
|
return;
|
|
188
191
|
}
|
|
189
|
-
$(
|
|
192
|
+
$(H(a, r)), s = void 0;
|
|
190
193
|
});
|
|
191
|
-
const
|
|
194
|
+
const g = n.push.bind(n), I = n.replace.bind(n), W = n.back.bind(n), x = n.forward.bind(n), z = n.go.bind(n), L = (a, r) => (p(
|
|
192
195
|
"push",
|
|
193
|
-
(
|
|
196
|
+
(r == null ? void 0 : r.direction) ?? "forward",
|
|
194
197
|
void 0,
|
|
195
|
-
|
|
196
|
-
),
|
|
198
|
+
r
|
|
199
|
+
), g(a)), A = (a, r) => (p(
|
|
197
200
|
"replace",
|
|
198
|
-
(
|
|
201
|
+
(r == null ? void 0 : r.direction) ?? "root",
|
|
199
202
|
void 0,
|
|
200
|
-
|
|
201
|
-
),
|
|
202
|
-
const
|
|
203
|
-
let
|
|
204
|
-
for (let
|
|
205
|
-
if (
|
|
206
|
-
|
|
203
|
+
r
|
|
204
|
+
), I(a)), B = (a, r) => {
|
|
205
|
+
const i = n.resolve(a).fullPath;
|
|
206
|
+
let l = -1;
|
|
207
|
+
for (let R = h; R >= 0; R--)
|
|
208
|
+
if (c[R].fullPath === i) {
|
|
209
|
+
l = R;
|
|
207
210
|
break;
|
|
208
211
|
}
|
|
209
|
-
if (
|
|
210
|
-
const m =
|
|
211
|
-
return m === 0 || (
|
|
212
|
+
if (l < 0) return !1;
|
|
213
|
+
const m = l - h;
|
|
214
|
+
return m === 0 || (p(
|
|
212
215
|
"pop",
|
|
213
|
-
(
|
|
216
|
+
(r == null ? void 0 : r.direction) ?? "back",
|
|
214
217
|
m,
|
|
215
|
-
|
|
216
|
-
),
|
|
217
|
-
},
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
...
|
|
222
|
-
id:
|
|
218
|
+
r
|
|
219
|
+
), z(m)), !0;
|
|
220
|
+
}, _ = (a, r) => {
|
|
221
|
+
const i = n.resolve(a).fullPath;
|
|
222
|
+
if (h >= 0 && n.currentRoute.value.fullPath === i) {
|
|
223
|
+
const l = c[h], m = {
|
|
224
|
+
...l,
|
|
225
|
+
id: J("route"),
|
|
223
226
|
action: "replace",
|
|
224
|
-
direction: (
|
|
227
|
+
direction: (r == null ? void 0 : r.direction) ?? "root",
|
|
225
228
|
source: "stack",
|
|
226
|
-
entryDirection: (
|
|
229
|
+
entryDirection: (r == null ? void 0 : r.direction) ?? "root",
|
|
227
230
|
delta: void 0,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
reuse: (r == null ? void 0 : r.reuse) ?? l.reuse,
|
|
232
|
+
transition: (r == null ? void 0 : r.transition) ?? l.transition,
|
|
233
|
+
transitionDuration: (r == null ? void 0 : r.duration) ?? l.transitionDuration,
|
|
234
|
+
transitionEasing: (r == null ? void 0 : r.easing) ?? l.transitionEasing,
|
|
231
235
|
cache: !0,
|
|
232
236
|
isStackFallback: !1
|
|
233
237
|
};
|
|
234
|
-
return
|
|
238
|
+
return c.splice(0, c.length, m), h = 0, b = !0, u.value = m, Promise.resolve(void 0);
|
|
235
239
|
}
|
|
236
|
-
return
|
|
240
|
+
return p(
|
|
237
241
|
"replace",
|
|
238
|
-
(
|
|
242
|
+
(r == null ? void 0 : r.direction) ?? "root",
|
|
239
243
|
void 0,
|
|
240
|
-
|
|
244
|
+
r,
|
|
241
245
|
!0
|
|
242
|
-
),
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
router:
|
|
251
|
-
transitionDuration:
|
|
252
|
-
transitionEasing:
|
|
253
|
-
transition:
|
|
254
|
-
transitions:
|
|
255
|
-
maxStackSize:
|
|
246
|
+
), b = !0, I(a);
|
|
247
|
+
}, V = () => {
|
|
248
|
+
p("pop", "back", -1), W();
|
|
249
|
+
}, j = () => {
|
|
250
|
+
p("pop", "forward", 1), x();
|
|
251
|
+
}, e = n;
|
|
252
|
+
e.push = L, e.replace = A, e.popTo = B, e.resetRoot = _, e.back = V, e.forward = j;
|
|
253
|
+
const o = {
|
|
254
|
+
router: e,
|
|
255
|
+
transitionDuration: d,
|
|
256
|
+
transitionEasing: D,
|
|
257
|
+
transition: E,
|
|
258
|
+
transitions: y,
|
|
259
|
+
maxStackSize: w,
|
|
256
260
|
shouldTransition: t.shouldTransition,
|
|
257
261
|
current: u,
|
|
258
262
|
get history() {
|
|
259
|
-
return
|
|
263
|
+
return c;
|
|
260
264
|
},
|
|
261
|
-
canGoBack: (
|
|
262
|
-
push:
|
|
263
|
-
replace:
|
|
264
|
-
popTo:
|
|
265
|
-
resetRoot:
|
|
266
|
-
back:
|
|
267
|
-
forward:
|
|
268
|
-
},
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
},
|
|
265
|
+
canGoBack: (a = 1) => h - a >= 0,
|
|
266
|
+
push: L,
|
|
267
|
+
replace: A,
|
|
268
|
+
popTo: B,
|
|
269
|
+
resetRoot: _,
|
|
270
|
+
back: V,
|
|
271
|
+
forward: j
|
|
272
|
+
}, f = n.install.bind(n);
|
|
273
|
+
return n.install = (a) => {
|
|
274
|
+
a.provide(N, o), f(a);
|
|
275
|
+
}, e;
|
|
272
276
|
}
|
|
273
|
-
const
|
|
274
|
-
function
|
|
275
|
-
if (!
|
|
277
|
+
const re = "onPageWillEnter", Q = "onPageDidEnter", oe = "onPageWillLeave", ne = "onPageDidLeave";
|
|
278
|
+
function De(t, n, c) {
|
|
279
|
+
if (!c)
|
|
276
280
|
throw new Error(`${t} must be called inside setup().`);
|
|
277
|
-
const u =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}), u[t] =
|
|
281
|
+
const u = c.proxy, d = u[t] ?? [];
|
|
282
|
+
d.push(() => {
|
|
283
|
+
c.isUnmounted || n();
|
|
284
|
+
}), u[t] = d, c.exposed && (c.exposed[t] = d);
|
|
281
285
|
}
|
|
282
|
-
function
|
|
283
|
-
return (
|
|
286
|
+
function G(t) {
|
|
287
|
+
return (n, c = se()) => De(t, n, c);
|
|
284
288
|
}
|
|
285
|
-
const
|
|
286
|
-
function
|
|
287
|
-
const t =
|
|
289
|
+
const Be = G(re), _e = G(Q), Ve = G(oe), Fe = G(ne);
|
|
290
|
+
function Ce() {
|
|
291
|
+
const t = F(N);
|
|
288
292
|
if (!t)
|
|
289
293
|
throw new Error("useStackRouter must be used after createStackRouter().");
|
|
290
294
|
return {
|
|
@@ -298,157 +302,174 @@ function Ct() {
|
|
|
298
302
|
forward: t.forward
|
|
299
303
|
};
|
|
300
304
|
}
|
|
301
|
-
function
|
|
302
|
-
const t =
|
|
305
|
+
function ae() {
|
|
306
|
+
const t = F(N);
|
|
303
307
|
if (!t)
|
|
304
308
|
throw new Error("RouterOutlet must be used with createStackRouter().");
|
|
305
309
|
return t;
|
|
306
310
|
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
const u = n
|
|
311
|
-
Array.isArray(u) ? u.forEach((
|
|
311
|
+
function P(t, n) {
|
|
312
|
+
const c = t.value;
|
|
313
|
+
if (!c) return;
|
|
314
|
+
const u = c[n];
|
|
315
|
+
Array.isArray(u) ? u.forEach((d) => d()) : typeof u == "function" && u.call(c);
|
|
312
316
|
}
|
|
313
|
-
function
|
|
317
|
+
function S(t) {
|
|
314
318
|
t.classList.remove("rs-page-hidden", "rs-page-invisible"), t.removeAttribute("aria-hidden");
|
|
315
319
|
}
|
|
316
|
-
function
|
|
320
|
+
function q(t) {
|
|
317
321
|
t.classList.add("rs-page-hidden"), t.setAttribute("aria-hidden", "true");
|
|
318
322
|
}
|
|
319
|
-
function
|
|
320
|
-
var
|
|
321
|
-
return (
|
|
323
|
+
function ce(t) {
|
|
324
|
+
var n;
|
|
325
|
+
return (n = t.components) == null ? void 0 : n.default;
|
|
322
326
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
return
|
|
327
|
+
function Te(t) {
|
|
328
|
+
const n = ce(t);
|
|
329
|
+
return n !== void 0 && typeof n == "object" && "name" in n && n.name === "RouterView";
|
|
326
330
|
}
|
|
327
|
-
const
|
|
331
|
+
const Ge = Y({
|
|
328
332
|
name: "RouterOutlet",
|
|
329
333
|
setup() {
|
|
330
|
-
const t =
|
|
334
|
+
const t = ae(), n = me(), c = F(ye), u = F(v, void 0), d = X(() => {
|
|
331
335
|
const e = u == null ? void 0 : u.value;
|
|
332
336
|
if (!e) return 0;
|
|
333
|
-
const o =
|
|
334
|
-
(
|
|
337
|
+
const o = n.matched.findIndex(
|
|
338
|
+
(f) => f === e
|
|
335
339
|
);
|
|
336
340
|
return o >= 0 ? o + 1 : 0;
|
|
337
|
-
}),
|
|
338
|
-
for (let e =
|
|
339
|
-
const o =
|
|
340
|
-
if (!
|
|
341
|
+
}), D = X(() => n.matched[d.value]), E = X(() => {
|
|
342
|
+
for (let e = d.value; e < n.matched.length; e++) {
|
|
343
|
+
const o = n.matched[e];
|
|
344
|
+
if (!Te(o))
|
|
341
345
|
return o;
|
|
342
346
|
}
|
|
343
|
-
return
|
|
344
|
-
}),
|
|
345
|
-
let
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
o.pageElement && (o === e ?
|
|
347
|
+
return D.value;
|
|
348
|
+
}), y = te([]), w = C("");
|
|
349
|
+
let h = 0;
|
|
350
|
+
ie(v, E);
|
|
351
|
+
const s = (e) => y.value.find((o) => o.id === e), b = (e) => y.value.find((o) => o.routeIds.has(e)), p = (e) => y.value.find((o) => o.routeKey === e), H = (e) => e.action === "push" && e.direction === "forward" && !e.reuse && y.value.some((o) => o.routeKey === e.key), T = (e) => {
|
|
352
|
+
y.value.forEach((o) => {
|
|
353
|
+
o.pageElement && (o === e ? S(o.pageElement) : q(o.pageElement));
|
|
350
354
|
});
|
|
351
|
-
},
|
|
352
|
-
const o =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
}, K = (e) => {
|
|
356
|
+
const o = t.history.findIndex(
|
|
357
|
+
(a) => a.id === e.routeInfo.id
|
|
358
|
+
);
|
|
359
|
+
if (o < 0) return;
|
|
360
|
+
const f = new Set(
|
|
361
|
+
t.history.slice(0, o + 1).map((a) => a.id)
|
|
362
|
+
);
|
|
363
|
+
y.value.forEach((a) => {
|
|
364
|
+
a.routeIds = new Set(
|
|
365
|
+
[...a.routeIds].filter((r) => f.has(r))
|
|
366
|
+
);
|
|
367
|
+
}), y.value = y.value.filter(
|
|
368
|
+
(a) => a === e || a.routeIds.size > 0
|
|
369
|
+
);
|
|
370
|
+
}, $ = (e) => {
|
|
371
|
+
y.value = y.value.filter((o) => o !== e);
|
|
356
372
|
}, g = (e) => {
|
|
357
373
|
const o = new Set(
|
|
358
|
-
t.history.map((
|
|
374
|
+
t.history.map((f) => f.id)
|
|
359
375
|
);
|
|
360
|
-
|
|
361
|
-
|
|
376
|
+
y.value.forEach((f) => {
|
|
377
|
+
f.routeIds = new Set(
|
|
378
|
+
[...f.routeIds].filter((a) => o.has(a))
|
|
379
|
+
);
|
|
380
|
+
}), y.value = y.value.filter(
|
|
381
|
+
(f) => f === e || f.routeInfo.cache && f.routeIds.size > 0
|
|
362
382
|
);
|
|
363
|
-
},
|
|
364
|
-
var
|
|
383
|
+
}, I = (e) => {
|
|
384
|
+
var f;
|
|
365
385
|
const o = e.props.default;
|
|
366
|
-
return o ? o === !0 ? ((
|
|
367
|
-
},
|
|
368
|
-
var
|
|
369
|
-
const
|
|
370
|
-
return ((
|
|
386
|
+
return o ? o === !0 ? ((f = t.current.value) == null ? void 0 : f.params) ?? {} : typeof o == "function" ? o(c) : o : {};
|
|
387
|
+
}, W = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transition ?? e.routeInfo.transition ?? t.transition : e.routeInfo.transition ?? t.transition, x = (e) => e.entryDirection === "none" || e.entryDirection === "root" || e.transition === "none", z = (e, o) => !(e.routeInfo.isStackFallback || e.routeInfo.direction === "none" || e.routeInfo.direction === "root" || e.routeInfo.action === "pop" && (x(e.routeInfo) || x(o.routeInfo))), L = (e, o) => {
|
|
388
|
+
var a;
|
|
389
|
+
const f = z(e, o);
|
|
390
|
+
return ((a = t.shouldTransition) == null ? void 0 : a.call(t, {
|
|
371
391
|
action: e.routeInfo.action,
|
|
372
392
|
direction: e.routeInfo.direction,
|
|
373
393
|
source: e.routeInfo.source,
|
|
374
394
|
entering: e.routeInfo,
|
|
375
395
|
leaving: o.routeInfo,
|
|
376
|
-
defaultResult:
|
|
377
|
-
})) ??
|
|
378
|
-
},
|
|
379
|
-
const
|
|
380
|
-
await
|
|
381
|
-
const
|
|
382
|
-
if (!
|
|
383
|
-
if (
|
|
384
|
-
|
|
396
|
+
defaultResult: f
|
|
397
|
+
})) ?? f;
|
|
398
|
+
}, A = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionDuration ?? e.routeInfo.transitionDuration ?? t.transitionDuration : e.routeInfo.transitionDuration ?? t.transitionDuration, B = (e, o) => e.routeInfo.action === "pop" ? o.routeInfo.transitionEasing ?? e.routeInfo.transitionEasing ?? t.transitionEasing : e.routeInfo.transitionEasing ?? t.transitionEasing, _ = async (e, o) => {
|
|
399
|
+
const f = ++h;
|
|
400
|
+
await de();
|
|
401
|
+
const a = e.pageElement;
|
|
402
|
+
if (!a) return;
|
|
403
|
+
if (P(e.componentRef, re), !o || o === e || !o.pageElement) {
|
|
404
|
+
S(a), P(e.componentRef, Q), g(e), T(e);
|
|
385
405
|
return;
|
|
386
406
|
}
|
|
387
|
-
const
|
|
388
|
-
|
|
407
|
+
const r = o.pageElement, i = L(e, o), l = i ? W(e, o) : "none", m = i ? A(e, o) : 0, R = B(e, o), U = Ie(
|
|
408
|
+
l || Z,
|
|
389
409
|
t.transitions
|
|
390
410
|
);
|
|
391
|
-
|
|
411
|
+
P(o.componentRef, oe), S(a), S(r), await Pe(U, {
|
|
392
412
|
direction: e.routeInfo.direction,
|
|
393
413
|
action: e.routeInfo.action,
|
|
394
414
|
routeInfo: e.routeInfo,
|
|
395
|
-
enteringElement:
|
|
396
|
-
leavingElement:
|
|
397
|
-
duration:
|
|
398
|
-
easing:
|
|
399
|
-
}),
|
|
400
|
-
},
|
|
401
|
-
const e =
|
|
415
|
+
enteringElement: a,
|
|
416
|
+
leavingElement: r,
|
|
417
|
+
duration: m,
|
|
418
|
+
easing: R
|
|
419
|
+
}), f === h && (q(r), P(o.componentRef, ne), P(e.componentRef, Q), e.routeInfo.action === "pop" ? K(e) : e.routeInfo.action === "replace" && $(o), g(e), T(e));
|
|
420
|
+
}, V = async () => {
|
|
421
|
+
const e = E.value, o = t.current.value;
|
|
402
422
|
if (!e || !o) return;
|
|
403
|
-
const
|
|
404
|
-
if (!
|
|
405
|
-
const
|
|
406
|
-
let
|
|
407
|
-
p ? (
|
|
408
|
-
id:
|
|
409
|
-
|
|
423
|
+
const f = ce(e);
|
|
424
|
+
if (!f) return;
|
|
425
|
+
const a = s(w.value);
|
|
426
|
+
let r = b(o.id);
|
|
427
|
+
!r && !H(o) && (r = p(o.key)), r ? (r.routeIds.add(o.id), r.routeKey = o.key, r.routeInfo = o, r.matchedRoute = e, r.component = f, r.props = I(e), r.mounted = !0) : (r = {
|
|
428
|
+
id: J("view"),
|
|
429
|
+
routeKey: o.key,
|
|
430
|
+
routeIds: /* @__PURE__ */ new Set([o.id]),
|
|
410
431
|
routeInfo: o,
|
|
411
432
|
matchedRoute: e,
|
|
412
|
-
component:
|
|
413
|
-
props:
|
|
433
|
+
component: f,
|
|
434
|
+
props: I(e),
|
|
414
435
|
componentRef: C(),
|
|
415
436
|
mounted: !0
|
|
416
|
-
},
|
|
437
|
+
}, y.value = [...y.value, r]), w.value = r.id, await _(r, a);
|
|
417
438
|
};
|
|
418
|
-
return
|
|
439
|
+
return ue(
|
|
419
440
|
() => {
|
|
420
441
|
var e;
|
|
421
|
-
return [(e = t.current.value) == null ? void 0 : e.id,
|
|
442
|
+
return [(e = t.current.value) == null ? void 0 : e.id, E.value];
|
|
422
443
|
},
|
|
423
444
|
() => {
|
|
424
|
-
|
|
445
|
+
V();
|
|
425
446
|
},
|
|
426
447
|
{ immediate: !0 }
|
|
427
|
-
),
|
|
428
|
-
|
|
448
|
+
), le(() => {
|
|
449
|
+
h++, y.value = [];
|
|
429
450
|
}), {
|
|
430
|
-
injectedRoute:
|
|
431
|
-
viewItems:
|
|
451
|
+
injectedRoute: c,
|
|
452
|
+
viewItems: y,
|
|
432
453
|
registerStackPage: (e, o) => {
|
|
433
|
-
e.pageElement = o, e.
|
|
454
|
+
e.pageElement = o, e.id === w.value ? S(o) : q(o);
|
|
434
455
|
}
|
|
435
456
|
};
|
|
436
457
|
},
|
|
437
458
|
render() {
|
|
438
|
-
return
|
|
459
|
+
return k(
|
|
439
460
|
"div",
|
|
440
461
|
{ class: "rs-outlet" },
|
|
441
462
|
this.viewItems.filter((t) => t.mounted).map(
|
|
442
|
-
(t) =>
|
|
463
|
+
(t) => k(t.component, {
|
|
443
464
|
key: t.id,
|
|
444
465
|
ref: t.componentRef,
|
|
445
466
|
...t.props,
|
|
446
|
-
registerStackPage: (
|
|
467
|
+
registerStackPage: (n) => this.registerStackPage(t, n)
|
|
447
468
|
})
|
|
448
469
|
)
|
|
449
470
|
);
|
|
450
471
|
}
|
|
451
|
-
}),
|
|
472
|
+
}), He = Y({
|
|
452
473
|
name: "RouterPage",
|
|
453
474
|
props: {
|
|
454
475
|
registerStackPage: {
|
|
@@ -456,25 +477,25 @@ const Ht = Q({
|
|
|
456
477
|
default: void 0
|
|
457
478
|
}
|
|
458
479
|
},
|
|
459
|
-
setup(t, { attrs:
|
|
480
|
+
setup(t, { attrs: n, slots: c }) {
|
|
460
481
|
const u = C();
|
|
461
|
-
return
|
|
462
|
-
var
|
|
463
|
-
u.value && ((
|
|
482
|
+
return fe(() => {
|
|
483
|
+
var d;
|
|
484
|
+
u.value && ((d = t.registerStackPage) == null || d.call(t, u.value));
|
|
464
485
|
}), () => {
|
|
465
|
-
var
|
|
466
|
-
return
|
|
486
|
+
var d;
|
|
487
|
+
return k(
|
|
467
488
|
"section",
|
|
468
489
|
{
|
|
469
|
-
...
|
|
490
|
+
...n,
|
|
470
491
|
ref: u,
|
|
471
|
-
class: ["rs-page",
|
|
492
|
+
class: ["rs-page", n.class]
|
|
472
493
|
},
|
|
473
|
-
(
|
|
494
|
+
(d = c.default) == null ? void 0 : d.call(c)
|
|
474
495
|
);
|
|
475
496
|
};
|
|
476
497
|
}
|
|
477
|
-
}),
|
|
498
|
+
}), Ke = Y({
|
|
478
499
|
name: "StackRouterDebugPanel",
|
|
479
500
|
props: {
|
|
480
501
|
initialOpen: {
|
|
@@ -483,52 +504,52 @@ const Ht = Q({
|
|
|
483
504
|
}
|
|
484
505
|
},
|
|
485
506
|
setup(t) {
|
|
486
|
-
const
|
|
507
|
+
const n = ae(), c = C(t.initialOpen);
|
|
487
508
|
return () => {
|
|
488
|
-
const u =
|
|
489
|
-
return
|
|
490
|
-
|
|
509
|
+
const u = n.current.value;
|
|
510
|
+
return k("aside", { class: "rs-debug-panel" }, [
|
|
511
|
+
k(
|
|
491
512
|
"button",
|
|
492
513
|
{
|
|
493
514
|
class: "rs-debug-toggle",
|
|
494
515
|
type: "button",
|
|
495
516
|
onClick: () => {
|
|
496
|
-
|
|
517
|
+
c.value = !c.value;
|
|
497
518
|
}
|
|
498
519
|
},
|
|
499
|
-
|
|
520
|
+
c.value ? "Stack x" : "Stack"
|
|
500
521
|
),
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
522
|
+
c.value ? k("section", { class: "rs-debug-body" }, [
|
|
523
|
+
k("header", [
|
|
524
|
+
k("strong", "Router Stack"),
|
|
525
|
+
k("span", `${n.history.length} pages`)
|
|
505
526
|
]),
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
527
|
+
k("dl", [
|
|
528
|
+
k("dt", "current"),
|
|
529
|
+
k("dd", (u == null ? void 0 : u.fullPath) ?? "-"),
|
|
530
|
+
k("dt", "canGoBack"),
|
|
531
|
+
k("dd", String(n.canGoBack()))
|
|
511
532
|
]),
|
|
512
|
-
|
|
533
|
+
k(
|
|
513
534
|
"ol",
|
|
514
|
-
|
|
515
|
-
(
|
|
535
|
+
n.history.map(
|
|
536
|
+
(d) => k(
|
|
516
537
|
"li",
|
|
517
538
|
{
|
|
518
|
-
key:
|
|
539
|
+
key: d.id,
|
|
519
540
|
class: {
|
|
520
|
-
"rs-debug-active":
|
|
521
|
-
"rs-debug-no-cache": !
|
|
541
|
+
"rs-debug-active": d.id === (u == null ? void 0 : u.id),
|
|
542
|
+
"rs-debug-no-cache": !d.cache
|
|
522
543
|
}
|
|
523
544
|
},
|
|
524
545
|
[
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
`${
|
|
528
|
-
` source:${
|
|
529
|
-
` entry:${
|
|
530
|
-
` cache:${
|
|
531
|
-
` transition:${
|
|
546
|
+
k("code", d.fullPath),
|
|
547
|
+
k("span", [
|
|
548
|
+
`${d.action}/${d.direction}`,
|
|
549
|
+
` source:${d.source}`,
|
|
550
|
+
` entry:${d.entryDirection}`,
|
|
551
|
+
` cache:${d.cache ? "yes" : "no"}`,
|
|
552
|
+
` transition:${d.transition ?? "-"}`
|
|
532
553
|
])
|
|
533
554
|
]
|
|
534
555
|
)
|
|
@@ -540,22 +561,22 @@ const Ht = Q({
|
|
|
540
561
|
}
|
|
541
562
|
});
|
|
542
563
|
export {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
564
|
+
ze as RouterLink,
|
|
565
|
+
Ge as RouterOutlet,
|
|
566
|
+
He as RouterPage,
|
|
567
|
+
je as RouterView,
|
|
568
|
+
Ke as StackRouterDebugPanel,
|
|
569
|
+
Ue as createMemoryHistory,
|
|
570
|
+
Ae as createStackRouter,
|
|
571
|
+
Xe as createWebHashHistory,
|
|
572
|
+
Me as createWebHistory,
|
|
573
|
+
Le as defineStackTransition,
|
|
574
|
+
_e as onPageDidEnter,
|
|
575
|
+
Fe as onPageDidLeave,
|
|
576
|
+
Be as onPageWillEnter,
|
|
577
|
+
Ve as onPageWillLeave,
|
|
578
|
+
N as stackRouterKey,
|
|
579
|
+
qe as useRoute,
|
|
580
|
+
Je as useRouter,
|
|
581
|
+
Ce as useStackRouter
|
|
561
582
|
};
|