kdu-router 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * kdu-router v3.0.0
2
+ * kdu-router v3.0.1
3
3
  * (c) 2022 NKDuy
4
4
  * @license MIT
5
5
  */
@@ -96,13 +96,17 @@ var View = {
96
96
  };
97
97
 
98
98
  // resolve props
99
- data.props = resolveProps(route, matched.props && matched.props[name]);
100
- data.attrs = {};
101
-
102
- for (var key in data.props) {
103
- if (!('props' in component) || !(key in component.props)) {
104
- data.attrs[key] = data.props[key];
105
- delete data.props[key];
99
+ var propsToPass = data.props = resolveProps(route, matched.props && matched.props[name]);
100
+ if (propsToPass) {
101
+ // clone to prevent mutation
102
+ propsToPass = data.props = extend({}, propsToPass);
103
+ // pass non-declared props as attrs
104
+ var attrs = data.attrs = data.attrs || {};
105
+ for (var key in propsToPass) {
106
+ if (!component.props || !(key in component.props)) {
107
+ attrs[key] = propsToPass[key];
108
+ delete propsToPass[key];
109
+ }
106
110
  }
107
111
  }
108
112
 
@@ -131,6 +135,13 @@ function resolveProps (route, config) {
131
135
  }
132
136
  }
133
137
 
138
+ function extend (to, from) {
139
+ for (var key in from) {
140
+ to[key] = from[key];
141
+ }
142
+ return to
143
+ }
144
+
134
145
  /* */
135
146
 
136
147
  var encodeReserveRE = /[!'()*]/g;
@@ -2605,7 +2616,7 @@ function createHref (base, fullPath, mode) {
2605
2616
  }
2606
2617
 
2607
2618
  KduRouter.install = install;
2608
- KduRouter.version = '3.0.0';
2619
+ KduRouter.version = '3.0.1';
2609
2620
 
2610
2621
  if (inBrowser && window.Kdu) {
2611
2622
  window.Kdu.use(KduRouter);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * kdu-router v3.0.0
2
+ * kdu-router v3.0.1
3
3
  * (c) 2022 NKDuy
4
4
  * @license MIT
5
5
  */
@@ -94,13 +94,17 @@ var View = {
94
94
  };
95
95
 
96
96
  // resolve props
97
- data.props = resolveProps(route, matched.props && matched.props[name]);
98
- data.attrs = {};
99
-
100
- for (var key in data.props) {
101
- if (!('props' in component) || !(key in component.props)) {
102
- data.attrs[key] = data.props[key];
103
- delete data.props[key];
97
+ var propsToPass = data.props = resolveProps(route, matched.props && matched.props[name]);
98
+ if (propsToPass) {
99
+ // clone to prevent mutation
100
+ propsToPass = data.props = extend({}, propsToPass);
101
+ // pass non-declared props as attrs
102
+ var attrs = data.attrs = data.attrs || {};
103
+ for (var key in propsToPass) {
104
+ if (!component.props || !(key in component.props)) {
105
+ attrs[key] = propsToPass[key];
106
+ delete propsToPass[key];
107
+ }
104
108
  }
105
109
  }
106
110
 
@@ -129,6 +133,13 @@ function resolveProps (route, config) {
129
133
  }
130
134
  }
131
135
 
136
+ function extend (to, from) {
137
+ for (var key in from) {
138
+ to[key] = from[key];
139
+ }
140
+ return to
141
+ }
142
+
132
143
  /* */
133
144
 
134
145
  var encodeReserveRE = /[!'()*]/g;
@@ -2603,7 +2614,7 @@ function createHref (base, fullPath, mode) {
2603
2614
  }
2604
2615
 
2605
2616
  KduRouter.install = install;
2606
- KduRouter.version = '3.0.0';
2617
+ KduRouter.version = '3.0.1';
2607
2618
 
2608
2619
  if (inBrowser && window.Kdu) {
2609
2620
  window.Kdu.use(KduRouter);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * kdu-router v3.0.0
2
+ * kdu-router v3.0.1
3
3
  * (c) 2022 NKDuy
4
4
  * @license MIT
5
5
  */
@@ -100,13 +100,17 @@ var View = {
100
100
  };
101
101
 
102
102
  // resolve props
103
- data.props = resolveProps(route, matched.props && matched.props[name]);
104
- data.attrs = {};
105
-
106
- for (var key in data.props) {
107
- if (!('props' in component) || !(key in component.props)) {
108
- data.attrs[key] = data.props[key];
109
- delete data.props[key];
103
+ var propsToPass = data.props = resolveProps(route, matched.props && matched.props[name]);
104
+ if (propsToPass) {
105
+ // clone to prevent mutation
106
+ propsToPass = data.props = extend({}, propsToPass);
107
+ // pass non-declared props as attrs
108
+ var attrs = data.attrs = data.attrs || {};
109
+ for (var key in propsToPass) {
110
+ if (!component.props || !(key in component.props)) {
111
+ attrs[key] = propsToPass[key];
112
+ delete propsToPass[key];
113
+ }
110
114
  }
111
115
  }
112
116
 
@@ -135,6 +139,13 @@ function resolveProps (route, config) {
135
139
  }
136
140
  }
137
141
 
142
+ function extend (to, from) {
143
+ for (var key in from) {
144
+ to[key] = from[key];
145
+ }
146
+ return to
147
+ }
148
+
138
149
  /* */
139
150
 
140
151
  var encodeReserveRE = /[!'()*]/g;
@@ -2609,7 +2620,7 @@ function createHref (base, fullPath, mode) {
2609
2620
  }
2610
2621
 
2611
2622
  KduRouter.install = install;
2612
- KduRouter.version = '3.0.0';
2623
+ KduRouter.version = '3.0.1';
2613
2624
 
2614
2625
  if (inBrowser && window.Kdu) {
2615
2626
  window.Kdu.use(KduRouter);
@@ -1,6 +1,6 @@
1
1
  /**
2
- * kdu-router v3.0.0
2
+ * kdu-router v3.0.1
3
3
  * (c) 2022 NKDuy
4
4
  * @license MIT
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.KduRouter=e()}(this,function(){"use strict";function f(t){return-1<Object.prototype.toString.call(t).indexOf("Error")}var U={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){for(var r=e.props,n=e.children,o=e.parent,i=e.data,e=(i.routerView=!0,o.$createElement),a=r.name,r=o.$route,u=o._routerViewCache||(o._routerViewCache={}),c=0,s=!1;o&&o._routerRoot!==o;)o.$knode&&o.$knode.data.routerView&&c++,o._inactive&&(s=!0),o=o.$parent;if(i.routerViewDepth=c,s)return e(u[a],i,n);var p=r.matched[c];if(!p)return u[a]=null,e();var h,f=u[a]=p.components[a];for(h in i.registerRouteInstance=function(t,e){var r=p.instances[a];(e&&r!==t||!e&&r===t)&&(p.instances[a]=e)},(i.hook||(i.hook={})).prepatch=function(t,e){p.instances[a]=e.componentInstance},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}}(r,p.props&&p.props[a]),i.attrs={},i.props)"props"in f&&h in f.props||(i.attrs[h]=i.props[h],delete i.props[h]);return e(f,i,n)}};function o(t){return encodeURIComponent(t).replace(M,H).replace(I,",")}var M=/[!'()*]/g,H=function(t){return"%"+t.charCodeAt(0).toString(16)},I=/%2C/g,z=decodeURIComponent;function B(t){var r={};return(t=t.trim().replace(/^(\?|#|&)/,""))&&t.split("&").forEach(function(t){var t=t.replace(/\+/g," ").split("="),e=z(t.shift()),t=0<t.length?z(t.join("=")):null;void 0===r[e]?r[e]=t:Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]}),r}function K(n){var t=n?Object.keys(n).map(function(e){var r,t=n[e];return void 0===t?"":null===t?o(e):Array.isArray(t)?(r=[],t.forEach(function(t){void 0!==t&&r.push(null===t?o(e):o(e)+"="+o(t))}),r.join("&")):o(e)+"="+o(t)}).filter(function(t){return 0<t.length}).join("&"):null;return t?"?"+t:""}var r=/\/?$/;function d(t,e,r,n){var n=n&&n.options.stringifyQuery,o=e.query||{};try{o=i(o)}catch(t){}o={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:o,params:e.params||{},fullPath:F(e,n),matched:t?function(t){var e=[];for(;t;)e.unshift(t),t=t.parent;return e}(t):[]};return r&&(o.redirectedFrom=F(r,n)),Object.freeze(o)}function i(t){if(Array.isArray(t))return t.map(i);if(t&&"object"==typeof t){var e,r={};for(e in t)r[e]=i(t[e]);return r}return t}var u=d(null,{path:"/"});function F(t,e){var r=t.path,n=t.query,t=t.hash;return void 0===t&&(t=""),(r||"/")+(e||K)(n=void 0===n?{}:n)+t}function V(t,e){return e===u?t===e:!!e&&(t.path&&e.path?t.path.replace(r,"")===e.path.replace(r,"")&&t.hash===e.hash&&a(t.query,e.query):!(!t.name||!e.name)&&t.name===e.name&&t.hash===e.hash&&a(t.query,e.query)&&a(t.params,e.params))}function a(r,n){var t,e;return void 0===n&&(n={}),(r=void 0===r?{}:r)&&n?(t=Object.keys(r),e=Object.keys(n),t.length===e.length&&t.every(function(t){var e=r[t],t=n[t];return"object"==typeof e&&"object"==typeof t?a(e,t):String(e)===String(t)})):r===n}function D(t,e){return 0===t.path.replace(r,"/").indexOf(e.path.replace(r,"/"))&&(!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)}var l,t=[String,Object],e=[String,Array],J={name:"router-link",props:{to:{type:t,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:e,default:"click"}},render:function(t){function e(t){N(t)&&(r.replace?n.replace(a):n.push(a))}var r=this,n=this.$router,o=this.$route,i=n.resolve(this.to,o,this.append),a=i.location,u=i.route,i=i.href,c={},s=n.options.linkActiveClass,p=n.options.linkExactActiveClass,s=null==this.activeClass?null==s?"router-link-active":s:this.activeClass,p=null==this.exactActiveClass?null==p?"router-link-exact-active":p:this.exactActiveClass,u=a.path?d(null,a,null,n):u,h=(c[p]=V(o,u),c[s]=this.exact?c[p]:D(o,u),{click:N}),s=(Array.isArray(this.event)?this.event.forEach(function(t){h[t]=e}):h[this.event]=e,{class:c});return"a"===this.tag?(s.on=h,s.attrs={href:i}):(p=function t(e){if(e)for(var r,n=0;n<e.length;n++){if("a"===(r=e[n]).tag)return r;if(r.children&&(r=t(r.children)))return r}}(this.$slots.default))?(p.isStatic=!1,o=l.util.extend,(p.data=o({},p.data)).on=h,(p.data.attrs=o({},p.data.attrs)).href=i):s.on=h,t(this.tag,s,this.$slots.default)}};function N(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.currentTarget&&t.currentTarget.getAttribute){var e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function c(t){var n,e,r;c.installed&&l===t||(c.installed=!0,n=function(t){return void 0!==t},e=function(t,e){var r=t.$options._parentKnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(t,e)},(l=t).mixin({beforeCreate:function(){n(this.$options.router)?((this._routerRoot=this)._router=this.$options.router,this._router.init(this),t.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,e(this,this)},destroyed:function(){e(this)}}),Object.defineProperty(t.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(t.prototype,"$route",{get:function(){return this._routerRoot._route}}),t.component("router-view",U),t.component("router-link",J),(r=t.config.optionMergeStrategies).beforeRouteEnter=r.beforeRouteLeave=r.beforeRouteUpdate=r.created)}var n="undefined"!=typeof window;function Q(t,e,r){var n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;for(var o=e.split("/"),i=(r&&o[o.length-1]||o.pop(),t.replace(/^\//,"").split("/")),a=0;a<i.length;a++){var u=i[a];".."===u?o.pop():"."!==u&&o.push(u)}return""!==o[0]&&o.unshift(""),o.join("/")}function h(t){return t.replace(/\/\//g,"/")}function X(t,e){return Z(v(t,e),e)}var y=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},s=et,t=v,e=Z,Y=tt,W=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function v(t,e){for(var r=[],n=0,o=0,i="",a=e&&e.delimiter||"/";null!=(h=W.exec(t));){var u,c,s,p,h,f=h[0],l=h[1],d=h.index;i+=t.slice(o,d),o=d+f.length,l?i+=l[1]:(d=t[o],f=h[2],l=h[3],u=h[4],c=h[5],s=h[6],p=h[7],d=(i&&(r.push(i),i=""),null!=f&&null!=d&&d!==f),h=h[2]||a,r.push({name:l||n++,prefix:f||"",delimiter:h,optional:"?"===s||"*"===s,repeat:"+"===s||"*"===s,partial:d,asterisk:!!p,pattern:(l=u||c)?l.replace(/([=!:$\/()])/g,"\\$1"):p?".*":"[^"+m(h)+"]+?"}))}return o<t.length&&(i+=t.substr(o)),i&&r.push(i),r}function G(t){return encodeURI(t).replace(/[\/?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Z(p,t){for(var h=new Array(p.length),e=0;e<p.length;e++)"object"==typeof p[e]&&(h[e]=new RegExp("^(?:"+p[e].pattern+")$",b(t)));return function(t,e){for(var r="",n=t||{},o=(e||{}).pretty?G:encodeURIComponent,i=0;i<p.length;i++){var a=p[i];if("string"==typeof a)r+=a;else{var u,c=n[a.name];if(null==c){if(a.optional){a.partial&&(r+=a.prefix);continue}throw new TypeError('Expected "'+a.name+'" to be defined')}if(y(c)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but received `'+JSON.stringify(c)+"`");if(0===c.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var s=0;s<c.length;s++){if(u=o(c[s]),!h[i].test(u))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'", but received `'+JSON.stringify(u)+"`");r+=(0===s?a.prefix:a.delimiter)+u}}else{if(u=a.asterisk?encodeURI(c).replace(/[?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}):o(c),!h[i].test(u))throw new TypeError('Expected "'+a.name+'" to match "'+a.pattern+'", but received "'+u+'"');r+=a.prefix+u}}}return r}}function m(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function g(t,e){return t.keys=e,t}function b(t){return t&&t.sensitive?"":"i"}function tt(t,e,r){y(e)||(r=e||r,e=[]);for(var n=(r=r||{}).strict,o=!1!==r.end,i="",a=0;a<t.length;a++){var u,c,s=t[a];"string"==typeof s?i+=m(s):(u=m(s.prefix),c="(?:"+s.pattern+")",e.push(s),s.repeat&&(c+="(?:"+u+c+")*"),i+=c=s.optional?s.partial?u+"("+c+")?":"(?:"+u+"("+c+"))?":u+"("+c+")")}var p=m(r.delimiter||"/"),h=i.slice(-p.length)===p;return n||(i=(h?i.slice(0,-p.length):i)+"(?:"+p+"(?=$))?"),i+=o?"$":n&&h?"":"(?="+p+"|$)",g(new RegExp("^"+i,b(r)),e)}function et(t,e,r){if(y(e)||(r=e||r,e=[]),r=r||{},t instanceof RegExp){var n=t,o=e,i=n.source.match(/\((?!\?)/g);if(i)for(var a=0;a<i.length;a++)o.push({name:a,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return g(n,o)}if(y(t)){for(var u=t,c=e,s=r,p=[],h=0;h<u.length;h++)p.push(et(u[h],c,s).source);return g(new RegExp("(?:"+p.join("|")+")",b(s)),c)}return n=e,tt(v(t,e=r),n,e)}s.parse=t,s.compile=X,s.tokensToFunction=e,s.tokensToRegExp=Y;var rt=Object.create(null);function w(t,e){try{return(rt[t]||(rt[t]=s.compile(t)))(e||{},{pretty:!0})}catch(t){return""}}function nt(t,e,r,n){var o=e||[],i=r||Object.create(null),a=n||Object.create(null);t.forEach(function(t){!function r(n,o,i,e,a,u){var t=e.path;var c=e.name;var s=e.pathToRegexpOptions||{};t=it(t,a,s.strict);"boolean"==typeof e.caseSensitive&&(s.sensitive=e.caseSensitive);var p={path:t,regex:ot(t,s),components:e.components||{default:e.component},instances:{},name:c,parent:a,matchAs:u,redirect:e.redirect,beforeEnter:e.beforeEnter,meta:e.meta||{},props:null==e.props?{}:e.components?e.props:{default:e.props}};e.children&&e.children.forEach(function(t){var e=u?h(u+"/"+t.path):void 0;r(n,o,i,t,p,e)});void 0!==e.alias&&(Array.isArray(e.alias)?e.alias:[e.alias]).forEach(function(t){t={path:t,children:e.children};r(n,o,i,t,a,p.path||"/")});o[p.path]||(n.push(p.path),o[p.path]=p);!c||i[c]||(i[c]=p)}(o,i,a,t)});for(var u=0,c=o.length;u<c;u++)"*"===o[u]&&(o.push(o.splice(u,1)[0]),c--,u--);return{pathList:o,pathMap:i,nameMap:a}}function ot(t,e){return s(t,[],e)}function it(t,e,r){return"/"===(t=r?t:t.replace(/\/$/,""))[0]||null==e?t:h(e.path+"/"+t)}function at(t,e,r,n){var o,i,a,u,t="string"==typeof t?{path:t}:t;return t.name||t._normalized?t:!t.path&&t.params&&e?((t=ut({},t))._normalized=!0,i=ut(ut({},e.params),t.params),e.name?(t.name=e.name,t.params=i):e.matched.length&&(o=e.matched[e.matched.length-1].path,t.path=w(o,i,e.path)),t):(o=t.path||"",u=i="",0<=(a=o.indexOf("#"))&&(i=o.slice(a),o=o.slice(0,a)),0<=(a=o.indexOf("?"))&&(u=o.slice(a+1),o=o.slice(0,a)),a=e&&e.path||"/",{_normalized:!0,path:(e={path:o,query:u,hash:i}).path?Q(e.path,a,r||t.append):a,query:function(t,e,r){void 0===e&&(e={});var n,o,r=r||B;try{n=r(t||"")}catch(t){n={}}for(o in e)n[o]=e[o];return n}(e.query,t.query,n&&n.options.parseQuery),hash:u=(u=t.hash||e.hash)&&"#"!==u.charAt(0)?"#"+u:u})}function ut(t,e){for(var r in e)t[r]=e[r];return t}function ct(t,c){var t=nt(t),s=t.pathList,p=t.pathMap,h=t.nameMap;function f(t,e,r){var n=at(t,e,!1,c),t=n.name;if(t){t=h[t];if(!t)return l(null,n);var o=t.regex.keys.filter(function(t){return!t.optional}).map(function(t){return t.name});if("object"!=typeof n.params&&(n.params={}),e&&"object"==typeof e.params)for(var i in e.params)!(i in n.params)&&-1<o.indexOf(i)&&(n.params[i]=e.params[i]);if(t)return n.path=w(t.path,n.params),l(t,n,r)}else if(n.path){n.params={};for(var a=0;a<s.length;a++){var u=s[a],u=p[u];if(function(t,e,r){var n=e.match(t);{if(!n)return;if(!r)return 1}for(var o=1,i=n.length;o<i;++o){var a=t.keys[o-1],u="string"==typeof n[o]?decodeURIComponent(n[o]):n[o];a&&(r[a.name]=u)}return 1}(u.regex,n.path,n.params))return l(u,n,r)}}return l(null,n)}function a(t,e){var r,n,o,i,a,u=t.redirect,u="function"==typeof u?u(d(t,e,null,c)):u;return(u="string"==typeof u?{path:u}:u)&&"object"==typeof u?(r=(u=u).name,n=u.path,o=e.query,i=e.hash,a=e.params,o=u.hasOwnProperty("query")?u.query:o,i=u.hasOwnProperty("hash")?u.hash:i,a=u.hasOwnProperty("params")?u.params:a,r?f({_normalized:!0,name:r,query:o,hash:i,params:a},void 0,e):n?f({_normalized:!0,path:w(Q(n,(u=t).parent?u.parent.path:"/",!0),a),query:o,hash:i},void 0,e):l(null,e)):l(null,e)}function l(t,e,r){var n,o,i;return t&&t.redirect?a(t,r||e):t&&t.matchAs?(n=e,(o=f({_normalized:!0,path:w(o=t.matchAs,n.params)}))?(i=(i=o.matched)[i.length-1],n.params=o.params,l(i,n)):l(null,n)):d(t,e,r,c)}return{match:f,addRoutes:function(t){nt(t,s,p,h)}}}var st=Object.create(null);function pt(){window.history.replaceState({key:R},""),window.addEventListener("popstate",function(t){ht(),t.state&&t.state.key&&(t=t.state.key,R=t)})}function p(t,r,n,o){var i;t.app&&(i=t.options.scrollBehavior)&&t.app.$nextTick(function(){var e=function(){var t=R;if(t)return st[t]}(),t=i(r,n,o?e:null);t&&("function"==typeof t.then?t.then(function(t){dt(t,e)}).catch(function(t){}):dt(t,e))})}function ht(){R&&(st[R]={x:window.pageXOffset,y:window.pageYOffset})}function ft(t){return x(t.x)||x(t.y)}function lt(t){return{x:x(t.x)?t.x:window.pageXOffset,y:x(t.y)?t.y:window.pageYOffset}}function x(t){return"number"==typeof t}function dt(t,e){var r,n,o,i="object"==typeof t;i&&"string"==typeof t.selector?(r=document.querySelector(t.selector))?(n=t.offset&&"object"==typeof t.offset?t.offset:{},n={x:x((o=n).x)?o.x:0,y:x(o.y)?o.y:0},o=r,r=n,n=document.documentElement.getBoundingClientRect(),e={x:(o=o.getBoundingClientRect()).left-n.left-r.x,y:o.top-n.top-r.y}):ft(t)&&(e=lt(t)):i&&ft(t)&&(e=lt(t)),e&&window.scrollTo(e.x,e.y)}var k=n&&(-1===(t=window.navigator.userAgent).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,yt=n&&window.performance&&window.performance.now?window.performance:Date,R=vt();function vt(){return yt.now().toFixed(3)}function E(e,r){ht();var t=window.history;try{r?t.replaceState({key:R},"",e):(R=vt(),t.pushState({key:R},"",e))}catch(t){window.location[r?"replace":"assign"](e)}}function mt(t){E(t,!0)}function gt(e,r,n){function o(t){t>=e.length?n():e[t]?r(e[t],function(){o(t+1)}):o(t+1)}o(0)}function bt(r){return function(t,e,u){var c=!1,s=0,p=null;wt(r,function(r,t,n,o){if("function"==typeof r&&void 0===r.cid){c=!0,s++;var e,i=Rt(function(t){var e;((e=t).__esModule||kt&&"Module"===e[Symbol.toStringTag])&&(t=t.default),r.resolved="function"==typeof t?t:l.extend(t),n.components[o]=t,--s<=0&&u()}),a=Rt(function(t){var e="Failed to resolve async component "+o+": "+t;p||(p=f(t)?t:new Error(e),u(p))});try{e=r(i,a)}catch(t){a(t)}e&&("function"==typeof e.then?e.then(i,a):(e=e.component)&&"function"==typeof e.then&&e.then(i,a))}}),c||u()}}function wt(t,r){return xt(t.map(function(e){return Object.keys(e.components).map(function(t){return r(e.components[t],e.instances[t],e,t)})}))}function xt(t){return Array.prototype.concat.apply([],t)}var kt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function Rt(r){var n=!1;return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!n)return n=!0,r.apply(this,t)}}function O(t,e){this.router=t,this.base=function(t){{var e;t=t||(n?(e=document.querySelector("base"),(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")):"/")}"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=u,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]}function Et(t,o,i,e){t=wt(t,function(t,e,r,n){t=function(t,e){"function"!=typeof t&&(t=l.extend(t));return t.options[e]}(t,o);if(t)return Array.isArray(t)?t.map(function(t){return i(t,e,r,n)}):i(t,e,r,n)});return xt(e?t.reverse():t)}function Ot(t,e){if(e)return function(){return t.apply(e,arguments)}}O.prototype.listen=function(t){this.cb=t},O.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},O.prototype.onError=function(t){this.errorCbs.push(t)},O.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(e){r&&r(e),e&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(t){t(e)}))})},O.prototype.confirmTransition=function(r,e,t){var n=this,o=this.current,i=function(e){f(e)&&(n.errorCbs.length?n.errorCbs.forEach(function(t){t(e)}):console.error(e)),t&&t(e)};if(V(r,o)&&r.matched.length===o.matched.length)return this.ensureURL(),i();function a(t,e){if(n.pending!==r)return i();try{t(r,o,function(t){!1===t||f(t)?(n.ensureURL(!0),i(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(i(),"object"==typeof t&&t.replace?n.replace(t):n.push(t)):e(t)})}catch(t){i(t)}}var u=function(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r<n&&t[r]===e[r];r++);return{updated:e.slice(0,r),activated:e.slice(r),deactivated:t.slice(r)}}(this.current.matched,r.matched),c=u.updated,s=u.deactivated,h=u.activated,u=[].concat(Et(s,"beforeRouteLeave",Ot,!0),this.router.beforeHooks,Et(c,"beforeRouteUpdate",Ot),h.map(function(t){return t.beforeEnter}),bt(h));this.pending=r;gt(u,a,function(){var s,p,t=[];s=t,p=function(){return n.current===r},gt(Et(h,"beforeRouteEnter",function(t,e,r,n){return o=t,i=r,a=n,u=s,c=p,function(t,e,r){return o(t,e,function(t){r(t),"function"==typeof t&&u.push(function(){!function t(e,r,n,o){r[n]?e(r[n]):o()&&setTimeout(function(){t(e,r,n,o)},16)}(t,i.instances,a,c)})})};var o,i,a,u,c}).concat(n.router.resolveHooks),a,function(){if(n.pending!==r)return i();n.pending=null,e(r),n.router.app&&n.router.app.$nextTick(function(){t.forEach(function(t){t()})})})})},O.prototype.updateRoute=function(e){var r=this.current;this.current=e,this.cb&&this.cb(e),this.router.afterHooks.forEach(function(t){t&&t(e,r)})};(C=O)&&(j.__proto__=C),((j.prototype=Object.create(C&&C.prototype)).constructor=j).prototype.go=function(t){window.history.go(t)},j.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){E(h(n.base+t.fullPath)),p(n.router,t,o,!1),e&&e(t)},r)},j.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){mt(h(n.base+t.fullPath)),p(n.router,t,o,!1),e&&e(t)},r)},j.prototype.ensureURL=function(t){A(this.base)!==this.current.fullPath&&(t?E:mt)(h(this.base+this.current.fullPath))},j.prototype.getCurrentLocation=function(){return A(this.base)};var C,Ct=j;function j(n,t){var o=this,i=(C.call(this,n,t),n.options.scrollBehavior),a=(i&&pt(),A(this.base));window.addEventListener("popstate",function(t){var e=o.current,r=A(o.base);o.current===u&&r===a||o.transitionTo(r,function(t){i&&p(n,t,e,!0)})})}function A(t){var e=window.location.pathname;return((e=t&&0===e.indexOf(t)?e.slice(t.length):e)||"/")+window.location.search+window.location.hash}(_=O)&&(T.__proto__=_),((T.prototype=Object.create(_&&_.prototype)).constructor=T).prototype.setupListeners=function(){var r=this,t=this.router.options.scrollBehavior,n=k&&t;n&&pt(),window.addEventListener(k?"popstate":"hashchange",function(){var e=r.current;At()&&r.transitionTo(S(),function(t){n&&p(r.router,t,e,!0),k||$(t.fullPath)})})},T.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){Tt(t.fullPath),p(n.router,t,o,!1),e&&e(t)},r)},T.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){$(t.fullPath),p(n.router,t,o,!1),e&&e(t)},r)},T.prototype.go=function(t){window.history.go(t)},T.prototype.ensureURL=function(t){var e=this.current.fullPath;S()!==e&&(t?Tt:$)(e)},T.prototype.getCurrentLocation=S;var _,jt=T;function T(t,e,r){_.call(this,t,e),r&&function(t){var e=A(t);if(!/^\/#/.test(e))return window.location.replace(h(t+"/#"+e)),1}(this.base)||At()}function At(){var t=S();if("/"===t.charAt(0))return 1;$("/"+t)}function S(){var t=window.location.href,e=t.indexOf("#");return-1===e?"":t.slice(e+1)}function _t(t){var e=window.location.href,r=e.indexOf("#");return(0<=r?e.slice(0,r):e)+"#"+t}function Tt(t){k?E(_t(t)):window.location.hash=t}function $(t){k?mt(_t(t)):window.location.replace(_t(t))}(q=O)&&(L.__proto__=q),((L.prototype=Object.create(q&&q.prototype)).constructor=L).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)},L.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)},L.prototype.go=function(t){var e,r=this,n=this.index+t;n<0||n>=this.stack.length||(e=this.stack[n],this.confirmTransition(e,function(){r.index=n,r.updateRoute(e)}))},L.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},L.prototype.ensureURL=function(){};var q,St=L;function L(t,e){q.call(this,t,e),this.stack=[],this.index=-1}function P(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=ct(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!k&&!1!==t.fallback,this.fallback&&(e="hash"),this.mode=e=n?e:"abstract"){case"history":this.history=new Ct(this,t.base);break;case"hash":this.history=new jt(this,t.base,this.fallback);break;case"abstract":this.history=new St(this,t.base)}}e={currentRoute:{configurable:!0}};function $t(e,r){return e.push(r),function(){var t=e.indexOf(r);-1<t&&e.splice(t,1)}}return P.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},e.currentRoute.get=function(){return this.history&&this.history.current},P.prototype.init=function(t){var e,r=this;this.apps.push(t),this.app||(this.app=t,(e=this.history)instanceof Ct?e.transitionTo(e.getCurrentLocation()):e instanceof jt&&(t=function(){e.setupListeners()},e.transitionTo(e.getCurrentLocation(),t,t)),e.listen(function(e){r.apps.forEach(function(t){t._route=e})}))},P.prototype.beforeEach=function(t){return $t(this.beforeHooks,t)},P.prototype.beforeResolve=function(t){return $t(this.resolveHooks,t)},P.prototype.afterEach=function(t){return $t(this.afterHooks,t)},P.prototype.onReady=function(t,e){this.history.onReady(t,e)},P.prototype.onError=function(t){this.history.onError(t)},P.prototype.push=function(t,e,r){this.history.push(t,e,r)},P.prototype.replace=function(t,e,r){this.history.replace(t,e,r)},P.prototype.go=function(t){this.history.go(t)},P.prototype.back=function(){this.go(-1)},P.prototype.forward=function(){this.go(1)},P.prototype.getMatchedComponents=function(t){t=t?t.matched?t:this.resolve(t).route:this.currentRoute;return t?[].concat.apply([],t.matched.map(function(e){return Object.keys(e.components).map(function(t){return e.components[t]})})):[]},P.prototype.resolve=function(t,e,r){t=at(t,e||this.history.current,r,this),r=this.match(t,e),e=r.redirectedFrom||r.fullPath;return{location:t,route:r,href:function(t,e,r){r="hash"===r?"#"+e:e;return t?h(t+"/"+r):r}(this.history.base,e,this.mode),normalizedTo:t,resolved:r}},P.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==u&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(P.prototype,e),P.install=c,P.version="3.0.0",n&&window.Kdu&&window.Kdu.use(P),P});
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.KduRouter=e()}(this,function(){"use strict";function f(t){return-1<Object.prototype.toString.call(t).indexOf("Error")}var U={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(t,e){for(var r=e.props,n=e.children,o=e.parent,e=e.data,i=(e.routerView=!0,o.$createElement),a=r.name,r=o.$route,u=o._routerViewCache||(o._routerViewCache={}),c=0,s=!1;o&&o._routerRoot!==o;)o.$knode&&o.$knode.data.routerView&&c++,o._inactive&&(s=!0),o=o.$parent;if(e.routerViewDepth=c,s)return i(u[a],e,n);var p=r.matched[c];if(!p)return u[a]=null,i();var h=u[a]=p.components[a];if(e.registerRouteInstance=function(t,e){var r=p.instances[a];(e&&r!==t||!e&&r===t)&&(p.instances[a]=e)},(e.hook||(e.hook={})).prepatch=function(t,e){p.instances[a]=e.componentInstance},l=e.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}}(r,p.props&&p.props[a])){var f,l=e.props=function(t,e){for(var r in e)t[r]=e[r];return t}({},l),d=e.attrs=e.attrs||{};for(f in l)h.props&&f in h.props||(d[f]=l[f],delete l[f])}return i(h,e,n)}};function o(t){return encodeURIComponent(t).replace(M,H).replace(I,",")}var M=/[!'()*]/g,H=function(t){return"%"+t.charCodeAt(0).toString(16)},I=/%2C/g,z=decodeURIComponent;function B(t){var r={};return(t=t.trim().replace(/^(\?|#|&)/,""))&&t.split("&").forEach(function(t){var t=t.replace(/\+/g," ").split("="),e=z(t.shift()),t=0<t.length?z(t.join("=")):null;void 0===r[e]?r[e]=t:Array.isArray(r[e])?r[e].push(t):r[e]=[r[e],t]}),r}function K(n){var t=n?Object.keys(n).map(function(e){var r,t=n[e];return void 0===t?"":null===t?o(e):Array.isArray(t)?(r=[],t.forEach(function(t){void 0!==t&&r.push(null===t?o(e):o(e)+"="+o(t))}),r.join("&")):o(e)+"="+o(t)}).filter(function(t){return 0<t.length}).join("&"):null;return t?"?"+t:""}var r=/\/?$/;function d(t,e,r,n){var n=n&&n.options.stringifyQuery,o=e.query||{};try{o=i(o)}catch(t){}o={name:e.name||t&&t.name,meta:t&&t.meta||{},path:e.path||"/",hash:e.hash||"",query:o,params:e.params||{},fullPath:F(e,n),matched:t?function(t){var e=[];for(;t;)e.unshift(t),t=t.parent;return e}(t):[]};return r&&(o.redirectedFrom=F(r,n)),Object.freeze(o)}function i(t){if(Array.isArray(t))return t.map(i);if(t&&"object"==typeof t){var e,r={};for(e in t)r[e]=i(t[e]);return r}return t}var u=d(null,{path:"/"});function F(t,e){var r=t.path,n=t.query,t=t.hash;return void 0===t&&(t=""),(r||"/")+(e||K)(n=void 0===n?{}:n)+t}function V(t,e){return e===u?t===e:!!e&&(t.path&&e.path?t.path.replace(r,"")===e.path.replace(r,"")&&t.hash===e.hash&&a(t.query,e.query):!(!t.name||!e.name)&&t.name===e.name&&t.hash===e.hash&&a(t.query,e.query)&&a(t.params,e.params))}function a(r,n){var t,e;return void 0===n&&(n={}),(r=void 0===r?{}:r)&&n?(t=Object.keys(r),e=Object.keys(n),t.length===e.length&&t.every(function(t){var e=r[t],t=n[t];return"object"==typeof e&&"object"==typeof t?a(e,t):String(e)===String(t)})):r===n}function D(t,e){return 0===t.path.replace(r,"/").indexOf(e.path.replace(r,"/"))&&(!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)}var l,t=[String,Object],e=[String,Array],J={name:"router-link",props:{to:{type:t,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:e,default:"click"}},render:function(t){function e(t){N(t)&&(r.replace?n.replace(a):n.push(a))}var r=this,n=this.$router,o=this.$route,i=n.resolve(this.to,o,this.append),a=i.location,u=i.route,i=i.href,c={},s=n.options.linkActiveClass,p=n.options.linkExactActiveClass,s=null==this.activeClass?null==s?"router-link-active":s:this.activeClass,p=null==this.exactActiveClass?null==p?"router-link-exact-active":p:this.exactActiveClass,u=a.path?d(null,a,null,n):u,h=(c[p]=V(o,u),c[s]=this.exact?c[p]:D(o,u),{click:N}),s=(Array.isArray(this.event)?this.event.forEach(function(t){h[t]=e}):h[this.event]=e,{class:c});return"a"===this.tag?(s.on=h,s.attrs={href:i}):(p=function t(e){if(e)for(var r,n=0;n<e.length;n++){if("a"===(r=e[n]).tag)return r;if(r.children&&(r=t(r.children)))return r}}(this.$slots.default))?(p.isStatic=!1,o=l.util.extend,(p.data=o({},p.data)).on=h,(p.data.attrs=o({},p.data.attrs)).href=i):s.on=h,t(this.tag,s,this.$slots.default)}};function N(t){if(!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.defaultPrevented||void 0!==t.button&&0!==t.button)){if(t.currentTarget&&t.currentTarget.getAttribute){var e=t.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return t.preventDefault&&t.preventDefault(),!0}}function c(t){var n,e,r;c.installed&&l===t||(c.installed=!0,n=function(t){return void 0!==t},e=function(t,e){var r=t.$options._parentKnode;n(r)&&n(r=r.data)&&n(r=r.registerRouteInstance)&&r(t,e)},(l=t).mixin({beforeCreate:function(){n(this.$options.router)?((this._routerRoot=this)._router=this.$options.router,this._router.init(this),t.util.defineReactive(this,"_route",this._router.history.current)):this._routerRoot=this.$parent&&this.$parent._routerRoot||this,e(this,this)},destroyed:function(){e(this)}}),Object.defineProperty(t.prototype,"$router",{get:function(){return this._routerRoot._router}}),Object.defineProperty(t.prototype,"$route",{get:function(){return this._routerRoot._route}}),t.component("router-view",U),t.component("router-link",J),(r=t.config.optionMergeStrategies).beforeRouteEnter=r.beforeRouteLeave=r.beforeRouteUpdate=r.created)}var n="undefined"!=typeof window;function Q(t,e,r){var n=t.charAt(0);if("/"===n)return t;if("?"===n||"#"===n)return e+t;for(var o=e.split("/"),i=(r&&o[o.length-1]||o.pop(),t.replace(/^\//,"").split("/")),a=0;a<i.length;a++){var u=i[a];".."===u?o.pop():"."!==u&&o.push(u)}return""!==o[0]&&o.unshift(""),o.join("/")}function h(t){return t.replace(/\/\//g,"/")}function X(t,e){return Z(v(t,e),e)}var y=Array.isArray||function(t){return"[object Array]"==Object.prototype.toString.call(t)},s=et,t=v,e=Z,Y=tt,W=new RegExp(["(\\\\.)","([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"].join("|"),"g");function v(t,e){for(var r=[],n=0,o=0,i="",a=e&&e.delimiter||"/";null!=(h=W.exec(t));){var u,c,s,p,h,f=h[0],l=h[1],d=h.index;i+=t.slice(o,d),o=d+f.length,l?i+=l[1]:(d=t[o],f=h[2],l=h[3],u=h[4],c=h[5],s=h[6],p=h[7],d=(i&&(r.push(i),i=""),null!=f&&null!=d&&d!==f),h=h[2]||a,r.push({name:l||n++,prefix:f||"",delimiter:h,optional:"?"===s||"*"===s,repeat:"+"===s||"*"===s,partial:d,asterisk:!!p,pattern:(l=u||c)?l.replace(/([=!:$\/()])/g,"\\$1"):p?".*":"[^"+m(h)+"]+?"}))}return o<t.length&&(i+=t.substr(o)),i&&r.push(i),r}function G(t){return encodeURI(t).replace(/[\/?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function Z(p,t){for(var h=new Array(p.length),e=0;e<p.length;e++)"object"==typeof p[e]&&(h[e]=new RegExp("^(?:"+p[e].pattern+")$",b(t)));return function(t,e){for(var r="",n=t||{},o=(e||{}).pretty?G:encodeURIComponent,i=0;i<p.length;i++){var a=p[i];if("string"==typeof a)r+=a;else{var u,c=n[a.name];if(null==c){if(a.optional){a.partial&&(r+=a.prefix);continue}throw new TypeError('Expected "'+a.name+'" to be defined')}if(y(c)){if(!a.repeat)throw new TypeError('Expected "'+a.name+'" to not repeat, but received `'+JSON.stringify(c)+"`");if(0===c.length){if(a.optional)continue;throw new TypeError('Expected "'+a.name+'" to not be empty')}for(var s=0;s<c.length;s++){if(u=o(c[s]),!h[i].test(u))throw new TypeError('Expected all "'+a.name+'" to match "'+a.pattern+'", but received `'+JSON.stringify(u)+"`");r+=(0===s?a.prefix:a.delimiter)+u}}else{if(u=a.asterisk?encodeURI(c).replace(/[?#]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}):o(c),!h[i].test(u))throw new TypeError('Expected "'+a.name+'" to match "'+a.pattern+'", but received "'+u+'"');r+=a.prefix+u}}}return r}}function m(t){return t.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}function g(t,e){return t.keys=e,t}function b(t){return t&&t.sensitive?"":"i"}function tt(t,e,r){y(e)||(r=e||r,e=[]);for(var n=(r=r||{}).strict,o=!1!==r.end,i="",a=0;a<t.length;a++){var u,c,s=t[a];"string"==typeof s?i+=m(s):(u=m(s.prefix),c="(?:"+s.pattern+")",e.push(s),s.repeat&&(c+="(?:"+u+c+")*"),i+=c=s.optional?s.partial?u+"("+c+")?":"(?:"+u+"("+c+"))?":u+"("+c+")")}var p=m(r.delimiter||"/"),h=i.slice(-p.length)===p;return n||(i=(h?i.slice(0,-p.length):i)+"(?:"+p+"(?=$))?"),i+=o?"$":n&&h?"":"(?="+p+"|$)",g(new RegExp("^"+i,b(r)),e)}function et(t,e,r){if(y(e)||(r=e||r,e=[]),r=r||{},t instanceof RegExp){var n=t,o=e,i=n.source.match(/\((?!\?)/g);if(i)for(var a=0;a<i.length;a++)o.push({name:a,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,asterisk:!1,pattern:null});return g(n,o)}if(y(t)){for(var u=t,c=e,s=r,p=[],h=0;h<u.length;h++)p.push(et(u[h],c,s).source);return g(new RegExp("(?:"+p.join("|")+")",b(s)),c)}return n=e,tt(v(t,e=r),n,e)}s.parse=t,s.compile=X,s.tokensToFunction=e,s.tokensToRegExp=Y;var rt=Object.create(null);function w(t,e){try{return(rt[t]||(rt[t]=s.compile(t)))(e||{},{pretty:!0})}catch(t){return""}}function nt(t,e,r,n){var o=e||[],i=r||Object.create(null),a=n||Object.create(null);t.forEach(function(t){!function r(n,o,i,e,a,u){var t=e.path;var c=e.name;var s=e.pathToRegexpOptions||{};t=it(t,a,s.strict);"boolean"==typeof e.caseSensitive&&(s.sensitive=e.caseSensitive);var p={path:t,regex:ot(t,s),components:e.components||{default:e.component},instances:{},name:c,parent:a,matchAs:u,redirect:e.redirect,beforeEnter:e.beforeEnter,meta:e.meta||{},props:null==e.props?{}:e.components?e.props:{default:e.props}};e.children&&e.children.forEach(function(t){var e=u?h(u+"/"+t.path):void 0;r(n,o,i,t,p,e)});void 0!==e.alias&&(Array.isArray(e.alias)?e.alias:[e.alias]).forEach(function(t){t={path:t,children:e.children};r(n,o,i,t,a,p.path||"/")});o[p.path]||(n.push(p.path),o[p.path]=p);!c||i[c]||(i[c]=p)}(o,i,a,t)});for(var u=0,c=o.length;u<c;u++)"*"===o[u]&&(o.push(o.splice(u,1)[0]),c--,u--);return{pathList:o,pathMap:i,nameMap:a}}function ot(t,e){return s(t,[],e)}function it(t,e,r){return"/"===(t=r?t:t.replace(/\/$/,""))[0]||null==e?t:h(e.path+"/"+t)}function at(t,e,r,n){var o,i,a,u,t="string"==typeof t?{path:t}:t;return t.name||t._normalized?t:!t.path&&t.params&&e?((t=ut({},t))._normalized=!0,i=ut(ut({},e.params),t.params),e.name?(t.name=e.name,t.params=i):e.matched.length&&(o=e.matched[e.matched.length-1].path,t.path=w(o,i,e.path)),t):(o=t.path||"",u=i="",0<=(a=o.indexOf("#"))&&(i=o.slice(a),o=o.slice(0,a)),0<=(a=o.indexOf("?"))&&(u=o.slice(a+1),o=o.slice(0,a)),a=e&&e.path||"/",{_normalized:!0,path:(e={path:o,query:u,hash:i}).path?Q(e.path,a,r||t.append):a,query:function(t,e,r){void 0===e&&(e={});var n,o,r=r||B;try{n=r(t||"")}catch(t){n={}}for(o in e)n[o]=e[o];return n}(e.query,t.query,n&&n.options.parseQuery),hash:u=(u=t.hash||e.hash)&&"#"!==u.charAt(0)?"#"+u:u})}function ut(t,e){for(var r in e)t[r]=e[r];return t}function ct(t,c){var t=nt(t),s=t.pathList,p=t.pathMap,h=t.nameMap;function f(t,e,r){var n=at(t,e,!1,c),t=n.name;if(t){t=h[t];if(!t)return l(null,n);var o=t.regex.keys.filter(function(t){return!t.optional}).map(function(t){return t.name});if("object"!=typeof n.params&&(n.params={}),e&&"object"==typeof e.params)for(var i in e.params)!(i in n.params)&&-1<o.indexOf(i)&&(n.params[i]=e.params[i]);if(t)return n.path=w(t.path,n.params),l(t,n,r)}else if(n.path){n.params={};for(var a=0;a<s.length;a++){var u=s[a],u=p[u];if(function(t,e,r){var n=e.match(t);{if(!n)return;if(!r)return 1}for(var o=1,i=n.length;o<i;++o){var a=t.keys[o-1],u="string"==typeof n[o]?decodeURIComponent(n[o]):n[o];a&&(r[a.name]=u)}return 1}(u.regex,n.path,n.params))return l(u,n,r)}}return l(null,n)}function a(t,e){var r,n,o,i,a,u=t.redirect,u="function"==typeof u?u(d(t,e,null,c)):u;return(u="string"==typeof u?{path:u}:u)&&"object"==typeof u?(r=(u=u).name,n=u.path,o=e.query,i=e.hash,a=e.params,o=u.hasOwnProperty("query")?u.query:o,i=u.hasOwnProperty("hash")?u.hash:i,a=u.hasOwnProperty("params")?u.params:a,r?f({_normalized:!0,name:r,query:o,hash:i,params:a},void 0,e):n?f({_normalized:!0,path:w(Q(n,(u=t).parent?u.parent.path:"/",!0),a),query:o,hash:i},void 0,e):l(null,e)):l(null,e)}function l(t,e,r){var n,o,i;return t&&t.redirect?a(t,r||e):t&&t.matchAs?(n=e,(o=f({_normalized:!0,path:w(o=t.matchAs,n.params)}))?(i=(i=o.matched)[i.length-1],n.params=o.params,l(i,n)):l(null,n)):d(t,e,r,c)}return{match:f,addRoutes:function(t){nt(t,s,p,h)}}}var st=Object.create(null);function pt(){window.history.replaceState({key:R},""),window.addEventListener("popstate",function(t){ht(),t.state&&t.state.key&&(t=t.state.key,R=t)})}function p(t,r,n,o){var i;t.app&&(i=t.options.scrollBehavior)&&t.app.$nextTick(function(){var e=function(){var t=R;if(t)return st[t]}(),t=i(r,n,o?e:null);t&&("function"==typeof t.then?t.then(function(t){dt(t,e)}).catch(function(t){}):dt(t,e))})}function ht(){R&&(st[R]={x:window.pageXOffset,y:window.pageYOffset})}function ft(t){return x(t.x)||x(t.y)}function lt(t){return{x:x(t.x)?t.x:window.pageXOffset,y:x(t.y)?t.y:window.pageYOffset}}function x(t){return"number"==typeof t}function dt(t,e){var r,n,o,i="object"==typeof t;i&&"string"==typeof t.selector?(r=document.querySelector(t.selector))?(n=t.offset&&"object"==typeof t.offset?t.offset:{},n={x:x((o=n).x)?o.x:0,y:x(o.y)?o.y:0},o=r,r=n,n=document.documentElement.getBoundingClientRect(),e={x:(o=o.getBoundingClientRect()).left-n.left-r.x,y:o.top-n.top-r.y}):ft(t)&&(e=lt(t)):i&&ft(t)&&(e=lt(t)),e&&window.scrollTo(e.x,e.y)}var k=n&&(-1===(t=window.navigator.userAgent).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,yt=n&&window.performance&&window.performance.now?window.performance:Date,R=vt();function vt(){return yt.now().toFixed(3)}function E(e,r){ht();var t=window.history;try{r?t.replaceState({key:R},"",e):(R=vt(),t.pushState({key:R},"",e))}catch(t){window.location[r?"replace":"assign"](e)}}function mt(t){E(t,!0)}function gt(e,r,n){function o(t){t>=e.length?n():e[t]?r(e[t],function(){o(t+1)}):o(t+1)}o(0)}function bt(r){return function(t,e,u){var c=!1,s=0,p=null;wt(r,function(r,t,n,o){if("function"==typeof r&&void 0===r.cid){c=!0,s++;var e,i=Rt(function(t){var e;((e=t).__esModule||kt&&"Module"===e[Symbol.toStringTag])&&(t=t.default),r.resolved="function"==typeof t?t:l.extend(t),n.components[o]=t,--s<=0&&u()}),a=Rt(function(t){var e="Failed to resolve async component "+o+": "+t;p||(p=f(t)?t:new Error(e),u(p))});try{e=r(i,a)}catch(t){a(t)}e&&("function"==typeof e.then?e.then(i,a):(e=e.component)&&"function"==typeof e.then&&e.then(i,a))}}),c||u()}}function wt(t,r){return xt(t.map(function(e){return Object.keys(e.components).map(function(t){return r(e.components[t],e.instances[t],e,t)})}))}function xt(t){return Array.prototype.concat.apply([],t)}var kt="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function Rt(r){var n=!1;return function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!n)return n=!0,r.apply(this,t)}}function O(t,e){this.router=t,this.base=function(t){{var e;t=t||(n?(e=document.querySelector("base"),(t=e&&e.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")):"/")}"/"!==t.charAt(0)&&(t="/"+t);return t.replace(/\/$/,"")}(e),this.current=u,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]}function Et(t,o,i,e){t=wt(t,function(t,e,r,n){t=function(t,e){"function"!=typeof t&&(t=l.extend(t));return t.options[e]}(t,o);if(t)return Array.isArray(t)?t.map(function(t){return i(t,e,r,n)}):i(t,e,r,n)});return xt(e?t.reverse():t)}function Ot(t,e){if(e)return function(){return t.apply(e,arguments)}}O.prototype.listen=function(t){this.cb=t},O.prototype.onReady=function(t,e){this.ready?t():(this.readyCbs.push(t),e&&this.readyErrorCbs.push(e))},O.prototype.onError=function(t){this.errorCbs.push(t)},O.prototype.transitionTo=function(t,e,r){var n=this,o=this.router.match(t,this.current);this.confirmTransition(o,function(){n.updateRoute(o),e&&e(o),n.ensureURL(),n.ready||(n.ready=!0,n.readyCbs.forEach(function(t){t(o)}))},function(e){r&&r(e),e&&!n.ready&&(n.ready=!0,n.readyErrorCbs.forEach(function(t){t(e)}))})},O.prototype.confirmTransition=function(r,e,t){var n=this,o=this.current,i=function(e){f(e)&&(n.errorCbs.length?n.errorCbs.forEach(function(t){t(e)}):console.error(e)),t&&t(e)};if(V(r,o)&&r.matched.length===o.matched.length)return this.ensureURL(),i();function a(t,e){if(n.pending!==r)return i();try{t(r,o,function(t){!1===t||f(t)?(n.ensureURL(!0),i(t)):"string"==typeof t||"object"==typeof t&&("string"==typeof t.path||"string"==typeof t.name)?(i(),"object"==typeof t&&t.replace?n.replace(t):n.push(t)):e(t)})}catch(t){i(t)}}var u=function(t,e){var r,n=Math.max(t.length,e.length);for(r=0;r<n&&t[r]===e[r];r++);return{updated:e.slice(0,r),activated:e.slice(r),deactivated:t.slice(r)}}(this.current.matched,r.matched),c=u.updated,s=u.deactivated,h=u.activated,u=[].concat(Et(s,"beforeRouteLeave",Ot,!0),this.router.beforeHooks,Et(c,"beforeRouteUpdate",Ot),h.map(function(t){return t.beforeEnter}),bt(h));this.pending=r;gt(u,a,function(){var s,p,t=[];s=t,p=function(){return n.current===r},gt(Et(h,"beforeRouteEnter",function(t,e,r,n){return o=t,i=r,a=n,u=s,c=p,function(t,e,r){return o(t,e,function(t){r(t),"function"==typeof t&&u.push(function(){!function t(e,r,n,o){r[n]?e(r[n]):o()&&setTimeout(function(){t(e,r,n,o)},16)}(t,i.instances,a,c)})})};var o,i,a,u,c}).concat(n.router.resolveHooks),a,function(){if(n.pending!==r)return i();n.pending=null,e(r),n.router.app&&n.router.app.$nextTick(function(){t.forEach(function(t){t()})})})})},O.prototype.updateRoute=function(e){var r=this.current;this.current=e,this.cb&&this.cb(e),this.router.afterHooks.forEach(function(t){t&&t(e,r)})};(C=O)&&(j.__proto__=C),((j.prototype=Object.create(C&&C.prototype)).constructor=j).prototype.go=function(t){window.history.go(t)},j.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){E(h(n.base+t.fullPath)),p(n.router,t,o,!1),e&&e(t)},r)},j.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){mt(h(n.base+t.fullPath)),p(n.router,t,o,!1),e&&e(t)},r)},j.prototype.ensureURL=function(t){A(this.base)!==this.current.fullPath&&(t?E:mt)(h(this.base+this.current.fullPath))},j.prototype.getCurrentLocation=function(){return A(this.base)};var C,Ct=j;function j(n,t){var o=this,i=(C.call(this,n,t),n.options.scrollBehavior),a=(i&&pt(),A(this.base));window.addEventListener("popstate",function(t){var e=o.current,r=A(o.base);o.current===u&&r===a||o.transitionTo(r,function(t){i&&p(n,t,e,!0)})})}function A(t){var e=window.location.pathname;return((e=t&&0===e.indexOf(t)?e.slice(t.length):e)||"/")+window.location.search+window.location.hash}(_=O)&&(T.__proto__=_),((T.prototype=Object.create(_&&_.prototype)).constructor=T).prototype.setupListeners=function(){var r=this,t=this.router.options.scrollBehavior,n=k&&t;n&&pt(),window.addEventListener(k?"popstate":"hashchange",function(){var e=r.current;At()&&r.transitionTo(S(),function(t){n&&p(r.router,t,e,!0),k||$(t.fullPath)})})},T.prototype.push=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){Tt(t.fullPath),p(n.router,t,o,!1),e&&e(t)},r)},T.prototype.replace=function(t,e,r){var n=this,o=this.current;this.transitionTo(t,function(t){$(t.fullPath),p(n.router,t,o,!1),e&&e(t)},r)},T.prototype.go=function(t){window.history.go(t)},T.prototype.ensureURL=function(t){var e=this.current.fullPath;S()!==e&&(t?Tt:$)(e)},T.prototype.getCurrentLocation=S;var _,jt=T;function T(t,e,r){_.call(this,t,e),r&&function(t){var e=A(t);if(!/^\/#/.test(e))return window.location.replace(h(t+"/#"+e)),1}(this.base)||At()}function At(){var t=S();if("/"===t.charAt(0))return 1;$("/"+t)}function S(){var t=window.location.href,e=t.indexOf("#");return-1===e?"":t.slice(e+1)}function _t(t){var e=window.location.href,r=e.indexOf("#");return(0<=r?e.slice(0,r):e)+"#"+t}function Tt(t){k?E(_t(t)):window.location.hash=t}function $(t){k?mt(_t(t)):window.location.replace(_t(t))}(q=O)&&(L.__proto__=q),((L.prototype=Object.create(q&&q.prototype)).constructor=L).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)},L.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)},L.prototype.go=function(t){var e,r=this,n=this.index+t;n<0||n>=this.stack.length||(e=this.stack[n],this.confirmTransition(e,function(){r.index=n,r.updateRoute(e)}))},L.prototype.getCurrentLocation=function(){var t=this.stack[this.stack.length-1];return t?t.fullPath:"/"},L.prototype.ensureURL=function(){};var q,St=L;function L(t,e){q.call(this,t,e),this.stack=[],this.index=-1}function P(t){void 0===t&&(t={}),this.app=null,this.apps=[],this.options=t,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=ct(t.routes||[],this);var e=t.mode||"hash";switch(this.fallback="history"===e&&!k&&!1!==t.fallback,this.fallback&&(e="hash"),this.mode=e=n?e:"abstract"){case"history":this.history=new Ct(this,t.base);break;case"hash":this.history=new jt(this,t.base,this.fallback);break;case"abstract":this.history=new St(this,t.base)}}e={currentRoute:{configurable:!0}};function $t(e,r){return e.push(r),function(){var t=e.indexOf(r);-1<t&&e.splice(t,1)}}return P.prototype.match=function(t,e,r){return this.matcher.match(t,e,r)},e.currentRoute.get=function(){return this.history&&this.history.current},P.prototype.init=function(t){var e,r=this;this.apps.push(t),this.app||(this.app=t,(e=this.history)instanceof Ct?e.transitionTo(e.getCurrentLocation()):e instanceof jt&&(t=function(){e.setupListeners()},e.transitionTo(e.getCurrentLocation(),t,t)),e.listen(function(e){r.apps.forEach(function(t){t._route=e})}))},P.prototype.beforeEach=function(t){return $t(this.beforeHooks,t)},P.prototype.beforeResolve=function(t){return $t(this.resolveHooks,t)},P.prototype.afterEach=function(t){return $t(this.afterHooks,t)},P.prototype.onReady=function(t,e){this.history.onReady(t,e)},P.prototype.onError=function(t){this.history.onError(t)},P.prototype.push=function(t,e,r){this.history.push(t,e,r)},P.prototype.replace=function(t,e,r){this.history.replace(t,e,r)},P.prototype.go=function(t){this.history.go(t)},P.prototype.back=function(){this.go(-1)},P.prototype.forward=function(){this.go(1)},P.prototype.getMatchedComponents=function(t){t=t?t.matched?t:this.resolve(t).route:this.currentRoute;return t?[].concat.apply([],t.matched.map(function(e){return Object.keys(e.components).map(function(t){return e.components[t]})})):[]},P.prototype.resolve=function(t,e,r){t=at(t,e||this.history.current,r,this),r=this.match(t,e),e=r.redirectedFrom||r.fullPath;return{location:t,route:r,href:function(t,e,r){r="hash"===r?"#"+e:e;return t?h(t+"/"+r):r}(this.history.base,e,this.mode),normalizedTo:t,resolved:r}},P.prototype.addRoutes=function(t){this.matcher.addRoutes(t),this.history.current!==u&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(P.prototype,e),P.install=c,P.version="3.0.1",n&&window.Kdu&&window.Kdu.use(P),P});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kdu-router",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Official router for Kdu.js 2",
5
5
  "author": "NKDuy",
6
6
  "license": "MIT",