Comparing version 1.2.7 to 1.2.8
@@ -242,3 +242,14 @@ "use strict"; | ||
var newTransition = this.router.transitionByIntent(this.intent, false); | ||
newTransition.method(this.urlMethod); | ||
// inheriting a `null` urlMethod is not valid | ||
// the urlMethod is only set to `null` when | ||
// the transition is initiated *after* the url | ||
// has been updated (i.e. `router.handleURL`) | ||
// | ||
// in that scenario, the url method cannot be | ||
// inherited for a new transition because then | ||
// the url would not update even though it should | ||
if (this.urlMethod !== null) { | ||
newTransition.method(this.urlMethod); | ||
} | ||
return newTransition; | ||
@@ -245,0 +256,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
(function(e,r,t){var n,a,i,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=i=a=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],i=n.deps,s=n.callback,o=[],l;for(var u=0,h=i.length;u<h;u++){if(i[u]==="exports"){o.push(l={})}else{o.push(a(d(i[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 a=0,i=r.length;a<i;a++){var s=r[a];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 a=e.merge;var i=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}}a(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 i("'"+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),a=n(this,this.runBeforeModelHook,r),i=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(a,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(i,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 a=e["default"];var i=r["default"];var s=t["default"];o.klasses={resolved:a,param:s,object:i};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 a=e["default"];var i=r.subclass;var s=t.Promise;var o=i(a,{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 a=e["default"];var i=r.subclass;var s=r.isParam;var o=t.Promise;var l=i(a,{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 a={};if(s(r)){a[t[0]]=r;return a}if(n){return n(r,t)}if(t.length!==1){return}var i=t[0];if(/_id$/.test(i)){a[i]=r.id}else{a[i]=r}return a}});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 a=r.resolveHook;var i=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={};i(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=a(t,"deserialize")||a(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,a,i,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=a.logAbort;var w=a.Transition;var x=i["default"];var T=s["default"];var H=o["default"];var q=Array.prototype.pop;function k(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 L(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var a;var i=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=g(n.queryParams,i.queryParams);if(O(i.handlerInfos,n.handlerInfos)){if(s){a=this.queryParamsTransition(s,t,n,i);if(a){a.queryParamsOnly=true;return a}}return this.activeTransition||new w(this)}if(r){R(this,i);return}a=new w(this,e,i,undefined,this.activeTransition);if(U(i.handlerInfos,n.handlerInfos)){a.queryParamsOnly=true}if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=a;a.promise=a.promise.then(function(e){return C(a,e.state)},null,y("Settle transition promise when transition is finalized"));if(!t){N(this,i,a)}z(this,i,s);return a}k.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 a=r[t];e.add(r,{as:a.handler});n=a.path==="/"||a.path===""||a.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var a=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var i=new w(this);i.queryParamsOnly=true;t.queryParams=_(this,n.handlerInfos,n.queryParams,i);i.promise=i.promise.then(function(e){M(i,t,true);if(a.didTransition){a.didTransition(a.currentHandlerInfos)}return e},null,y("Transition complete"));return i}},transitionByIntent:function(e){try{return L.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;var t=r?r.state:this.state;var n=t.handlerInfos;var a={};for(var i=0,s=n.length;i<s;++i){var o=n[i];a[o.name]=o.params||{}}d(this,"Starting a refresh transition");var l=new T({name:n[n.length-1].name,pivotHandler:e||n[0].handler,contexts:[],queryParams:this._changedQueryParams||t.queryParams||{}});var u=this.transitionByIntent(l,false);if(r&&r.urlMethod==="replace"){u.method(r.urlMethod)}return u},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 a=new T({name:e,contexts:t});var i=a.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=i.handlerInfos.length;o<l;++o){var u=i.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 a=n||this.state,i=a.handlerInfos,s,o;if(!i.length){return false}var l=i[i.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=i[h];if(s.name===e){break}}if(h===u.length){return false}var f=new P;f.handlerInfos=i.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=O(c.handlerInfos,f.handlerInfos);if(!t||!v){return v}var p={};m(p,t);var y=a.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 a,i,s;for(a=0,i=n.exited.length;a<i;a++){s=n.exited[a].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(a=0,i=n.reset.length;a<i;a++){s=n.reset[a].handler;b(s,"reset",false,t)}for(a=0,i=n.updatedContext.length;a<i;a++){S(l,n.updatedContext[a],false,t)}for(a=0,i=n.entered.length;a<i;a++){S(l,n.entered[a],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=_(e,l,r.queryParams,t)}function S(e,r,t,n){var a=r.handler,i=r.context;function s(a){if(t){b(a,"enter",n)}if(n&&n.isAborted){throw new x}a.context=i;b(a,"contextDidChange");b(a,"setup",i,n);if(n&&n.isAborted){throw new x}e.push(r)}if(!a){r.handlerPromise=r.handlerPromise.then(s)}else{s(a)}return true}function A(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var a={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var i,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){i=true}if(i){a.entered.push(h);if(u){a.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;a.updatedContext.push(h)}else{a.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){a.exited.unshift(t[o])}a.reset=a.updatedContext.slice();a.reset.reverse();return a}function M(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,a=r.handlerInfos,i=a[a.length-1].name,s={};for(var o=a.length-1;o>=0;--o){var l=a[o];m(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(i,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;var d=e.queryParamsOnly&&t==="replace";if(h||f||d){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(a){if(!((a instanceof x))){var i=e.state.handlerInfos;e.trigger(true,"error",a,e,i[i.length-1].handler);e.abort()}throw a}}function E(e,r,t){var n=r[0]||"/";var a=r[r.length-1];var i={};if(a&&a.hasOwnProperty("queryParams")){i=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:i})}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:i})}return e.transitionByIntent(s,t)}function O(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 U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t].name!==r[t].name){return false}if(!j(e[t].params,r[t].params)){return false}}return true}function j(e,r){if(!e&&!r){return true}else if(!e&&!!r||!!e&&!r){return false}var t=Object.keys(e);var n=Object.keys(r);if(t.length!==n.length){return false}for(var a=0,i=t.length;a<i;++a){var s=t[a];if(e[s]!==r[s]){return false}}return true}function _(e,r,t,n){for(var a in t){if(t.hasOwnProperty(a)&&t[a]===null){delete t[a]}}var i=[];f(e,r,true,["finalizeQueryParamChange",t,i,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=i.length;o<l;++o){var u=i[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function N(e,r,t){var n=e.state.handlerInfos,a=[],i=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){i=l;break}if(!d.isResolved){a.push(h)}}if(i!==null){s=n.slice(i,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"]=k});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,a){"use strict";var i=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;a["default"]=f(i,{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,a){var i=u([this.name].concat(this.contexts)),s=i[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,a)},applyToHandlers:function(e,r,t,n,a,i,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(i){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(a&&!i){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(!a){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 a=e[t];e[t]=a.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,a,i,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,a)}else{n.pop()}}else if(a&&a.name===e){return a}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return a}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,a){var i={};var s=t.length;while(s--){var u=a&&e===a.name&&a.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){i[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){i[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:i})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,a,i){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=a["default"];i["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var a=r.recognize(this.url),i,s;if(!a){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(i=0,s=a.length;i<s;++i){var v=a[i];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[i];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[i]=p}else{n.handlerInfos[i]=y}}u(n.queryParams,a.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var a=e.promiseLabel;var i=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 a("'"+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 a=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(),a.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},a.promiseLabel("Handle abort"))}function u(e){var t=a.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:a.handlerInfos[n].handler,wasAborted:o,state:a})}function h(e){var t=a.handlerInfos[r.resolveIndex].isResolved;a.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;i(n,"redirect",e.context,r)}return l().then(f,null,a.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===a.handlerInfos.length){return{error:null,state:a}}var e=a.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,a.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","./transition-aborted-error","exports"],function(e,r,t,n){"use strict";var a=e.Promise;var i=r.trigger;var s=r.slice;var o=r.log;var l=r.promiseLabel;var u=t["default"];function h(e,r,t,n,i){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=a.reject(n);this.error=n;return}this.isCausedByAbortingTransition=!!i;this.isCausedByInitialTransition=i&&(i.isCausedByInitialTransition||i.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=a.resolve(this.state);this.params={}}function d(){if(s.isAborted){return a.reject(undefined,l("Transition aborted - reject"))}}}function f(e){return function(r){if(r.wasAborted||e.isAborted){return a.reject(d(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return a.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 a=r[t];if(a.name===e||a.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();var e=this.router.transitionByIntent(this.intent,false);e.method(this.urlMethod);return e},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}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 a.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 a(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=a;function i(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,a;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){a=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,a]}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,a=e[r].length;t<a;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(a){var i=r.call(n,2);i.push(a);return t.apply(e,i)}}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 a=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+a+"'. There are no active handlers")}var i=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,a,n));continue}if(u.events&&u.events[a]){if(u.events[a].apply(u,n)===true){i=true}else{return}}}if(a==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!i&&!t){throw new Error("Nothing handled the event '"+a+"'.")}}e.trigger=c;function v(e,r){var t;var a={all:{},changed:{},removed:{}};i(a.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;a.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){a.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]){a.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){a.changed[t]=r[t];s=true}}}}return s&&a}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);i(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 a=g(e,r);return a&&e[a].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=i;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 a=r.Transition;t["default"]=n;t.Transition=a});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=a("router")})(window,window.RSVP,window.RouteRecognizer); | ||
(function(e,r,t){var n,a,i,s;(function(){var e={},r={};n=function(r,t,n){e[r]={deps:t,callback:n}};s=i=a=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],i=n.deps,s=n.callback,o=[],l;for(var u=0,h=i.length;u<h;u++){if(i[u]==="exports"){o.push(l={})}else{o.push(a(d(i[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 a=0,i=r.length;a<i;a++){var s=r[a];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 a=e.merge;var i=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}}a(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 i("'"+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),a=n(this,this.runBeforeModelHook,r),i=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(a,null,u.promiseLabel("Before model")).then(t,null,u.promiseLabel("Check if aborted during 'beforeModel' hook")).then(i,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 a=e["default"];var i=r["default"];var s=t["default"];o.klasses={resolved:a,param:s,object:i};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 a=e["default"];var i=r.subclass;var s=t.Promise;var o=i(a,{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 a=e["default"];var i=r.subclass;var s=r.isParam;var o=t.Promise;var l=i(a,{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 a={};if(s(r)){a[t[0]]=r;return a}if(n){return n(r,t)}if(t.length!==1){return}var i=t[0];if(/_id$/.test(i)){a[i]=r.id}else{a[i]=r}return a}});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 a=r.resolveHook;var i=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={};i(r,this.params);r.queryParams=e.queryParams}var t=this.handler;var n=a(t,"deserialize")||a(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,a,i,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=a.logAbort;var w=a.Transition;var x=i["default"];var T=s["default"];var H=o["default"];var q=Array.prototype.pop;function k(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 L(e,r){var t=!!this.activeTransition;var n=t?this.activeTransition.state:this.state;var a;var i=e.applyToState(n,this.recognizer,this.getHandler,r,this.getSerializer);var s=g(n.queryParams,i.queryParams);if(O(i.handlerInfos,n.handlerInfos)){if(s){a=this.queryParamsTransition(s,t,n,i);if(a){a.queryParamsOnly=true;return a}}return this.activeTransition||new w(this)}if(r){R(this,i);return}a=new w(this,e,i,undefined,this.activeTransition);if(U(i.handlerInfos,n.handlerInfos)){a.queryParamsOnly=true}if(this.activeTransition){this.activeTransition.abort()}this.activeTransition=a;a.promise=a.promise.then(function(e){return C(a,e.state)},null,y("Settle transition promise when transition is finalized"));if(!t){N(this,i,a)}z(this,i,s);return a}k.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 a=r[t];e.add(r,{as:a.handler});n=a.path==="/"||a.path===""||a.handler.slice(-6)===".index"}})},hasRoute:function(e){return this.recognizer.hasRoute(e)},getHandler:function(){},getSerializer:function(){},queryParamsTransition:function(e,r,t,n){var a=this;z(this,n,e);if(!r&&this.activeTransition){return this.activeTransition}else{var i=new w(this);i.queryParamsOnly=true;t.queryParams=_(this,n.handlerInfos,n.queryParams,i);i.promise=i.promise.then(function(e){M(i,t,true);if(a.didTransition){a.didTransition(a.currentHandlerInfos)}return e},null,y("Transition complete"));return i}},transitionByIntent:function(e){try{return L.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;var t=r?r.state:this.state;var n=t.handlerInfos;var a={};for(var i=0,s=n.length;i<s;++i){var o=n[i];a[o.name]=o.params||{}}d(this,"Starting a refresh transition");var l=new T({name:n[n.length-1].name,pivotHandler:e||n[0].handler,contexts:[],queryParams:this._changedQueryParams||t.queryParams||{}});var u=this.transitionByIntent(l,false);if(r&&r.urlMethod==="replace"){u.method(r.urlMethod)}return u},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 a=new T({name:e,contexts:t});var i=a.applyToState(this.state,this.recognizer,this.getHandler,null,this.getSerializer);var s={};for(var o=0,l=i.handlerInfos.length;o<l;++o){var u=i.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 a=n||this.state,i=a.handlerInfos,s,o;if(!i.length){return false}var l=i[i.length-1].name;var u=this.recognizer.handlersFor(l);var h=0;for(o=u.length;h<o;++h){s=i[h];if(s.name===e){break}}if(h===u.length){return false}var f=new P;f.handlerInfos=i.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=O(c.handlerInfos,f.handlerInfos);if(!t||!v){return v}var p={};m(p,t);var y=a.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 a,i,s;for(a=0,i=n.exited.length;a<i;a++){s=n.exited[a].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(a=0,i=n.reset.length;a<i;a++){s=n.reset[a].handler;b(s,"reset",false,t)}for(a=0,i=n.updatedContext.length;a<i;a++){S(l,n.updatedContext[a],false,t)}for(a=0,i=n.entered.length;a<i;a++){S(l,n.entered[a],true,t)}}catch(u){e.state=o;e.currentHandlerInfos=o.handlerInfos;throw u}e.state.queryParams=_(e,l,r.queryParams,t)}function S(e,r,t,n){var a=r.handler,i=r.context;function s(a){if(t){b(a,"enter",n)}if(n&&n.isAborted){throw new x}a.context=i;b(a,"contextDidChange");b(a,"setup",i,n);if(n&&n.isAborted){throw new x}e.push(r)}if(!a){r.handlerPromise=r.handlerPromise.then(s)}else{s(a)}return true}function A(e,r){var t=e.handlerInfos;var n=r.handlerInfos;var a={updatedContext:[],exited:[],entered:[],unchanged:[],reset:undefined};var i,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){i=true}if(i){a.entered.push(h);if(u){a.exited.unshift(u)}}else if(s||u.context!==h.context){s=true;a.updatedContext.push(h)}else{a.unchanged.push(u)}}for(o=n.length,l=t.length;o<l;o++){a.exited.unshift(t[o])}a.reset=a.updatedContext.slice();a.reset.reverse();return a}function M(e,r){var t=e.urlMethod;if(!t){return}var n=e.router,a=r.handlerInfos,i=a[a.length-1].name,s={};for(var o=a.length-1;o>=0;--o){var l=a[o];m(s,l.params);if(l.handler.inaccessibleByURL){t=null}}if(t){s.queryParams=e._visibleQueryParams||r.queryParams;var u=n.recognizer.generate(i,s);var h=e.isCausedByInitialTransition;var f=t==="replace"&&!e.isCausedByAbortingTransition;var d=e.queryParamsOnly&&t==="replace";if(h||f||d){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(a){if(!((a instanceof x))){var i=e.state.handlerInfos;e.trigger(true,"error",a,e,i[i.length-1].handler);e.abort()}throw a}}function E(e,r,t){var n=r[0]||"/";var a=r[r.length-1];var i={};if(a&&a.hasOwnProperty("queryParams")){i=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:i})}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:i})}return e.transitionByIntent(s,t)}function O(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 U(e,r){if(e.length!==r.length){return false}for(var t=0,n=e.length;t<n;++t){if(e[t].name!==r[t].name){return false}if(!j(e[t].params,r[t].params)){return false}}return true}function j(e,r){if(!e&&!r){return true}else if(!e&&!!r||!!e&&!r){return false}var t=Object.keys(e);var n=Object.keys(r);if(t.length!==n.length){return false}for(var a=0,i=t.length;a<i;++a){var s=t[a];if(e[s]!==r[s]){return false}}return true}function _(e,r,t,n){for(var a in t){if(t.hasOwnProperty(a)&&t[a]===null){delete t[a]}}var i=[];f(e,r,true,["finalizeQueryParamChange",t,i,n]);if(n){n._visibleQueryParams={}}var s={};for(var o=0,l=i.length;o<l;++o){var u=i[o];s[u.key]=u.value;if(n&&u.visible!==false){n._visibleQueryParams[u.key]=u.value}}return s}function N(e,r,t){var n=e.state.handlerInfos,a=[],i=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){i=l;break}if(!d.isResolved){a.push(h)}}if(i!==null){s=n.slice(i,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"]=k});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,a){"use strict";var i=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;a["default"]=f(i,{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,a){var i=u([this.name].concat(this.contexts)),s=i[0],o=r.handlersFor(s[0]);var l=o[o.length-1].handler;return this.applyToHandlers(e,o,t,l,n,null,a)},applyToHandlers:function(e,r,t,n,a,i,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(i){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(a&&!i){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(!a){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 a=e[t];e[t]=a.getUnresolved()}},getHandlerInfoForDynamicSegment:function(e,r,t,n,a,i,s,u){var h;if(n.length>0){h=n[n.length-1];if(l(h)){return this.createParamHandlerInfo(e,r,t,n,a)}else{n.pop()}}else if(a&&a.name===e){return a}else{if(this.preTransitionState){var f=this.preTransitionState.handlerInfos[s];h=f&&f.context}else{return a}}return o("object",{name:e,getHandler:r,serializer:u,context:h,names:t})},createParamHandlerInfo:function(e,r,t,n,a){var i={};var s=t.length;while(s--){var u=a&&e===a.name&&a.params||{};var h=n[n.length-1];var f=t[s];if(l(h)){i[f]=""+n.pop()}else{if(u.hasOwnProperty(f)){i[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:i})}})});n("router/transition-intent/url-transition-intent",["../transition-intent","../transition-state","../handler-info/factory","../utils","../unrecognized-url-error","exports"],function(e,r,t,n,a,i){"use strict";var s=e["default"];var o=r["default"];var l=t["default"];var u=n.merge;var h=n.subclass;var f=a["default"];i["default"]=h(s,{url:null,initialize:function(e){this.url=e.url},applyToState:function(e,r,t){var n=new o;var a=r.recognize(this.url),i,s;if(!a){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(i=0,s=a.length;i<s;++i){var v=a[i];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[i];if(h||p.shouldSupercede(y)){h=true;n.handlerInfos[i]=p}else{n.handlerInfos[i]=y}}u(n.queryParams,a.queryParams);return n}})});n("router/transition-state",["./utils","rsvp","exports"],function(e,r,t){"use strict";var n=e.forEach;var a=e.promiseLabel;var i=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 a("'"+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 a=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(),a.promiseLabel("Check if should continue"))["catch"](function(e){o=true;return s.reject(e)},a.promiseLabel("Handle abort"))}function u(e){var t=a.handlerInfos;var n=r.resolveIndex>=t.length?t.length-1:r.resolveIndex;return s.reject({error:e,handlerWithError:a.handlerInfos[n].handler,wasAborted:o,state:a})}function h(e){var t=a.handlerInfos[r.resolveIndex].isResolved;a.handlerInfos[r.resolveIndex++]=e;if(!t){var n=e.handler;i(n,"redirect",e.context,r)}return l().then(f,null,a.promiseLabel("Resolve handler"))}function f(){if(r.resolveIndex===a.handlerInfos.length){return{error:null,state:a}}var e=a.handlerInfos[r.resolveIndex];return e.resolve(l,r).then(h,null,a.promiseLabel("Proceed"))}}};t["default"]=o});n("router/transition",["rsvp","./utils","./transition-aborted-error","exports"],function(e,r,t,n){"use strict";var a=e.Promise;var i=r.trigger;var s=r.slice;var o=r.log;var l=r.promiseLabel;var u=t["default"];function h(e,r,t,n,i){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=a.reject(n);this.error=n;return}this.isCausedByAbortingTransition=!!i;this.isCausedByInitialTransition=i&&(i.isCausedByInitialTransition||i.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=a.resolve(this.state);this.params={}}function d(){if(s.isAborted){return a.reject(undefined,l("Transition aborted - reject"))}}}function f(e){return function(r){if(r.wasAborted||e.isAborted){return a.reject(d(e))}else{e.trigger("error",r.error,e,r.handlerWithError);e.abort();return a.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 a=r[t];if(a.name===e||a.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();var e=this.router.transitionByIntent(this.intent,false);if(this.urlMethod!==null){e.method(this.urlMethod)}return e},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}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 a.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 a(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&typeof e.then==="function"}e.isPromise=a;function i(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,a;if(t&&t>0&&e[t-1]&&e[t-1].hasOwnProperty("queryParams")){a=e[t-1].queryParams;n=r.call(e,0,t-1);return[n,a]}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,a=e[r].length;t<a;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(a){var i=r.call(n,2);i.push(a);return t.apply(e,i)}}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 a=n.shift();if(!r){if(t){return}throw new Error("Could not trigger event '"+a+"'. There are no active handlers")}var i=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,a,n));continue}if(u.events&&u.events[a]){if(u.events[a].apply(u,n)===true){i=true}else{return}}}if(a==="error"&&n[0].name==="UnrecognizedURLError"){throw n[0]}else if(!i&&!t){throw new Error("Nothing handled the event '"+a+"'.")}}e.trigger=c;function v(e,r){var t;var a={all:{},changed:{},removed:{}};i(a.all,r);var s=false;l(e);l(r);for(t in e){if(e.hasOwnProperty(t)){if(!r.hasOwnProperty(t)){s=true;a.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){a.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]){a.changed[t]=r[t];s=true}}}}else{if(e[t]!==r[t]){a.changed[t]=r[t];s=true}}}}return s&&a}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);i(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 a=g(e,r);return a&&e[a].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=i;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 a=r.Transition;t["default"]=n;t.Transition=a});n("route-recognizer",[],function(){return{"default":t}});n("rsvp",[],function(){return r});n("rsvp/promise",[],function(){return{"default":r.Promise}});window.Router=a("router")})(window,window.RSVP,window.RouteRecognizer); |
@@ -238,3 +238,14 @@ import { Promise } from 'rsvp'; | ||
var newTransition = this.router.transitionByIntent(this.intent, false); | ||
newTransition.method(this.urlMethod); | ||
// inheriting a `null` urlMethod is not valid | ||
// the urlMethod is only set to `null` when | ||
// the transition is initiated *after* the url | ||
// has been updated (i.e. `router.handleURL`) | ||
// | ||
// in that scenario, the url method cannot be | ||
// inherited for a new transition because then | ||
// the url would not update even though it should | ||
if (this.urlMethod !== null) { | ||
newTransition.method(this.urlMethod); | ||
} | ||
return newTransition; | ||
@@ -241,0 +252,0 @@ }, |
{ | ||
"name": "router_js", | ||
"namespace": "Router", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "A lightweight JavaScript library is built on top of route-recognizer and rsvp.js to provide an API for handling routes", | ||
@@ -6,0 +6,0 @@ "author": "Tilde, Inc.", |
@@ -64,6 +64,14 @@ import { Backburner } from "backburner"; | ||
function shouldNotHappen(assert) { | ||
function handleURL(router) { | ||
var result = router.handleURL.apply(router, slice.call(arguments, 1)); | ||
flushBackburner(); | ||
return result; | ||
} | ||
function shouldNotHappen(assert, _message) { | ||
var message = _message || "this .then handler should not be called"; | ||
return function _shouldNotHappen(error) { | ||
console.error(error.stack); // jshint ignore:line | ||
assert.ok(false, "this .then handler should not be called"); | ||
assert.ok(false, message); | ||
}; | ||
@@ -91,2 +99,3 @@ } | ||
flushBackburner, | ||
handleURL, | ||
transitionTo, | ||
@@ -93,0 +102,0 @@ transitionToWithAbort, |
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
Sorry, the diff of this file is not supported yet
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
875801
19290