Comparing version 1.2.4 to 1.2.5
@@ -16,3 +16,3 @@ "use strict"; | ||
var Transition = require("./transition").Transition; | ||
var TransitionAborted = require("./transition").TransitionAborted; | ||
var TransitionAbortedError = require("./transition-aborted-error")["default"]; | ||
var NamedTransitionIntent = require("./transition-intent/named-transition-intent")["default"]; | ||
@@ -509,3 +509,3 @@ var URLTransitionIntent = require("./transition-intent/url-transition-intent")["default"]; | ||
if (transition && transition.isAborted) { | ||
throw new TransitionAborted(); | ||
throw new TransitionAbortedError(); | ||
} | ||
@@ -518,3 +518,3 @@ | ||
if (transition && transition.isAborted) { | ||
throw new TransitionAborted(); | ||
throw new TransitionAbortedError(); | ||
} | ||
@@ -711,3 +711,3 @@ | ||
} catch(e) { | ||
if (!((e instanceof TransitionAborted))) { | ||
if (!((e instanceof TransitionAbortedError))) { | ||
//var erroneousHandler = handlerInfos.pop(); | ||
@@ -714,0 +714,0 @@ var infos = transition.state.handlerInfos; |
@@ -7,2 +7,3 @@ "use strict"; | ||
var promiseLabel = require("./utils").promiseLabel; | ||
var TransitionAbortedError = require("./transition-aborted-error")["default"]; | ||
@@ -333,16 +334,11 @@ /** | ||
Logs and returns a TransitionAborted error. | ||
Logs and returns an instance of TransitionAbortedError. | ||
*/ | ||
function logAbort(transition) { | ||
log(transition.router, transition.sequence, "detected abort."); | ||
return new TransitionAborted(); | ||
return new TransitionAbortedError(); | ||
} | ||
function TransitionAborted(message) { | ||
this.message = (message || "TransitionAborted"); | ||
this.name = "TransitionAborted"; | ||
} | ||
exports.Transition = Transition; | ||
exports.logAbort = logAbort; | ||
exports.TransitionAborted = TransitionAborted; | ||
exports.TransitionAbortedError = TransitionAbortedError; |
"use strict"; | ||
var oCreate = require("./utils").oCreate; | ||
/** | ||
Promise reject reasons passed to promise rejection | ||
handlers for failed transitions. | ||
*/ | ||
function UnrecognizedURLError(message) { | ||
this.message = (message || "UnrecognizedURLError"); | ||
this.name = "UnrecognizedURLError"; | ||
Error.call(this); | ||
if (!(this instanceof UnrecognizedURLError)) { | ||
return new UnrecognizedURLError(message); | ||
} | ||
var error = Error.call(this, message); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, UnrecognizedURLError); | ||
} else { | ||
this.stack = error.stack; | ||
} | ||
this.description = error.description; | ||
this.fileName = error.fileName; | ||
this.lineNumber = error.lineNumber; | ||
this.message = error.message || 'UnrecognizedURL'; | ||
this.name = 'UnrecognizedURLError'; | ||
this.number = error.number; | ||
this.code = error.code; | ||
} | ||
@@ -13,0 +25,0 @@ |
@@ -1,1 +0,1 @@ | ||
(function(e,r,t){var n,i,a,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=a=i=function(t){if(r[t]){return r[t]}r[t]={};if(!e[t]){throw new Error("Could not find module "+t)}var n=e[t],a=n.deps,s=n.callback,o=[],l;for(var u=0,h=a.length;u<h;u++){if(a[u]==="exports"){o.push(l={})}else{o.push(i(d(a[u])))}}var f=s.apply(this,o);return r[t]=l||f;function d(e){if(e.charAt(0)!=="."){return e}var r=e.split("/");var n=t.split("/").slice(0,-1);for(var i=0,a=r.length;i<a;i++){var s=r[i];if(s===".."){n.pop()}else if(s==="."){continue}else{n.push(s)}}return n.join("/")}}})();n("router/handler-info",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.bind;var i=e.merge;var a=e.promiseLabel;var s=e.applyHook;var o=e.isPromise;var l=r.Promise;var u=Object.freeze({});function h(e){var r=e||{};this._handler=u;if(r.handler){var t=r.name;this.handlerPromise=l.resolve(r.handler);if(o(r.handler)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler));r.handler=undefined}else if(r.handler){r.handler._handlerName=t}}i(this,r);this.initialize(r)}h.prototype={name:null,getHandler:function(){},fetchHandler:function(){var e=this.getHandler(this.name);this.handlerPromise=l.resolve(e);if(o(e)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler))}else if(e){e._handlerName=this.name;return this.handler=e}return this.handler=undefined},_handlerPromise:undefined,params:null,context:null,factory:null,initialize:function(){},log:function(e,r){if(e.log){e.log(this.name+": "+r)}},promiseLabel:function(e){return a("'"+this.name+"' "+e)},getUnresolved:function(){return this},serialize:function(){return this.params||{}},updateHandler:function(e){e._handlerName=this.name;return this.handler=e},resolve:function(e,r){var t=n(this,this.checkForAbort,e),i=n(this,this.runBeforeModelHook,r),a=n(this,this.getModel,r),s=n(this,this.runAfterModelHook,r),o=n(this,this.becomeResolved,r),u=this;return l.resolve(this.handlerPromise,this.promiseLabel("Start handler")).then(function(e){return l.resolve(e).then(t,null,u.promiseLabel("Check for abort")).then(i,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(a,null,u.promiseLabel("Model")).then(t,null,u.promiseLabel("Check if aborted in 'model' hook")).then(s,null,u.promiseLabel("After model")).then(t,null,u.promiseLabel("Check if aborted in 'afterModel' hook")).then(o,null,u.promiseLabel("Become resolved"))},function(e){throw e})},runBeforeModelHook:function(e){if(e.trigger){e.trigger(true,"willResolveModel",e,this.handler)}return this.runSharedModelHook(e,"beforeModel",[])},runAfterModelHook:function(e,r){var t=this.name;this.stashResolvedModel(e,r);return this.runSharedModelHook(e,"afterModel",[r]).then(function(){return e.resolvedModels[t]},null,this.promiseLabel("Ignore fulfillment value and return model value"))},runSharedModelHook:function(e,r,t){this.log(e,"calling "+r+" hook");if(this.queryParams){t.push(this.queryParams)}t.push(e);var n=s(this.handler,r,t);if(n&&n.isTransition){n=null}return l.resolve(n,this.promiseLabel("Resolve value returned from one of the model hooks"))},getModel:null,checkForAbort:function(e,r){return l.resolve(e(),this.promiseLabel("Check for abort")).then(function(){return r},null,this.promiseLabel("Ignore fulfillment value and continue"))},stashResolvedModel:function(e,r){e.resolvedModels=e.resolvedModels||{};e.resolvedModels[this.name]=r},becomeResolved:function(e,r){var t=this.serialize(r);if(e){this.stashResolvedModel(e,r);e.params=e.params||{};e.params[this.name]=t}return this.factory("resolved",{context:r,name:this.name,handler:this.handler,params:t})},shouldSupercede:function(e){if(!e){return true}var r=e.context===this.context;return e.name!==this.name||this.hasOwnProperty("context")&&!r||this.hasOwnProperty("params")&&!f(this.params,e.params)}};Object.defineProperty(h.prototype,"handler",{get:function(){if(this._handler!==u){return this._handler}return this.fetchHandler()},set:function(e){return this._handler=e}});Object.defineProperty(h.prototype,"handlerPromise",{get:function(){if(this._handlerPromise){return this._handlerPromise}this.fetchHandler();return this._handlerPromise},set:function(e){return this._handlerPromise=e}});function f(e,r){if(!e^!r){return false}if(!e){return true}for(var t in e){if(e.hasOwnProperty(t)&&e[t]!==r[t]){return false}}return true}t["default"]=h});n("router/handler-info/factory",["./resolved-handler-info","./unresolved-handler-info-by-object","./unresolved-handler-info-by-param","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r["default"];var s=t["default"];o.klasses={resolved:i,param:s,object:a};function o(e,r){var t=o.klasses[e],n=new t(r||{});n.factory=o;return n}n["default"]=o});n("router/handler-info/resolved-handler-info",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=t.Promise;var o=a(i,{resolve:function(e,r){if(r&&r.resolvedModels){r.resolvedModels[this.name]=this.context}return s.resolve(this,this.promiseLabel("Resolve"))},getUnresolved:function(){return this.factory("param",{name:this.name,handler:this.handler,params:this.params})},isResolved:true});n["default"]=o});n("router/handler-info/unresolved-handler-info-by-object",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=r.isParam;var o=t.Promise;var l=a(i,{getModel:function(e){this.log(e,this.name+": resolving provided model");return o.resolve(this.context)},initialize:function(e){this.names=e.names||[];this.context=e.context},serialize:function(e){var r=e||this.context,t=this.names,n=this.serializer||this.handler&&this.handler.serialize;var i={};if(s(r)){i[t[0]]=r;return i}if(n){return n(r,t)}if(t.length!==1){return}var a=t[0];if(/_id$/.test(a)){i[a]=r.id}else{i[a]=r}return i}});n["default"]=l});n("router/handler-info/unresolved-handler-info-by-param",["../handler-info","../utils","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.resolveHook;var a=r.merge;var s=r.subclass;var o=s(n,{initialize:function(e){this.params=e.params||{}},getModel:function(e){var r=this.params;if(e&&e.queryParams){r={};a(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=i(t,"deserialize")||i(t,"model");return this.runSharedModelHook(e,n,[r])}});t["default"]=o});n("router/router",["route-recognizer","rsvp","./utils","./transition-state","./transition","./transition-intent/named-transition-intent","./transition-intent/url-transition-intent","exports"],function(e,r,t,n,i,a,s,o){"use strict";var l=e["default"];var u=r.Promise;var h=t.trigger;var f=t.log;var d=t.slice;var c=t.forEach;var v=t.merge;var m=t.extractQueryParams;var p=t.getChangelist;var g=t.promiseLabel;var y=t.callHook;var b=n["default"];var P=i.logAbort;var I=i.Transition;var w=i.TransitionAborted;var x=a["default"];var T=s["default"];var H=Array.prototype.pop;function q(e){var r=e||{};this.getHandler=r.getHandler||this.getHandler;this.getSerializer=r.getSerializer||this.getSerializer;this.updateURL=r.updateURL||this.updateURL;this.replaceURL=r.replaceURL||this.replaceURL;this.didTransition=r.didTransition||this.didTransition;this.willTransition=r.willTransition||this.willTransition;this.delegate=r.delegate||this.delegate;this.triggerEvent=r.triggerEvent||this.triggerEvent;this.log=r.log||this.log;this.dslCallBacks=[];this.state=undefined;this.activeTransition=undefined;this._changedQueryParams=undefined;this.oldState=undefined;this.currentHandlerInfos=undefined;this.state=undefined;this.currentSequence=0;this.recognizer=new l;this.reset()}function L(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var i;var a=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=p(n.queryParams,a.queryParams);if(U(a.handlerInfos,n.handlerInfos)){if(s){i=this.queryParamsTransition(s,t,n,a);if(i){return i}}return this.activeTransition||new I(this)}if(r){R(this,a);return}i=new I(this,e,a,undefined,this.activeTransition);if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=i;i.promise=i.promise.then(function(e){return M(i,e.state)},null,g("Settle transition promise when transition is finalized"));if(!t){j(this,a,i)}z(this,a,s);return i}q.prototype={map:function(e){this.recognizer.delegate=this.delegate;this.recognizer.map(e,function(e,r){for(var t=r.length-1,n=true;t>=0&&n;--t){var i=r[t];e.add(r,{as:i.handler});n=i.path==="/"||i.path===""||i.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var i=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var a=new I(this);a.queryParamsOnly=true;t.queryParams=E(this,n.handlerInfos,n.queryParams,a);a.promise=a.promise.then(function(e){k(a,t,true);if(i.didTransition){i.didTransition(i.currentHandlerInfos)}return e},null,g("Transition complete"));return a}},transitionByIntent:function(e){try{return L.apply(this,arguments)}catch(r){return new I(this,e,null,r)}},reset:function(){if(this.state){c(this.state.handlerInfos.slice().reverse(),function(e){var r=e.handler;y(r,"exit")})}this.oldState=undefined;this.state=new b;this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var r=d.call(arguments);if(e.charAt(0)!=="/"){r[0]="/"+e}return C(this,r).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return C(this,arguments)},intermediateTransitionTo:function(){return C(this,arguments,true)},refresh:function(e){var r=this.activeTransition?this.activeTransition.state:this.state;var t=r.handlerInfos;var n={};for(var i=0,a=t.length;i<a;++i){var s=t[i];n[s.name]=s.params||{}}f(this,"Starting a refresh transition");var o=new x({name:t[t.length-1].name,pivotHandler:e||t[0].handler,contexts:[],queryParams:this._changedQueryParams||r.queryParams||{}});return this.transitionByIntent(o,false)},replaceWith:function(){return C(this,arguments).method("replace")},generate:function(e){var r=m(d.call(arguments,1)),t=r[0],n=r[1];var i=new x({name:e,contexts:t});var a=i.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=a.handlerInfos.length;o<l;++o){var u=a.handlerInfos[o];var h=u.serialize();v(s,h)}s.queryParams=n;return this.recognizer.generate(e,s)},applyIntent:function(e,r){var t=new x({name:e,contexts:r});var n=this.activeTransition&&this.activeTransition.state||this.state;return t.applyToState(n,this.recognizer,this.getHandler,null,this.getSerializer)},isActiveIntent:function(e,r,t,n){var i=n||this.state,a=i.handlerInfos,s,o;if(!a.length){return false}var l=a[a.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=a[h];if(s.name===e){break}}if(h===u.length){return false}var f=new b;f.handlerInfos=a.slice(0,h+1);u=u.slice(0,h+1);var d=new x({name:l,contexts:r});var c=d.applyToHandlers(f,u,this.getHandler,l,true,true,this.getSerializer);var m=U(c.handlerInfos,f.handlerInfos);if(!t||!m){return m}var g={};v(g,t);var y=i.queryParams;for(var P in y){if(y.hasOwnProperty(P)&&g.hasOwnProperty(P)){g[P]=y[P]}}return m&&!p(g,t)},isActive:function(e){var r=m(d.call(arguments,1));return this.isActiveIntent(e,r[0],r[1])},trigger:function(){var e=d.call(arguments);h(this,this.currentHandlerInfos,false,e)},log:null};function z(e,r,t){if(t){e._changedQueryParams=t.all;h(e,r.handlerInfos,true,["queryParamsDidChange",t.changed,t.all,t.removed]);e._changedQueryParams=null}}function R(e,r,t){var n=S(e.state,r);var i,a,s;for(i=0,a=n.exited.length;i<a;i++){s=n.exited[i].handler;delete s.context;y(s,"reset",true,t);y(s,"exit",t)}var o=e.oldState=e.state;e.state=r;var l=e.currentHandlerInfos=n.unchanged.slice();try{for(i=0,a=n.reset.length;i<a;i++){s=n.reset[i].handler;y(s,"reset",false,t)}for(i=0,a=n.updatedContext.length;i<a;i++){A(l,n.updatedContext[i],false,t)}for(i=0,a=n.entered.length;i<a;i++){A(l,n.entered[i],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=E(e,l,r.queryParams,t)}function A(e,r,t,n){var i=r.handler,a=r.context;function s(i){if(t){y(i,"enter",n)}if(n&&n.isAborted){throw new w}i.context=a;y(i,"contextDidChange");y(i,"setup",a,n);if(n&&n.isAborted){throw new w}e.push(r)}if(!i){r.handlerPromise=r.handlerPromise.then(s)}else{s(i)}return true}function S(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var i={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var a,s=false,o,l;for(o=0,l=n.length;o<l;o++){var u=t[o],h=n[o];if(!u||u.handler!==h.handler){a=true}if(a){i.entered.push(h);if(u){i.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;i.updatedContext.push(h)}else{i.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){i.exited.unshift(t[o])}i.reset=i.updatedContext.slice();i.reset.reverse();return i}function k(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,i=r.handlerInfos,a=i[i.length-1].name,s={};for(var o=i.length-1;o>=0;--o){var l=i[o];v(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(a,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;if(h||f){n.replaceURL(u)}else{n.updateURL(u)}}}function M(e,r){try{f(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var t=e.router,n=r.handlerInfos;R(t,r,e);if(e.isAborted){t.state.handlerInfos=t.currentHandlerInfos;return u.reject(P(e))}k(e,r,e.intent.url);e.isActive=false;t.activeTransition=null;h(t,t.currentHandlerInfos,true,["didTransition"]);if(t.didTransition){t.didTransition(t.currentHandlerInfos)}f(t,e.sequence,"TRANSITION COMPLETE.");return n[n.length-1].handler}catch(i){if(!((i instanceof w))){var a=e.state.handlerInfos;e.trigger(true,"error",i,e,a[a.length-1].handler);e.abort()}throw i}}function C(e,r,t){var n=r[0]||"/";var i=r[r.length-1];var a={};if(i&&i.hasOwnProperty("queryParams")){a=H.call(r).queryParams}var s;if(r.length===0){f(e,"Updating query params");var o=e.state.handlerInfos;s=new x({name:o[o.length-1].name,contexts:[],queryParams:a})}else if(n.charAt(0)==="/"){f(e,"Attempting URL transition to "+n);s=new T({url:n})}else{f(e,"Attempting transition to "+n);s=new x({name:r[0],contexts:d.call(r,1),queryParams:a})}return e.transitionByIntent(s,t)}function U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t]!==r[t]){return false}}return true}function E(e,r,t,n){for(var i in t){if(t.hasOwnProperty(i)&&t[i]===null){delete t[i]}}var a=[];h(e,r,true,["finalizeQueryParamChange",t,a,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=a.length;o<l;++o){var u=a[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function j(e,r,t){var n=e.state.handlerInfos,i=[],a=null,s,o,l,u,f,d;u=n.length;for(l=0;l<u;l++){f=n[l];d=r.handlerInfos[l];if(!d||f.name!==d.name){a=l;break}if(!d.isResolved){i.push(f)}}if(a!==null){s=n.slice(a,u);o=function(e){for(var r=0,t=s.length;r<t;r++){if(s[r].name===e){return true}}return false}}h(e,n,true,["willTransition",t]);if(e.willTransition){e.willTransition(n,r.handlerInfos,t)}}o["default"]=q});n("router/transition-intent",["exports"],function(e){"use strict";function r(e){this.initialize(e);this.data=this.data||{}}r.prototype={initialize:null,applyToState:null};e["default"]=r});n("router/transition-intent/named-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],function(e,r,t,n,i){"use strict";var a=e["default"];var s=r["default"];var o=t["default"];var l=n.isParam;var u=n.extractQueryParams;var h=n.merge;var f=n.subclass;i["default"]=f(a,{name:null,pivotHandler:null,contexts:null,queryParams:null,initialize:function(e){this.name=e.name;this.pivotHandler=e.pivotHandler;this.contexts=e.contexts||[];this.queryParams=e.queryParams},applyToState:function(e,r,t,n,i){var a=u([this.name].concat(this.contexts)),s=a[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,i)},applyToHandlers:function(e,r,t,n,i,a,o){var l,u;var f=new s;var d=this.contexts.slice(0);var c=r.length;if(this.pivotHandler){for(l=0,u=r.length;l<u;++l){if(r[l].handler===this.pivotHandler._handlerName){c=l;break}}}for(l=r.length-1;l>=0;--l){var v=r[l];var m=v.handler;var p=e.handlerInfos[l];var g=null;if(v.names.length>0){if(l>=c){g=this.createParamHandlerInfo(m,t,v.names,d,p)}else{var y=o(m);g=this.getHandlerInfoForDynamicSegment(m,t,v.names,d,p,n,l,y)}}else{g=this.createParamHandlerInfo(m,t,v.names,d,p)}if(a){g=g.becomeResolved(null,g.context);var b=p&&p.context;if(v.names.length>0&&g.context===b){g.params=p&&p.params}g.context=b}var P=p;if(l>=c||g.shouldSupercede(p)){c=Math.min(l,c);P=g}if(i&&!a){P=P.becomeResolved(null,P.context)}f.handlerInfos.unshift(P)}if(d.length>0){throw new Error("More context objects were passed than there are dynamic segments for the route: "+n)}if(!i){this.invalidateChildren(f.handlerInfos,c)}h(f.queryParams,this.queryParams||{});return f},invalidateChildren:function(e,r){for(var t=r,n=e.length;t<n;++t){var i=e[t];e[t]=i.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,i,a,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,i)}else{n.pop()}}else if(i&&i.name===e){return i}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return i}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,i){var a={};var s=t.length;while(s--){var u=i&&e===i.name&&i.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){a[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){a[f]=u[f]}else{throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e)}}}return o("param",{name:e,getHandler:r,params:a})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,i,a){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=i["default"];a["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var i=r.recognize(this.url),a,s;if(!i){throw new f(this.url)}var h=false;var d=this.url;function c(e){if(e&&e.inaccessibleByURL){throw new f(d)}return e}for(a=0,s=i.length;a<s;++a){var v=i[a];var m=v.handler;var p=l("param",{name:m,getHandler:t,params:v.params});var g=p.handler;if(g){c(g)}else{p.handlerPromise=p.handlerPromise.then(c)}var y=e.handlerInfos[a];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[a]=p}else{n.handlerInfos[a]=y}}u(n.queryParams,i.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var i=e.promiseLabel;var a=e.callHook;var s=r.Promise;function o(){this.handlerInfos=[];this.queryParams={};this.params={}}o.prototype={promiseLabel:function(e){var r="";n(this.handlerInfos,function(e){if(r!==""){r+="."}r+=e.name});return i("'"+r+"': "+e)},resolve:function(e,r){var t=this.params;n(this.handlerInfos,function(e){t[e.name]=e.params||{}});r=r||{};r.resolveIndex=0;var i=this;var o=false;return s.resolve(null,this.promiseLabel("Start transition")).then(f,null,this.promiseLabel("Resolve handler"))["catch"](u,this.promiseLabel("Handle error"));function l(){return s.resolve(e(),i.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},i.promiseLabel("Handle abort"))}function u(e){var t=i.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:i.handlerInfos[n].handler,wasAborted:o,state:i})}function h(e){var t=i.handlerInfos[r.resolveIndex].isResolved;i.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;a(n,"redirect",e.context,r)}return l().then(f,null,i.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===i.handlerInfos.length){return{error:null,state:i}}var e=i.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,i.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","exports"],function(e,r,t){"use strict";var n=e.Promise;var i=r.trigger;var a=r.slice;var s=r.log;var o=r.promiseLabel;function l(e,r,t,i,a){var s=this;this.state=t||e.state;this.intent=r;this.router=e;this.data=this.intent&&this.intent.data||{};this.resolvedModels={};this.queryParams={};this.promise=undefined;this.error=undefined;this.params=undefined;this.handlerInfos=undefined;this.targetName=undefined;this.pivotHandler=undefined;this.sequence=undefined;this.isAborted=false;this.isActive=true;if(i){this.promise=n.reject(i);this.error=i;return}this.isCausedByAbortingTransition=!!a;this.isCausedByInitialTransition=a&&(a.isCausedByInitialTransition||a.sequence===0);if(t){this.params=t.params;this.queryParams=t.queryParams;this.handlerInfos=t.handlerInfos;var l=t.handlerInfos.length;if(l){this.targetName=t.handlerInfos[l-1].name}for(var h=0;h<l;++h){var f=t.handlerInfos[h];if(!f.isResolved){break}this.pivotHandler=f.handler}this.sequence=e.currentSequence++;this.promise=t.resolve(d,this)["catch"](u(s),o("Handle Abort"))}else{this.promise=n.resolve(this.state);this.params={}}function d(){if(s.isAborted){return n.reject(undefined,o("Transition aborted - reject"))}}}function u(e){return function(r){if(r.wasAborted||e.isAborted){return n.reject(h(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return n.reject(r.error)}}}l.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:false,isTransition:true,isExiting:function(e){var r=this.handlerInfos;for(var t=0,n=r.length;t<n;++t){var i=r[t];if(i.name===e||i.handler===e){return false}}return true},promise:null,data:null,then:function(e,r,t){return this.promise.then(e,r,t)},"catch":function(e,r){return this.promise["catch"](e,r)},"finally":function(e,r){return this.promise["finally"](e,r)},abort:function(){if(this.isAborted){return this}s(this.router,this.sequence,this.targetName+": transition was aborted");this.intent.preTransitionState=this.router.state;this.isAborted=true;this.isActive=false;this.router.activeTransition=null;return this},retry:function(){this.abort();return this.router.transitionByIntent(this.intent,false)},method:function(e){this.urlMethod=e;return this},trigger:function(e){var r=a.call(arguments);if(typeof e==="boolean"){r.shift()}else{e=false}i(this.router,this.state.handlerInfos.slice(0,this.resolveIndex+1),e,r)},followRedirects:function(){var e=this.router;return this.promise["catch"](function(r){if(e.activeTransition){return e.activeTransition.followRedirects()}return n.reject(r)})},toString:function(){return"Transition (sequence "+this.sequence+")"},log:function(e){s(this.router,this.sequence,e)}};l.prototype.send=l.prototype.trigger;function h(e){s(e.router,e.sequence,"detected abort.");return new f}function f(e){this.message=e||"TransitionAborted";this.name="TransitionAborted"}t.Transition=l;t.logAbort=h;t.TransitionAborted=f});n("router/unrecognized-url-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){this.message=e||"UnrecognizedURLError";this.name="UnrecognizedURLError";Error.call(this)}n.prototype=t(Error.prototype);r["default"]=n});n("router/utils",["exports"],function(e){"use strict";var r=Array.prototype.slice;var t;if(!Array.isArray){t=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}else{t=Array.isArray}var n=t;e.isArray=n;function i(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=i;function a(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}}var s=Object.create||function(e){function r(){}r.prototype=e;return new r};e.oCreate=s;function o(e){var t=e&&e.length,n,i;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){i=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,i]}else{return[e,null]}}e.extractQueryParams=o;function l(e){for(var r in e){if(typeof e[r]==="number"){e[r]=""+e[r]}else if(n(e[r])){for(var t=0,i=e[r].length;t<i;t++){e[r][t]=""+e[r][t]}}}}function u(e,r,t){if(!e.log){return}if(arguments.length===3){e.log("Transition #"+r+": "+t)}else{t=r;e.log(t)}}e.log=u;function h(e,t){var n=arguments;return function(i){var a=r.call(n,2);a.push(i);return t.apply(e,a)}}e.bind=h;function f(e){return typeof e==="string"||e instanceof String||typeof e==="number"||e instanceof Number}function d(e,r){for(var t=0,n=e.length;t<n&&false!==r(e[t]);t++){}}e.forEach=d;function c(e,r,t,n){if(e.triggerEvent){e.triggerEvent(r,t,n);return}var i=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+i+"'. There are no active handlers")}var a=false;function s(e,r,t){t.events[e].apply(t,r)}for(var o=r.length-1;o>=0;o--){var l=r[o],u=l.handler;if(!u){l.handlerPromise.then(h(null,s,i,n));continue}if(u.events&&u.events[i]){if(u.events[i].apply(u,n)===true){a=true}else{return}}}if(i==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!a&&!t){throw new Error("Nothing handled the event '"+i+"'.")}}e.trigger=c;function v(e,r){var t;var i={all:{},changed:{},removed:{}};a(i.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;i.removed[t]=e[t]}}}for(t in r){if(r.hasOwnProperty(t)){if(n(e[t])&&n(r[t])){if(e[t].length!==r[t].length){i.changed[t]=r[t];s=true}else{for(var o=0,u=e[t].length;o<u;o++){if(e[t][o]!==r[t][o]){i.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){i.changed[t]=r[t];s=true}}}}return s&&i}e.getChangelist=v;function m(e){return"Router: "+e}e.promiseLabel=m;function p(e,r){function t(r){e.call(this,r||{})}t.prototype=s(e.prototype);a(t.prototype,r);return t}e.subclass=p;function g(e,r){if(!e){return}var t="_"+r;return e[t]&&t||e[r]&&r}function y(e,r,t,n){var i=g(e,r);return i&&e[i].call(e,t,n)}function b(e,r,t){var n=g(e,r);if(n){if(t.length===0){return e[n].call(e)}else if(t.length===1){return e[n].call(e,t[0])}else if(t.length===2){return e[n].call(e,t[0],t[1])}else{return e[n].apply(e,t)}}}e.merge=a;e.slice=r;e.isParam=f;e.coerceQueryParamsToString=l;e.callHook=y;e.resolveHook=g;e.applyHook=b});n("router",["./router/router","./router/transition","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.Transition;t["default"]=n;t.Transition=i});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=i("router")})(window,window.RSVP,window.RouteRecognizer); | ||
(function(e,r,t){var n,i,a,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=a=i=function(t){if(r[t]){return r[t]}r[t]={};if(!e[t]){throw new Error("Could not find module "+t)}var n=e[t],a=n.deps,s=n.callback,o=[],l;for(var u=0,h=a.length;u<h;u++){if(a[u]==="exports"){o.push(l={})}else{o.push(i(d(a[u])))}}var f=s.apply(this,o);return r[t]=l||f;function d(e){if(e.charAt(0)!=="."){return e}var r=e.split("/");var n=t.split("/").slice(0,-1);for(var i=0,a=r.length;i<a;i++){var s=r[i];if(s===".."){n.pop()}else if(s==="."){continue}else{n.push(s)}}return n.join("/")}}})();n("router/handler-info",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.bind;var i=e.merge;var a=e.promiseLabel;var s=e.applyHook;var o=e.isPromise;var l=r.Promise;var u=Object.freeze({});function h(e){var r=e||{};this._handler=u;if(r.handler){var t=r.name;this.handlerPromise=l.resolve(r.handler);if(o(r.handler)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler));r.handler=undefined}else if(r.handler){r.handler._handlerName=t}}i(this,r);this.initialize(r)}h.prototype={name:null,getHandler:function(){},fetchHandler:function(){var e=this.getHandler(this.name);this.handlerPromise=l.resolve(e);if(o(e)){this.handlerPromise=this.handlerPromise.then(n(this,this.updateHandler))}else if(e){e._handlerName=this.name;return this.handler=e}return this.handler=undefined},_handlerPromise:undefined,params:null,context:null,factory:null,initialize:function(){},log:function(e,r){if(e.log){e.log(this.name+": "+r)}},promiseLabel:function(e){return a("'"+this.name+"' "+e)},getUnresolved:function(){return this},serialize:function(){return this.params||{}},updateHandler:function(e){e._handlerName=this.name;return this.handler=e},resolve:function(e,r){var t=n(this,this.checkForAbort,e),i=n(this,this.runBeforeModelHook,r),a=n(this,this.getModel,r),s=n(this,this.runAfterModelHook,r),o=n(this,this.becomeResolved,r),u=this;return l.resolve(this.handlerPromise,this.promiseLabel("Start handler")).then(function(e){return l.resolve(e).then(t,null,u.promiseLabel("Check for abort")).then(i,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(a,null,u.promiseLabel("Model")).then(t,null,u.promiseLabel("Check if aborted in 'model' hook")).then(s,null,u.promiseLabel("After model")).then(t,null,u.promiseLabel("Check if aborted in 'afterModel' hook")).then(o,null,u.promiseLabel("Become resolved"))},function(e){throw e})},runBeforeModelHook:function(e){if(e.trigger){e.trigger(true,"willResolveModel",e,this.handler)}return this.runSharedModelHook(e,"beforeModel",[])},runAfterModelHook:function(e,r){var t=this.name;this.stashResolvedModel(e,r);return this.runSharedModelHook(e,"afterModel",[r]).then(function(){return e.resolvedModels[t]},null,this.promiseLabel("Ignore fulfillment value and return model value"))},runSharedModelHook:function(e,r,t){this.log(e,"calling "+r+" hook");if(this.queryParams){t.push(this.queryParams)}t.push(e);var n=s(this.handler,r,t);if(n&&n.isTransition){n=null}return l.resolve(n,this.promiseLabel("Resolve value returned from one of the model hooks"))},getModel:null,checkForAbort:function(e,r){return l.resolve(e(),this.promiseLabel("Check for abort")).then(function(){return r},null,this.promiseLabel("Ignore fulfillment value and continue"))},stashResolvedModel:function(e,r){e.resolvedModels=e.resolvedModels||{};e.resolvedModels[this.name]=r},becomeResolved:function(e,r){var t=this.serialize(r);if(e){this.stashResolvedModel(e,r);e.params=e.params||{};e.params[this.name]=t}return this.factory("resolved",{context:r,name:this.name,handler:this.handler,params:t})},shouldSupercede:function(e){if(!e){return true}var r=e.context===this.context;return e.name!==this.name||this.hasOwnProperty("context")&&!r||this.hasOwnProperty("params")&&!f(this.params,e.params)}};Object.defineProperty(h.prototype,"handler",{get:function(){if(this._handler!==u){return this._handler}return this.fetchHandler()},set:function(e){return this._handler=e}});Object.defineProperty(h.prototype,"handlerPromise",{get:function(){if(this._handlerPromise){return this._handlerPromise}this.fetchHandler();return this._handlerPromise},set:function(e){return this._handlerPromise=e}});function f(e,r){if(!e^!r){return false}if(!e){return true}for(var t in e){if(e.hasOwnProperty(t)&&e[t]!==r[t]){return false}}return true}t["default"]=h});n("router/handler-info/factory",["./resolved-handler-info","./unresolved-handler-info-by-object","./unresolved-handler-info-by-param","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r["default"];var s=t["default"];o.klasses={resolved:i,param:s,object:a};function o(e,r){var t=o.klasses[e],n=new t(r||{});n.factory=o;return n}n["default"]=o});n("router/handler-info/resolved-handler-info",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=t.Promise;var o=a(i,{resolve:function(e,r){if(r&&r.resolvedModels){r.resolvedModels[this.name]=this.context}return s.resolve(this,this.promiseLabel("Resolve"))},getUnresolved:function(){return this.factory("param",{name:this.name,handler:this.handler,params:this.params})},isResolved:true});n["default"]=o});n("router/handler-info/unresolved-handler-info-by-object",["../handler-info","../utils","rsvp","exports"],function(e,r,t,n){"use strict";var i=e["default"];var a=r.subclass;var s=r.isParam;var o=t.Promise;var l=a(i,{getModel:function(e){this.log(e,this.name+": resolving provided model");return o.resolve(this.context)},initialize:function(e){this.names=e.names||[];this.context=e.context},serialize:function(e){var r=e||this.context,t=this.names,n=this.serializer||this.handler&&this.handler.serialize;var i={};if(s(r)){i[t[0]]=r;return i}if(n){return n(r,t)}if(t.length!==1){return}var a=t[0];if(/_id$/.test(a)){i[a]=r.id}else{i[a]=r}return i}});n["default"]=l});n("router/handler-info/unresolved-handler-info-by-param",["../handler-info","../utils","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.resolveHook;var a=r.merge;var s=r.subclass;var o=s(n,{initialize:function(e){this.params=e.params||{}},getModel:function(e){var r=this.params;if(e&&e.queryParams){r={};a(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=i(t,"deserialize")||i(t,"model");return this.runSharedModelHook(e,n,[r])}});t["default"]=o});n("router/router",["route-recognizer","rsvp","./utils","./transition-state","./transition","./transition-aborted-error","./transition-intent/named-transition-intent","./transition-intent/url-transition-intent","exports"],function(e,r,t,n,i,a,s,o,l){"use strict";var u=e["default"];var h=r.Promise;var f=t.trigger;var d=t.log;var c=t.slice;var v=t.forEach;var m=t.merge;var p=t.extractQueryParams;var g=t.getChangelist;var y=t.promiseLabel;var b=t.callHook;var P=n["default"];var I=i.logAbort;var w=i.Transition;var x=a["default"];var T=s["default"];var H=o["default"];var q=Array.prototype.pop;function L(e){var r=e||{};this.getHandler=r.getHandler||this.getHandler;this.getSerializer=r.getSerializer||this.getSerializer;this.updateURL=r.updateURL||this.updateURL;this.replaceURL=r.replaceURL||this.replaceURL;this.didTransition=r.didTransition||this.didTransition;this.willTransition=r.willTransition||this.willTransition;this.delegate=r.delegate||this.delegate;this.triggerEvent=r.triggerEvent||this.triggerEvent;this.log=r.log||this.log;this.dslCallBacks=[];this.state=undefined;this.activeTransition=undefined;this._changedQueryParams=undefined;this.oldState=undefined;this.currentHandlerInfos=undefined;this.state=undefined;this.currentSequence=0;this.recognizer=new u;this.reset()}function k(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var i;var a=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=g(n.queryParams,a.queryParams);if(U(a.handlerInfos,n.handlerInfos)){if(s){i=this.queryParamsTransition(s,t,n,a);if(i){return i}}return this.activeTransition||new w(this)}if(r){R(this,a);return}i=new w(this,e,a,undefined,this.activeTransition);if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=i;i.promise=i.promise.then(function(e){return C(i,e.state)},null,y("Settle transition promise when transition is finalized"));if(!t){O(this,a,i)}z(this,a,s);return i}L.prototype={map:function(e){this.recognizer.delegate=this.delegate;this.recognizer.map(e,function(e,r){for(var t=r.length-1,n=true;t>=0&&n;--t){var i=r[t];e.add(r,{as:i.handler});n=i.path==="/"||i.path===""||i.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var i=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var a=new w(this);a.queryParamsOnly=true;t.queryParams=j(this,n.handlerInfos,n.queryParams,a);a.promise=a.promise.then(function(e){M(a,t,true);if(i.didTransition){i.didTransition(i.currentHandlerInfos)}return e},null,y("Transition complete"));return a}},transitionByIntent:function(e){try{return k.apply(this,arguments)}catch(r){return new w(this,e,null,r)}},reset:function(){if(this.state){v(this.state.handlerInfos.slice().reverse(),function(e){var r=e.handler;b(r,"exit")})}this.oldState=undefined;this.state=new P;this.currentHandlerInfos=null},activeTransition:null,handleURL:function(e){var r=c.call(arguments);if(e.charAt(0)!=="/"){r[0]="/"+e}return E(this,r).method(null)},updateURL:function(){throw new Error("updateURL is not implemented")},replaceURL:function(e){this.updateURL(e)},transitionTo:function(){return E(this,arguments)},intermediateTransitionTo:function(){return E(this,arguments,true)},refresh:function(e){var r=this.activeTransition?this.activeTransition.state:this.state;var t=r.handlerInfos;var n={};for(var i=0,a=t.length;i<a;++i){var s=t[i];n[s.name]=s.params||{}}d(this,"Starting a refresh transition");var o=new T({name:t[t.length-1].name,pivotHandler:e||t[0].handler,contexts:[],queryParams:this._changedQueryParams||r.queryParams||{}});return this.transitionByIntent(o,false)},replaceWith:function(){return E(this,arguments).method("replace")},generate:function(e){var r=p(c.call(arguments,1)),t=r[0],n=r[1];var i=new T({name:e,contexts:t});var a=i.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=a.handlerInfos.length;o<l;++o){var u=a.handlerInfos[o];var h=u.serialize();m(s,h)}s.queryParams=n;return this.recognizer.generate(e,s)},applyIntent:function(e,r){var t=new T({name:e,contexts:r});var n=this.activeTransition&&this.activeTransition.state||this.state;return t.applyToState(n,this.recognizer,this.getHandler,null,this.getSerializer)},isActiveIntent:function(e,r,t,n){var i=n||this.state,a=i.handlerInfos,s,o;if(!a.length){return false}var l=a[a.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=a[h];if(s.name===e){break}}if(h===u.length){return false}var f=new P;f.handlerInfos=a.slice(0,h+1);u=u.slice(0,h+1);var d=new T({name:l,contexts:r});var c=d.applyToHandlers(f,u,this.getHandler,l,true,true,this.getSerializer);var v=U(c.handlerInfos,f.handlerInfos);if(!t||!v){return v}var p={};m(p,t);var y=i.queryParams;for(var b in y){if(y.hasOwnProperty(b)&&p.hasOwnProperty(b)){p[b]=y[b]}}return v&&!g(p,t)},isActive:function(e){var r=p(c.call(arguments,1));return this.isActiveIntent(e,r[0],r[1])},trigger:function(){var e=c.call(arguments);f(this,this.currentHandlerInfos,false,e)},log:null};function z(e,r,t){if(t){e._changedQueryParams=t.all;f(e,r.handlerInfos,true,["queryParamsDidChange",t.changed,t.all,t.removed]);e._changedQueryParams=null}}function R(e,r,t){var n=A(e.state,r);var i,a,s;for(i=0,a=n.exited.length;i<a;i++){s=n.exited[i].handler;delete s.context;b(s,"reset",true,t);b(s,"exit",t)}var o=e.oldState=e.state;e.state=r;var l=e.currentHandlerInfos=n.unchanged.slice();try{for(i=0,a=n.reset.length;i<a;i++){s=n.reset[i].handler;b(s,"reset",false,t)}for(i=0,a=n.updatedContext.length;i<a;i++){S(l,n.updatedContext[i],false,t)}for(i=0,a=n.entered.length;i<a;i++){S(l,n.entered[i],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=j(e,l,r.queryParams,t)}function S(e,r,t,n){var i=r.handler,a=r.context;function s(i){if(t){b(i,"enter",n)}if(n&&n.isAborted){throw new x}i.context=a;b(i,"contextDidChange");b(i,"setup",a,n);if(n&&n.isAborted){throw new x}e.push(r)}if(!i){r.handlerPromise=r.handlerPromise.then(s)}else{s(i)}return true}function A(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var i={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var a,s=false,o,l;for(o=0,l=n.length;o<l;o++){var u=t[o],h=n[o];if(!u||u.handler!==h.handler){a=true}if(a){i.entered.push(h);if(u){i.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;i.updatedContext.push(h)}else{i.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){i.exited.unshift(t[o])}i.reset=i.updatedContext.slice();i.reset.reverse();return i}function M(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,i=r.handlerInfos,a=i[i.length-1].name,s={};for(var o=i.length-1;o>=0;--o){var l=i[o];m(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(a,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;if(h||f){n.replaceURL(u)}else{n.updateURL(u)}}}function C(e,r){try{d(e.router,e.sequence,"Resolved all models on destination route; finalizing transition.");var t=e.router,n=r.handlerInfos;R(t,r,e);if(e.isAborted){t.state.handlerInfos=t.currentHandlerInfos;return h.reject(I(e))}M(e,r,e.intent.url);e.isActive=false;t.activeTransition=null;f(t,t.currentHandlerInfos,true,["didTransition"]);if(t.didTransition){t.didTransition(t.currentHandlerInfos)}d(t,e.sequence,"TRANSITION COMPLETE.");return n[n.length-1].handler}catch(i){if(!((i instanceof x))){var a=e.state.handlerInfos;e.trigger(true,"error",i,e,a[a.length-1].handler);e.abort()}throw i}}function E(e,r,t){var n=r[0]||"/";var i=r[r.length-1];var a={};if(i&&i.hasOwnProperty("queryParams")){a=q.call(r).queryParams}var s;if(r.length===0){d(e,"Updating query params");var o=e.state.handlerInfos;s=new T({name:o[o.length-1].name,contexts:[],queryParams:a})}else if(n.charAt(0)==="/"){d(e,"Attempting URL transition to "+n);s=new H({url:n})}else{d(e,"Attempting transition to "+n);s=new T({name:r[0],contexts:c.call(r,1),queryParams:a})}return e.transitionByIntent(s,t)}function U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t]!==r[t]){return false}}return true}function j(e,r,t,n){for(var i in t){if(t.hasOwnProperty(i)&&t[i]===null){delete t[i]}}var a=[];f(e,r,true,["finalizeQueryParamChange",t,a,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=a.length;o<l;++o){var u=a[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function O(e,r,t){var n=e.state.handlerInfos,i=[],a=null,s,o,l,u,h,d;u=n.length;for(l=0;l<u;l++){h=n[l];d=r.handlerInfos[l];if(!d||h.name!==d.name){a=l;break}if(!d.isResolved){i.push(h)}}if(a!==null){s=n.slice(a,u);o=function(e){for(var r=0,t=s.length;r<t;r++){if(s[r].name===e){return true}}return false}}f(e,n,true,["willTransition",t]);if(e.willTransition){e.willTransition(n,r.handlerInfos,t)}}l["default"]=L});n("router/transition-aborted-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"TransitionAborted";this.name="TransitionAborted";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/transition-intent",["exports"],function(e){"use strict";function r(e){this.initialize(e);this.data=this.data||{}}r.prototype={initialize:null,applyToState:null};e["default"]=r});n("router/transition-intent/named-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","exports"],function(e,r,t,n,i){"use strict";var a=e["default"];var s=r["default"];var o=t["default"];var l=n.isParam;var u=n.extractQueryParams;var h=n.merge;var f=n.subclass;i["default"]=f(a,{name:null,pivotHandler:null,contexts:null,queryParams:null,initialize:function(e){this.name=e.name;this.pivotHandler=e.pivotHandler;this.contexts=e.contexts||[];this.queryParams=e.queryParams},applyToState:function(e,r,t,n,i){var a=u([this.name].concat(this.contexts)),s=a[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,i)},applyToHandlers:function(e,r,t,n,i,a,o){var l,u;var f=new s;var d=this.contexts.slice(0);var c=r.length;if(this.pivotHandler){for(l=0,u=r.length;l<u;++l){if(r[l].handler===this.pivotHandler._handlerName){c=l;break}}}for(l=r.length-1;l>=0;--l){var v=r[l];var m=v.handler;var p=e.handlerInfos[l];var g=null;if(v.names.length>0){if(l>=c){g=this.createParamHandlerInfo(m,t,v.names,d,p)}else{var y=o(m);g=this.getHandlerInfoForDynamicSegment(m,t,v.names,d,p,n,l,y)}}else{g=this.createParamHandlerInfo(m,t,v.names,d,p)}if(a){g=g.becomeResolved(null,g.context);var b=p&&p.context;if(v.names.length>0&&g.context===b){g.params=p&&p.params}g.context=b}var P=p;if(l>=c||g.shouldSupercede(p)){c=Math.min(l,c);P=g}if(i&&!a){P=P.becomeResolved(null,P.context)}f.handlerInfos.unshift(P)}if(d.length>0){throw new Error("More context objects were passed than there are dynamic segments for the route: "+n)}if(!i){this.invalidateChildren(f.handlerInfos,c)}h(f.queryParams,this.queryParams||{});return f},invalidateChildren:function(e,r){for(var t=r,n=e.length;t<n;++t){var i=e[t];e[t]=i.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,i,a,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,i)}else{n.pop()}}else if(i&&i.name===e){return i}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return i}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,i){var a={};var s=t.length;while(s--){var u=i&&e===i.name&&i.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){a[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){a[f]=u[f]}else{throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route "+e)}}}return o("param",{name:e,getHandler:r,params:a})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,i,a){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=i["default"];a["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var i=r.recognize(this.url),a,s;if(!i){throw new f(this.url)}var h=false;var d=this.url;function c(e){if(e&&e.inaccessibleByURL){throw new f(d)}return e}for(a=0,s=i.length;a<s;++a){var v=i[a];var m=v.handler;var p=l("param",{name:m,getHandler:t,params:v.params});var g=p.handler;if(g){c(g)}else{p.handlerPromise=p.handlerPromise.then(c)}var y=e.handlerInfos[a];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[a]=p}else{n.handlerInfos[a]=y}}u(n.queryParams,i.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var i=e.promiseLabel;var a=e.callHook;var s=r.Promise;function o(){this.handlerInfos=[];this.queryParams={};this.params={}}o.prototype={promiseLabel:function(e){var r="";n(this.handlerInfos,function(e){if(r!==""){r+="."}r+=e.name});return i("'"+r+"': "+e)},resolve:function(e,r){var t=this.params;n(this.handlerInfos,function(e){t[e.name]=e.params||{}});r=r||{};r.resolveIndex=0;var i=this;var o=false;return s.resolve(null,this.promiseLabel("Start transition")).then(f,null,this.promiseLabel("Resolve handler"))["catch"](u,this.promiseLabel("Handle error"));function l(){return s.resolve(e(),i.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},i.promiseLabel("Handle abort"))}function u(e){var t=i.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:i.handlerInfos[n].handler,wasAborted:o,state:i})}function h(e){var t=i.handlerInfos[r.resolveIndex].isResolved;i.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;a(n,"redirect",e.context,r)}return l().then(f,null,i.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===i.handlerInfos.length){return{error:null,state:i}}var e=i.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,i.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","./transition-aborted-error","exports"],function(e,r,t,n){"use strict";var i=e.Promise;var a=r.trigger;var s=r.slice;var o=r.log;var l=r.promiseLabel;var u=t["default"];function h(e,r,t,n,a){var s=this;this.state=t||e.state;this.intent=r;this.router=e;this.data=this.intent&&this.intent.data||{};this.resolvedModels={};this.queryParams={};this.promise=undefined;this.error=undefined;this.params=undefined;this.handlerInfos=undefined;this.targetName=undefined;this.pivotHandler=undefined;this.sequence=undefined;this.isAborted=false;this.isActive=true;if(n){this.promise=i.reject(n);this.error=n;return}this.isCausedByAbortingTransition=!!a;this.isCausedByInitialTransition=a&&(a.isCausedByInitialTransition||a.sequence===0);if(t){this.params=t.params;this.queryParams=t.queryParams;this.handlerInfos=t.handlerInfos;var o=t.handlerInfos.length;if(o){this.targetName=t.handlerInfos[o-1].name}for(var u=0;u<o;++u){var h=t.handlerInfos[u];if(!h.isResolved){break}this.pivotHandler=h.handler}this.sequence=e.currentSequence++;this.promise=t.resolve(d,this)["catch"](f(s),l("Handle Abort"))}else{this.promise=i.resolve(this.state);this.params={}}function d(){if(s.isAborted){return i.reject(undefined,l("Transition aborted - reject"))}}}function f(e){return function(r){if(r.wasAborted||e.isAborted){return i.reject(d(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return i.reject(r.error)}}}h.prototype={targetName:null,urlMethod:"update",intent:null,pivotHandler:null,resolveIndex:0,resolvedModels:null,state:null,queryParamsOnly:false,isTransition:true,isExiting:function(e){var r=this.handlerInfos;for(var t=0,n=r.length;t<n;++t){var i=r[t];if(i.name===e||i.handler===e){return false}}return true},promise:null,data:null,then:function(e,r,t){return this.promise.then(e,r,t)},"catch":function(e,r){return this.promise["catch"](e,r)},"finally":function(e,r){return this.promise["finally"](e,r)},abort:function(){if(this.isAborted){return this}o(this.router,this.sequence,this.targetName+": transition was aborted");this.intent.preTransitionState=this.router.state;this.isAborted=true;this.isActive=false;this.router.activeTransition=null;return this},retry:function(){this.abort();return this.router.transitionByIntent(this.intent,false)},method:function(e){this.urlMethod=e;return this},trigger:function(e){var r=s.call(arguments);if(typeof e==="boolean"){r.shift()}else{e=false}a(this.router,this.state.handlerInfos.slice(0,this.resolveIndex+1),e,r)},followRedirects:function(){var e=this.router;return this.promise["catch"](function(r){if(e.activeTransition){return e.activeTransition.followRedirects()}return i.reject(r)})},toString:function(){return"Transition (sequence "+this.sequence+")"},log:function(e){o(this.router,this.sequence,e)}};h.prototype.send=h.prototype.trigger;function d(e){o(e.router,e.sequence,"detected abort.");return new u}n.Transition=h;n.logAbort=d;n.TransitionAbortedError=u});n("router/unrecognized-url-error",["./utils","exports"],function(e,r){"use strict";var t=e.oCreate;function n(e){if(!(this instanceof n)){return new n(e)}var r=Error.call(this,e);if(Error.captureStackTrace){Error.captureStackTrace(this,n)}else{this.stack=r.stack}this.description=r.description;this.fileName=r.fileName;this.lineNumber=r.lineNumber;this.message=r.message||"UnrecognizedURL";this.name="UnrecognizedURLError";this.number=r.number;this.code=r.code}n.prototype=t(Error.prototype);r["default"]=n});n("router/utils",["exports"],function(e){"use strict";var r=Array.prototype.slice;var t;if(!Array.isArray){t=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}else{t=Array.isArray}var n=t;e.isArray=n;function i(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=i;function a(e,r){for(var t in r){if(r.hasOwnProperty(t)){e[t]=r[t]}}}var s=Object.create||function(e){function r(){}r.prototype=e;return new r};e.oCreate=s;function o(e){var t=e&&e.length,n,i;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){i=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,i]}else{return[e,null]}}e.extractQueryParams=o;function l(e){for(var r in e){if(typeof e[r]==="number"){e[r]=""+e[r]}else if(n(e[r])){for(var t=0,i=e[r].length;t<i;t++){e[r][t]=""+e[r][t]}}}}function u(e,r,t){if(!e.log){return}if(arguments.length===3){e.log("Transition #"+r+": "+t)}else{t=r;e.log(t)}}e.log=u;function h(e,t){var n=arguments;return function(i){var a=r.call(n,2);a.push(i);return t.apply(e,a)}}e.bind=h;function f(e){return typeof e==="string"||e instanceof String||typeof e==="number"||e instanceof Number}function d(e,r){for(var t=0,n=e.length;t<n&&false!==r(e[t]);t++){}}e.forEach=d;function c(e,r,t,n){if(e.triggerEvent){e.triggerEvent(r,t,n);return}var i=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+i+"'. There are no active handlers")}var a=false;function s(e,r,t){t.events[e].apply(t,r)}for(var o=r.length-1;o>=0;o--){var l=r[o],u=l.handler;if(!u){l.handlerPromise.then(h(null,s,i,n));continue}if(u.events&&u.events[i]){if(u.events[i].apply(u,n)===true){a=true}else{return}}}if(i==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!a&&!t){throw new Error("Nothing handled the event '"+i+"'.")}}e.trigger=c;function v(e,r){var t;var i={all:{},changed:{},removed:{}};a(i.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;i.removed[t]=e[t]}}}for(t in r){if(r.hasOwnProperty(t)){if(n(e[t])&&n(r[t])){if(e[t].length!==r[t].length){i.changed[t]=r[t];s=true}else{for(var o=0,u=e[t].length;o<u;o++){if(e[t][o]!==r[t][o]){i.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){i.changed[t]=r[t];s=true}}}}return s&&i}e.getChangelist=v;function m(e){return"Router: "+e}e.promiseLabel=m;function p(e,r){function t(r){e.call(this,r||{})}t.prototype=s(e.prototype);a(t.prototype,r);return t}e.subclass=p;function g(e,r){if(!e){return}var t="_"+r;return e[t]&&t||e[r]&&r}function y(e,r,t,n){var i=g(e,r);return i&&e[i].call(e,t,n)}function b(e,r,t){var n=g(e,r);if(n){if(t.length===0){return e[n].call(e)}else if(t.length===1){return e[n].call(e,t[0])}else if(t.length===2){return e[n].call(e,t[0],t[1])}else{return e[n].apply(e,t)}}}e.merge=a;e.slice=r;e.isParam=f;e.coerceQueryParamsToString=l;e.callHook=y;e.resolveHook=g;e.applyHook=b});n("router",["./router/router","./router/transition","exports"],function(e,r,t){"use strict";var n=e["default"];var i=r.Transition;t["default"]=n;t.Transition=i});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=i("router")})(window,window.RSVP,window.RouteRecognizer); |
@@ -5,3 +5,4 @@ import RouteRecognizer from 'route-recognizer'; | ||
import TransitionState from './transition-state'; | ||
import { logAbort, Transition, TransitionAborted } from './transition'; | ||
import { logAbort, Transition } from './transition'; | ||
import TransitionAbortedError from './transition-aborted-error'; | ||
import NamedTransitionIntent from './transition-intent/named-transition-intent'; | ||
@@ -498,3 +499,3 @@ import URLTransitionIntent from './transition-intent/url-transition-intent'; | ||
if (transition && transition.isAborted) { | ||
throw new TransitionAborted(); | ||
throw new TransitionAbortedError(); | ||
} | ||
@@ -507,3 +508,3 @@ | ||
if (transition && transition.isAborted) { | ||
throw new TransitionAborted(); | ||
throw new TransitionAbortedError(); | ||
} | ||
@@ -700,3 +701,3 @@ | ||
} catch(e) { | ||
if (!(e instanceof TransitionAborted)) { | ||
if (!(e instanceof TransitionAbortedError)) { | ||
//var erroneousHandler = handlerInfos.pop(); | ||
@@ -703,0 +704,0 @@ var infos = transition.state.handlerInfos; |
import { Promise } from 'rsvp'; | ||
import { trigger, slice, log, promiseLabel } from './utils'; | ||
import TransitionAbortedError from './transition-aborted-error'; | ||
@@ -328,14 +329,9 @@ /** | ||
Logs and returns a TransitionAborted error. | ||
Logs and returns an instance of TransitionAbortedError. | ||
*/ | ||
function logAbort(transition) { | ||
log(transition.router, transition.sequence, "detected abort."); | ||
return new TransitionAborted(); | ||
return new TransitionAbortedError(); | ||
} | ||
function TransitionAborted(message) { | ||
this.message = (message || "TransitionAborted"); | ||
this.name = "TransitionAborted"; | ||
} | ||
export { Transition, logAbort, TransitionAborted }; | ||
export { Transition, logAbort, TransitionAbortedError as TransitionAborted }; |
import { oCreate } from './utils'; | ||
/** | ||
Promise reject reasons passed to promise rejection | ||
handlers for failed transitions. | ||
*/ | ||
function UnrecognizedURLError(message) { | ||
this.message = (message || "UnrecognizedURLError"); | ||
this.name = "UnrecognizedURLError"; | ||
Error.call(this); | ||
if (!(this instanceof UnrecognizedURLError)) { | ||
return new UnrecognizedURLError(message); | ||
} | ||
var error = Error.call(this, message); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, UnrecognizedURLError); | ||
} else { | ||
this.stack = error.stack; | ||
} | ||
this.description = error.description; | ||
this.fileName = error.fileName; | ||
this.lineNumber = error.lineNumber; | ||
this.message = error.message || 'UnrecognizedURL'; | ||
this.name = 'UnrecognizedURLError'; | ||
this.number = error.number; | ||
this.code = error.code; | ||
} | ||
@@ -12,0 +24,0 @@ |
{ | ||
"name": "router_js", | ||
"namespace": "Router", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "A lightweight JavaScript library is built on top of route-recognizer and rsvp.js to provide an API for handling routes", | ||
@@ -42,3 +42,3 @@ "author": "Tilde, Inc.", | ||
"bugs": { | ||
"url": "https://github.com/tildeio/rsvp.js/issues" | ||
"url": "https://github.com/tildeio/router.js/issues" | ||
}, | ||
@@ -45,0 +45,0 @@ "keywords": [ |
@@ -143,2 +143,7 @@ # router.js | ||
Some example libraries include: | ||
- [history.js](https://github.com/browserstate/history.js/) | ||
- [location-bar](https://github.com/KidkArolis/location-bar) | ||
## Always In Sync | ||
@@ -418,3 +423,4 @@ | ||
Both work identically, so do whichever you prefer. | ||
Both recognize the same sets of URLs but only the nested | ||
ones invoke the hooks in the ancestor routes too. | ||
@@ -650,5 +656,4 @@ ## Events | ||
If there are multiple matches, `route-recognizer` will | ||
prefer routes with fewer dynamic segments, so | ||
`/posts/edit` will match in preference to `/posts/:id` | ||
if both match. | ||
prefer routes that are more specific, so `/posts/edit` will be preferred | ||
over, say, `/posts/:id`. | ||
@@ -655,0 +660,0 @@ ## Architecture / Contributing |
import { Backburner } from "backburner"; | ||
import { resolve, configure } from "rsvp"; | ||
import { oCreate } from 'router/utils'; | ||
import TransitionAbortedError from 'router/transition-aborted-error'; | ||
@@ -42,2 +43,7 @@ var slice = Array.prototype.slice; | ||
function assertAbort(assert) { | ||
return function _assertAbort(e) { | ||
assert.ok(e instanceof TransitionAbortedError, 'transition was redirected/aborted'); | ||
}; | ||
} | ||
@@ -55,5 +61,3 @@ // Helper method that performs a transition and flushes | ||
var args = slice.call(arguments, 2); | ||
router.transitionTo.apply(router, args).then(shouldNotHappen, function(reason) { | ||
assert.equal(reason.name, "TransitionAborted", "transition was redirected/aborted"); | ||
}); | ||
router.transitionTo.apply(router, args).then(shouldNotHappen, assertAbort(assert)); | ||
flushBackburner(); | ||
@@ -84,2 +88,11 @@ } | ||
export { module, test, flushBackburner, transitionTo, transitionToWithAbort, shouldNotHappen, stubbedHandlerInfoFactory }; | ||
export { | ||
module, | ||
test, | ||
flushBackburner, | ||
transitionTo, | ||
transitionToWithAbort, | ||
shouldNotHappen, | ||
stubbedHandlerInfoFactory, | ||
assertAbort | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
736876
64
18870
680
0