vuejs-rails 2.2.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e31ad5112a87297ecdd603a3a16dd8d2bab31caf
4
- data.tar.gz: e6556db586b0861086b28ce702962dc2b162b801
3
+ metadata.gz: 869cf26b6079bbf39d417889c604e1522950bc46
4
+ data.tar.gz: c31c58f1e95cfe35f632b11c7f696ec352063702
5
5
  SHA512:
6
- metadata.gz: a08f876ae280979642268d30c1c31c2ee955690004db34afc320e7b20250df6ecf9c3107113349574d299a6ae4976124c3eb1249d1c454a529e9e653e1bae914
7
- data.tar.gz: 2bccc97acd3b1f64ca01a2cb7286968d6f6a450c5fe7f03d399280c942ded97e4166140ce1d6bd3d70796416bea840a40f99e92b7396b8b4709feb4ef497aac7
6
+ metadata.gz: e014ef47475c5c5b37a9d5bb071cd5484f6c05ca71386add02ffbbeae695806bafd908a371bd30a36dd34c536ab906e12ec5488edc9d3cdce39c2195f7b15134
7
+ data.tar.gz: d24371fcf29b98392b191b75927493dfb2386490fc4847bd2042f781eff7830cd274e324ff6b746b1c0a728d8bb4558c25e94c4645180bc46799caa481423f03
data/Readme.md CHANGED
@@ -9,10 +9,10 @@ Rails 3.1+ asset-pipeline gem to provide Vue.js
9
9
 
10
10
  ### Package Versions
11
11
 
12
- - vue v2.2.1
13
- - vue-router v2.2.1
14
- - vue-resource v1.2.1
15
- - vuex v2.2.1
12
+ - vue v2.3.2
13
+ - vue-router v2.5.2
14
+ - vue-resource v1.3.1
15
+ - vuex v2.3.0
16
16
 
17
17
  ### Setup
18
18
 
@@ -41,6 +41,18 @@ In `app/views/layouts/application.html.erb`, move this line from the head of the
41
41
 
42
42
  You may write your Vue.js code directly in your views using `<script>` tags, or in a separate Javascript file (recommended).
43
43
 
44
+ #### Full and minified assets versions
45
+
46
+ Starting from version '>= 2.3.2', by default, gem uses minified versions in production and full versions otherwise.
47
+
48
+ You can override this behavior by setting `Vue.development_mode` flag:
49
+ ```ruby
50
+ Vue.development_mode = true
51
+ ```
52
+ You can do it in e.g. `config/initializers/vue_config.rb`, your environment initializers.
53
+
54
+ Make sure to clean your assets cache (`rake tmp:cache:clear`) after changing state of the flag.
55
+
44
56
  ## Contributing
45
57
 
46
58
  Contributions are welcome, please follow [GitHub Flow](https://guides.github.com/introduction/flow/index.html)
@@ -1,6 +1,15 @@
1
1
  require "vuejs-rails/version"
2
2
 
3
3
  module Vue
4
+ mattr_accessor :development_mode
5
+
6
+ class << self
7
+ development_mode = defined?(::Rails) && ::Rails.env.development?
8
+ def full_or_minified(asset_name)
9
+ development_mode ? "dist/#{asset_name}.js": "dist/#{asset_name}.min.js"
10
+ end
11
+ end
12
+
4
13
  module Rails
5
14
  require "vuejs-rails/engine" if defined?(::Rails) and Gem::Requirement.new('>= 3.1').satisfied_by?(Gem::Version.new ::Rails.version)
6
15
  end
@@ -1,5 +1,5 @@
1
1
  module Vue
2
2
  module Rails
3
- VERSION = '2.2.1'
3
+ VERSION = '2.3.2'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-resource v1.2.1
2
+ * vue-resource v1.3.1
3
3
  * https://github.com/pagekit/vue-resource
4
4
  * Released under the MIT License.
5
5
  */
@@ -657,7 +657,15 @@ function Url(url, params) {
657
657
  options$$1 = merge({}, Url.options, self.$options, options$$1);
658
658
 
659
659
  Url.transforms.forEach(function (handler) {
660
- transform = factory(handler, transform, self.$vm);
660
+
661
+ if (isString(handler)) {
662
+ handler = Url.transform[handler];
663
+ }
664
+
665
+ if (isFunction(handler)) {
666
+ transform = factory(handler, transform, self.$vm);
667
+ }
668
+
661
669
  });
662
670
 
663
671
  return transform(options$$1);
@@ -677,7 +685,8 @@ Url.options = {
677
685
  * Url transforms.
678
686
  */
679
687
 
680
- Url.transforms = [template, query, root];
688
+ Url.transform = {template: template, query: query, root: root};
689
+ Url.transforms = ['template', 'query', 'root'];
681
690
 
682
691
  /**
683
692
  * Encodes a Url parameter string.
@@ -1012,8 +1021,6 @@ var header = function (request, next) {
1012
1021
  * XMLHttp client (Browser).
1013
1022
  */
1014
1023
 
1015
- var SUPPORTS_BLOB = typeof Blob !== 'undefined' && typeof FileReader !== 'undefined';
1016
-
1017
1024
  var xhrClient = function (request) {
1018
1025
  return new PromiseObj(function (resolve) {
1019
1026
 
@@ -1049,7 +1056,11 @@ var xhrClient = function (request) {
1049
1056
  xhr.timeout = request.timeout;
1050
1057
  }
1051
1058
 
1052
- if (request.credentials === true) {
1059
+ if (request.responseType && 'responseType' in xhr) {
1060
+ xhr.responseType = request.responseType;
1061
+ }
1062
+
1063
+ if (request.withCredentials || request.credentials) {
1053
1064
  xhr.withCredentials = true;
1054
1065
  }
1055
1066
 
@@ -1057,10 +1068,6 @@ var xhrClient = function (request) {
1057
1068
  request.headers.set('X-Requested-With', 'XMLHttpRequest');
1058
1069
  }
1059
1070
 
1060
- if ('responseType' in xhr && SUPPORTS_BLOB) {
1061
- xhr.responseType = 'blob';
1062
- }
1063
-
1064
1071
  request.headers.forEach(function (value, name) {
1065
1072
  xhr.setRequestHeader(name, value);
1066
1073
  });
@@ -1357,7 +1364,15 @@ function Http(options$$1) {
1357
1364
  defaults(options$$1 || {}, self.$options, Http.options);
1358
1365
 
1359
1366
  Http.interceptors.forEach(function (handler) {
1360
- client.use(handler);
1367
+
1368
+ if (isString(handler)) {
1369
+ handler = Http.interceptor[handler];
1370
+ }
1371
+
1372
+ if (isFunction(handler)) {
1373
+ client.use(handler);
1374
+ }
1375
+
1361
1376
  });
1362
1377
 
1363
1378
  return client(new Request(options$$1)).then(function (response) {
@@ -1385,7 +1400,8 @@ Http.headers = {
1385
1400
  custom: {}
1386
1401
  };
1387
1402
 
1388
- Http.interceptors = [before, method, body, jsonp, header, cors];
1403
+ Http.interceptor = {before: before, method: method, body: body, jsonp: jsonp, header: header, cors: cors};
1404
+ Http.interceptors = ['before', 'method', 'body', 'jsonp', 'header', 'cors'];
1389
1405
 
1390
1406
  ['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) {
1391
1407
 
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * vue-resource v1.3.1
3
+ * https://github.com/pagekit/vue-resource
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueResource=e()}(this,function(){"use strict";function t(t){this.state=D,this.value=void 0,this.deferred=[];var e=this;try{t(function(t){e.resolve(t)},function(t){e.reject(t)})}catch(t){e.reject(t)}}function e(t,e){t instanceof Promise?this.promise=t:this.promise=new Promise(t.bind(e)),this.context=e}function n(t){"undefined"!=typeof console&&z&&console.warn("[VueResource warn]: "+t)}function o(t){"undefined"!=typeof console&&console.error(t)}function r(t,e){return X(t,e)}function i(t){return t?t.replace(/^\s*|\s*$/g,""):""}function u(t){return t?t.toLowerCase():""}function s(t){return t?t.toUpperCase():""}function a(t){return"string"==typeof t}function c(t){return"function"==typeof t}function f(t){return null!==t&&"object"==typeof t}function p(t){return f(t)&&Object.getPrototypeOf(t)==Object.prototype}function h(t){return"undefined"!=typeof Blob&&t instanceof Blob}function d(t){return"undefined"!=typeof FormData&&t instanceof FormData}function l(t,n,o){var r=e.resolve(t);return arguments.length<2?r:r.then(n,o)}function m(t,e,n){return n=n||{},c(n)&&(n=n.call(e)),v(t.bind({$vm:e,$options:n}),t,{$options:n})}function y(t,e){var n,o;if(Y(t))for(n=0;n<t.length;n++)e.call(t[n],t[n],n);else if(f(t))for(o in t)G.call(t,o)&&e.call(t[o],t[o],o);return t}function v(t){return _.call(arguments,1).forEach(function(e){w(t,e,!0)}),t}function b(t){return _.call(arguments,1).forEach(function(e){for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t}function g(t){return _.call(arguments,1).forEach(function(e){w(t,e)}),t}function w(t,e,n){for(var o in e)n&&(p(e[o])||Y(e[o]))?(p(e[o])&&!p(t[o])&&(t[o]={}),Y(e[o])&&!Y(t[o])&&(t[o]=[]),w(t[o],e[o],n)):void 0!==e[o]&&(t[o]=e[o])}function T(t,e,n){var o=x(t),r=o.expand(e);return n&&n.push.apply(n,o.vars),r}function x(t){var e=["+","#",".","/",";","?","&"],n=[];return{vars:n,expand:function(o){return t.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(t,r,i){if(r){var u=null,s=[];if(-1!==e.indexOf(r.charAt(0))&&(u=r.charAt(0),r=r.substr(1)),r.split(/,/g).forEach(function(t){var e=/([^:\*]*)(?::(\d+)|(\*))?/.exec(t);s.push.apply(s,j(o,u,e[1],e[2]||e[3])),n.push(e[1])}),u&&"+"!==u){var a=",";return"?"===u?a="&":"#"!==u&&(a=u),(0!==s.length?u:"")+s.join(a)}return s.join(",")}return C(i)})}}}function j(t,e,n,o){var r=t[n],i=[];if(E(r)&&""!==r)if("string"==typeof r||"number"==typeof r||"boolean"==typeof r)r=r.toString(),o&&"*"!==o&&(r=r.substring(0,parseInt(o,10))),i.push(P(e,r,O(e)?n:null));else if("*"===o)Array.isArray(r)?r.filter(E).forEach(function(t){i.push(P(e,t,O(e)?n:null))}):Object.keys(r).forEach(function(t){E(r[t])&&i.push(P(e,r[t],t))});else{var u=[];Array.isArray(r)?r.filter(E).forEach(function(t){u.push(P(e,t))}):Object.keys(r).forEach(function(t){E(r[t])&&(u.push(encodeURIComponent(t)),u.push(P(e,r[t].toString())))}),O(e)?i.push(encodeURIComponent(n)+"="+u.join(",")):0!==u.length&&i.push(u.join(","))}else";"===e?i.push(encodeURIComponent(n)):""!==r||"&"!==e&&"?"!==e?""===r&&i.push(""):i.push(encodeURIComponent(n)+"=");return i}function E(t){return void 0!==t&&null!==t}function O(t){return";"===t||"&"===t||"?"===t}function P(t,e,n){return e="+"===t||"#"===t?C(e):encodeURIComponent(e),n?encodeURIComponent(n)+"="+e:e}function C(t){return t.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t)),t}).join("")}function $(t,e){var n,o=this||{},r=t;return a(t)&&(r={url:t,params:e}),r=v({},$.options,o.$options,r),$.transforms.forEach(function(t){a(t)&&(t=$.transform[t]),c(t)&&(n=U(t,n,o.$vm))}),n(r)}function U(t,e,n){return function(o){return t.call(n,o,e)}}function A(t,e,n){var o,r=Y(e),i=p(e);y(e,function(e,u){o=f(e)||Y(e),n&&(u=n+"["+(i||o?u:"")+"]"),!n&&r?t.add(e.name,e.value):o?A(t,e,u):t.add(u,e)})}function R(t){var e=t.match(/^\[|^\{(?!\{)/),n={"[":/]$/,"{":/}$/};return e&&n[e[0]].test(t)}function S(t,e){e((t.client||(K?ht:dt))(t))}function k(t,e){return Object.keys(t).reduce(function(t,n){return u(e)===u(n)?n:t},null)}function I(t){if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return i(t)}function q(t){return new e(function(e){var n=new FileReader;n.readAsText(t),n.onload=function(){e(n.result)}})}function H(t){return 0===t.type.indexOf("text")||-1!==t.type.indexOf("json")}function L(t){var n=this||{},r=lt(n.$vm);return b(t||{},n.$options,L.options),L.interceptors.forEach(function(t){a(t)&&(t=L.interceptor[t]),c(t)&&r.use(t)}),r(new vt(t)).then(function(t){return t.ok?t:e.reject(t)},function(t){return t instanceof Error&&o(t),e.reject(t)})}function B(t,e,n,o){var r=this||{},i={};return n=Z({},B.actions,n),y(n,function(n,u){n=v({url:t,params:Z({},e)},o,n),i[u]=function(){return(r.$http||L)(M(n,arguments))}}),i}function M(t,e){var n,o=Z({},t),r={};switch(e.length){case 2:r=e[0],n=e[1];break;case 1:/^(POST|PUT|PATCH)$/i.test(o.method)?n=e[0]:r=e[0];break;case 0:break;default:throw"Expected up to 2 arguments [params, body], got "+e.length+" arguments"}return o.body=n,o.params=Z({},o.params,r),o}function N(t){N.installed||(Q(t),t.url=$,t.http=L,t.resource=B,t.Promise=e,Object.defineProperties(t.prototype,{$url:{get:function(){return m(t.url,this,this.$options.url)}},$http:{get:function(){return m(t.http,this,this.$options.http)}},$resource:{get:function(){return t.resource.bind(this)}},$promise:{get:function(){var e=this;return function(n){return new t.Promise(n,e)}}}}))}var D=2;t.reject=function(e){return new t(function(t,n){n(e)})},t.resolve=function(e){return new t(function(t,n){t(e)})},t.all=function(e){return new t(function(n,o){var r=0,i=[];0===e.length&&n(i);for(var u=0;u<e.length;u+=1)t.resolve(e[u]).then(function(t){return function(o){i[t]=o,(r+=1)===e.length&&n(i)}}(u),o)})},t.race=function(e){return new t(function(n,o){for(var r=0;r<e.length;r+=1)t.resolve(e[r]).then(n,o)})};var J=t.prototype;J.resolve=function(t){var e=this;if(e.state===D){if(t===e)throw new TypeError("Promise settled with itself.");var n=!1;try{var o=t&&t.then;if(null!==t&&"object"==typeof t&&"function"==typeof o)return void o.call(t,function(t){n||e.resolve(t),n=!0},function(t){n||e.reject(t),n=!0})}catch(t){return void(n||e.reject(t))}e.state=0,e.value=t,e.notify()}},J.reject=function(t){var e=this;if(e.state===D){if(t===e)throw new TypeError("Promise settled with itself.");e.state=1,e.value=t,e.notify()}},J.notify=function(){var t=this;r(function(){if(t.state!==D)for(;t.deferred.length;){var e=t.deferred.shift(),n=e[0],o=e[1],r=e[2],i=e[3];try{0===t.state?r("function"==typeof n?n.call(void 0,t.value):t.value):1===t.state&&("function"==typeof o?r(o.call(void 0,t.value)):i(t.value))}catch(t){i(t)}}})},J.then=function(e,n){var o=this;return new t(function(t,r){o.deferred.push([e,n,t,r]),o.notify()})},J.catch=function(t){return this.then(void 0,t)},"undefined"==typeof Promise&&(window.Promise=t),e.all=function(t,n){return new e(Promise.all(t),n)},e.resolve=function(t,n){return new e(Promise.resolve(t),n)},e.reject=function(t,n){return new e(Promise.reject(t),n)},e.race=function(t,n){return new e(Promise.race(t),n)};var W=e.prototype;W.bind=function(t){return this.context=t,this},W.then=function(t,n){return t&&t.bind&&this.context&&(t=t.bind(this.context)),n&&n.bind&&this.context&&(n=n.bind(this.context)),new e(this.promise.then(t,n),this.context)},W.catch=function(t){return t&&t.bind&&this.context&&(t=t.bind(this.context)),new e(this.promise.catch(t),this.context)},W.finally=function(t){return this.then(function(e){return t.call(this),e},function(e){return t.call(this),Promise.reject(e)})};var X,F={},G=F.hasOwnProperty,V=[],_=V.slice,z=!1,K="undefined"!=typeof window,Q=function(t){var e=t.config,n=t.nextTick;X=n,z=e.debug||!e.silent},Y=Array.isArray,Z=Object.assign||g,tt=function(t,e){var n=e(t);return a(t.root)&&!n.match(/^(https?:)?\//)&&(n=t.root+"/"+n),n},et=function(t,e){var n=Object.keys($.options.params),o={},r=e(t);return y(t.params,function(t,e){-1===n.indexOf(e)&&(o[e]=t)}),o=$.params(o),o&&(r+=(-1==r.indexOf("?")?"?":"&")+o),r},nt=function(t){var e=[],n=T(t.url,t.params,e);return e.forEach(function(e){delete t.params[e]}),n};$.options={url:"",root:null,params:{}},$.transform={template:nt,query:et,root:tt},$.transforms=["template","query","root"],$.params=function(t){var e=[],n=encodeURIComponent;return e.add=function(t,e){c(e)&&(e=e()),null===e&&(e=""),this.push(n(t)+"="+n(e))},A(e,t),e.join("&").replace(/%20/g,"+")},$.parse=function(t){var e=document.createElement("a");return document.documentMode&&(e.href=t,t=e.href),e.href=t,{href:e.href,protocol:e.protocol?e.protocol.replace(/:$/,""):"",port:e.port,host:e.host,hostname:e.hostname,pathname:"/"===e.pathname.charAt(0)?e.pathname:"/"+e.pathname,search:e.search?e.search.replace(/^\?/,""):"",hash:e.hash?e.hash.replace(/^#/,""):""}};var ot=function(t){return new e(function(e){var n=new XDomainRequest,o=function(o){var r=o.type,i=0;"load"===r?i=200:"error"===r&&(i=500),e(t.respondWith(n.responseText,{status:i}))};t.abort=function(){return n.abort()},n.open(t.method,t.getUrl()),t.timeout&&(n.timeout=t.timeout),n.onload=o,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){},n.send(t.getBody())})},rt=K&&"withCredentials"in new XMLHttpRequest,it=function(t,e){if(K){var n=$.parse(location.href),o=$.parse(t.getUrl());o.protocol===n.protocol&&o.host===n.host||(t.crossOrigin=!0,t.emulateHTTP=!1,rt||(t.client=ot))}e()},ut=function(t,e){d(t.body)?t.headers.delete("Content-Type"):(f(t.body)||Y(t.body))&&(t.emulateJSON?(t.body=$.params(t.body),t.headers.set("Content-Type","application/x-www-form-urlencoded")):t.body=JSON.stringify(t.body)),e(function(t){return Object.defineProperty(t,"data",{get:function(){return this.body},set:function(t){this.body=t}}),t.bodyText?l(t.text(),function(e){if(0===(t.headers.get("Content-Type")||"").indexOf("application/json")||R(e))try{t.body=JSON.parse(e)}catch(e){t.body=null}else t.body=e;return t}):t})},st=function(t){return new e(function(e){var n,o,r=t.jsonp||"callback",i=t.jsonpCallback||"_jsonp"+Math.random().toString(36).substr(2),u=null;n=function(n){var r=n.type,s=0;"load"===r&&null!==u?s=200:"error"===r&&(s=500),s&&window[i]&&(delete window[i],document.body.removeChild(o)),e(t.respondWith(u,{status:s}))},window[i]=function(t){u=JSON.stringify(t)},t.abort=function(){n({type:"abort"})},t.params[r]=i,t.timeout&&setTimeout(t.abort,t.timeout),o=document.createElement("script"),o.src=t.getUrl(),o.type="text/javascript",o.async=!0,o.onload=n,o.onerror=n,document.body.appendChild(o)})},at=function(t,e){"JSONP"==t.method&&(t.client=st),e()},ct=function(t,e){c(t.before)&&t.before.call(this,t),e()},ft=function(t,e){t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers.set("X-HTTP-Method-Override",t.method),t.method="POST"),e()},pt=function(t,e){y(Z({},L.headers.common,t.crossOrigin?{}:L.headers.custom,L.headers[u(t.method)]),function(e,n){t.headers.has(n)||t.headers.set(n,e)}),e()},ht=function(t){return new e(function(e){var n=new XMLHttpRequest,o=function(o){var r=t.respondWith("response"in n?n.response:n.responseText,{status:1223===n.status?204:n.status,statusText:1223===n.status?"No Content":i(n.statusText)});y(i(n.getAllResponseHeaders()).split("\n"),function(t){r.headers.append(t.slice(0,t.indexOf(":")),t.slice(t.indexOf(":")+1))}),e(r)};t.abort=function(){return n.abort()},t.progress&&("GET"===t.method?n.addEventListener("progress",t.progress):/^(POST|PUT)$/i.test(t.method)&&n.upload.addEventListener("progress",t.progress)),n.open(t.method,t.getUrl(),!0),t.timeout&&(n.timeout=t.timeout),t.responseType&&"responseType"in n&&(n.responseType=t.responseType),(t.withCredentials||t.credentials)&&(n.withCredentials=!0),t.crossOrigin||t.headers.set("X-Requested-With","XMLHttpRequest"),t.headers.forEach(function(t,e){n.setRequestHeader(e,t)}),n.onload=o,n.onabort=o,n.onerror=o,n.ontimeout=o,n.send(t.getBody())})},dt=function(t){var n=require("got");return new e(function(e){var o,r=t.getUrl(),u=t.getBody(),s=t.method,a={};t.headers.forEach(function(t,e){a[e]=t}),n(r,{body:u,method:s,headers:a}).then(o=function(n){var o=t.respondWith(n.body,{status:n.statusCode,statusText:i(n.statusMessage)});y(n.headers,function(t,e){o.headers.set(e,t)}),e(o)},function(t){return o(t.response)})})},lt=function(t){function o(o){return new e(function(e){function s(){r=i.pop(),c(r)?r.call(t,o,a):(n("Invalid interceptor of type "+typeof r+", must be a function"),a())}function a(n){if(c(n))u.unshift(n);else if(f(n))return u.forEach(function(e){n=l(n,function(n){return e.call(t,n)||n})}),void l(n,e);s()}s()},t)}var r,i=[S],u=[];return f(t)||(t=null),o.use=function(t){i.push(t)},o},mt=function(t){var e=this;this.map={},y(t,function(t,n){return e.append(n,t)})};mt.prototype.has=function(t){return null!==k(this.map,t)},mt.prototype.get=function(t){var e=this.map[k(this.map,t)];return e?e.join():null},mt.prototype.getAll=function(t){return this.map[k(this.map,t)]||[]},mt.prototype.set=function(t,e){this.map[I(k(this.map,t)||t)]=[i(e)]},mt.prototype.append=function(t,e){var n=this.map[k(this.map,t)];n?n.push(i(e)):this.set(t,e)},mt.prototype.delete=function(t){delete this.map[k(this.map,t)]},mt.prototype.deleteAll=function(){this.map={}},mt.prototype.forEach=function(t,e){var n=this;y(this.map,function(o,r){y(o,function(o){return t.call(e,o,r,n)})})};var yt=function(t,e){var n=e.url,o=e.headers,r=e.status,i=e.statusText;this.url=n,this.ok=r>=200&&r<300,this.status=r||0,this.statusText=i||"",this.headers=new mt(o),this.body=t,a(t)?this.bodyText=t:h(t)&&(this.bodyBlob=t,H(t)&&(this.bodyText=q(t)))};yt.prototype.blob=function(){return l(this.bodyBlob)},yt.prototype.text=function(){return l(this.bodyText)},yt.prototype.json=function(){return l(this.text(),function(t){return JSON.parse(t)})};var vt=function(t){this.body=null,this.params={},Z(this,t,{method:s(t.method||"GET")}),this.headers instanceof mt||(this.headers=new mt(this.headers))};vt.prototype.getUrl=function(){return $(this)},vt.prototype.getBody=function(){return this.body},vt.prototype.respondWith=function(t,e){return new yt(t,Z(e||{},{url:this.getUrl()}))};var bt={Accept:"application/json, text/plain, */*"},gt={"Content-Type":"application/json;charset=utf-8"};return L.options={},L.headers={put:gt,post:gt,patch:gt,delete:gt,common:bt,custom:{}},L.interceptor={before:ct,method:ft,body:ut,jsonp:at,header:pt,cors:it},L.interceptors=["before","method","body","jsonp","header","cors"],["get","delete","head","jsonp"].forEach(function(t){L[t]=function(e,n){return this(Z(n||{},{url:e,method:t}))}}),["post","put","patch"].forEach(function(t){L[t]=function(e,n,o){return this(Z(o||{},{url:e,method:t,body:n}))}}),B.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},update:{method:"PUT"},remove:{method:"DELETE"},delete:{method:"DELETE"}},"undefined"!=typeof window&&window.Vue&&window.Vue.use(N),N});
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue-router v2.2.1
2
+ * vue-router v2.5.2
3
3
  * (c) 2017 Evan You
4
4
  * @license MIT
5
5
  */
@@ -18,7 +18,7 @@ function assert (condition, message) {
18
18
  }
19
19
 
20
20
  function warn (condition, message) {
21
- if (!condition) {
21
+ if ("development" !== 'production' && !condition) {
22
22
  typeof console !== 'undefined' && console.warn(("[vue-router] " + message));
23
23
  }
24
24
  }
@@ -32,7 +32,7 @@ var View = {
32
32
  default: 'default'
33
33
  }
34
34
  },
35
- render: function render (h, ref) {
35
+ render: function render (_, ref) {
36
36
  var props = ref.props;
37
37
  var children = ref.children;
38
38
  var parent = ref.parent;
@@ -40,6 +40,9 @@ var View = {
40
40
 
41
41
  data.routerView = true;
42
42
 
43
+ // directly use parent context's createElement() function
44
+ // so that components rendered by router-view can resolve named slots
45
+ var h = parent.$createElement;
43
46
  var name = props.name;
44
47
  var route = parent.$route;
45
48
  var cache = parent._routerViewCache || (parent._routerViewCache = {});
@@ -73,18 +76,19 @@ var View = {
73
76
 
74
77
  var component = cache[name] = matched.components[name];
75
78
 
76
- // inject instance registration hooks
77
- var hooks = data.hook || (data.hook = {});
78
- hooks.init = function (vnode) {
79
- matched.instances[name] = vnode.child;
80
- };
81
- hooks.prepatch = function (oldVnode, vnode) {
82
- matched.instances[name] = vnode.child;
83
- };
84
- hooks.destroy = function (vnode) {
85
- if (matched.instances[name] === vnode.child) {
86
- matched.instances[name] = undefined;
79
+ // attach instance registration hook
80
+ // this will be called in the instance's injected lifecycle hooks
81
+ data.registerRouteInstance = function (vm, val) {
82
+ // val could be undefined for unregistration
83
+ if (matched.instances[name] !== vm) {
84
+ matched.instances[name] = val;
87
85
  }
86
+ }
87
+
88
+ // also regiseter instance in prepatch hook
89
+ // in case the same component instance is reused across different routes
90
+ ;(data.hook || (data.hook = {})).prepatch = function (_, vnode) {
91
+ matched.instances[name] = vnode.componentInstance;
88
92
  };
89
93
 
90
94
  // resolve props
@@ -105,7 +109,13 @@ function resolveProps (route, config) {
105
109
  case 'boolean':
106
110
  return config ? route.params : undefined
107
111
  default:
108
- warn(false, ("props in \"" + (route.path) + "\" is a " + (typeof config) + ", expecting an object, function or boolean."));
112
+ {
113
+ warn(
114
+ false,
115
+ "props in \"" + (route.path) + "\" is a " + (typeof config) + ", " +
116
+ "expecting an object, function or boolean."
117
+ );
118
+ }
109
119
  }
110
120
  }
111
121
 
@@ -115,7 +125,7 @@ var encodeReserveRE = /[!'()*]/g;
115
125
  var encodeReserveReplacer = function (c) { return '%' + c.charCodeAt(0).toString(16); };
116
126
  var commaRE = /%2C/g;
117
127
 
118
- // fixed encodeURIComponent which is more comformant to RFC3986:
128
+ // fixed encodeURIComponent which is more conformant to RFC3986:
119
129
  // - escapes [!'()*]
120
130
  // - preserve commas
121
131
  var encode = function (str) { return encodeURIComponent(str)
@@ -126,25 +136,24 @@ var decode = decodeURIComponent;
126
136
 
127
137
  function resolveQuery (
128
138
  query,
129
- extraQuery
139
+ extraQuery,
140
+ _parseQuery
130
141
  ) {
131
142
  if ( extraQuery === void 0 ) extraQuery = {};
132
143
 
133
- if (query) {
134
- var parsedQuery;
135
- try {
136
- parsedQuery = parseQuery(query);
137
- } catch (e) {
138
- "development" !== 'production' && warn(false, e.message);
139
- parsedQuery = {};
140
- }
141
- for (var key in extraQuery) {
142
- parsedQuery[key] = extraQuery[key];
143
- }
144
- return parsedQuery
145
- } else {
146
- return extraQuery
144
+ var parse = _parseQuery || parseQuery;
145
+ var parsedQuery;
146
+ try {
147
+ parsedQuery = parse(query || '');
148
+ } catch (e) {
149
+ "development" !== 'production' && warn(false, e.message);
150
+ parsedQuery = {};
147
151
  }
152
+ for (var key in extraQuery) {
153
+ var val = extraQuery[key];
154
+ parsedQuery[key] = Array.isArray(val) ? val.slice() : val;
155
+ }
156
+ return parsedQuery
148
157
  }
149
158
 
150
159
  function parseQuery (query) {
@@ -209,13 +218,16 @@ function stringifyQuery (obj) {
209
218
 
210
219
  /* */
211
220
 
221
+
212
222
  var trailingSlashRE = /\/?$/;
213
223
 
214
224
  function createRoute (
215
225
  record,
216
226
  location,
217
- redirectedFrom
227
+ redirectedFrom,
228
+ router
218
229
  ) {
230
+ var stringifyQuery$$1 = router && router.options.stringifyQuery;
219
231
  var route = {
220
232
  name: location.name || (record && record.name),
221
233
  meta: (record && record.meta) || {},
@@ -223,11 +235,11 @@ function createRoute (
223
235
  hash: location.hash || '',
224
236
  query: location.query || {},
225
237
  params: location.params || {},
226
- fullPath: getFullPath(location),
238
+ fullPath: getFullPath(location, stringifyQuery$$1),
227
239
  matched: record ? formatMatch(record) : []
228
240
  };
229
241
  if (redirectedFrom) {
230
- route.redirectedFrom = getFullPath(redirectedFrom);
242
+ route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery$$1);
231
243
  }
232
244
  return Object.freeze(route)
233
245
  }
@@ -246,12 +258,16 @@ function formatMatch (record) {
246
258
  return res
247
259
  }
248
260
 
249
- function getFullPath (ref) {
261
+ function getFullPath (
262
+ ref,
263
+ _stringifyQuery
264
+ ) {
250
265
  var path = ref.path;
251
266
  var query = ref.query; if ( query === void 0 ) query = {};
252
267
  var hash = ref.hash; if ( hash === void 0 ) hash = '';
253
268
 
254
- return (path || '/') + stringifyQuery(query) + hash
269
+ var stringify = _stringifyQuery || stringifyQuery;
270
+ return (path || '/') + stringify(query) + hash
255
271
  }
256
272
 
257
273
  function isSameRoute (a, b) {
@@ -329,6 +345,7 @@ var Link = {
329
345
  append: Boolean,
330
346
  replace: Boolean,
331
347
  activeClass: String,
348
+ exactActiveClass: String,
332
349
  event: {
333
350
  type: eventTypes,
334
351
  default: 'click'
@@ -343,11 +360,30 @@ var Link = {
343
360
  var location = ref.location;
344
361
  var route = ref.route;
345
362
  var href = ref.href;
363
+
346
364
  var classes = {};
347
- var activeClass = this.activeClass || router.options.linkActiveClass || 'router-link-active';
348
- var compareTarget = location.path ? createRoute(null, location) : route;
365
+ var globalActiveClass = router.options.linkActiveClass;
366
+ var globalExactActiveClass = router.options.linkExactActiveClass;
367
+ // Support global empty active class
368
+ var activeClassFallback = globalActiveClass == null
369
+ ? 'router-link-active'
370
+ : globalActiveClass;
371
+ var exactActiveClassFallback = globalExactActiveClass == null
372
+ ? 'router-link-exact-active'
373
+ : globalExactActiveClass;
374
+ var activeClass = this.activeClass == null
375
+ ? activeClassFallback
376
+ : this.activeClass;
377
+ var exactActiveClass = this.exactActiveClass == null
378
+ ? exactActiveClassFallback
379
+ : this.exactActiveClass;
380
+ var compareTarget = location.path
381
+ ? createRoute(null, location, null, router)
382
+ : route;
383
+
384
+ classes[exactActiveClass] = isSameRoute(current, compareTarget);
349
385
  classes[activeClass] = this.exact
350
- ? isSameRoute(current, compareTarget)
386
+ ? classes[exactActiveClass]
351
387
  : isIncludedRoute(current, compareTarget);
352
388
 
353
389
  var handler = function (e) {
@@ -403,8 +439,8 @@ function guardEvent (e) {
403
439
  // don't redirect on right click
404
440
  if (e.button !== undefined && e.button !== 0) { return }
405
441
  // don't redirect if `target="_blank"`
406
- if (e.target && e.target.getAttribute) {
407
- var target = e.target.getAttribute('target');
442
+ if (e.currentTarget && e.currentTarget.getAttribute) {
443
+ var target = e.currentTarget.getAttribute('target');
408
444
  if (/\b_blank\b/i.test(target)) { return }
409
445
  }
410
446
  // this may be a Weex event which doesn't have this method
@@ -445,13 +481,26 @@ function install (Vue) {
445
481
  get: function get () { return this.$root._route }
446
482
  });
447
483
 
484
+ var isDef = function (v) { return v !== undefined; };
485
+
486
+ var registerInstance = function (vm, callVal) {
487
+ var i = vm.$options._parentVnode;
488
+ if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {
489
+ i(vm, callVal);
490
+ }
491
+ };
492
+
448
493
  Vue.mixin({
449
494
  beforeCreate: function beforeCreate () {
450
- if (this.$options.router) {
495
+ if (isDef(this.$options.router)) {
451
496
  this._router = this.$options.router;
452
497
  this._router.init(this);
453
498
  Vue.util.defineReactive(this, '_route', this._router.history.current);
454
499
  }
500
+ registerInstance(this, this);
501
+ },
502
+ destroyed: function destroyed () {
503
+ registerInstance(this);
455
504
  }
456
505
  });
457
506
 
@@ -474,11 +523,12 @@ function resolvePath (
474
523
  base,
475
524
  append
476
525
  ) {
477
- if (relative.charAt(0) === '/') {
526
+ var firstChar = relative.charAt(0);
527
+ if (firstChar === '/') {
478
528
  return relative
479
529
  }
480
530
 
481
- if (relative.charAt(0) === '?' || relative.charAt(0) === '#') {
531
+ if (firstChar === '?' || firstChar === '#') {
482
532
  return base + relative
483
533
  }
484
534
 
@@ -495,11 +545,9 @@ function resolvePath (
495
545
  var segments = relative.replace(/^\//, '').split('/');
496
546
  for (var i = 0; i < segments.length; i++) {
497
547
  var segment = segments[i];
498
- if (segment === '.') {
499
- continue
500
- } else if (segment === '..') {
548
+ if (segment === '..') {
501
549
  stack.pop();
502
- } else {
550
+ } else if (segment !== '.') {
503
551
  stack.push(segment);
504
552
  }
505
553
  }
@@ -539,127 +587,6 @@ function cleanPath (path) {
539
587
  return path.replace(/\/\//g, '/')
540
588
  }
541
589
 
542
- /* */
543
-
544
- function createRouteMap (
545
- routes,
546
- oldPathMap,
547
- oldNameMap
548
- ) {
549
- var pathMap = oldPathMap || Object.create(null);
550
- var nameMap = oldNameMap || Object.create(null);
551
-
552
- routes.forEach(function (route) {
553
- addRouteRecord(pathMap, nameMap, route);
554
- });
555
-
556
- return {
557
- pathMap: pathMap,
558
- nameMap: nameMap
559
- }
560
- }
561
-
562
- function addRouteRecord (
563
- pathMap,
564
- nameMap,
565
- route,
566
- parent,
567
- matchAs
568
- ) {
569
- var path = route.path;
570
- var name = route.name;
571
- {
572
- assert(path != null, "\"path\" is required in a route configuration.");
573
- assert(
574
- typeof route.component !== 'string',
575
- "route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
576
- "string id. Use an actual component instead."
577
- );
578
- }
579
-
580
- var record = {
581
- path: normalizePath(path, parent),
582
- components: route.components || { default: route.component },
583
- instances: {},
584
- name: name,
585
- parent: parent,
586
- matchAs: matchAs,
587
- redirect: route.redirect,
588
- beforeEnter: route.beforeEnter,
589
- meta: route.meta || {},
590
- props: route.props == null
591
- ? {}
592
- : route.components
593
- ? route.props
594
- : { default: route.props }
595
- };
596
-
597
- if (route.children) {
598
- // Warn if route is named and has a default child route.
599
- // If users navigate to this route by name, the default child will
600
- // not be rendered (GH Issue #629)
601
- {
602
- if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
603
- warn(
604
- false,
605
- "Named Route '" + (route.name) + "' has a default child route. " +
606
- "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
607
- "the default child route will not be rendered. Remove the name from " +
608
- "this route and use the name of the default child route for named " +
609
- "links instead."
610
- );
611
- }
612
- }
613
- route.children.forEach(function (child) {
614
- var childMatchAs = matchAs
615
- ? cleanPath((matchAs + "/" + (child.path)))
616
- : undefined;
617
- addRouteRecord(pathMap, nameMap, child, record, childMatchAs);
618
- });
619
- }
620
-
621
- if (route.alias !== undefined) {
622
- if (Array.isArray(route.alias)) {
623
- route.alias.forEach(function (alias) {
624
- var aliasRoute = {
625
- path: alias,
626
- children: route.children
627
- };
628
- addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
629
- });
630
- } else {
631
- var aliasRoute = {
632
- path: route.alias,
633
- children: route.children
634
- };
635
- addRouteRecord(pathMap, nameMap, aliasRoute, parent, record.path);
636
- }
637
- }
638
-
639
- if (!pathMap[record.path]) {
640
- pathMap[record.path] = record;
641
- }
642
-
643
- if (name) {
644
- if (!nameMap[name]) {
645
- nameMap[name] = record;
646
- } else if ("development" !== 'production' && !matchAs) {
647
- warn(
648
- false,
649
- "Duplicate named routes definition: " +
650
- "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
651
- );
652
- }
653
- }
654
- }
655
-
656
- function normalizePath (path, parent) {
657
- path = path.replace(/\/$/, '');
658
- if (path[0] === '/') { return path }
659
- if (parent == null) { return path }
660
- return cleanPath(((parent.path) + "/" + path))
661
- }
662
-
663
590
  var index$1 = Array.isArray || function (arr) {
664
591
  return Object.prototype.toString.call(arr) == '[object Array]';
665
592
  };
@@ -1098,24 +1025,6 @@ index.tokensToRegExp = tokensToRegExp_1;
1098
1025
 
1099
1026
  /* */
1100
1027
 
1101
- var regexpCache = Object.create(null);
1102
-
1103
- function getRouteRegex (path) {
1104
- var hit = regexpCache[path];
1105
- var keys, regexp;
1106
-
1107
- if (hit) {
1108
- keys = hit.keys;
1109
- regexp = hit.regexp;
1110
- } else {
1111
- keys = [];
1112
- regexp = index(path, keys);
1113
- regexpCache[path] = { keys: keys, regexp: regexp };
1114
- }
1115
-
1116
- return { keys: keys, regexp: regexp }
1117
- }
1118
-
1119
1028
  var regexpCompileCache = Object.create(null);
1120
1029
 
1121
1030
  function fillParams (
@@ -1138,10 +1047,162 @@ function fillParams (
1138
1047
 
1139
1048
  /* */
1140
1049
 
1050
+ function createRouteMap (
1051
+ routes,
1052
+ oldPathList,
1053
+ oldPathMap,
1054
+ oldNameMap
1055
+ ) {
1056
+ // the path list is used to control path matching priority
1057
+ var pathList = oldPathList || [];
1058
+ var pathMap = oldPathMap || Object.create(null);
1059
+ var nameMap = oldNameMap || Object.create(null);
1060
+
1061
+ routes.forEach(function (route) {
1062
+ addRouteRecord(pathList, pathMap, nameMap, route);
1063
+ });
1064
+
1065
+ // ensure wildcard routes are always at the end
1066
+ for (var i = 0, l = pathList.length; i < l; i++) {
1067
+ if (pathList[i] === '*') {
1068
+ pathList.push(pathList.splice(i, 1)[0]);
1069
+ l--;
1070
+ i--;
1071
+ }
1072
+ }
1073
+
1074
+ return {
1075
+ pathList: pathList,
1076
+ pathMap: pathMap,
1077
+ nameMap: nameMap
1078
+ }
1079
+ }
1080
+
1081
+ function addRouteRecord (
1082
+ pathList,
1083
+ pathMap,
1084
+ nameMap,
1085
+ route,
1086
+ parent,
1087
+ matchAs
1088
+ ) {
1089
+ var path = route.path;
1090
+ var name = route.name;
1091
+ {
1092
+ assert(path != null, "\"path\" is required in a route configuration.");
1093
+ assert(
1094
+ typeof route.component !== 'string',
1095
+ "route config \"component\" for path: " + (String(path || name)) + " cannot be a " +
1096
+ "string id. Use an actual component instead."
1097
+ );
1098
+ }
1099
+
1100
+ var normalizedPath = normalizePath(path, parent);
1101
+ var record = {
1102
+ path: normalizedPath,
1103
+ regex: compileRouteRegex(normalizedPath),
1104
+ components: route.components || { default: route.component },
1105
+ instances: {},
1106
+ name: name,
1107
+ parent: parent,
1108
+ matchAs: matchAs,
1109
+ redirect: route.redirect,
1110
+ beforeEnter: route.beforeEnter,
1111
+ meta: route.meta || {},
1112
+ props: route.props == null
1113
+ ? {}
1114
+ : route.components
1115
+ ? route.props
1116
+ : { default: route.props }
1117
+ };
1118
+
1119
+ if (route.children) {
1120
+ // Warn if route is named and has a default child route.
1121
+ // If users navigate to this route by name, the default child will
1122
+ // not be rendered (GH Issue #629)
1123
+ {
1124
+ if (route.name && route.children.some(function (child) { return /^\/?$/.test(child.path); })) {
1125
+ warn(
1126
+ false,
1127
+ "Named Route '" + (route.name) + "' has a default child route. " +
1128
+ "When navigating to this named route (:to=\"{name: '" + (route.name) + "'\"), " +
1129
+ "the default child route will not be rendered. Remove the name from " +
1130
+ "this route and use the name of the default child route for named " +
1131
+ "links instead."
1132
+ );
1133
+ }
1134
+ }
1135
+ route.children.forEach(function (child) {
1136
+ var childMatchAs = matchAs
1137
+ ? cleanPath((matchAs + "/" + (child.path)))
1138
+ : undefined;
1139
+ addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs);
1140
+ });
1141
+ }
1142
+
1143
+ if (route.alias !== undefined) {
1144
+ if (Array.isArray(route.alias)) {
1145
+ route.alias.forEach(function (alias) {
1146
+ var aliasRoute = {
1147
+ path: alias,
1148
+ children: route.children
1149
+ };
1150
+ addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path);
1151
+ });
1152
+ } else {
1153
+ var aliasRoute = {
1154
+ path: route.alias,
1155
+ children: route.children
1156
+ };
1157
+ addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path);
1158
+ }
1159
+ }
1160
+
1161
+ if (!pathMap[record.path]) {
1162
+ pathList.push(record.path);
1163
+ pathMap[record.path] = record;
1164
+ }
1165
+
1166
+ if (name) {
1167
+ if (!nameMap[name]) {
1168
+ nameMap[name] = record;
1169
+ } else if ("development" !== 'production' && !matchAs) {
1170
+ warn(
1171
+ false,
1172
+ "Duplicate named routes definition: " +
1173
+ "{ name: \"" + name + "\", path: \"" + (record.path) + "\" }"
1174
+ );
1175
+ }
1176
+ }
1177
+ }
1178
+
1179
+ function compileRouteRegex (path) {
1180
+ var regex = index(path);
1181
+ {
1182
+ var keys = {};
1183
+ regex.keys.forEach(function (key) {
1184
+ warn(!keys[key.name], ("Duplicate param keys in route with path: \"" + path + "\""));
1185
+ keys[key.name] = true;
1186
+ });
1187
+ }
1188
+ return regex
1189
+ }
1190
+
1191
+ function normalizePath (path, parent) {
1192
+ path = path.replace(/\/$/, '');
1193
+ if (path[0] === '/') { return path }
1194
+ if (parent == null) { return path }
1195
+ return cleanPath(((parent.path) + "/" + path))
1196
+ }
1197
+
1198
+ /* */
1199
+
1200
+
1141
1201
  function normalizeLocation (
1142
1202
  raw,
1143
1203
  current,
1144
- append
1204
+ append,
1205
+ router
1145
1206
  ) {
1146
1207
  var next = typeof raw === 'string' ? { path: raw } : raw;
1147
1208
  // named target
@@ -1170,8 +1231,14 @@ function normalizeLocation (
1170
1231
  var basePath = (current && current.path) || '/';
1171
1232
  var path = parsedPath.path
1172
1233
  ? resolvePath(parsedPath.path, basePath, append || next.append)
1173
- : (current && current.path) || '/';
1174
- var query = resolveQuery(parsedPath.query, next.query);
1234
+ : basePath;
1235
+
1236
+ var query = resolveQuery(
1237
+ parsedPath.query,
1238
+ next.query,
1239
+ router && router.options.parseQuery
1240
+ );
1241
+
1175
1242
  var hash = next.hash || parsedPath.hash;
1176
1243
  if (hash && hash.charAt(0) !== '#') {
1177
1244
  hash = "#" + hash;
@@ -1194,13 +1261,18 @@ function assign (a, b) {
1194
1261
 
1195
1262
  /* */
1196
1263
 
1197
- function createMatcher (routes) {
1264
+
1265
+ function createMatcher (
1266
+ routes,
1267
+ router
1268
+ ) {
1198
1269
  var ref = createRouteMap(routes);
1270
+ var pathList = ref.pathList;
1199
1271
  var pathMap = ref.pathMap;
1200
1272
  var nameMap = ref.nameMap;
1201
1273
 
1202
1274
  function addRoutes (routes) {
1203
- createRouteMap(routes, pathMap, nameMap);
1275
+ createRouteMap(routes, pathList, pathMap, nameMap);
1204
1276
  }
1205
1277
 
1206
1278
  function match (
@@ -1208,7 +1280,7 @@ function createMatcher (routes) {
1208
1280
  currentRoute,
1209
1281
  redirectedFrom
1210
1282
  ) {
1211
- var location = normalizeLocation(raw, currentRoute);
1283
+ var location = normalizeLocation(raw, currentRoute, false, router);
1212
1284
  var name = location.name;
1213
1285
 
1214
1286
  if (name) {
@@ -1216,7 +1288,7 @@ function createMatcher (routes) {
1216
1288
  {
1217
1289
  warn(record, ("Route with name '" + name + "' does not exist"));
1218
1290
  }
1219
- var paramNames = getRouteRegex(record.path).keys
1291
+ var paramNames = record.regex.keys
1220
1292
  .filter(function (key) { return !key.optional; })
1221
1293
  .map(function (key) { return key.name; });
1222
1294
 
@@ -1238,9 +1310,11 @@ function createMatcher (routes) {
1238
1310
  }
1239
1311
  } else if (location.path) {
1240
1312
  location.params = {};
1241
- for (var path in pathMap) {
1242
- if (matchRoute(path, location.params, location.path)) {
1243
- return _createRoute(pathMap[path], location, redirectedFrom)
1313
+ for (var i = 0; i < pathList.length; i++) {
1314
+ var path = pathList[i];
1315
+ var record$1 = pathMap[path];
1316
+ if (matchRoute(record$1.regex, location.path, location.params)) {
1317
+ return _createRoute(record$1, location, redirectedFrom)
1244
1318
  }
1245
1319
  }
1246
1320
  }
@@ -1254,7 +1328,7 @@ function createMatcher (routes) {
1254
1328
  ) {
1255
1329
  var originalRedirect = record.redirect;
1256
1330
  var redirect = typeof originalRedirect === 'function'
1257
- ? originalRedirect(createRoute(record, location))
1331
+ ? originalRedirect(createRoute(record, location, null, router))
1258
1332
  : originalRedirect;
1259
1333
 
1260
1334
  if (typeof redirect === 'string') {
@@ -1262,9 +1336,11 @@ function createMatcher (routes) {
1262
1336
  }
1263
1337
 
1264
1338
  if (!redirect || typeof redirect !== 'object') {
1265
- "development" !== 'production' && warn(
1266
- false, ("invalid redirect option: " + (JSON.stringify(redirect)))
1267
- );
1339
+ {
1340
+ warn(
1341
+ false, ("invalid redirect option: " + (JSON.stringify(redirect)))
1342
+ );
1343
+ }
1268
1344
  return _createRoute(null, location)
1269
1345
  }
1270
1346
 
@@ -1304,7 +1380,9 @@ function createMatcher (routes) {
1304
1380
  hash: hash
1305
1381
  }, undefined, location)
1306
1382
  } else {
1307
- warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
1383
+ {
1384
+ warn(false, ("invalid redirect option: " + (JSON.stringify(redirect))));
1385
+ }
1308
1386
  return _createRoute(null, location)
1309
1387
  }
1310
1388
  }
@@ -1339,7 +1417,7 @@ function createMatcher (routes) {
1339
1417
  if (record && record.matchAs) {
1340
1418
  return alias(record, location, record.matchAs)
1341
1419
  }
1342
- return createRoute(record, location, redirectedFrom)
1420
+ return createRoute(record, location, redirectedFrom, router)
1343
1421
  }
1344
1422
 
1345
1423
  return {
@@ -1349,14 +1427,11 @@ function createMatcher (routes) {
1349
1427
  }
1350
1428
 
1351
1429
  function matchRoute (
1430
+ regex,
1352
1431
  path,
1353
- params,
1354
- pathname
1432
+ params
1355
1433
  ) {
1356
- var ref = getRouteRegex(path);
1357
- var regexp = ref.regexp;
1358
- var keys = ref.keys;
1359
- var m = pathname.match(regexp);
1434
+ var m = path.match(regex);
1360
1435
 
1361
1436
  if (!m) {
1362
1437
  return false
@@ -1365,9 +1440,11 @@ function matchRoute (
1365
1440
  }
1366
1441
 
1367
1442
  for (var i = 1, len = m.length; i < len; ++i) {
1368
- var key = keys[i - 1];
1443
+ var key = regex.keys[i - 1];
1369
1444
  var val = typeof m[i] === 'string' ? decodeURIComponent(m[i]) : m[i];
1370
- if (key) { params[key.name] = val; }
1445
+ if (key) {
1446
+ params[key.name] = val;
1447
+ }
1371
1448
  }
1372
1449
 
1373
1450
  return true
@@ -1453,7 +1530,8 @@ function getScrollPosition () {
1453
1530
  }
1454
1531
 
1455
1532
  function getElementPosition (el) {
1456
- var docRect = document.documentElement.getBoundingClientRect();
1533
+ var docEl = document.documentElement;
1534
+ var docRect = docEl.getBoundingClientRect();
1457
1535
  var elRect = el.getBoundingClientRect();
1458
1536
  return {
1459
1537
  x: elRect.left - docRect.left,
@@ -1554,7 +1632,6 @@ function runQueue (queue, fn, cb) {
1554
1632
 
1555
1633
  /* */
1556
1634
 
1557
-
1558
1635
  var History = function History (router, base) {
1559
1636
  this.router = router;
1560
1637
  this.base = normalizeBase(base);
@@ -1563,20 +1640,29 @@ var History = function History (router, base) {
1563
1640
  this.pending = null;
1564
1641
  this.ready = false;
1565
1642
  this.readyCbs = [];
1643
+ this.readyErrorCbs = [];
1644
+ this.errorCbs = [];
1566
1645
  };
1567
1646
 
1568
1647
  History.prototype.listen = function listen (cb) {
1569
1648
  this.cb = cb;
1570
1649
  };
1571
1650
 
1572
- History.prototype.onReady = function onReady (cb) {
1651
+ History.prototype.onReady = function onReady (cb, errorCb) {
1573
1652
  if (this.ready) {
1574
1653
  cb();
1575
1654
  } else {
1576
1655
  this.readyCbs.push(cb);
1656
+ if (errorCb) {
1657
+ this.readyErrorCbs.push(errorCb);
1658
+ }
1577
1659
  }
1578
1660
  };
1579
1661
 
1662
+ History.prototype.onError = function onError (errorCb) {
1663
+ this.errorCbs.push(errorCb);
1664
+ };
1665
+
1580
1666
  History.prototype.transitionTo = function transitionTo (location, onComplete, onAbort) {
1581
1667
  var this$1 = this;
1582
1668
 
@@ -1589,18 +1675,34 @@ History.prototype.transitionTo = function transitionTo (location, onComplete, on
1589
1675
  // fire ready cbs once
1590
1676
  if (!this$1.ready) {
1591
1677
  this$1.ready = true;
1592
- this$1.readyCbs.forEach(function (cb) {
1593
- cb(route);
1594
- });
1678
+ this$1.readyCbs.forEach(function (cb) { cb(route); });
1595
1679
  }
1596
- }, onAbort);
1680
+ }, function (err) {
1681
+ if (onAbort) {
1682
+ onAbort(err);
1683
+ }
1684
+ if (err && !this$1.ready) {
1685
+ this$1.ready = true;
1686
+ this$1.readyErrorCbs.forEach(function (cb) { cb(err); });
1687
+ }
1688
+ });
1597
1689
  };
1598
1690
 
1599
1691
  History.prototype.confirmTransition = function confirmTransition (route, onComplete, onAbort) {
1600
1692
  var this$1 = this;
1601
1693
 
1602
1694
  var current = this.current;
1603
- var abort = function () { onAbort && onAbort(); };
1695
+ var abort = function (err) {
1696
+ if (isError(err)) {
1697
+ if (this$1.errorCbs.length) {
1698
+ this$1.errorCbs.forEach(function (cb) { cb(err); });
1699
+ } else {
1700
+ warn(false, 'uncaught error during route navigation:');
1701
+ console.error(err);
1702
+ }
1703
+ }
1704
+ onAbort && onAbort(err);
1705
+ };
1604
1706
  if (
1605
1707
  isSameRoute(route, current) &&
1606
1708
  // in the case the route map has been dynamically appended to
@@ -1633,29 +1735,44 @@ History.prototype.confirmTransition = function confirmTransition (route, onCompl
1633
1735
  if (this$1.pending !== route) {
1634
1736
  return abort()
1635
1737
  }
1636
- hook(route, current, function (to) {
1637
- if (to === false) {
1638
- // next(false) -> abort navigation, ensure current URL
1639
- this$1.ensureURL(true);
1640
- abort();
1641
- } else if (typeof to === 'string' || typeof to === 'object') {
1642
- // next('/') or next({ path: '/' }) -> redirect
1643
- (typeof to === 'object' && to.replace) ? this$1.replace(to) : this$1.push(to);
1644
- abort();
1645
- } else {
1646
- // confirm transition and pass on the value
1647
- next(to);
1648
- }
1649
- });
1738
+ try {
1739
+ hook(route, current, function (to) {
1740
+ if (to === false || isError(to)) {
1741
+ // next(false) -> abort navigation, ensure current URL
1742
+ this$1.ensureURL(true);
1743
+ abort(to);
1744
+ } else if (
1745
+ typeof to === 'string' ||
1746
+ (typeof to === 'object' && (
1747
+ typeof to.path === 'string' ||
1748
+ typeof to.name === 'string'
1749
+ ))
1750
+ ) {
1751
+ // next('/') or next({ path: '/' }) -> redirect
1752
+ abort();
1753
+ if (typeof to === 'object' && to.replace) {
1754
+ this$1.replace(to);
1755
+ } else {
1756
+ this$1.push(to);
1757
+ }
1758
+ } else {
1759
+ // confirm transition and pass on the value
1760
+ next(to);
1761
+ }
1762
+ });
1763
+ } catch (e) {
1764
+ abort(e);
1765
+ }
1650
1766
  };
1651
1767
 
1652
1768
  runQueue(queue, iterator, function () {
1653
1769
  var postEnterCbs = [];
1654
1770
  var isValid = function () { return this$1.current === route; };
1655
- var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
1656
1771
  // wait until async components are resolved before
1657
1772
  // extracting in-component enter guards
1658
- runQueue(enterGuards, iterator, function () {
1773
+ var enterGuards = extractEnterGuards(activated, postEnterCbs, isValid);
1774
+ var queue = enterGuards.concat(this$1.router.resolveHooks);
1775
+ runQueue(queue, iterator, function () {
1659
1776
  if (this$1.pending !== route) {
1660
1777
  return abort()
1661
1778
  }
@@ -1663,7 +1780,7 @@ History.prototype.confirmTransition = function confirmTransition (route, onCompl
1663
1780
  onComplete(route);
1664
1781
  if (this$1.router.app) {
1665
1782
  this$1.router.app.$nextTick(function () {
1666
- postEnterCbs.forEach(function (cb) { return cb(); });
1783
+ postEnterCbs.forEach(function (cb) { cb(); });
1667
1784
  });
1668
1785
  }
1669
1786
  });
@@ -1684,7 +1801,7 @@ function normalizeBase (base) {
1684
1801
  if (inBrowser) {
1685
1802
  // respect <base> tag
1686
1803
  var baseEl = document.querySelector('base');
1687
- base = baseEl ? baseEl.getAttribute('href') : '/';
1804
+ base = (baseEl && baseEl.getAttribute('href')) || '/';
1688
1805
  } else {
1689
1806
  base = '/';
1690
1807
  }
@@ -1752,8 +1869,10 @@ function extractUpdateHooks (updated) {
1752
1869
  }
1753
1870
 
1754
1871
  function bindGuard (guard, instance) {
1755
- return function boundRouteGuard () {
1756
- return guard.apply(instance, arguments)
1872
+ if (instance) {
1873
+ return function boundRouteGuard () {
1874
+ return guard.apply(instance, arguments)
1875
+ }
1757
1876
  }
1758
1877
  }
1759
1878
 
@@ -1807,31 +1926,66 @@ function poll (
1807
1926
  }
1808
1927
 
1809
1928
  function resolveAsyncComponents (matched) {
1810
- return flatMapComponents(matched, function (def, _, match, key) {
1811
- // if it's a function and doesn't have Vue options attached,
1812
- // assume it's an async component resolve function.
1813
- // we are not using Vue's default async resolving mechanism because
1814
- // we want to halt the navigation until the incoming component has been
1815
- // resolved.
1816
- if (typeof def === 'function' && !def.options) {
1817
- return function (to, from, next) {
1929
+ return function (to, from, next) {
1930
+ var hasAsync = false;
1931
+ var pending = 0;
1932
+ var error = null;
1933
+
1934
+ flatMapComponents(matched, function (def, _, match, key) {
1935
+ // if it's a function and doesn't have cid attached,
1936
+ // assume it's an async component resolve function.
1937
+ // we are not using Vue's default async resolving mechanism because
1938
+ // we want to halt the navigation until the incoming component has been
1939
+ // resolved.
1940
+ if (typeof def === 'function' && def.cid === undefined) {
1941
+ hasAsync = true;
1942
+ pending++;
1943
+
1818
1944
  var resolve = once(function (resolvedDef) {
1945
+ // save resolved on async factory in case it's used elsewhere
1946
+ def.resolved = typeof resolvedDef === 'function'
1947
+ ? resolvedDef
1948
+ : _Vue.extend(resolvedDef);
1819
1949
  match.components[key] = resolvedDef;
1820
- next();
1950
+ pending--;
1951
+ if (pending <= 0) {
1952
+ next();
1953
+ }
1821
1954
  });
1822
1955
 
1823
1956
  var reject = once(function (reason) {
1824
- warn(false, ("Failed to resolve async component " + key + ": " + reason));
1825
- next(false);
1957
+ var msg = "Failed to resolve async component " + key + ": " + reason;
1958
+ "development" !== 'production' && warn(false, msg);
1959
+ if (!error) {
1960
+ error = isError(reason)
1961
+ ? reason
1962
+ : new Error(msg);
1963
+ next(error);
1964
+ }
1826
1965
  });
1827
1966
 
1828
- var res = def(resolve, reject);
1829
- if (res && typeof res.then === 'function') {
1830
- res.then(resolve, reject);
1967
+ var res;
1968
+ try {
1969
+ res = def(resolve, reject);
1970
+ } catch (e) {
1971
+ reject(e);
1972
+ }
1973
+ if (res) {
1974
+ if (typeof res.then === 'function') {
1975
+ res.then(resolve, reject);
1976
+ } else {
1977
+ // new syntax in Vue 2.3
1978
+ var comp = res.component;
1979
+ if (comp && typeof comp.then === 'function') {
1980
+ comp.then(resolve, reject);
1981
+ }
1982
+ }
1831
1983
  }
1832
1984
  }
1833
- }
1834
- })
1985
+ });
1986
+
1987
+ if (!hasAsync) { next(); }
1988
+ }
1835
1989
  }
1836
1990
 
1837
1991
  function flatMapComponents (
@@ -1864,6 +2018,10 @@ function once (fn) {
1864
2018
  }
1865
2019
  }
1866
2020
 
2021
+ function isError (err) {
2022
+ return Object.prototype.toString.call(err).indexOf('Error') > -1
2023
+ }
2024
+
1867
2025
  /* */
1868
2026
 
1869
2027
 
@@ -1899,9 +2057,11 @@ var HTML5History = (function (History$$1) {
1899
2057
  HTML5History.prototype.push = function push (location, onComplete, onAbort) {
1900
2058
  var this$1 = this;
1901
2059
 
2060
+ var ref = this;
2061
+ var fromRoute = ref.current;
1902
2062
  this.transitionTo(location, function (route) {
1903
2063
  pushState(cleanPath(this$1.base + route.fullPath));
1904
- handleScroll(this$1.router, route, this$1.current, false);
2064
+ handleScroll(this$1.router, route, fromRoute, false);
1905
2065
  onComplete && onComplete(route);
1906
2066
  }, onAbort);
1907
2067
  };
@@ -1909,9 +2069,11 @@ var HTML5History = (function (History$$1) {
1909
2069
  HTML5History.prototype.replace = function replace (location, onComplete, onAbort) {
1910
2070
  var this$1 = this;
1911
2071
 
2072
+ var ref = this;
2073
+ var fromRoute = ref.current;
1912
2074
  this.transitionTo(location, function (route) {
1913
2075
  replaceState(cleanPath(this$1.base + route.fullPath));
1914
- handleScroll(this$1.router, route, this$1.current, false);
2076
+ handleScroll(this$1.router, route, fromRoute, false);
1915
2077
  onComplete && onComplete(route);
1916
2078
  }, onAbort);
1917
2079
  };
@@ -2108,8 +2270,9 @@ var VueRouter = function VueRouter (options) {
2108
2270
  this.apps = [];
2109
2271
  this.options = options;
2110
2272
  this.beforeHooks = [];
2273
+ this.resolveHooks = [];
2111
2274
  this.afterHooks = [];
2112
- this.matcher = createMatcher(options.routes || []);
2275
+ this.matcher = createMatcher(options.routes || [], this);
2113
2276
 
2114
2277
  var mode = options.mode || 'hash';
2115
2278
  this.fallback = mode === 'history' && !supportsPushState;
@@ -2193,15 +2356,23 @@ VueRouter.prototype.init = function init (app /* Vue component instance */) {
2193
2356
  };
2194
2357
 
2195
2358
  VueRouter.prototype.beforeEach = function beforeEach (fn) {
2196
- this.beforeHooks.push(fn);
2359
+ return registerHook(this.beforeHooks, fn)
2360
+ };
2361
+
2362
+ VueRouter.prototype.beforeResolve = function beforeResolve (fn) {
2363
+ return registerHook(this.resolveHooks, fn)
2197
2364
  };
2198
2365
 
2199
2366
  VueRouter.prototype.afterEach = function afterEach (fn) {
2200
- this.afterHooks.push(fn);
2367
+ return registerHook(this.afterHooks, fn)
2368
+ };
2369
+
2370
+ VueRouter.prototype.onReady = function onReady (cb, errorCb) {
2371
+ this.history.onReady(cb, errorCb);
2201
2372
  };
2202
2373
 
2203
- VueRouter.prototype.onReady = function onReady (cb) {
2204
- this.history.onReady(cb);
2374
+ VueRouter.prototype.onError = function onError (errorCb) {
2375
+ this.history.onError(errorCb);
2205
2376
  };
2206
2377
 
2207
2378
  VueRouter.prototype.push = function push (location, onComplete, onAbort) {
@@ -2243,7 +2414,12 @@ VueRouter.prototype.resolve = function resolve (
2243
2414
  current,
2244
2415
  append
2245
2416
  ) {
2246
- var location = normalizeLocation(to, current || this.history.current, append);
2417
+ var location = normalizeLocation(
2418
+ to,
2419
+ current || this.history.current,
2420
+ append,
2421
+ this
2422
+ );
2247
2423
  var route = this.match(location, current);
2248
2424
  var fullPath = route.redirectedFrom || route.fullPath;
2249
2425
  var base = this.history.base;
@@ -2267,13 +2443,21 @@ VueRouter.prototype.addRoutes = function addRoutes (routes) {
2267
2443
 
2268
2444
  Object.defineProperties( VueRouter.prototype, prototypeAccessors );
2269
2445
 
2446
+ function registerHook (list, fn) {
2447
+ list.push(fn);
2448
+ return function () {
2449
+ var i = list.indexOf(fn);
2450
+ if (i > -1) { list.splice(i, 1); }
2451
+ }
2452
+ }
2453
+
2270
2454
  function createHref (base, fullPath, mode) {
2271
2455
  var path = mode === 'hash' ? '#' + fullPath : fullPath;
2272
2456
  return base ? cleanPath(base + '/' + path) : path
2273
2457
  }
2274
2458
 
2275
2459
  VueRouter.install = install;
2276
- VueRouter.version = '2.2.1';
2460
+ VueRouter.version = '2.5.2';
2277
2461
 
2278
2462
  if (inBrowser && window.Vue) {
2279
2463
  window.Vue.use(VueRouter);