angular2
Version:
Angular 2 - a web framework for modern web apps
1,362 lines (1,348 loc) • 145 kB
JavaScript
"format register";
System.register("angular2/src/router/directives/router_link_transform", ["angular2/compiler", "angular2/src/compiler/expression_parser/ast", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/compiler/expression_parser/parser"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
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) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var compiler_1 = require("angular2/compiler");
var ast_1 = require("angular2/src/compiler/expression_parser/ast");
var exceptions_1 = require("angular2/src/facade/exceptions");
var core_1 = require("angular2/core");
var parser_1 = require("angular2/src/compiler/expression_parser/parser");
var FixedPart = (function() {
function FixedPart(value) {
this.value = value;
}
return FixedPart;
}());
var AuxiliaryStart = (function() {
function AuxiliaryStart() {}
return AuxiliaryStart;
}());
var AuxiliaryEnd = (function() {
function AuxiliaryEnd() {}
return AuxiliaryEnd;
}());
var Params = (function() {
function Params(ast) {
this.ast = ast;
}
return Params;
}());
var RouterLinkLexer = (function() {
function RouterLinkLexer(parser, exp) {
this.parser = parser;
this.exp = exp;
this.index = 0;
}
RouterLinkLexer.prototype.tokenize = function() {
var tokens = [];
while (this.index < this.exp.length) {
tokens.push(this._parseToken());
}
return tokens;
};
RouterLinkLexer.prototype._parseToken = function() {
var c = this.exp[this.index];
if (c == '[') {
this.index++;
return new AuxiliaryStart();
} else if (c == ']') {
this.index++;
return new AuxiliaryEnd();
} else if (c == '(') {
return this._parseParams();
} else if (c == '/' && this.index !== 0) {
this.index++;
return this._parseFixedPart();
} else {
return this._parseFixedPart();
}
};
RouterLinkLexer.prototype._parseParams = function() {
var start = this.index;
for (; this.index < this.exp.length; ++this.index) {
var c = this.exp[this.index];
if (c == ')') {
var paramsContent = this.exp.substring(start + 1, this.index);
this.index++;
return new Params(this.parser.parseBinding("{" + paramsContent + "}", null).ast);
}
}
throw new exceptions_1.BaseException("Cannot find ')'");
};
RouterLinkLexer.prototype._parseFixedPart = function() {
var start = this.index;
var sawNonSlash = false;
for (; this.index < this.exp.length; ++this.index) {
var c = this.exp[this.index];
if (c == '(' || c == '[' || c == ']' || (c == '/' && sawNonSlash)) {
break;
}
if (c != '.' && c != '/') {
sawNonSlash = true;
}
}
var fixed = this.exp.substring(start, this.index);
if (start === this.index || !sawNonSlash || fixed.startsWith('//')) {
throw new exceptions_1.BaseException("Invalid router link");
}
return new FixedPart(fixed);
};
return RouterLinkLexer;
}());
var RouterLinkAstGenerator = (function() {
function RouterLinkAstGenerator(tokens) {
this.tokens = tokens;
this.index = 0;
}
RouterLinkAstGenerator.prototype.generate = function() {
return this._genAuxiliary();
};
RouterLinkAstGenerator.prototype._genAuxiliary = function() {
var arr = [];
for (; this.index < this.tokens.length; this.index++) {
var r = this.tokens[this.index];
if (r instanceof FixedPart) {
arr.push(new ast_1.LiteralPrimitive(r.value));
} else if (r instanceof Params) {
arr.push(r.ast);
} else if (r instanceof AuxiliaryEnd) {
break;
} else if (r instanceof AuxiliaryStart) {
this.index++;
arr.push(this._genAuxiliary());
}
}
return new ast_1.LiteralArray(arr);
};
return RouterLinkAstGenerator;
}());
var RouterLinkAstTransformer = (function(_super) {
__extends(RouterLinkAstTransformer, _super);
function RouterLinkAstTransformer(parser) {
_super.call(this);
this.parser = parser;
}
RouterLinkAstTransformer.prototype.visitQuote = function(ast, context) {
if (ast.prefix == "route") {
return parseRouterLinkExpression(this.parser, ast.uninterpretedExpression);
} else {
return _super.prototype.visitQuote.call(this, ast, context);
}
};
return RouterLinkAstTransformer;
}(ast_1.AstTransformer));
function parseRouterLinkExpression(parser, exp) {
var tokens = new RouterLinkLexer(parser, exp.trim()).tokenize();
return new RouterLinkAstGenerator(tokens).generate();
}
exports.parseRouterLinkExpression = parseRouterLinkExpression;
var RouterLinkTransform = (function() {
function RouterLinkTransform(parser) {
this.astTransformer = new RouterLinkAstTransformer(parser);
}
RouterLinkTransform.prototype.visitNgContent = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitEmbeddedTemplate = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitElement = function(ast, context) {
var _this = this;
var updatedChildren = ast.children.map(function(c) {
return c.visit(_this, context);
});
var updatedInputs = ast.inputs.map(function(c) {
return c.visit(_this, context);
});
var updatedDirectives = ast.directives.map(function(c) {
return c.visit(_this, context);
});
return new compiler_1.ElementAst(ast.name, ast.attrs, updatedInputs, ast.outputs, ast.references, updatedDirectives, ast.providers, ast.hasViewContainer, updatedChildren, ast.ngContentIndex, ast.sourceSpan);
};
RouterLinkTransform.prototype.visitReference = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitVariable = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitEvent = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitElementProperty = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitAttr = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitBoundText = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitText = function(ast, context) {
return ast;
};
RouterLinkTransform.prototype.visitDirective = function(ast, context) {
var _this = this;
var updatedInputs = ast.inputs.map(function(c) {
return c.visit(_this, context);
});
return new compiler_1.DirectiveAst(ast.directive, updatedInputs, ast.hostProperties, ast.hostEvents, ast.sourceSpan);
};
RouterLinkTransform.prototype.visitDirectiveProperty = function(ast, context) {
var transformedValue = ast.value.visit(this.astTransformer);
return new compiler_1.BoundDirectivePropertyAst(ast.directiveName, ast.templateName, transformedValue, ast.sourceSpan);
};
RouterLinkTransform = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [parser_1.Parser])], RouterLinkTransform);
return RouterLinkTransform;
}());
exports.RouterLinkTransform = RouterLinkTransform;
global.define = __define;
return module.exports;
});
System.register("angular2/router/router_link_dsl", ["angular2/compiler", "angular2/core", "angular2/src/router/directives/router_link_transform", "angular2/src/facade/lang", "angular2/src/router/directives/router_link_transform"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var compiler_1 = require("angular2/compiler");
var core_1 = require("angular2/core");
var router_link_transform_1 = require("angular2/src/router/directives/router_link_transform");
var lang_1 = require("angular2/src/facade/lang");
var router_link_transform_2 = require("angular2/src/router/directives/router_link_transform");
exports.RouterLinkTransform = router_link_transform_2.RouterLinkTransform;
exports.ROUTER_LINK_DSL_PROVIDER = lang_1.CONST_EXPR(new core_1.Provider(compiler_1.TEMPLATE_TRANSFORMS, {
useClass: router_link_transform_1.RouterLinkTransform,
multi: true
}));
global.define = __define;
return module.exports;
});
System.register("angular2/src/platform/browser/location/platform_location", [], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var PlatformLocation = (function() {
function PlatformLocation() {}
Object.defineProperty(PlatformLocation.prototype, "pathname", {
get: function() {
return null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformLocation.prototype, "search", {
get: function() {
return null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformLocation.prototype, "hash", {
get: function() {
return null;
},
enumerable: true,
configurable: true
});
return PlatformLocation;
}());
exports.PlatformLocation = PlatformLocation;
global.define = __define;
return module.exports;
});
System.register("angular2/src/platform/browser/location/location", ["angular2/src/facade/async", "angular2/core", "angular2/src/platform/browser/location/location_strategy"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var async_1 = require("angular2/src/facade/async");
var core_1 = require("angular2/core");
var location_strategy_1 = require("angular2/src/platform/browser/location/location_strategy");
var Location = (function() {
function Location(platformStrategy) {
var _this = this;
this.platformStrategy = platformStrategy;
this._subject = new async_1.EventEmitter();
var browserBaseHref = this.platformStrategy.getBaseHref();
this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
this.platformStrategy.onPopState(function(ev) {
async_1.ObservableWrapper.callEmit(_this._subject, {
'url': _this.path(),
'pop': true,
'type': ev.type
});
});
}
Location.prototype.path = function() {
return this.normalize(this.platformStrategy.path());
};
Location.prototype.normalize = function(url) {
return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
};
Location.prototype.prepareExternalUrl = function(url) {
if (url.length > 0 && !url.startsWith('/')) {
url = '/' + url;
}
return this.platformStrategy.prepareExternalUrl(url);
};
Location.prototype.go = function(path, query) {
if (query === void 0) {
query = '';
}
this.platformStrategy.pushState(null, '', path, query);
};
Location.prototype.replaceState = function(path, query) {
if (query === void 0) {
query = '';
}
this.platformStrategy.replaceState(null, '', path, query);
};
Location.prototype.forward = function() {
this.platformStrategy.forward();
};
Location.prototype.back = function() {
this.platformStrategy.back();
};
Location.prototype.subscribe = function(onNext, onThrow, onReturn) {
if (onThrow === void 0) {
onThrow = null;
}
if (onReturn === void 0) {
onReturn = null;
}
return async_1.ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn);
};
Location.normalizeQueryParams = function(params) {
return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
};
Location.joinWithSlash = function(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;
};
Location.stripTrailingSlash = function(url) {
if (/\/$/g.test(url)) {
url = url.substring(0, url.length - 1);
}
return url;
};
Location = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [location_strategy_1.LocationStrategy])], Location);
return Location;
}());
exports.Location = Location;
function _stripBaseHref(baseHref, url) {
if (baseHref.length > 0 && url.startsWith(baseHref)) {
return url.substring(baseHref.length);
}
return url;
}
function _stripIndexHtml(url) {
if (/\/index.html$/g.test(url)) {
return url.substring(0, url.length - 11);
}
return url;
}
global.define = __define;
return module.exports;
});
System.register("angular2/src/platform/browser/location/path_location_strategy", ["angular2/core", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/platform/browser/location/platform_location", "angular2/src/platform/browser/location/location_strategy", "angular2/src/platform/browser/location/location"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
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) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
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 platform_location_1 = require("angular2/src/platform/browser/location/platform_location");
var location_strategy_1 = require("angular2/src/platform/browser/location/location_strategy");
var location_1 = require("angular2/src/platform/browser/location/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_1.Location.joinWithSlash(this._baseHref, internal);
};
PathLocationStrategy.prototype.path = function() {
return this._platformLocation.pathname + location_1.Location.normalizeQueryParams(this._platformLocation.search);
};
PathLocationStrategy.prototype.pushState = function(state, title, url, queryParams) {
var externalUrl = this.prepareExternalUrl(url + location_1.Location.normalizeQueryParams(queryParams));
this._platformLocation.pushState(state, title, externalUrl);
};
PathLocationStrategy.prototype.replaceState = function(state, title, url, queryParams) {
var externalUrl = this.prepareExternalUrl(url + location_1.Location.normalizeQueryParams(queryParams));
this._platformLocation.replaceState(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_config/route_config_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
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) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
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 __make_dart_analyzer_happy = null;
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 AbstractRoute = (function() {
function AbstractRoute(_a) {
var name = _a.name,
useAsDefault = _a.useAsDefault,
path = _a.path,
regex = _a.regex,
serializer = _a.serializer,
data = _a.data;
this.name = name;
this.useAsDefault = useAsDefault;
this.path = path;
this.regex = regex;
this.serializer = serializer;
this.data = data;
}
AbstractRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AbstractRoute);
return AbstractRoute;
}());
exports.AbstractRoute = AbstractRoute;
var Route = (function(_super) {
__extends(Route, _super);
function Route(_a) {
var name = _a.name,
useAsDefault = _a.useAsDefault,
path = _a.path,
regex = _a.regex,
serializer = _a.serializer,
data = _a.data,
component = _a.component;
_super.call(this, {
name: name,
useAsDefault: useAsDefault,
path: path,
regex: regex,
serializer: serializer,
data: data
});
this.aux = null;
this.component = component;
}
Route = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Route);
return Route;
}(AbstractRoute));
exports.Route = Route;
var AuxRoute = (function(_super) {
__extends(AuxRoute, _super);
function AuxRoute(_a) {
var name = _a.name,
useAsDefault = _a.useAsDefault,
path = _a.path,
regex = _a.regex,
serializer = _a.serializer,
data = _a.data,
component = _a.component;
_super.call(this, {
name: name,
useAsDefault: useAsDefault,
path: path,
regex: regex,
serializer: serializer,
data: data
});
this.component = component;
}
AuxRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AuxRoute);
return AuxRoute;
}(AbstractRoute));
exports.AuxRoute = AuxRoute;
var AsyncRoute = (function(_super) {
__extends(AsyncRoute, _super);
function AsyncRoute(_a) {
var name = _a.name,
useAsDefault = _a.useAsDefault,
path = _a.path,
regex = _a.regex,
serializer = _a.serializer,
data = _a.data,
loader = _a.loader;
_super.call(this, {
name: name,
useAsDefault: useAsDefault,
path: path,
regex: regex,
serializer: serializer,
data: data
});
this.aux = null;
this.loader = loader;
}
AsyncRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AsyncRoute);
return AsyncRoute;
}(AbstractRoute));
exports.AsyncRoute = AsyncRoute;
var Redirect = (function(_super) {
__extends(Redirect, _super);
function Redirect(_a) {
var name = _a.name,
useAsDefault = _a.useAsDefault,
path = _a.path,
regex = _a.regex,
serializer = _a.serializer,
data = _a.data,
redirectTo = _a.redirectTo;
_super.call(this, {
name: name,
useAsDefault: useAsDefault,
path: path,
regex: regex,
serializer: serializer,
data: data
});
this.redirectTo = redirectTo;
}
Redirect = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Redirect);
return Redirect;
}(AbstractRoute));
exports.Redirect = Redirect;
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;
"use strict";
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");
function convertUrlParamsToArray(urlParams) {
var paramsArray = [];
if (lang_1.isBlank(urlParams)) {
return [];
}
collection_1.StringMapWrapper.forEach(urlParams, function(value, key) {
paramsArray.push((value === true) ? key : key + '=' + value);
});
return paramsArray;
}
exports.convertUrlParamsToArray = convertUrlParamsToArray;
function serializeParams(urlParams, joiner) {
if (joiner === void 0) {
joiner = '&';
}
return convertUrlParamsToArray(urlParams).join(joiner);
}
exports.serializeParams = serializeParams;
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 = lang_1.CONST_EXPR({});
}
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() {
var paramString = serializeParams(this.params, ';');
if (paramString.length > 0) {
return ';' + paramString;
}
return '';
};
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);
};
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 QUERY_PARAM_VALUE_RE = lang_1.RegExpWrapper.create('^[^\\(\\)\\?;&#]+');
function matchUrlQueryParamValue(str) {
var match = lang_1.RegExpWrapper.firstMatch(QUERY_PARAM_VALUE_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.parseQueryParam(params);
while (this._remaining.length > 0 && this.peekStartsWith('&')) {
this.capture('&');
this.parseQueryParam(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.parseQueryParam = 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 = matchUrlQueryParamValue(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();
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;
"use strict";
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(component, child, auxInstruction) {
this.component = component;
this.child = child;
this.auxInstruction = auxInstruction;
}
Object.defineProperty(Instruction.prototype, "urlPath", {
get: function() {
return lang_1.isPresent(this.component) ? this.component.urlPath : '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(Instruction.prototype, "urlParams", {
get: function() {
return lang_1.isPresent(this.component) ? this.component.urlParams : [];
},
enumerable: true,
configurable: true
});
Object.defineProperty(Instruction.prototype, "specificity", {
get: function() {
var total = '';
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() : '') + this.toUrlQuery();
};
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.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, component, child, 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, component, child, {});
}
DefaultInstruction.prototype.toLinkUrl = function() {
return '';
};
DefaultInstruction.prototype._toLinkUrl = function() {
return '';
};
return DefaultInstruction;
}(ResolvedInstruction));
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, null, null, {});
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(instruction) {
_this.child = lang_1.isPresent(instruction) ? instruction.child : null;
return _this.component = lang_1.isPresent(instruction) ? instruction.component : null;
});
};
return UnresolvedInstruction;
}(Instruction));
exports.UnresolvedInstruction = UnresolvedInstruction;
var RedirectInstruction = (function(_super) {
__extends(RedirectInstruction, _super);
function RedirectInstruction(component, child, auxInstruction, _specificity) {
_super.call(this, component, child, auxInstruction);
this._specificity = _specificity;
}
Object.defineProperty(RedirectInstruction.prototype, "specificity", {
get: function() {
return this._specificity;
},
enumerable: true,
configurable: true
});
return RedirectInstruction;
}(ResolvedInstruction));
exports.RedirectInstruction = RedirectInstruction;
var ComponentInstruction = (function() {
function ComponentInstruction(urlPath, urlParams, data, componentType, terminal, specificity, params, routeName) {
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.routeName = routeName;
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/rules/route_handlers/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;
"use strict";
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/rules/route_handlers/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;
"use strict";
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/utils", ["angular2/src/facade/lang", "angular2/src/facade/collection"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var lang_1 = require("angular2/src/facade/lang");
var collection_1 = require("angular2/src/facade/collection");
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;
}());
exports.TouchMap = TouchMap;
function normalizeString(obj) {
if (lang_1.isBlank(obj)) {
return null;
} else {
return obj.toString();
}
}
exports.normalizeString = normalizeString;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/rules/route_paths/route_path", [], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var MatchedUrl = (function() {
function MatchedUrl(urlPath, urlParams, allParams, auxiliary, rest) {
this.urlPath = urlPath;
this.urlParams = urlParams;
this.allParams = allParams;
this.auxiliary = auxiliary;
this.rest = rest;
}
return MatchedUrl;
}());
exports.MatchedUrl = MatchedUrl;
var GeneratedUrl = (function() {
function GeneratedUrl(urlPath, urlParams) {
this.urlPath = urlPath;
this.urlParams = urlParams;
}
return GeneratedUrl;
}());
exports.GeneratedUrl = GeneratedUrl;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/rules/route_paths/regex_route_path", ["angular2/src/facade/lang", "angular2/src/router/rules/route_paths/route_path"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var lang_1 = require("angular2/src/facade/lang");
var route_path_1 = require("angular2/src/router/rules/route_paths/route_path");
var RegexRoutePath = (function() {
function RegexRoutePath(_reString, _serializer) {
this._reString = _reString;
this._serializer = _serializer;
this.terminal = true;
this.specificity = '2';
this.hash = this._reString;
this._regex = lang_1.RegExpWrapper.create(this._reString);
}
RegexRoutePath.prototype.matchUrl = function(url) {
var urlPath = url.toString();
var params = {};
var matcher = lang_1.RegExpWrapper.matcher(this._regex, urlPath);
var match = lang_1.RegExpMatcherWrapper.next(matcher);
if (lang_1.isBlank(match)) {
return null;
}
for (var i = 0; i < match.length; i += 1) {
params[i.toString()] = match[i];
}
return new route_path_1.MatchedUrl(urlPath, [], params, [], null);
};
RegexRoutePath.prototype.generateUrl = function(params) {
return this._serializer(params);
};
RegexRoutePath.prototype.toString = function() {
return this._reString;
};
return RegexRoutePath;
}());
exports.RegexRoutePath = RegexRoutePath;
global.define = __define;
return module.exports;
});
System.register("angular2/src/router/route_config/route_config_decorator", ["angular2/src/router/route_config/route_config_impl", "angular2/src/core/util/decorators", "angular2/src/router/route_config/route_config_impl"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var route_config_impl_1 = require("angular2/src/router/route_config/route_config_impl");
var decorators_1 = require("angular2/src/core/util/decorators");
var route_config_impl_2 = require("angular2/src/router/route_config/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/lifecycle/lifecycle_annotations_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
var global = System.global,
__define = global.define;
global.define = undefined;
"use strict";
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key)