angular2
Version:
Angular 2 - a web framework for modern web apps
1,317 lines (1,302 loc) • 114 kB
JavaScript
"format register";
System.register("angular2/src/router/route_config_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2:
return decorators.reduceRight(function(o, d) {
return (d && d(o)) || o;
}, target);
case 3:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key)), void 0;
}, void 0);
case 4:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key, o)) || o;
}, desc);
}
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var lang_1 = require("angular2/src/facade/lang");
var RouteConfig = (function() {
function RouteConfig(configs) {
this.configs = configs;
}
RouteConfig = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Array])], RouteConfig);
return RouteConfig;
})();
exports.RouteConfig = RouteConfig;
var Route = (function() {
function Route(_a) {
var path = _a.path,
component = _a.component,
name = _a.name,
data = _a.data,
useAsDefault = _a.useAsDefault;
this.aux = null;
this.loader = null;
this.redirectTo = null;
this.path = path;
this.component = component;
this.name = name;
this.data = data;
this.useAsDefault = useAsDefault;
}
Route = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Route);
return Route;
})();
exports.Route = Route;
var AuxRoute = (function() {
function AuxRoute(_a) {
var path = _a.path,
component = _a.component,
name = _a.name;
this.data = null;
this.aux = null;
this.loader = null;
this.redirectTo = null;
this.useAsDefault = false;
this.path = path;
this.component = component;
this.name = name;
}
AuxRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AuxRoute);
return AuxRoute;
})();
exports.AuxRoute = AuxRoute;
var AsyncRoute = (function() {
function AsyncRoute(_a) {
var path = _a.path,
loader = _a.loader,
name = _a.name,
data = _a.data,
useAsDefault = _a.useAsDefault;
this.aux = null;
this.path = path;
this.loader = loader;
this.name = name;
this.data = data;
this.useAsDefault = useAsDefault;
}
AsyncRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AsyncRoute);
return AsyncRoute;
})();
exports.AsyncRoute = AsyncRoute;
var Redirect = (function() {
function Redirect(_a) {
var path = _a.path,
redirectTo = _a.redirectTo;
this.name = null;
this.loader = null;
this.data = null;
this.aux = null;
this.useAsDefault = false;
this.path = path;
this.redirectTo = redirectTo;
}
Redirect = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Redirect);
return Redirect;
})();
exports.Redirect = Redirect;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/instruction", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/async"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var collection_1 = require("angular2/src/facade/collection");
var lang_1 = require("angular2/src/facade/lang");
var async_1 = require("angular2/src/facade/async");
var RouteParams = (function() {
function RouteParams(params) {
this.params = params;
}
RouteParams.prototype.get = function(param) {
return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.params, param));
};
return RouteParams;
})();
exports.RouteParams = RouteParams;
var RouteData = (function() {
function RouteData(data) {
if (data === void 0) {
data = lang_1.CONST_EXPR({});
}
this.data = data;
}
RouteData.prototype.get = function(key) {
return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.data, key));
};
return RouteData;
})();
exports.RouteData = RouteData;
exports.BLANK_ROUTE_DATA = new RouteData();
var Instruction = (function() {
function Instruction() {
this.auxInstruction = {};
}
Object.defineProperty(Instruction.prototype, "urlPath", {
get: function() {
return this.component.urlPath;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Instruction.prototype, "urlParams", {
get: function() {
return this.component.urlParams;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Instruction.prototype, "specificity", {
get: function() {
var total = 0;
if (lang_1.isPresent(this.component)) {
total += this.component.specificity;
}
if (lang_1.isPresent(this.child)) {
total += this.child.specificity;
}
return total;
},
enumerable: true,
configurable: true
});
Instruction.prototype.toRootUrl = function() {
return this.toUrlPath() + this.toUrlQuery();
};
Instruction.prototype._toNonRootUrl = function() {
return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
};
Instruction.prototype.toUrlQuery = function() {
return this.urlParams.length > 0 ? ('?' + this.urlParams.join('&')) : '';
};
Instruction.prototype.replaceChild = function(child) {
return new ResolvedInstruction(this.component, child, this.auxInstruction);
};
Instruction.prototype.toUrlPath = function() {
return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
};
Instruction.prototype.toLinkUrl = function() {
return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
};
Instruction.prototype._toLinkUrl = function() {
return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
};
Instruction.prototype._stringifyPathMatrixAuxPrefixed = function() {
var primary = this._stringifyPathMatrixAux();
if (primary.length > 0) {
primary = '/' + primary;
}
return primary;
};
Instruction.prototype._stringifyMatrixParams = function() {
return this.urlParams.length > 0 ? (';' + this.component.urlParams.join(';')) : '';
};
Instruction.prototype._stringifyPathMatrixAux = function() {
if (lang_1.isBlank(this.component)) {
return '';
}
return this.urlPath + this._stringifyMatrixParams() + this._stringifyAux();
};
Instruction.prototype._stringifyAux = function() {
var routes = [];
collection_1.StringMapWrapper.forEach(this.auxInstruction, function(auxInstruction, _) {
routes.push(auxInstruction._stringifyPathMatrixAux());
});
if (routes.length > 0) {
return '(' + routes.join('//') + ')';
}
return '';
};
return Instruction;
})();
exports.Instruction = Instruction;
var ResolvedInstruction = (function(_super) {
__extends(ResolvedInstruction, _super);
function ResolvedInstruction(component, child, auxInstruction) {
_super.call(this);
this.component = component;
this.child = child;
this.auxInstruction = auxInstruction;
}
ResolvedInstruction.prototype.resolveComponent = function() {
return async_1.PromiseWrapper.resolve(this.component);
};
return ResolvedInstruction;
})(Instruction);
exports.ResolvedInstruction = ResolvedInstruction;
var DefaultInstruction = (function(_super) {
__extends(DefaultInstruction, _super);
function DefaultInstruction(component, child) {
_super.call(this);
this.component = component;
this.child = child;
}
DefaultInstruction.prototype.resolveComponent = function() {
return async_1.PromiseWrapper.resolve(this.component);
};
DefaultInstruction.prototype.toLinkUrl = function() {
return '';
};
DefaultInstruction.prototype._toLinkUrl = function() {
return '';
};
return DefaultInstruction;
})(Instruction);
exports.DefaultInstruction = DefaultInstruction;
var UnresolvedInstruction = (function(_super) {
__extends(UnresolvedInstruction, _super);
function UnresolvedInstruction(_resolver, _urlPath, _urlParams) {
if (_urlPath === void 0) {
_urlPath = '';
}
if (_urlParams === void 0) {
_urlParams = lang_1.CONST_EXPR([]);
}
_super.call(this);
this._resolver = _resolver;
this._urlPath = _urlPath;
this._urlParams = _urlParams;
}
Object.defineProperty(UnresolvedInstruction.prototype, "urlPath", {
get: function() {
if (lang_1.isPresent(this.component)) {
return this.component.urlPath;
}
if (lang_1.isPresent(this._urlPath)) {
return this._urlPath;
}
return '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(UnresolvedInstruction.prototype, "urlParams", {
get: function() {
if (lang_1.isPresent(this.component)) {
return this.component.urlParams;
}
if (lang_1.isPresent(this._urlParams)) {
return this._urlParams;
}
return [];
},
enumerable: true,
configurable: true
});
UnresolvedInstruction.prototype.resolveComponent = function() {
var _this = this;
if (lang_1.isPresent(this.component)) {
return async_1.PromiseWrapper.resolve(this.component);
}
return this._resolver().then(function(resolution) {
_this.child = resolution.child;
return _this.component = resolution.component;
});
};
return UnresolvedInstruction;
})(Instruction);
exports.UnresolvedInstruction = UnresolvedInstruction;
var RedirectInstruction = (function(_super) {
__extends(RedirectInstruction, _super);
function RedirectInstruction(component, child, auxInstruction) {
_super.call(this, component, child, auxInstruction);
}
return RedirectInstruction;
})(ResolvedInstruction);
exports.RedirectInstruction = RedirectInstruction;
var ComponentInstruction = (function() {
function ComponentInstruction(urlPath, urlParams, data, componentType, terminal, specificity, params) {
if (params === void 0) {
params = null;
}
this.urlPath = urlPath;
this.urlParams = urlParams;
this.componentType = componentType;
this.terminal = terminal;
this.specificity = specificity;
this.params = params;
this.reuse = false;
this.routeData = lang_1.isPresent(data) ? data : exports.BLANK_ROUTE_DATA;
}
return ComponentInstruction;
})();
exports.ComponentInstruction = ComponentInstruction;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/url_parser", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var collection_1 = require("angular2/src/facade/collection");
var lang_1 = require("angular2/src/facade/lang");
var exceptions_1 = require("angular2/src/facade/exceptions");
var Url = (function() {
function Url(path, child, auxiliary, params) {
if (child === void 0) {
child = null;
}
if (auxiliary === void 0) {
auxiliary = lang_1.CONST_EXPR([]);
}
if (params === void 0) {
params = null;
}
this.path = path;
this.child = child;
this.auxiliary = auxiliary;
this.params = params;
}
Url.prototype.toString = function() {
return this.path + this._matrixParamsToString() + this._auxToString() + this._childString();
};
Url.prototype.segmentToString = function() {
return this.path + this._matrixParamsToString();
};
Url.prototype._auxToString = function() {
return this.auxiliary.length > 0 ? ('(' + this.auxiliary.map(function(sibling) {
return sibling.toString();
}).join('//') + ')') : '';
};
Url.prototype._matrixParamsToString = function() {
if (lang_1.isBlank(this.params)) {
return '';
}
return ';' + serializeParams(this.params).join(';');
};
Url.prototype._childString = function() {
return lang_1.isPresent(this.child) ? ('/' + this.child.toString()) : '';
};
return Url;
})();
exports.Url = Url;
var RootUrl = (function(_super) {
__extends(RootUrl, _super);
function RootUrl(path, child, auxiliary, params) {
if (child === void 0) {
child = null;
}
if (auxiliary === void 0) {
auxiliary = lang_1.CONST_EXPR([]);
}
if (params === void 0) {
params = null;
}
_super.call(this, path, child, auxiliary, params);
}
RootUrl.prototype.toString = function() {
return this.path + this._auxToString() + this._childString() + this._queryParamsToString();
};
RootUrl.prototype.segmentToString = function() {
return this.path + this._queryParamsToString();
};
RootUrl.prototype._queryParamsToString = function() {
if (lang_1.isBlank(this.params)) {
return '';
}
return '?' + serializeParams(this.params).join('&');
};
return RootUrl;
})(Url);
exports.RootUrl = RootUrl;
function pathSegmentsToUrl(pathSegments) {
var url = new Url(pathSegments[pathSegments.length - 1]);
for (var i = pathSegments.length - 2; i >= 0; i -= 1) {
url = new Url(pathSegments[i], url);
}
return url;
}
exports.pathSegmentsToUrl = pathSegmentsToUrl;
var SEGMENT_RE = lang_1.RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
function matchUrlSegment(str) {
var match = lang_1.RegExpWrapper.firstMatch(SEGMENT_RE, str);
return lang_1.isPresent(match) ? match[0] : '';
}
var UrlParser = (function() {
function UrlParser() {}
UrlParser.prototype.peekStartsWith = function(str) {
return this._remaining.startsWith(str);
};
UrlParser.prototype.capture = function(str) {
if (!this._remaining.startsWith(str)) {
throw new exceptions_1.BaseException("Expected \"" + str + "\".");
}
this._remaining = this._remaining.substring(str.length);
};
UrlParser.prototype.parse = function(url) {
this._remaining = url;
if (url == '' || url == '/') {
return new Url('');
}
return this.parseRoot();
};
UrlParser.prototype.parseRoot = function() {
if (this.peekStartsWith('/')) {
this.capture('/');
}
var path = matchUrlSegment(this._remaining);
this.capture(path);
var aux = [];
if (this.peekStartsWith('(')) {
aux = this.parseAuxiliaryRoutes();
}
if (this.peekStartsWith(';')) {
this.parseMatrixParams();
}
var child = null;
if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
this.capture('/');
child = this.parseSegment();
}
var queryParams = null;
if (this.peekStartsWith('?')) {
queryParams = this.parseQueryParams();
}
return new RootUrl(path, child, aux, queryParams);
};
UrlParser.prototype.parseSegment = function() {
if (this._remaining.length == 0) {
return null;
}
if (this.peekStartsWith('/')) {
this.capture('/');
}
var path = matchUrlSegment(this._remaining);
this.capture(path);
var matrixParams = null;
if (this.peekStartsWith(';')) {
matrixParams = this.parseMatrixParams();
}
var aux = [];
if (this.peekStartsWith('(')) {
aux = this.parseAuxiliaryRoutes();
}
var child = null;
if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
this.capture('/');
child = this.parseSegment();
}
return new Url(path, child, aux, matrixParams);
};
UrlParser.prototype.parseQueryParams = function() {
var params = {};
this.capture('?');
this.parseParam(params);
while (this._remaining.length > 0 && this.peekStartsWith('&')) {
this.capture('&');
this.parseParam(params);
}
return params;
};
UrlParser.prototype.parseMatrixParams = function() {
var params = {};
while (this._remaining.length > 0 && this.peekStartsWith(';')) {
this.capture(';');
this.parseParam(params);
}
return params;
};
UrlParser.prototype.parseParam = function(params) {
var key = matchUrlSegment(this._remaining);
if (lang_1.isBlank(key)) {
return ;
}
this.capture(key);
var value = true;
if (this.peekStartsWith('=')) {
this.capture('=');
var valueMatch = matchUrlSegment(this._remaining);
if (lang_1.isPresent(valueMatch)) {
value = valueMatch;
this.capture(value);
}
}
params[key] = value;
};
UrlParser.prototype.parseAuxiliaryRoutes = function() {
var routes = [];
this.capture('(');
while (!this.peekStartsWith(')') && this._remaining.length > 0) {
routes.push(this.parseSegment());
if (this.peekStartsWith('//')) {
this.capture('//');
}
}
this.capture(')');
return routes;
};
return UrlParser;
})();
exports.UrlParser = UrlParser;
exports.parser = new UrlParser();
function serializeParams(paramMap) {
var params = [];
if (lang_1.isPresent(paramMap)) {
collection_1.StringMapWrapper.forEach(paramMap, function(value, key) {
if (value == true) {
params.push(key);
} else {
params.push(key + '=' + value);
}
});
}
return params;
}
exports.serializeParams = serializeParams;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/async_route_handler", ["angular2/src/facade/lang", "angular2/src/router/instruction"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var lang_1 = require("angular2/src/facade/lang");
var instruction_1 = require("angular2/src/router/instruction");
var AsyncRouteHandler = (function() {
function AsyncRouteHandler(_loader, data) {
if (data === void 0) {
data = null;
}
this._loader = _loader;
this._resolvedComponent = null;
this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
}
AsyncRouteHandler.prototype.resolveComponentType = function() {
var _this = this;
if (lang_1.isPresent(this._resolvedComponent)) {
return this._resolvedComponent;
}
return this._resolvedComponent = this._loader().then(function(componentType) {
_this.componentType = componentType;
return componentType;
});
};
return AsyncRouteHandler;
})();
exports.AsyncRouteHandler = AsyncRouteHandler;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/sync_route_handler", ["angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/router/instruction"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var async_1 = require("angular2/src/facade/async");
var lang_1 = require("angular2/src/facade/lang");
var instruction_1 = require("angular2/src/router/instruction");
var SyncRouteHandler = (function() {
function SyncRouteHandler(componentType, data) {
this.componentType = componentType;
this._resolvedComponent = null;
this._resolvedComponent = async_1.PromiseWrapper.resolve(componentType);
this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
}
SyncRouteHandler.prototype.resolveComponentType = function() {
return this._resolvedComponent;
};
return SyncRouteHandler;
})();
exports.SyncRouteHandler = SyncRouteHandler;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/route_config_decorator", ["angular2/src/router/route_config_impl", "angular2/src/core/util/decorators", "angular2/src/router/route_config_impl"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var route_config_impl_1 = require("angular2/src/router/route_config_impl");
var decorators_1 = require("angular2/src/core/util/decorators");
var route_config_impl_2 = require("angular2/src/router/route_config_impl");
exports.Route = route_config_impl_2.Route;
exports.Redirect = route_config_impl_2.Redirect;
exports.AuxRoute = route_config_impl_2.AuxRoute;
exports.AsyncRoute = route_config_impl_2.AsyncRoute;
exports.RouteConfig = decorators_1.makeDecorator(route_config_impl_1.RouteConfig);
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/location_strategy", ["angular2/src/facade/lang", "angular2/core"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var lang_1 = require("angular2/src/facade/lang");
var core_1 = require("angular2/core");
var LocationStrategy = (function() {
function LocationStrategy() {}
return LocationStrategy;
})();
exports.LocationStrategy = LocationStrategy;
exports.APP_BASE_HREF = lang_1.CONST_EXPR(new core_1.OpaqueToken('appBaseHref'));
function normalizeQueryParams(params) {
return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
}
exports.normalizeQueryParams = normalizeQueryParams;
function joinWithSlash(start, end) {
if (start.length == 0) {
return end;
}
if (end.length == 0) {
return start;
}
var slashes = 0;
if (start.endsWith('/')) {
slashes++;
}
if (end.startsWith('/')) {
slashes++;
}
if (slashes == 2) {
return start + end.substring(1);
}
if (slashes == 1) {
return start + end;
}
return start + '/' + end;
}
exports.joinWithSlash = joinWithSlash;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/lifecycle_annotations_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2:
return decorators.reduceRight(function(o, d) {
return (d && d(o)) || o;
}, target);
case 3:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key)), void 0;
}, void 0);
case 4:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key, o)) || o;
}, desc);
}
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var lang_1 = require("angular2/src/facade/lang");
var RouteLifecycleHook = (function() {
function RouteLifecycleHook(name) {
this.name = name;
}
RouteLifecycleHook = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], RouteLifecycleHook);
return RouteLifecycleHook;
})();
exports.RouteLifecycleHook = RouteLifecycleHook;
var CanActivate = (function() {
function CanActivate(fn) {
this.fn = fn;
}
CanActivate = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Function])], CanActivate);
return CanActivate;
})();
exports.CanActivate = CanActivate;
exports.routerCanReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanReuse"));
exports.routerCanDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanDeactivate"));
exports.routerOnActivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnActivate"));
exports.routerOnReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnReuse"));
exports.routerOnDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnDeactivate"));
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/lifecycle_annotations", ["angular2/src/core/util/decorators", "angular2/src/router/lifecycle_annotations_impl", "angular2/src/router/lifecycle_annotations_impl"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var decorators_1 = require("angular2/src/core/util/decorators");
var lifecycle_annotations_impl_1 = require("angular2/src/router/lifecycle_annotations_impl");
var lifecycle_annotations_impl_2 = require("angular2/src/router/lifecycle_annotations_impl");
exports.routerCanReuse = lifecycle_annotations_impl_2.routerCanReuse;
exports.routerCanDeactivate = lifecycle_annotations_impl_2.routerCanDeactivate;
exports.routerOnActivate = lifecycle_annotations_impl_2.routerOnActivate;
exports.routerOnReuse = lifecycle_annotations_impl_2.routerOnReuse;
exports.routerOnDeactivate = lifecycle_annotations_impl_2.routerOnDeactivate;
exports.CanActivate = decorators_1.makeDecorator(lifecycle_annotations_impl_1.CanActivate);
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/router_link", ["angular2/core", "angular2/src/facade/lang", "angular2/src/router/router", "angular2/src/router/location"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2:
return decorators.reduceRight(function(o, d) {
return (d && d(o)) || o;
}, target);
case 3:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key)), void 0;
}, void 0);
case 4:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key, o)) || o;
}, desc);
}
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var core_1 = require("angular2/core");
var lang_1 = require("angular2/src/facade/lang");
var router_1 = require("angular2/src/router/router");
var location_1 = require("angular2/src/router/location");
var RouterLink = (function() {
function RouterLink(_router, _location) {
this._router = _router;
this._location = _location;
}
Object.defineProperty(RouterLink.prototype, "isRouteActive", {
get: function() {
return this._router.isRouteActive(this._navigationInstruction);
},
enumerable: true,
configurable: true
});
Object.defineProperty(RouterLink.prototype, "routeParams", {
set: function(changes) {
this._routeParams = changes;
this._navigationInstruction = this._router.generate(this._routeParams);
var navigationHref = this._navigationInstruction.toLinkUrl();
this.visibleHref = this._location.prepareExternalUrl(navigationHref);
},
enumerable: true,
configurable: true
});
RouterLink.prototype.onClick = function() {
if (!lang_1.isString(this.target) || this.target == '_self') {
this._router.navigateByInstruction(this._navigationInstruction);
return false;
}
return true;
};
RouterLink = __decorate([core_1.Directive({
selector: '[router-link]',
inputs: ['routeParams: routerLink', 'target: target'],
host: {
'(click)': 'onClick()',
'[attr.href]': 'visibleHref',
'[class.router-link-active]': 'isRouteActive'
}
}), __metadata('design:paramtypes', [router_1.Router, location_1.Location])], RouterLink);
return RouterLink;
})();
exports.RouterLink = RouterLink;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/hash_location_strategy", ["angular2/core", "angular2/src/router/location_strategy", "angular2/src/facade/lang", "angular2/src/router/platform_location"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2:
return decorators.reduceRight(function(o, d) {
return (d && d(o)) || o;
}, target);
case 3:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key)), void 0;
}, void 0);
case 4:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key, o)) || o;
}, desc);
}
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};
var core_1 = require("angular2/core");
var location_strategy_1 = require("angular2/src/router/location_strategy");
var lang_1 = require("angular2/src/facade/lang");
var platform_location_1 = require("angular2/src/router/platform_location");
var HashLocationStrategy = (function(_super) {
__extends(HashLocationStrategy, _super);
function HashLocationStrategy(_platformLocation, _baseHref) {
_super.call(this);
this._platformLocation = _platformLocation;
this._baseHref = '';
if (lang_1.isPresent(_baseHref)) {
this._baseHref = _baseHref;
}
}
HashLocationStrategy.prototype.onPopState = function(fn) {
this._platformLocation.onPopState(fn);
};
HashLocationStrategy.prototype.getBaseHref = function() {
return this._baseHref;
};
HashLocationStrategy.prototype.path = function() {
var path = this._platformLocation.hash;
return (path.length > 0 ? path.substring(1) : path) + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
};
HashLocationStrategy.prototype.prepareExternalUrl = function(internal) {
var url = location_strategy_1.joinWithSlash(this._baseHref, internal);
return url.length > 0 ? ('#' + url) : url;
};
HashLocationStrategy.prototype.pushState = function(state, title, path, queryParams) {
var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
if (url.length == 0) {
url = this._platformLocation.pathname;
}
this._platformLocation.pushState(state, title, url);
};
HashLocationStrategy.prototype.forward = function() {
this._platformLocation.forward();
};
HashLocationStrategy.prototype.back = function() {
this._platformLocation.back();
};
HashLocationStrategy = __decorate([core_1.Injectable(), __param(1, core_1.Optional()), __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)), __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])], HashLocationStrategy);
return HashLocationStrategy;
})(location_strategy_1.LocationStrategy);
exports.HashLocationStrategy = HashLocationStrategy;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/path_location_strategy", ["angular2/core", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/router/location_strategy", "angular2/src/router/platform_location"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var __extends = (this && this.__extends) || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2:
return decorators.reduceRight(function(o, d) {
return (d && d(o)) || o;
}, target);
case 3:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key)), void 0;
}, void 0);
case 4:
return decorators.reduceRight(function(o, d) {
return (d && d(target, key, o)) || o;
}, desc);
}
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};
var core_1 = require("angular2/core");
var lang_1 = require("angular2/src/facade/lang");
var exceptions_1 = require("angular2/src/facade/exceptions");
var location_strategy_1 = require("angular2/src/router/location_strategy");
var platform_location_1 = require("angular2/src/router/platform_location");
var PathLocationStrategy = (function(_super) {
__extends(PathLocationStrategy, _super);
function PathLocationStrategy(_platformLocation, href) {
_super.call(this);
this._platformLocation = _platformLocation;
if (lang_1.isBlank(href)) {
href = this._platformLocation.getBaseHrefFromDOM();
}
if (lang_1.isBlank(href)) {
throw new exceptions_1.BaseException("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
}
this._baseHref = href;
}
PathLocationStrategy.prototype.onPopState = function(fn) {
this._platformLocation.onPopState(fn);
this._platformLocation.onHashChange(fn);
};
PathLocationStrategy.prototype.getBaseHref = function() {
return this._baseHref;
};
PathLocationStrategy.prototype.prepareExternalUrl = function(internal) {
return location_strategy_1.joinWithSlash(this._baseHref, internal);
};
PathLocationStrategy.prototype.path = function() {
return this._platformLocation.pathname + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
};
PathLocationStrategy.prototype.pushState = function(state, title, url, queryParams) {
var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
this._platformLocation.pushState(state, title, externalUrl);
};
PathLocationStrategy.prototype.forward = function() {
this._platformLocation.forward();
};
PathLocationStrategy.prototype.back = function() {
this._platformLocation.back();
};
PathLocationStrategy = __decorate([core_1.Injectable(), __param(1, core_1.Optional()), __param(1, core_1.Inject(location_strategy_1.APP_BASE_HREF)), __metadata('design:paramtypes', [platform_location_1.PlatformLocation, String])], PathLocationStrategy);
return PathLocationStrategy;
})(location_strategy_1.LocationStrategy);
exports.PathLocationStrategy = PathLocationStrategy;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/route_definition", [], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/path_recognizer", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/router/url_parser"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var lang_1 = require("angular2/src/facade/lang");
var exceptions_1 = require("angular2/src/facade/exceptions");
var collection_1 = require("angular2/src/facade/collection");
var url_parser_1 = require("angular2/src/router/url_parser");
var TouchMap = (function() {
function TouchMap(map) {
var _this = this;
this.map = {};
this.keys = {};
if (lang_1.isPresent(map)) {
collection_1.StringMapWrapper.forEach(map, function(value, key) {
_this.map[key] = lang_1.isPresent(value) ? value.toString() : null;
_this.keys[key] = true;
});
}
}
TouchMap.prototype.get = function(key) {
collection_1.StringMapWrapper.delete(this.keys, key);
return this.map[key];
};
TouchMap.prototype.getUnused = function() {
var _this = this;
var unused = {};
var keys = collection_1.StringMapWrapper.keys(this.keys);
keys.forEach(function(key) {
return unused[key] = collection_1.StringMapWrapper.get(_this.map, key);
});
return unused;
};
return TouchMap;
})();
function normalizeString(obj) {
if (lang_1.isBlank(obj)) {
return null;
} else {
return obj.toString();
}
}
var ContinuationSegment = (function() {
function ContinuationSegment() {
this.name = '';
}
ContinuationSegment.prototype.generate = function(params) {
return '';
};
ContinuationSegment.prototype.match = function(path) {
return true;
};
return ContinuationSegment;
})();
var StaticSegment = (function() {
function StaticSegment(path) {
this.path = path;
this.name = '';
}
StaticSegment.prototype.match = function(path) {
return path == this.path;
};
StaticSegment.prototype.generate = function(params) {
return this.path;
};
return StaticSegment;
})();
var DynamicSegment = (function() {
function DynamicSegment(name) {
this.name = name;
}
DynamicSegment.prototype.match = function(path) {
return path.length > 0;
};
DynamicSegment.prototype.generate = function(params) {
if (!collection_1.StringMapWrapper.contains(params.map, this.name)) {
throw new exceptions_1.BaseException("Route generator for '" + this.name + "' was not included in parameters passed.");
}
return normalizeString(params.get(this.name));
};
return DynamicSegment;
})();
var StarSegment = (function() {
function StarSegment(name) {
this.name = name;
}
StarSegment.prototype.match = function(path) {
return true;
};
StarSegment.prototype.generate = function(params) {
return normalizeString(params.get(this.name));
};
return StarSegment;
})();
var paramMatcher = /^:([^\/]+)$/g;
var wildcardMatcher = /^\*([^\/]+)$/g;
function parsePathString(route) {
if (route.startsWith("/")) {
route = route.substring(1);
}
var segments = splitBySlash(route);
var results = [];
var specificity = 0;
if (segments.length > 98) {
throw new exceptions_1.BaseException("'" + route + "' has more than the maximum supported number of segments.");
}
var limit = segments.length - 1;
for (var i = 0; i <= limit; i++) {
var segment = segments[i],
match;
if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(paramMatcher, segment))) {
results.push(new DynamicSegment(match[1]));
specificity += (100 - i);
} else if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
results.push(new StarSegment(match[1]));
} else if (segment == '...') {
if (i < limit) {
throw new exceptions_1.BaseException("Unexpected \"...\" before the end of the path for \"" + route + "\".");
}
results.push(new ContinuationSegment());
} else {
results.push(new StaticSegment(segment));
specificity += 100 * (100 - i);
}
}
var result = collection_1.StringMapWrapper.create();
collection_1.StringMapWrapper.set(result, 'segments', results);
collection_1.StringMapWrapper.set(result, 'specificity', specificity);
return result;
}
function pathDslHash(segments) {
return segments.map(function(segment) {
if (segment instanceof StarSegment) {
return '*';
} else if (segment instanceof ContinuationSegment) {
return '...';
} else if (segment instanceof DynamicSegment) {
return ':';
} else if (segment instanceof StaticSegment) {
return segment.path;
}
}).join('/');
}
function splitBySlash(url) {
return url.split('/');
}
var RESERVED_CHARS = lang_1.RegExpWrapper.create('//|\\(|\\)|;|\\?|=');
function assertPath(path) {
if (lang_1.StringWrapper.contains(path, '#')) {
throw new exceptions_1.BaseException("Path \"" + path + "\" should not include \"#\". Use \"HashLocationStrategy\" instead.");
}
var illegalCharacter = lang_1.RegExpWrapper.firstMatch(RESERVED_CHARS, path);
if (lang_1.isPresent(illegalCharacter)) {
throw new exceptions_1.BaseException("Path \"" + path + "\" contains \"" + illegalCharacter[0] + "\" which is not allowed in a route config.");
}
}
var PathRecognizer = (function() {
function PathRecognizer(path) {
this.path = path;
this.terminal = true;
assertPath(path);
var parsed = parsePathString(path);
this._segments = parsed['segments'];
this.specificity = parsed['specificity'];
this.hash = pathDslHash(this._segments);
var lastSegment = this._segments[this._segments.length - 1];
this.terminal = !(lastSegment instanceof ContinuationSegment);
}
PathRecognizer.prototype.recognize = function(beginningSegment) {
var nextSegment = beginningSegment;
var currentSegment;
var positionalParams = {};
var captured = [];
for (var i = 0; i < this._segments.length; i += 1) {
var segment = this._segments[i];
currentSegment = nextSegment;
if (segment instanceof ContinuationSegment) {
break;
}
if (lang_1.isPresent(currentSegment)) {
captured.push(currentSegment.path);
if (segment instanceof StarSegment) {
positionalParams[segment.name] = currentSegment.toString();
nextSegment = null;
break;
}
if (segment instanceof DynamicSegment) {
positionalParams[segment.name] = currentSegment.path;
} else if (!segment.match(currentSegment.path)) {
return null;
}
nextSegment = currentSegment.child;
} else if (!segment.match('')) {
return null;
}
}
if (this.terminal && lang_1.isPresent(nextSegment)) {
return null;
}
var urlPath = captured.join('/');
var auxiliary;
var urlParams;
var allParams;
if (lang_1.isPresent(currentSegment)) {
var paramsSegment = beginningSegment instanceof url_parser_1.RootUrl ? beginningSegment : currentSegment;
allParams = lang_1.isPresent(paramsSegment.params) ? collection_1.StringMapWrapper.merge(paramsSegment.params, positionalParams) : positionalParams;
urlParams = url_parser_1.serializeParams(paramsSegment.params);
auxiliary = currentSegment.auxiliary;
} else {
allParams = positionalParams;
auxiliary = [];
urlParams = [];
}
return {
urlPath: urlPath,
urlParams: urlParams,
allParams: allParams,
auxiliary: auxiliary,
nextSegment: nextSegment
};
};
PathRecognizer.prototype.generate = function(params) {
var paramTokens = new TouchMap(params);
var path = [];
for (var i = 0; i < this._segments.length; i++) {
var segment = this._segments[i];
if (!(segment instanceof ContinuationSegment)) {
path.push(segment.generate(paramTokens));
}
}
var urlPath = path.join('/');
var nonPositionalParams = paramTokens.getUnused();
var urlParams = url_parser_1.serializeParams(nonPositionalParams);
return {
urlPath: urlPath,
urlParams: urlParams
};
};
return PathRecognizer;
})();
exports.PathRecognizer = PathRecognizer;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/component_recognizer", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/router/route_recognizer", "angular2/src/router/route_config_impl", "angular2/src/router/async_route_handler", "angular2/src/router/sync_route_handler"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
var lang_1 = require("angular2/src/facade/lang");
var exceptions_1 = require("angular2/src/facade/exceptions");
var collection_1 = require("angular2/src/facade/collection");
var async_1 = require("angular2/src/facade/async");
var route_recognizer_1 = require("angular2/src/router/route_recognizer");
var route_config_impl_1 = require("angular2/src/router/route_config_impl");
var async_route_handler_1 = require("angular2/src/router/async_route_handler");
var sync_route_handler_1 = require("angular2/src/router/sync_route_handler");
var ComponentRecognizer = (function() {
function ComponentRecognizer() {
this.names = new collection_1.Map();
this.auxNames = new collection_1.Map();
this.auxRoutes = new collection_1.Map();
this.matchers = [];
this.defaultRoute = null;
}
ComponentRecognizer.prototype.config = function(config) {
var handler;
if (lang_1.isPresent(config.name) && config.name[0].toUpperCase() != config.name[0]) {
var suggestedName = config.name[0].toUpperCase() + config.name.substring(1);
throw new exceptions_1.BaseException("Route \"" + config.path + "\" with name \"" + config.name + "\" does not begin with an uppercase letter. Route names should be CamelCase like \"" + suggestedName + "\".");
}
if (config instanceof route_config_impl_1.AuxRoute) {
handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
var path = config.path.startsWith('/') ? config.path.substring(1) : config.path;
var recognizer = new route_recognizer_1.RouteRecognizer(config.path, handler);
this.auxRoutes.set(path, recognizer);
if (lang_1.isPresent(config.name)) {
this.auxNames.set(config.name, recognizer);
}
return recognizer.terminal;
}
var useAsDefault = false;
if (config instanceof route_config_impl_1.Redirect) {
var redirector = new route_recognizer_1.RedirectRecognizer(config.path, config.redirectTo);
this._assertNoHashCollision(redirector.hash, config.path);
this.matchers.push(redirector);
return true;
}
if (config instanceof route_config_impl_1.Route) {
handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);