From 6d17d0b63d177d57b18a28fa829510ddecb01b4b Mon Sep 17 00:00:00 2001 From: Morris Singer Date: Wed, 1 Jul 2015 13:58:18 -0400 Subject: [PATCH 1/2] Rebuild dist to reflect what's in src The existing build artifacts in dist did not match what was in src, meaning that users were getting an older version of the router when installing with Bower, NPM, etc. --- dist/router.es5.js | 252 ++++++++++++++++++++++++----------------- dist/router.es5.min.js | 2 +- 2 files changed, 146 insertions(+), 108 deletions(-) diff --git a/dist/router.es5.js b/dist/router.es5.js index e894e7e..df68cae 100644 --- a/dist/router.es5.js +++ b/dist/router.es5.js @@ -6,23 +6,22 @@ angular.module('ngNewRouter', []) .factory('$router', routerFactory) .value('$routeParams', {}) - .provider('$componentLoader', $componentLoaderProvider) + .factory('$componentMapper', $componentMapperFactory) .provider('$pipeline', pipelineProvider) .factory('$$pipeline', privatePipelineFactory) .factory('$setupRoutersStep', setupRoutersStepFactory) .factory('$initLocalsStep', initLocalsStepFactory) - .factory('$initControllersStep', initControllersStepFactory) .factory('$runCanDeactivateHookStep', runCanDeactivateHookStepFactory) .factory('$runCanActivateHookStep', runCanActivateHookStepFactory) .factory('$loadTemplatesStep', loadTemplatesStepFactory) .value('$activateStep', activateStepValue) - .directive('ngViewport', ngViewportDirective) - .directive('ngViewport', ngViewportFillContentDirective) + .directive('ngOutlet', ngOutletDirective) + .directive('ngOutlet', ngOutletFillContentDirective) .directive('ngLink', ngLinkDirective) .directive('a', anchorLinkDirective) - +var NOOP_CONTROLLER = function(){}; /* * A module for inspecting controller constructors @@ -48,31 +47,42 @@ controllerProviderDecorator.$inject = ["$controllerProvider", "$controllerIntros */ function $controllerIntrospectorProvider() { var controllers = []; + var constructorsByName = {}; var onControllerRegistered = null; + + function getController(constructor) { + return angular.isArray(constructor) ? constructor[constructor.length - 1] : constructor; + } + return { register: function (name, constructor) { - if (angular.isArray(constructor)) { - constructor = constructor[constructor.length - 1]; - } - if (constructor.$routeConfig) { + var controller = getController(constructor); + constructorsByName[name] = constructor; + if (controller.$routeConfig) { if (onControllerRegistered) { - onControllerRegistered(name, constructor.$routeConfig); + onControllerRegistered(name, controller.$routeConfig); } else { - controllers.push({name: name, config: constructor.$routeConfig}); + controllers.push({name: name, config: controller.$routeConfig}); } } }, - $get: ['$componentLoader', function ($componentLoader) { - return function (newOnControllerRegistered) { + $get: ['$componentMapper', function ($componentMapper) { + var fn = function (newOnControllerRegistered) { onControllerRegistered = function (name, constructor) { - name = $componentLoader.component(name); + name = $componentMapper.component(name); return newOnControllerRegistered(name, constructor); }; while(controllers.length > 0) { var rule = controllers.pop(); onControllerRegistered(rule.name, rule.config); } - } + }; + + fn.getTypeByName = function (name) { + return constructorsByName[name]; + }; + + return fn; }] } } @@ -103,20 +113,20 @@ function routerFactory($$rootRouter, $rootScope, $location, $$grammar, $controll routerFactory.$inject = ["$$rootRouter", "$rootScope", "$location", "$$grammar", "$controllerIntrospector"]; /** - * @name ngViewport + * @name ngOutlet * * @description - * An ngViewport is where resolved content goes. + * An ngOutlet is where resolved content goes. * * ## Use * * ```html - *
+ *
* ``` * - * The value for the `ngViewport` attribute is optional. + * The value for the `ngOutlet` attribute is optional. */ -function ngViewportDirective($animate, $injector, $q, $router) { +function ngOutletDirective($animate, $injector, $q, $router, $componentMapper, $controller) { var rootRouter = $router; return { @@ -124,18 +134,18 @@ function ngViewportDirective($animate, $injector, $q, $router) { transclude: 'element', terminal: true, priority: 400, - require: ['?^^ngViewport', 'ngViewport'], - link: viewportLink, + require: ['?^^ngOutlet', 'ngOutlet'], + link: outletLink, controller: function() {}, - controllerAs: '$$ngViewport' + controllerAs: '$$ngOutlet' }; function invoke(method, context, instruction) { return $injector.invoke(method, context, instruction.locals); } - function viewportLink(scope, $element, attrs, ctrls, $transclude) { - var viewportName = attrs.ngViewport || 'default', + function outletLink(scope, $element, attrs, ctrls, $transclude) { + var outletName = attrs.ngOutlet || 'default', parentCtrl = ctrls[0], myCtrl = ctrls[1], router = (parentCtrl && parentCtrl.$$router) || rootRouter; @@ -166,7 +176,7 @@ function ngViewportDirective($animate, $injector, $q, $router) { } } - router.registerViewport({ + router.registerOutlet({ canDeactivate: function(instruction) { if (currentController && currentController.canDeactivate) { return invoke(currentController.canDeactivate, currentController, instruction); @@ -179,17 +189,30 @@ function ngViewportDirective($animate, $injector, $q, $router) { return; } - instruction.locals.$scope = newScope = scope.$new(); + var controllerConstructor = instruction.controllerConstructor; + + if (!instruction.locals.$scope) { + instruction.locals.$scope = scope.$new(); + } + newScope = instruction.locals.$scope; + + if (controllerConstructor === NOOP_CONTROLLER) { + console.warn && console.warn('Could not find controller for', $componentMapper.controllerName(instruction.component)); + } + var ctrl = $controller(controllerConstructor, instruction.locals); + instruction.controllerAs = $componentMapper.controllerAs(instruction.component); + instruction.controller = ctrl; + myCtrl.$$router = instruction.router; myCtrl.$$template = instruction.template; - var componentName = instruction.component; + var controllerAs = instruction.controllerAs || instruction.component; var clone = $transclude(newScope, function(clone) { $animate.enter(clone, null, currentElement || $element); cleanupLastView(); }); var newController = instruction.controller; - newScope[componentName] = newController; + newScope[controllerAs] = newController; var result; if (currentController && currentController.deactivate) { @@ -214,7 +237,7 @@ function ngViewportDirective($animate, $injector, $q, $router) { } return result; } - }, viewportName); + }, outletName); } // TODO: how best to serialize? @@ -228,13 +251,13 @@ function ngViewportDirective($animate, $injector, $q, $router) { }); } } -ngViewportDirective.$inject = ["$animate", "$injector", "$q", "$router"]; +ngOutletDirective.$inject = ["$animate", "$injector", "$q", "$router", "$componentMapper", "$controller"]; -function ngViewportFillContentDirective($compile) { +function ngOutletFillContentDirective($compile) { return { restrict: 'EA', priority: -400, - require: 'ngViewport', + require: 'ngOutlet', link: function(scope, $element, attrs, ctrl) { var template = ctrl.$$template; $element.html(template); @@ -243,7 +266,7 @@ function ngViewportFillContentDirective($compile) { } }; } -ngViewportFillContentDirective.$inject = ["$compile"]; +ngOutletFillContentDirective.$inject = ["$compile"]; function makeComponentString(name) { return [ @@ -260,7 +283,7 @@ var LINK_MICROSYNTAX_RE = /^(.+?)(?:\((.*)\))?$/; * Lets you link to different parts of the app, and automatically generates hrefs. * * ## Use - * The directive uses a simple syntax: `router-link="componentName({ param: paramValue })"` + * The directive uses a simple syntax: `ng-link="componentName({ param: paramValue })"` * * ## Example * @@ -274,7 +297,7 @@ var LINK_MICROSYNTAX_RE = /^(.+?)(?:\((.*)\))?$/; * * ```html *
- * {{app.user.name}} + * {{app.user.name}} *
* ``` */ @@ -282,7 +305,7 @@ function ngLinkDirective($router, $location, $parse) { var rootRouter = $router; return { - require: '?^^ngViewport', + require: '?^^ngOutlet', restrict: 'A', link: ngLinkDirectiveLinkFn }; @@ -335,6 +358,9 @@ function anchorLinkDirective($router) { 'xlink:href' : 'href'; element.on('click', function(event) { + if (event.which !== 1) + return; + var href = element.attr(hrefAttrName); if (!href) { event.preventDefault(); @@ -355,12 +381,23 @@ function setupRoutersStepFactory() { } } +//TODO: rename to "normalize" step /* * $initLocalsStep */ -function initLocalsStepFactory() { +function initLocalsStepFactory($componentMapper, $controllerIntrospector) { return function initLocals(instruction) { return instruction.router.traverseInstruction(instruction, function(instruction) { + if (typeof instruction.component === 'function') { + instruction.controllerConstructor = instruction.component; + } else { + var controllerName = $componentMapper.controllerName(instruction.component); + if (typeof controllerName === 'function') { + instruction.controllerConstructor = controllerName; + } else { + instruction.controllerConstructor = $controllerIntrospector.getTypeByName(controllerName) || NOOP_CONTROLLER; + } + } return instruction.locals = { $router: instruction.router, $routeParams: (instruction.params || {}) @@ -368,31 +405,12 @@ function initLocalsStepFactory() { }); } } +initLocalsStepFactory.$inject = ["$componentMapper", "$controllerIntrospector"]; -/* - * $initControllersStep - */ -function initControllersStepFactory($controller, $componentLoader) { - return function initControllers(instruction) { - return instruction.router.traverseInstruction(instruction, function(instruction) { - var controllerName = $componentLoader.controllerName(instruction.component); - var locals = instruction.locals; - var ctrl; - try { - ctrl = $controller(controllerName, locals); - } catch(e) { - console.warn && console.warn('Could not instantiate controller', controllerName); - ctrl = $controller(angular.noop, locals); - } - return instruction.controller = ctrl; - }); - } -} -initControllersStepFactory.$inject = ["$controller", "$componentLoader"]; function runCanDeactivateHookStepFactory() { return function runCanDeactivateHook(instruction) { - return instruction.router.canDeactivatePorts(instruction); + return instruction.router.canDeactivateOutlets(instruction); }; } @@ -406,28 +424,28 @@ function runCanActivateHookStepFactory($injector) { return function runCanActivateHook(instruction) { return instruction.router.traverseInstruction(instruction, function(instruction) { - var controller = instruction.controller; - return !controller.canActivate || invoke(controller.canActivate, controller, instruction); + var controllerConstructor = instruction.controllerConstructor; + return !controllerConstructor.canActivate || invoke(controllerConstructor.canActivate, null, instruction); }); } } runCanActivateHookStepFactory.$inject = ["$injector"]; -function loadTemplatesStepFactory($componentLoader, $templateRequest) { +function loadTemplatesStepFactory($componentMapper, $templateRequest) { return function loadTemplates(instruction) { return instruction.router.traverseInstruction(instruction, function(instruction) { - var componentTemplateUrl = $componentLoader.template(instruction.component); + var componentTemplateUrl = $componentMapper.template(instruction.component); return $templateRequest(componentTemplateUrl).then(function (templateHtml) { return instruction.template = templateHtml; }); }); }; } -loadTemplatesStepFactory.$inject = ["$componentLoader", "$templateRequest"]; +loadTemplatesStepFactory.$inject = ["$componentMapper", "$templateRequest"]; function activateStepValue(instruction) { - return instruction.router.activatePorts(instruction); + return instruction.router.activateOutlets(instruction); } @@ -437,7 +455,6 @@ function pipelineProvider() { var protoStepConfiguration = [ '$setupRoutersStep', '$initLocalsStep', - '$initControllersStep', '$runCanDeactivateHookStep', '$runCanActivateHookStep', '$loadTemplatesStep', @@ -475,7 +492,7 @@ function pipelineProvider() { /** - * @name $componentLoaderProvider + * @name $componentMapper * @description * * This lets you configure conventions for what controllers are named and where to load templates from. @@ -490,7 +507,7 @@ function pipelineProvider() { * * This service makes it easy to group all of them into a single concept. */ -function $componentLoaderProvider() { +function $componentMapperFactory() { var DEFAULT_SUFFIX = 'Controller'; @@ -507,17 +524,29 @@ function $componentLoaderProvider() { return name[0].toLowerCase() + name.substr(1, name.length - DEFAULT_SUFFIX.length - 1); }; + var componentToControllerAs = function componentToControllerAsDefault(name) { + return name; + }; + return { - $get: function () { - return { - controllerName: componentToCtrl, - template: componentToTemplate, - component: ctrlToComponent - }; + controllerName: function (name) { + return componentToCtrl(name); + }, + + controllerAs: function (name) { + return componentToControllerAs(name); + }, + + template: function (name) { + return componentToTemplate(name); + }, + + component: function (name) { + return ctrlToComponent(name); }, /** - * @name $componentLoaderProvider#setCtrlNameMapping + * @name $componentMapper#setCtrlNameMapping * @description takes a function for mapping component names to component controller names */ setCtrlNameMapping: function(newFn) { @@ -526,7 +555,16 @@ function $componentLoaderProvider() { }, /** - * @name $componentLoaderProvider#setCtrlNameMapping + * @name $componentMapper#setCtrlAsMapping + * @description takes a function for mapping component names to controllerAs name in the template + */ + setCtrlAsMapping: function(newFn) { + componentToControllerAs = newFn; + return this; + }, + + /** + * @name $componentMapper#setComponentFromCtrlMapping * @description takes a function for mapping component controller names to component names */ setComponentFromCtrlMapping: function (newFn) { @@ -535,7 +573,7 @@ function $componentLoaderProvider() { }, /** - * @name $componentLoaderProvider#setTemplateMapping + * @name $componentMapper#setTemplateMapping * @description takes a function for mapping component names to component template URLs */ setTemplateMapping: function(newFn) { @@ -649,7 +687,7 @@ var Router = function Router(grammar, pipeline, parent, name) { this.name = name; this.parent = parent || null; this.navigating = false; - this.ports = {}; + this.outlets = {}; this.children = {}; this.registry = grammar; this.pipeline = pipeline; @@ -662,9 +700,9 @@ var Router = function Router(grammar, pipeline, parent, name) { } return this.children[name]; }, - registerViewport: function(view) { + registerOutlet: function(view) { var name = arguments[1] !== (void 0) ? arguments[1] : 'default'; - this.ports[name] = view; + this.outlets[name] = view; return this.renavigate(); }, config: function(mapping) { @@ -704,10 +742,10 @@ var Router = function Router(grammar, pipeline, parent, name) { }, traverseInstructionSync: function(instruction, fn) { var $__0 = this; - forEach(instruction.viewports, (function(childInstruction, viewportName) { + forEach(instruction.outlets, (function(childInstruction, outletName) { return fn(instruction, childInstruction); })); - forEach(instruction.viewports, (function(childInstruction) { + forEach(instruction.outlets, (function(childInstruction) { return $__0.traverseInstructionSync(childInstruction, fn); })); }, @@ -715,38 +753,38 @@ var Router = function Router(grammar, pipeline, parent, name) { if (!instruction) { return $q.when(); } - return mapObjAsync(instruction.viewports, (function(childInstruction, viewportName) { - return boolToPromise(fn(childInstruction, viewportName)); + return mapObjAsync(instruction.outlets, (function(childInstruction, outletName) { + return boolToPromise(fn(childInstruction, outletName)); })).then((function() { - return mapObjAsync(instruction.viewports, (function(childInstruction, viewportName) { + return mapObjAsync(instruction.outlets, (function(childInstruction, outletName) { return childInstruction.router.traverseInstruction(childInstruction, fn); })); })); }, - activatePorts: function(instruction) { - return this.queryViewports((function(port, name) { - return port.activate(instruction.viewports[name]); + activateOutlets: function(instruction) { + return this.queryOutlets((function(outlet, name) { + return outlet.activate(instruction.outlets[name]); })).then((function() { - return mapObjAsync(instruction.viewports, (function(instruction) { - return instruction.router.activatePorts(instruction); + return mapObjAsync(instruction.outlets, (function(instruction) { + return instruction.router.activateOutlets(instruction); })); })); }, - canDeactivatePorts: function(instruction) { - return this.traversePorts((function(port, name) { - return boolToPromise(port.canDeactivate(instruction.viewports[name])); + canDeactivateOutlets: function(instruction) { + return this.traverseOutlets((function(outlet, name) { + return boolToPromise(outlet.canDeactivate(instruction.outlets[name])); })); }, - traversePorts: function(fn) { + traverseOutlets: function(fn) { var $__0 = this; - return this.queryViewports(fn).then((function() { + return this.queryOutlets(fn).then((function() { return mapObjAsync($__0.children, (function(child) { - return child.traversePorts(fn); + return child.traverseOutlets(fn); })); })); }, - queryViewports: function(fn) { - return mapObjAsync(this.ports, fn); + queryOutlets: function(fn) { + return mapObjAsync(this.outlets, fn); }, recognize: function(url) { return this.registry.recognize(url); @@ -1441,23 +1479,23 @@ var Grammar = function Grammar() { var lastHandler = lastContextChunk.handler; var lastParams = lastContextChunk.params; var instruction = { - viewports: {}, + outlets: {}, params: lastParams }; if (lastParams && lastParams.childRoute) { var childUrl = '/' + lastParams.childRoute; instruction.canonicalUrl = lastHandler.rewroteUrl.substr(0, lastHandler.rewroteUrl.length - (lastParams.childRoute.length + 1)); - forEach(lastHandler.components, (function(componentName, viewportName) { - instruction.viewports[viewportName] = $__0.recognize(childUrl, componentName); + forEach(lastHandler.components, (function(componentName, outletName) { + instruction.outlets[outletName] = $__0.recognize(childUrl, componentName); })); - instruction.canonicalUrl += instruction.viewports[Object.keys(instruction.viewports)[0]].canonicalUrl; + instruction.canonicalUrl += instruction.outlets[Object.keys(instruction.outlets)[0]].canonicalUrl; } else { instruction.canonicalUrl = lastHandler.rewroteUrl; - forEach(lastHandler.components, (function(componentName, viewportName) { - instruction.viewports[viewportName] = {viewports: {}}; + forEach(lastHandler.components, (function(componentName, outletName) { + instruction.outlets[outletName] = {outlets: {}}; })); } - forEach(instruction.viewports, (function(instruction, componentName) { + forEach(instruction.outlets, (function(instruction, componentName) { instruction.component = lastHandler.components[componentName]; instruction.params = lastParams; })); @@ -1542,8 +1580,8 @@ var CanonicalRecognizer = function CanonicalRecognizer(name) { if (mapping.as) { aliases = [mapping.as]; } else { - aliases = mapObj(mapping.components, (function(componentName, viewportName) { - return viewportName + ':' + componentName; + aliases = mapObj(mapping.components, (function(componentName, outletName) { + return outletName + ':' + componentName; })); if (mapping.components.default) { aliases.push(mapping.components.default); diff --git a/dist/router.es5.min.js b/dist/router.es5.min.js index abeb48b..28d9aba 100644 --- a/dist/router.es5.min.js +++ b/dist/router.es5.min.js @@ -1 +1 @@ -"use strict";function controllerProviderDecorator(t,e){var r=t.register;t.register=function(t,n){return e.register(t,n),r.apply(this,arguments)}}function $controllerIntrospectorProvider(){var t=[],e=null;return{register:function(r,n){angular.isArray(n)&&(n=n[n.length-1]),n.$routeConfig&&(e?e(r,n.$routeConfig):t.push({name:r,config:n.$routeConfig}))},$get:["$componentLoader",function(r){return function(n){for(e=function(t,e){return t=r.component(t),n(t,e)};t.length>0;){var o=t.pop();e(o.name,o.config)}}}]}}function routerFactory(t,e,r,n,o){o(function(t,e){n.config(t,e)}),e.$watch(function(){return r.path()},function(e){t.navigate(e)});var i=t.navigate;return t.navigate=function(t){return i.call(this,t).then(function(t){t&&r.path(t)})},t}function ngViewportDirective(t,e,r,n){function o(t,r,n){return e.invoke(t,r,n.locals)}function i(e,n,i,u,s){function p(){g&&(t.cancel(g),g=null),l&&(l.$destroy(),l=null),v&&(g=t.leave(v),g.then(function(){g=null}),v=null)}var l,f,h,v,g,d,m=i.ngViewport||"default",y=u[0],w=u[1],$=y&&y.$$router||c;$.registerViewport({canDeactivate:function(t){return h&&h.canDeactivate?o(h.canDeactivate,h,t):!0},activate:function(i){var c=a(i);if(c!==d){i.locals.$scope=f=e.$new(),w.$$router=i.router,w.$$template=i.template;var u=i.component,g=s(f,function(e){t.enter(e,null,v||n),p()}),m=i.controller;f[u]=m;var y;if(h&&h.deactivate&&(y=r.when(o(h.deactivate,h,i))),h=m,v=g,l=f,d=c,m.activate){var $=r.when(o(m.activate,m,i));return y?y.then($):$}return y}}},m)}function a(t){return JSON.stringify({path:t.path,component:t.component,params:Object.keys(t.params).reduce(function(e,r){return"childRoute"!==r&&(e[r]=t.params[r]),e},{})})}var c=n;return{restrict:"AE",transclude:"element",terminal:!0,priority:400,require:["?^^ngViewport","ngViewport"],link:i,controller:function(){},controllerAs:"$$ngViewport"}}function ngViewportFillContentDirective(t){return{restrict:"EA",priority:-400,require:"ngViewport",link:function(e,r,n,o){var i=o.$$template;r.html(i);var a=t(r.contents());a(e)}}}function makeComponentString(t){return['',""].join("")}function ngLinkDirective(t,e,r){function n(t,e,n,i){var a=i&&i.$$router||o;if(a){var c,u=n.ngLink||"",s=u.match(LINK_MICROSYNTAX_RE),p=s[1],l=s[2];if(l){var f=r(l);if(f.constant){var h=f();c="."+a.generate(p,h),e.attr("href",c)}else t.$watch(function(){return f(t)},function(t){c="."+a.generate(p,t),e.attr("href",c)},!0)}else c="."+a.generate(p),e.attr("href",c)}}var o=t;return{require:"?^^ngViewport",restrict:"A",link:n}}function anchorLinkDirective(t){return{restrict:"E",link:function(e,r){if("a"===r[0].nodeName.toLowerCase()){var n="[object SVGAnimatedString]"===Object.prototype.toString.call(r.prop("href"))?"xlink:href":"href";r.on("click",function(e){var o=r.attr(n);o||e.preventDefault(),t.recognize(o)&&(t.navigate(o),e.preventDefault())})}}}}function setupRoutersStepFactory(){return function(t){return t.router.makeDescendantRouters(t)}}function initLocalsStepFactory(){return function(t){return t.router.traverseInstruction(t,function(t){return t.locals={$router:t.router,$routeParams:t.params||{}}})}}function initControllersStepFactory(t,e){return function(r){return r.router.traverseInstruction(r,function(r){var n,o=e.controllerName(r.component),i=r.locals;try{n=t(o,i)}catch(a){console.warn&&console.warn("Could not instantiate controller",o),n=t(angular.noop,i)}return r.controller=n})}}function runCanDeactivateHookStepFactory(){return function(t){return t.router.canDeactivatePorts(t)}}function runCanActivateHookStepFactory(t){function e(e,r,n){return t.invoke(e,r,{$routeParams:n.params})}return function(t){return t.router.traverseInstruction(t,function(t){var r=t.controller;return!r.canActivate||e(r.canActivate,r,t)})}}function loadTemplatesStepFactory(t,e){return function(r){return r.router.traverseInstruction(r,function(r){var n=t.template(r.component);return e(n).then(function(t){return r.template=t})})}}function activateStepValue(t){return t.router.activatePorts(t)}function pipelineProvider(){var t,e=["$setupRoutersStep","$initLocalsStep","$initControllersStep","$runCanDeactivateHookStep","$runCanActivateHookStep","$loadTemplatesStep","$activateStep"];return{steps:e.slice(0),config:function(t){e=t},$get:["$injector","$q",function(r,n){return t=e.map(function(t){return r.get(t)}),{process:function(e){function r(t){if(0===o.length)return t;var i=o.shift();return n.when(i(e)).then(r)}var o=t.slice(0);return r()}}}]}}function $componentLoaderProvider(){var t="Controller",e=function(e){return e[0].toUpperCase()+e.substr(1)+t},r=function(t){var e=dashCase(t);return"./components/"+e+"/"+e+".html"},n=function(e){return e[0].toLowerCase()+e.substr(1,e.length-t.length-1)};return{$get:function(){return{controllerName:e,template:r,component:n}},setCtrlNameMapping:function(t){return e=t,this},setComponentFromCtrlMapping:function(t){return n=t,this},setTemplateMapping:function(t){return r=t,this}}}function privatePipelineFactory(t){return t}function dashCase(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}angular.module("ngNewRouter",[]).factory("$router",routerFactory).value("$routeParams",{}).provider("$componentLoader",$componentLoaderProvider).provider("$pipeline",pipelineProvider).factory("$$pipeline",privatePipelineFactory).factory("$setupRoutersStep",setupRoutersStepFactory).factory("$initLocalsStep",initLocalsStepFactory).factory("$initControllersStep",initControllersStepFactory).factory("$runCanDeactivateHookStep",runCanDeactivateHookStepFactory).factory("$runCanActivateHookStep",runCanActivateHookStepFactory).factory("$loadTemplatesStep",loadTemplatesStepFactory).value("$activateStep",activateStepValue).directive("ngViewport",ngViewportDirective).directive("ngViewport",ngViewportFillContentDirective).directive("ngLink",ngLinkDirective).directive("a",anchorLinkDirective),angular.module("ng").provider("$controllerIntrospector",$controllerIntrospectorProvider).config(controllerProviderDecorator),controllerProviderDecorator.$inject=["$controllerProvider","$controllerIntrospectorProvider"],routerFactory.$inject=["$$rootRouter","$rootScope","$location","$$grammar","$controllerIntrospector"],ngViewportDirective.$inject=["$animate","$injector","$q","$router"],ngViewportFillContentDirective.$inject=["$compile"];var LINK_MICROSYNTAX_RE=/^(.+?)(?:\((.*)\))?$/;ngLinkDirective.$inject=["$router","$location","$parse"],anchorLinkDirective.$inject=["$router"],initControllersStepFactory.$inject=["$controller","$componentLoader"],runCanActivateHookStepFactory.$inject=["$injector"],loadTemplatesStepFactory.$inject=["$componentLoader","$templateRequest"],privatePipelineFactory.$inject=["$pipeline"],angular.module("ngNewRouter").factory("$$rootRouter",["$q","$$grammar","$$pipeline",function(t,e,r){function n(t,e,r,n){return h(e,"constructor",{value:t,configurable:!0,enumerable:!1,writable:!0}),arguments.length>3?("function"==typeof n&&(t.__proto__=n),t.prototype=g(o(n),i(e))):t.prototype=e,h(t,"prototype",{configurable:!1,writable:!1}),v(t,i(r))}function o(t){if("function"==typeof t){var e=t.prototype;if(Object(e)===e||null===e)return t.prototype;throw new TypeError("super prototype must be an Object or null")}if(null===t)return null;throw new TypeError("Super expression must either be null or a function, not "+typeof t+".")}function i(t){for(var e={},r=m(t),n=0;n3?("function"==typeof i&&(t.__proto__=i),t.prototype=u(e(i),r(n))):t.prototype=n,a(t,"prototype",{configurable:!1,writable:!1}),c(t,r(o))}function e(t){if("function"==typeof t){var e=t.prototype;if(Object(e)===e||null===e)return t.prototype;throw new TypeError("super prototype must be an Object or null")}if(null===t)return null;throw new TypeError("Super expression must either be null or a function, not "+typeof t+".")}function r(t){for(var e={},r=p(t),n=0;ns;s++){var l,f=c[s];(l=f.match(/^:([^\/]+)$/))?(u.push(new r(l[1])),i.push(l[1]),a.dynamics++):(l=f.match(/^\*([^\/]+)$/))?(u.push(new n(l[1])),i.push(l[1]),a.stars++):""===f?u.push(new o):(u.push(new e(f)),a.statics++)}return u}function a(t){this.charSpec=t,this.nextStates=[]}function c(t){return t.sort(function(t,e){if(t.types.stars!==e.types.stars)return t.types.stars-e.types.stars;if(t.types.stars){if(t.types.statics!==e.types.statics)return e.types.statics-t.types.statics;if(t.types.dynamics!==e.types.dynamics)return e.types.dynamics-t.types.dynamics}return t.types.dynamics!==e.types.dynamics?t.types.dynamics-e.types.dynamics:t.types.statics!==e.types.statics?e.types.statics-t.types.statics:0})}function u(t,e){for(var r=[],n=0,o=t.length;o>n;n++){var i=t[n];r=r.concat(i.match(e))}return r}function s(t){this.queryParams=t||{}}function p(t,e,r){for(var n=t.handlers,o=t.regex,i=e.match(o),a=1,c=new s(r),u=0,p=n.length;p>u;u++){for(var l=n[u],f=l.names,h={},v=0,g=f.length;g>v;v++)h[f[v]]=i[a++];c.push({handler:l.handler,params:h,isDynamic:!!f.length})}return c}function l(t,e){return e.eachChar(function(e){t=t.put(e)}),t}var f=function(){function t(t,e,r){this.path=t,this.matcher=e,this.delegate=r}function e(t){this.routes={},this.children={},this.target=t}function r(e,n,o){return function(i,a){var c=e+i;return a?void a(r(c,n,o)):new t(e+i,n,o)}}function n(t,e,r){for(var n=0,o=0,i=t.length;i>o;o++)n+=t[o].path.length;e=e.substr(n);var a={path:e,handler:r};t.push(a)}function o(t,e,r,i){var a=e.routes;for(var c in a)if(a.hasOwnProperty(c)){var u=t.slice();n(u,c,a[c]),e.children[c]?o(u,e.children[c],r,i):r.call(i,u)}}return t.prototype={to:function(t,e){var r=this.delegate;if(r&&r.willAddRoute&&(t=r.willAddRoute(this.matcher.target,t)),this.matcher.add(this.path,t),e){if(0===e.length)throw new Error("You must have an argument in the function passed to `to`");this.matcher.addChild(this.path,t,e,this.delegate)}return this}},e.prototype={add:function(t,e){this.routes[t]=e},addChild:function(t,n,o,i){var a=new e(n);this.children[t]=a;var c=r(t,a,i);i&&i.contextEntered&&i.contextEntered(n,c),o(c)}},function(t,n){var i=new e;t(r("",i,this.delegate)),o([],i,function(t){n?n(this,t):this.add(t)},this)}}(),h=["/",".","*","+","?","|","(",")","[","]","{","}","\\"],v=new RegExp("(\\"+h.join("|\\")+")","g");e.prototype={eachChar:function(t){for(var e,r=this.string,n=0,o=r.length;o>n;n++)e=r.charAt(n),t({validChars:e})},regex:function(){return this.string.replace(v,"\\$1")},generate:function(){return this.string}},r.prototype={eachChar:function(t){t({invalidChars:"/",repeat:!0})},regex:function(){return"([^/]+)"},generate:function(t){return t[this.name]}},n.prototype={eachChar:function(t){t({invalidChars:"",repeat:!0})},regex:function(){return"(.+)"},generate:function(t){return t[this.name]}},o.prototype={eachChar:function(){},regex:function(){return""},generate:function(){return""}},a.prototype={get:function(t){for(var e=this.nextStates,r=0,n=e.length;n>r;r++){var o=e[r],i=o.charSpec.validChars===t.validChars;if(i=i&&o.charSpec.invalidChars===t.invalidChars)return o}},put:function(t){var e;return(e=this.get(t))?e:(e=new a(t),this.nextStates.push(e),t.repeat&&e.nextStates.push(e),e)},match:function(t){for(var e,r,n,o=this.nextStates,i=[],a=0,c=o.length;c>a;a++)e=o[a],r=e.charSpec,"undefined"!=typeof(n=r.validChars)?-1!==n.indexOf(t)&&i.push(e):"undefined"!=typeof(n=r.invalidChars)&&-1===n.indexOf(t)&&i.push(e);return i}};var g=Object.create||function(t){function e(){}return e.prototype=t,new e};s.prototype=g({splice:Array.prototype.splice,slice:Array.prototype.slice,push:Array.prototype.push,length:0,queryParams:null});var d=function(){this.rootState=new a,this.names={}};return d.prototype={add:function(t,e){for(var r,n=this.rootState,a="^",c={statics:0,dynamics:0,stars:0},u=[],s=[],p=!0,f=0,h=t.length;h>f;f++){var v=t[f],g=[],d=i(v.path,g,c);s=s.concat(d);for(var m=0,y=d.length;y>m;m++){var w=d[m];w instanceof o||(p=!1,n=n.put({validChars:"/"}),a+="/",n=l(n,w),a+=w.regex())}var $={handler:v.handler,names:g};u.push($)}p&&(n=n.put({validChars:"/"}),a+="/"),n.handlers=u,n.regex=new RegExp(a+"$"),n.types=c,(r=e&&e.as)&&(this.names[r]={segments:s,handlers:u})},handlersFor:function(t){var e=this.names[t],r=[];if(!e)throw new Error("There is no route named "+t);for(var n=0,o=e.handlers.length;o>n;n++)r.push(e.handlers[n]);return r},hasRoute:function(t){return!!this.names[t]},generate:function(t,e){var r=this.names[t],n="";if(!r)throw new Error("There is no route named "+t);for(var i=r.segments,a=0,c=i.length;c>a;a++){var u=i[a];u instanceof o||(n+="/",n+=u.generate(e))}return"/"!==n.charAt(0)&&(n="/"+n),e&&e.queryParams&&(n+=this.generateQueryString(e.queryParams,r.handlers)),n},generateQueryString:function(e){var r=[],n=[];for(var o in e)e.hasOwnProperty(o)&&n.push(o);n.sort();for(var i=0,a=n.length;a>i;i++){o=n[i];var c=e[o];if(null!=c){var u=encodeURIComponent(o);if(t(c))for(var s=0,p=c.length;p>s;s++){var l=o+"[]="+encodeURIComponent(c[s]);r.push(l)}else u+="="+encodeURIComponent(c),r.push(u)}}return 0===r.length?"":"?"+r.join("&")},parseQueryString:function(t){for(var e=t.split("&"),r={},n=0;n2&&"[]"===a.slice(c-2)&&(u=!0,a=a.slice(0,c-2),r[a]||(r[a]=[])),o=i[1]?decodeURIComponent(i[1]):""),u?r[a].push(o):r[a]=o}return r},recognize:function(t){var e,r,n,o,i=[this.rootState],a={},s=!1;if(o=t.indexOf("?"),-1!==o){var l=t.substr(o+1,t.length);t=t.substr(0,o),a=this.parseQueryString(l)}for(t=decodeURI(t),"/"!==t.charAt(0)&&(t="/"+t),e=t.length,e>1&&"/"===t.charAt(e-1)&&(t=t.substr(0,e-1),s=!0),r=0,n=t.length;n>r&&(i=u(i,t.charAt(r)),i.length);r++);var f=[];for(r=0,n=i.length;n>r;r++)i[r].handlers&&f.push(i[r]);i=c(f);var h=f[0];return h&&h.handlers?(s&&"(.+)$"===h.regex.source.slice(-5)&&(t+="/"),p(h,t,a)):void 0}},d.prototype.map=f,d.VERSION="VERSION_STRING_PLACEHOLDER",d}()),f="/*childRoute",h=function(){this.rules={}};t(h,{config:function(t,e){"app"===t&&(t="/"),this.rules[t]||(this.rules[t]=new v(t)),this.rules[t].config(e)},recognize:function(t){var e=void 0!==arguments[1]?arguments[1]:"/",r=this;if("undefined"!=typeof t){var n=this.rules[e];if(n){var i=n.recognize(t);if(i){var a=i[i.length-1],c=a.handler,u=a.params,s={viewports:{},params:u};if(u&&u.childRoute){var p="/"+u.childRoute;s.canonicalUrl=c.rewroteUrl.substr(0,c.rewroteUrl.length-(u.childRoute.length+1)),o(c.components,function(t,e){s.viewports[e]=r.recognize(p,t)}),s.canonicalUrl+=s.viewports[Object.keys(s.viewports)[0]].canonicalUrl}else s.canonicalUrl=c.rewroteUrl,o(c.components,function(t,e){s.viewports[e]={viewports:{}}});return o(s.viewports,function(t,e){t.component=c.components[e],t.params=u}),s}}}},generate:function(t,e){var r,n="";do{if(r=null,o(this.rules,function(o){o.hasRoute(t)&&(n=o.generate(t,e)+n,r=o)}),!r)return"";t=r.name}while("/"!==r.name);return n}},{}),Object.defineProperty(h.prototype.recognize,"parameters",{get:function(){return[[$traceurRuntime.type.string],[]]}});var v=function(t){this.name=t,this.rewrites={},this.recognizer=new l};return t(v,{config:function(t){var e=this;t instanceof Array?t.forEach(function(t){return e.configOne(t)}):this.configOne(t)},getCanonicalUrl:function(t){return"."===t[0]&&(t=t.substr(1)),(""===t||"/"!==t[0])&&(t="/"+t),o(this.rewrites,function(e,r){"/"===r?"/"===t&&(t=e):0===t.indexOf(r)&&(t=t.replace(r,e))}),t},configOne:function(t){var e=this;if(t.redirectTo){if(this.rewrites[t.path])throw new Error('"'+t.path+'" already maps to "'+this.rewrites[t.path]+'"');return void(this.rewrites[t.path]=t.redirectTo)}if(t.component){if(t.components)throw new Error('A route config should have either a "component" or "components" property, but not both.');t.components=t.component,delete t.component}"string"==typeof t.components&&(t.components={"default":t.components});var r;t.as?r=[t.as]:(r=i(t.components,function(t,e){return e+":"+t}),t.components["default"]&&r.push(t.components["default"])),r.forEach(function(r){return e.recognizer.add([{path:t.path,handler:t}],{as:r})});var o=n(t);o.path+=f,this.recognizer.add([{path:o.path,handler:o}])},recognize:function(t){var e=this.getCanonicalUrl(t),r=this.recognizer.recognize(e);return r&&(r[0].handler.rewroteUrl=e),r},generate:function(t,e){return this.recognizer.generate(t,e)},hasRoute:function(t){return this.recognizer.hasRoute(t)}},{}),new h}]); \ No newline at end of file +"use strict";function controllerProviderDecorator(t,e){var n=t.register;t.register=function(t,r){return e.register(t,r),n.apply(this,arguments)}}function $controllerIntrospectorProvider(){function t(t){return angular.isArray(t)?t[t.length-1]:t}var e=[],n={},r=null;return{register:function(o,i){var a=t(i);n[o]=i,a.$routeConfig&&(r?r(o,a.$routeConfig):e.push({name:o,config:a.$routeConfig}))},$get:["$componentMapper",function(t){var o=function(n){for(r=function(e,r){return e=t.component(e),n(e,r)};e.length>0;){var o=e.pop();r(o.name,o.config)}};return o.getTypeByName=function(t){return n[t]},o}]}}function routerFactory(t,e,n,r,o){o(function(t,e){r.config(t,e)}),e.$watch(function(){return n.path()},function(e){t.navigate(e)});var i=t.navigate;return t.navigate=function(t){return i.call(this,t).then(function(t){t&&n.path(t)})},t}function ngOutletDirective(t,e,n,r,o,i){function a(t,n,r){return e.invoke(t,n,r.locals)}function u(e,r,u,l,p){function f(){y&&(t.cancel(y),y=null),h&&(h.$destroy(),h=null),m&&(y=t.leave(m),y.then(function(){y=null}),m=null)}var h,g,v,m,y,d,$=u.ngOutlet||"default",O=l[0],w=l[1],C=O&&O.$$router||s;C.registerOutlet({canDeactivate:function(t){return v&&v.canDeactivate?a(v.canDeactivate,v,t):!0},activate:function(u){var s=c(u);if(s!==d){var l=u.controllerConstructor;u.locals.$scope||(u.locals.$scope=e.$new()),g=u.locals.$scope,l===NOOP_CONTROLLER&&console.warn&&console.warn("Could not find controller for",o.controllerName(u.component));var y=i(l,u.locals);u.controllerAs=o.controllerAs(u.component),u.controller=y,w.$$router=u.router,w.$$template=u.template;var $=u.controllerAs||u.component,O=p(g,function(e){t.enter(e,null,m||r),f()}),C=u.controller;g[$]=C;var S;if(v&&v.deactivate&&(S=n.when(a(v.deactivate,v,u))),v=C,m=O,h=g,d=s,C.activate){var b=n.when(a(C.activate,C,u));return S?S.then(b):b}return S}}},$)}function c(t){return JSON.stringify({path:t.path,component:t.component,params:Object.keys(t.params).reduce(function(e,n){return"childRoute"!==n&&(e[n]=t.params[n]),e},{})})}var s=r;return{restrict:"AE",transclude:"element",terminal:!0,priority:400,require:["?^^ngOutlet","ngOutlet"],link:u,controller:function(){},controllerAs:"$$ngOutlet"}}function ngOutletFillContentDirective(t){return{restrict:"EA",priority:-400,require:"ngOutlet",link:function(e,n,r,o){var i=o.$$template;n.html(i);var a=t(n.contents());a(e)}}}function makeComponentString(t){return['',""].join("")}function ngLinkDirective(t,e,n){function r(t,e,r,i){var a=i&&i.$$router||o;if(a){var u,c=r.ngLink||"",s=c.match(LINK_MICROSYNTAX_RE),l=s[1],p=s[2];if(p){var f=n(p);if(f.constant){var h=f();u="."+a.generate(l,h),e.attr("href",u)}else t.$watch(function(){return f(t)},function(t){u="."+a.generate(l,t),e.attr("href",u)},!0)}else u="."+a.generate(l),e.attr("href",u)}}var o=t;return{require:"?^^ngOutlet",restrict:"A",link:r}}function anchorLinkDirective(t){return{restrict:"E",link:function(e,n){if("a"===n[0].nodeName.toLowerCase()){var r="[object SVGAnimatedString]"===Object.prototype.toString.call(n.prop("href"))?"xlink:href":"href";n.on("click",function(e){if(1===e.which){var o=n.attr(r);o||e.preventDefault(),t.recognize(o)&&(t.navigate(o),e.preventDefault())}})}}}}function setupRoutersStepFactory(){return function(t){return t.router.makeDescendantRouters(t)}}function initLocalsStepFactory(t,e){return function(n){return n.router.traverseInstruction(n,function(n){if("function"==typeof n.component)n.controllerConstructor=n.component;else{var r=t.controllerName(n.component);n.controllerConstructor="function"==typeof r?r:e.getTypeByName(r)||NOOP_CONTROLLER}return n.locals={$router:n.router,$routeParams:n.params||{}}})}}function runCanDeactivateHookStepFactory(){return function(t){return t.router.canDeactivateOutlets(t)}}function runCanActivateHookStepFactory(t){function e(e,n,r){return t.invoke(e,n,{$routeParams:r.params})}return function(t){return t.router.traverseInstruction(t,function(t){var n=t.controllerConstructor;return!n.canActivate||e(n.canActivate,null,t)})}}function loadTemplatesStepFactory(t,e){return function(n){return n.router.traverseInstruction(n,function(n){var r=t.template(n.component);return e(r).then(function(t){return n.template=t})})}}function activateStepValue(t){return t.router.activateOutlets(t)}function pipelineProvider(){var t,e=["$setupRoutersStep","$initLocalsStep","$runCanDeactivateHookStep","$runCanActivateHookStep","$loadTemplatesStep","$activateStep"];return{steps:e.slice(0),config:function(t){e=t},$get:["$injector","$q",function(n,r){return t=e.map(function(t){return n.get(t)}),{process:function(e){function n(t){if(0===o.length)return t;var i=o.shift();return r.when(i(e)).then(n)}var o=t.slice(0);return n()}}}]}}function $componentMapperFactory(){var t="Controller",e=function(e){return e[0].toUpperCase()+e.substr(1)+t},n=function(t){var e=dashCase(t);return"./components/"+e+"/"+e+".html"},r=function(e){return e[0].toLowerCase()+e.substr(1,e.length-t.length-1)},o=function(t){return t};return{controllerName:function(t){return e(t)},controllerAs:function(t){return o(t)},template:function(t){return n(t)},component:function(t){return r(t)},setCtrlNameMapping:function(t){return e=t,this},setCtrlAsMapping:function(t){return o=t,this},setComponentFromCtrlMapping:function(t){return r=t,this},setTemplateMapping:function(t){return n=t,this}}}function privatePipelineFactory(t){return t}function dashCase(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}angular.module("ngNewRouter",[]).factory("$router",routerFactory).value("$routeParams",{}).factory("$componentMapper",$componentMapperFactory).provider("$pipeline",pipelineProvider).factory("$$pipeline",privatePipelineFactory).factory("$setupRoutersStep",setupRoutersStepFactory).factory("$initLocalsStep",initLocalsStepFactory).factory("$runCanDeactivateHookStep",runCanDeactivateHookStepFactory).factory("$runCanActivateHookStep",runCanActivateHookStepFactory).factory("$loadTemplatesStep",loadTemplatesStepFactory).value("$activateStep",activateStepValue).directive("ngOutlet",ngOutletDirective).directive("ngOutlet",ngOutletFillContentDirective).directive("ngLink",ngLinkDirective).directive("a",anchorLinkDirective);var NOOP_CONTROLLER=function(){};angular.module("ng").provider("$controllerIntrospector",$controllerIntrospectorProvider).config(controllerProviderDecorator),controllerProviderDecorator.$inject=["$controllerProvider","$controllerIntrospectorProvider"],routerFactory.$inject=["$$rootRouter","$rootScope","$location","$$grammar","$controllerIntrospector"],ngOutletDirective.$inject=["$animate","$injector","$q","$router","$componentMapper","$controller"],ngOutletFillContentDirective.$inject=["$compile"];var LINK_MICROSYNTAX_RE=/^(.+?)(?:\((.*)\))?$/;ngLinkDirective.$inject=["$router","$location","$parse"],anchorLinkDirective.$inject=["$router"],initLocalsStepFactory.$inject=["$componentMapper","$controllerIntrospector"],runCanActivateHookStepFactory.$inject=["$injector"],loadTemplatesStepFactory.$inject=["$componentMapper","$templateRequest"],privatePipelineFactory.$inject=["$pipeline"],angular.module("ngNewRouter").factory("$$rootRouter",["$q","$$grammar","$$pipeline",function(t,e,n){function r(t,e,n,r){return h(e,"constructor",{value:t,configurable:!0,enumerable:!1,writable:!0}),arguments.length>3?("function"==typeof r&&(t.__proto__=r),t.prototype=v(o(r),i(e))):t.prototype=e,h(t,"prototype",{configurable:!1,writable:!1}),g(t,i(n))}function o(t){if("function"==typeof t){var e=t.prototype;if(Object(e)===e||null===e)return t.prototype;throw new TypeError("super prototype must be an Object or null")}if(null===t)return null;throw new TypeError("Super expression must either be null or a function, not "+typeof t+".")}function i(t){for(var e={},n=y(t),r=0;r3?("function"==typeof i&&(t.__proto__=i),t.prototype=s(n(i),r(e))):t.prototype=e,u(t,"prototype",{configurable:!1,writable:!1}),c(t,r(o))}function n(t){if("function"==typeof t){var e=t.prototype;if(Object(e)===e||null===e)return t.prototype;throw new TypeError("super prototype must be an Object or null")}if(null===t)return null;throw new TypeError("Super expression must either be null or a function, not "+typeof t+".")}function r(t){for(var e={},n=p(t),r=0;rs;s++){var p,f=u[s];(p=f.match(/^:([^\/]+)$/))?(c.push(new n(p[1])),i.push(p[1]),a.dynamics++):(p=f.match(/^\*([^\/]+)$/))?(c.push(new r(p[1])),i.push(p[1]),a.stars++):""===f?c.push(new o):(c.push(new e(f)),a.statics++)}return c}function a(t){this.charSpec=t,this.nextStates=[]}function u(t){return t.sort(function(t,e){if(t.types.stars!==e.types.stars)return t.types.stars-e.types.stars;if(t.types.stars){if(t.types.statics!==e.types.statics)return e.types.statics-t.types.statics;if(t.types.dynamics!==e.types.dynamics)return e.types.dynamics-t.types.dynamics}return t.types.dynamics!==e.types.dynamics?t.types.dynamics-e.types.dynamics:t.types.statics!==e.types.statics?e.types.statics-t.types.statics:0})}function c(t,e){for(var n=[],r=0,o=t.length;o>r;r++){var i=t[r];n=n.concat(i.match(e))}return n}function s(t){this.queryParams=t||{}}function l(t,e,n){for(var r=t.handlers,o=t.regex,i=e.match(o),a=1,u=new s(n),c=0,l=r.length;l>c;c++){for(var p=r[c],f=p.names,h={},g=0,v=f.length;v>g;g++)h[f[g]]=i[a++];u.push({handler:p.handler,params:h,isDynamic:!!f.length})}return u}function p(t,e){return e.eachChar(function(e){t=t.put(e)}),t}var f=function(){function t(t,e,n){this.path=t,this.matcher=e,this.delegate=n}function e(t){this.routes={},this.children={},this.target=t}function n(e,r,o){return function(i,a){var u=e+i;return a?void a(n(u,r,o)):new t(e+i,r,o)}}function r(t,e,n){for(var r=0,o=0,i=t.length;i>o;o++)r+=t[o].path.length;e=e.substr(r);var a={path:e,handler:n};t.push(a)}function o(t,e,n,i){var a=e.routes;for(var u in a)if(a.hasOwnProperty(u)){var c=t.slice();r(c,u,a[u]),e.children[u]?o(c,e.children[u],n,i):n.call(i,c)}}return t.prototype={to:function(t,e){var n=this.delegate;if(n&&n.willAddRoute&&(t=n.willAddRoute(this.matcher.target,t)),this.matcher.add(this.path,t),e){if(0===e.length)throw new Error("You must have an argument in the function passed to `to`");this.matcher.addChild(this.path,t,e,this.delegate)}return this}},e.prototype={add:function(t,e){this.routes[t]=e},addChild:function(t,r,o,i){var a=new e(r);this.children[t]=a;var u=n(t,a,i);i&&i.contextEntered&&i.contextEntered(r,u),o(u)}},function(t,r){var i=new e;t(n("",i,this.delegate)),o([],i,function(t){r?r(this,t):this.add(t)},this)}}(),h=["/",".","*","+","?","|","(",")","[","]","{","}","\\"],g=new RegExp("(\\"+h.join("|\\")+")","g");e.prototype={eachChar:function(t){for(var e,n=this.string,r=0,o=n.length;o>r;r++)e=n.charAt(r),t({validChars:e})},regex:function(){return this.string.replace(g,"\\$1")},generate:function(){return this.string}},n.prototype={eachChar:function(t){t({invalidChars:"/",repeat:!0})},regex:function(){return"([^/]+)"},generate:function(t){return t[this.name]}},r.prototype={eachChar:function(t){t({invalidChars:"",repeat:!0})},regex:function(){return"(.+)"},generate:function(t){return t[this.name]}},o.prototype={eachChar:function(){},regex:function(){return""},generate:function(){return""}},a.prototype={get:function(t){for(var e=this.nextStates,n=0,r=e.length;r>n;n++){var o=e[n],i=o.charSpec.validChars===t.validChars;if(i=i&&o.charSpec.invalidChars===t.invalidChars)return o}},put:function(t){var e;return(e=this.get(t))?e:(e=new a(t),this.nextStates.push(e),t.repeat&&e.nextStates.push(e),e)},match:function(t){for(var e,n,r,o=this.nextStates,i=[],a=0,u=o.length;u>a;a++)e=o[a],n=e.charSpec,"undefined"!=typeof(r=n.validChars)?-1!==r.indexOf(t)&&i.push(e):"undefined"!=typeof(r=n.invalidChars)&&-1===r.indexOf(t)&&i.push(e);return i}};var v=Object.create||function(t){function e(){}return e.prototype=t,new e};s.prototype=v({splice:Array.prototype.splice,slice:Array.prototype.slice,push:Array.prototype.push,length:0,queryParams:null});var m=function(){this.rootState=new a,this.names={}};return m.prototype={add:function(t,e){for(var n,r=this.rootState,a="^",u={statics:0,dynamics:0,stars:0},c=[],s=[],l=!0,f=0,h=t.length;h>f;f++){var g=t[f],v=[],m=i(g.path,v,u);s=s.concat(m);for(var y=0,d=m.length;d>y;y++){var $=m[y];$ instanceof o||(l=!1,r=r.put({validChars:"/"}),a+="/",r=p(r,$),a+=$.regex())}var O={handler:g.handler,names:v};c.push(O)}l&&(r=r.put({validChars:"/"}),a+="/"),r.handlers=c,r.regex=new RegExp(a+"$"),r.types=u,(n=e&&e.as)&&(this.names[n]={segments:s,handlers:c})},handlersFor:function(t){var e=this.names[t],n=[];if(!e)throw new Error("There is no route named "+t);for(var r=0,o=e.handlers.length;o>r;r++)n.push(e.handlers[r]);return n},hasRoute:function(t){return!!this.names[t]},generate:function(t,e){var n=this.names[t],r="";if(!n)throw new Error("There is no route named "+t);for(var i=n.segments,a=0,u=i.length;u>a;a++){var c=i[a];c instanceof o||(r+="/",r+=c.generate(e))}return"/"!==r.charAt(0)&&(r="/"+r),e&&e.queryParams&&(r+=this.generateQueryString(e.queryParams,n.handlers)),r},generateQueryString:function(e,n){var r=[],o=[];for(var i in e)e.hasOwnProperty(i)&&o.push(i);o.sort();for(var a=0,u=o.length;u>a;a++){i=o[a];var c=e[i];if(null!=c){var s=encodeURIComponent(i);if(t(c))for(var l=0,p=c.length;p>l;l++){var f=i+"[]="+encodeURIComponent(c[l]);r.push(f)}else s+="="+encodeURIComponent(c),r.push(s)}}return 0===r.length?"":"?"+r.join("&")},parseQueryString:function(t){for(var e=t.split("&"),n={},r=0;r2&&"[]"===a.slice(u-2)&&(c=!0,a=a.slice(0,u-2),n[a]||(n[a]=[])),o=i[1]?decodeURIComponent(i[1]):""),c?n[a].push(o):n[a]=o}return n},recognize:function(t){var e,n,r,o,i=[this.rootState],a={},s=!1;if(o=t.indexOf("?"),-1!==o){var p=t.substr(o+1,t.length);t=t.substr(0,o),a=this.parseQueryString(p)}for(t=decodeURI(t),"/"!==t.charAt(0)&&(t="/"+t),e=t.length,e>1&&"/"===t.charAt(e-1)&&(t=t.substr(0,e-1),s=!0),n=0,r=t.length;r>n&&(i=c(i,t.charAt(n)),i.length);n++);var f=[];for(n=0,r=i.length;r>n;n++)i[n].handlers&&f.push(i[n]);i=u(f);var h=f[0];return h&&h.handlers?(s&&"(.+)$"===h.regex.source.slice(-5)&&(t+="/"),l(h,t,a)):void 0}},m.prototype.map=f,m.VERSION="VERSION_STRING_PLACEHOLDER",m}()),h="/*childRoute",g=function(){this.rules={}};e(g,{config:function(t,e){"app"===t&&(t="/"),this.rules[t]||(this.rules[t]=new v(t)),this.rules[t].config(e)},recognize:function(t){var e=void 0!==arguments[1]?arguments[1]:"/",n=this;if("undefined"!=typeof t){var r=this.rules[e];if(r){var o=r.recognize(t);if(o){var a=o[o.length-1],u=a.handler,c=a.params,s={outlets:{},params:c};if(c&&c.childRoute){var l="/"+c.childRoute;s.canonicalUrl=u.rewroteUrl.substr(0,u.rewroteUrl.length-(c.childRoute.length+1)),i(u.components,function(t,e){s.outlets[e]=n.recognize(l,t)}),s.canonicalUrl+=s.outlets[Object.keys(s.outlets)[0]].canonicalUrl}else s.canonicalUrl=u.rewroteUrl,i(u.components,function(t,e){s.outlets[e]={outlets:{}}});return i(s.outlets,function(t,e){t.component=u.components[e],t.params=c}),s}}}},generate:function(t,e){var n,r="";do{if(n=null,i(this.rules,function(o){o.hasRoute(t)&&(r=o.generate(t,e)+r,n=o)}),!n)return"";t=n.name}while("/"!==n.name);return r}},{}),Object.defineProperty(g.prototype.recognize,"parameters",{get:function(){return[[$traceurRuntime.type.string],[]]}});var v=function(t){this.name=t,this.rewrites={},this.recognizer=new f};return e(v,{config:function(t){var e=this;t instanceof Array?t.forEach(function(t){return e.configOne(t)}):this.configOne(t)},getCanonicalUrl:function(t){return"."===t[0]&&(t=t.substr(1)),(""===t||"/"!==t[0])&&(t="/"+t),i(this.rewrites,function(e,n){"/"===n?"/"===t&&(t=e):0===t.indexOf(n)&&(t=t.replace(n,e))}),t},configOne:function(t){var e=this;if(t.redirectTo){if(this.rewrites[t.path])throw new Error('"'+t.path+'" already maps to "'+this.rewrites[t.path]+'"');return void(this.rewrites[t.path]=t.redirectTo)}if(t.component){if(t.components)throw new Error('A route config should have either a "component" or "components" property, but not both.');t.components=t.component,delete t.component}"string"==typeof t.components&&(t.components={"default":t.components});var n;t.as?n=[t.as]:(n=a(t.components,function(t,e){return e+":"+t}),t.components["default"]&&n.push(t.components["default"])),n.forEach(function(n){return e.recognizer.add([{path:t.path,handler:t}],{as:n})});var r=o(t);r.path+=h,this.recognizer.add([{path:r.path,handler:r}])},recognize:function(t){var e=this.getCanonicalUrl(t),n=this.recognizer.recognize(e);return n&&(n[0].handler.rewroteUrl=e),n},generate:function(t,e){return this.recognizer.generate(t,e)},hasRoute:function(t){return this.recognizer.hasRoute(t)}},{}),new g}]); \ No newline at end of file From 4719fad69915b34e44adfe3013fb3a5a5adb3632 Mon Sep 17 00:00:00 2001 From: Morris Singer Date: Thu, 2 Jul 2015 16:12:47 -0400 Subject: [PATCH 2/2] add bower.json --- bower.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..ec86319 --- /dev/null +++ b/bower.json @@ -0,0 +1,8 @@ +{ + "name": "router", + "version": "1.4.1", + "main": "./dist/router.es5.js", + "ignore": [], + "dependencies": { + } +}