vue-router
Advanced tools
Comparing version 4.0.0-beta.6 to 4.0.0-beta.7
@@ -0,1 +1,14 @@ | ||
# [4.0.0-beta.7](https://github.com/vuejs/vue-router-next/compare/v4.0.0-beta.6...v4.0.0-beta.7) (2020-08-19) | ||
### Bug Fixes | ||
- **encoding:** encode partial params ([eb04117](https://github.com/vuejs/vue-router-next/commit/eb041175c02ab0dac093823574a85bbbbf2056eb)) | ||
- **matcher:** avoid trailing slash with optional params ([faf0aab](https://github.com/vuejs/vue-router-next/commit/faf0aab6451848e5b4330e1d01033137a0c42a5a)) | ||
- **types:** append declare module ([50ad404](https://github.com/vuejs/vue-router-next/commit/50ad404ae45086f051b01ac552e4a3ab98535633)), closes [#419](https://github.com/vuejs/vue-router-next/issues/419) | ||
- **vetur:** update tags/attributes definition ([#408](https://github.com/vuejs/vue-router-next/issues/408)) ([df8b2b1](https://github.com/vuejs/vue-router-next/commit/df8b2b140155d1e4ad5d00cd17d57ab2046a75e2)) | ||
### Features | ||
- **warn:** warn against infinite redirections ([e3dcc8d](https://github.com/vuejs/vue-router-next/commit/e3dcc8d9477e17f9b92e22787b750edc4658b77a)) | ||
# [4.0.0-beta.6](https://github.com/vuejs/vue-router-next/compare/v4.0.0-beta.5...v4.0.0-beta.6) (2020-08-05) | ||
@@ -2,0 +15,0 @@ |
@@ -318,3 +318,3 @@ import { App } from 'vue'; | ||
/** | ||
* @description A key | ||
* A param in a url like `/users/:id` | ||
*/ | ||
@@ -915,1 +915,53 @@ declare interface PathParserParamKey { | ||
export { } | ||
declare module 'vue' { | ||
export interface ComponentCustomOptions { | ||
/** | ||
* Guard called when the router is navigating to the route that is rendering | ||
* this component from a different route. Differently from `beforeRouteUpdate` | ||
* and `beforeRouteLeave`, `beforeRouteEnter` does not have access to the | ||
* component instance through `this` because it triggers before the component | ||
* is even mounted. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteEnter?: NavigationGuardWithThis<undefined> | ||
/** | ||
* Guard called whenever the route that renders this component has changed but | ||
* it is reused for the new route. This allows you to guard for changes in | ||
* params, the query or the hash. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteUpdate?: NavigationGuard | ||
/** | ||
* Guard called when the router is navigating away from the current route that | ||
* is rendering this component. | ||
* | ||
* @param to - RouteLocationRaw we are navigating to | ||
* @param from - RouteLocationRaw we are navigating from | ||
* @param next - function to validate, cancel or modify (by redirecting) the | ||
* navigation | ||
*/ | ||
beforeRouteLeave?: NavigationGuard | ||
} | ||
export interface ComponentCustomProperties { | ||
/** | ||
* Normalized current location. See {@link RouteLocationNormalizedLoaded}. | ||
*/ | ||
$route: RouteLocationNormalizedLoaded | ||
/** | ||
* {@link Router} instance used by the application. | ||
*/ | ||
$router: Router | ||
} | ||
} |
/*! | ||
* vue-router v4.0.0-beta.5 | ||
* vue-router v4.0.0-beta.6 | ||
* (c) 2020 Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
var VueRouter=function(e,t){"use strict";const n="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,r=e=>n?Symbol(e):"_vr_"+e,o=r("rvlm"),a=r("rvd"),c=r("r"),i=r("rl"),s="undefined"!=typeof window;const l=Object.assign;function u(e,t){const n={};for(const r in t){const o=t[r];n[r]=Array.isArray(o)?o.map(e):e(o)}return n}let f=()=>{};const p=/\/$/;function h(e,t,n="/"){let r,o={},a="",c="";const i=t.indexOf("?"),s=t.indexOf("#",i>-1?i:0);return i>-1&&(r=t.slice(0,i),a=t.slice(i+1,s>-1?s:t.length),o=e(a)),s>-1&&(r=r||t.slice(0,s),c=t.slice(s,t.length)),r=function(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),r=e.split("/");let o,a,c=n.length-1;for(o=0;o<r.length;o++)if(a=r[o],1!==c&&"."!==a){if(".."!==a)break;c--}return n.slice(0,c).join("/")+"/"+r.slice(o-(o===r.length?1:0)).join("/")}(null!=r?r:t,n),{fullPath:r+(a&&"?")+a+c,path:r,query:o,hash:c}}function d(e,t){return!t||e.toLowerCase().indexOf(t.toLowerCase())?e:e.slice(t.length)||"/"}function m(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function g(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(!v(e[n],t[n]))return!1;return!0}function v(e,t){return Array.isArray(e)?y(e,t):Array.isArray(t)?y(t,e):e===t}function y(e,t){return Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):1===e.length&&e[0]===t}var b,w;!function(e){e.pop="pop",e.push="push"}(b||(b={})),function(e){e.back="back",e.forward="forward",e.unknown=""}(w||(w={}));function R(e){if(!e)if(s){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return"/"!==e[0]&&"#"!==e[0]&&(e="/"+e),e.replace(p,"")}const E=/^[^#]+#/;function O(e,t){return e.replace(E,"#")+t}const k=()=>({left:window.pageXOffset,top:window.pageYOffset});function A(e){let t;if("el"in e){let n=e.el;const r="string"==typeof n&&n.startsWith("#"),o="string"==typeof n?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!o)return;t=function(e,t){const n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}(o,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(null!=t.left?t.left:window.pageXOffset,null!=t.top?t.top:window.pageYOffset)}function x(e,t){return(history.state?history.state.position-t:-1)+e}const P=new Map;let C=()=>location.protocol+"//"+location.host;function j(e,t){const{pathname:n,search:r,hash:o}=t;if(e.indexOf("#")>-1){let e=o.slice(1);return"/"!==e[0]&&(e="/"+e),d(e,"")}return d(n,e)+r+o}function $(e,t,n,r=!1,o=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:o?k():null}}function S(e){const{history:t,location:n}=window;let r={value:j(e,n)},o={value:t.state};function a(r,a,c){const i=C()+(e.indexOf("#")>-1&&n.search?n.pathname+n.search+"#":e)+r;try{t[c?"replaceState":"pushState"](a,"",i),o.value=a}catch(e){!function(e,...t){console.warn("[Vue Router warn]: "+e,...t)}("Error with push/replace State",e),n[c?"replace":"assign"](i)}}return o.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0),{location:r,state:o,push:function(e,n){const o=l({},t.state,{forward:e,scroll:k()});a(o.current,o,!0),a(e,l({},$(r.value,e,null),{position:o.position+1},n),!1),r.value=e},replace:function(e,n){a(e,l({},t.state,$(o.value.back,e,o.value.forward,!0),n,{position:o.value.position}),!0),r.value=e}}}function L(e){const t=S(e=R(e)),n=function(e,t,n,r){let o=[],a=[],c=null;const i=({state:a})=>{const i=j(e,location),s=n.value,l=t.value;let u=0;if(a){if(n.value=i,t.value=a,c&&c===s)return void(c=null);u=l?a.position-l.position:0}else r(i);o.forEach(e=>{e(n.value,s,{delta:u,type:b.pop,direction:u?u>0?w.forward:w.back:w.unknown})})};function s(){const{history:e}=window;e.state&&e.replaceState(l({},e.state,{scroll:k()}),"")}return window.addEventListener("popstate",i),window.addEventListener("beforeunload",s),{pauseListeners:function(){c=n.value},listen:function(e){o.push(e);const t=()=>{const t=o.indexOf(e);t>-1&&o.splice(t,1)};return a.push(t),t},destroy:function(){for(const e of a)e();a=[],window.removeEventListener("popstate",i),window.removeEventListener("beforeunload",s)}}}(e,t.state,t.location,t.replace);const r=l({location:"",base:e,go:function(e,t=!0){t||n.pauseListeners(),history.go(e)},createHref:O.bind(null,e)},t,n);return Object.defineProperty(r,"location",{get:()=>t.location.value}),Object.defineProperty(r,"state",{get:()=>t.state.value}),r}function q(e){return"string"==typeof e||"symbol"==typeof e}const M={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},T=r("nf");var _;function B(e,t){return l(new Error,{type:e,[T]:!0},t)}function I(e,t){return e instanceof Error&&T in e&&(null==t||!!(e.type&t))}(_=e.NavigationFailureType||(e.NavigationFailureType={}))[_.aborted=4]="aborted",_[_.cancelled=8]="cancelled",_[_.duplicated=16]="duplicated";const V={sensitive:!1,strict:!1,start:!0,end:!0},F=/[.+*?^${}()[\]/\\]/g;function G(e,t){let n=0;for(;n<e.length&&n<t.length;){const r=t[n]-e[n];if(r)return r;n++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}function H(e,t){let n=0;const r=e.score,o=t.score;for(;n<r.length&&n<o.length;){const e=G(r[n],o[n]);if(e)return e;n++}return o.length-r.length}const U={type:0,value:""},D=/[a-zA-Z0-9_]/;function N(e,t,n){const r=function(e,t){const n=l({},V,t);let r=[],o=n.start?"^":"";const a=[];for(const t of e){const e=t.length?[]:[90];n.strict&&!t.length&&(o+="/");for(let r=0;r<t.length;r++){const c=t[r];let i=40+(n.sensitive?.25:0);if(0===c.type)r||(o+="/"),o+=c.value.replace(F,"\\$&"),i+=40;else if(1===c.type){const{value:e,repeatable:t,optional:n,regexp:s}=c;a.push({name:e,repeatable:t,optional:n});const l=s||"[^/]+?";if("[^/]+?"!==l){i+=10;try{new RegExp(`(${l})`)}catch(t){throw new Error(`Invalid custom RegExp for param "${e}" (${l}): `+t.message)}}let u=t?`((?:${l})(?:/(?:${l}))*)`:`(${l})`;r||(u=n?`(?:/${u})`:"/"+u),n&&(u+="?"),o+=u,i+=20,n&&(i+=-8),t&&(i+=-20),".*"===l&&(i+=-50)}e.push(i)}r.push(e)}if(n.strict&&n.end){const e=r.length-1;r[e][r[e].length-1]+=.7000000000000001}n.strict||(o+="/?"),n.end?o+="$":n.strict&&(o+="(?:/|$)");const c=new RegExp(o,n.sensitive?"":"i");return{re:c,score:r,keys:a,parse:function(e){const t=e.match(c),n={};if(!t)return null;for(let e=1;e<t.length;e++){const r=t[e]||"",o=a[e-1];n[o.name]=r&&o.repeatable?r.split("/"):r}return n},stringify:function(t){let n="",r=!1;for(const o of e){r&&"/"===n[n.length-1]||(n+="/"),r=!1;for(const e of o)if(0===e.type)n+=e.value;else if(1===e.type){const{value:o,repeatable:a,optional:c}=e,i=o in t?t[o]:"";if(Array.isArray(i)&&!a)throw new Error(`Provided param "${o}" is an array but it is not repeatable (* or + modifiers)`);const s=Array.isArray(i)?i.join("/"):i;if(!s){if(!c)throw new Error(`Missing required param "${o}"`);r=!0}n+=s}}return n}}}(function(e){if(!e)return[[]];if("/"===e)return[[U]];if("/"!==e[0])throw new Error('A non-empty path must start with "/"');function t(e){throw new Error(`ERR (${n})/"${l}": ${e}`)}let n=0,r=n;const o=[];let a;function c(){a&&o.push(a),a=[]}let i,s=0,l="",u="";function f(){l&&(0===n?a.push({type:0,value:l}):1===n||2===n||3===n?(a.length>1&&("*"===i||"+"===i)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:l,regexp:u,repeatable:"*"===i||"+"===i,optional:"*"===i||"?"===i})):t("Invalid state to consume buffer"),l="")}function p(){l+=i}for(;s<e.length;)if(i=e[s++],"\\"!==i||2===n)switch(n){case 0:"/"===i?(l&&f(),c()):":"===i?(f(),n=1):p();break;case 4:p(),n=r;break;case 1:"("===i?(n=2,u=""):D.test(i)?p():(f(),n=0,"*"!==i&&"?"!==i&&"+"!==i&&s--);break;case 2:")"===i?"\\"==u[u.length-1]?u=u.slice(0,-1)+i:n=3:u+=i;break;case 3:f(),n=0,"*"!==i&&"?"!==i&&"+"!==i&&s--;break;default:t("Unknown state")}else r=n,n=4;return 2===n&&t(`Unfinished custom RegExp for param "${l}"`),f(),c(),o}(e.path),n),o=l(r,{record:e,parent:t,children:[],alias:[]});return t&&!o.record.aliasOf==!t.record.aliasOf&&t.children.push(o),o}function K(e,t){const n=[],r=new Map;function o(e,n,r){let i=!r,s=function(e){return{path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:void 0,beforeEnter:e.beforeEnter,props:Q(e),children:e.children||[],instances:{},leaveGuards:[],updateGuards:[],enterCallbacks:{},components:"components"in e?e.components||{}:{default:e.component}}}(e);s.aliasOf=r&&r.record;const u=X(t,e),p=[s];if("alias"in e){const t="string"==typeof e.alias?[e.alias]:e.alias;for(const e of t)p.push(l({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s}))}let h,d;for(const t of p){let{path:l}=t;if(n&&"/"!==l[0]){let e=n.record.path,r="/"===e[e.length-1]?"":"/";t.path=n.record.path+(l&&r+l)}if(h=N(t,n,u),r?r.alias.push(h):(d=d||h,d!==h&&d.alias.push(h),i&&e.name&&!W(h)&&a(e.name)),"children"in s){let e=s.children;for(let t=0;t<e.length;t++)o(e[t],h,r&&r.children[t])}r=r||h,c(h)}return d?()=>{a(d)}:f}function a(e){if(q(e)){const t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(a),t.alias.forEach(a))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(a),e.alias.forEach(a))}}function c(e){let t=0;for(;t<n.length&&H(e,n[t])>=0;)t++;n.splice(t,0,e),e.record.name&&!W(e)&&r.set(e.record.name,e)}return t=X({strict:!1,end:!0,sensitive:!1},t),e.forEach(e=>o(e)),{addRoute:o,resolve:function(e,t){let o,a,c,i={};if("name"in e&&e.name){if(o=r.get(e.name),!o)throw B(1,{location:e});c=o.record.name,i=l(function(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}(t.params,o.keys.map(e=>e.name)),e.params),a=o.stringify(i)}else if("path"in e)a=e.path,o=n.find(e=>e.re.test(a)),o&&(i=o.parse(a),c=o.record.name);else{if(o=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!o)throw B(1,{location:e,currentLocation:t});c=o.record.name,i=l({},t.params,e.params),a=o.stringify(i)}const s=[];let u=o;for(;u;)s.unshift(u.record),u=u.parent;return{name:c,path:a,params:i,matched:s,meta:z(s)}},removeRoute:a,getRoutes:function(){return n},getRecordMatcher:function(e){return r.get(e)}}}function Q(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(let r in e.components)t[r]="boolean"==typeof n?n:n[r];return t}function W(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function z(e){return e.reduce((e,t)=>l(e,t.meta),{})}function X(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}const Y=/#/g,Z=/&/g,J=/\//g,ee=/=/g,te=/\?/g,ne=/%5B/g,re=/%5D/g,oe=/%5E/g,ae=/%60/g,ce=/%7B/g,ie=/%7C/g,se=/%7D/g;function le(e){return encodeURI(""+e).replace(ie,"|").replace(ne,"[").replace(re,"]")}function ue(e){return le(e).replace(Y,"%23").replace(Z,"%26").replace(ee,"%3D").replace(ae,"`").replace(ce,"{").replace(se,"}").replace(oe,"^")}function fe(e){return function(e){return le(e).replace(Y,"%23").replace(te,"%3F")}(e).replace(J,"%2F")}function pe(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}function he(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){let[r,o]=n[e].split("=");r=pe(r);let a=null==o?null:pe(o);if(r in t){let e=t[r];Array.isArray(e)||(e=t[r]=[e]),e.push(a)}else t[r]=a}return t}function de(e){let t="";for(let n in e){t.length&&(t+="&");const r=e[n];if(n=ue(n),null==r){void 0!==r&&(t+=n);continue}let o=Array.isArray(r)?r.map(e=>e&&ue(e)):[r&&ue(r)];for(let e=0;e<o.length;e++)t+=(e?"&":"")+n,null!=o[e]&&(t+="="+o[e])}return t}function me(e){const t={};for(let n in e){let r=e[n];void 0!==r&&(t[n]=Array.isArray(r)?r.map(e=>null==e?null:""+e):null==r?r:""+r)}return t}function ge(){let e=[];return{add:function(t){return e.push(t),()=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)}},list:()=>e,reset:function(){e=[]}}}function ve(e,t,n,r,o){const a=r&&(r.enterCallbacks[o]=r.enterCallbacks[o]||[]);return()=>new Promise((c,i)=>{const s=e=>{var s;!1===e?i(B(4,{from:n,to:t})):e instanceof Error?i(e):"string"==typeof(s=e)||s&&"object"==typeof s?i(B(2,{from:t,to:e})):(a&&r.enterCallbacks[o]===a&&"function"==typeof e&&a.push(e),c())};let l=Promise.resolve(e.call(r&&r.instances[o],t,n,s));e.length<3&&(l=l.then(s)),l.catch(e=>i(e))})}function ye(e,t,r,o){const a=[];for(const i of e)for(const e in i.components){let s=i.components[e];if("beforeRouteEnter"===t||i.instances[e])if("object"==typeof(c=s)||"displayName"in c||"props"in c||"__vccOpts"in c){const n=(s.__vccOpts||s)[t];n&&a.push(ve(n,r,o,i,e))}else{let c=s();c=c.catch(()=>null),a.push(()=>c.then(a=>{if(!a)return Promise.reject(new Error(`Couldn't resolve component "${e}" for the following record with path "${i.path}"`));const c=(s=a).__esModule||n&&"Module"===s[Symbol.toStringTag]?a.default:a;var s;i.components[e]=c;const l=c[t];return l&&ve(l,r,o,i,e)()}))}}var c;return a}function be(e){const n=t.inject(c),r=t.inject(i),o=t.computed(()=>n.resolve(t.unref(e.to))),a=t.computed(()=>{let{matched:e}=o.value,{length:t}=e;const n=e[t-1];let a=r.matched;if(!n||!a.length)return-1;let c=a.findIndex(m.bind(null,n));if(c>-1)return c;let i=Re(e[t-2]);return t>1&&Re(n)===i&&a[a.length-1].path!==i?a.findIndex(m.bind(null,e[t-2])):c}),s=t.computed(()=>a.value>-1&&function(e,t){for(let n in t){let r=t[n],o=e[n];if("string"==typeof r){if(r!==o)return!1}else if(!Array.isArray(o)||o.length!==r.length||r.some((e,t)=>e!==o[t]))return!1}return!0}(r.params,o.value.params)),l=t.computed(()=>a.value>-1&&a.value===r.matched.length-1&&g(r.params,o.value.params));return{route:o,href:t.computed(()=>o.value.href),isActive:s,isExactActive:l,navigate:function(r={}){return function(e){if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;if(e.defaultPrevented)return;if(void 0!==e.button&&0!==e.button)return;if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}e.preventDefault&&e.preventDefault();return!0}(r)?n[t.unref(e.replace)?"replace":"push"](t.unref(e.to)):Promise.resolve()}}}const we=t.defineComponent({name:"RouterLink",props:{to:{type:[String,Object],required:!0},activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},setup(e,{slots:n,attrs:r}){const o=t.reactive(be(e)),{options:a}=t.inject(c),i=t.computed(()=>({[Ee(e.activeClass,a.linkActiveClass,"router-link-active")]:o.isActive,[Ee(e.exactActiveClass,a.linkExactActiveClass,"router-link-exact-active")]:o.isExactActive}));return()=>{const a=n.default&&n.default(o);return e.custom?a:t.h("a",l({"aria-current":o.isExactActive?e.ariaCurrentValue:null,onClick:o.navigate,href:o.href},r,{class:i.value}),a)}}});function Re(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}let Ee=(e,t,n)=>null!=e?e:null!=t?t:n;const Oe=t.defineComponent({name:"RouterView",props:{name:{type:String,default:"default"},route:Object},setup(e,{attrs:n,slots:r}){const c=t.inject(i),s=t.inject(a,0),u=t.computed(()=>(e.route||c).matched[s]);t.provide(a,s+1),t.provide(o,u);const f=t.ref();return()=>{const o=e.route||c,a=u.value,i=a&&a.components[e.name];if(!i)return r.default?r.default({Component:i,route:o}):null;const s=a.props[e.name],p=s?!0===s?o.params:"function"==typeof s?s(o):s:null,h=e.name,d=t.h(i,l({},p,n,{onVnodeMounted:()=>{a.instances[h]=f.value,(a.enterCallbacks[h]||[]).forEach(e=>e(f.value))},onVnodeUnmounted:()=>{a.instances[h]=null},ref:f}));return r.default?r.default({Component:d,route:o}):d}}});function ke(e){return e.reduce((e,t)=>e.then(()=>t()),Promise.resolve())}function Ae(e,t){const n=[],r=[],o=[],a=Math.max(t.matched.length,e.matched.length);for(let c=0;c<a;c++){const a=t.matched[c];a&&(e.matched.indexOf(a)<0?n.push(a):r.push(a));const i=e.matched[c];i&&t.matched.indexOf(i)<0&&o.push(i)}return[n,r,o]}return e.RouterLink=we,e.RouterView=Oe,e.START_LOCATION=M,e.createMemoryHistory=function(e=""){let t=[],n=[""],r=0;function o(e){r++,r===n.length||n.splice(r),n.push(e)}const a={location:"",state:{},base:e,createHref:O.bind(null,e),replace(e){n.splice(r--,1),o(e)},push(e,t){o(e)},listen:e=>(t.push(e),()=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)}),destroy(){t=[]},go(e,o=!0){const a=this.location,c=e<0?w.back:w.forward;r=Math.max(0,Math.min(r+e,n.length-1)),o&&function(e,n,{direction:r,delta:o}){const a={direction:r,delta:o,type:b.pop};for(let r of t)r(e,n,a)}(this.location,a,{direction:c,delta:e})}};return Object.defineProperty(a,"location",{get:()=>n[r]}),a},e.createRouter=function(e){const n=K(e.routes,e);let r=e.parseQuery||he,o=e.stringifyQuery||de,{scrollBehavior:a}=e,p=e.history;const d=ge(),v=ge(),y=ge(),b=t.shallowRef(M);let w=M;s&&a&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const R=u.bind(null,e=>""+e),E=u.bind(null,fe),O=u.bind(null,pe);function C(e,t){if(t=t||b.value,"string"==typeof e){let o=h(r,e,t.path),a=n.resolve({path:o.path},t),c=p.createHref(o.fullPath);return l(o,a,{params:O(a.params),redirectedFrom:void 0,href:c})}let a;a=l({},e,"path"in e?{path:h(r,e.path,t.path).path}:{params:E(e.params)});let c=n.resolve(a,t);const i=le(e.hash||"").replace(ce,"{").replace(se,"}").replace(oe,"^");c.params="params"in e?R(e.params):O(c.params);const s=function(e,t){let n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}(o,l({},e,{hash:i,path:c.path}));let u=p.createHref(s);return l({fullPath:s,hash:i,query:o===de?me(e.query):e.query},c,{redirectedFrom:void 0,href:u})}function j(e){return"string"==typeof e?{path:e}:l({},e)}function $(e,t){if(w!==e)return B(8,{from:t,to:e})}function S(e){return L(e)}function L(e,t){const n=w=C(e),r=b.value,a=e.state,c=e.force,i=!0===e.replace,s=n.matched[n.matched.length-1];if(s&&s.redirect){const{redirect:e}=s;let r=j("function"==typeof e?e(n):e);return L(l({query:n.query,hash:n.hash,params:n.params},r,{state:a,force:c,replace:i}),t||n)}const u=n;let f;return u.redirectedFrom=t,!c&&function(e,t,n){let r=t.matched.length-1,o=n.matched.length-1;return r>-1&&r===o&&m(t.matched[r],n.matched[o])&&g(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}(o,r,n)&&(f=B(16,{to:u,from:r}),X(r,r,!0,!1)),(f?Promise.resolve(f):_(u,r)).catch(e=>I(e,14)?e:W(e)).then(e=>{if(e){if(I(e,2))return L(l(j(e.to),{state:a,force:c,replace:i}),t||u)}else e=F(u,r,!0,i,a);return V(u,r,e),e})}function T(e,t){const n=$(e,t);return n?Promise.reject(n):Promise.resolve()}function _(e,t){let n;n=ye(t.matched.filter(t=>e.matched.indexOf(t)<0).reverse(),"beforeRouteLeave",e,t);const[r,o]=Ae(e,t);for(const o of r)for(const r of o.leaveGuards)n.push(ve(r,e,t));const a=T.bind(null,e,t);return n.push(a),ke(n).then(()=>{n=[];for(const r of d.list())n.push(ve(r,e,t));return n.push(a),ke(n)}).then(()=>{n=ye(e.matched.filter(e=>t.matched.indexOf(e)>-1),"beforeRouteUpdate",e,t);for(const r of o)for(const o of r.updateGuards)n.push(ve(o,e,t));return n.push(a),ke(n)}).then(()=>{n=[];for(const r of e.matched)if(r.beforeEnter&&t.matched.indexOf(r)<0)if(Array.isArray(r.beforeEnter))for(const o of r.beforeEnter)n.push(ve(o,e,t));else n.push(ve(r.beforeEnter,e,t));return n.push(a),ke(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=ye(e.matched.filter(e=>t.matched.indexOf(e)<0),"beforeRouteEnter",e,t),n.push(a),ke(n))).then(()=>{n=[];for(const r of v.list())n.push(ve(r,e,t));return n.push(a),ke(n)}).catch(e=>I(e,8)?e:Promise.reject(e))}function V(e,t,n){for(const r of y.list())r(e,t,n)}function F(e,t,n,r,o){const a=$(e,t);if(a)return a;const[c]=Ae(e,t);for(const e of c)e.leaveGuards=[],e.updateGuards=[],e.instances={},e.enterCallbacks={};const i=t===M,u=s?history.state:{};n&&(r||i?p.replace(e.fullPath,l({scroll:i&&u&&u.scroll},o)):p.push(e.fullPath,o)),b.value=e,X(e,t,n,i),z()}let G;function H(){G=p.listen((e,t,n)=>{const r=C(e);w=r;const o=b.value;var a,c;s&&(a=x(o.fullPath,n.delta),c=k(),P.set(a,c)),_(r,o).catch(e=>I(e,12)?e:I(e,2)?(n.delta&&p.go(-n.delta,!1),L(e.to,r).catch(f),Promise.reject()):(n.delta&&p.go(-n.delta,!1),W(e))).then(e=>{(e=e||F(r,o,!1))&&n.delta&&p.go(-n.delta,!1),V(r,o,e)}).catch(f)})}let U,D,N=ge(),Q=ge();function W(e){return z(e),Q.list().forEach(t=>t(e)),Promise.reject(e)}function z(e){U||(U=!0,H(),N.list().forEach(([t,n])=>e?n(e):t()),N.reset())}function X(e,n,r,o){if(!s||!a)return Promise.resolve();let c=!r&&function(e){const t=P.get(e);return P.delete(e),t}(x(e.fullPath,0))||(o||!r)&&history.state&&history.state.scroll||null;return t.nextTick().then(()=>a(e,n,c)).then(e=>e&&A(e)).catch(W)}function Y(e){return new Promise((t,n)=>{let r=Q.add(e=>{r(),o(),n(e)}),o=y.add((e,n,a)=>{r(),o(),t(a)});p.go(e)})}const Z=new Set;return{currentRoute:b,addRoute:function(e,t){let r,o;return q(e)?(r=n.getRecordMatcher(e),o=t):o=e,n.addRoute(o,r)},removeRoute:function(e){let t=n.getRecordMatcher(e);t&&n.removeRoute(t)},hasRoute:function(e){return!!n.getRecordMatcher(e)},getRoutes:function(){return n.getRoutes().map(e=>e.record)},resolve:C,options:e,push:S,replace:function(e){return S(l(j(e),{replace:!0}))},go:Y,back:()=>Y(-1),forward:()=>Y(1),beforeEach:d.add,beforeResolve:v.add,afterEach:y.add,onError:Q.add,isReady:function(){return U&&b.value!==M?Promise.resolve():new Promise((e,t)=>{N.add([e,t])})},install(e){e.component("RouterLink",we),e.component("RouterView",Oe),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{get:()=>t.unref(b)}),s&&!D&&b.value===M&&(D=!0,S(p.location).catch(e=>{}));const n={};for(let e in M)n[e]=t.computed(()=>b.value[e]);e.provide(c,this),e.provide(i,t.reactive(n));let r=e.unmount;Z.add(e),e.unmount=function(){Z.delete(e),Z.size<1&&(G(),b.value=M,D=!1,U=!1),r.call(this,arguments)}}}},e.createRouterMatcher=K,e.createWebHashHistory=function(e){return(e=location.host&&e||location.pathname).indexOf("#")<0&&(e+="#"),L(e)},e.createWebHistory=L,e.isNavigationFailure=I,e.onBeforeRouteLeave=function(e){const n=t.getCurrentInstance();if(!n)return;const r=t.inject(o,{}).value;r&&r.leaveGuards.push(e.bind(n.proxy))},e.onBeforeRouteUpdate=function(e){const n=t.getCurrentInstance();if(!n)return;const r=t.inject(o,{}).value;r&&r.updateGuards.push(e.bind(n.proxy))},e.parseQuery=he,e.stringifyQuery=de,e.useLink=be,e.useRoute=function(){return t.inject(i)},e.useRouter=function(){return t.inject(c)},e}({},Vue); | ||
var VueRouter=function(e,t){"use strict";const n="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,r=e=>n?Symbol(e):"_vr_"+e,o=r("rvlm"),a=r("rvd"),i=r("r"),c=r("rl"),s="undefined"!=typeof window;const l=Object.assign;function u(e,t){const n={};for(const r in t){const o=t[r];n[r]=Array.isArray(o)?o.map(e):e(o)}return n}let f=()=>{};const p=/\/$/;function h(e,t,n="/"){let r,o={},a="",i="";const c=t.indexOf("?"),s=t.indexOf("#",c>-1?c:0);return c>-1&&(r=t.slice(0,c),a=t.slice(c+1,s>-1?s:t.length),o=e(a)),s>-1&&(r=r||t.slice(0,s),i=t.slice(s,t.length)),r=function(e,t){if(e.startsWith("/"))return e;if(!e)return t;const n=t.split("/"),r=e.split("/");let o,a,i=n.length-1;for(o=0;o<r.length;o++)if(a=r[o],1!==i&&"."!==a){if(".."!==a)break;i--}return n.slice(0,i).join("/")+"/"+r.slice(o-(o===r.length?1:0)).join("/")}(null!=r?r:t,n),{fullPath:r+(a&&"?")+a+i,path:r,query:o,hash:i}}function d(e,t){return!t||e.toLowerCase().indexOf(t.toLowerCase())?e:e.slice(t.length)||"/"}function m(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function g(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(!v(e[n],t[n]))return!1;return!0}function v(e,t){return Array.isArray(e)?y(e,t):Array.isArray(t)?y(t,e):e===t}function y(e,t){return Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):1===e.length&&e[0]===t}var b,w;!function(e){e.pop="pop",e.push="push"}(b||(b={})),function(e){e.back="back",e.forward="forward",e.unknown=""}(w||(w={}));function R(e){if(!e)if(s){const t=document.querySelector("base");e=(e=t&&t.getAttribute("href")||"/").replace(/^\w+:\/\/[^\/]+/,"")}else e="/";return"/"!==e[0]&&"#"!==e[0]&&(e="/"+e),e.replace(p,"")}const E=/^[^#]+#/;function O(e,t){return e.replace(E,"#")+t}const k=()=>({left:window.pageXOffset,top:window.pageYOffset});function A(e){let t;if("el"in e){let n=e.el;const r="string"==typeof n&&n.startsWith("#"),o="string"==typeof n?r?document.getElementById(n.slice(1)):document.querySelector(n):n;if(!o)return;t=function(e,t){const n=document.documentElement.getBoundingClientRect(),r=e.getBoundingClientRect();return{behavior:t.behavior,left:r.left-n.left-(t.left||0),top:r.top-n.top-(t.top||0)}}(o,e)}else t=e;"scrollBehavior"in document.documentElement.style?window.scrollTo(t):window.scrollTo(null!=t.left?t.left:window.pageXOffset,null!=t.top?t.top:window.pageYOffset)}function x(e,t){return(history.state?history.state.position-t:-1)+e}const P=new Map;let C=()=>location.protocol+"//"+location.host;function j(e,t){const{pathname:n,search:r,hash:o}=t;if(e.indexOf("#")>-1){let e=o.slice(1);return"/"!==e[0]&&(e="/"+e),d(e,"")}return d(n,e)+r+o}function $(e,t,n,r=!1,o=!1){return{back:e,current:t,forward:n,replaced:r,position:window.history.length,scroll:o?k():null}}function S(e){const{history:t,location:n}=window;let r={value:j(e,n)},o={value:t.state};function a(r,a,i){const c=C()+(e.indexOf("#")>-1&&n.search?n.pathname+n.search+"#":e)+r;try{t[i?"replaceState":"pushState"](a,"",c),o.value=a}catch(e){!function(e,...t){console.warn("[Vue Router warn]: "+e,...t)}("Error with push/replace State",e),n[i?"replace":"assign"](c)}}return o.value||a(r.value,{back:null,current:r.value,forward:null,position:t.length-1,replaced:!0,scroll:null},!0),{location:r,state:o,push:function(e,n){const o=l({},t.state,{forward:e,scroll:k()});a(o.current,o,!0),a(e,l({},$(r.value,e,null),{position:o.position+1},n),!1),r.value=e},replace:function(e,n){a(e,l({},t.state,$(o.value.back,e,o.value.forward,!0),n,{position:o.value.position}),!0),r.value=e}}}function L(e){const t=S(e=R(e)),n=function(e,t,n,r){let o=[],a=[],i=null;const c=({state:a})=>{const c=j(e,location),s=n.value,l=t.value;let u=0;if(a){if(n.value=c,t.value=a,i&&i===s)return void(i=null);u=l?a.position-l.position:0}else r(c);o.forEach(e=>{e(n.value,s,{delta:u,type:b.pop,direction:u?u>0?w.forward:w.back:w.unknown})})};function s(){const{history:e}=window;e.state&&e.replaceState(l({},e.state,{scroll:k()}),"")}return window.addEventListener("popstate",c),window.addEventListener("beforeunload",s),{pauseListeners:function(){i=n.value},listen:function(e){o.push(e);const t=()=>{const t=o.indexOf(e);t>-1&&o.splice(t,1)};return a.push(t),t},destroy:function(){for(const e of a)e();a=[],window.removeEventListener("popstate",c),window.removeEventListener("beforeunload",s)}}}(e,t.state,t.location,t.replace);const r=l({location:"",base:e,go:function(e,t=!0){t||n.pauseListeners(),history.go(e)},createHref:O.bind(null,e)},t,n);return Object.defineProperty(r,"location",{get:()=>t.location.value}),Object.defineProperty(r,"state",{get:()=>t.state.value}),r}function q(e){return"string"==typeof e||"symbol"==typeof e}const M={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},T=r("nf");var _;function B(e,t){return l(new Error,{type:e,[T]:!0},t)}function I(e,t){return e instanceof Error&&T in e&&(null==t||!!(e.type&t))}(_=e.NavigationFailureType||(e.NavigationFailureType={}))[_.aborted=4]="aborted",_[_.cancelled=8]="cancelled",_[_.duplicated=16]="duplicated";const V={sensitive:!1,strict:!1,start:!0,end:!0},F=/[.+*?^${}()[\]/\\]/g;function G(e,t){let n=0;for(;n<e.length&&n<t.length;){const r=t[n]-e[n];if(r)return r;n++}return e.length<t.length?1===e.length&&80===e[0]?-1:1:e.length>t.length?1===t.length&&80===t[0]?1:-1:0}function H(e,t){let n=0;const r=e.score,o=t.score;for(;n<r.length&&n<o.length;){const e=G(r[n],o[n]);if(e)return e;n++}return o.length-r.length}const U={type:0,value:""},W=/[a-zA-Z0-9_]/;function D(e,t,n){const r=function(e,t){const n=l({},V,t);let r=[],o=n.start?"^":"";const a=[];for(const t of e){const e=t.length?[]:[90];n.strict&&!t.length&&(o+="/");for(let r=0;r<t.length;r++){const i=t[r];let c=40+(n.sensitive?.25:0);if(0===i.type)r||(o+="/"),o+=i.value.replace(F,"\\$&"),c+=40;else if(1===i.type){const{value:e,repeatable:t,optional:n,regexp:s}=i;a.push({name:e,repeatable:t,optional:n});const l=s||"[^/]+?";if("[^/]+?"!==l){c+=10;try{new RegExp(`(${l})`)}catch(t){throw new Error(`Invalid custom RegExp for param "${e}" (${l}): `+t.message)}}let u=t?`((?:${l})(?:/(?:${l}))*)`:`(${l})`;r||(u=n?`(?:/${u})`:"/"+u),n&&(u+="?"),o+=u,c+=20,n&&(c+=-8),t&&(c+=-20),".*"===l&&(c+=-50)}e.push(c)}r.push(e)}if(n.strict&&n.end){const e=r.length-1;r[e][r[e].length-1]+=.7000000000000001}n.strict||(o+="/?"),n.end?o+="$":n.strict&&(o+="(?:/|$)");const i=new RegExp(o,n.sensitive?"":"i");return{re:i,score:r,keys:a,parse:function(e){const t=e.match(i),n={};if(!t)return null;for(let e=1;e<t.length;e++){const r=t[e]||"",o=a[e-1];n[o.name]=r&&o.repeatable?r.split("/"):r}return n},stringify:function(t){let n="",r=!1;for(const o of e){r&&n.endsWith("/")||(n+="/"),r=!1;for(const e of o)if(0===e.type)n+=e.value;else if(1===e.type){const{value:o,repeatable:a,optional:i}=e,c=o in t?t[o]:"";if(Array.isArray(c)&&!a)throw new Error(`Provided param "${o}" is an array but it is not repeatable (* or + modifiers)`);const s=Array.isArray(c)?c.join("/"):c;if(!s){if(!i)throw new Error(`Missing required param "${o}"`);n.endsWith("/")?n=n.slice(0,-1):r=!0}n+=s}}return n}}}(function(e){if(!e)return[[]];if("/"===e)return[[U]];if("/"!==e[0])throw new Error('A non-empty path must start with "/"');function t(e){throw new Error(`ERR (${n})/"${l}": ${e}`)}let n=0,r=n;const o=[];let a;function i(){a&&o.push(a),a=[]}let c,s=0,l="",u="";function f(){l&&(0===n?a.push({type:0,value:l}):1===n||2===n||3===n?(a.length>1&&("*"===c||"+"===c)&&t(`A repeatable param (${l}) must be alone in its segment. eg: '/:ids+.`),a.push({type:1,value:l,regexp:u,repeatable:"*"===c||"+"===c,optional:"*"===c||"?"===c})):t("Invalid state to consume buffer"),l="")}function p(){l+=c}for(;s<e.length;)if(c=e[s++],"\\"!==c||2===n)switch(n){case 0:"/"===c?(l&&f(),i()):":"===c?(f(),n=1):p();break;case 4:p(),n=r;break;case 1:"("===c?(n=2,u=""):W.test(c)?p():(f(),n=0,"*"!==c&&"?"!==c&&"+"!==c&&s--);break;case 2:")"===c?"\\"==u[u.length-1]?u=u.slice(0,-1)+c:n=3:u+=c;break;case 3:f(),n=0,"*"!==c&&"?"!==c&&"+"!==c&&s--;break;default:t("Unknown state")}else r=n,n=4;return 2===n&&t(`Unfinished custom RegExp for param "${l}"`),f(),i(),o}(e.path),n),o=l(r,{record:e,parent:t,children:[],alias:[]});return t&&!o.record.aliasOf==!t.record.aliasOf&&t.children.push(o),o}function N(e,t){const n=[],r=new Map;function o(e,n,r){let c=!r,s=function(e){return{path:e.path,redirect:e.redirect,name:e.name,meta:e.meta||{},aliasOf:void 0,beforeEnter:e.beforeEnter,props:K(e),children:e.children||[],instances:{},leaveGuards:[],updateGuards:[],enterCallbacks:{},components:"components"in e?e.components||{}:{default:e.component}}}(e);s.aliasOf=r&&r.record;const u=X(t,e),p=[s];if("alias"in e){const t="string"==typeof e.alias?[e.alias]:e.alias;for(const e of t)p.push(l({},s,{components:r?r.record.components:s.components,path:e,aliasOf:r?r.record:s}))}let h,d;for(const t of p){let{path:l}=t;if(n&&"/"!==l[0]){let e=n.record.path,r="/"===e[e.length-1]?"":"/";t.path=n.record.path+(l&&r+l)}if(h=D(t,n,u),r?r.alias.push(h):(d=d||h,d!==h&&d.alias.push(h),c&&e.name&&!Q(h)&&a(e.name)),"children"in s){let e=s.children;for(let t=0;t<e.length;t++)o(e[t],h,r&&r.children[t])}r=r||h,i(h)}return d?()=>{a(d)}:f}function a(e){if(q(e)){const t=r.get(e);t&&(r.delete(e),n.splice(n.indexOf(t),1),t.children.forEach(a),t.alias.forEach(a))}else{let t=n.indexOf(e);t>-1&&(n.splice(t,1),e.record.name&&r.delete(e.record.name),e.children.forEach(a),e.alias.forEach(a))}}function i(e){let t=0;for(;t<n.length&&H(e,n[t])>=0;)t++;n.splice(t,0,e),e.record.name&&!Q(e)&&r.set(e.record.name,e)}return t=X({strict:!1,end:!0,sensitive:!1},t),e.forEach(e=>o(e)),{addRoute:o,resolve:function(e,t){let o,a,i,c={};if("name"in e&&e.name){if(o=r.get(e.name),!o)throw B(1,{location:e});i=o.record.name,c=l(function(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}(t.params,o.keys.filter(e=>!e.optional).map(e=>e.name)),e.params),a=o.stringify(c)}else if("path"in e)a=e.path,o=n.find(e=>e.re.test(a)),o&&(c=o.parse(a),i=o.record.name);else{if(o=t.name?r.get(t.name):n.find(e=>e.re.test(t.path)),!o)throw B(1,{location:e,currentLocation:t});i=o.record.name,c=l({},t.params,e.params),a=o.stringify(c)}const s=[];let u=o;for(;u;)s.unshift(u.record),u=u.parent;return{name:i,path:a,params:c,matched:s,meta:z(s)}},removeRoute:a,getRoutes:function(){return n},getRecordMatcher:function(e){return r.get(e)}}}function K(e){const t={},n=e.props||!1;if("component"in e)t.default=n;else for(let r in e.components)t[r]="boolean"==typeof n?n:n[r];return t}function Q(e){for(;e;){if(e.record.aliasOf)return!0;e=e.parent}return!1}function z(e){return e.reduce((e,t)=>l(e,t.meta),{})}function X(e,t){let n={};for(let r in e)n[r]=r in t?t[r]:e[r];return n}const Y=/#/g,Z=/&/g,J=/\//g,ee=/=/g,te=/\?/g,ne=/%5B/g,re=/%5D/g,oe=/%5E/g,ae=/%60/g,ie=/%7B/g,ce=/%7C/g,se=/%7D/g;function le(e){return encodeURI(""+e).replace(ce,"|").replace(ne,"[").replace(re,"]")}function ue(e){return le(e).replace(Y,"%23").replace(Z,"%26").replace(ee,"%3D").replace(ae,"`").replace(ie,"{").replace(se,"}").replace(oe,"^")}function fe(e){return function(e){return le(e).replace(Y,"%23").replace(te,"%3F")}(e).replace(J,"%2F")}function pe(e){try{return decodeURIComponent(""+e)}catch(e){}return""+e}function he(e){const t={};if(""===e||"?"===e)return t;const n=("?"===e[0]?e.slice(1):e).split("&");for(let e=0;e<n.length;++e){let[r,o]=n[e].split("=");r=pe(r);let a=null==o?null:pe(o);if(r in t){let e=t[r];Array.isArray(e)||(e=t[r]=[e]),e.push(a)}else t[r]=a}return t}function de(e){let t="";for(let n in e){t.length&&(t+="&");const r=e[n];if(n=ue(n),null==r){void 0!==r&&(t+=n);continue}let o=Array.isArray(r)?r.map(e=>e&&ue(e)):[r&&ue(r)];for(let e=0;e<o.length;e++)t+=(e?"&":"")+n,null!=o[e]&&(t+="="+o[e])}return t}function me(e){const t={};for(let n in e){let r=e[n];void 0!==r&&(t[n]=Array.isArray(r)?r.map(e=>null==e?null:""+e):null==r?r:""+r)}return t}function ge(){let e=[];return{add:function(t){return e.push(t),()=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)}},list:()=>e,reset:function(){e=[]}}}function ve(e,t,n,r,o){const a=r&&(r.enterCallbacks[o]=r.enterCallbacks[o]||[]);return()=>new Promise((i,c)=>{const s=e=>{var s;!1===e?c(B(4,{from:n,to:t})):e instanceof Error?c(e):"string"==typeof(s=e)||s&&"object"==typeof s?c(B(2,{from:t,to:e})):(a&&r.enterCallbacks[o]===a&&"function"==typeof e&&a.push(e),i())};let l=Promise.resolve(e.call(r&&r.instances[o],t,n,s));e.length<3&&(l=l.then(s)),l.catch(e=>c(e))})}function ye(e,t,r,o){const a=[];for(const c of e)for(const e in c.components){let s=c.components[e];if("beforeRouteEnter"===t||c.instances[e])if("object"==typeof(i=s)||"displayName"in i||"props"in i||"__vccOpts"in i){const n=(s.__vccOpts||s)[t];n&&a.push(ve(n,r,o,c,e))}else{let i=s();i=i.catch(()=>null),a.push(()=>i.then(a=>{if(!a)return Promise.reject(new Error(`Couldn't resolve component "${e}" for the following record with path "${c.path}"`));const i=(s=a).__esModule||n&&"Module"===s[Symbol.toStringTag]?a.default:a;var s;c.components[e]=i;const l=i[t];return l&&ve(l,r,o,c,e)()}))}}var i;return a}function be(e){const n=t.inject(i),r=t.inject(c),o=t.computed(()=>n.resolve(t.unref(e.to))),a=t.computed(()=>{let{matched:e}=o.value,{length:t}=e;const n=e[t-1];let a=r.matched;if(!n||!a.length)return-1;let i=a.findIndex(m.bind(null,n));if(i>-1)return i;let c=Re(e[t-2]);return t>1&&Re(n)===c&&a[a.length-1].path!==c?a.findIndex(m.bind(null,e[t-2])):i}),s=t.computed(()=>a.value>-1&&function(e,t){for(let n in t){let r=t[n],o=e[n];if("string"==typeof r){if(r!==o)return!1}else if(!Array.isArray(o)||o.length!==r.length||r.some((e,t)=>e!==o[t]))return!1}return!0}(r.params,o.value.params)),l=t.computed(()=>a.value>-1&&a.value===r.matched.length-1&&g(r.params,o.value.params));return{route:o,href:t.computed(()=>o.value.href),isActive:s,isExactActive:l,navigate:function(r={}){return function(e){if(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)return;if(e.defaultPrevented)return;if(void 0!==e.button&&0!==e.button)return;if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}e.preventDefault&&e.preventDefault();return!0}(r)?n[t.unref(e.replace)?"replace":"push"](t.unref(e.to)):Promise.resolve()}}}const we=t.defineComponent({name:"RouterLink",props:{to:{type:[String,Object],required:!0},activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},setup(e,{slots:n,attrs:r}){const o=t.reactive(be(e)),{options:a}=t.inject(i),c=t.computed(()=>({[Ee(e.activeClass,a.linkActiveClass,"router-link-active")]:o.isActive,[Ee(e.exactActiveClass,a.linkExactActiveClass,"router-link-exact-active")]:o.isExactActive}));return()=>{const a=n.default&&n.default(o);return e.custom?a:t.h("a",l({"aria-current":o.isExactActive?e.ariaCurrentValue:null,onClick:o.navigate,href:o.href},r,{class:c.value}),a)}}});function Re(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}let Ee=(e,t,n)=>null!=e?e:null!=t?t:n;const Oe=t.defineComponent({name:"RouterView",props:{name:{type:String,default:"default"},route:Object},setup(e,{attrs:n,slots:r}){const i=t.inject(c),s=t.inject(a,0),u=t.computed(()=>(e.route||i).matched[s]);t.provide(a,s+1),t.provide(o,u);const f=t.ref();return()=>{const o=e.route||i,a=u.value,c=a&&a.components[e.name];if(!c)return r.default?r.default({Component:c,route:o}):null;const s=a.props[e.name],p=s?!0===s?o.params:"function"==typeof s?s(o):s:null,h=e.name,d=t.h(c,l({},p,n,{onVnodeMounted:()=>{a.instances[h]=f.value,(a.enterCallbacks[h]||[]).forEach(e=>e(f.value))},onVnodeUnmounted:()=>{a.instances[h]=null},ref:f}));return r.default?r.default({Component:d,route:o}):d}}});function ke(e){return e.reduce((e,t)=>e.then(()=>t()),Promise.resolve())}function Ae(e,t){const n=[],r=[],o=[],a=Math.max(t.matched.length,e.matched.length);for(let i=0;i<a;i++){const a=t.matched[i];a&&(e.matched.indexOf(a)<0?n.push(a):r.push(a));const c=e.matched[i];c&&t.matched.indexOf(c)<0&&o.push(c)}return[n,r,o]}return e.RouterLink=we,e.RouterView=Oe,e.START_LOCATION=M,e.createMemoryHistory=function(e=""){let t=[],n=[""],r=0;function o(e){r++,r===n.length||n.splice(r),n.push(e)}const a={location:"",state:{},base:e,createHref:O.bind(null,e),replace(e){n.splice(r--,1),o(e)},push(e,t){o(e)},listen:e=>(t.push(e),()=>{const n=t.indexOf(e);n>-1&&t.splice(n,1)}),destroy(){t=[]},go(e,o=!0){const a=this.location,i=e<0?w.back:w.forward;r=Math.max(0,Math.min(r+e,n.length-1)),o&&function(e,n,{direction:r,delta:o}){const a={direction:r,delta:o,type:b.pop};for(let r of t)r(e,n,a)}(this.location,a,{direction:i,delta:e})}};return Object.defineProperty(a,"location",{get:()=>n[r]}),a},e.createRouter=function(e){const n=N(e.routes,e);let r=e.parseQuery||he,o=e.stringifyQuery||de,{scrollBehavior:a}=e,p=e.history;const d=ge(),v=ge(),y=ge(),b=t.shallowRef(M);let w=M;s&&a&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const R=u.bind(null,e=>""+e),E=u.bind(null,fe),O=u.bind(null,pe);function C(e,t){if(t={...t||b.value},"string"==typeof e){let o=h(r,e,t.path),a=n.resolve({path:o.path},t),i=p.createHref(o.fullPath);return l(o,a,{params:O(a.params),redirectedFrom:void 0,href:i})}let a;"path"in e?a=l({},e,{path:h(r,e.path,t.path).path}):(a=l({},e,{params:E(e.params)}),t.params=E(t.params));let i=n.resolve(a,t);const c=le(e.hash||"").replace(ie,"{").replace(se,"}").replace(oe,"^");i.params=R(O(i.params));const s=function(e,t){let n=t.query?e(t.query):"";return t.path+(n&&"?")+n+(t.hash||"")}(o,l({},e,{hash:c,path:i.path}));let u=p.createHref(s);return l({fullPath:s,hash:c,query:o===de?me(e.query):e.query},i,{redirectedFrom:void 0,href:u})}function j(e){return"string"==typeof e?{path:e}:l({},e)}function $(e,t){if(w!==e)return B(8,{from:t,to:e})}function S(e){return L(e)}function L(e,t){const n=w=C(e),r=b.value,a=e.state,i=e.force,c=!0===e.replace,s=n.matched[n.matched.length-1];if(s&&s.redirect){const{redirect:e}=s;let r=j("function"==typeof e?e(n):e);return L(l({query:n.query,hash:n.hash,params:n.params},r,{state:a,force:i,replace:c}),t||n)}const u=n;let f;return u.redirectedFrom=t,!i&&function(e,t,n){let r=t.matched.length-1,o=n.matched.length-1;return r>-1&&r===o&&m(t.matched[r],n.matched[o])&&g(t.params,n.params)&&e(t.query)===e(n.query)&&t.hash===n.hash}(o,r,n)&&(f=B(16,{to:u,from:r}),X(r,r,!0,!1)),(f?Promise.resolve(f):_(u,r)).catch(e=>I(e,14)?e:Q(e)).then(e=>{if(e){if(I(e,2))return L(l(j(e.to),{state:a,force:i,replace:c}),t||u)}else e=F(u,r,!0,c,a);return V(u,r,e),e})}function T(e,t){const n=$(e,t);return n?Promise.reject(n):Promise.resolve()}function _(e,t){let n;n=ye(t.matched.filter(t=>e.matched.indexOf(t)<0).reverse(),"beforeRouteLeave",e,t);const[r,o]=Ae(e,t);for(const o of r)for(const r of o.leaveGuards)n.push(ve(r,e,t));const a=T.bind(null,e,t);return n.push(a),ke(n).then(()=>{n=[];for(const r of d.list())n.push(ve(r,e,t));return n.push(a),ke(n)}).then(()=>{n=ye(e.matched.filter(e=>t.matched.indexOf(e)>-1),"beforeRouteUpdate",e,t);for(const r of o)for(const o of r.updateGuards)n.push(ve(o,e,t));return n.push(a),ke(n)}).then(()=>{n=[];for(const r of e.matched)if(r.beforeEnter&&t.matched.indexOf(r)<0)if(Array.isArray(r.beforeEnter))for(const o of r.beforeEnter)n.push(ve(o,e,t));else n.push(ve(r.beforeEnter,e,t));return n.push(a),ke(n)}).then(()=>(e.matched.forEach(e=>e.enterCallbacks={}),n=ye(e.matched.filter(e=>t.matched.indexOf(e)<0),"beforeRouteEnter",e,t),n.push(a),ke(n))).then(()=>{n=[];for(const r of v.list())n.push(ve(r,e,t));return n.push(a),ke(n)}).catch(e=>I(e,8)?e:Promise.reject(e))}function V(e,t,n){for(const r of y.list())r(e,t,n)}function F(e,t,n,r,o){const a=$(e,t);if(a)return a;const[i]=Ae(e,t);for(const e of i)e.leaveGuards=[],e.updateGuards=[],e.instances={},e.enterCallbacks={};const c=t===M,u=s?history.state:{};n&&(r||c?p.replace(e.fullPath,l({scroll:c&&u&&u.scroll},o)):p.push(e.fullPath,o)),b.value=e,X(e,t,n,c),z()}let G;function H(){G=p.listen((e,t,n)=>{const r=C(e);w=r;const o=b.value;var a,i;s&&(a=x(o.fullPath,n.delta),i=k(),P.set(a,i)),_(r,o).catch(e=>I(e,12)?e:I(e,2)?(n.delta&&p.go(-n.delta,!1),L(e.to,r).catch(f),Promise.reject()):(n.delta&&p.go(-n.delta,!1),Q(e))).then(e=>{(e=e||F(r,o,!1))&&n.delta&&p.go(-n.delta,!1),V(r,o,e)}).catch(f)})}let U,W,D=ge(),K=ge();function Q(e){return z(e),K.list().forEach(t=>t(e)),Promise.reject(e)}function z(e){U||(U=!0,H(),D.list().forEach(([t,n])=>e?n(e):t()),D.reset())}function X(e,n,r,o){if(!s||!a)return Promise.resolve();let i=!r&&function(e){const t=P.get(e);return P.delete(e),t}(x(e.fullPath,0))||(o||!r)&&history.state&&history.state.scroll||null;return t.nextTick().then(()=>a(e,n,i)).then(e=>e&&A(e)).catch(Q)}function Y(e){return new Promise((t,n)=>{let r=K.add(e=>{r(),o(),n(e)}),o=y.add((e,n,a)=>{r(),o(),t(a)});p.go(e)})}const Z=new Set;return{currentRoute:b,addRoute:function(e,t){let r,o;return q(e)?(r=n.getRecordMatcher(e),o=t):o=e,n.addRoute(o,r)},removeRoute:function(e){let t=n.getRecordMatcher(e);t&&n.removeRoute(t)},hasRoute:function(e){return!!n.getRecordMatcher(e)},getRoutes:function(){return n.getRoutes().map(e=>e.record)},resolve:C,options:e,push:S,replace:function(e){return S(l(j(e),{replace:!0}))},go:Y,back:()=>Y(-1),forward:()=>Y(1),beforeEach:d.add,beforeResolve:v.add,afterEach:y.add,onError:K.add,isReady:function(){return U&&b.value!==M?Promise.resolve():new Promise((e,t)=>{D.add([e,t])})},install(e){e.component("RouterLink",we),e.component("RouterView",Oe),e.config.globalProperties.$router=this,Object.defineProperty(e.config.globalProperties,"$route",{get:()=>t.unref(b)}),s&&!W&&b.value===M&&(W=!0,S(p.location).catch(e=>{}));const n={};for(let e in M)n[e]=t.computed(()=>b.value[e]);e.provide(i,this),e.provide(c,t.reactive(n));let r=e.unmount;Z.add(e),e.unmount=function(){Z.delete(e),Z.size<1&&(G(),b.value=M,W=!1,U=!1),r.call(this,arguments)}}}},e.createRouterMatcher=N,e.createWebHashHistory=function(e){return(e=location.host&&e||location.pathname).indexOf("#")<0&&(e+="#"),L(e)},e.createWebHistory=L,e.isNavigationFailure=I,e.onBeforeRouteLeave=function(e){const n=t.getCurrentInstance();if(!n)return;const r=t.inject(o,{}).value;r&&r.leaveGuards.push(e.bind(n.proxy))},e.onBeforeRouteUpdate=function(e){const n=t.getCurrentInstance();if(!n)return;const r=t.inject(o,{}).value;r&&r.updateGuards.push(e.bind(n.proxy))},e.parseQuery=he,e.stringifyQuery=de,e.useLink=be,e.useRoute=function(){return t.inject(c)},e.useRouter=function(){return t.inject(i)},e}({},Vue); |
{ | ||
"name": "vue-router", | ||
"version": "4.0.0-beta.6", | ||
"version": "4.0.0-beta.7", | ||
"main": "dist/vue-router.cjs.js", | ||
@@ -10,5 +10,2 @@ "browser": "dist/vue-router.esm.js", | ||
"types": "dist/vue-router.d.ts", | ||
"tsd": { | ||
"directory": "test-dts" | ||
}, | ||
"sideEffects": false, | ||
@@ -25,3 +22,3 @@ "license": "MIT", | ||
"build": "rollup -c rollup.config.js", | ||
"build:dts": "api-extractor run --local --verbose", | ||
"build:dts": "api-extractor run --local --verbose && tail -n +7 src/globalExtensions.ts >> dist/vue-router.d.ts", | ||
"dev": "webpack-dev-server --mode=development", | ||
@@ -37,3 +34,3 @@ "release": "bash scripts/release.sh", | ||
"test:types": "tsc --build tsconfig.json", | ||
"test:tsd": "tsd", | ||
"test:dts": "tsc -p ./test-dts/tsconfig.json", | ||
"test:unit": "jest --coverage", | ||
@@ -67,3 +64,3 @@ "test": "yarn run test:types && yarn run test:unit && yarn run build && yarn run build:dts && yarn run test:e2e", | ||
"peerDependencies": { | ||
"vue": "^3.0.0-beta.20" | ||
"vue": "^3.0.0-rc.5" | ||
}, | ||
@@ -75,3 +72,3 @@ "vetur": { | ||
"devDependencies": { | ||
"@microsoft/api-documenter": "^7.8.21", | ||
"@microsoft/api-documenter": "^7.8.27", | ||
"@microsoft/api-extractor": "^7.8.1", | ||
@@ -82,20 +79,20 @@ "@rollup/plugin-alias": "^3.1.1", | ||
"@rollup/plugin-replace": "^2.3.3", | ||
"@size-limit/preset-small-lib": "^4.5.5", | ||
"@types/jest": "^26.0.8", | ||
"@size-limit/preset-small-lib": "^4.5.6", | ||
"@types/jest": "^26.0.10", | ||
"@types/jsdom": "^16.2.3", | ||
"@types/webpack": "^4.41.21", | ||
"@types/webpack-env": "^1.15.2", | ||
"@vue/compiler-sfc": "3.0.0-rc.2", | ||
"@vue/server-renderer": "^3.0.0-rc.2", | ||
"@vue/compiler-sfc": "3.0.0-rc.5", | ||
"@vue/server-renderer": "^3.0.0-rc.5", | ||
"axios": "^0.19.2", | ||
"browserstack-local": "^1.4.5", | ||
"chalk": "^4.1.0", | ||
"chromedriver": "^83.0.1", | ||
"chromedriver": "^84.0.1", | ||
"codecov": "^3.7.2", | ||
"conventional-changelog-cli": "^2.0.34", | ||
"css-loader": "^3.6.0", | ||
"conventional-changelog-cli": "^2.1.0", | ||
"css-loader": "^4.2.1", | ||
"dotenv": "^8.2.0", | ||
"faked-promise": "^2.2.2", | ||
"html-webpack-plugin": "^4.3.0", | ||
"jest": "^26.2.2", | ||
"jest": "^26.4.0", | ||
"jest-mock-warn": "^1.1.0", | ||
@@ -106,8 +103,8 @@ "lint-staged": "^10.2.11", | ||
"prettier": "^2.0.5", | ||
"rollup": "^2.23.0", | ||
"rollup": "^2.26.3", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"rollup-plugin-typescript2": "^0.27.2", | ||
"selenium-server": "^3.141.59", | ||
"serve-handler": "^6.1.3", | ||
"size-limit": "^4.5.5", | ||
"size-limit": "^4.5.6", | ||
"style-loader": "^1.2.1", | ||
@@ -117,6 +114,5 @@ "ts-jest": "^26.1.4", | ||
"ts-node": "^8.10.2", | ||
"tsd": "^0.11.0", | ||
"typescript": "^3.9.7", | ||
"vue": "^3.0.0-beta.20", | ||
"vue-loader": "^16.0.0-beta.4", | ||
"vue": "^3.0.0-rc.5", | ||
"vue-loader": "^16.0.0-beta.5", | ||
"webpack": "^4.44.1", | ||
@@ -123,0 +119,0 @@ "webpack-bundle-analyzer": "^3.8.0", |
@@ -48,3 +48,3 @@ # vue-router-next [![CircleCI](https://circleci.com/gh/vuejs/vue-router-next.svg?style=svg)](https://circleci.com/gh/vuejs/vue-router-next) | ||
Otherwise there will be an initial transition as if you provided the `appear` prop to `transition` because the router displays its initial location (nothing) and then displays the first location. This happens because navigations are all asynchronous now. **If you have navigation guards upon the initial navigation**, you might not want to block the app render until they are resolved. | ||
- On SSR, you need to manually pass the appropriate history by using a ternary: | ||
- On SSR, you need to manually pass the appropriate history: | ||
```js | ||
@@ -60,3 +60,3 @@ // router.js | ||
``` | ||
- The object returned in `scrollBehavior` is now similar to [`ScrollToOptions`](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions): `x` is renamed to `left` and `y` is renamed to `top`. | ||
- The object returned in `scrollBehavior` is now similar to [`ScrollToOptions`](https://developer.mozilla.org/en-US/docs/Web/API/ScrollToOptions): `x` is renamed to `left` and `y` is renamed to `top`. See [RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0035-router-scroll-position.md). | ||
- `transition` and `keep-alive` must now be used **inside** of `RouterView` via the `v-slot` API: | ||
@@ -72,6 +72,6 @@ ```vue | ||
``` | ||
See more on the [KeepAlive](https://github.com/vuejs/vue-router-next/blob/master/e2e/keep-alive/index.ts) and the [Transition](https://github.com/vuejs/vue-router-next/blob/master/e2e/transitions/index.ts) examples. | ||
See more on the [KeepAlive](https://github.com/vuejs/vue-router-next/blob/master/e2e/keep-alive/index.ts) and the [Transition](https://github.com/vuejs/vue-router-next/blob/master/e2e/transitions/index.ts) examples. See [RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0034-router-view-keep-alive-transitions.md). | ||
- `parent` is removed from Route locations (`this.$route` and object returned by `router.resolve`). You can still access it via the `matched` array: | ||
```js | ||
const parent = this.$route.matched[this.$route.matched.length -1] | ||
const parent = this.$route.matched[this.$route.matched.length - 2] | ||
``` | ||
@@ -78,0 +78,0 @@ |
@@ -16,2 +16,6 @@ { | ||
}, | ||
"custom": { | ||
"type": "boolean", | ||
"description": "Whether `<router-link>` should not wrap its content in an `<a>` tag." | ||
}, | ||
"active-class": { | ||
@@ -18,0 +22,0 @@ "type": "string", |
@@ -7,5 +7,5 @@ { | ||
"router-link": { | ||
"attributes": ["to", "activeClass","exactActiveClass", "custom"], | ||
"attributes": ["to", "replace", "custom", "active-class","exact-active-class", "aria-current-value"], | ||
"description": "Component that renders an `<a>` with the correct `href` attribute and click listeners to trigger a local navigation when clicked. Can also customize its rendering by providing the `custom` prop and using its `v-slot` API." | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
627936
47
13999
35