crossroads
Advanced tools
Comparing version 0.9.1 to 0.10.0
12
build.js
@@ -21,3 +21,3 @@ | ||
LICENSE : _pkg.licenses[0].type, | ||
BUILD_DATE : _now.getUTCFullYear() +'/'+ (_now.getUTCMonth() + 1) +'/'+ _now.getUTCDate() +' '+ _now.getUTCHours() +':'+ _now.getUTCMinutes() | ||
BUILD_DATE : _now.getUTCFullYear() +'/'+ pad(_now.getUTCMonth() + 1) +'/'+ pad(_now.getUTCDate()) +' '+ pad(_now.getUTCHours()) +':'+ pad(_now.getUTCMinutes()) | ||
}; | ||
@@ -85,2 +85,12 @@ | ||
function pad(val){ | ||
val = String(val); | ||
if (val.length < 2) { | ||
return '0'+ val; | ||
} else { | ||
return val; | ||
} | ||
} | ||
// --- run --- | ||
@@ -87,0 +97,0 @@ purgeDeploy(); |
# Crossroads.js Changelog # | ||
## v0.10.0 (2012/08/12) ## | ||
### Improvements | ||
- Avoid dispatching the routed/bypassed/matched signals if passing same | ||
request in subsequent calls. (#57) | ||
- Add `crossroads.resetState()` (#66) | ||
## v0.9.1 (2012/07/29) ## | ||
@@ -5,0 +14,0 @@ |
@@ -5,3 +5,3 @@ /** @license | ||
* Author: Miller Medeiros | ||
* Version: 0.9.1 (2012/7/29 15:56) | ||
* Version: 0.10.0 (2012/08/12 03:41) | ||
*/ | ||
@@ -106,6 +106,7 @@ | ||
function Crossroads() { | ||
this.bypassed = new signals.Signal(); | ||
this.routed = new signals.Signal(); | ||
this._routes = []; | ||
this._prevRoutes = []; | ||
this.bypassed = new signals.Signal(); | ||
this.routed = new signals.Signal(); | ||
this.resetState(); | ||
} | ||
@@ -115,2 +116,8 @@ | ||
resetState : function(){ | ||
this._prevRoutes.length = 0; | ||
this._prevMatchedRequest = null; | ||
this._prevBypassedRequest = null; | ||
}, | ||
greedy : false, | ||
@@ -154,2 +161,7 @@ | ||
// should only care about different requests | ||
if (request === this._prevMatchedRequest || request === this._prevBypassedRequest) { | ||
return; | ||
} | ||
var routes = this._getMatchedRoutes(request), | ||
@@ -161,5 +173,7 @@ i = 0, | ||
if (n) { | ||
this._prevMatchedRequest = request; | ||
this._notifyPrevRoutes(routes, request); | ||
this._prevRoutes = routes; | ||
//shold be incremental loop, execute routes in order | ||
//should be incremental loop, execute routes in order | ||
while (i < n) { | ||
@@ -173,4 +187,6 @@ cur = routes[i]; | ||
} else { | ||
this._prevBypassedRequest = request; | ||
this.bypassed.dispatch.apply(this.bypassed, defaultArgs.concat([request])); | ||
} | ||
}, | ||
@@ -239,3 +255,3 @@ | ||
crossroads = new Crossroads(); | ||
crossroads.VERSION = '0.9.1'; | ||
crossroads.VERSION = '0.10.0'; | ||
@@ -242,0 +258,0 @@ crossroads.NORM_AS_ARRAY = function (req, vals) { |
@@ -5,4 +5,4 @@ /** @license | ||
* Author: Miller Medeiros | ||
* Version: 0.9.1 (2012/7/29 15:56) | ||
* Version: 0.10.0 (2012/08/12 03:41) | ||
*/ | ||
(function(a){a(["signals"],function(a){function e(a,b){if(a.indexOf)return a.indexOf(b);var c=a.length;while(c--)if(a[c]===b)return c;return-1}function f(a,b){return"[object "+b+"]"===Object.prototype.toString.call(a)}function g(a){return f(a,"RegExp")}function h(a){return f(a,"Array")}function i(a){return typeof a=="function"}function j(a){var b;return a===null||a==="null"?b=null:a==="true"?b=!0:a==="false"?b=!1:a===d||a==="undefined"?b=d:a===""||isNaN(a)?b=a:b=parseFloat(a),b}function k(a){var b=a.length,c=[];while(b--)c[b]=j(a[b]);return c}function l(a){var b=(a||"").replace("?","").split("&"),c=b.length,d={},e,f;while(c--)e=b[c].split("="),f=j(e[1]),d[e[0]]=typeof f=="string"?decodeURIComponent(f):f;return d}function m(){this._routes=[],this._prevRoutes=[],this.bypassed=new a.Signal,this.routed=new a.Signal}function n(c,d,e,f){var h=g(c),i=b.patternLexer;this._router=f,this._pattern=c,this._paramsIds=h?null:i.getParamIds(c),this._optionalParamsIds=h?null:i.getOptionalParamsIds(c),this._matchRegexp=h?c:i.compilePattern(c),this.matched=new a.Signal,this.switched=new a.Signal,d&&this.matched.add(d),this._priority=e||0}var b,c,d;return c=/t(.+)?/.exec("t")[1]==="",m.prototype={greedy:!1,greedyEnabled:!0,normalizeFn:null,create:function(){return new m},shouldTypecast:!1,addRoute:function(a,b,c){var d=new n(a,b,c,this);return this._sortedInsert(d),d},removeRoute:function(a){var b=e(this._routes,a);b!==-1&&this._routes.splice(b,1),a._destroy()},removeAllRoutes:function(){var a=this.getNumRoutes();while(a--)this._routes[a]._destroy();this._routes.length=0},parse:function(a,b){a=a||"",b=b||[];var c=this._getMatchedRoutes(a),d=0,e=c.length,f;if(e){this._notifyPrevRoutes(c,a),this._prevRoutes=c;while(d<e)f=c[d],f.route.matched.dispatch.apply(f.route.matched,b.concat(f.params)),f.isFirst=!d,this.routed.dispatch.apply(this.routed,b.concat([a,f])),d+=1}else this.bypassed.dispatch.apply(this.bypassed,b.concat([a]))},_notifyPrevRoutes:function(a,b){var c=0,d;while(d=this._prevRoutes[c++])d.route.switched&&this._didSwitch(d.route,a)&&d.route.switched.dispatch(b)},_didSwitch:function(a,b){var c,d=0;while(c=b[d++])if(c.route===a)return!1;return!0},getNumRoutes:function(){return this._routes.length},_sortedInsert:function(a){var b=this._routes,c=b.length;do--c;while(b[c]&&a._priority<=b[c]._priority);b.splice(c+1,0,a)},_getMatchedRoutes:function(a){var b=[],c=this._routes,d=c.length,e;while(e=c[--d]){(!b.length||this.greedy||e.greedy)&&e.match(a)&&b.push({route:e,params:e._getParamsArray(a)});if(!this.greedyEnabled&&b.length)break}return b},toString:function(){return"[crossroads numRoutes:"+this.getNumRoutes()+"]"}},b=new m,b.VERSION="0.9.1",b.NORM_AS_ARRAY=function(a,b){return[b.vals_]},b.NORM_AS_OBJECT=function(a,b){return[b]},n.prototype={greedy:!1,rules:void 0,match:function(a){return a=a||"",this._matchRegexp.test(a)&&this._validateParams(a)},_validateParams:function(a){var b=this.rules,c=this._getParamsObject(a),d;for(d in b)if(d!=="normalize_"&&b.hasOwnProperty(d)&&!this._isValidParam(a,d,c))return!1;return!0},_isValidParam:function(a,b,c){var d=this.rules[b],f=c[b],j=!1,k=b.indexOf("?")===0;return f==null&&this._optionalParamsIds&&e(this._optionalParamsIds,b)!==-1?j=!0:g(d)?(k&&(f=c[b+"_"]),j=d.test(f)):h(d)?(k&&(f=c[b+"_"]),j=e(d,f)!==-1):i(d)&&(j=d(f,a,c)),j},_getParamsObject:function(a){var d=this._router.shouldTypecast,f=b.patternLexer.getParamValues(a,this._matchRegexp,d),g={},h=f.length,i,k;while(h--)k=f[h],this._paramsIds&&(i=this._paramsIds[h],i.indexOf("?")===0&&k&&(g[i+"_"]=k,k=l(k),f[h]=k),c&&k===""&&e(this._optionalParamsIds,i)!==-1&&(k=void 0,f[h]=k),g[i]=k),g[h]=k;return g.request_=d?j(a):a,g.vals_=f,g},_getParamsArray:function(a){var b=this.rules?this.rules.normalize_:null,c;return b=b||this._router.normalizeFn,b&&i(b)?c=b(a,this._getParamsObject(a)):c=this._getParamsObject(a).vals_,c},interpolate:function(a){var c=b.patternLexer.interpolate(this._pattern,a);if(!this._validateParams(c))throw new Error("Generated string doesn't validate against `Route.rules`.");return c},dispose:function(){this._router.removeRoute(this)},_destroy:function(){this.matched.dispose(),this.switched.dispose(),this.matched=this.switched=this._pattern=this._matchRegexp=null},toString:function(){return'[Route pattern:"'+this._pattern+'", numListeners:'+this.matched.getNumListeners()+"]"}},b.patternLexer=function(){function j(){var a,b;for(a in e)e.hasOwnProperty(a)&&(b=e[a],b.id="__CR_"+a+"__",b.save="save"in b?b.save.replace("{{id}}",b.id):b.id,b.rRestore=new RegExp(b.id,"g"))}function l(a,b){var c=[],d;a.lastIndex=0;while(d=a.exec(b))c.push(d[1]);return c}function m(a){return l(d,a)}function n(a){return l(e.OP.rgx,a)}function o(d){return d=d||"",d&&(i===f?d=d.replace(b,""):i===h&&(d=d.replace(c,"")),d=p(d,"rgx","save"),d=d.replace(a,"\\$&"),d=p(d,"rRestore","res"),i===f&&(d="\\/?"+d)),i!==g&&(d+="\\/?"),new RegExp("^"+d+"$")}function p(a,b,c){var d,f;for(f in e)e.hasOwnProperty(f)&&(d=e[f],a=a.replace(d[b],d[c]));return a}function q(a,b,c){var d=b.exec(a);return d&&(d.shift(),c&&(d=k(d))),d}function r(a,b){if(typeof a!="string")throw new Error("Route pattern should be a string.");var c=function(a,c){var d;if(c in b){d=String(b[c]);if(a.indexOf("*")===-1&&d.indexOf("/")!==-1)throw new Error('Invalid value "'+d+'" for segment "'+a+'".')}else{if(a.indexOf("{")!==-1)throw new Error("The segment "+a+" is required.");d=""}return d};return e.OS.trail||(e.OS.trail=new RegExp("(?:"+e.OS.id+")+$")),a.replace(e.OS.rgx,e.OS.save).replace(d,c).replace(e.OS.trail,"").replace(e.OS.rRestore,"/")}var a=/[\\.+*?\^$\[\](){}\/'#]/g,b=/^\/|\/$/g,c=/\/$/g,d=/(?:\{|:)([^}:]+)(?:\}|:)/g,e={OS:{rgx:/([:}]|\w(?=\/))\/?(:|(?:\{\?))/g,save:"$1{{id}}$2",res:"\\/?"},RS:{rgx:/([:}])\/?(\{)/g,save:"$1{{id}}$2",res:"\\/"},RQ:{rgx:/\{\?([^}]+)\}/g,res:"\\?([^#]+)"},OQ:{rgx:/:\?([^:]+):/g,res:"(?:\\?([^#]*))?"},OR:{rgx:/:([^:]+)\*:/g,res:"(.*)?"},RR:{rgx:/\{([^}]+)\*\}/g,res:"(.+)"},RP:{rgx:/\{([^}]+)\}/g,res:"([^\\/?]+)"},OP:{rgx:/:([^:]+):/g,res:"([^\\/?]+)?/?"}},f=1,g=2,h=3,i=f;return j(),{strict:function(){i=g},loose:function(){i=f},legacy:function(){i=h},getParamIds:m,getOptionalParamsIds:n,getParamValues:q,compilePattern:o,interpolate:r}}(),b})})(typeof define=="function"&&define.amd?define:function(a,b){typeof module!="undefined"&&module.exports?module.exports=b(require(a[0])):window.crossroads=b(window[a[0]])}) | ||
(function(a){a(["signals"],function(a){function e(a,b){if(a.indexOf)return a.indexOf(b);var c=a.length;while(c--)if(a[c]===b)return c;return-1}function f(a,b){return"[object "+b+"]"===Object.prototype.toString.call(a)}function g(a){return f(a,"RegExp")}function h(a){return f(a,"Array")}function i(a){return typeof a=="function"}function j(a){var b;return a===null||a==="null"?b=null:a==="true"?b=!0:a==="false"?b=!1:a===d||a==="undefined"?b=d:a===""||isNaN(a)?b=a:b=parseFloat(a),b}function k(a){var b=a.length,c=[];while(b--)c[b]=j(a[b]);return c}function l(a){var b=(a||"").replace("?","").split("&"),c=b.length,d={},e,f;while(c--)e=b[c].split("="),f=j(e[1]),d[e[0]]=typeof f=="string"?decodeURIComponent(f):f;return d}function m(){this.bypassed=new a.Signal,this.routed=new a.Signal,this._routes=[],this._prevRoutes=[],this.resetState()}function n(c,d,e,f){var h=g(c),i=b.patternLexer;this._router=f,this._pattern=c,this._paramsIds=h?null:i.getParamIds(c),this._optionalParamsIds=h?null:i.getOptionalParamsIds(c),this._matchRegexp=h?c:i.compilePattern(c),this.matched=new a.Signal,this.switched=new a.Signal,d&&this.matched.add(d),this._priority=e||0}var b,c,d;return c=/t(.+)?/.exec("t")[1]==="",m.prototype={resetState:function(){this._prevRoutes.length=0,this._prevMatchedRequest=null,this._prevBypassedRequest=null},greedy:!1,greedyEnabled:!0,normalizeFn:null,create:function(){return new m},shouldTypecast:!1,addRoute:function(a,b,c){var d=new n(a,b,c,this);return this._sortedInsert(d),d},removeRoute:function(a){var b=e(this._routes,a);b!==-1&&this._routes.splice(b,1),a._destroy()},removeAllRoutes:function(){var a=this.getNumRoutes();while(a--)this._routes[a]._destroy();this._routes.length=0},parse:function(a,b){a=a||"",b=b||[];if(a===this._prevMatchedRequest||a===this._prevBypassedRequest)return;var c=this._getMatchedRoutes(a),d=0,e=c.length,f;if(e){this._prevMatchedRequest=a,this._notifyPrevRoutes(c,a),this._prevRoutes=c;while(d<e)f=c[d],f.route.matched.dispatch.apply(f.route.matched,b.concat(f.params)),f.isFirst=!d,this.routed.dispatch.apply(this.routed,b.concat([a,f])),d+=1}else this._prevBypassedRequest=a,this.bypassed.dispatch.apply(this.bypassed,b.concat([a]))},_notifyPrevRoutes:function(a,b){var c=0,d;while(d=this._prevRoutes[c++])d.route.switched&&this._didSwitch(d.route,a)&&d.route.switched.dispatch(b)},_didSwitch:function(a,b){var c,d=0;while(c=b[d++])if(c.route===a)return!1;return!0},getNumRoutes:function(){return this._routes.length},_sortedInsert:function(a){var b=this._routes,c=b.length;do--c;while(b[c]&&a._priority<=b[c]._priority);b.splice(c+1,0,a)},_getMatchedRoutes:function(a){var b=[],c=this._routes,d=c.length,e;while(e=c[--d]){(!b.length||this.greedy||e.greedy)&&e.match(a)&&b.push({route:e,params:e._getParamsArray(a)});if(!this.greedyEnabled&&b.length)break}return b},toString:function(){return"[crossroads numRoutes:"+this.getNumRoutes()+"]"}},b=new m,b.VERSION="0.10.0",b.NORM_AS_ARRAY=function(a,b){return[b.vals_]},b.NORM_AS_OBJECT=function(a,b){return[b]},n.prototype={greedy:!1,rules:void 0,match:function(a){return a=a||"",this._matchRegexp.test(a)&&this._validateParams(a)},_validateParams:function(a){var b=this.rules,c=this._getParamsObject(a),d;for(d in b)if(d!=="normalize_"&&b.hasOwnProperty(d)&&!this._isValidParam(a,d,c))return!1;return!0},_isValidParam:function(a,b,c){var d=this.rules[b],f=c[b],j=!1,k=b.indexOf("?")===0;return f==null&&this._optionalParamsIds&&e(this._optionalParamsIds,b)!==-1?j=!0:g(d)?(k&&(f=c[b+"_"]),j=d.test(f)):h(d)?(k&&(f=c[b+"_"]),j=e(d,f)!==-1):i(d)&&(j=d(f,a,c)),j},_getParamsObject:function(a){var d=this._router.shouldTypecast,f=b.patternLexer.getParamValues(a,this._matchRegexp,d),g={},h=f.length,i,k;while(h--)k=f[h],this._paramsIds&&(i=this._paramsIds[h],i.indexOf("?")===0&&k&&(g[i+"_"]=k,k=l(k),f[h]=k),c&&k===""&&e(this._optionalParamsIds,i)!==-1&&(k=void 0,f[h]=k),g[i]=k),g[h]=k;return g.request_=d?j(a):a,g.vals_=f,g},_getParamsArray:function(a){var b=this.rules?this.rules.normalize_:null,c;return b=b||this._router.normalizeFn,b&&i(b)?c=b(a,this._getParamsObject(a)):c=this._getParamsObject(a).vals_,c},interpolate:function(a){var c=b.patternLexer.interpolate(this._pattern,a);if(!this._validateParams(c))throw new Error("Generated string doesn't validate against `Route.rules`.");return c},dispose:function(){this._router.removeRoute(this)},_destroy:function(){this.matched.dispose(),this.switched.dispose(),this.matched=this.switched=this._pattern=this._matchRegexp=null},toString:function(){return'[Route pattern:"'+this._pattern+'", numListeners:'+this.matched.getNumListeners()+"]"}},b.patternLexer=function(){function j(){var a,b;for(a in e)e.hasOwnProperty(a)&&(b=e[a],b.id="__CR_"+a+"__",b.save="save"in b?b.save.replace("{{id}}",b.id):b.id,b.rRestore=new RegExp(b.id,"g"))}function l(a,b){var c=[],d;a.lastIndex=0;while(d=a.exec(b))c.push(d[1]);return c}function m(a){return l(d,a)}function n(a){return l(e.OP.rgx,a)}function o(d){return d=d||"",d&&(i===f?d=d.replace(b,""):i===h&&(d=d.replace(c,"")),d=p(d,"rgx","save"),d=d.replace(a,"\\$&"),d=p(d,"rRestore","res"),i===f&&(d="\\/?"+d)),i!==g&&(d+="\\/?"),new RegExp("^"+d+"$")}function p(a,b,c){var d,f;for(f in e)e.hasOwnProperty(f)&&(d=e[f],a=a.replace(d[b],d[c]));return a}function q(a,b,c){var d=b.exec(a);return d&&(d.shift(),c&&(d=k(d))),d}function r(a,b){if(typeof a!="string")throw new Error("Route pattern should be a string.");var c=function(a,c){var d;if(c in b){d=String(b[c]);if(a.indexOf("*")===-1&&d.indexOf("/")!==-1)throw new Error('Invalid value "'+d+'" for segment "'+a+'".')}else{if(a.indexOf("{")!==-1)throw new Error("The segment "+a+" is required.");d=""}return d};return e.OS.trail||(e.OS.trail=new RegExp("(?:"+e.OS.id+")+$")),a.replace(e.OS.rgx,e.OS.save).replace(d,c).replace(e.OS.trail,"").replace(e.OS.rRestore,"/")}var a=/[\\.+*?\^$\[\](){}\/'#]/g,b=/^\/|\/$/g,c=/\/$/g,d=/(?:\{|:)([^}:]+)(?:\}|:)/g,e={OS:{rgx:/([:}]|\w(?=\/))\/?(:|(?:\{\?))/g,save:"$1{{id}}$2",res:"\\/?"},RS:{rgx:/([:}])\/?(\{)/g,save:"$1{{id}}$2",res:"\\/"},RQ:{rgx:/\{\?([^}]+)\}/g,res:"\\?([^#]+)"},OQ:{rgx:/:\?([^:]+):/g,res:"(?:\\?([^#]*))?"},OR:{rgx:/:([^:]+)\*:/g,res:"(.*)?"},RR:{rgx:/\{([^}]+)\*\}/g,res:"(.+)"},RP:{rgx:/\{([^}]+)\}/g,res:"([^\\/?]+)"},OP:{rgx:/:([^:]+):/g,res:"([^\\/?]+)?/?"}},f=1,g=2,h=3,i=f;return j(),{strict:function(){i=g},loose:function(){i=f},legacy:function(){i=h},getParamIds:m,getOptionalParamsIds:n,getParamValues:q,compilePattern:o,interpolate:r}}(),b})})(typeof define=="function"&&define.amd?define:function(a,b){typeof module!="undefined"&&module.exports?module.exports=b(require(a[0])):window.crossroads=b(window[a[0]])}) |
@@ -6,3 +6,3 @@ { | ||
"homepage" : "http://millermedeiros.github.com/crossroads.js/", | ||
"version" : "0.9.1", | ||
"version" : "0.10.0", | ||
"author" : { | ||
@@ -28,3 +28,6 @@ "name" : "Miller Medeiros", | ||
"signals" : "*" | ||
}, | ||
"devDependencies" : { | ||
"uglify-js" : "~1.2.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42017
11563
625
1