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