@lazycatcloud/vue-router-stack 0.0.4 → 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/router/types.d.ts +3 -0
- package/dist/vue-router-stack.cjs +1 -1
- package/dist/vue-router-stack.js +323 -307
- 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
|
|
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"),R=require("vue-router"),Q={};function U(t="route"){const n=(Q[t]??0)+1;return Q[t]=n,`${t}-${n}`}const J="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 a=n[t];return a||n[J]}function Y(t,n,a){if(!n||!t.animate||Number(a.duration)<=0)return Promise.resolve();const l=t.animate(n,a);return l.finished.then(()=>l.cancel())}async function le(t,n){const a=t(n),l={duration:n.duration,easing:n.easing,fill:"both",...a.options};await Promise.all([Y(n.enteringElement,a.entering,l),Y(n.leavingElement,a.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 M(t,n){return n||(t==="pop"?"back":t==="replace"?"none":"forward")}function fe(t){const n=R.createRouter(t),a=[],l=i.shallowRef(),d=t.transitionDuration??210,D=t.transitionEasing??re,E=t.transition??J,k={...se,...t.transitions},P=t.maxStackSize??30;let m=-1,u,w=!1;const b=(c,r,s,f,y=!1,p="stack")=>{u={action:c,direction:M(c,r),source:p,delta:s,transition:f==null?void 0:f.transition,duration:f==null?void 0:f.duration,easing:f==null?void 0:f.easing,resetRoot:y}},F=(c,r)=>{const s=(u==null?void 0:u.action)??"push",f=M(s,u==null?void 0:u.direction),y=l.value,p=s==="push"&&f==="forward",z=T(c);return{id:U("route"),key:c.fullPath,fullPath:c.fullPath,pathname:c.path,params:c.params,query:c.query,action:s,direction:f,source:(u==null?void 0:u.source)??"stack",entryDirection:f,lastPathname:(y==null?void 0:y.pathname)||(r.name?r.path:void 0),pushedByRoute:p?y==null?void 0:y.pathname:y==null?void 0:y.pushedByRoute,position:de(),delta:u==null?void 0:u.delta,transition:(u==null?void 0:u.transition)??E,transitionDuration:(u==null?void 0:u.duration)??d,transitionEasing:(u==null?void 0:u.easing)??D,cache:z}},T=c=>{const r=c.meta.stack;return c.meta.stackCache!==!1&&(r==null?void 0:r.cache)!==!1},K=()=>{if(P<=0||a.length<=P)return;const c=a.length-P;a.splice(0,c),m=Math.max(0,m-c)},W=c=>{if(c.action==="pop"){let r=-1;if(c.direction==="forward"||(c.delta??0)>0){for(let s=m+1;s<a.length;s++)if(a[s].key===c.key){r=s;break}}else for(let s=m-1;s>=0;s--)if(a[s].key===c.key){r=s;break}if(r>=0){const s=a[r];a[r]={...s,...c,id:s.id,source:c.source,entryDirection:s.entryDirection,transition:s.transition,transitionDuration:s.transitionDuration,transitionEasing:s.transitionEasing},m=r}else a.push({...c,direction:"none",entryDirection:"none",transition:"none",isStackFallback:!0}),m=a.length-1}else if(c.action==="replace"){if(u!=null&&u.resetRoot){a.splice(0,a.length,c),m=0,l.value=a[m];return}m>=0?a[m]=c:(a.push(c),m=0)}else m<a.length-1&&a.splice(m+1),a.push(c),m=a.length-1;K(),l.value=a[m]};t.history.listen((c,r,s)=>{const f="delta"in s?s.delta:void 0,y=s.direction==="back"?"back":s.direction==="forward"?"forward":void 0;u?(u.delta=f,u.direction=M(u.action,u.direction??y)):b(s.type==="pop"?"pop":s.type,y,f,void 0,!1,"external")}),n.beforeEach(c=>!((u==null?void 0:u.action)==="pop"&&w&&!a.some(r=>r.fullPath===c.fullPath))),n.afterEach((c,r,s)=>{if(s){u=void 0;return}W(F(c,r)),u=void 0});const L=n.push.bind(n),S=n.replace.bind(n),G=n.back.bind(n),x=n.forward.bind(n),$=n.go.bind(n),A=(c,r)=>(b("push",(r==null?void 0:r.direction)??"forward",void 0,r),L(c)),j=(c,r)=>(b("replace",(r==null?void 0:r.direction)??"root",void 0,r),S(c)),B=(c,r)=>{const s=n.resolve(c).fullPath;let f=-1;for(let p=m;p>=0;p--)if(a[p].fullPath===s){f=p;break}if(f<0)return!1;const y=f-m;return y===0||(b("pop",(r==null?void 0:r.direction)??"back",y,r),$(y)),!0},V=(c,r)=>{const s=n.resolve(c).fullPath;if(m>=0&&n.currentRoute.value.fullPath===s){const f=a[m],y={...f,id:U("route"),action:"replace",direction:(r==null?void 0:r.direction)??"root",source:"stack",entryDirection:(r==null?void 0:r.direction)??"root",delta:void 0,transition:(r==null?void 0:r.transition)??f.transition,transitionDuration:(r==null?void 0:r.duration)??f.transitionDuration,transitionEasing:(r==null?void 0:r.easing)??f.transitionEasing,cache:!0,isStackFallback:!1};return a.splice(0,a.length,y),m=0,w=!0,l.value=y,Promise.resolve(void 0)}return b("replace",(r==null?void 0:r.direction)??"root",void 0,r,!0),w=!0,S(c)},_=()=>{b("pop","back",-1),G()},v=()=>{b("pop","forward",1),x()},e=n;e.push=A,e.replace=j,e.popTo=B,e.resetRoot=V,e.back=_,e.forward=v;const o={router:e,transitionDuration:d,transitionEasing:D,transition:E,transitions:k,maxStackSize:P,shouldTransition:t.shouldTransition,current:l,get history(){return a},canGoBack:(c=1)=>m-c>=0,push:A,replace:j,popTo:B,resetRoot:V,back:_,forward:v},h=n.install.bind(n);return n.install=c=>{c.provide(H,o),h(c)},e}const Z="onPageWillEnter",X="onPageDidEnter",N="onPageWillLeave",O="onPageDidLeave";function he(t,n,a){if(!a)throw new Error(`${t} must be called inside setup().`);const l=a.proxy,d=l[t]??[];d.push(()=>{a.isUnmounted||n()}),l[t]=d,a.exposed&&(a.exposed[t]=d)}function C(t){return(n,a=i.getCurrentInstance())=>he(t,n,a)}const me=C(Z),ye=C(X),ke=C(N),Re=C(O);function pe(){const t=i.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=i.inject(H);if(!t)throw new Error("RouterOutlet must be used with createStackRouter().");return t}function I(t,n){const a=t.value;if(!a)return;const l=a[n];Array.isArray(l)?l.forEach(d=>d()):typeof l=="function"&&l.call(a)}function g(t){t.classList.remove("rs-page-hidden","rs-page-invisible"),t.removeAttribute("aria-hidden")}function q(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 be(t){const n=te(t);return n!==void 0&&typeof n=="object"&&"name"in n&&n.name==="RouterView"}const Pe=i.defineComponent({name:"RouterOutlet",setup(){const t=ee(),n=R.useRoute(),a=i.inject(R.routeLocationKey),l=i.inject(R.matchedRouteKey,void 0),d=i.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}),D=i.computed(()=>n.matched[d.value]),E=i.computed(()=>{for(let e=d.value;e<n.matched.length;e++){const o=n.matched[e];if(!be(o))return o}return D.value}),k=i.shallowRef([]),P=i.ref("");let m=0;i.provide(R.matchedRouteKey,E);const u=e=>k.value.find(o=>o.id===e),w=e=>k.value.find(o=>o.routeIds.has(e)),b=e=>k.value.find(o=>o.routeKey===e),F=e=>e.action==="push"&&e.direction==="forward"&&k.value.some(o=>o.routeKey===e.key),T=e=>{k.value.forEach(o=>{o.pageElement&&(o===e?g(o.pageElement):q(o.pageElement))})},K=e=>{const o=k.value.findIndex(h=>h===e);o>=0&&(k.value=k.value.slice(0,o+1))},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(c=>o.has(c)))}),k.value=k.value.filter(h=>h===e||h.routeInfo.cache&&h.routeIds.size>0)},S=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(a):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 c;const h=$(e,o);return((c=t.shouldTransition)==null?void 0:c.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 i.nextTick();const c=e.pageElement;if(!c)return;if(I(e.componentRef,Z),!o||o===e||!o.pageElement){g(c),I(e.componentRef,X),L(e),T(e);return}const r=o.pageElement,s=A(e,o),f=s?G(e,o):"none",y=s?j(e,o):0,p=B(e,o),z=ue(f||J,t.transitions);I(o.componentRef,N),g(c),g(r),await le(z,{direction:e.routeInfo.direction,action:e.routeInfo.action,routeInfo:e.routeInfo,enteringElement:c,leavingElement:r,duration:y,easing:p}),h===m&&(q(r),I(o.componentRef,O),I(e.componentRef,X),e.routeInfo.action==="pop"?K(e):e.routeInfo.action==="replace"&&W(o),L(e),T(e))},_=async()=>{const e=E.value,o=t.current.value;if(!e||!o)return;const h=te(e);if(!h)return;const c=u(P.value);let r=w(o.id);!r&&!F(o)&&(r=b(o.key)),r?(r.routeIds.add(o.id),r.routeKey=o.key,r.routeInfo=o,r.matchedRoute=e,r.component=h,r.props=S(e),r.mounted=!0):(r={id:U("view"),routeKey:o.key,routeIds:new Set([o.id]),routeInfo:o,matchedRoute:e,component:h,props:S(e),componentRef:i.ref(),mounted:!0},k.value=[...k.value,r]),P.value=r.id,await V(r,c)};return i.watch(()=>{var e;return[(e=t.current.value)==null?void 0:e.id,E.value]},()=>{_()},{immediate:!0}),i.onUnmounted(()=>{m++,k.value=[]}),{injectedRoute:a,viewItems:k,registerStackPage:(e,o)=>{e.pageElement=o,e.id===P.value?g(o):q(o)}}},render(){return i.h("div",{class:"rs-outlet"},this.viewItems.filter(t=>t.mounted).map(t=>i.h(t.component,{key:t.id,ref:t.componentRef,...t.props,registerStackPage:n=>this.registerStackPage(t,n)})))}}),Ee=i.defineComponent({name:"RouterPage",props:{registerStackPage:{type:Function,default:void 0}},setup(t,{attrs:n,slots:a}){const l=i.ref();return i.onMounted(()=>{var d;l.value&&((d=t.registerStackPage)==null||d.call(t,l.value))}),()=>{var d;return i.h("section",{...n,ref:l,class:["rs-page",n.class]},(d=a.default)==null?void 0:d.call(a))}}}),we=i.defineComponent({name:"StackRouterDebugPanel",props:{initialOpen:{type:Boolean,default:!1}},setup(t){const n=ee(),a=i.ref(t.initialOpen);return()=>{const l=n.current.value;return i.h("aside",{class:"rs-debug-panel"},[i.h("button",{class:"rs-debug-toggle",type:"button",onClick:()=>{a.value=!a.value}},a.value?"Stack x":"Stack"),a.value?i.h("section",{class:"rs-debug-body"},[i.h("header",[i.h("strong","Router Stack"),i.h("span",`${n.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(n.canGoBack()))]),i.h("ol",n.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:()=>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=Ee;exports.StackRouterDebugPanel=we;exports.createStackRouter=fe;exports.defineStackTransition=oe;exports.onPageDidEnter=ye;exports.onPageDidLeave=Re;exports.onPageWillEnter=me;exports.onPageWillLeave=ke;exports.stackRouterKey=H;exports.useStackRouter=pe;
|
|
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
|
|
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
4
|
const O = {};
|
|
5
|
-
function
|
|
6
|
-
const n = (O[
|
|
7
|
-
return 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
|
|
11
|
-
return
|
|
9
|
+
const Z = "slide", ke = "cubic-bezier(0.3, 0, 0.66, 1)";
|
|
10
|
+
function Le(t) {
|
|
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,11 +20,11 @@ const pt = ({ direction: e }) => e === "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 n =
|
|
26
|
+
}), we = ({ direction: t }) => {
|
|
27
|
+
const n = t === "back";
|
|
28
28
|
return {
|
|
29
29
|
entering: n ? [
|
|
30
30
|
{ transform: "scale(0.98)", opacity: 0 },
|
|
@@ -41,224 +41,228 @@ const pt = ({ direction: e }) => e === "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 (!n || !
|
|
54
|
+
function ee(t, n, c) {
|
|
55
|
+
if (!n || !t.animate || Number(c.duration) <= 0)
|
|
56
56
|
return Promise.resolve();
|
|
57
|
-
const u =
|
|
57
|
+
const u = t.animate(n, c);
|
|
58
58
|
return u.finished.then(() => u.cancel());
|
|
59
59
|
}
|
|
60
|
-
async function
|
|
61
|
-
const
|
|
60
|
+
async function Pe(t, n) {
|
|
61
|
+
const c = t(n), u = {
|
|
62
62
|
duration: n.duration,
|
|
63
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
|
|
74
|
-
const
|
|
75
|
-
return typeof (
|
|
72
|
+
const N = Symbol("stack-router");
|
|
73
|
+
function Se() {
|
|
74
|
+
const t = window.history.state;
|
|
75
|
+
return typeof (t == null ? void 0 : t.position) == "number" ? t.position : window.history.length;
|
|
76
76
|
}
|
|
77
|
-
function M(
|
|
78
|
-
return n || (
|
|
77
|
+
function M(t, n) {
|
|
78
|
+
return n || (t === "pop" ? "back" : t === "replace" ? "none" : "forward");
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
const n =
|
|
82
|
-
...
|
|
83
|
-
...
|
|
84
|
-
},
|
|
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
|
+
...t.transitions
|
|
84
|
+
}, w = t.maxStackSize ?? 30;
|
|
85
85
|
let h = -1, s, b = !1;
|
|
86
|
-
const
|
|
86
|
+
const p = (a, r, i, l, m = !1, R = "stack") => {
|
|
87
87
|
s = {
|
|
88
|
-
action:
|
|
89
|
-
direction: M(
|
|
90
|
-
source:
|
|
88
|
+
action: a,
|
|
89
|
+
direction: M(a, r),
|
|
90
|
+
source: R,
|
|
91
91
|
delta: i,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
}, H = (
|
|
98
|
-
const i = (s == null ? void 0 : s.action) ?? "push",
|
|
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:
|
|
101
|
+
id: J("route"),
|
|
102
|
+
key: a.fullPath,
|
|
103
|
+
fullPath: a.fullPath,
|
|
104
|
+
pathname: a.path,
|
|
105
|
+
params: a.params,
|
|
106
|
+
query: a.query,
|
|
106
107
|
action: i,
|
|
107
|
-
direction:
|
|
108
|
+
direction: l,
|
|
109
|
+
reuse: (s == null ? void 0 : s.reuse) ?? !1,
|
|
108
110
|
source: (s == null ? void 0 : s.source) ?? "stack",
|
|
109
|
-
entryDirection:
|
|
110
|
-
lastPathname: (m == null ? void 0 : m.pathname) || (
|
|
111
|
-
pushedByRoute:
|
|
112
|
-
position:
|
|
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(),
|
|
113
115
|
delta: s == null ? void 0 : s.delta,
|
|
114
|
-
transition: (s == null ? void 0 : s.transition) ??
|
|
115
|
-
transitionDuration: (s == null ? void 0 : s.duration) ??
|
|
116
|
+
transition: (s == null ? void 0 : s.transition) ?? E,
|
|
117
|
+
transitionDuration: (s == null ? void 0 : s.duration) ?? d,
|
|
116
118
|
transitionEasing: (s == null ? void 0 : s.easing) ?? D,
|
|
117
119
|
cache: U
|
|
118
120
|
};
|
|
119
|
-
}, T = (
|
|
120
|
-
const
|
|
121
|
-
return
|
|
121
|
+
}, T = (a) => {
|
|
122
|
+
const r = a.meta.stack;
|
|
123
|
+
return a.meta.stackCache !== !1 && (r == null ? void 0 : r.cache) !== !1;
|
|
122
124
|
}, K = () => {
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
}, $ = (
|
|
127
|
-
if (
|
|
128
|
-
let
|
|
129
|
-
if (
|
|
130
|
-
for (let i = h + 1; i <
|
|
131
|
-
if (
|
|
132
|
-
|
|
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
138
|
for (let i = h - 1; i >= 0; i--)
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
+
if (c[i].key === a.key) {
|
|
140
|
+
r = i;
|
|
139
141
|
break;
|
|
140
142
|
}
|
|
141
|
-
if (
|
|
142
|
-
const i =
|
|
143
|
-
|
|
143
|
+
if (r >= 0) {
|
|
144
|
+
const i = c[r];
|
|
145
|
+
c[r] = {
|
|
144
146
|
...i,
|
|
145
|
-
...
|
|
147
|
+
...a,
|
|
146
148
|
id: i.id,
|
|
147
|
-
|
|
149
|
+
reuse: i.reuse,
|
|
150
|
+
source: a.source,
|
|
148
151
|
entryDirection: i.entryDirection,
|
|
149
152
|
transition: i.transition,
|
|
150
153
|
transitionDuration: i.transitionDuration,
|
|
151
154
|
transitionEasing: i.transitionEasing
|
|
152
|
-
}, h =
|
|
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
|
-
}), h =
|
|
161
|
-
} else if (
|
|
163
|
+
}), h = c.length - 1;
|
|
164
|
+
} else if (a.action === "replace") {
|
|
162
165
|
if (s != null && s.resetRoot) {
|
|
163
|
-
|
|
166
|
+
c.splice(0, c.length, a), h = 0, u.value = c[h];
|
|
164
167
|
return;
|
|
165
168
|
}
|
|
166
|
-
h >= 0 ?
|
|
169
|
+
h >= 0 ? c[h] = a : (c.push(a), h = 0);
|
|
167
170
|
} else
|
|
168
|
-
h <
|
|
169
|
-
K(), u.value =
|
|
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
|
-
|
|
172
|
-
const
|
|
173
|
-
s ? (s.delta =
|
|
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(
|
|
174
177
|
s.action,
|
|
175
178
|
s.direction ?? m
|
|
176
|
-
)) :
|
|
179
|
+
)) : p(
|
|
177
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
|
-
}), n.beforeEach((
|
|
187
|
+
}), n.beforeEach((a) => !((s == null ? void 0 : s.action) === "pop" && b && !c.some((r) => r.fullPath === a.fullPath))), n.afterEach((a, r, i) => {
|
|
185
188
|
if (i) {
|
|
186
189
|
s = void 0;
|
|
187
190
|
return;
|
|
188
191
|
}
|
|
189
|
-
$(H(
|
|
192
|
+
$(H(a, r)), s = void 0;
|
|
190
193
|
});
|
|
191
|
-
const g = n.push.bind(n),
|
|
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
|
-
), g(
|
|
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 i = n.resolve(
|
|
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
|
-
|
|
218
|
+
r
|
|
216
219
|
), z(m)), !0;
|
|
217
|
-
}, _ = (
|
|
218
|
-
const i = n.resolve(
|
|
220
|
+
}, _ = (a, r) => {
|
|
221
|
+
const i = n.resolve(a).fullPath;
|
|
219
222
|
if (h >= 0 && n.currentRoute.value.fullPath === i) {
|
|
220
|
-
const
|
|
221
|
-
...
|
|
222
|
-
id:
|
|
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
|
-
), b = !0,
|
|
246
|
+
), b = !0, I(a);
|
|
243
247
|
}, V = () => {
|
|
244
|
-
|
|
248
|
+
p("pop", "back", -1), W();
|
|
245
249
|
}, j = () => {
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
router:
|
|
251
|
-
transitionDuration:
|
|
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,
|
|
252
256
|
transitionEasing: D,
|
|
253
|
-
transition:
|
|
257
|
+
transition: E,
|
|
254
258
|
transitions: y,
|
|
255
|
-
maxStackSize:
|
|
256
|
-
shouldTransition:
|
|
259
|
+
maxStackSize: w,
|
|
260
|
+
shouldTransition: t.shouldTransition,
|
|
257
261
|
current: u,
|
|
258
262
|
get history() {
|
|
259
|
-
return
|
|
263
|
+
return c;
|
|
260
264
|
},
|
|
261
|
-
canGoBack: (
|
|
265
|
+
canGoBack: (a = 1) => h - a >= 0,
|
|
262
266
|
push: L,
|
|
263
267
|
replace: A,
|
|
264
268
|
popTo: B,
|
|
@@ -266,176 +270,188 @@ function At(e) {
|
|
|
266
270
|
back: V,
|
|
267
271
|
forward: j
|
|
268
272
|
}, f = n.install.bind(n);
|
|
269
|
-
return n.install = (
|
|
270
|
-
|
|
271
|
-
},
|
|
273
|
+
return n.install = (a) => {
|
|
274
|
+
a.provide(N, o), f(a);
|
|
275
|
+
}, e;
|
|
272
276
|
}
|
|
273
|
-
const
|
|
274
|
-
function
|
|
275
|
-
if (!
|
|
276
|
-
throw new Error(`${
|
|
277
|
-
const u =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}), u[
|
|
277
|
+
const re = "onPageWillEnter", Q = "onPageDidEnter", oe = "onPageWillLeave", ne = "onPageDidLeave";
|
|
278
|
+
function De(t, n, c) {
|
|
279
|
+
if (!c)
|
|
280
|
+
throw new Error(`${t} must be called inside setup().`);
|
|
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 G(
|
|
283
|
-
return (n,
|
|
286
|
+
function G(t) {
|
|
287
|
+
return (n, c = se()) => De(t, n, c);
|
|
284
288
|
}
|
|
285
|
-
const
|
|
286
|
-
function
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
289
|
+
const Be = G(re), _e = G(Q), Ve = G(oe), Fe = G(ne);
|
|
290
|
+
function Ce() {
|
|
291
|
+
const t = F(N);
|
|
292
|
+
if (!t)
|
|
289
293
|
throw new Error("useStackRouter must be used after createStackRouter().");
|
|
290
294
|
return {
|
|
291
|
-
router:
|
|
292
|
-
canGoBack:
|
|
293
|
-
push:
|
|
294
|
-
replace:
|
|
295
|
-
popTo:
|
|
296
|
-
resetRoot:
|
|
297
|
-
back:
|
|
298
|
-
forward:
|
|
295
|
+
router: t.router,
|
|
296
|
+
canGoBack: t.canGoBack,
|
|
297
|
+
push: t.push,
|
|
298
|
+
replace: t.replace,
|
|
299
|
+
popTo: t.popTo,
|
|
300
|
+
resetRoot: t.resetRoot,
|
|
301
|
+
back: t.back,
|
|
302
|
+
forward: t.forward
|
|
299
303
|
};
|
|
300
304
|
}
|
|
301
|
-
function
|
|
302
|
-
const
|
|
303
|
-
if (!
|
|
305
|
+
function ae() {
|
|
306
|
+
const t = F(N);
|
|
307
|
+
if (!t)
|
|
304
308
|
throw new Error("RouterOutlet must be used with createStackRouter().");
|
|
305
|
-
return
|
|
309
|
+
return t;
|
|
306
310
|
}
|
|
307
|
-
function
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
const u =
|
|
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 S(
|
|
314
|
-
|
|
317
|
+
function S(t) {
|
|
318
|
+
t.classList.remove("rs-page-hidden", "rs-page-invisible"), t.removeAttribute("aria-hidden");
|
|
315
319
|
}
|
|
316
|
-
function q(
|
|
317
|
-
|
|
320
|
+
function q(t) {
|
|
321
|
+
t.classList.add("rs-page-hidden"), t.setAttribute("aria-hidden", "true");
|
|
318
322
|
}
|
|
319
|
-
function
|
|
323
|
+
function ce(t) {
|
|
320
324
|
var n;
|
|
321
|
-
return (n =
|
|
325
|
+
return (n = t.components) == null ? void 0 : n.default;
|
|
322
326
|
}
|
|
323
|
-
function
|
|
324
|
-
const n =
|
|
327
|
+
function Te(t) {
|
|
328
|
+
const n = ce(t);
|
|
325
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
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
333
|
-
const
|
|
334
|
-
(f) => f ===
|
|
334
|
+
const t = ae(), n = me(), c = F(ye), u = F(v, void 0), d = X(() => {
|
|
335
|
+
const e = u == null ? void 0 : u.value;
|
|
336
|
+
if (!e) return 0;
|
|
337
|
+
const o = n.matched.findIndex(
|
|
338
|
+
(f) => f === e
|
|
335
339
|
);
|
|
336
|
-
return
|
|
337
|
-
}), D = X(() => n.matched[
|
|
338
|
-
for (let
|
|
339
|
-
const
|
|
340
|
-
if (!
|
|
341
|
-
return
|
|
340
|
+
return o >= 0 ? o + 1 : 0;
|
|
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))
|
|
345
|
+
return o;
|
|
342
346
|
}
|
|
343
347
|
return D.value;
|
|
344
|
-
}), y =
|
|
348
|
+
}), y = te([]), w = C("");
|
|
345
349
|
let h = 0;
|
|
346
|
-
|
|
347
|
-
const s = (
|
|
348
|
-
y.value.forEach((
|
|
349
|
-
|
|
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
|
-
}, K = (
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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);
|
|
372
|
+
}, g = (e) => {
|
|
373
|
+
const o = new Set(
|
|
374
|
+
t.history.map((f) => f.id)
|
|
359
375
|
);
|
|
360
376
|
y.value.forEach((f) => {
|
|
361
377
|
f.routeIds = new Set(
|
|
362
|
-
[...f.routeIds].filter((
|
|
378
|
+
[...f.routeIds].filter((a) => o.has(a))
|
|
363
379
|
);
|
|
364
380
|
}), y.value = y.value.filter(
|
|
365
|
-
(f) => f ===
|
|
381
|
+
(f) => f === e || f.routeInfo.cache && f.routeIds.size > 0
|
|
366
382
|
);
|
|
367
|
-
},
|
|
383
|
+
}, I = (e) => {
|
|
368
384
|
var f;
|
|
369
|
-
const
|
|
370
|
-
return
|
|
371
|
-
}, W = (
|
|
372
|
-
var
|
|
373
|
-
const f = z(
|
|
374
|
-
return ((
|
|
375
|
-
action:
|
|
376
|
-
direction:
|
|
377
|
-
source:
|
|
378
|
-
entering:
|
|
379
|
-
leaving:
|
|
385
|
+
const o = e.props.default;
|
|
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, {
|
|
391
|
+
action: e.routeInfo.action,
|
|
392
|
+
direction: e.routeInfo.direction,
|
|
393
|
+
source: e.routeInfo.source,
|
|
394
|
+
entering: e.routeInfo,
|
|
395
|
+
leaving: o.routeInfo,
|
|
380
396
|
defaultResult: f
|
|
381
397
|
})) ?? f;
|
|
382
|
-
}, A = (
|
|
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) => {
|
|
383
399
|
const f = ++h;
|
|
384
|
-
await
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
387
|
-
if (
|
|
388
|
-
S(
|
|
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);
|
|
389
405
|
return;
|
|
390
406
|
}
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
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,
|
|
409
|
+
t.transitions
|
|
394
410
|
);
|
|
395
|
-
|
|
396
|
-
direction:
|
|
397
|
-
action:
|
|
398
|
-
routeInfo:
|
|
399
|
-
enteringElement:
|
|
400
|
-
leavingElement:
|
|
411
|
+
P(o.componentRef, oe), S(a), S(r), await Pe(U, {
|
|
412
|
+
direction: e.routeInfo.direction,
|
|
413
|
+
action: e.routeInfo.action,
|
|
414
|
+
routeInfo: e.routeInfo,
|
|
415
|
+
enteringElement: a,
|
|
416
|
+
leavingElement: r,
|
|
401
417
|
duration: m,
|
|
402
|
-
easing:
|
|
403
|
-
}), f === h && (q(
|
|
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));
|
|
404
420
|
}, V = async () => {
|
|
405
|
-
const
|
|
406
|
-
if (!
|
|
407
|
-
const f =
|
|
421
|
+
const e = E.value, o = t.current.value;
|
|
422
|
+
if (!e || !o) return;
|
|
423
|
+
const f = ce(e);
|
|
408
424
|
if (!f) return;
|
|
409
|
-
const
|
|
410
|
-
let
|
|
411
|
-
!
|
|
412
|
-
id:
|
|
413
|
-
routeKey:
|
|
414
|
-
routeIds: /* @__PURE__ */ new Set([
|
|
415
|
-
routeInfo:
|
|
416
|
-
matchedRoute:
|
|
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]),
|
|
431
|
+
routeInfo: o,
|
|
432
|
+
matchedRoute: e,
|
|
417
433
|
component: f,
|
|
418
|
-
props:
|
|
434
|
+
props: I(e),
|
|
419
435
|
componentRef: C(),
|
|
420
436
|
mounted: !0
|
|
421
|
-
}, y.value = [...y.value,
|
|
437
|
+
}, y.value = [...y.value, r]), w.value = r.id, await _(r, a);
|
|
422
438
|
};
|
|
423
|
-
return
|
|
439
|
+
return ue(
|
|
424
440
|
() => {
|
|
425
|
-
var
|
|
426
|
-
return [(
|
|
441
|
+
var e;
|
|
442
|
+
return [(e = t.current.value) == null ? void 0 : e.id, E.value];
|
|
427
443
|
},
|
|
428
444
|
() => {
|
|
429
445
|
V();
|
|
430
446
|
},
|
|
431
447
|
{ immediate: !0 }
|
|
432
|
-
),
|
|
448
|
+
), le(() => {
|
|
433
449
|
h++, y.value = [];
|
|
434
450
|
}), {
|
|
435
|
-
injectedRoute:
|
|
451
|
+
injectedRoute: c,
|
|
436
452
|
viewItems: y,
|
|
437
|
-
registerStackPage: (
|
|
438
|
-
|
|
453
|
+
registerStackPage: (e, o) => {
|
|
454
|
+
e.pageElement = o, e.id === w.value ? S(o) : q(o);
|
|
439
455
|
}
|
|
440
456
|
};
|
|
441
457
|
},
|
|
@@ -443,17 +459,17 @@ const Gt = Q({
|
|
|
443
459
|
return k(
|
|
444
460
|
"div",
|
|
445
461
|
{ class: "rs-outlet" },
|
|
446
|
-
this.viewItems.filter((
|
|
447
|
-
(
|
|
448
|
-
key:
|
|
449
|
-
ref:
|
|
450
|
-
...
|
|
451
|
-
registerStackPage: (n) => this.registerStackPage(
|
|
462
|
+
this.viewItems.filter((t) => t.mounted).map(
|
|
463
|
+
(t) => k(t.component, {
|
|
464
|
+
key: t.id,
|
|
465
|
+
ref: t.componentRef,
|
|
466
|
+
...t.props,
|
|
467
|
+
registerStackPage: (n) => this.registerStackPage(t, n)
|
|
452
468
|
})
|
|
453
469
|
)
|
|
454
470
|
);
|
|
455
471
|
}
|
|
456
|
-
}),
|
|
472
|
+
}), He = Y({
|
|
457
473
|
name: "RouterPage",
|
|
458
474
|
props: {
|
|
459
475
|
registerStackPage: {
|
|
@@ -461,13 +477,13 @@ const Gt = Q({
|
|
|
461
477
|
default: void 0
|
|
462
478
|
}
|
|
463
479
|
},
|
|
464
|
-
setup(
|
|
480
|
+
setup(t, { attrs: n, slots: c }) {
|
|
465
481
|
const u = C();
|
|
466
|
-
return
|
|
467
|
-
var
|
|
468
|
-
u.value && ((
|
|
482
|
+
return fe(() => {
|
|
483
|
+
var d;
|
|
484
|
+
u.value && ((d = t.registerStackPage) == null || d.call(t, u.value));
|
|
469
485
|
}), () => {
|
|
470
|
-
var
|
|
486
|
+
var d;
|
|
471
487
|
return k(
|
|
472
488
|
"section",
|
|
473
489
|
{
|
|
@@ -475,11 +491,11 @@ const Gt = Q({
|
|
|
475
491
|
ref: u,
|
|
476
492
|
class: ["rs-page", n.class]
|
|
477
493
|
},
|
|
478
|
-
(
|
|
494
|
+
(d = c.default) == null ? void 0 : d.call(c)
|
|
479
495
|
);
|
|
480
496
|
};
|
|
481
497
|
}
|
|
482
|
-
}),
|
|
498
|
+
}), Ke = Y({
|
|
483
499
|
name: "StackRouterDebugPanel",
|
|
484
500
|
props: {
|
|
485
501
|
initialOpen: {
|
|
@@ -487,8 +503,8 @@ const Gt = Q({
|
|
|
487
503
|
default: !1
|
|
488
504
|
}
|
|
489
505
|
},
|
|
490
|
-
setup(
|
|
491
|
-
const n =
|
|
506
|
+
setup(t) {
|
|
507
|
+
const n = ae(), c = C(t.initialOpen);
|
|
492
508
|
return () => {
|
|
493
509
|
const u = n.current.value;
|
|
494
510
|
return k("aside", { class: "rs-debug-panel" }, [
|
|
@@ -498,12 +514,12 @@ const Gt = Q({
|
|
|
498
514
|
class: "rs-debug-toggle",
|
|
499
515
|
type: "button",
|
|
500
516
|
onClick: () => {
|
|
501
|
-
|
|
517
|
+
c.value = !c.value;
|
|
502
518
|
}
|
|
503
519
|
},
|
|
504
|
-
|
|
520
|
+
c.value ? "Stack x" : "Stack"
|
|
505
521
|
),
|
|
506
|
-
|
|
522
|
+
c.value ? k("section", { class: "rs-debug-body" }, [
|
|
507
523
|
k("header", [
|
|
508
524
|
k("strong", "Router Stack"),
|
|
509
525
|
k("span", `${n.history.length} pages`)
|
|
@@ -517,23 +533,23 @@ const Gt = Q({
|
|
|
517
533
|
k(
|
|
518
534
|
"ol",
|
|
519
535
|
n.history.map(
|
|
520
|
-
(
|
|
536
|
+
(d) => k(
|
|
521
537
|
"li",
|
|
522
538
|
{
|
|
523
|
-
key:
|
|
539
|
+
key: d.id,
|
|
524
540
|
class: {
|
|
525
|
-
"rs-debug-active":
|
|
526
|
-
"rs-debug-no-cache": !
|
|
541
|
+
"rs-debug-active": d.id === (u == null ? void 0 : u.id),
|
|
542
|
+
"rs-debug-no-cache": !d.cache
|
|
527
543
|
}
|
|
528
544
|
},
|
|
529
545
|
[
|
|
530
|
-
k("code",
|
|
546
|
+
k("code", d.fullPath),
|
|
531
547
|
k("span", [
|
|
532
|
-
`${
|
|
533
|
-
` source:${
|
|
534
|
-
` entry:${
|
|
535
|
-
` cache:${
|
|
536
|
-
` transition:${
|
|
548
|
+
`${d.action}/${d.direction}`,
|
|
549
|
+
` source:${d.source}`,
|
|
550
|
+
` entry:${d.entryDirection}`,
|
|
551
|
+
` cache:${d.cache ? "yes" : "no"}`,
|
|
552
|
+
` transition:${d.transition ?? "-"}`
|
|
537
553
|
])
|
|
538
554
|
]
|
|
539
555
|
)
|
|
@@ -545,22 +561,22 @@ const Gt = Q({
|
|
|
545
561
|
}
|
|
546
562
|
});
|
|
547
563
|
export {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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
|
|
566
582
|
};
|