diff --git a/dist/routux.min.js b/dist/routux.min.js index 28aadd7..f4d3af6 100644 --- a/dist/routux.min.js +++ b/dist/routux.min.js @@ -1 +1 @@ -/*! routux v0.2.0 | MIT (c) 2015 Nicolas Tallefourtane - https://github.com/Nicolab/routux */!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(1)["default"],i=r(2),o=n(i),a=r(11),u=n(a),s={Router:u["default"],Route:o["default"],noConflict:function(){return window&&(window.routux=null,delete window.routux),this}};window&&(window.routux=s),e.exports=s},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(3)["default"],i=r(8)["default"];Object.defineProperty(t,"__esModule",{value:!0});var o=r(9),a=-1,u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(i(this,e),this.router=t.router,this.middlewares=t.middlewares,this.pattern=t.pattern,this.name=t.name||this.pattern,a++,Object.defineProperty(this,"_uid",{enumerable:!0,configurable:!1,writable:!1,value:a}),!this.middlewares.length)throw new Error("A route must have one middleware (or more).");this.reset()}return n(e,[{key:"reset",value:function(){return this.params={},this.query={},this.regexp=o(this.pattern,this.router.opt.regexp),this.getPath=o.compile(this.pattern),this}},{key:"getUrl",value:function(e){return this.router.getUrl(this,e)}},{key:"getFullUrl",value:function(e){return this.router.getFullUrl(this,e)}},{key:"baseUrl",get:function(){return this.router.location.baseUrl}}]),e}();t["default"]=u,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(4)["default"];t["default"]=function(){function e(e,t){for(var r=0;r0?y:d)(e)}function i(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}function o(e,t,r){return e[t]=r,e}function a(e){return m?function(t,r,n){return w.setDesc(t,r,i(e,n))}:o}function u(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function s(e){return"function"==typeof e}function c(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}var l="undefined"!=typeof self?self:Function("return this")(),f={},h=Object.defineProperty,p={}.hasOwnProperty,d=Math.ceil,y=Math.floor,g=Math.max,v=Math.min,m=!!function(){try{return 2==h({},"a",{get:function(){return 2}}).a}catch(e){}}(),b=a(1),w=e.exports=r(7)({g:l,core:f,html:l.document&&document.documentElement,isObject:u,isFunction:s,that:function(){return this},toInteger:n,toLength:function(e){return e>0?v(n(e),9007199254740991):0},toIndex:function(e,t){return e=n(e),0>e?g(e+t,0):v(e,t)},has:function(e,t){return p.call(e,t)},create:Object.create,getProto:Object.getPrototypeOf,DESC:m,desc:i,getDesc:Object.getOwnPropertyDescriptor,setDesc:h,setDescs:Object.defineProperties,getKeys:Object.keys,getNames:Object.getOwnPropertyNames,getSymbols:Object.getOwnPropertySymbols,assertDefined:c,ES5Object:Object,toObject:function(e){return w.ES5Object(c(e))},hide:b,def:a(0),set:l.Symbol?o:b,each:[].forEach});"undefined"!=typeof __e&&(__e=f),"undefined"!=typeof __g&&(__g=l)},function(e,t){e.exports=function(e){return e.FW=!1,e.path=e.core,e}},function(e,t){"use strict";t["default"]=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},t.__esModule=!0},function(e,t,r){function n(e){for(var t,r=[],n=0,i=0,o="";null!=(t=g.exec(e));){var a=t[0],s=t[1],c=t.index;if(o+=e.slice(i,c),i=c+a.length,s)o+=s[1];else{o&&(r.push(o),o="");var l=t[2],f=t[3],h=t[4],p=t[5],d=t[6],y=t[7],v="+"===d||"*"===d,m="?"===d||"*"===d,b=l||"/",w=h||p||(y?".*":"[^"+b+"]+?");r.push({name:f||n++,prefix:l||"",delimiter:b,optional:m,repeat:v,pattern:u(w)})}}return ie;e++)this.buildRoute(this._routes[e]);return this}},{key:"buildRoute",value:function(e){var t=void 0;if(e.reset().regexp.result=e.regexp.exec(this.location.current),e.regexp.result){for(var r=0,n=e.regexp.keys.length;n>r;r++)t=e.regexp.keys[r].name,e.query=this.req.query,e.params[t]=e.regexp.result[r+1],this.req.params[t]=e.params[t];this.matches[e.name]=e,this._matches.push(this.matches[e.name])}return this}},{key:"run",value:function(){var e=this,t=void 0,r=void 0;t=[],r=function(n){if(t.length){var i=t.shift(),o=i.route,a=i.middleware;if(a.length<3){if(n)return r(n);a.call(o,e.req,function(e){r(e)})}else a.call(o,n,e.req,function(e){r(e)})}};for(var n=0,i=this._matches.length;i>n;n++)for(var o=this._matches[n],a=0,u=o.middlewares.length;u>a;a++)t.push({route:o,middleware:o.middlewares[a]});return this.running=!0,r(),this}},{key:"baseUrl",get:function(){return this.location.baseUrl}},{key:"url",get:function(){return this.location.url}},{key:"fullUrl",get:function(){return this.location.fullUrl}},{key:"current",get:function(){return this.location.current}}]),e}();e.exports=h},function(e,t){"use strict";var r=function n(e){var t=arguments.length;if(2>t)throw new Error("There should be at least 2 arguments passed to mergeRecursive()");for(var r=1;t>r;r++)for(var i in arguments[r])e[i]=e[i]&&"object"==typeof e[i]?n(e[i],arguments[r][i]):arguments[r][i];return e};e.exports={mergeRecursive:r}},function(e,t,r){"use strict";var n=r(14)["default"],i=r(20)["default"],o=r(3)["default"],a=r(8)["default"],u=r(1)["default"];Object.defineProperty(t,"__esModule",{value:!0});var s=r(23),c=u(s),l=function(e){function t(e){a(this,t),n(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.pathPrefix=this.opt.pathPrefix||"#",this.urlPrefix=this.pathPrefix,this._onChange=this._onChange.bind(this)}return i(t,e),o(t,[{key:"normalizePath",value:function(e){return e&&0===e.indexOf(this.baseUrl)&&(e=e.slice(this.baseUrl.length)),decodeURI(-1===e.indexOf(this.pathPrefix)?e:e.split(this.pathPrefix)[1]||"")}},{key:"historyBack",value:function(){n(Object.getPrototypeOf(t.prototype),"pop",this).call(this),window.history.back()}},{key:"historyForward",value:function(){n(Object.getPrototypeOf(t.prototype),"push",this).call(this),window.history.forward()}},{key:"push",value:function(e){n(Object.getPrototypeOf(t.prototype),"push",this).call(this,e),"undefined"!=typeof e&&(window.location.hash=this.pathPrefix+e)}},{key:"replace",value:function(e){n(Object.getPrototypeOf(t.prototype),"replace",this).call(this,e),window.location.replace(window.location.pathname+window.location.search+this.pathPrefix+e)}},{key:"addChangeListener",value:function(e){n(Object.getPrototypeOf(t.prototype),"addChangeListener",this).call(this,e),this._isListening||(window.addEventListener?window.addEventListener("hashchange",this._onChange,!1):window.attachEvent("onhashchange",this._onChange),this._isListening=!0)}},{key:"removeChangeListener",value:function(e){n(Object.getPrototypeOf(t.prototype),"removeChangeListener",this).call(this,e),0===this._listeners.length&&(window.removeEventListener?window.removeEventListener("hashchange",this._onChange,!1):window.removeEvent("onhashchange",this._onChange),this._isListening=!1)}},{key:"current",get:function(){return this.normalizePath(window.location.href)}},{key:"queryString",get:function(){return window.location.search.substring(1)}},{key:"baseUrl",get:function(){return window.location.origin+window.location.pathname}},{key:"url",get:function(){return this.urlPrefix+this.normalizePath(window.location.hash)}},{key:"fullUrl",get:function(){var e="/"===this.url.charAt(0)?this.url.substring(1):this.url;return this.baseUrl+e}}]),t}(c["default"]);t["default"]=l,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(15)["default"];t["default"]=function(e,t,r){for(var i=!0;i;){var o=e,a=t,u=r;s=l=c=void 0,i=!1,null===o&&(o=Function.prototype);var s=n(o,a);if(void 0!==s){if("value"in s)return s.value;var c=s.get;return void 0===c?void 0:c.call(u)}var l=Object.getPrototypeOf(o);if(null===l)return void 0;e=l,t=a,r=u,i=!0}},t.__esModule=!0},function(e,t,r){e.exports={"default":r(16),__esModule:!0}},function(e,t,r){var n=r(6);r(17),e.exports=function(e,t){return n.getDesc(e,t)}},function(e,t,r){var n=r(6),i=r(18),o=n.isObject,a=n.toObject;n.each.call("freeze,seal,preventExtensions,isFrozen,isSealed,isExtensible,getOwnPropertyDescriptor,getPrototypeOf,keys,getOwnPropertyNames".split(","),function(e,t){var u=(n.core.Object||{})[e]||Object[e],s=0,c={};c[e]=0==t?function(e){return o(e)?u(e):e}:1==t?function(e){return o(e)?u(e):e}:2==t?function(e){return o(e)?u(e):e}:3==t?function(e){return o(e)?u(e):!0}:4==t?function(e){return o(e)?u(e):!0}:5==t?function(e){return o(e)?u(e):!1}:6==t?function(e,t){return u(a(e),t)}:7==t?function(e){return u(Object(n.assertDefined(e)))}:8==t?function(e){return u(a(e))}:r(19).get;try{u("z")}catch(l){s=1}i(i.S+i.F*s,"Object",c)})},function(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}function i(e,t,r){var o,c,l,f,h=e&i.G,p=e&i.P,d=h?a:e&i.S?a[t]:(a[t]||{}).prototype,y=h?u:u[t]||(u[t]={});h&&(r=t);for(o in r)c=!(e&i.F)&&d&&o in d,c&&o in y||(l=c?d[o]:r[o],h&&!s(d[o])?f=r[o]:e&i.B&&c?f=n(l,a):e&i.W&&d[o]==l?!function(e){f=function(t){return this instanceof e?new e(t):e(t)},f.prototype=e.prototype}(l):f=p&&s(l)?n(Function.call,l):l,y[o]=f,p&&((y.prototype||(y.prototype={}))[o]=l))}var o=r(6),a=o.g,u=o.core,s=o.isFunction;i.F=1,i.G=2,i.S=4,i.P=8,i.B=16,i.W=32,e.exports=i},function(e,t,r){function n(e){try{return a(e)}catch(t){return u.slice()}}var i=r(6),o={}.toString,a=i.getNames,u="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.get=function(e){return u&&"[object Window]"==o.call(e)?n(e):a(i.toObject(e))}},function(e,t,r){"use strict";var n=r(21)["default"];t["default"]=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=n(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},t.__esModule=!0},function(e,t,r){e.exports={"default":r(22),__esModule:!0}},function(e,t,r){var n=r(6);e.exports=function(e,t){return n.create(e,t)}},function(e,t,r){"use strict";var n=r(3)["default"],i=r(8)["default"],o=r(1)["default"];Object.defineProperty(t,"__esModule",{value:!0});var a=r(24),u=o(a),s=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];i(this,e),this.PUSH="push",this.REPLACE="replace",this.POP="pop",this._actionType=null,this._isListening=!1,this._listeners=[];var r=this;this.opt=t,this.qs={__proto__:u["default"]},this.qs.currentWith=function(e){return r.qs.parse(r.queryString,e)},Object.defineProperty(this.qs,"current",{get:function(){return r.qs.parse(r.normalizePath(r.queryString))}}),this.urlPrefix=this.pathPrefix="/"}return n(e,[{key:"ensureSlash",value:function(){var e=this.current;return"/"===e.charAt(0)?!0:(this.replace("/"+e),!1)}},{key:"normalizePath",value:function(e){return"/"===e.charAt(0)?decodeURI(e):"/"+decodeURI(e)}},{key:"historyBack",value:function(){this.pop()}},{key:"historyForward",value:function(){this.push()}},{key:"_onChange",value:function(){var e=void 0;this.ensureSlash()&&(e=this._actionType,this._actionType=null,this.notifyChange(e||this.POP))}},{key:"notifyChange",value:function(e){var t=void 0,r=void 0;r=this,t={path:this.current,type:e},this._listeners.forEach(function(e){e.call(r,t)})}},{key:"addChangeListener",value:function(e){this._listeners.push(e),this.ensureSlash()}},{key:"removeChangeListener",value:function(e){this._listeners=this._listeners.filter(function(t){return t!==e})}},{key:"push",value:function(){this._actionType=this.PUSH}},{key:"replace",value:function(){this._actionType=this.REPLACE}},{key:"pop",value:function(){this._actionType=this.POP}},{key:"current",get:function(){throw new ReferenceError("Location.current is not implemented by the adapter used.")}},{key:"queryString",get:function(){throw new ReferenceError("Location.queryString is not implemented by the adapter used.")}},{key:"baseUrl",get:function(){throw new ReferenceError("Location.baseUrl is not implemented by the adapter used.")}},{key:"url",get:function(){throw new ReferenceError("Location.url is not implemented by the adapter used.")}},{key:"fullUrl",get:function(){return this.baseUrl+this.url}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t,r){var n=r(25),i=r(27);e.exports={stringify:n,parse:i}},function(e,t,r){var n=r(26),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(e,t){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e,t){return e}},strictNullHandling:!1};i.stringify=function(e,t,r,o,a){if("function"==typeof a)e=a(t,e);else if(n.isBuffer(e))e=e.toString();else if(e instanceof Date)e=e.toISOString();else if(null===e){if(o)return n.encode(t);e=""}if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return[n.encode(t)+"="+n.encode(e)];var u=[];if("undefined"==typeof e)return u;for(var s=Array.isArray(a)?a:Object.keys(e),c=0,l=s.length;l>c;++c){var f=s[c];u=u.concat(Array.isArray(e)?i.stringify(e[f],r(t,f),r,o,a):i.stringify(e[f],t+"["+f+"]",r,o,a))}return u},e.exports=function(e,t){t=t||{};var r,n,o="undefined"==typeof t.delimiter?i.delimiter:t.delimiter,a="boolean"==typeof t.strictNullHandling?t.strictNullHandling:i.strictNullHandling;"function"==typeof t.filter?(n=t.filter,e=n("",e)):Array.isArray(t.filter)&&(r=n=t.filter);var u=[];if("object"!=typeof e||null===e)return"";var s;s=t.arrayFormat in i.arrayPrefixGenerators?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":"indices";var c=i.arrayPrefixGenerators[s];r||(r=Object.keys(e));for(var l=0,f=r.length;f>l;++l){var h=r[l];u=u.concat(i.stringify(e[h],h,c,a,n))}return u.join(o)}},function(e,t){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();t.arrayToObject=function(e,t){for(var r=t.plainObjects?Object.create(null):{},n=0,i=e.length;i>n;++n)"undefined"!=typeof e[n]&&(r[n]=e[n]);return r},t.merge=function(e,r,n){if(!r)return e;if("object"!=typeof r)return Array.isArray(e)?e.push(r):"object"==typeof e?e[r]=!0:e=[e,r],e;if("object"!=typeof e)return e=[e].concat(r);Array.isArray(e)&&!Array.isArray(r)&&(e=t.arrayToObject(e,n));for(var i=Object.keys(r),o=0,a=i.length;a>o;++o){var u=i[o],s=r[u];e[u]=Object.prototype.hasOwnProperty.call(e,u)?t.merge(e[u],s,n):s}return e},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;"string"!=typeof e&&(e=""+e);for(var t="",n=0,i=e.length;i>n;++n){var o=e.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?t+=e[n]:128>o?t+=r.hexTable[o]:2048>o?t+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?t+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&e.charCodeAt(n)),t+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return t},t.compact=function(e,r){if("object"!=typeof e||null===e)return e;r=r||[];var n=r.indexOf(e);if(-1!==n)return r[n];if(r.push(e),Array.isArray(e)){for(var i=[],o=0,a=e.length;a>o;++o)"undefined"!=typeof e[o]&&i.push(e[o]);return i}var u=Object.keys(e);for(o=0,a=u.length;a>o;++o){var s=u[o];e[s]=t.compact(e[s],r)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null===e||"undefined"==typeof e?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},function(e,t,r){var n=r(26),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1};i.parseValues=function(e,t){for(var r={},i=e.split(t.delimiter,t.parameterLimit===1/0?void 0:t.parameterLimit),o=0,a=i.length;a>o;++o){var u=i[o],s=-1===u.indexOf("]=")?u.indexOf("="):u.indexOf("]=")+1;if(-1===s)r[n.decode(u)]="",t.strictNullHandling&&(r[n.decode(u)]=null);else{var c=n.decode(u.slice(0,s)),l=n.decode(u.slice(s+1));r[c]=Object.prototype.hasOwnProperty.call(r,c)?[].concat(r[c]).concat(l):l}}return r},i.parseObject=function(e,t,r){if(!e.length)return t;var n,o=e.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(e,t,r));else{n=r.plainObjects?Object.create(null):{};var a="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,u=parseInt(a,10),s=""+u;!isNaN(u)&&o!==a&&s===a&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(n=[],n[u]=i.parseObject(e,t,r)):n[a]=i.parseObject(e,t,r)}return n},i.parseKeys=function(e,t,r){if(e){r.allowDots&&(e=e.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,a=n.exec(e),u=[];if(a[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(a[1])&&!r.allowPrototypes)return;u.push(a[1])}for(var s=0;null!==(a=o.exec(e))&&su;++u){var c=a[u],l=i.parseKeys(c,r[c],t);o=n.merge(o,l,t)}return n.compact(o)}}]); \ No newline at end of file +/*! routux v0.2.2 | MIT (c) 2015 Nicolas Tallefourtane - https://github.com/Nicolab/routux */!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(1)["default"];Object.defineProperty(t,"__esModule",{value:!0});var i=r(2),o=n(i),a=r(10),u=n(a),s={Router:u["default"],Route:o["default"],noConflict:function(){return window&&(window.routux=null,delete window.routux),this}};window&&(window.routux=s),t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";t["default"]=function(e){return e&&e.__esModule?e:{"default":e}},t.__esModule=!0},function(e,t,r){"use strict";var n=r(3)["default"],i=r(7)["default"];Object.defineProperty(t,"__esModule",{value:!0});var o=r(8),a=-1,u=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];if(i(this,e),this.router=t.router,this.middlewares=t.middlewares,this.pattern=t.pattern,this.name=t.name||this.pattern,a++,Object.defineProperty(this,"_uid",{enumerable:!0,configurable:!1,writable:!1,value:a}),!this.middlewares.length)throw new Error("A route must have one middleware (or more).");this.reset()}return n(e,[{key:"reset",value:function(){return this.params={},this.query={},this.regexp=o(this.pattern,this.router.opt.regexp),this.getPath=o.compile(this.pattern),this}},{key:"getUrl",value:function(e){return this.router.getUrl(this,e)}},{key:"getFullUrl",value:function(e){return this.router.getFullUrl(this,e)}},{key:"baseUrl",get:function(){return this.router.location.baseUrl}}]),e}();t["default"]=u,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(4)["default"];t["default"]=function(){function e(e,t){for(var r=0;re;e++)this.buildRoute(this._routes[e]);return this}},{key:"buildRoute",value:function(e){var t=void 0;if(e.reset().regexp.result=e.regexp.exec(this.location.current),e.regexp.result){for(var r=0,n=e.regexp.keys.length;n>r;r++)t=e.regexp.keys[r].name,e.query=this.req.query,e.params[t]=e.regexp.result[r+1],this.req.params[t]=e.params[t];this.matches[e.name]=e,this._matches.push(this.matches[e.name])}return this}},{key:"run",value:function(){var e=this,t=void 0,r=void 0;t=[],r=function(n){if(t.length){var i=t.shift(),o=i.route,a=i.middleware;if(a.length<3){if(n)return r(n);a.call(o,e.req,function(e){r(e)})}else a.call(o,n,e.req,function(e){r(e)})}};for(var n=0,i=this._matches.length;i>n;n++)for(var o=this._matches[n],a=0,u=o.middlewares.length;u>a;a++)t.push({route:o,middleware:o.middlewares[a]});return this.running=!0,r(),this}},{key:"baseUrl",get:function(){return this.location.baseUrl}},{key:"url",get:function(){return this.location.url}},{key:"fullUrl",get:function(){return this.location.fullUrl}},{key:"current",get:function(){return this.location.current}}]),e}();e.exports=p},function(e,t){"use strict";var r=function n(e){var t=arguments.length;if(2>t)throw new Error("There should be at least 2 arguments passed to mergeRecursive()");for(var r=1;t>r;r++)for(var i in arguments[r])e[i]=e[i]&&"object"==typeof e[i]?n(e[i],arguments[r][i]):arguments[r][i];return e};e.exports={mergeRecursive:r}},function(e,t,r){"use strict";var n=r(13)["default"],i=r(26)["default"],o=r(3)["default"],a=r(7)["default"],u=r(1)["default"];Object.defineProperty(t,"__esModule",{value:!0});var s=r(36),c=u(s),l=function(e){function t(e){a(this,t),n(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e),this.pathPrefix=this.opt.pathPrefix||"#",this.urlPrefix=this.pathPrefix,this._onChange=this._onChange.bind(this)}return i(t,e),o(t,[{key:"normalizePath",value:function(e){return e&&0===e.indexOf(this.baseUrl)&&(e=e.slice(this.baseUrl.length)),decodeURI(-1===e.indexOf(this.pathPrefix)?e:e.split(this.pathPrefix)[1]||"")}},{key:"historyBack",value:function(){n(Object.getPrototypeOf(t.prototype),"pop",this).call(this),window.history.back()}},{key:"historyForward",value:function(){n(Object.getPrototypeOf(t.prototype),"push",this).call(this),window.history.forward()}},{key:"push",value:function(e){n(Object.getPrototypeOf(t.prototype),"push",this).call(this,e),"undefined"!=typeof e&&(window.location.hash=this.pathPrefix+e)}},{key:"replace",value:function(e){n(Object.getPrototypeOf(t.prototype),"replace",this).call(this,e),window.location.replace(window.location.pathname+window.location.search+this.pathPrefix+e)}},{key:"addChangeListener",value:function(e){n(Object.getPrototypeOf(t.prototype),"addChangeListener",this).call(this,e),this._isListening||(window.addEventListener?window.addEventListener("hashchange",this._onChange,!1):window.attachEvent("onhashchange",this._onChange),this._isListening=!0)}},{key:"removeChangeListener",value:function(e){n(Object.getPrototypeOf(t.prototype),"removeChangeListener",this).call(this,e),0===this._listeners.length&&(window.removeEventListener?window.removeEventListener("hashchange",this._onChange,!1):window.removeEvent("onhashchange",this._onChange),this._isListening=!1)}},{key:"current",get:function(){return this.normalizePath(window.location.href)}},{key:"queryString",get:function(){return window.location.search.substring(1)}},{key:"baseUrl",get:function(){return window.location.origin+window.location.pathname}},{key:"url",get:function(){return this.urlPrefix+this.normalizePath(window.location.hash)}},{key:"fullUrl",get:function(){var e="/"===this.url.charAt(0)?this.url.substring(1):this.url;return this.baseUrl+e}}]),t}(c["default"]);t["default"]=l,e.exports=t["default"]},function(e,t,r){"use strict";var n=r(14)["default"];t["default"]=function(e,t,r){for(var i=!0;i;){var o=e,a=t,u=r;s=l=c=void 0,i=!1,null===o&&(o=Function.prototype);var s=n(o,a);if(void 0!==s){if("value"in s)return s.value;var c=s.get;return void 0===c?void 0:c.call(u)}var l=Object.getPrototypeOf(o);if(null===l)return void 0;e=l,t=a,r=u,i=!0}},t.__esModule=!0},function(e,t,r){e.exports={"default":r(15),__esModule:!0}},function(e,t,r){var n=r(6);r(16),e.exports=function(e,t){return n.getDesc(e,t)}},function(e,t,r){var n=r(6),i=r(21),o=r(22),a=r(17),u=r(24);n.each.call("freeze,seal,preventExtensions,isFrozen,isSealed,isExtensible,getOwnPropertyDescriptor,getPrototypeOf,keys,getOwnPropertyNames".split(","),function(e,t){var n=(i.Object||{})[e]||Object[e],s=0,c={};c[e]=0==t?function(e){return u(e)?n(e):e}:1==t?function(e){return u(e)?n(e):e}:2==t?function(e){return u(e)?n(e):e}:3==t?function(e){return u(e)?n(e):!0}:4==t?function(e){return u(e)?n(e):!0}:5==t?function(e){return u(e)?n(e):!1}:6==t?function(e,t){return n(a(e),t)}:7==t?function(e){return n(a(e,!0))}:8==t?function(e){return n(a(e))}:r(25).get;try{n("z")}catch(l){s=1}o(o.S+o.F*s,"Object",c)})},function(e,t,r){var n=r(18),i=r(20);e.exports=function(e,t){return(t?Object:n)(i(e))}},function(e,t,r){var n=r(19),i=Object;e.exports=0 in i("z")?i:function(e){return"String"==n(e)?e.split(""):i(e)}},function(e,t){var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t){e.exports=function(e){if(void 0==e)throw TypeError("Can't call method on "+e);return e}},function(e,t){var r=e.exports={};"number"==typeof __e&&(__e=r)},function(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}function i(e,t,r){var s,c,l,f,p=e&i.G,h=e&i.P,d=p?o:e&i.S?o[t]:(o[t]||{})[u],y=p?a:a[t]||(a[t]={});p&&(r=t);for(s in r)c=!(e&i.F)&&d&&s in d,c&&s in y||(l=c?d[s]:r[s],p&&"function"!=typeof d[s]?f=r[s]:e&i.B&&c?f=n(l,o):e&i.W&&d[s]==l?!function(e){f=function(t){return this instanceof e?new e(t):e(t)},f[u]=e[u]}(l):f=h&&"function"==typeof l?n(Function.call,l):l,y[s]=f,h&&((y[u]||(y[u]={}))[s]=l))}var o=r(23),a=r(21),u="prototype";i.F=1,i.G=2,i.S=4,i.P=8,i.B=16,i.W=32,e.exports=i},function(e,t){var r="undefined"!=typeof self&&self.Math==Math?self:Function("return this")();e.exports=r,"number"==typeof __g&&(__g=r)},function(e,t){e.exports=function(e){return null!==e&&("object"==typeof e||"function"==typeof e)}},function(e,t,r){function n(e){try{return a(e)}catch(t){return u.slice()}}var i={}.toString,o=r(17),a=r(6).getNames,u="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.get=function(e){return u&&"[object Window]"==i.call(e)?n(e):a(o(e))}},function(e,t,r){"use strict";var n=r(27)["default"],i=r(29)["default"];t["default"]=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=n(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(i?i(e,t):e.__proto__=t)},t.__esModule=!0},function(e,t,r){e.exports={"default":r(28),__esModule:!0}},function(e,t,r){var n=r(6);e.exports=function(e,t){return n.create(e,t)}},function(e,t,r){e.exports={"default":r(30),__esModule:!0}},function(e,t,r){r(31),e.exports=r(21).Object.setPrototypeOf},function(e,t,r){var n=r(22);n(n.S,"Object",{setPrototypeOf:r(32).set})},function(e,t,r){function n(e,t){if(a(e),!o(t)&&null!==t)throw TypeError(t+": can't set as prototype!")}var i=r(6).getDesc,o=r(24),a=r(33);e.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(e,t){try{t=r(34)(Function.call,i(Object.prototype,"__proto__").set,2),t({},[])}catch(o){e=!0}return function(r,i){return n(r,i),e?r.__proto__=i:t(r,i),r}}():void 0),check:n}},function(e,t,r){var n=r(24);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t,r){var n=r(35);e.exports=function(e,t,r){if(n(e),~r&&void 0===t)return e;switch(r){case 1:return function(r){return e.call(t,r)};case 2:return function(r,n){return e.call(t,r,n)};case 3:return function(r,n,i){return e.call(t,r,n,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t,r){"use strict";var n=r(3)["default"],i=r(7)["default"],o=r(1)["default"];Object.defineProperty(t,"__esModule",{value:!0});var a=r(37),u=o(a),s=function(){function e(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];i(this,e),this.PUSH="push",this.REPLACE="replace",this.POP="pop",this._actionType=null,this._isListening=!1,this._listeners=[];var r=this;this.opt=t,this.qs={__proto__:u["default"]},this.qs.currentWith=function(e){return r.qs.parse(r.queryString,e)},Object.defineProperty(this.qs,"current",{get:function(){return r.qs.parse(r.normalizePath(r.queryString))}}),this.urlPrefix=this.pathPrefix="/"}return n(e,[{key:"ensureSlash",value:function(){var e=this.current;return"/"===e.charAt(0)?!0:(this.replace("/"+e),!1)}},{key:"normalizePath",value:function(e){return"/"===e.charAt(0)?decodeURI(e):"/"+decodeURI(e)}},{key:"historyBack",value:function(){this.pop()}},{key:"historyForward",value:function(){this.push()}},{key:"_onChange",value:function(){var e=void 0;this.ensureSlash()&&(e=this._actionType,this._actionType=null,this.notifyChange(e||this.POP))}},{key:"notifyChange",value:function(e){var t=void 0,r=void 0;r=this,t={path:this.current,type:e},this._listeners.forEach(function(e){e.call(r,t)})}},{key:"addChangeListener",value:function(e){this._listeners.push(e),this.ensureSlash()}},{key:"removeChangeListener",value:function(e){this._listeners=this._listeners.filter(function(t){return t!==e})}},{key:"push",value:function(){this._actionType=this.PUSH}},{key:"replace",value:function(){this._actionType=this.REPLACE}},{key:"pop",value:function(){this._actionType=this.POP}},{key:"current",get:function(){throw new ReferenceError("Location.current is not implemented by the adapter used.")}},{key:"queryString",get:function(){throw new ReferenceError("Location.queryString is not implemented by the adapter used.")}},{key:"baseUrl",get:function(){throw new ReferenceError("Location.baseUrl is not implemented by the adapter used.")}},{key:"url",get:function(){throw new ReferenceError("Location.url is not implemented by the adapter used.")}},{key:"fullUrl",get:function(){return this.baseUrl+this.url}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t,r){var n=r(38),i=r(40);e.exports={stringify:n,parse:i}},function(e,t,r){var n=r(39),i={delimiter:"&",arrayPrefixGenerators:{brackets:function(e,t){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e,t){return e}},strictNullHandling:!1};i.stringify=function(e,t,r,o,a){if("function"==typeof a)e=a(t,e);else if(n.isBuffer(e))e=e.toString();else if(e instanceof Date)e=e.toISOString();else if(null===e){if(o)return n.encode(t);e=""}if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return[n.encode(t)+"="+n.encode(e)];var u=[];if("undefined"==typeof e)return u;for(var s=Array.isArray(a)?a:Object.keys(e),c=0,l=s.length;l>c;++c){var f=s[c];u=u.concat(Array.isArray(e)?i.stringify(e[f],r(t,f),r,o,a):i.stringify(e[f],t+"["+f+"]",r,o,a))}return u},e.exports=function(e,t){t=t||{};var r,n,o="undefined"==typeof t.delimiter?i.delimiter:t.delimiter,a="boolean"==typeof t.strictNullHandling?t.strictNullHandling:i.strictNullHandling;"function"==typeof t.filter?(n=t.filter,e=n("",e)):Array.isArray(t.filter)&&(r=n=t.filter);var u=[];if("object"!=typeof e||null===e)return"";var s;s=t.arrayFormat in i.arrayPrefixGenerators?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":"indices";var c=i.arrayPrefixGenerators[s];r||(r=Object.keys(e));for(var l=0,f=r.length;f>l;++l){var p=r[l];u=u.concat(i.stringify(e[p],p,c,a,n))}return u.join(o)}},function(e,t){var r={};r.hexTable=new Array(256);for(var n=0;256>n;++n)r.hexTable[n]="%"+((16>n?"0":"")+n.toString(16)).toUpperCase();t.arrayToObject=function(e,t){for(var r=t.plainObjects?Object.create(null):{},n=0,i=e.length;i>n;++n)"undefined"!=typeof e[n]&&(r[n]=e[n]);return r},t.merge=function(e,r,n){if(!r)return e;if("object"!=typeof r)return Array.isArray(e)?e.push(r):"object"==typeof e?e[r]=!0:e=[e,r],e;if("object"!=typeof e)return e=[e].concat(r);Array.isArray(e)&&!Array.isArray(r)&&(e=t.arrayToObject(e,n));for(var i=Object.keys(r),o=0,a=i.length;a>o;++o){var u=i[o],s=r[u];e[u]=Object.prototype.hasOwnProperty.call(e,u)?t.merge(e[u],s,n):s}return e},t.decode=function(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(t){return e}},t.encode=function(e){if(0===e.length)return e;"string"!=typeof e&&(e=""+e);for(var t="",n=0,i=e.length;i>n;++n){var o=e.charCodeAt(n);45===o||46===o||95===o||126===o||o>=48&&57>=o||o>=65&&90>=o||o>=97&&122>=o?t+=e[n]:128>o?t+=r.hexTable[o]:2048>o?t+=r.hexTable[192|o>>6]+r.hexTable[128|63&o]:55296>o||o>=57344?t+=r.hexTable[224|o>>12]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o]:(++n,o=65536+((1023&o)<<10|1023&e.charCodeAt(n)),t+=r.hexTable[240|o>>18]+r.hexTable[128|o>>12&63]+r.hexTable[128|o>>6&63]+r.hexTable[128|63&o])}return t},t.compact=function(e,r){if("object"!=typeof e||null===e)return e;r=r||[];var n=r.indexOf(e);if(-1!==n)return r[n];if(r.push(e),Array.isArray(e)){for(var i=[],o=0,a=e.length;a>o;++o)"undefined"!=typeof e[o]&&i.push(e[o]);return i}var u=Object.keys(e);for(o=0,a=u.length;a>o;++o){var s=u[o];e[s]=t.compact(e[s],r)}return e},t.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},t.isBuffer=function(e){return null===e||"undefined"==typeof e?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}},function(e,t,r){var n=r(39),i={delimiter:"&",depth:5,arrayLimit:20,parameterLimit:1e3,strictNullHandling:!1,plainObjects:!1,allowPrototypes:!1};i.parseValues=function(e,t){for(var r={},i=e.split(t.delimiter,t.parameterLimit===1/0?void 0:t.parameterLimit),o=0,a=i.length;a>o;++o){var u=i[o],s=-1===u.indexOf("]=")?u.indexOf("="):u.indexOf("]=")+1;if(-1===s)r[n.decode(u)]="",t.strictNullHandling&&(r[n.decode(u)]=null);else{var c=n.decode(u.slice(0,s)),l=n.decode(u.slice(s+1));r[c]=Object.prototype.hasOwnProperty.call(r,c)?[].concat(r[c]).concat(l):l}}return r},i.parseObject=function(e,t,r){if(!e.length)return t;var n,o=e.shift();if("[]"===o)n=[],n=n.concat(i.parseObject(e,t,r));else{n=r.plainObjects?Object.create(null):{};var a="["===o[0]&&"]"===o[o.length-1]?o.slice(1,o.length-1):o,u=parseInt(a,10),s=""+u;!isNaN(u)&&o!==a&&s===a&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(n=[],n[u]=i.parseObject(e,t,r)):n[a]=i.parseObject(e,t,r)}return n},i.parseKeys=function(e,t,r){if(e){r.allowDots&&(e=e.replace(/\.([^\.\[]+)/g,"[$1]"));var n=/^([^\[\]]*)/,o=/(\[[^\[\]]*\])/g,a=n.exec(e),u=[];if(a[1]){if(!r.plainObjects&&Object.prototype.hasOwnProperty(a[1])&&!r.allowPrototypes)return;u.push(a[1])}for(var s=0;null!==(a=o.exec(e))&&su;++u){var c=a[u],l=i.parseKeys(c,r[c],t);o=n.merge(o,l,t)}return n.compact(o)}}]); \ No newline at end of file diff --git a/package.json b/package.json index f399df2..6ff8351 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "routux", - "version": "0.2.1", + "version": "0.2.2", "description": "A fast and productive router to improve the UX (User eXperience) of any front-end application (supports middlewares, regex pattern, named routes, error handler, ...).", + "main": "./dist/routux.min.js", "keywords": [ "router", "route", @@ -30,28 +31,28 @@ "build": "gulp dist.build && gulp test.build" }, "devDependencies": { - "babel-core": "^5.4.3", - "babel-loader": "^5.1.2", - "babel-runtime": "^5.4.3", + "babel-core": "^5.8.20", + "babel-loader": "^5.3.2", + "babel-runtime": "^5.8.20", "del": "^1.1.1", "ejs-mate": "^2.2.0", "event-stream": "^3.3.1", "gulp": "git://github.com/gulpjs/gulp.git#4.0", - "gulp-concat": "^2.5.2", + "gulp-concat": "^2.6.0", "gulp-header": "^1.2.2", "gulp-mocha": "^2.1.1", "gulp-rename": "^1.2.2", "gulp-uglify": "^1.2.0", - "gulp-webpack": "^1.4.0", + "gulp-webpack": "^1.5.0", "gulp-webserver": "^0.9.1", "lazypipe": "^0.2.3", "lodash": "^3.10.0", - "node-libs-browser": "^0.5.0", + "node-libs-browser": "^0.5.2", "phantomjs": "^1.9.17", "selenium-standalone": "^4.5.3", "unit.js": "^2.0.0", "webdriverio": "^3.1.0", - "webpack": "^1.9.6" + "webpack": "^1.10.5" }, "dependencies": { "path-to-regexp": "^1.2.0", diff --git a/src/index.js b/src/index.js index bcf14a2..b27e621 100644 --- a/src/index.js +++ b/src/index.js @@ -12,7 +12,7 @@ import Route from './Route'; import Router from './Router'; -let routux = { +var routux = { Router, Route, noConflict() { @@ -29,4 +29,4 @@ if(window) { window.routux = routux; } -module.exports = routux; \ No newline at end of file +export default routux; \ No newline at end of file