From 346d30ca73485435801700f0386a654c45619197 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 11 Jul 2019 22:41:11 +0200 Subject: [PATCH] Workaround bublejs/buble#210 :( --- dist/vue-router.common.js | 28 ++++++++++++++-------------- dist/vue-router.esm.browser.js | 24 +++++++++++++----------- dist/vue-router.esm.browser.min.js | 2 +- dist/vue-router.esm.js | 28 ++++++++++++++-------------- dist/vue-router.js | 28 ++++++++++++++-------------- dist/vue-router.min.js | 2 +- src/history/base.js | 24 +++++++++++++----------- 7 files changed, 70 insertions(+), 66 deletions(-) diff --git a/dist/vue-router.common.js b/dist/vue-router.common.js index 06703fb62..6d2a86499 100644 --- a/dist/vue-router.common.js +++ b/dist/vue-router.common.js @@ -2168,28 +2168,28 @@ function resolveQueues ( next, equalLayers ) { - var ref, ref$1, ref$2, ref$3, ref$4; - - var res = { - updated: [], - activated: [], - deactivated: [] - }; + var updated = []; + var activated = []; + var deactivated = []; var min = Math.min(current.length, next.length); for (var i = equalLayers; i < min; i++) { - var r = resolveQueue(current[i].matched, next[i].matched) - (ref = res.updated).push.apply(ref, r.updated) - (ref$1 = res.activated).push.apply(ref$1, r.activated) - (ref$2 = res.deactivated).push.apply(ref$2, r.deactivated); + var r = resolveQueue(current[i].matched, next[i].matched); + updated.push.apply(updated, r.updated); + activated.push.apply(activated, r.activated); + deactivated.push.apply(deactivated, r.deactivated); } for (var i$1 = min; i$1 < current.length; i$1++) { - (ref$3 = res.deactivated).push.apply(ref$3, current[i$1].matched); + deactivated.push.apply(deactivated, current[i$1].matched); } for (var i$2 = min; i$2 < next.length; i$2++) { - (ref$4 = res.activated).push.apply(ref$4, next[i$2].matched); + activated.push.apply(activated, next[i$2].matched); + } + return { + updated: updated, + activated: activated, + deactivated: deactivated } - return res } function resolveQueue ( diff --git a/dist/vue-router.esm.browser.js b/dist/vue-router.esm.browser.js index 0b50c04e4..b1d2a20e3 100644 --- a/dist/vue-router.esm.browser.js +++ b/dist/vue-router.esm.browser.js @@ -2148,26 +2148,28 @@ function resolveQueues ( next, equalLayers ) { - const res = { - updated: [], - activated: [], - deactivated: [] - }; + const updated = []; + const activated = []; + const deactivated = []; const min = Math.min(current.length, next.length); for (let i = equalLayers; i < min; i++) { const r = resolveQueue(current[i].matched, next[i].matched); - res.updated.push(...r.updated); - res.activated.push(...r.activated); - res.deactivated.push(...r.deactivated); + updated.push(...r.updated); + activated.push(...r.activated); + deactivated.push(...r.deactivated); } for (let i = min; i < current.length; i++) { - res.deactivated.push(...current[i].matched); + deactivated.push(...current[i].matched); } for (let i = min; i < next.length; i++) { - res.activated.push(...next[i].matched); + activated.push(...next[i].matched); + } + return { + updated, + activated, + deactivated } - return res } function resolveQueue ( diff --git a/dist/vue-router.esm.browser.min.js b/dist/vue-router.esm.browser.min.js index 91bdbeb68..8d3ce9556 100644 --- a/dist/vue-router.esm.browser.min.js +++ b/dist/vue-router.esm.browser.min.js @@ -3,4 +3,4 @@ * (c) 2019 Evan You * @license MIT */ -function t(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function e(t,e){return e instanceof t||e&&e.name===t.name}function r(t,e){for(const r in e)t[r]=e[r];return t}var n={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"},nextLayer:{type:Boolean,default:!1}},render(t,{props:e,children:n,parent:o,data:s}){s.routerView=!0;const i=o.$createElement,a=e.name,c=o._routerViewCache||(o._routerViewCache={}),h=o._routerLayer+(e.nextLayer?1:0);if(o._routerRoot._routes.length<=h)return c[a]=null,i();const u=o._routerRoot._routes[h];let l=0,p=!1;for(;o&&o._routerRoot!==o;){const t=o.$vnode&&o.$vnode.data;t&&(t.routerView&&l++,t.keepAlive&&o._inactive&&(p=!0)),o=o.$parent}if(s.routerViewDepth=l,p)return i(c[a],s,n);const f=u.matched[l];if(!f)return c[a]=null,i();const d=c[a]=f.components[a];s.registerRouteInstance=(t,e)=>{const r=f.instances[a];(e&&r!==t||!e&&r===t)&&(f.instances[a]=e),t._routerLayer=h},(s.hook||(s.hook={})).prepatch=(t,e)=>{f.instances[a]=e.componentInstance},s.hook.init=t=>{t.data.keepAlive&&t.componentInstance&&t.componentInstance!==f.instances[a]&&(f.instances[a]=t.componentInstance)};let y=s.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}(u,f.props&&f.props[a]);if(y){y=s.props=r({},y);const t=s.attrs=s.attrs||{};for(const e in y)d.props&&e in d.props||(t[e]=y[e],delete y[e])}return i(d,s,n)}};const o=/[!'()*]/g,s=t=>"%"+t.charCodeAt(0).toString(16),i=/%2C/g,a=t=>encodeURIComponent(t).replace(o,s).replace(i,","),c=decodeURIComponent;function h(t){const e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(t=>{const r=t.replace(/\+/g," ").split("="),n=c(r.shift()),o=r.length>0?c(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function u(t){const e=t?Object.keys(t).map(e=>{const r=t[e];if(void 0===r)return"";if(null===r)return a(e);if(Array.isArray(r)){const t=[];return r.forEach(r=>{void 0!==r&&(null===r?t.push(a(e)):t.push(a(e)+"="+a(r)))}),t.join("&")}return a(e)+"="+a(r)}).filter(t=>t.length>0).join("&"):null;return e?`?${e}`:""}const l=/\/?$/;function p(t,e,r,n){const o=n&&n.options.stringifyQuery;let s=e.query||{};try{s=f(s)}catch(t){}const i={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:s,params:e.params||{},fullPath:m(e,o),matched:t?y(t):[]};return r&&(i.redirectedFrom=m(r,o)),Object.freeze(i)}function f(t){if(Array.isArray(t))return t.map(f);if(t&&"object"==typeof t){const e={};for(const r in t)e[r]=f(t[r]);return e}return t}const d=p(null,{path:"/"});function y(t){const e=[];for(;t;)e.unshift(t),t=t.parent;return e}function m({path:t,query:e={},hash:r=""},n){return(t||"/")+(n||u)(e)+r}function g(t,e){return e===d?t===e:!!e&&(t.path&&e.path?t.path.replace(l,"")===e.path.replace(l,"")&&t.hash===e.hash&&v(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&v(t.query,e.query)&&v(t.params,e.params)))}function v(t={},e={}){if(!t||!e)return t===e;const r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(r=>{const n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?v(n,o):String(n)===String(o)})}function w(t,e,r){const n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;const o=e.split("/");r&&o[o.length-1]||o.pop();const s=t.replace(/^\//,"").split("/");for(let t=0;t=0&&(e=t.slice(n),t=t.slice(0,n));const o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}(s.path||""),a=e&&e.path||"/",c=i.path?w(i.path,a,n||s.append):a,u=function(t,e={},r){const n=r||h;let o;try{o=n(t||"")}catch(t){o={}}for(const t in e)o[t]=e[t];return o}(i.query,s.query,o&&o.options.parseQuery);let l=s.hash||i.hash;return l&&"#"!==l.charAt(0)&&(l=`#${l}`),{_normalized:!0,path:c,query:u,hash:l}}const V=[String,Object],H=[String,Array];var z={name:"RouterLink",props:{to:{type:V,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,addLayer:Boolean,removeLayer:Boolean,activeClass:String,exactActiveClass:String,event:{type:H,default:"click"}},render(t){const e=this.$router,n=this.$route,{location:o,route:s,href:i}=e.resolve(this.to,n,this.append),a={},c=e.options.linkActiveClass,h=e.options.linkExactActiveClass,u=null==c?"router-link-active":c,f=null==h?"router-link-exact-active":h,d=null==this.activeClass?u:this.activeClass,y=null==this.exactActiveClass?f:this.exactActiveClass,m=s.redirectedFrom?p(null,B(s.redirectedFrom),null,e):s;a[y]=g(n,m),a[d]=this.exact?a[y]:function(t,e){return 0===t.path.replace(l,"/").indexOf(e.path.replace(l,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(const r in e)if(!(r in t))return!1;return!0}(t.query,e.query)}(n,m);const v=t=>{F(t)&&(this.replace?this.addLayer?e.replaceAddLayer(o):this.removeLayer?e.replaceRemoveLayer():e.replaceLayer(this._routerLayer,o):this.addLayer?e.pushAddLayer(o):this.removeLayer?e.pushRemoveLayer():e.pushLayer(this._routerLayer,o))},w={click:F};Array.isArray(this.event)?this.event.forEach(t=>{w[t]=v}):w[this.event]=v;const b={class:a};if("a"===this.tag)b.on=w,b.attrs={href:i};else{const t=function t(e){if(e){let r;for(let n=0;n{!function t(e,r,n,o,s,i){const{path:a,name:c}=o;const h=o.pathToRegexpOptions||{};const u=function(t,e,r){r||(t=t.replace(/\/$/,""));return"/"===t[0]?t:null==e?t:b(`${e.path}/${t}`)}(a,s,h.strict);"boolean"==typeof o.caseSensitive&&(h.sensitive=o.caseSensitive);const l={path:u,regex:Q(u,h),components:o.components||{default:o.component},instances:{},name:c,parent:s,matchAs:i,redirect:o.redirect,beforeEnter:o.beforeEnter,meta:o.meta||{},props:null==o.props?{}:o.components?o.props:{default:o.props}};o.children&&o.children.forEach(o=>{const s=i?b(`${i}/${o.path}`):void 0;t(e,r,n,o,l,s)});if(void 0!==o.alias){const i=Array.isArray(o.alias)?o.alias:[o.alias];i.forEach(i=>{const a={path:i,children:o.children};t(e,r,n,a,s,l.path||"/")})}r[l.path]||(e.push(l.path),r[l.path]=l);c&&(n[c]||(n[c]=l))}(o,s,i,t)});for(let t=0,e=o.length;t!t.optional).map(t=>t.name);if("object"!=typeof c.params&&(c.params={}),s&&"object"==typeof s.params)for(const t in s.params)!(t in c.params)&&e.indexOf(t)>-1&&(c.params[t]=s.params[t]);return c.path=M(t.path,c.params),a(t,c,i)}if(c.path){c.params={};for(let t=0;t{tt(),t.state&&t.state.key&&function(t){ct=t}(t.state.key)})}function Z(t,e,r,n){if(!t.app)return;const o=t.options.scrollBehavior;o&&t.app.$nextTick(()=>{const s=function(){const t=ut();if(t)return W[t]}(),i=o.call(t,e,r,n?s:null);i&&("function"==typeof i.then?i.then(t=>{st(t,s)}).catch(t=>{}):st(i,s))})}function tt(){const t=ut();t&&(W[t]={x:window.pageXOffset,y:window.pageYOffset})}function et(t){return nt(t.x)||nt(t.y)}function rt(t){return{x:nt(t.x)?t.x:window.pageXOffset,y:nt(t.y)?t.y:window.pageYOffset}}function nt(t){return"number"==typeof t}const ot=/^#\d/;function st(t,e){const r="object"==typeof t;if(r&&"string"==typeof t.selector){const r=ot.test(t.selector)?document.getElementById(t.selector.slice(1)):document.querySelector(t.selector);if(r){let o=t.offset&&"object"==typeof t.offset?t.offset:{};e=function(t,e){const r=document.documentElement.getBoundingClientRect(),n=t.getBoundingClientRect();return{x:n.left-r.left-e.x,y:n.top-r.top-e.y}}(r,o={x:nt((n=o).x)?n.x:0,y:nt(n.y)?n.y:0})}else et(t)&&(e=rt(t))}else r&&et(t)&&(e=rt(t));var n;e&&window.scrollTo(e.x,e.y)}const it=N&&function(){const t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),at=N&&window.performance&&window.performance.now?window.performance:Date;let ct=ht();function ht(){return at.now().toFixed(3)}function ut(){return ct}function lt(t,e,r){tt();const n=window.history;try{r?n.replaceState({key:ct,state:e},"",t):(ct=ht(),n.pushState({key:ct,state:e},"",t))}catch(e){window.location[r?"replace":"assign"](t)}}function pt(t,e,r){const n=o=>{o>=t.length?r():t[o]?e(t[o],()=>{n(o+1)}):n(o+1)};n(0)}function ft(e){return(r,n,o)=>{let s=!1,i=0,a=null;dt(e,(e,r,n,c)=>{if("function"==typeof e&&void 0===e.cid){s=!0,i++;const r=gt(t=>{(function(t){return t.__esModule||mt&&"Module"===t[Symbol.toStringTag]})(t)&&(t=t.default),e.resolved="function"==typeof t?t:D.extend(t),n.components[c]=t,--i<=0&&o()}),h=gt(e=>{const r=`Failed to resolve async component ${c}: ${e}`;a||(a=t(e)?e:new Error(r),o(a))});let u;try{u=e(r,h)}catch(t){h(t)}if(u)if("function"==typeof u.then)u.then(r,h);else{const t=u.component;t&&"function"==typeof t.then&&t.then(r,h)}}}),s||o()}}function dt(t,e){return yt(t.map(t=>Object.keys(t.components).map(r=>e(t.components[r],t.instances[r],t,r))))}function yt(t){return Array.prototype.concat.apply([],t)}const mt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function gt(t){let e=!1;return function(...r){if(!e)return e=!0,t.apply(this,r)}}class vt extends Error{constructor(){super("Navigating to current location is not allowed"),this.name="NavigationDuplicated"}}class wt{constructor(t,e){this.router=t,this.base=function(t){if(!t)if(N){const e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=[d],this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]}listen(t){this.cb=t}onReady(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))}onError(t){this.errorCbs.push(t)}getClosestCurrent(t){return t>=this.current.length?this.current[this.current.length-1]:this.current[t]}transitionTo(t,e,r){const n=t.map((t,e)=>this.router.match(t,this.getClosestCurrent(e)));this.confirmTransition(n,t=>{this.updateCurrent(n,t),e&&e(n),this.ensureURL(),this.ready||(this.ready=!0,this.readyCbs.forEach(t=>{t(n)}))},t=>{r&&r(t),t&&!this.ready&&(this.ready=!0,this.readyErrorCbs.forEach(e=>{e(t)}))})}confirmTransition(r,n,o){const s=this.current,i=r=>{!e(vt,r)&&t(r)&&(this.errorCbs.length?this.errorCbs.forEach(t=>{t(r)}):console.error(r)),o&&o(r)};let a=0;for(a=0;at.beforeEnter),ft(u));this.pending=r;const p=(e,n)=>{if(this.pending!==r)return i();try{e(r,s,e=>{!1===e||t(e)?(this.ensureURL(!0),i(e)):"string"==typeof e||"object"==typeof e&&("string"==typeof e.path||"string"==typeof e.name)?(i(),"object"==typeof e&&e.replace?this.replace(e):this.push(e)):n(e)})}catch(t){i(t)}};pt(l,p,()=>{const t=[];pt(function(t,e,r){return Lt(t,"beforeRouteEnter",(t,n,o,s)=>(function(t,e,r,n,o){return function(s,i,a){return t(s,i,t=>{"function"==typeof t&&n.push(()=>{!function t(e,r,n,o){r[n]&&!r[n]._isBeingDestroyed?e(r[n]):o()&&setTimeout(()=>{t(e,r,n,o)},16)}(t,e.instances,r,o)}),a(t)})}})(t,o,s,e,r))}(u,t,()=>this.current===r).concat(this.router.resolveHooks),p,()=>{if(this.pending!==r)return i();this.pending=null,n(a),this.router.app&&this.router.app.$nextTick(()=>{t.forEach(t=>{t()})})})})}updateCurrent(t,e){const r=this.current;this.current=t,this.cb&&this.cb(t,e),this.router.afterHooks.forEach(e=>{e&&e(t,r)})}}function bt(t,e){let r;const n=Math.max(t.length,e.length);for(r=0;r{const i=function(t,e){"function"!=typeof t&&(t=D.extend(t));return t.options[e]}(t,e);if(i)return Array.isArray(i)?i.map(t=>r(t,n,o,s)):r(i,n,o,s)});return yt(n?o.reverse():o)}function xt(t,e){if(e)return function(){return t.apply(e,arguments)}}class Rt extends wt{constructor(t,e){super(t,e);const r=t.options.scrollBehavior,n=it&&r;n&&G();const o=kt(this.base);window.addEventListener("popstate",e=>{const r=this.current,s=kt(this.base);if(this.current===d&&s===o)return;let i=[s];window.history.state.state&&(i=window.history.state.state),this.transitionTo(i,e=>{n&&Z(t,e,r,!0)})})}go(t){window.history.go(t)}navigateAllLayers(t,e,r,n){const{current:o}=this;this.transitionTo(t,t=>{this.ensureURL(e);const n=this.current[this.current.length-1];Z(this.router,n,o,!1),r&&r(n)},n)}navigateLastLayer(t,e,r,n){const o=[...this.current.slice(0,-1).map(t=>t.fullPath),t];this.navigateAllLayers(o,e,r,n)}navigateLayer(t,e,r,n,o){const s=[...this.current.slice(0,t).map(t=>t.fullPath),e,...this.current.slice(t+1).map(t=>t.fullPath)];this.navigateAllLayers(s,r,n,o)}navigateAddLayer(t,e,r,n){const o=[...this.current.map(t=>t.fullPath),t];this.navigateAllLayers(o,e,r,n)}navigateRemoveLayer(t,e,r,n){const o=this.current.slice(0,-1).map(t=>t.fullPath);this.navigateAllLayers(o,e,r,n)}ensureURL(t){const e=this.current[this.current.length-1];if(kt(this.base)!==e.fullPath){lt(b(this.base+e.fullPath),this.current.map(t=>t.fullPath),!t)}}getCurrentLocation(){return kt(this.base)}}function kt(t){let e=decodeURI(window.location.pathname);return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}class At extends wt{constructor(t,e,r){super(t,e),r&&function(t){const e=kt(t);if(!/^\/#/.test(e))return window.location.replace(b(t+"/#"+e)),!0}(this.base)||Et()}setupListeners(){const t=this.router.options.scrollBehavior,e=it&&t;e&&G(),window.addEventListener(it?"popstate":"hashchange",()=>{const t=this.current;Et()&&this.transitionTo(Ct(),r=>{e&&Z(this.router,r,t,!0),it||$t(r.fullPath)})})}push(t,e,r){const{current:n}=this;this.transitionTo(t,t=>{Ot(t.fullPath),Z(this.router,t,n,!1),e&&e(t)},r)}replace(t,e,r){const{current:n}=this;this.transitionTo(t,t=>{$t(t.fullPath),Z(this.router,t,n,!1),e&&e(t)},r)}go(t){window.history.go(t)}ensureURL(t){const e=this.current.fullPath;Ct()!==e&&(t?Ot(e):$t(e))}getCurrentLocation(){return Ct()}}function Et(){const t=Ct();return"/"===t.charAt(0)||($t("/"+t),!1)}function Ct(){let t=window.location.href;const e=t.indexOf("#");if(e<0)return"";const r=(t=t.slice(e+1)).indexOf("?");if(r<0){const e=t.indexOf("#");t=e>-1?decodeURI(t.slice(0,e))+t.slice(e):decodeURI(t)}else r>-1&&(t=decodeURI(t.slice(0,r))+t.slice(r));return t}function _t(t){const e=window.location.href,r=e.indexOf("#");return`${r>=0?e.slice(0,r):e}#${t}`}function Ot(t){it?lt(_t(t)):window.location.hash=t}function $t(t){it?lt(_t(t),!0):window.location.replace(_t(t))}class jt extends wt{constructor(t,e){super(t,e),this.stack=[],this.index=-1}push(t,e,r){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index+1).concat(t),this.index++,e&&e(t)},r)}replace(t,e,r){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index).concat(t),e&&e(t)},r)}go(t){const r=this.index+t;if(r<0||r>=this.stack.length)return;const n=this.stack[r];this.confirmTransition(n,()=>{this.index=r,this.updateRoute(n)},t=>{e(vt,t)&&(this.index=r)})}getCurrentLocation(){const t=this.stack[this.stack.length-1];return t?t.fullPath:"/"}ensureURL(){}}class Tt{constructor(t={}){this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=X(t.routes||[],this);let e=t.mode||"hash";switch(this.fallback="history"===e&&!it&&!1!==t.fallback,this.fallback&&(e="hash"),N||(e="abstract"),this.mode=e,e){case"history":this.history=new Rt(this,t.base);break;case"hash":this.history=new At(this,t.base,this.fallback);break;case"abstract":this.history=new jt(this,t.base)}}match(t,e,r){return this.matcher.match(t,e,r)}get currentRoute(){return this.history&&this.history.current}init(t){if(this.apps.push(t),t.$once("hook:destroyed",()=>{const e=this.apps.indexOf(t);e>-1&&this.apps.splice(e,1),this.app===t&&(this.app=this.apps[0]||null)}),this.app)return;this.app=t;const e=this.history;if(e instanceof Rt)e.transitionTo([e.getCurrentLocation()]);else if(e instanceof At){const t=()=>{e.setupListeners()};e.transitionTo(e.getCurrentLocation(),t,t)}e.listen((t,e)=>{this.apps.forEach(r=>{for(let n=e;nt.length;)r._routes.pop()})})}beforeEach(t){return St(this.beforeHooks,t)}beforeResolve(t){return St(this.resolveHooks,t)}afterEach(t){return St(this.afterHooks,t)}onReady(t,e){this.history.onReady(t,e)}onError(t){this.history.onError(t)}push(t,e,r){this.history.navigateLastLayer(t,!0,e,r)}replace(t,e,r){this.history.navigateLastLayer(t,!1,e,r)}pushAddLayer(t,e,r){this.history.navigateAddLayer(t,!0,e,r)}replaceAddLayer(t,e,r){this.history.navigateAddLayer(t,!1,e,r)}pushRemoveLayer(t,e){this.history.navigateRemoveLayer(!0,t,e)}replaceRemoveLayer(t,e){this.history.navigateRemoveLayer(!1,t,e)}pushLayer(t,e,r,n){this.history.navigateLayer(t,e,!0,r,n)}replaceLayer(t,e,r,n){this.history.navigateLayer(t,e,!1,r,n)}pushAllLayers(t,e,r){this.history.navigateAllLayers(t,!0,e,r)}replaceAllLayers(t,e,r){this.history.navigateAllLayers(t,!1,e,r)}go(t){this.history.go(t)}back(){this.go(-1)}forward(){this.go(1)}getMatchedComponents(t){const e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(t=>Object.keys(t.components).map(e=>t.components[e]))):[]}resolve(t,e,r){const n=B(t,e=e||this.history.current,r,this),o=this.match(n,e),s=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:function(t,e,r){var n="hash"===r?"#"+e:e;return t?b(t+"/"+n):n}(this.history.base,s,this.mode),normalizedTo:n,resolved:o}}addRoutes(t){this.matcher.addRoutes(t),this.history.current!==d&&this.history.transitionTo(this.history.getCurrentLocation())}}function St(t,e){return t.push(e),()=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)}}Tt.install=function t(e){if(t.installed&&D===e)return;t.installed=!0,D=e;const r=t=>void 0!==t,o=(t,e)=>{let n=t.$options._parentVnode;r(n)&&r(n=n.data)&&r(n=n.registerRouteInstance)&&n(t,e)};e.mixin({beforeCreate(){r(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),this._routerLayer=0,e.util.defineReactive(this,"_routes",this._router.history.current)):(this._routerRoot=this.$parent&&this.$parent._routerRoot||this,this._routerLayer=this.$parent?this.$parent._routerLayer:0),o(this,this)},destroyed(){o(this)}}),Object.defineProperty(e.prototype,"$router",{get(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$routerLayer",{get(){return new K(this._routerRoot._router,this._routerLayer)}}),Object.defineProperty(e.prototype,"$route",{get(){return this._routerRoot._routes[this._routerLayer]}}),e.component("RouterView",n),e.component("RouterLink",z);const s=e.config.optionMergeStrategies;s.beforeRouteEnter=s.beforeRouteLeave=s.beforeRouteUpdate=s.created},Tt.version="3.0.7",N&&window.Vue&&window.Vue.use(Tt);export default Tt; \ No newline at end of file +function t(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function e(t,e){return e instanceof t||e&&e.name===t.name}function r(t,e){for(const r in e)t[r]=e[r];return t}var n={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"},nextLayer:{type:Boolean,default:!1}},render(t,{props:e,children:n,parent:o,data:s}){s.routerView=!0;const i=o.$createElement,a=e.name,c=o._routerViewCache||(o._routerViewCache={}),h=o._routerLayer+(e.nextLayer?1:0);if(o._routerRoot._routes.length<=h)return c[a]=null,i();const u=o._routerRoot._routes[h];let l=0,p=!1;for(;o&&o._routerRoot!==o;){const t=o.$vnode&&o.$vnode.data;t&&(t.routerView&&l++,t.keepAlive&&o._inactive&&(p=!0)),o=o.$parent}if(s.routerViewDepth=l,p)return i(c[a],s,n);const f=u.matched[l];if(!f)return c[a]=null,i();const d=c[a]=f.components[a];s.registerRouteInstance=(t,e)=>{const r=f.instances[a];(e&&r!==t||!e&&r===t)&&(f.instances[a]=e),t._routerLayer=h},(s.hook||(s.hook={})).prepatch=(t,e)=>{f.instances[a]=e.componentInstance},s.hook.init=t=>{t.data.keepAlive&&t.componentInstance&&t.componentInstance!==f.instances[a]&&(f.instances[a]=t.componentInstance)};let y=s.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}(u,f.props&&f.props[a]);if(y){y=s.props=r({},y);const t=s.attrs=s.attrs||{};for(const e in y)d.props&&e in d.props||(t[e]=y[e],delete y[e])}return i(d,s,n)}};const o=/[!'()*]/g,s=t=>"%"+t.charCodeAt(0).toString(16),i=/%2C/g,a=t=>encodeURIComponent(t).replace(o,s).replace(i,","),c=decodeURIComponent;function h(t){const e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(t=>{const r=t.replace(/\+/g," ").split("="),n=c(r.shift()),o=r.length>0?c(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function u(t){const e=t?Object.keys(t).map(e=>{const r=t[e];if(void 0===r)return"";if(null===r)return a(e);if(Array.isArray(r)){const t=[];return r.forEach(r=>{void 0!==r&&(null===r?t.push(a(e)):t.push(a(e)+"="+a(r)))}),t.join("&")}return a(e)+"="+a(r)}).filter(t=>t.length>0).join("&"):null;return e?`?${e}`:""}const l=/\/?$/;function p(t,e,r,n){const o=n&&n.options.stringifyQuery;let s=e.query||{};try{s=f(s)}catch(t){}const i={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:s,params:e.params||{},fullPath:m(e,o),matched:t?y(t):[]};return r&&(i.redirectedFrom=m(r,o)),Object.freeze(i)}function f(t){if(Array.isArray(t))return t.map(f);if(t&&"object"==typeof t){const e={};for(const r in t)e[r]=f(t[r]);return e}return t}const d=p(null,{path:"/"});function y(t){const e=[];for(;t;)e.unshift(t),t=t.parent;return e}function m({path:t,query:e={},hash:r=""},n){return(t||"/")+(n||u)(e)+r}function g(t,e){return e===d?t===e:!!e&&(t.path&&e.path?t.path.replace(l,"")===e.path.replace(l,"")&&t.hash===e.hash&&v(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&v(t.query,e.query)&&v(t.params,e.params)))}function v(t={},e={}){if(!t||!e)return t===e;const r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(r=>{const n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?v(n,o):String(n)===String(o)})}function w(t,e,r){const n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;const o=e.split("/");r&&o[o.length-1]||o.pop();const s=t.replace(/^\//,"").split("/");for(let t=0;t=0&&(e=t.slice(n),t=t.slice(0,n));const o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}(s.path||""),a=e&&e.path||"/",c=i.path?w(i.path,a,n||s.append):a,u=function(t,e={},r){const n=r||h;let o;try{o=n(t||"")}catch(t){o={}}for(const t in e)o[t]=e[t];return o}(i.query,s.query,o&&o.options.parseQuery);let l=s.hash||i.hash;return l&&"#"!==l.charAt(0)&&(l=`#${l}`),{_normalized:!0,path:c,query:u,hash:l}}const V=[String,Object],H=[String,Array];var z={name:"RouterLink",props:{to:{type:V,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,addLayer:Boolean,removeLayer:Boolean,activeClass:String,exactActiveClass:String,event:{type:H,default:"click"}},render(t){const e=this.$router,n=this.$route,{location:o,route:s,href:i}=e.resolve(this.to,n,this.append),a={},c=e.options.linkActiveClass,h=e.options.linkExactActiveClass,u=null==c?"router-link-active":c,f=null==h?"router-link-exact-active":h,d=null==this.activeClass?u:this.activeClass,y=null==this.exactActiveClass?f:this.exactActiveClass,m=s.redirectedFrom?p(null,B(s.redirectedFrom),null,e):s;a[y]=g(n,m),a[d]=this.exact?a[y]:function(t,e){return 0===t.path.replace(l,"/").indexOf(e.path.replace(l,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(const r in e)if(!(r in t))return!1;return!0}(t.query,e.query)}(n,m);const v=t=>{F(t)&&(this.replace?this.addLayer?e.replaceAddLayer(o):this.removeLayer?e.replaceRemoveLayer():e.replaceLayer(this._routerLayer,o):this.addLayer?e.pushAddLayer(o):this.removeLayer?e.pushRemoveLayer():e.pushLayer(this._routerLayer,o))},w={click:F};Array.isArray(this.event)?this.event.forEach(t=>{w[t]=v}):w[this.event]=v;const b={class:a};if("a"===this.tag)b.on=w,b.attrs={href:i};else{const t=function t(e){if(e){let r;for(let n=0;n{!function t(e,r,n,o,s,i){const{path:a,name:c}=o;const h=o.pathToRegexpOptions||{};const u=function(t,e,r){r||(t=t.replace(/\/$/,""));return"/"===t[0]?t:null==e?t:b(`${e.path}/${t}`)}(a,s,h.strict);"boolean"==typeof o.caseSensitive&&(h.sensitive=o.caseSensitive);const l={path:u,regex:Q(u,h),components:o.components||{default:o.component},instances:{},name:c,parent:s,matchAs:i,redirect:o.redirect,beforeEnter:o.beforeEnter,meta:o.meta||{},props:null==o.props?{}:o.components?o.props:{default:o.props}};o.children&&o.children.forEach(o=>{const s=i?b(`${i}/${o.path}`):void 0;t(e,r,n,o,l,s)});if(void 0!==o.alias){const i=Array.isArray(o.alias)?o.alias:[o.alias];i.forEach(i=>{const a={path:i,children:o.children};t(e,r,n,a,s,l.path||"/")})}r[l.path]||(e.push(l.path),r[l.path]=l);c&&(n[c]||(n[c]=l))}(o,s,i,t)});for(let t=0,e=o.length;t!t.optional).map(t=>t.name);if("object"!=typeof c.params&&(c.params={}),s&&"object"==typeof s.params)for(const t in s.params)!(t in c.params)&&e.indexOf(t)>-1&&(c.params[t]=s.params[t]);return c.path=M(t.path,c.params),a(t,c,i)}if(c.path){c.params={};for(let t=0;t{tt(),t.state&&t.state.key&&function(t){ct=t}(t.state.key)})}function Z(t,e,r,n){if(!t.app)return;const o=t.options.scrollBehavior;o&&t.app.$nextTick(()=>{const s=function(){const t=ut();if(t)return W[t]}(),i=o.call(t,e,r,n?s:null);i&&("function"==typeof i.then?i.then(t=>{st(t,s)}).catch(t=>{}):st(i,s))})}function tt(){const t=ut();t&&(W[t]={x:window.pageXOffset,y:window.pageYOffset})}function et(t){return nt(t.x)||nt(t.y)}function rt(t){return{x:nt(t.x)?t.x:window.pageXOffset,y:nt(t.y)?t.y:window.pageYOffset}}function nt(t){return"number"==typeof t}const ot=/^#\d/;function st(t,e){const r="object"==typeof t;if(r&&"string"==typeof t.selector){const r=ot.test(t.selector)?document.getElementById(t.selector.slice(1)):document.querySelector(t.selector);if(r){let o=t.offset&&"object"==typeof t.offset?t.offset:{};e=function(t,e){const r=document.documentElement.getBoundingClientRect(),n=t.getBoundingClientRect();return{x:n.left-r.left-e.x,y:n.top-r.top-e.y}}(r,o={x:nt((n=o).x)?n.x:0,y:nt(n.y)?n.y:0})}else et(t)&&(e=rt(t))}else r&&et(t)&&(e=rt(t));var n;e&&window.scrollTo(e.x,e.y)}const it=N&&function(){const t=window.navigator.userAgent;return(-1===t.indexOf("Android 2.")&&-1===t.indexOf("Android 4.0")||-1===t.indexOf("Mobile Safari")||-1!==t.indexOf("Chrome")||-1!==t.indexOf("Windows Phone"))&&(window.history&&"pushState"in window.history)}(),at=N&&window.performance&&window.performance.now?window.performance:Date;let ct=ht();function ht(){return at.now().toFixed(3)}function ut(){return ct}function lt(t,e,r){tt();const n=window.history;try{r?n.replaceState({key:ct,state:e},"",t):(ct=ht(),n.pushState({key:ct,state:e},"",t))}catch(e){window.location[r?"replace":"assign"](t)}}function pt(t,e,r){const n=o=>{o>=t.length?r():t[o]?e(t[o],()=>{n(o+1)}):n(o+1)};n(0)}function ft(e){return(r,n,o)=>{let s=!1,i=0,a=null;dt(e,(e,r,n,c)=>{if("function"==typeof e&&void 0===e.cid){s=!0,i++;const r=gt(t=>{(function(t){return t.__esModule||mt&&"Module"===t[Symbol.toStringTag]})(t)&&(t=t.default),e.resolved="function"==typeof t?t:D.extend(t),n.components[c]=t,--i<=0&&o()}),h=gt(e=>{const r=`Failed to resolve async component ${c}: ${e}`;a||(a=t(e)?e:new Error(r),o(a))});let u;try{u=e(r,h)}catch(t){h(t)}if(u)if("function"==typeof u.then)u.then(r,h);else{const t=u.component;t&&"function"==typeof t.then&&t.then(r,h)}}}),s||o()}}function dt(t,e){return yt(t.map(t=>Object.keys(t.components).map(r=>e(t.components[r],t.instances[r],t,r))))}function yt(t){return Array.prototype.concat.apply([],t)}const mt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function gt(t){let e=!1;return function(...r){if(!e)return e=!0,t.apply(this,r)}}class vt extends Error{constructor(){super("Navigating to current location is not allowed"),this.name="NavigationDuplicated"}}class wt{constructor(t,e){this.router=t,this.base=function(t){if(!t)if(N){const e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=[d],this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]}listen(t){this.cb=t}onReady(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))}onError(t){this.errorCbs.push(t)}getClosestCurrent(t){return t>=this.current.length?this.current[this.current.length-1]:this.current[t]}transitionTo(t,e,r){const n=t.map((t,e)=>this.router.match(t,this.getClosestCurrent(e)));this.confirmTransition(n,t=>{this.updateCurrent(n,t),e&&e(n),this.ensureURL(),this.ready||(this.ready=!0,this.readyCbs.forEach(t=>{t(n)}))},t=>{r&&r(t),t&&!this.ready&&(this.ready=!0,this.readyErrorCbs.forEach(e=>{e(t)}))})}confirmTransition(r,n,o){const s=this.current,i=r=>{!e(vt,r)&&t(r)&&(this.errorCbs.length?this.errorCbs.forEach(t=>{t(r)}):console.error(r)),o&&o(r)};let a=0;for(a=0;at.beforeEnter),ft(u));this.pending=r;const p=(e,n)=>{if(this.pending!==r)return i();try{e(r,s,e=>{!1===e||t(e)?(this.ensureURL(!0),i(e)):"string"==typeof e||"object"==typeof e&&("string"==typeof e.path||"string"==typeof e.name)?(i(),"object"==typeof e&&e.replace?this.replace(e):this.push(e)):n(e)})}catch(t){i(t)}};pt(l,p,()=>{const t=[];pt(function(t,e,r){return Lt(t,"beforeRouteEnter",(t,n,o,s)=>(function(t,e,r,n,o){return function(s,i,a){return t(s,i,t=>{"function"==typeof t&&n.push(()=>{!function t(e,r,n,o){r[n]&&!r[n]._isBeingDestroyed?e(r[n]):o()&&setTimeout(()=>{t(e,r,n,o)},16)}(t,e.instances,r,o)}),a(t)})}})(t,o,s,e,r))}(u,t,()=>this.current===r).concat(this.router.resolveHooks),p,()=>{if(this.pending!==r)return i();this.pending=null,n(a),this.router.app&&this.router.app.$nextTick(()=>{t.forEach(t=>{t()})})})})}updateCurrent(t,e){const r=this.current;this.current=t,this.cb&&this.cb(t,e),this.router.afterHooks.forEach(e=>{e&&e(t,r)})}}function bt(t,e){let r;const n=Math.max(t.length,e.length);for(r=0;r{const i=function(t,e){"function"!=typeof t&&(t=D.extend(t));return t.options[e]}(t,e);if(i)return Array.isArray(i)?i.map(t=>r(t,n,o,s)):r(i,n,o,s)});return yt(n?o.reverse():o)}function xt(t,e){if(e)return function(){return t.apply(e,arguments)}}class Rt extends wt{constructor(t,e){super(t,e);const r=t.options.scrollBehavior,n=it&&r;n&&G();const o=kt(this.base);window.addEventListener("popstate",e=>{const r=this.current,s=kt(this.base);if(this.current===d&&s===o)return;let i=[s];window.history.state.state&&(i=window.history.state.state),this.transitionTo(i,e=>{n&&Z(t,e,r,!0)})})}go(t){window.history.go(t)}navigateAllLayers(t,e,r,n){const{current:o}=this;this.transitionTo(t,t=>{this.ensureURL(e);const n=this.current[this.current.length-1];Z(this.router,n,o,!1),r&&r(n)},n)}navigateLastLayer(t,e,r,n){const o=[...this.current.slice(0,-1).map(t=>t.fullPath),t];this.navigateAllLayers(o,e,r,n)}navigateLayer(t,e,r,n,o){const s=[...this.current.slice(0,t).map(t=>t.fullPath),e,...this.current.slice(t+1).map(t=>t.fullPath)];this.navigateAllLayers(s,r,n,o)}navigateAddLayer(t,e,r,n){const o=[...this.current.map(t=>t.fullPath),t];this.navigateAllLayers(o,e,r,n)}navigateRemoveLayer(t,e,r,n){const o=this.current.slice(0,-1).map(t=>t.fullPath);this.navigateAllLayers(o,e,r,n)}ensureURL(t){const e=this.current[this.current.length-1];if(kt(this.base)!==e.fullPath){lt(b(this.base+e.fullPath),this.current.map(t=>t.fullPath),!t)}}getCurrentLocation(){return kt(this.base)}}function kt(t){let e=decodeURI(window.location.pathname);return t&&0===e.indexOf(t)&&(e=e.slice(t.length)),(e||"/")+window.location.search+window.location.hash}class At extends wt{constructor(t,e,r){super(t,e),r&&function(t){const e=kt(t);if(!/^\/#/.test(e))return window.location.replace(b(t+"/#"+e)),!0}(this.base)||Et()}setupListeners(){const t=this.router.options.scrollBehavior,e=it&&t;e&&G(),window.addEventListener(it?"popstate":"hashchange",()=>{const t=this.current;Et()&&this.transitionTo(Ct(),r=>{e&&Z(this.router,r,t,!0),it||$t(r.fullPath)})})}push(t,e,r){const{current:n}=this;this.transitionTo(t,t=>{Ot(t.fullPath),Z(this.router,t,n,!1),e&&e(t)},r)}replace(t,e,r){const{current:n}=this;this.transitionTo(t,t=>{$t(t.fullPath),Z(this.router,t,n,!1),e&&e(t)},r)}go(t){window.history.go(t)}ensureURL(t){const e=this.current.fullPath;Ct()!==e&&(t?Ot(e):$t(e))}getCurrentLocation(){return Ct()}}function Et(){const t=Ct();return"/"===t.charAt(0)||($t("/"+t),!1)}function Ct(){let t=window.location.href;const e=t.indexOf("#");if(e<0)return"";const r=(t=t.slice(e+1)).indexOf("?");if(r<0){const e=t.indexOf("#");t=e>-1?decodeURI(t.slice(0,e))+t.slice(e):decodeURI(t)}else r>-1&&(t=decodeURI(t.slice(0,r))+t.slice(r));return t}function _t(t){const e=window.location.href,r=e.indexOf("#");return`${r>=0?e.slice(0,r):e}#${t}`}function Ot(t){it?lt(_t(t)):window.location.hash=t}function $t(t){it?lt(_t(t),!0):window.location.replace(_t(t))}class jt extends wt{constructor(t,e){super(t,e),this.stack=[],this.index=-1}push(t,e,r){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index+1).concat(t),this.index++,e&&e(t)},r)}replace(t,e,r){this.transitionTo(t,t=>{this.stack=this.stack.slice(0,this.index).concat(t),e&&e(t)},r)}go(t){const r=this.index+t;if(r<0||r>=this.stack.length)return;const n=this.stack[r];this.confirmTransition(n,()=>{this.index=r,this.updateRoute(n)},t=>{e(vt,t)&&(this.index=r)})}getCurrentLocation(){const t=this.stack[this.stack.length-1];return t?t.fullPath:"/"}ensureURL(){}}class Tt{constructor(t={}){this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=X(t.routes||[],this);let e=t.mode||"hash";switch(this.fallback="history"===e&&!it&&!1!==t.fallback,this.fallback&&(e="hash"),N||(e="abstract"),this.mode=e,e){case"history":this.history=new Rt(this,t.base);break;case"hash":this.history=new At(this,t.base,this.fallback);break;case"abstract":this.history=new jt(this,t.base)}}match(t,e,r){return this.matcher.match(t,e,r)}get currentRoute(){return this.history&&this.history.current}init(t){if(this.apps.push(t),t.$once("hook:destroyed",()=>{const e=this.apps.indexOf(t);e>-1&&this.apps.splice(e,1),this.app===t&&(this.app=this.apps[0]||null)}),this.app)return;this.app=t;const e=this.history;if(e instanceof Rt)e.transitionTo([e.getCurrentLocation()]);else if(e instanceof At){const t=()=>{e.setupListeners()};e.transitionTo(e.getCurrentLocation(),t,t)}e.listen((t,e)=>{this.apps.forEach(r=>{for(let n=e;nt.length;)r._routes.pop()})})}beforeEach(t){return St(this.beforeHooks,t)}beforeResolve(t){return St(this.resolveHooks,t)}afterEach(t){return St(this.afterHooks,t)}onReady(t,e){this.history.onReady(t,e)}onError(t){this.history.onError(t)}push(t,e,r){this.history.navigateLastLayer(t,!0,e,r)}replace(t,e,r){this.history.navigateLastLayer(t,!1,e,r)}pushAddLayer(t,e,r){this.history.navigateAddLayer(t,!0,e,r)}replaceAddLayer(t,e,r){this.history.navigateAddLayer(t,!1,e,r)}pushRemoveLayer(t,e){this.history.navigateRemoveLayer(!0,t,e)}replaceRemoveLayer(t,e){this.history.navigateRemoveLayer(!1,t,e)}pushLayer(t,e,r,n){this.history.navigateLayer(t,e,!0,r,n)}replaceLayer(t,e,r,n){this.history.navigateLayer(t,e,!1,r,n)}pushAllLayers(t,e,r){this.history.navigateAllLayers(t,!0,e,r)}replaceAllLayers(t,e,r){this.history.navigateAllLayers(t,!1,e,r)}go(t){this.history.go(t)}back(){this.go(-1)}forward(){this.go(1)}getMatchedComponents(t){const e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(t=>Object.keys(t.components).map(e=>t.components[e]))):[]}resolve(t,e,r){const n=B(t,e=e||this.history.current,r,this),o=this.match(n,e),s=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:function(t,e,r){var n="hash"===r?"#"+e:e;return t?b(t+"/"+n):n}(this.history.base,s,this.mode),normalizedTo:n,resolved:o}}addRoutes(t){this.matcher.addRoutes(t),this.history.current!==d&&this.history.transitionTo(this.history.getCurrentLocation())}}function St(t,e){return t.push(e),()=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)}}Tt.install=function t(e){if(t.installed&&D===e)return;t.installed=!0,D=e;const r=t=>void 0!==t,o=(t,e)=>{let n=t.$options._parentVnode;r(n)&&r(n=n.data)&&r(n=n.registerRouteInstance)&&n(t,e)};e.mixin({beforeCreate(){r(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),this._routerLayer=0,e.util.defineReactive(this,"_routes",this._router.history.current)):(this._routerRoot=this.$parent&&this.$parent._routerRoot||this,this._routerLayer=this.$parent?this.$parent._routerLayer:0),o(this,this)},destroyed(){o(this)}}),Object.defineProperty(e.prototype,"$router",{get(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$routerLayer",{get(){return new K(this._routerRoot._router,this._routerLayer)}}),Object.defineProperty(e.prototype,"$route",{get(){return this._routerRoot._routes[this._routerLayer]}}),e.component("RouterView",n),e.component("RouterLink",z);const s=e.config.optionMergeStrategies;s.beforeRouteEnter=s.beforeRouteLeave=s.beforeRouteUpdate=s.created},Tt.version="3.0.7",N&&window.Vue&&window.Vue.use(Tt);export default Tt; \ No newline at end of file diff --git a/dist/vue-router.esm.js b/dist/vue-router.esm.js index 07516d373..aa103638c 100644 --- a/dist/vue-router.esm.js +++ b/dist/vue-router.esm.js @@ -2166,28 +2166,28 @@ function resolveQueues ( next, equalLayers ) { - var ref, ref$1, ref$2, ref$3, ref$4; - - var res = { - updated: [], - activated: [], - deactivated: [] - }; + var updated = []; + var activated = []; + var deactivated = []; var min = Math.min(current.length, next.length); for (var i = equalLayers; i < min; i++) { - var r = resolveQueue(current[i].matched, next[i].matched) - (ref = res.updated).push.apply(ref, r.updated) - (ref$1 = res.activated).push.apply(ref$1, r.activated) - (ref$2 = res.deactivated).push.apply(ref$2, r.deactivated); + var r = resolveQueue(current[i].matched, next[i].matched); + updated.push.apply(updated, r.updated); + activated.push.apply(activated, r.activated); + deactivated.push.apply(deactivated, r.deactivated); } for (var i$1 = min; i$1 < current.length; i$1++) { - (ref$3 = res.deactivated).push.apply(ref$3, current[i$1].matched); + deactivated.push.apply(deactivated, current[i$1].matched); } for (var i$2 = min; i$2 < next.length; i$2++) { - (ref$4 = res.activated).push.apply(ref$4, next[i$2].matched); + activated.push.apply(activated, next[i$2].matched); + } + return { + updated: updated, + activated: activated, + deactivated: deactivated } - return res } function resolveQueue ( diff --git a/dist/vue-router.js b/dist/vue-router.js index f0b4aa1e4..a21ef9bba 100644 --- a/dist/vue-router.js +++ b/dist/vue-router.js @@ -2172,28 +2172,28 @@ function resolveQueues ( next, equalLayers ) { - var ref, ref$1, ref$2, ref$3, ref$4; - - var res = { - updated: [], - activated: [], - deactivated: [] - }; + var updated = []; + var activated = []; + var deactivated = []; var min = Math.min(current.length, next.length); for (var i = equalLayers; i < min; i++) { - var r = resolveQueue(current[i].matched, next[i].matched) - (ref = res.updated).push.apply(ref, r.updated) - (ref$1 = res.activated).push.apply(ref$1, r.activated) - (ref$2 = res.deactivated).push.apply(ref$2, r.deactivated); + var r = resolveQueue(current[i].matched, next[i].matched); + updated.push.apply(updated, r.updated); + activated.push.apply(activated, r.activated); + deactivated.push.apply(deactivated, r.deactivated); } for (var i$1 = min; i$1 < current.length; i$1++) { - (ref$3 = res.deactivated).push.apply(ref$3, current[i$1].matched); + deactivated.push.apply(deactivated, current[i$1].matched); } for (var i$2 = min; i$2 < next.length; i$2++) { - (ref$4 = res.activated).push.apply(ref$4, next[i$2].matched); + activated.push.apply(activated, next[i$2].matched); + } + return { + updated: updated, + activated: activated, + deactivated: deactivated } - return res } function resolveQueue ( diff --git a/dist/vue-router.min.js b/dist/vue-router.min.js index 0108872c0..541847d53 100644 --- a/dist/vue-router.min.js +++ b/dist/vue-router.min.js @@ -3,4 +3,4 @@ * (c) 2019 Evan You * @license MIT */ -var t,e;t=this,e=function(){"use strict";function t(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function e(t,e){return e instanceof t||e&&e.name===t.name}function r(t,e){for(var r in e)t[r]=e[r];return t}var n={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"},nextLayer:{type:Boolean,default:!1}},render:function(t,e){var n=e.props,o=e.children,a=e.parent,i=e.data;i.routerView=!0;var u=a.$createElement,c=n.name,s=a._routerViewCache||(a._routerViewCache={}),p=a._routerLayer+(n.nextLayer?1:0);if(a._routerRoot._routes.length<=p)return s[c]=null,u();for(var f=a._routerRoot._routes[p],h=0,l=!1;a&&a._routerRoot!==a;){var y=a.$vnode&&a.$vnode.data;y&&(y.routerView&&h++,y.keepAlive&&a._inactive&&(l=!0)),a=a.$parent}if(i.routerViewDepth=h,l)return u(s[c],i,o);var d=f.matched[h];if(!d)return s[c]=null,u();var v=s[c]=d.components[c];i.registerRouteInstance=function(t,e){var r=d.instances[c];(e&&r!==t||!e&&r===t)&&(d.instances[c]=e),t._routerLayer=p},(i.hook||(i.hook={})).prepatch=function(t,e){d.instances[c]=e.componentInstance},i.hook.init=function(t){t.data.keepAlive&&t.componentInstance&&t.componentInstance!==d.instances[c]&&(d.instances[c]=t.componentInstance)};var m=i.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}(f,d.props&&d.props[c]);if(m){m=i.props=r({},m);var g=i.attrs=i.attrs||{};for(var w in m)v.props&&w in v.props||(g[w]=m[w],delete m[w])}return u(v,i,o)}},o=/[!'()*]/g,a=function(t){return"%"+t.charCodeAt(0).toString(16)},i=/%2C/g,u=function(t){return encodeURIComponent(t).replace(o,a).replace(i,",")},c=decodeURIComponent;function s(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var r=t.replace(/\+/g," ").split("="),n=c(r.shift()),o=r.length>0?c(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function p(t){var e=t?Object.keys(t).map(function(e){var r=t[e];if(void 0===r)return"";if(null===r)return u(e);if(Array.isArray(r)){var n=[];return r.forEach(function(t){void 0!==t&&(null===t?n.push(u(e)):n.push(u(e)+"="+u(t)))}),n.join("&")}return u(e)+"="+u(r)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}var f=/\/?$/;function h(t,e,r,n){var o=n&&n.options.stringifyQuery,a=e.query||{};try{a=l(a)}catch(t){}var i={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:a,params:e.params||{},fullPath:v(e,o),matched:t?d(t):[]};return r&&(i.redirectedFrom=v(r,o)),Object.freeze(i)}function l(t){if(Array.isArray(t))return t.map(l);if(t&&"object"==typeof t){var e={};for(var r in t)e[r]=l(t[r]);return e}return t}var y=h(null,{path:"/"});function d(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function v(t,e){var r=t.path,n=t.query;void 0===n&&(n={});var o=t.hash;return void 0===o&&(o=""),(r||"/")+(e||p)(n)+o}function m(t,e){return e===y?t===e:!!e&&(t.path&&e.path?t.path.replace(f,"")===e.path.replace(f,"")&&t.hash===e.hash&&g(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&g(t.query,e.query)&&g(t.params,e.params)))}function g(t,e){if(void 0===t&&(t={}),void 0===e&&(e={}),!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(r){var n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?g(n,o):String(n)===String(o)})}function w(t,e,r){var n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;var o=e.split("/");r&&o[o.length-1]||o.pop();for(var a=t.replace(/^\//,"").split("/"),i=0;i=0&&(e=t.slice(n),t=t.slice(0,n));var o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}(a.path||""),p=e&&e.path||"/",f=c.path?w(c.path,p,n||a.append):p,h=function(t,e,r){void 0===e&&(e={});var n,o=r||s;try{n=o(t||"")}catch(t){n={}}for(var a in e)n[a]=e[a];return n}(c.query,a.query,o&&o.options.parseQuery),l=a.hash||c.hash;return l&&"#"!==l.charAt(0)&&(l="#"+l),{_normalized:!0,path:f,query:h,hash:l}}var V,H=[String,Object],z=[String,Array],F={name:"RouterLink",props:{to:{type:H,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,addLayer:Boolean,removeLayer:Boolean,activeClass:String,exactActiveClass:String,event:{type:z,default:"click"}},render:function(t){var e=this,n=this.$router,o=this.$route,a=n.resolve(this.to,o,this.append),i=a.location,u=a.route,c=a.href,s={},p=n.options.linkActiveClass,l=n.options.linkExactActiveClass,y=null==p?"router-link-active":p,d=null==l?"router-link-exact-active":l,v=null==this.activeClass?y:this.activeClass,g=null==this.exactActiveClass?d:this.exactActiveClass,w=u.redirectedFrom?h(null,B(u.redirectedFrom),null,n):u;s[g]=m(o,w),s[v]=this.exact?s[g]:function(t,e){return 0===t.path.replace(f,"/").indexOf(e.path.replace(f,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(var r in e)if(!(r in t))return!1;return!0}(t.query,e.query)}(o,w);var b=function(t){D(t)&&(e.replace?e.addLayer?n.replaceAddLayer(i):e.removeLayer?n.replaceRemoveLayer():n.replaceLayer(e._routerLayer,i):e.addLayer?n.pushAddLayer(i):e.removeLayer?n.pushRemoveLayer():n.pushLayer(e._routerLayer,i))},L={click:D};Array.isArray(this.event)?this.event.forEach(function(t){L[t]=b}):L[this.event]=b;var x={class:s};if("a"===this.tag)x.on=L,x.attrs={href:c};else{var R=function t(e){if(e)for(var r,n=0;n-1&&(u.params[h]=r.params[h]);return u.path=M(p.path,u.params),c(p,u,i)}if(u.path){u.params={};for(var l=0;l=t.length?r():t[o]?e(t[o],function(){n(o+1)}):n(o+1)};n(0)}function yt(e){return function(r,n,o){var a=!1,i=0,u=null;dt(e,function(e,r,n,c){if("function"==typeof e&&void 0===e.cid){a=!0,i++;var s,p=gt(function(t){var r;((r=t).__esModule||mt&&"Module"===r[Symbol.toStringTag])&&(t=t.default),e.resolved="function"==typeof t?t:V.extend(t),n.components[c]=t,--i<=0&&o()}),f=gt(function(e){var r="Failed to resolve async component "+c+": "+e;u||(u=t(e)?e:new Error(r),o(u))});try{s=e(p,f)}catch(t){f(t)}if(s)if("function"==typeof s.then)s.then(p,f);else{var h=s.component;h&&"function"==typeof h.then&&h.then(p,f)}}}),a||o()}}function dt(t,e){return vt(t.map(function(t){return Object.keys(t.components).map(function(r){return e(t.components[r],t.instances[r],t,r)})}))}function vt(t){return Array.prototype.concat.apply([],t)}var mt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function gt(t){var e=!1;return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];if(!e)return e=!0,t.apply(this,r)}}var wt=function(t){function e(){t.call(this,"Navigating to current location is not allowed"),this.name="NavigationDuplicated"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),bt=function(t,e){this.router=t,this.base=function(t){if(!t)if(N){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=[y],this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function Lt(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=this.current.length?this.current[this.current.length-1]:this.current[t]},bt.prototype.transitionTo=function(t,e,r){var n=this,o=t.map(function(t,e){return n.router.match(t,n.getClosestCurrent(e))});this.confirmTransition(o,function(t){n.updateCurrent(o,t),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(t){r&&r(t),t&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(e){e(t)}))})},bt.prototype.confirmTransition=function(r,n,o){var a=this,i=this.current,u=function(r){!e(wt,r)&&t(r)&&(a.errorCbs.length?a.errorCbs.forEach(function(t){t(r)}):console.error(r)),o&&o(r)},c=0;for(c=0;c-1?decodeURI(t.slice(0,n))+t.slice(n):decodeURI(t)}else r>-1&&(t=decodeURI(t.slice(0,r))+t.slice(r));return t}function Ct(t){var e=window.location.href,r=e.indexOf("#");return(r>=0?e.slice(0,r):e)+"#"+t}function jt(t){ut?ht(Ct(t)):window.location.hash=t}function $t(t){ut?ht(Ct(t),!0):window.location.replace(Ct(t))}var Tt=function(t){function r(e,r){t.call(this,e,r),this.stack=[],this.index=-1}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.push=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++,e&&e(t)},r)},r.prototype.replace=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index).concat(t),e&&e(t)},r)},r.prototype.go=function(t){var r=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var o=this.stack[n];this.confirmTransition(o,function(){r.index=n,r.updateRoute(o)},function(t){e(wt,t)&&(r.index=n)})}},r.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},r.prototype.ensureURL=function(){},r}(bt),St=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=X(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!ut&&!1!==t.fallback,this.fallback&&(e="hash"),N||(e="abstract"),this.mode=e,e){case"history":this.history=new _t(this,t.base);break;case"hash":this.history=new At(this,t.base,this.fallback);break;case"abstract":this.history=new Tt(this,t.base)}},Pt={currentRoute:{configurable:!0}};function qt(t,e){return t.push(e),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}return St.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},Pt.currentRoute.get=function(){return this.history&&this.history.current},St.prototype.init=function(t){var e=this;if(this.apps.push(t),t.$once("hook:destroyed",function(){var r=e.apps.indexOf(t);r>-1&&e.apps.splice(r,1),e.app===t&&(e.app=e.apps[0]||null)}),!this.app){this.app=t;var r=this.history;if(r instanceof _t)r.transitionTo([r.getCurrentLocation()]);else if(r instanceof At){var n=function(){r.setupListeners()};r.transitionTo(r.getCurrentLocation(),n,n)}r.listen(function(t,r){e.apps.forEach(function(e){for(var n=r;nt.length;)e._routes.pop()})})}},St.prototype.beforeEach=function(t){return qt(this.beforeHooks,t)},St.prototype.beforeResolve=function(t){return qt(this.resolveHooks,t)},St.prototype.afterEach=function(t){return qt(this.afterHooks,t)},St.prototype.onReady=function(t,e){this.history.onReady(t,e)},St.prototype.onError=function(t){this.history.onError(t)},St.prototype.push=function(t,e,r){this.history.navigateLastLayer(t,!0,e,r)},St.prototype.replace=function(t,e,r){this.history.navigateLastLayer(t,!1,e,r)},St.prototype.pushAddLayer=function(t,e,r){this.history.navigateAddLayer(t,!0,e,r)},St.prototype.replaceAddLayer=function(t,e,r){this.history.navigateAddLayer(t,!1,e,r)},St.prototype.pushRemoveLayer=function(t,e){this.history.navigateRemoveLayer(!0,t,e)},St.prototype.replaceRemoveLayer=function(t,e){this.history.navigateRemoveLayer(!1,t,e)},St.prototype.pushLayer=function(t,e,r,n){this.history.navigateLayer(t,e,!0,r,n)},St.prototype.replaceLayer=function(t,e,r,n){this.history.navigateLayer(t,e,!1,r,n)},St.prototype.pushAllLayers=function(t,e,r){this.history.navigateAllLayers(t,!0,e,r)},St.prototype.replaceAllLayers=function(t,e,r){this.history.navigateAllLayers(t,!1,e,r)},St.prototype.go=function(t){this.history.go(t)},St.prototype.back=function(){this.go(-1)},St.prototype.forward=function(){this.go(1)},St.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(function(t){return Object.keys(t.components).map(function(e){return t.components[e]})})):[]},St.prototype.resolve=function(t,e,r){var n=B(t,e=e||this.history.current,r,this),o=this.match(n,e),a=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:function(t,e,r){var n="hash"===r?"#"+e:e;return t?b(t+"/"+n):n}(this.history.base,a,this.mode),normalizedTo:n,resolved:o}},St.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==y&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(St.prototype,Pt),St.install=function t(e){if(!t.installed||V!==e){t.installed=!0,V=e;var r=function(t){return void 0!==t},o=function(t,e){var n=t.$options._parentVnode;r(n)&&r(n=n.data)&&r(n=n.registerRouteInstance)&&n(t,e)};e.mixin({beforeCreate:function(){r(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),this._routerLayer=0,e.util.defineReactive(this,"_routes",this._router.history.current)):(this._routerRoot=this.$parent&&this.$parent._routerRoot||this,this._routerLayer=this.$parent?this.$parent._routerLayer:0),o(this,this)},destroyed:function(){o(this)}}),Object.defineProperty(e.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$routerLayer",{get:function(){return new K(this._routerRoot._router,this._routerLayer)}}),Object.defineProperty(e.prototype,"$route",{get:function(){return this._routerRoot._routes[this._routerLayer]}}),e.component("RouterView",n),e.component("RouterLink",F);var a=e.config.optionMergeStrategies;a.beforeRouteEnter=a.beforeRouteLeave=a.beforeRouteUpdate=a.created}},St.version="3.0.7",N&&window.Vue&&window.Vue.use(St),St},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e(); \ No newline at end of file +var t,e;t=this,e=function(){"use strict";function t(t){return Object.prototype.toString.call(t).indexOf("Error")>-1}function e(t,e){return e instanceof t||e&&e.name===t.name}function r(t,e){for(var r in e)t[r]=e[r];return t}var n={name:"RouterView",functional:!0,props:{name:{type:String,default:"default"},nextLayer:{type:Boolean,default:!1}},render:function(t,e){var n=e.props,o=e.children,i=e.parent,a=e.data;a.routerView=!0;var u=i.$createElement,s=n.name,c=i._routerViewCache||(i._routerViewCache={}),p=i._routerLayer+(n.nextLayer?1:0);if(i._routerRoot._routes.length<=p)return c[s]=null,u();for(var f=i._routerRoot._routes[p],h=0,l=!1;i&&i._routerRoot!==i;){var y=i.$vnode&&i.$vnode.data;y&&(y.routerView&&h++,y.keepAlive&&i._inactive&&(l=!0)),i=i.$parent}if(a.routerViewDepth=h,l)return u(c[s],a,o);var d=f.matched[h];if(!d)return c[s]=null,u();var v=c[s]=d.components[s];a.registerRouteInstance=function(t,e){var r=d.instances[s];(e&&r!==t||!e&&r===t)&&(d.instances[s]=e),t._routerLayer=p},(a.hook||(a.hook={})).prepatch=function(t,e){d.instances[s]=e.componentInstance},a.hook.init=function(t){t.data.keepAlive&&t.componentInstance&&t.componentInstance!==d.instances[s]&&(d.instances[s]=t.componentInstance)};var m=a.props=function(t,e){switch(typeof e){case"undefined":return;case"object":return e;case"function":return e(t);case"boolean":return e?t.params:void 0}}(f,d.props&&d.props[s]);if(m){m=a.props=r({},m);var g=a.attrs=a.attrs||{};for(var w in m)v.props&&w in v.props||(g[w]=m[w],delete m[w])}return u(v,a,o)}},o=/[!'()*]/g,i=function(t){return"%"+t.charCodeAt(0).toString(16)},a=/%2C/g,u=function(t){return encodeURIComponent(t).replace(o,i).replace(a,",")},s=decodeURIComponent;function c(t){var e={};return(t=t.trim().replace(/^(\?|#|&)/,""))?(t.split("&").forEach(function(t){var r=t.replace(/\+/g," ").split("="),n=s(r.shift()),o=r.length>0?s(r.join("=")):null;void 0===e[n]?e[n]=o:Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]}),e):e}function p(t){var e=t?Object.keys(t).map(function(e){var r=t[e];if(void 0===r)return"";if(null===r)return u(e);if(Array.isArray(r)){var n=[];return r.forEach(function(t){void 0!==t&&(null===t?n.push(u(e)):n.push(u(e)+"="+u(t)))}),n.join("&")}return u(e)+"="+u(r)}).filter(function(t){return t.length>0}).join("&"):null;return e?"?"+e:""}var f=/\/?$/;function h(t,e,r,n){var o=n&&n.options.stringifyQuery,i=e.query||{};try{i=l(i)}catch(t){}var a={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:i,params:e.params||{},fullPath:v(e,o),matched:t?d(t):[]};return r&&(a.redirectedFrom=v(r,o)),Object.freeze(a)}function l(t){if(Array.isArray(t))return t.map(l);if(t&&"object"==typeof t){var e={};for(var r in t)e[r]=l(t[r]);return e}return t}var y=h(null,{path:"/"});function d(t){for(var e=[];t;)e.unshift(t),t=t.parent;return e}function v(t,e){var r=t.path,n=t.query;void 0===n&&(n={});var o=t.hash;return void 0===o&&(o=""),(r||"/")+(e||p)(n)+o}function m(t,e){return e===y?t===e:!!e&&(t.path&&e.path?t.path.replace(f,"")===e.path.replace(f,"")&&t.hash===e.hash&&g(t.query,e.query):!(!t.name||!e.name)&&(t.name===e.name&&t.hash===e.hash&&g(t.query,e.query)&&g(t.params,e.params)))}function g(t,e){if(void 0===t&&(t={}),void 0===e&&(e={}),!t||!e)return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(r){var n=t[r],o=e[r];return"object"==typeof n&&"object"==typeof o?g(n,o):String(n)===String(o)})}function w(t,e,r){var n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;var o=e.split("/");r&&o[o.length-1]||o.pop();for(var i=t.replace(/^\//,"").split("/"),a=0;a=0&&(e=t.slice(n),t=t.slice(0,n));var o=t.indexOf("?");return o>=0&&(r=t.slice(o+1),t=t.slice(0,o)),{path:t,query:r,hash:e}}(i.path||""),p=e&&e.path||"/",f=s.path?w(s.path,p,n||i.append):p,h=function(t,e,r){void 0===e&&(e={});var n,o=r||c;try{n=o(t||"")}catch(t){n={}}for(var i in e)n[i]=e[i];return n}(s.query,i.query,o&&o.options.parseQuery),l=i.hash||s.hash;return l&&"#"!==l.charAt(0)&&(l="#"+l),{_normalized:!0,path:f,query:h,hash:l}}var V,H=[String,Object],z=[String,Array],F={name:"RouterLink",props:{to:{type:H,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,addLayer:Boolean,removeLayer:Boolean,activeClass:String,exactActiveClass:String,event:{type:z,default:"click"}},render:function(t){var e=this,n=this.$router,o=this.$route,i=n.resolve(this.to,o,this.append),a=i.location,u=i.route,s=i.href,c={},p=n.options.linkActiveClass,l=n.options.linkExactActiveClass,y=null==p?"router-link-active":p,d=null==l?"router-link-exact-active":l,v=null==this.activeClass?y:this.activeClass,g=null==this.exactActiveClass?d:this.exactActiveClass,w=u.redirectedFrom?h(null,B(u.redirectedFrom),null,n):u;c[g]=m(o,w),c[v]=this.exact?c[g]:function(t,e){return 0===t.path.replace(f,"/").indexOf(e.path.replace(f,"/"))&&(!e.hash||t.hash===e.hash)&&function(t,e){for(var r in e)if(!(r in t))return!1;return!0}(t.query,e.query)}(o,w);var b=function(t){D(t)&&(e.replace?e.addLayer?n.replaceAddLayer(a):e.removeLayer?n.replaceRemoveLayer():n.replaceLayer(e._routerLayer,a):e.addLayer?n.pushAddLayer(a):e.removeLayer?n.pushRemoveLayer():n.pushLayer(e._routerLayer,a))},L={click:D};Array.isArray(this.event)?this.event.forEach(function(t){L[t]=b}):L[this.event]=b;var x={class:c};if("a"===this.tag)x.on=L,x.attrs={href:s};else{var R=function t(e){if(e)for(var r,n=0;n-1&&(u.params[h]=r.params[h]);return u.path=M(p.path,u.params),s(p,u,a)}if(u.path){u.params={};for(var l=0;l=t.length?r():t[o]?e(t[o],function(){n(o+1)}):n(o+1)};n(0)}function yt(e){return function(r,n,o){var i=!1,a=0,u=null;dt(e,function(e,r,n,s){if("function"==typeof e&&void 0===e.cid){i=!0,a++;var c,p=gt(function(t){var r;((r=t).__esModule||mt&&"Module"===r[Symbol.toStringTag])&&(t=t.default),e.resolved="function"==typeof t?t:V.extend(t),n.components[s]=t,--a<=0&&o()}),f=gt(function(e){var r="Failed to resolve async component "+s+": "+e;u||(u=t(e)?e:new Error(r),o(u))});try{c=e(p,f)}catch(t){f(t)}if(c)if("function"==typeof c.then)c.then(p,f);else{var h=c.component;h&&"function"==typeof h.then&&h.then(p,f)}}}),i||o()}}function dt(t,e){return vt(t.map(function(t){return Object.keys(t.components).map(function(r){return e(t.components[r],t.instances[r],t,r)})}))}function vt(t){return Array.prototype.concat.apply([],t)}var mt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function gt(t){var e=!1;return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];if(!e)return e=!0,t.apply(this,r)}}var wt=function(t){function e(){t.call(this,"Navigating to current location is not allowed"),this.name="NavigationDuplicated"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(Error),bt=function(t,e){this.router=t,this.base=function(t){if(!t)if(N){var e=document.querySelector("base");t=(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else t="/";"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=[y],this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function Lt(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r=this.current.length?this.current[this.current.length-1]:this.current[t]},bt.prototype.transitionTo=function(t,e,r){var n=this,o=t.map(function(t,e){return n.router.match(t,n.getClosestCurrent(e))});this.confirmTransition(o,function(t){n.updateCurrent(o,t),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(t){r&&r(t),t&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(e){e(t)}))})},bt.prototype.confirmTransition=function(r,n,o){var i=this,a=this.current,u=function(r){!e(wt,r)&&t(r)&&(i.errorCbs.length?i.errorCbs.forEach(function(t){t(r)}):console.error(r)),o&&o(r)},s=0;for(s=0;s-1?decodeURI(t.slice(0,n))+t.slice(n):decodeURI(t)}else r>-1&&(t=decodeURI(t.slice(0,r))+t.slice(r));return t}function Ct(t){var e=window.location.href,r=e.indexOf("#");return(r>=0?e.slice(0,r):e)+"#"+t}function jt(t){ut?ht(Ct(t)):window.location.hash=t}function $t(t){ut?ht(Ct(t),!0):window.location.replace(Ct(t))}var Tt=function(t){function r(e,r){t.call(this,e,r),this.stack=[],this.index=-1}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.push=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index+1).concat(t),n.index++,e&&e(t)},r)},r.prototype.replace=function(t,e,r){var n=this;this.transitionTo(t,function(t){n.stack=n.stack.slice(0,n.index).concat(t),e&&e(t)},r)},r.prototype.go=function(t){var r=this,n=this.index+t;if(!(n<0||n>=this.stack.length)){var o=this.stack[n];this.confirmTransition(o,function(){r.index=n,r.updateRoute(o)},function(t){e(wt,t)&&(r.index=n)})}},r.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},r.prototype.ensureURL=function(){},r}(bt),St=function(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=X(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!ut&&!1!==t.fallback,this.fallback&&(e="hash"),N||(e="abstract"),this.mode=e,e){case"history":this.history=new _t(this,t.base);break;case"hash":this.history=new At(this,t.base,this.fallback);break;case"abstract":this.history=new Tt(this,t.base)}},Pt={currentRoute:{configurable:!0}};function qt(t,e){return t.push(e),function(){var r=t.indexOf(e);r>-1&&t.splice(r,1)}}return St.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},Pt.currentRoute.get=function(){return this.history&&this.history.current},St.prototype.init=function(t){var e=this;if(this.apps.push(t),t.$once("hook:destroyed",function(){var r=e.apps.indexOf(t);r>-1&&e.apps.splice(r,1),e.app===t&&(e.app=e.apps[0]||null)}),!this.app){this.app=t;var r=this.history;if(r instanceof _t)r.transitionTo([r.getCurrentLocation()]);else if(r instanceof At){var n=function(){r.setupListeners()};r.transitionTo(r.getCurrentLocation(),n,n)}r.listen(function(t,r){e.apps.forEach(function(e){for(var n=r;nt.length;)e._routes.pop()})})}},St.prototype.beforeEach=function(t){return qt(this.beforeHooks,t)},St.prototype.beforeResolve=function(t){return qt(this.resolveHooks,t)},St.prototype.afterEach=function(t){return qt(this.afterHooks,t)},St.prototype.onReady=function(t,e){this.history.onReady(t,e)},St.prototype.onError=function(t){this.history.onError(t)},St.prototype.push=function(t,e,r){this.history.navigateLastLayer(t,!0,e,r)},St.prototype.replace=function(t,e,r){this.history.navigateLastLayer(t,!1,e,r)},St.prototype.pushAddLayer=function(t,e,r){this.history.navigateAddLayer(t,!0,e,r)},St.prototype.replaceAddLayer=function(t,e,r){this.history.navigateAddLayer(t,!1,e,r)},St.prototype.pushRemoveLayer=function(t,e){this.history.navigateRemoveLayer(!0,t,e)},St.prototype.replaceRemoveLayer=function(t,e){this.history.navigateRemoveLayer(!1,t,e)},St.prototype.pushLayer=function(t,e,r,n){this.history.navigateLayer(t,e,!0,r,n)},St.prototype.replaceLayer=function(t,e,r,n){this.history.navigateLayer(t,e,!1,r,n)},St.prototype.pushAllLayers=function(t,e,r){this.history.navigateAllLayers(t,!0,e,r)},St.prototype.replaceAllLayers=function(t,e,r){this.history.navigateAllLayers(t,!1,e,r)},St.prototype.go=function(t){this.history.go(t)},St.prototype.back=function(){this.go(-1)},St.prototype.forward=function(){this.go(1)},St.prototype.getMatchedComponents=function(t){var e=t?t.matched?t:this.resolve(t).route:this.currentRoute;return e?[].concat.apply([],e.matched.map(function(t){return Object.keys(t.components).map(function(e){return t.components[e]})})):[]},St.prototype.resolve=function(t,e,r){var n=B(t,e=e||this.history.current,r,this),o=this.match(n,e),i=o.redirectedFrom||o.fullPath;return{location:n,route:o,href:function(t,e,r){var n="hash"===r?"#"+e:e;return t?b(t+"/"+n):n}(this.history.base,i,this.mode),normalizedTo:n,resolved:o}},St.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==y&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(St.prototype,Pt),St.install=function t(e){if(!t.installed||V!==e){t.installed=!0,V=e;var r=function(t){return void 0!==t},o=function(t,e){var n=t.$options._parentVnode;r(n)&&r(n=n.data)&&r(n=n.registerRouteInstance)&&n(t,e)};e.mixin({beforeCreate:function(){r(this.$options.router)?(this._routerRoot=this,this._router=this.$options.router,this._router.init(this),this._routerLayer=0,e.util.defineReactive(this,"_routes",this._router.history.current)):(this._routerRoot=this.$parent&&this.$parent._routerRoot||this,this._routerLayer=this.$parent?this.$parent._routerLayer:0),o(this,this)},destroyed:function(){o(this)}}),Object.defineProperty(e.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(e.prototype,"$routerLayer",{get:function(){return new K(this._routerRoot._router,this._routerLayer)}}),Object.defineProperty(e.prototype,"$route",{get:function(){return this._routerRoot._routes[this._routerLayer]}}),e.component("RouterView",n),e.component("RouterLink",F);var i=e.config.optionMergeStrategies;i.beforeRouteEnter=i.beforeRouteLeave=i.beforeRouteUpdate=i.created}},St.version="3.0.7",N&&window.Vue&&window.Vue.use(St),St},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueRouter=e(); \ No newline at end of file diff --git a/src/history/base.js b/src/history/base.js index 72ca5078a..e8f9002ee 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -258,26 +258,28 @@ function resolveQueues ( activated: Array, deactivated: Array } { - const res = { - updated: [], - activated: [], - deactivated: [] - } + const updated = [] + const activated = [] + const deactivated = [] const min = Math.min(current.length, next.length) for (let i = equalLayers; i < min; i++) { const r = resolveQueue(current[i].matched, next[i].matched) - res.updated.push(...r.updated) - res.activated.push(...r.activated) - res.deactivated.push(...r.deactivated) + updated.push(...r.updated) + activated.push(...r.activated) + deactivated.push(...r.deactivated) } for (let i = min; i < current.length; i++) { - res.deactivated.push(...current[i].matched) + deactivated.push(...current[i].matched) } for (let i = min; i < next.length; i++) { - res.activated.push(...next[i].matched) + activated.push(...next[i].matched) + } + return { + updated, + activated, + deactivated } - return res } function resolveQueue (