angular2-rails 2.0.0.pre.beta.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +25 -0
- data/lib/angular2-rails.rb +9 -0
- data/lib/angular2-rails/engine.rb +6 -0
- data/lib/angular2-rails/sprockets.rb +3 -0
- data/lib/angular2-rails/version.rb +5 -0
- data/lib/tasks/angular2/rails_tasks.rake +4 -0
- data/vendor/assets/javascripts/Rx.js +11615 -0
- data/vendor/assets/javascripts/Rx.min.js +417 -0
- data/vendor/assets/javascripts/Rx.min.js.map +1 -0
- data/vendor/assets/javascripts/Rx.umd.js +10274 -0
- data/vendor/assets/javascripts/Rx.umd.min.js +748 -0
- data/vendor/assets/javascripts/Rx.umd.min.js.map +8 -0
- data/vendor/assets/javascripts/angular2-all-testing.umd.dev.js +41097 -0
- data/vendor/assets/javascripts/angular2-all.umd.dev.js +38827 -0
- data/vendor/assets/javascripts/angular2-all.umd.js +38826 -0
- data/vendor/assets/javascripts/angular2-all.umd.min.js +20 -0
- data/vendor/assets/javascripts/angular2-polyfills.js +2491 -0
- data/vendor/assets/javascripts/angular2-polyfills.min.js +1 -0
- data/vendor/assets/javascripts/angular2.dev.js +26056 -0
- data/vendor/assets/javascripts/angular2.js +26056 -0
- data/vendor/assets/javascripts/angular2.min.js +19 -0
- data/vendor/assets/javascripts/http.dev.js +1106 -0
- data/vendor/assets/javascripts/http.js +1106 -0
- data/vendor/assets/javascripts/http.min.js +1 -0
- data/vendor/assets/javascripts/overview.md +92 -0
- data/vendor/assets/javascripts/router.dev.js +3436 -0
- data/vendor/assets/javascripts/router.js +3436 -0
- data/vendor/assets/javascripts/router.min.js +3 -0
- data/vendor/assets/javascripts/testing.dev.js +2205 -0
- data/vendor/assets/javascripts/testing.dev.js.map +1 -0
- data/vendor/assets/javascripts/upgrade.dev.js +833 -0
- data/vendor/assets/javascripts/upgrade.js +833 -0
- data/vendor/assets/javascripts/upgrade.min.js +1 -0
- data/vendor/assets/javascripts/web_worker/ui.dev.js +24221 -0
- data/vendor/assets/javascripts/web_worker/worker.dev.js +40089 -0
- metadata +101 -0
@@ -0,0 +1,3436 @@
|
|
1
|
+
"format register";
|
2
|
+
System.register("angular2/src/router/directives/router_link_transform", ["angular2/compiler", "angular2/src/core/change_detection/parser/ast", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/core/change_detection/parser/parser"], true, function(require, exports, module) {
|
3
|
+
var global = System.global,
|
4
|
+
__define = global.define;
|
5
|
+
global.define = undefined;
|
6
|
+
"use strict";
|
7
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
8
|
+
for (var p in b)
|
9
|
+
if (b.hasOwnProperty(p))
|
10
|
+
d[p] = b[p];
|
11
|
+
function __() {
|
12
|
+
this.constructor = d;
|
13
|
+
}
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15
|
+
};
|
16
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
17
|
+
var c = arguments.length,
|
18
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
19
|
+
d;
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
21
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
22
|
+
else
|
23
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
24
|
+
if (d = decorators[i])
|
25
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
27
|
+
};
|
28
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
30
|
+
return Reflect.metadata(k, v);
|
31
|
+
};
|
32
|
+
var compiler_1 = require("angular2/compiler");
|
33
|
+
var ast_1 = require("angular2/src/core/change_detection/parser/ast");
|
34
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
35
|
+
var core_1 = require("angular2/core");
|
36
|
+
var parser_1 = require("angular2/src/core/change_detection/parser/parser");
|
37
|
+
var FixedPart = (function() {
|
38
|
+
function FixedPart(value) {
|
39
|
+
this.value = value;
|
40
|
+
}
|
41
|
+
return FixedPart;
|
42
|
+
}());
|
43
|
+
var AuxiliaryStart = (function() {
|
44
|
+
function AuxiliaryStart() {}
|
45
|
+
return AuxiliaryStart;
|
46
|
+
}());
|
47
|
+
var AuxiliaryEnd = (function() {
|
48
|
+
function AuxiliaryEnd() {}
|
49
|
+
return AuxiliaryEnd;
|
50
|
+
}());
|
51
|
+
var Params = (function() {
|
52
|
+
function Params(ast) {
|
53
|
+
this.ast = ast;
|
54
|
+
}
|
55
|
+
return Params;
|
56
|
+
}());
|
57
|
+
var RouterLinkLexer = (function() {
|
58
|
+
function RouterLinkLexer(parser, exp) {
|
59
|
+
this.parser = parser;
|
60
|
+
this.exp = exp;
|
61
|
+
this.index = 0;
|
62
|
+
}
|
63
|
+
RouterLinkLexer.prototype.tokenize = function() {
|
64
|
+
var tokens = [];
|
65
|
+
while (this.index < this.exp.length) {
|
66
|
+
tokens.push(this._parseToken());
|
67
|
+
}
|
68
|
+
return tokens;
|
69
|
+
};
|
70
|
+
RouterLinkLexer.prototype._parseToken = function() {
|
71
|
+
var c = this.exp[this.index];
|
72
|
+
if (c == '[') {
|
73
|
+
this.index++;
|
74
|
+
return new AuxiliaryStart();
|
75
|
+
} else if (c == ']') {
|
76
|
+
this.index++;
|
77
|
+
return new AuxiliaryEnd();
|
78
|
+
} else if (c == '(') {
|
79
|
+
return this._parseParams();
|
80
|
+
} else if (c == '/' && this.index !== 0) {
|
81
|
+
this.index++;
|
82
|
+
return this._parseFixedPart();
|
83
|
+
} else {
|
84
|
+
return this._parseFixedPart();
|
85
|
+
}
|
86
|
+
};
|
87
|
+
RouterLinkLexer.prototype._parseParams = function() {
|
88
|
+
var start = this.index;
|
89
|
+
for (; this.index < this.exp.length; ++this.index) {
|
90
|
+
var c = this.exp[this.index];
|
91
|
+
if (c == ')') {
|
92
|
+
var paramsContent = this.exp.substring(start + 1, this.index);
|
93
|
+
this.index++;
|
94
|
+
return new Params(this.parser.parseBinding("{" + paramsContent + "}", null).ast);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
throw new exceptions_1.BaseException("Cannot find ')'");
|
98
|
+
};
|
99
|
+
RouterLinkLexer.prototype._parseFixedPart = function() {
|
100
|
+
var start = this.index;
|
101
|
+
var sawNonSlash = false;
|
102
|
+
for (; this.index < this.exp.length; ++this.index) {
|
103
|
+
var c = this.exp[this.index];
|
104
|
+
if (c == '(' || c == '[' || c == ']' || (c == '/' && sawNonSlash)) {
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
if (c != '.' && c != '/') {
|
108
|
+
sawNonSlash = true;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
var fixed = this.exp.substring(start, this.index);
|
112
|
+
if (start === this.index || !sawNonSlash || fixed.startsWith('//')) {
|
113
|
+
throw new exceptions_1.BaseException("Invalid router link");
|
114
|
+
}
|
115
|
+
return new FixedPart(fixed);
|
116
|
+
};
|
117
|
+
return RouterLinkLexer;
|
118
|
+
}());
|
119
|
+
var RouterLinkAstGenerator = (function() {
|
120
|
+
function RouterLinkAstGenerator(tokens) {
|
121
|
+
this.tokens = tokens;
|
122
|
+
this.index = 0;
|
123
|
+
}
|
124
|
+
RouterLinkAstGenerator.prototype.generate = function() {
|
125
|
+
return this._genAuxiliary();
|
126
|
+
};
|
127
|
+
RouterLinkAstGenerator.prototype._genAuxiliary = function() {
|
128
|
+
var arr = [];
|
129
|
+
for (; this.index < this.tokens.length; this.index++) {
|
130
|
+
var r = this.tokens[this.index];
|
131
|
+
if (r instanceof FixedPart) {
|
132
|
+
arr.push(new ast_1.LiteralPrimitive(r.value));
|
133
|
+
} else if (r instanceof Params) {
|
134
|
+
arr.push(r.ast);
|
135
|
+
} else if (r instanceof AuxiliaryEnd) {
|
136
|
+
break;
|
137
|
+
} else if (r instanceof AuxiliaryStart) {
|
138
|
+
this.index++;
|
139
|
+
arr.push(this._genAuxiliary());
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return new ast_1.LiteralArray(arr);
|
143
|
+
};
|
144
|
+
return RouterLinkAstGenerator;
|
145
|
+
}());
|
146
|
+
var RouterLinkAstTransformer = (function(_super) {
|
147
|
+
__extends(RouterLinkAstTransformer, _super);
|
148
|
+
function RouterLinkAstTransformer(parser) {
|
149
|
+
_super.call(this);
|
150
|
+
this.parser = parser;
|
151
|
+
}
|
152
|
+
RouterLinkAstTransformer.prototype.visitQuote = function(ast) {
|
153
|
+
if (ast.prefix == "route") {
|
154
|
+
return parseRouterLinkExpression(this.parser, ast.uninterpretedExpression);
|
155
|
+
} else {
|
156
|
+
return _super.prototype.visitQuote.call(this, ast);
|
157
|
+
}
|
158
|
+
};
|
159
|
+
return RouterLinkAstTransformer;
|
160
|
+
}(ast_1.AstTransformer));
|
161
|
+
function parseRouterLinkExpression(parser, exp) {
|
162
|
+
var tokens = new RouterLinkLexer(parser, exp.trim()).tokenize();
|
163
|
+
return new RouterLinkAstGenerator(tokens).generate();
|
164
|
+
}
|
165
|
+
exports.parseRouterLinkExpression = parseRouterLinkExpression;
|
166
|
+
var RouterLinkTransform = (function() {
|
167
|
+
function RouterLinkTransform(parser) {
|
168
|
+
this.astTransformer = new RouterLinkAstTransformer(parser);
|
169
|
+
}
|
170
|
+
RouterLinkTransform.prototype.visitNgContent = function(ast, context) {
|
171
|
+
return ast;
|
172
|
+
};
|
173
|
+
RouterLinkTransform.prototype.visitEmbeddedTemplate = function(ast, context) {
|
174
|
+
return ast;
|
175
|
+
};
|
176
|
+
RouterLinkTransform.prototype.visitElement = function(ast, context) {
|
177
|
+
var _this = this;
|
178
|
+
var updatedChildren = ast.children.map(function(c) {
|
179
|
+
return c.visit(_this, context);
|
180
|
+
});
|
181
|
+
var updatedInputs = ast.inputs.map(function(c) {
|
182
|
+
return c.visit(_this, context);
|
183
|
+
});
|
184
|
+
var updatedDirectives = ast.directives.map(function(c) {
|
185
|
+
return c.visit(_this, context);
|
186
|
+
});
|
187
|
+
return new compiler_1.ElementAst(ast.name, ast.attrs, updatedInputs, ast.outputs, ast.exportAsVars, updatedDirectives, updatedChildren, ast.ngContentIndex, ast.sourceSpan);
|
188
|
+
};
|
189
|
+
RouterLinkTransform.prototype.visitVariable = function(ast, context) {
|
190
|
+
return ast;
|
191
|
+
};
|
192
|
+
RouterLinkTransform.prototype.visitEvent = function(ast, context) {
|
193
|
+
return ast;
|
194
|
+
};
|
195
|
+
RouterLinkTransform.prototype.visitElementProperty = function(ast, context) {
|
196
|
+
return ast;
|
197
|
+
};
|
198
|
+
RouterLinkTransform.prototype.visitAttr = function(ast, context) {
|
199
|
+
return ast;
|
200
|
+
};
|
201
|
+
RouterLinkTransform.prototype.visitBoundText = function(ast, context) {
|
202
|
+
return ast;
|
203
|
+
};
|
204
|
+
RouterLinkTransform.prototype.visitText = function(ast, context) {
|
205
|
+
return ast;
|
206
|
+
};
|
207
|
+
RouterLinkTransform.prototype.visitDirective = function(ast, context) {
|
208
|
+
var _this = this;
|
209
|
+
var updatedInputs = ast.inputs.map(function(c) {
|
210
|
+
return c.visit(_this, context);
|
211
|
+
});
|
212
|
+
return new compiler_1.DirectiveAst(ast.directive, updatedInputs, ast.hostProperties, ast.hostEvents, ast.exportAsVars, ast.sourceSpan);
|
213
|
+
};
|
214
|
+
RouterLinkTransform.prototype.visitDirectiveProperty = function(ast, context) {
|
215
|
+
var transformedValue = ast.value.visit(this.astTransformer);
|
216
|
+
return new compiler_1.BoundDirectivePropertyAst(ast.directiveName, ast.templateName, transformedValue, ast.sourceSpan);
|
217
|
+
};
|
218
|
+
RouterLinkTransform = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [parser_1.Parser])], RouterLinkTransform);
|
219
|
+
return RouterLinkTransform;
|
220
|
+
}());
|
221
|
+
exports.RouterLinkTransform = RouterLinkTransform;
|
222
|
+
global.define = __define;
|
223
|
+
return module.exports;
|
224
|
+
});
|
225
|
+
|
226
|
+
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) {
|
227
|
+
var global = System.global,
|
228
|
+
__define = global.define;
|
229
|
+
global.define = undefined;
|
230
|
+
"use strict";
|
231
|
+
var compiler_1 = require("angular2/compiler");
|
232
|
+
var core_1 = require("angular2/core");
|
233
|
+
var router_link_transform_1 = require("angular2/src/router/directives/router_link_transform");
|
234
|
+
var lang_1 = require("angular2/src/facade/lang");
|
235
|
+
var router_link_transform_2 = require("angular2/src/router/directives/router_link_transform");
|
236
|
+
exports.RouterLinkTransform = router_link_transform_2.RouterLinkTransform;
|
237
|
+
exports.ROUTER_LINK_DSL_PROVIDER = lang_1.CONST_EXPR(new core_1.Provider(compiler_1.TEMPLATE_TRANSFORMS, {
|
238
|
+
useClass: router_link_transform_1.RouterLinkTransform,
|
239
|
+
multi: true
|
240
|
+
}));
|
241
|
+
global.define = __define;
|
242
|
+
return module.exports;
|
243
|
+
});
|
244
|
+
|
245
|
+
System.register("angular2/src/router/route_config/route_config_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
|
246
|
+
var global = System.global,
|
247
|
+
__define = global.define;
|
248
|
+
global.define = undefined;
|
249
|
+
"use strict";
|
250
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
251
|
+
for (var p in b)
|
252
|
+
if (b.hasOwnProperty(p))
|
253
|
+
d[p] = b[p];
|
254
|
+
function __() {
|
255
|
+
this.constructor = d;
|
256
|
+
}
|
257
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
258
|
+
};
|
259
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
260
|
+
var c = arguments.length,
|
261
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
262
|
+
d;
|
263
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
264
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
265
|
+
else
|
266
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
267
|
+
if (d = decorators[i])
|
268
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
269
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
270
|
+
};
|
271
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
272
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
273
|
+
return Reflect.metadata(k, v);
|
274
|
+
};
|
275
|
+
var lang_1 = require("angular2/src/facade/lang");
|
276
|
+
var __make_dart_analyzer_happy = null;
|
277
|
+
var RouteConfig = (function() {
|
278
|
+
function RouteConfig(configs) {
|
279
|
+
this.configs = configs;
|
280
|
+
}
|
281
|
+
RouteConfig = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Array])], RouteConfig);
|
282
|
+
return RouteConfig;
|
283
|
+
}());
|
284
|
+
exports.RouteConfig = RouteConfig;
|
285
|
+
var AbstractRoute = (function() {
|
286
|
+
function AbstractRoute(_a) {
|
287
|
+
var name = _a.name,
|
288
|
+
useAsDefault = _a.useAsDefault,
|
289
|
+
path = _a.path,
|
290
|
+
regex = _a.regex,
|
291
|
+
serializer = _a.serializer,
|
292
|
+
data = _a.data;
|
293
|
+
this.name = name;
|
294
|
+
this.useAsDefault = useAsDefault;
|
295
|
+
this.path = path;
|
296
|
+
this.regex = regex;
|
297
|
+
this.serializer = serializer;
|
298
|
+
this.data = data;
|
299
|
+
}
|
300
|
+
AbstractRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AbstractRoute);
|
301
|
+
return AbstractRoute;
|
302
|
+
}());
|
303
|
+
exports.AbstractRoute = AbstractRoute;
|
304
|
+
var Route = (function(_super) {
|
305
|
+
__extends(Route, _super);
|
306
|
+
function Route(_a) {
|
307
|
+
var name = _a.name,
|
308
|
+
useAsDefault = _a.useAsDefault,
|
309
|
+
path = _a.path,
|
310
|
+
regex = _a.regex,
|
311
|
+
serializer = _a.serializer,
|
312
|
+
data = _a.data,
|
313
|
+
component = _a.component;
|
314
|
+
_super.call(this, {
|
315
|
+
name: name,
|
316
|
+
useAsDefault: useAsDefault,
|
317
|
+
path: path,
|
318
|
+
regex: regex,
|
319
|
+
serializer: serializer,
|
320
|
+
data: data
|
321
|
+
});
|
322
|
+
this.aux = null;
|
323
|
+
this.component = component;
|
324
|
+
}
|
325
|
+
Route = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Route);
|
326
|
+
return Route;
|
327
|
+
}(AbstractRoute));
|
328
|
+
exports.Route = Route;
|
329
|
+
var AuxRoute = (function(_super) {
|
330
|
+
__extends(AuxRoute, _super);
|
331
|
+
function AuxRoute(_a) {
|
332
|
+
var name = _a.name,
|
333
|
+
useAsDefault = _a.useAsDefault,
|
334
|
+
path = _a.path,
|
335
|
+
regex = _a.regex,
|
336
|
+
serializer = _a.serializer,
|
337
|
+
data = _a.data,
|
338
|
+
component = _a.component;
|
339
|
+
_super.call(this, {
|
340
|
+
name: name,
|
341
|
+
useAsDefault: useAsDefault,
|
342
|
+
path: path,
|
343
|
+
regex: regex,
|
344
|
+
serializer: serializer,
|
345
|
+
data: data
|
346
|
+
});
|
347
|
+
this.component = component;
|
348
|
+
}
|
349
|
+
AuxRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AuxRoute);
|
350
|
+
return AuxRoute;
|
351
|
+
}(AbstractRoute));
|
352
|
+
exports.AuxRoute = AuxRoute;
|
353
|
+
var AsyncRoute = (function(_super) {
|
354
|
+
__extends(AsyncRoute, _super);
|
355
|
+
function AsyncRoute(_a) {
|
356
|
+
var name = _a.name,
|
357
|
+
useAsDefault = _a.useAsDefault,
|
358
|
+
path = _a.path,
|
359
|
+
regex = _a.regex,
|
360
|
+
serializer = _a.serializer,
|
361
|
+
data = _a.data,
|
362
|
+
loader = _a.loader;
|
363
|
+
_super.call(this, {
|
364
|
+
name: name,
|
365
|
+
useAsDefault: useAsDefault,
|
366
|
+
path: path,
|
367
|
+
regex: regex,
|
368
|
+
serializer: serializer,
|
369
|
+
data: data
|
370
|
+
});
|
371
|
+
this.aux = null;
|
372
|
+
this.loader = loader;
|
373
|
+
}
|
374
|
+
AsyncRoute = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], AsyncRoute);
|
375
|
+
return AsyncRoute;
|
376
|
+
}(AbstractRoute));
|
377
|
+
exports.AsyncRoute = AsyncRoute;
|
378
|
+
var Redirect = (function(_super) {
|
379
|
+
__extends(Redirect, _super);
|
380
|
+
function Redirect(_a) {
|
381
|
+
var name = _a.name,
|
382
|
+
useAsDefault = _a.useAsDefault,
|
383
|
+
path = _a.path,
|
384
|
+
regex = _a.regex,
|
385
|
+
serializer = _a.serializer,
|
386
|
+
data = _a.data,
|
387
|
+
redirectTo = _a.redirectTo;
|
388
|
+
_super.call(this, {
|
389
|
+
name: name,
|
390
|
+
useAsDefault: useAsDefault,
|
391
|
+
path: path,
|
392
|
+
regex: regex,
|
393
|
+
serializer: serializer,
|
394
|
+
data: data
|
395
|
+
});
|
396
|
+
this.redirectTo = redirectTo;
|
397
|
+
}
|
398
|
+
Redirect = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Object])], Redirect);
|
399
|
+
return Redirect;
|
400
|
+
}(AbstractRoute));
|
401
|
+
exports.Redirect = Redirect;
|
402
|
+
global.define = __define;
|
403
|
+
return module.exports;
|
404
|
+
});
|
405
|
+
|
406
|
+
System.register("angular2/src/router/url_parser", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
|
407
|
+
var global = System.global,
|
408
|
+
__define = global.define;
|
409
|
+
global.define = undefined;
|
410
|
+
"use strict";
|
411
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
412
|
+
for (var p in b)
|
413
|
+
if (b.hasOwnProperty(p))
|
414
|
+
d[p] = b[p];
|
415
|
+
function __() {
|
416
|
+
this.constructor = d;
|
417
|
+
}
|
418
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
419
|
+
};
|
420
|
+
var collection_1 = require("angular2/src/facade/collection");
|
421
|
+
var lang_1 = require("angular2/src/facade/lang");
|
422
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
423
|
+
function convertUrlParamsToArray(urlParams) {
|
424
|
+
var paramsArray = [];
|
425
|
+
if (lang_1.isBlank(urlParams)) {
|
426
|
+
return [];
|
427
|
+
}
|
428
|
+
collection_1.StringMapWrapper.forEach(urlParams, function(value, key) {
|
429
|
+
paramsArray.push((value === true) ? key : key + '=' + value);
|
430
|
+
});
|
431
|
+
return paramsArray;
|
432
|
+
}
|
433
|
+
exports.convertUrlParamsToArray = convertUrlParamsToArray;
|
434
|
+
function serializeParams(urlParams, joiner) {
|
435
|
+
if (joiner === void 0) {
|
436
|
+
joiner = '&';
|
437
|
+
}
|
438
|
+
return convertUrlParamsToArray(urlParams).join(joiner);
|
439
|
+
}
|
440
|
+
exports.serializeParams = serializeParams;
|
441
|
+
var Url = (function() {
|
442
|
+
function Url(path, child, auxiliary, params) {
|
443
|
+
if (child === void 0) {
|
444
|
+
child = null;
|
445
|
+
}
|
446
|
+
if (auxiliary === void 0) {
|
447
|
+
auxiliary = lang_1.CONST_EXPR([]);
|
448
|
+
}
|
449
|
+
if (params === void 0) {
|
450
|
+
params = lang_1.CONST_EXPR({});
|
451
|
+
}
|
452
|
+
this.path = path;
|
453
|
+
this.child = child;
|
454
|
+
this.auxiliary = auxiliary;
|
455
|
+
this.params = params;
|
456
|
+
}
|
457
|
+
Url.prototype.toString = function() {
|
458
|
+
return this.path + this._matrixParamsToString() + this._auxToString() + this._childString();
|
459
|
+
};
|
460
|
+
Url.prototype.segmentToString = function() {
|
461
|
+
return this.path + this._matrixParamsToString();
|
462
|
+
};
|
463
|
+
Url.prototype._auxToString = function() {
|
464
|
+
return this.auxiliary.length > 0 ? ('(' + this.auxiliary.map(function(sibling) {
|
465
|
+
return sibling.toString();
|
466
|
+
}).join('//') + ')') : '';
|
467
|
+
};
|
468
|
+
Url.prototype._matrixParamsToString = function() {
|
469
|
+
var paramString = serializeParams(this.params, ';');
|
470
|
+
if (paramString.length > 0) {
|
471
|
+
return ';' + paramString;
|
472
|
+
}
|
473
|
+
return '';
|
474
|
+
};
|
475
|
+
Url.prototype._childString = function() {
|
476
|
+
return lang_1.isPresent(this.child) ? ('/' + this.child.toString()) : '';
|
477
|
+
};
|
478
|
+
return Url;
|
479
|
+
}());
|
480
|
+
exports.Url = Url;
|
481
|
+
var RootUrl = (function(_super) {
|
482
|
+
__extends(RootUrl, _super);
|
483
|
+
function RootUrl(path, child, auxiliary, params) {
|
484
|
+
if (child === void 0) {
|
485
|
+
child = null;
|
486
|
+
}
|
487
|
+
if (auxiliary === void 0) {
|
488
|
+
auxiliary = lang_1.CONST_EXPR([]);
|
489
|
+
}
|
490
|
+
if (params === void 0) {
|
491
|
+
params = null;
|
492
|
+
}
|
493
|
+
_super.call(this, path, child, auxiliary, params);
|
494
|
+
}
|
495
|
+
RootUrl.prototype.toString = function() {
|
496
|
+
return this.path + this._auxToString() + this._childString() + this._queryParamsToString();
|
497
|
+
};
|
498
|
+
RootUrl.prototype.segmentToString = function() {
|
499
|
+
return this.path + this._queryParamsToString();
|
500
|
+
};
|
501
|
+
RootUrl.prototype._queryParamsToString = function() {
|
502
|
+
if (lang_1.isBlank(this.params)) {
|
503
|
+
return '';
|
504
|
+
}
|
505
|
+
return '?' + serializeParams(this.params);
|
506
|
+
};
|
507
|
+
return RootUrl;
|
508
|
+
}(Url));
|
509
|
+
exports.RootUrl = RootUrl;
|
510
|
+
function pathSegmentsToUrl(pathSegments) {
|
511
|
+
var url = new Url(pathSegments[pathSegments.length - 1]);
|
512
|
+
for (var i = pathSegments.length - 2; i >= 0; i -= 1) {
|
513
|
+
url = new Url(pathSegments[i], url);
|
514
|
+
}
|
515
|
+
return url;
|
516
|
+
}
|
517
|
+
exports.pathSegmentsToUrl = pathSegmentsToUrl;
|
518
|
+
var SEGMENT_RE = lang_1.RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
|
519
|
+
function matchUrlSegment(str) {
|
520
|
+
var match = lang_1.RegExpWrapper.firstMatch(SEGMENT_RE, str);
|
521
|
+
return lang_1.isPresent(match) ? match[0] : '';
|
522
|
+
}
|
523
|
+
var QUERY_PARAM_VALUE_RE = lang_1.RegExpWrapper.create('^[^\\(\\)\\?;&#]+');
|
524
|
+
function matchUrlQueryParamValue(str) {
|
525
|
+
var match = lang_1.RegExpWrapper.firstMatch(QUERY_PARAM_VALUE_RE, str);
|
526
|
+
return lang_1.isPresent(match) ? match[0] : '';
|
527
|
+
}
|
528
|
+
var UrlParser = (function() {
|
529
|
+
function UrlParser() {}
|
530
|
+
UrlParser.prototype.peekStartsWith = function(str) {
|
531
|
+
return this._remaining.startsWith(str);
|
532
|
+
};
|
533
|
+
UrlParser.prototype.capture = function(str) {
|
534
|
+
if (!this._remaining.startsWith(str)) {
|
535
|
+
throw new exceptions_1.BaseException("Expected \"" + str + "\".");
|
536
|
+
}
|
537
|
+
this._remaining = this._remaining.substring(str.length);
|
538
|
+
};
|
539
|
+
UrlParser.prototype.parse = function(url) {
|
540
|
+
this._remaining = url;
|
541
|
+
if (url == '' || url == '/') {
|
542
|
+
return new Url('');
|
543
|
+
}
|
544
|
+
return this.parseRoot();
|
545
|
+
};
|
546
|
+
UrlParser.prototype.parseRoot = function() {
|
547
|
+
if (this.peekStartsWith('/')) {
|
548
|
+
this.capture('/');
|
549
|
+
}
|
550
|
+
var path = matchUrlSegment(this._remaining);
|
551
|
+
this.capture(path);
|
552
|
+
var aux = [];
|
553
|
+
if (this.peekStartsWith('(')) {
|
554
|
+
aux = this.parseAuxiliaryRoutes();
|
555
|
+
}
|
556
|
+
if (this.peekStartsWith(';')) {
|
557
|
+
this.parseMatrixParams();
|
558
|
+
}
|
559
|
+
var child = null;
|
560
|
+
if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
|
561
|
+
this.capture('/');
|
562
|
+
child = this.parseSegment();
|
563
|
+
}
|
564
|
+
var queryParams = null;
|
565
|
+
if (this.peekStartsWith('?')) {
|
566
|
+
queryParams = this.parseQueryParams();
|
567
|
+
}
|
568
|
+
return new RootUrl(path, child, aux, queryParams);
|
569
|
+
};
|
570
|
+
UrlParser.prototype.parseSegment = function() {
|
571
|
+
if (this._remaining.length == 0) {
|
572
|
+
return null;
|
573
|
+
}
|
574
|
+
if (this.peekStartsWith('/')) {
|
575
|
+
this.capture('/');
|
576
|
+
}
|
577
|
+
var path = matchUrlSegment(this._remaining);
|
578
|
+
this.capture(path);
|
579
|
+
var matrixParams = null;
|
580
|
+
if (this.peekStartsWith(';')) {
|
581
|
+
matrixParams = this.parseMatrixParams();
|
582
|
+
}
|
583
|
+
var aux = [];
|
584
|
+
if (this.peekStartsWith('(')) {
|
585
|
+
aux = this.parseAuxiliaryRoutes();
|
586
|
+
}
|
587
|
+
var child = null;
|
588
|
+
if (this.peekStartsWith('/') && !this.peekStartsWith('//')) {
|
589
|
+
this.capture('/');
|
590
|
+
child = this.parseSegment();
|
591
|
+
}
|
592
|
+
return new Url(path, child, aux, matrixParams);
|
593
|
+
};
|
594
|
+
UrlParser.prototype.parseQueryParams = function() {
|
595
|
+
var params = {};
|
596
|
+
this.capture('?');
|
597
|
+
this.parseQueryParam(params);
|
598
|
+
while (this._remaining.length > 0 && this.peekStartsWith('&')) {
|
599
|
+
this.capture('&');
|
600
|
+
this.parseQueryParam(params);
|
601
|
+
}
|
602
|
+
return params;
|
603
|
+
};
|
604
|
+
UrlParser.prototype.parseMatrixParams = function() {
|
605
|
+
var params = {};
|
606
|
+
while (this._remaining.length > 0 && this.peekStartsWith(';')) {
|
607
|
+
this.capture(';');
|
608
|
+
this.parseParam(params);
|
609
|
+
}
|
610
|
+
return params;
|
611
|
+
};
|
612
|
+
UrlParser.prototype.parseParam = function(params) {
|
613
|
+
var key = matchUrlSegment(this._remaining);
|
614
|
+
if (lang_1.isBlank(key)) {
|
615
|
+
return ;
|
616
|
+
}
|
617
|
+
this.capture(key);
|
618
|
+
var value = true;
|
619
|
+
if (this.peekStartsWith('=')) {
|
620
|
+
this.capture('=');
|
621
|
+
var valueMatch = matchUrlSegment(this._remaining);
|
622
|
+
if (lang_1.isPresent(valueMatch)) {
|
623
|
+
value = valueMatch;
|
624
|
+
this.capture(value);
|
625
|
+
}
|
626
|
+
}
|
627
|
+
params[key] = value;
|
628
|
+
};
|
629
|
+
UrlParser.prototype.parseQueryParam = function(params) {
|
630
|
+
var key = matchUrlSegment(this._remaining);
|
631
|
+
if (lang_1.isBlank(key)) {
|
632
|
+
return ;
|
633
|
+
}
|
634
|
+
this.capture(key);
|
635
|
+
var value = true;
|
636
|
+
if (this.peekStartsWith('=')) {
|
637
|
+
this.capture('=');
|
638
|
+
var valueMatch = matchUrlQueryParamValue(this._remaining);
|
639
|
+
if (lang_1.isPresent(valueMatch)) {
|
640
|
+
value = valueMatch;
|
641
|
+
this.capture(value);
|
642
|
+
}
|
643
|
+
}
|
644
|
+
params[key] = value;
|
645
|
+
};
|
646
|
+
UrlParser.prototype.parseAuxiliaryRoutes = function() {
|
647
|
+
var routes = [];
|
648
|
+
this.capture('(');
|
649
|
+
while (!this.peekStartsWith(')') && this._remaining.length > 0) {
|
650
|
+
routes.push(this.parseSegment());
|
651
|
+
if (this.peekStartsWith('//')) {
|
652
|
+
this.capture('//');
|
653
|
+
}
|
654
|
+
}
|
655
|
+
this.capture(')');
|
656
|
+
return routes;
|
657
|
+
};
|
658
|
+
return UrlParser;
|
659
|
+
}());
|
660
|
+
exports.UrlParser = UrlParser;
|
661
|
+
exports.parser = new UrlParser();
|
662
|
+
global.define = __define;
|
663
|
+
return module.exports;
|
664
|
+
});
|
665
|
+
|
666
|
+
System.register("angular2/src/router/instruction", ["angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/async"], true, function(require, exports, module) {
|
667
|
+
var global = System.global,
|
668
|
+
__define = global.define;
|
669
|
+
global.define = undefined;
|
670
|
+
"use strict";
|
671
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
672
|
+
for (var p in b)
|
673
|
+
if (b.hasOwnProperty(p))
|
674
|
+
d[p] = b[p];
|
675
|
+
function __() {
|
676
|
+
this.constructor = d;
|
677
|
+
}
|
678
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
679
|
+
};
|
680
|
+
var collection_1 = require("angular2/src/facade/collection");
|
681
|
+
var lang_1 = require("angular2/src/facade/lang");
|
682
|
+
var async_1 = require("angular2/src/facade/async");
|
683
|
+
var RouteParams = (function() {
|
684
|
+
function RouteParams(params) {
|
685
|
+
this.params = params;
|
686
|
+
}
|
687
|
+
RouteParams.prototype.get = function(param) {
|
688
|
+
return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.params, param));
|
689
|
+
};
|
690
|
+
return RouteParams;
|
691
|
+
}());
|
692
|
+
exports.RouteParams = RouteParams;
|
693
|
+
var RouteData = (function() {
|
694
|
+
function RouteData(data) {
|
695
|
+
if (data === void 0) {
|
696
|
+
data = lang_1.CONST_EXPR({});
|
697
|
+
}
|
698
|
+
this.data = data;
|
699
|
+
}
|
700
|
+
RouteData.prototype.get = function(key) {
|
701
|
+
return lang_1.normalizeBlank(collection_1.StringMapWrapper.get(this.data, key));
|
702
|
+
};
|
703
|
+
return RouteData;
|
704
|
+
}());
|
705
|
+
exports.RouteData = RouteData;
|
706
|
+
exports.BLANK_ROUTE_DATA = new RouteData();
|
707
|
+
var Instruction = (function() {
|
708
|
+
function Instruction(component, child, auxInstruction) {
|
709
|
+
this.component = component;
|
710
|
+
this.child = child;
|
711
|
+
this.auxInstruction = auxInstruction;
|
712
|
+
}
|
713
|
+
Object.defineProperty(Instruction.prototype, "urlPath", {
|
714
|
+
get: function() {
|
715
|
+
return lang_1.isPresent(this.component) ? this.component.urlPath : '';
|
716
|
+
},
|
717
|
+
enumerable: true,
|
718
|
+
configurable: true
|
719
|
+
});
|
720
|
+
Object.defineProperty(Instruction.prototype, "urlParams", {
|
721
|
+
get: function() {
|
722
|
+
return lang_1.isPresent(this.component) ? this.component.urlParams : [];
|
723
|
+
},
|
724
|
+
enumerable: true,
|
725
|
+
configurable: true
|
726
|
+
});
|
727
|
+
Object.defineProperty(Instruction.prototype, "specificity", {
|
728
|
+
get: function() {
|
729
|
+
var total = '';
|
730
|
+
if (lang_1.isPresent(this.component)) {
|
731
|
+
total += this.component.specificity;
|
732
|
+
}
|
733
|
+
if (lang_1.isPresent(this.child)) {
|
734
|
+
total += this.child.specificity;
|
735
|
+
}
|
736
|
+
return total;
|
737
|
+
},
|
738
|
+
enumerable: true,
|
739
|
+
configurable: true
|
740
|
+
});
|
741
|
+
Instruction.prototype.toRootUrl = function() {
|
742
|
+
return this.toUrlPath() + this.toUrlQuery();
|
743
|
+
};
|
744
|
+
Instruction.prototype._toNonRootUrl = function() {
|
745
|
+
return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
|
746
|
+
};
|
747
|
+
Instruction.prototype.toUrlQuery = function() {
|
748
|
+
return this.urlParams.length > 0 ? ('?' + this.urlParams.join('&')) : '';
|
749
|
+
};
|
750
|
+
Instruction.prototype.replaceChild = function(child) {
|
751
|
+
return new ResolvedInstruction(this.component, child, this.auxInstruction);
|
752
|
+
};
|
753
|
+
Instruction.prototype.toUrlPath = function() {
|
754
|
+
return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toNonRootUrl() : '');
|
755
|
+
};
|
756
|
+
Instruction.prototype.toLinkUrl = function() {
|
757
|
+
return this.urlPath + this._stringifyAux() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '') + this.toUrlQuery();
|
758
|
+
};
|
759
|
+
Instruction.prototype._toLinkUrl = function() {
|
760
|
+
return this._stringifyPathMatrixAuxPrefixed() + (lang_1.isPresent(this.child) ? this.child._toLinkUrl() : '');
|
761
|
+
};
|
762
|
+
Instruction.prototype._stringifyPathMatrixAuxPrefixed = function() {
|
763
|
+
var primary = this._stringifyPathMatrixAux();
|
764
|
+
if (primary.length > 0) {
|
765
|
+
primary = '/' + primary;
|
766
|
+
}
|
767
|
+
return primary;
|
768
|
+
};
|
769
|
+
Instruction.prototype._stringifyMatrixParams = function() {
|
770
|
+
return this.urlParams.length > 0 ? (';' + this.urlParams.join(';')) : '';
|
771
|
+
};
|
772
|
+
Instruction.prototype._stringifyPathMatrixAux = function() {
|
773
|
+
if (lang_1.isBlank(this.component)) {
|
774
|
+
return '';
|
775
|
+
}
|
776
|
+
return this.urlPath + this._stringifyMatrixParams() + this._stringifyAux();
|
777
|
+
};
|
778
|
+
Instruction.prototype._stringifyAux = function() {
|
779
|
+
var routes = [];
|
780
|
+
collection_1.StringMapWrapper.forEach(this.auxInstruction, function(auxInstruction, _) {
|
781
|
+
routes.push(auxInstruction._stringifyPathMatrixAux());
|
782
|
+
});
|
783
|
+
if (routes.length > 0) {
|
784
|
+
return '(' + routes.join('//') + ')';
|
785
|
+
}
|
786
|
+
return '';
|
787
|
+
};
|
788
|
+
return Instruction;
|
789
|
+
}());
|
790
|
+
exports.Instruction = Instruction;
|
791
|
+
var ResolvedInstruction = (function(_super) {
|
792
|
+
__extends(ResolvedInstruction, _super);
|
793
|
+
function ResolvedInstruction(component, child, auxInstruction) {
|
794
|
+
_super.call(this, component, child, auxInstruction);
|
795
|
+
}
|
796
|
+
ResolvedInstruction.prototype.resolveComponent = function() {
|
797
|
+
return async_1.PromiseWrapper.resolve(this.component);
|
798
|
+
};
|
799
|
+
return ResolvedInstruction;
|
800
|
+
}(Instruction));
|
801
|
+
exports.ResolvedInstruction = ResolvedInstruction;
|
802
|
+
var DefaultInstruction = (function(_super) {
|
803
|
+
__extends(DefaultInstruction, _super);
|
804
|
+
function DefaultInstruction(component, child) {
|
805
|
+
_super.call(this, component, child, {});
|
806
|
+
}
|
807
|
+
DefaultInstruction.prototype.toLinkUrl = function() {
|
808
|
+
return '';
|
809
|
+
};
|
810
|
+
DefaultInstruction.prototype._toLinkUrl = function() {
|
811
|
+
return '';
|
812
|
+
};
|
813
|
+
return DefaultInstruction;
|
814
|
+
}(ResolvedInstruction));
|
815
|
+
exports.DefaultInstruction = DefaultInstruction;
|
816
|
+
var UnresolvedInstruction = (function(_super) {
|
817
|
+
__extends(UnresolvedInstruction, _super);
|
818
|
+
function UnresolvedInstruction(_resolver, _urlPath, _urlParams) {
|
819
|
+
if (_urlPath === void 0) {
|
820
|
+
_urlPath = '';
|
821
|
+
}
|
822
|
+
if (_urlParams === void 0) {
|
823
|
+
_urlParams = lang_1.CONST_EXPR([]);
|
824
|
+
}
|
825
|
+
_super.call(this, null, null, {});
|
826
|
+
this._resolver = _resolver;
|
827
|
+
this._urlPath = _urlPath;
|
828
|
+
this._urlParams = _urlParams;
|
829
|
+
}
|
830
|
+
Object.defineProperty(UnresolvedInstruction.prototype, "urlPath", {
|
831
|
+
get: function() {
|
832
|
+
if (lang_1.isPresent(this.component)) {
|
833
|
+
return this.component.urlPath;
|
834
|
+
}
|
835
|
+
if (lang_1.isPresent(this._urlPath)) {
|
836
|
+
return this._urlPath;
|
837
|
+
}
|
838
|
+
return '';
|
839
|
+
},
|
840
|
+
enumerable: true,
|
841
|
+
configurable: true
|
842
|
+
});
|
843
|
+
Object.defineProperty(UnresolvedInstruction.prototype, "urlParams", {
|
844
|
+
get: function() {
|
845
|
+
if (lang_1.isPresent(this.component)) {
|
846
|
+
return this.component.urlParams;
|
847
|
+
}
|
848
|
+
if (lang_1.isPresent(this._urlParams)) {
|
849
|
+
return this._urlParams;
|
850
|
+
}
|
851
|
+
return [];
|
852
|
+
},
|
853
|
+
enumerable: true,
|
854
|
+
configurable: true
|
855
|
+
});
|
856
|
+
UnresolvedInstruction.prototype.resolveComponent = function() {
|
857
|
+
var _this = this;
|
858
|
+
if (lang_1.isPresent(this.component)) {
|
859
|
+
return async_1.PromiseWrapper.resolve(this.component);
|
860
|
+
}
|
861
|
+
return this._resolver().then(function(instruction) {
|
862
|
+
_this.child = lang_1.isPresent(instruction) ? instruction.child : null;
|
863
|
+
return _this.component = lang_1.isPresent(instruction) ? instruction.component : null;
|
864
|
+
});
|
865
|
+
};
|
866
|
+
return UnresolvedInstruction;
|
867
|
+
}(Instruction));
|
868
|
+
exports.UnresolvedInstruction = UnresolvedInstruction;
|
869
|
+
var RedirectInstruction = (function(_super) {
|
870
|
+
__extends(RedirectInstruction, _super);
|
871
|
+
function RedirectInstruction(component, child, auxInstruction, _specificity) {
|
872
|
+
_super.call(this, component, child, auxInstruction);
|
873
|
+
this._specificity = _specificity;
|
874
|
+
}
|
875
|
+
Object.defineProperty(RedirectInstruction.prototype, "specificity", {
|
876
|
+
get: function() {
|
877
|
+
return this._specificity;
|
878
|
+
},
|
879
|
+
enumerable: true,
|
880
|
+
configurable: true
|
881
|
+
});
|
882
|
+
return RedirectInstruction;
|
883
|
+
}(ResolvedInstruction));
|
884
|
+
exports.RedirectInstruction = RedirectInstruction;
|
885
|
+
var ComponentInstruction = (function() {
|
886
|
+
function ComponentInstruction(urlPath, urlParams, data, componentType, terminal, specificity, params, routeName) {
|
887
|
+
if (params === void 0) {
|
888
|
+
params = null;
|
889
|
+
}
|
890
|
+
this.urlPath = urlPath;
|
891
|
+
this.urlParams = urlParams;
|
892
|
+
this.componentType = componentType;
|
893
|
+
this.terminal = terminal;
|
894
|
+
this.specificity = specificity;
|
895
|
+
this.params = params;
|
896
|
+
this.routeName = routeName;
|
897
|
+
this.reuse = false;
|
898
|
+
this.routeData = lang_1.isPresent(data) ? data : exports.BLANK_ROUTE_DATA;
|
899
|
+
}
|
900
|
+
return ComponentInstruction;
|
901
|
+
}());
|
902
|
+
exports.ComponentInstruction = ComponentInstruction;
|
903
|
+
global.define = __define;
|
904
|
+
return module.exports;
|
905
|
+
});
|
906
|
+
|
907
|
+
System.register("angular2/src/router/rules/route_handlers/async_route_handler", ["angular2/src/facade/lang", "angular2/src/router/instruction"], true, function(require, exports, module) {
|
908
|
+
var global = System.global,
|
909
|
+
__define = global.define;
|
910
|
+
global.define = undefined;
|
911
|
+
"use strict";
|
912
|
+
var lang_1 = require("angular2/src/facade/lang");
|
913
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
914
|
+
var AsyncRouteHandler = (function() {
|
915
|
+
function AsyncRouteHandler(_loader, data) {
|
916
|
+
if (data === void 0) {
|
917
|
+
data = null;
|
918
|
+
}
|
919
|
+
this._loader = _loader;
|
920
|
+
this._resolvedComponent = null;
|
921
|
+
this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
|
922
|
+
}
|
923
|
+
AsyncRouteHandler.prototype.resolveComponentType = function() {
|
924
|
+
var _this = this;
|
925
|
+
if (lang_1.isPresent(this._resolvedComponent)) {
|
926
|
+
return this._resolvedComponent;
|
927
|
+
}
|
928
|
+
return this._resolvedComponent = this._loader().then(function(componentType) {
|
929
|
+
_this.componentType = componentType;
|
930
|
+
return componentType;
|
931
|
+
});
|
932
|
+
};
|
933
|
+
return AsyncRouteHandler;
|
934
|
+
}());
|
935
|
+
exports.AsyncRouteHandler = AsyncRouteHandler;
|
936
|
+
global.define = __define;
|
937
|
+
return module.exports;
|
938
|
+
});
|
939
|
+
|
940
|
+
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) {
|
941
|
+
var global = System.global,
|
942
|
+
__define = global.define;
|
943
|
+
global.define = undefined;
|
944
|
+
"use strict";
|
945
|
+
var async_1 = require("angular2/src/facade/async");
|
946
|
+
var lang_1 = require("angular2/src/facade/lang");
|
947
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
948
|
+
var SyncRouteHandler = (function() {
|
949
|
+
function SyncRouteHandler(componentType, data) {
|
950
|
+
this.componentType = componentType;
|
951
|
+
this._resolvedComponent = null;
|
952
|
+
this._resolvedComponent = async_1.PromiseWrapper.resolve(componentType);
|
953
|
+
this.data = lang_1.isPresent(data) ? new instruction_1.RouteData(data) : instruction_1.BLANK_ROUTE_DATA;
|
954
|
+
}
|
955
|
+
SyncRouteHandler.prototype.resolveComponentType = function() {
|
956
|
+
return this._resolvedComponent;
|
957
|
+
};
|
958
|
+
return SyncRouteHandler;
|
959
|
+
}());
|
960
|
+
exports.SyncRouteHandler = SyncRouteHandler;
|
961
|
+
global.define = __define;
|
962
|
+
return module.exports;
|
963
|
+
});
|
964
|
+
|
965
|
+
System.register("angular2/src/router/utils", ["angular2/src/facade/lang", "angular2/src/facade/collection"], true, function(require, exports, module) {
|
966
|
+
var global = System.global,
|
967
|
+
__define = global.define;
|
968
|
+
global.define = undefined;
|
969
|
+
"use strict";
|
970
|
+
var lang_1 = require("angular2/src/facade/lang");
|
971
|
+
var collection_1 = require("angular2/src/facade/collection");
|
972
|
+
var TouchMap = (function() {
|
973
|
+
function TouchMap(map) {
|
974
|
+
var _this = this;
|
975
|
+
this.map = {};
|
976
|
+
this.keys = {};
|
977
|
+
if (lang_1.isPresent(map)) {
|
978
|
+
collection_1.StringMapWrapper.forEach(map, function(value, key) {
|
979
|
+
_this.map[key] = lang_1.isPresent(value) ? value.toString() : null;
|
980
|
+
_this.keys[key] = true;
|
981
|
+
});
|
982
|
+
}
|
983
|
+
}
|
984
|
+
TouchMap.prototype.get = function(key) {
|
985
|
+
collection_1.StringMapWrapper.delete(this.keys, key);
|
986
|
+
return this.map[key];
|
987
|
+
};
|
988
|
+
TouchMap.prototype.getUnused = function() {
|
989
|
+
var _this = this;
|
990
|
+
var unused = {};
|
991
|
+
var keys = collection_1.StringMapWrapper.keys(this.keys);
|
992
|
+
keys.forEach(function(key) {
|
993
|
+
return unused[key] = collection_1.StringMapWrapper.get(_this.map, key);
|
994
|
+
});
|
995
|
+
return unused;
|
996
|
+
};
|
997
|
+
return TouchMap;
|
998
|
+
}());
|
999
|
+
exports.TouchMap = TouchMap;
|
1000
|
+
function normalizeString(obj) {
|
1001
|
+
if (lang_1.isBlank(obj)) {
|
1002
|
+
return null;
|
1003
|
+
} else {
|
1004
|
+
return obj.toString();
|
1005
|
+
}
|
1006
|
+
}
|
1007
|
+
exports.normalizeString = normalizeString;
|
1008
|
+
global.define = __define;
|
1009
|
+
return module.exports;
|
1010
|
+
});
|
1011
|
+
|
1012
|
+
System.register("angular2/src/router/rules/route_paths/route_path", [], true, function(require, exports, module) {
|
1013
|
+
var global = System.global,
|
1014
|
+
__define = global.define;
|
1015
|
+
global.define = undefined;
|
1016
|
+
"use strict";
|
1017
|
+
var MatchedUrl = (function() {
|
1018
|
+
function MatchedUrl(urlPath, urlParams, allParams, auxiliary, rest) {
|
1019
|
+
this.urlPath = urlPath;
|
1020
|
+
this.urlParams = urlParams;
|
1021
|
+
this.allParams = allParams;
|
1022
|
+
this.auxiliary = auxiliary;
|
1023
|
+
this.rest = rest;
|
1024
|
+
}
|
1025
|
+
return MatchedUrl;
|
1026
|
+
}());
|
1027
|
+
exports.MatchedUrl = MatchedUrl;
|
1028
|
+
var GeneratedUrl = (function() {
|
1029
|
+
function GeneratedUrl(urlPath, urlParams) {
|
1030
|
+
this.urlPath = urlPath;
|
1031
|
+
this.urlParams = urlParams;
|
1032
|
+
}
|
1033
|
+
return GeneratedUrl;
|
1034
|
+
}());
|
1035
|
+
exports.GeneratedUrl = GeneratedUrl;
|
1036
|
+
global.define = __define;
|
1037
|
+
return module.exports;
|
1038
|
+
});
|
1039
|
+
|
1040
|
+
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) {
|
1041
|
+
var global = System.global,
|
1042
|
+
__define = global.define;
|
1043
|
+
global.define = undefined;
|
1044
|
+
"use strict";
|
1045
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1046
|
+
var route_path_1 = require("angular2/src/router/rules/route_paths/route_path");
|
1047
|
+
var RegexRoutePath = (function() {
|
1048
|
+
function RegexRoutePath(_reString, _serializer) {
|
1049
|
+
this._reString = _reString;
|
1050
|
+
this._serializer = _serializer;
|
1051
|
+
this.terminal = true;
|
1052
|
+
this.specificity = '2';
|
1053
|
+
this.hash = this._reString;
|
1054
|
+
this._regex = lang_1.RegExpWrapper.create(this._reString);
|
1055
|
+
}
|
1056
|
+
RegexRoutePath.prototype.matchUrl = function(url) {
|
1057
|
+
var urlPath = url.toString();
|
1058
|
+
var params = {};
|
1059
|
+
var matcher = lang_1.RegExpWrapper.matcher(this._regex, urlPath);
|
1060
|
+
var match = lang_1.RegExpMatcherWrapper.next(matcher);
|
1061
|
+
if (lang_1.isBlank(match)) {
|
1062
|
+
return null;
|
1063
|
+
}
|
1064
|
+
for (var i = 0; i < match.length; i += 1) {
|
1065
|
+
params[i.toString()] = match[i];
|
1066
|
+
}
|
1067
|
+
return new route_path_1.MatchedUrl(urlPath, [], params, [], null);
|
1068
|
+
};
|
1069
|
+
RegexRoutePath.prototype.generateUrl = function(params) {
|
1070
|
+
return this._serializer(params);
|
1071
|
+
};
|
1072
|
+
RegexRoutePath.prototype.toString = function() {
|
1073
|
+
return this._reString;
|
1074
|
+
};
|
1075
|
+
return RegexRoutePath;
|
1076
|
+
}());
|
1077
|
+
exports.RegexRoutePath = RegexRoutePath;
|
1078
|
+
global.define = __define;
|
1079
|
+
return module.exports;
|
1080
|
+
});
|
1081
|
+
|
1082
|
+
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) {
|
1083
|
+
var global = System.global,
|
1084
|
+
__define = global.define;
|
1085
|
+
global.define = undefined;
|
1086
|
+
"use strict";
|
1087
|
+
var route_config_impl_1 = require("angular2/src/router/route_config/route_config_impl");
|
1088
|
+
var decorators_1 = require("angular2/src/core/util/decorators");
|
1089
|
+
var route_config_impl_2 = require("angular2/src/router/route_config/route_config_impl");
|
1090
|
+
exports.Route = route_config_impl_2.Route;
|
1091
|
+
exports.Redirect = route_config_impl_2.Redirect;
|
1092
|
+
exports.AuxRoute = route_config_impl_2.AuxRoute;
|
1093
|
+
exports.AsyncRoute = route_config_impl_2.AsyncRoute;
|
1094
|
+
exports.RouteConfig = decorators_1.makeDecorator(route_config_impl_1.RouteConfig);
|
1095
|
+
global.define = __define;
|
1096
|
+
return module.exports;
|
1097
|
+
});
|
1098
|
+
|
1099
|
+
System.register("angular2/src/router/location/location_strategy", ["angular2/src/facade/lang", "angular2/core"], true, function(require, exports, module) {
|
1100
|
+
var global = System.global,
|
1101
|
+
__define = global.define;
|
1102
|
+
global.define = undefined;
|
1103
|
+
"use strict";
|
1104
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1105
|
+
var core_1 = require("angular2/core");
|
1106
|
+
var LocationStrategy = (function() {
|
1107
|
+
function LocationStrategy() {}
|
1108
|
+
return LocationStrategy;
|
1109
|
+
}());
|
1110
|
+
exports.LocationStrategy = LocationStrategy;
|
1111
|
+
exports.APP_BASE_HREF = lang_1.CONST_EXPR(new core_1.OpaqueToken('appBaseHref'));
|
1112
|
+
function normalizeQueryParams(params) {
|
1113
|
+
return (params.length > 0 && params.substring(0, 1) != '?') ? ('?' + params) : params;
|
1114
|
+
}
|
1115
|
+
exports.normalizeQueryParams = normalizeQueryParams;
|
1116
|
+
function joinWithSlash(start, end) {
|
1117
|
+
if (start.length == 0) {
|
1118
|
+
return end;
|
1119
|
+
}
|
1120
|
+
if (end.length == 0) {
|
1121
|
+
return start;
|
1122
|
+
}
|
1123
|
+
var slashes = 0;
|
1124
|
+
if (start.endsWith('/')) {
|
1125
|
+
slashes++;
|
1126
|
+
}
|
1127
|
+
if (end.startsWith('/')) {
|
1128
|
+
slashes++;
|
1129
|
+
}
|
1130
|
+
if (slashes == 2) {
|
1131
|
+
return start + end.substring(1);
|
1132
|
+
}
|
1133
|
+
if (slashes == 1) {
|
1134
|
+
return start + end;
|
1135
|
+
}
|
1136
|
+
return start + '/' + end;
|
1137
|
+
}
|
1138
|
+
exports.joinWithSlash = joinWithSlash;
|
1139
|
+
global.define = __define;
|
1140
|
+
return module.exports;
|
1141
|
+
});
|
1142
|
+
|
1143
|
+
System.register("angular2/src/router/lifecycle/lifecycle_annotations_impl", ["angular2/src/facade/lang"], true, function(require, exports, module) {
|
1144
|
+
var global = System.global,
|
1145
|
+
__define = global.define;
|
1146
|
+
global.define = undefined;
|
1147
|
+
"use strict";
|
1148
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
1149
|
+
var c = arguments.length,
|
1150
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
1151
|
+
d;
|
1152
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
1153
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
1154
|
+
else
|
1155
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
1156
|
+
if (d = decorators[i])
|
1157
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1158
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1159
|
+
};
|
1160
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
1161
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
1162
|
+
return Reflect.metadata(k, v);
|
1163
|
+
};
|
1164
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1165
|
+
var RouteLifecycleHook = (function() {
|
1166
|
+
function RouteLifecycleHook(name) {
|
1167
|
+
this.name = name;
|
1168
|
+
}
|
1169
|
+
RouteLifecycleHook = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [String])], RouteLifecycleHook);
|
1170
|
+
return RouteLifecycleHook;
|
1171
|
+
}());
|
1172
|
+
exports.RouteLifecycleHook = RouteLifecycleHook;
|
1173
|
+
var CanActivate = (function() {
|
1174
|
+
function CanActivate(fn) {
|
1175
|
+
this.fn = fn;
|
1176
|
+
}
|
1177
|
+
CanActivate = __decorate([lang_1.CONST(), __metadata('design:paramtypes', [Function])], CanActivate);
|
1178
|
+
return CanActivate;
|
1179
|
+
}());
|
1180
|
+
exports.CanActivate = CanActivate;
|
1181
|
+
exports.routerCanReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanReuse"));
|
1182
|
+
exports.routerCanDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerCanDeactivate"));
|
1183
|
+
exports.routerOnActivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnActivate"));
|
1184
|
+
exports.routerOnReuse = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnReuse"));
|
1185
|
+
exports.routerOnDeactivate = lang_1.CONST_EXPR(new RouteLifecycleHook("routerOnDeactivate"));
|
1186
|
+
global.define = __define;
|
1187
|
+
return module.exports;
|
1188
|
+
});
|
1189
|
+
|
1190
|
+
System.register("angular2/src/router/lifecycle/lifecycle_annotations", ["angular2/src/core/util/decorators", "angular2/src/router/lifecycle/lifecycle_annotations_impl", "angular2/src/router/lifecycle/lifecycle_annotations_impl"], true, function(require, exports, module) {
|
1191
|
+
var global = System.global,
|
1192
|
+
__define = global.define;
|
1193
|
+
global.define = undefined;
|
1194
|
+
"use strict";
|
1195
|
+
var decorators_1 = require("angular2/src/core/util/decorators");
|
1196
|
+
var lifecycle_annotations_impl_1 = require("angular2/src/router/lifecycle/lifecycle_annotations_impl");
|
1197
|
+
var lifecycle_annotations_impl_2 = require("angular2/src/router/lifecycle/lifecycle_annotations_impl");
|
1198
|
+
exports.routerCanReuse = lifecycle_annotations_impl_2.routerCanReuse;
|
1199
|
+
exports.routerCanDeactivate = lifecycle_annotations_impl_2.routerCanDeactivate;
|
1200
|
+
exports.routerOnActivate = lifecycle_annotations_impl_2.routerOnActivate;
|
1201
|
+
exports.routerOnReuse = lifecycle_annotations_impl_2.routerOnReuse;
|
1202
|
+
exports.routerOnDeactivate = lifecycle_annotations_impl_2.routerOnDeactivate;
|
1203
|
+
exports.CanActivate = decorators_1.makeDecorator(lifecycle_annotations_impl_1.CanActivate);
|
1204
|
+
global.define = __define;
|
1205
|
+
return module.exports;
|
1206
|
+
});
|
1207
|
+
|
1208
|
+
System.register("angular2/src/router/directives/router_link", ["angular2/core", "angular2/src/facade/lang", "angular2/src/router/router", "angular2/src/router/location/location"], true, function(require, exports, module) {
|
1209
|
+
var global = System.global,
|
1210
|
+
__define = global.define;
|
1211
|
+
global.define = undefined;
|
1212
|
+
"use strict";
|
1213
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
1214
|
+
var c = arguments.length,
|
1215
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
1216
|
+
d;
|
1217
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
1218
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
1219
|
+
else
|
1220
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
1221
|
+
if (d = decorators[i])
|
1222
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1223
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1224
|
+
};
|
1225
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
1226
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
1227
|
+
return Reflect.metadata(k, v);
|
1228
|
+
};
|
1229
|
+
var core_1 = require("angular2/core");
|
1230
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1231
|
+
var router_1 = require("angular2/src/router/router");
|
1232
|
+
var location_1 = require("angular2/src/router/location/location");
|
1233
|
+
var RouterLink = (function() {
|
1234
|
+
function RouterLink(_router, _location) {
|
1235
|
+
var _this = this;
|
1236
|
+
this._router = _router;
|
1237
|
+
this._location = _location;
|
1238
|
+
this._router.subscribe(function(_) {
|
1239
|
+
return _this._updateLink();
|
1240
|
+
});
|
1241
|
+
}
|
1242
|
+
RouterLink.prototype._updateLink = function() {
|
1243
|
+
this._navigationInstruction = this._router.generate(this._routeParams);
|
1244
|
+
var navigationHref = this._navigationInstruction.toLinkUrl();
|
1245
|
+
this.visibleHref = this._location.prepareExternalUrl(navigationHref);
|
1246
|
+
};
|
1247
|
+
Object.defineProperty(RouterLink.prototype, "isRouteActive", {
|
1248
|
+
get: function() {
|
1249
|
+
return this._router.isRouteActive(this._navigationInstruction);
|
1250
|
+
},
|
1251
|
+
enumerable: true,
|
1252
|
+
configurable: true
|
1253
|
+
});
|
1254
|
+
Object.defineProperty(RouterLink.prototype, "routeParams", {
|
1255
|
+
set: function(changes) {
|
1256
|
+
this._routeParams = changes;
|
1257
|
+
this._updateLink();
|
1258
|
+
},
|
1259
|
+
enumerable: true,
|
1260
|
+
configurable: true
|
1261
|
+
});
|
1262
|
+
RouterLink.prototype.onClick = function() {
|
1263
|
+
if (!lang_1.isString(this.target) || this.target == '_self') {
|
1264
|
+
this._router.navigateByInstruction(this._navigationInstruction);
|
1265
|
+
return false;
|
1266
|
+
}
|
1267
|
+
return true;
|
1268
|
+
};
|
1269
|
+
RouterLink = __decorate([core_1.Directive({
|
1270
|
+
selector: '[routerLink]',
|
1271
|
+
inputs: ['routeParams: routerLink', 'target: target'],
|
1272
|
+
host: {
|
1273
|
+
'(click)': 'onClick()',
|
1274
|
+
'[attr.href]': 'visibleHref',
|
1275
|
+
'[class.router-link-active]': 'isRouteActive'
|
1276
|
+
}
|
1277
|
+
}), __metadata('design:paramtypes', [router_1.Router, location_1.Location])], RouterLink);
|
1278
|
+
return RouterLink;
|
1279
|
+
}());
|
1280
|
+
exports.RouterLink = RouterLink;
|
1281
|
+
global.define = __define;
|
1282
|
+
return module.exports;
|
1283
|
+
});
|
1284
|
+
|
1285
|
+
System.register("angular2/src/router/location/platform_location", [], true, function(require, exports, module) {
|
1286
|
+
var global = System.global,
|
1287
|
+
__define = global.define;
|
1288
|
+
global.define = undefined;
|
1289
|
+
"use strict";
|
1290
|
+
var PlatformLocation = (function() {
|
1291
|
+
function PlatformLocation() {}
|
1292
|
+
Object.defineProperty(PlatformLocation.prototype, "pathname", {
|
1293
|
+
get: function() {
|
1294
|
+
return null;
|
1295
|
+
},
|
1296
|
+
enumerable: true,
|
1297
|
+
configurable: true
|
1298
|
+
});
|
1299
|
+
Object.defineProperty(PlatformLocation.prototype, "search", {
|
1300
|
+
get: function() {
|
1301
|
+
return null;
|
1302
|
+
},
|
1303
|
+
enumerable: true,
|
1304
|
+
configurable: true
|
1305
|
+
});
|
1306
|
+
Object.defineProperty(PlatformLocation.prototype, "hash", {
|
1307
|
+
get: function() {
|
1308
|
+
return null;
|
1309
|
+
},
|
1310
|
+
enumerable: true,
|
1311
|
+
configurable: true
|
1312
|
+
});
|
1313
|
+
return PlatformLocation;
|
1314
|
+
}());
|
1315
|
+
exports.PlatformLocation = PlatformLocation;
|
1316
|
+
global.define = __define;
|
1317
|
+
return module.exports;
|
1318
|
+
});
|
1319
|
+
|
1320
|
+
System.register("angular2/src/router/location/hash_location_strategy", ["angular2/core", "angular2/src/router/location/location_strategy", "angular2/src/facade/lang", "angular2/src/router/location/platform_location"], true, function(require, exports, module) {
|
1321
|
+
var global = System.global,
|
1322
|
+
__define = global.define;
|
1323
|
+
global.define = undefined;
|
1324
|
+
"use strict";
|
1325
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
1326
|
+
for (var p in b)
|
1327
|
+
if (b.hasOwnProperty(p))
|
1328
|
+
d[p] = b[p];
|
1329
|
+
function __() {
|
1330
|
+
this.constructor = d;
|
1331
|
+
}
|
1332
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1333
|
+
};
|
1334
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
1335
|
+
var c = arguments.length,
|
1336
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
1337
|
+
d;
|
1338
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
1339
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
1340
|
+
else
|
1341
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
1342
|
+
if (d = decorators[i])
|
1343
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1344
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1345
|
+
};
|
1346
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
1347
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
1348
|
+
return Reflect.metadata(k, v);
|
1349
|
+
};
|
1350
|
+
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
1351
|
+
return function(target, key) {
|
1352
|
+
decorator(target, key, paramIndex);
|
1353
|
+
};
|
1354
|
+
};
|
1355
|
+
var core_1 = require("angular2/core");
|
1356
|
+
var location_strategy_1 = require("angular2/src/router/location/location_strategy");
|
1357
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1358
|
+
var platform_location_1 = require("angular2/src/router/location/platform_location");
|
1359
|
+
var HashLocationStrategy = (function(_super) {
|
1360
|
+
__extends(HashLocationStrategy, _super);
|
1361
|
+
function HashLocationStrategy(_platformLocation, _baseHref) {
|
1362
|
+
_super.call(this);
|
1363
|
+
this._platformLocation = _platformLocation;
|
1364
|
+
this._baseHref = '';
|
1365
|
+
if (lang_1.isPresent(_baseHref)) {
|
1366
|
+
this._baseHref = _baseHref;
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
HashLocationStrategy.prototype.onPopState = function(fn) {
|
1370
|
+
this._platformLocation.onPopState(fn);
|
1371
|
+
this._platformLocation.onHashChange(fn);
|
1372
|
+
};
|
1373
|
+
HashLocationStrategy.prototype.getBaseHref = function() {
|
1374
|
+
return this._baseHref;
|
1375
|
+
};
|
1376
|
+
HashLocationStrategy.prototype.path = function() {
|
1377
|
+
var path = this._platformLocation.hash;
|
1378
|
+
if (!lang_1.isPresent(path))
|
1379
|
+
path = '#';
|
1380
|
+
return (path.length > 0 ? path.substring(1) : path);
|
1381
|
+
};
|
1382
|
+
HashLocationStrategy.prototype.prepareExternalUrl = function(internal) {
|
1383
|
+
var url = location_strategy_1.joinWithSlash(this._baseHref, internal);
|
1384
|
+
return url.length > 0 ? ('#' + url) : url;
|
1385
|
+
};
|
1386
|
+
HashLocationStrategy.prototype.pushState = function(state, title, path, queryParams) {
|
1387
|
+
var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
|
1388
|
+
if (url.length == 0) {
|
1389
|
+
url = this._platformLocation.pathname;
|
1390
|
+
}
|
1391
|
+
this._platformLocation.pushState(state, title, url);
|
1392
|
+
};
|
1393
|
+
HashLocationStrategy.prototype.replaceState = function(state, title, path, queryParams) {
|
1394
|
+
var url = this.prepareExternalUrl(path + location_strategy_1.normalizeQueryParams(queryParams));
|
1395
|
+
if (url.length == 0) {
|
1396
|
+
url = this._platformLocation.pathname;
|
1397
|
+
}
|
1398
|
+
this._platformLocation.replaceState(state, title, url);
|
1399
|
+
};
|
1400
|
+
HashLocationStrategy.prototype.forward = function() {
|
1401
|
+
this._platformLocation.forward();
|
1402
|
+
};
|
1403
|
+
HashLocationStrategy.prototype.back = function() {
|
1404
|
+
this._platformLocation.back();
|
1405
|
+
};
|
1406
|
+
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);
|
1407
|
+
return HashLocationStrategy;
|
1408
|
+
}(location_strategy_1.LocationStrategy));
|
1409
|
+
exports.HashLocationStrategy = HashLocationStrategy;
|
1410
|
+
global.define = __define;
|
1411
|
+
return module.exports;
|
1412
|
+
});
|
1413
|
+
|
1414
|
+
System.register("angular2/src/router/location/path_location_strategy", ["angular2/core", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/router/location/location_strategy", "angular2/src/router/location/platform_location"], true, function(require, exports, module) {
|
1415
|
+
var global = System.global,
|
1416
|
+
__define = global.define;
|
1417
|
+
global.define = undefined;
|
1418
|
+
"use strict";
|
1419
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
1420
|
+
for (var p in b)
|
1421
|
+
if (b.hasOwnProperty(p))
|
1422
|
+
d[p] = b[p];
|
1423
|
+
function __() {
|
1424
|
+
this.constructor = d;
|
1425
|
+
}
|
1426
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1427
|
+
};
|
1428
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
1429
|
+
var c = arguments.length,
|
1430
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
1431
|
+
d;
|
1432
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
1433
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
1434
|
+
else
|
1435
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
1436
|
+
if (d = decorators[i])
|
1437
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
1438
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
1439
|
+
};
|
1440
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
1441
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
1442
|
+
return Reflect.metadata(k, v);
|
1443
|
+
};
|
1444
|
+
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
1445
|
+
return function(target, key) {
|
1446
|
+
decorator(target, key, paramIndex);
|
1447
|
+
};
|
1448
|
+
};
|
1449
|
+
var core_1 = require("angular2/core");
|
1450
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1451
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
1452
|
+
var location_strategy_1 = require("angular2/src/router/location/location_strategy");
|
1453
|
+
var platform_location_1 = require("angular2/src/router/location/platform_location");
|
1454
|
+
var PathLocationStrategy = (function(_super) {
|
1455
|
+
__extends(PathLocationStrategy, _super);
|
1456
|
+
function PathLocationStrategy(_platformLocation, href) {
|
1457
|
+
_super.call(this);
|
1458
|
+
this._platformLocation = _platformLocation;
|
1459
|
+
if (lang_1.isBlank(href)) {
|
1460
|
+
href = this._platformLocation.getBaseHrefFromDOM();
|
1461
|
+
}
|
1462
|
+
if (lang_1.isBlank(href)) {
|
1463
|
+
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.");
|
1464
|
+
}
|
1465
|
+
this._baseHref = href;
|
1466
|
+
}
|
1467
|
+
PathLocationStrategy.prototype.onPopState = function(fn) {
|
1468
|
+
this._platformLocation.onPopState(fn);
|
1469
|
+
this._platformLocation.onHashChange(fn);
|
1470
|
+
};
|
1471
|
+
PathLocationStrategy.prototype.getBaseHref = function() {
|
1472
|
+
return this._baseHref;
|
1473
|
+
};
|
1474
|
+
PathLocationStrategy.prototype.prepareExternalUrl = function(internal) {
|
1475
|
+
return location_strategy_1.joinWithSlash(this._baseHref, internal);
|
1476
|
+
};
|
1477
|
+
PathLocationStrategy.prototype.path = function() {
|
1478
|
+
return this._platformLocation.pathname + location_strategy_1.normalizeQueryParams(this._platformLocation.search);
|
1479
|
+
};
|
1480
|
+
PathLocationStrategy.prototype.pushState = function(state, title, url, queryParams) {
|
1481
|
+
var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
|
1482
|
+
this._platformLocation.pushState(state, title, externalUrl);
|
1483
|
+
};
|
1484
|
+
PathLocationStrategy.prototype.replaceState = function(state, title, url, queryParams) {
|
1485
|
+
var externalUrl = this.prepareExternalUrl(url + location_strategy_1.normalizeQueryParams(queryParams));
|
1486
|
+
this._platformLocation.replaceState(state, title, externalUrl);
|
1487
|
+
};
|
1488
|
+
PathLocationStrategy.prototype.forward = function() {
|
1489
|
+
this._platformLocation.forward();
|
1490
|
+
};
|
1491
|
+
PathLocationStrategy.prototype.back = function() {
|
1492
|
+
this._platformLocation.back();
|
1493
|
+
};
|
1494
|
+
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);
|
1495
|
+
return PathLocationStrategy;
|
1496
|
+
}(location_strategy_1.LocationStrategy));
|
1497
|
+
exports.PathLocationStrategy = PathLocationStrategy;
|
1498
|
+
global.define = __define;
|
1499
|
+
return module.exports;
|
1500
|
+
});
|
1501
|
+
|
1502
|
+
System.register("angular2/src/router/router_providers_common", ["angular2/src/router/location/location_strategy", "angular2/src/router/location/path_location_strategy", "angular2/src/router/router", "angular2/src/router/route_registry", "angular2/src/router/location/location", "angular2/src/facade/lang", "angular2/core", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
|
1503
|
+
var global = System.global,
|
1504
|
+
__define = global.define;
|
1505
|
+
global.define = undefined;
|
1506
|
+
"use strict";
|
1507
|
+
var location_strategy_1 = require("angular2/src/router/location/location_strategy");
|
1508
|
+
var path_location_strategy_1 = require("angular2/src/router/location/path_location_strategy");
|
1509
|
+
var router_1 = require("angular2/src/router/router");
|
1510
|
+
var route_registry_1 = require("angular2/src/router/route_registry");
|
1511
|
+
var location_1 = require("angular2/src/router/location/location");
|
1512
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1513
|
+
var core_1 = require("angular2/core");
|
1514
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
1515
|
+
exports.ROUTER_PROVIDERS_COMMON = lang_1.CONST_EXPR([route_registry_1.RouteRegistry, lang_1.CONST_EXPR(new core_1.Provider(location_strategy_1.LocationStrategy, {useClass: path_location_strategy_1.PathLocationStrategy})), location_1.Location, lang_1.CONST_EXPR(new core_1.Provider(router_1.Router, {
|
1516
|
+
useFactory: routerFactory,
|
1517
|
+
deps: lang_1.CONST_EXPR([route_registry_1.RouteRegistry, location_1.Location, route_registry_1.ROUTER_PRIMARY_COMPONENT, core_1.ApplicationRef])
|
1518
|
+
})), lang_1.CONST_EXPR(new core_1.Provider(route_registry_1.ROUTER_PRIMARY_COMPONENT, {
|
1519
|
+
useFactory: routerPrimaryComponentFactory,
|
1520
|
+
deps: lang_1.CONST_EXPR([core_1.ApplicationRef])
|
1521
|
+
}))]);
|
1522
|
+
function routerFactory(registry, location, primaryComponent, appRef) {
|
1523
|
+
var rootRouter = new router_1.RootRouter(registry, location, primaryComponent);
|
1524
|
+
appRef.registerDisposeListener(function() {
|
1525
|
+
return rootRouter.dispose();
|
1526
|
+
});
|
1527
|
+
return rootRouter;
|
1528
|
+
}
|
1529
|
+
function routerPrimaryComponentFactory(app) {
|
1530
|
+
if (app.componentTypes.length == 0) {
|
1531
|
+
throw new exceptions_1.BaseException("Bootstrap at least one component before injecting Router.");
|
1532
|
+
}
|
1533
|
+
return app.componentTypes[0];
|
1534
|
+
}
|
1535
|
+
global.define = __define;
|
1536
|
+
return module.exports;
|
1537
|
+
});
|
1538
|
+
|
1539
|
+
System.register("angular2/src/router/rules/rules", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/promise", "angular2/src/facade/collection", "angular2/src/router/url_parser", "angular2/src/router/instruction"], true, function(require, exports, module) {
|
1540
|
+
var global = System.global,
|
1541
|
+
__define = global.define;
|
1542
|
+
global.define = undefined;
|
1543
|
+
"use strict";
|
1544
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
1545
|
+
for (var p in b)
|
1546
|
+
if (b.hasOwnProperty(p))
|
1547
|
+
d[p] = b[p];
|
1548
|
+
function __() {
|
1549
|
+
this.constructor = d;
|
1550
|
+
}
|
1551
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
1552
|
+
};
|
1553
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1554
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
1555
|
+
var promise_1 = require("angular2/src/facade/promise");
|
1556
|
+
var collection_1 = require("angular2/src/facade/collection");
|
1557
|
+
var url_parser_1 = require("angular2/src/router/url_parser");
|
1558
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
1559
|
+
var RouteMatch = (function() {
|
1560
|
+
function RouteMatch() {}
|
1561
|
+
return RouteMatch;
|
1562
|
+
}());
|
1563
|
+
exports.RouteMatch = RouteMatch;
|
1564
|
+
var PathMatch = (function(_super) {
|
1565
|
+
__extends(PathMatch, _super);
|
1566
|
+
function PathMatch(instruction, remaining, remainingAux) {
|
1567
|
+
_super.call(this);
|
1568
|
+
this.instruction = instruction;
|
1569
|
+
this.remaining = remaining;
|
1570
|
+
this.remainingAux = remainingAux;
|
1571
|
+
}
|
1572
|
+
return PathMatch;
|
1573
|
+
}(RouteMatch));
|
1574
|
+
exports.PathMatch = PathMatch;
|
1575
|
+
var RedirectMatch = (function(_super) {
|
1576
|
+
__extends(RedirectMatch, _super);
|
1577
|
+
function RedirectMatch(redirectTo, specificity) {
|
1578
|
+
_super.call(this);
|
1579
|
+
this.redirectTo = redirectTo;
|
1580
|
+
this.specificity = specificity;
|
1581
|
+
}
|
1582
|
+
return RedirectMatch;
|
1583
|
+
}(RouteMatch));
|
1584
|
+
exports.RedirectMatch = RedirectMatch;
|
1585
|
+
var RedirectRule = (function() {
|
1586
|
+
function RedirectRule(_pathRecognizer, redirectTo) {
|
1587
|
+
this._pathRecognizer = _pathRecognizer;
|
1588
|
+
this.redirectTo = redirectTo;
|
1589
|
+
this.hash = this._pathRecognizer.hash;
|
1590
|
+
}
|
1591
|
+
Object.defineProperty(RedirectRule.prototype, "path", {
|
1592
|
+
get: function() {
|
1593
|
+
return this._pathRecognizer.toString();
|
1594
|
+
},
|
1595
|
+
set: function(val) {
|
1596
|
+
throw new exceptions_1.BaseException('you cannot set the path of a RedirectRule directly');
|
1597
|
+
},
|
1598
|
+
enumerable: true,
|
1599
|
+
configurable: true
|
1600
|
+
});
|
1601
|
+
RedirectRule.prototype.recognize = function(beginningSegment) {
|
1602
|
+
var match = null;
|
1603
|
+
if (lang_1.isPresent(this._pathRecognizer.matchUrl(beginningSegment))) {
|
1604
|
+
match = new RedirectMatch(this.redirectTo, this._pathRecognizer.specificity);
|
1605
|
+
}
|
1606
|
+
return promise_1.PromiseWrapper.resolve(match);
|
1607
|
+
};
|
1608
|
+
RedirectRule.prototype.generate = function(params) {
|
1609
|
+
throw new exceptions_1.BaseException("Tried to generate a redirect.");
|
1610
|
+
};
|
1611
|
+
return RedirectRule;
|
1612
|
+
}());
|
1613
|
+
exports.RedirectRule = RedirectRule;
|
1614
|
+
var RouteRule = (function() {
|
1615
|
+
function RouteRule(_routePath, handler, _routeName) {
|
1616
|
+
this._routePath = _routePath;
|
1617
|
+
this.handler = handler;
|
1618
|
+
this._routeName = _routeName;
|
1619
|
+
this._cache = new collection_1.Map();
|
1620
|
+
this.specificity = this._routePath.specificity;
|
1621
|
+
this.hash = this._routePath.hash;
|
1622
|
+
this.terminal = this._routePath.terminal;
|
1623
|
+
}
|
1624
|
+
Object.defineProperty(RouteRule.prototype, "path", {
|
1625
|
+
get: function() {
|
1626
|
+
return this._routePath.toString();
|
1627
|
+
},
|
1628
|
+
set: function(val) {
|
1629
|
+
throw new exceptions_1.BaseException('you cannot set the path of a RouteRule directly');
|
1630
|
+
},
|
1631
|
+
enumerable: true,
|
1632
|
+
configurable: true
|
1633
|
+
});
|
1634
|
+
RouteRule.prototype.recognize = function(beginningSegment) {
|
1635
|
+
var _this = this;
|
1636
|
+
var res = this._routePath.matchUrl(beginningSegment);
|
1637
|
+
if (lang_1.isBlank(res)) {
|
1638
|
+
return null;
|
1639
|
+
}
|
1640
|
+
return this.handler.resolveComponentType().then(function(_) {
|
1641
|
+
var componentInstruction = _this._getInstruction(res.urlPath, res.urlParams, res.allParams);
|
1642
|
+
return new PathMatch(componentInstruction, res.rest, res.auxiliary);
|
1643
|
+
});
|
1644
|
+
};
|
1645
|
+
RouteRule.prototype.generate = function(params) {
|
1646
|
+
var generated = this._routePath.generateUrl(params);
|
1647
|
+
var urlPath = generated.urlPath;
|
1648
|
+
var urlParams = generated.urlParams;
|
1649
|
+
return this._getInstruction(urlPath, url_parser_1.convertUrlParamsToArray(urlParams), params);
|
1650
|
+
};
|
1651
|
+
RouteRule.prototype.generateComponentPathValues = function(params) {
|
1652
|
+
return this._routePath.generateUrl(params);
|
1653
|
+
};
|
1654
|
+
RouteRule.prototype._getInstruction = function(urlPath, urlParams, params) {
|
1655
|
+
if (lang_1.isBlank(this.handler.componentType)) {
|
1656
|
+
throw new exceptions_1.BaseException("Tried to get instruction before the type was loaded.");
|
1657
|
+
}
|
1658
|
+
var hashKey = urlPath + '?' + urlParams.join('&');
|
1659
|
+
if (this._cache.has(hashKey)) {
|
1660
|
+
return this._cache.get(hashKey);
|
1661
|
+
}
|
1662
|
+
var instruction = new instruction_1.ComponentInstruction(urlPath, urlParams, this.handler.data, this.handler.componentType, this.terminal, this.specificity, params, this._routeName);
|
1663
|
+
this._cache.set(hashKey, instruction);
|
1664
|
+
return instruction;
|
1665
|
+
};
|
1666
|
+
return RouteRule;
|
1667
|
+
}());
|
1668
|
+
exports.RouteRule = RouteRule;
|
1669
|
+
global.define = __define;
|
1670
|
+
return module.exports;
|
1671
|
+
});
|
1672
|
+
|
1673
|
+
System.register("angular2/src/router/rules/route_paths/param_route_path", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/router/utils", "angular2/src/router/url_parser", "angular2/src/router/rules/route_paths/route_path"], true, function(require, exports, module) {
|
1674
|
+
var global = System.global,
|
1675
|
+
__define = global.define;
|
1676
|
+
global.define = undefined;
|
1677
|
+
"use strict";
|
1678
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1679
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
1680
|
+
var collection_1 = require("angular2/src/facade/collection");
|
1681
|
+
var utils_1 = require("angular2/src/router/utils");
|
1682
|
+
var url_parser_1 = require("angular2/src/router/url_parser");
|
1683
|
+
var route_path_1 = require("angular2/src/router/rules/route_paths/route_path");
|
1684
|
+
var ContinuationPathSegment = (function() {
|
1685
|
+
function ContinuationPathSegment() {
|
1686
|
+
this.name = '';
|
1687
|
+
this.specificity = '';
|
1688
|
+
this.hash = '...';
|
1689
|
+
}
|
1690
|
+
ContinuationPathSegment.prototype.generate = function(params) {
|
1691
|
+
return '';
|
1692
|
+
};
|
1693
|
+
ContinuationPathSegment.prototype.match = function(path) {
|
1694
|
+
return true;
|
1695
|
+
};
|
1696
|
+
return ContinuationPathSegment;
|
1697
|
+
}());
|
1698
|
+
var StaticPathSegment = (function() {
|
1699
|
+
function StaticPathSegment(path) {
|
1700
|
+
this.path = path;
|
1701
|
+
this.name = '';
|
1702
|
+
this.specificity = '2';
|
1703
|
+
this.hash = path;
|
1704
|
+
}
|
1705
|
+
StaticPathSegment.prototype.match = function(path) {
|
1706
|
+
return path == this.path;
|
1707
|
+
};
|
1708
|
+
StaticPathSegment.prototype.generate = function(params) {
|
1709
|
+
return this.path;
|
1710
|
+
};
|
1711
|
+
return StaticPathSegment;
|
1712
|
+
}());
|
1713
|
+
var DynamicPathSegment = (function() {
|
1714
|
+
function DynamicPathSegment(name) {
|
1715
|
+
this.name = name;
|
1716
|
+
this.specificity = '1';
|
1717
|
+
this.hash = ':';
|
1718
|
+
}
|
1719
|
+
DynamicPathSegment.prototype.match = function(path) {
|
1720
|
+
return path.length > 0;
|
1721
|
+
};
|
1722
|
+
DynamicPathSegment.prototype.generate = function(params) {
|
1723
|
+
if (!collection_1.StringMapWrapper.contains(params.map, this.name)) {
|
1724
|
+
throw new exceptions_1.BaseException("Route generator for '" + this.name + "' was not included in parameters passed.");
|
1725
|
+
}
|
1726
|
+
return encodeDynamicSegment(utils_1.normalizeString(params.get(this.name)));
|
1727
|
+
};
|
1728
|
+
DynamicPathSegment.paramMatcher = /^:([^\/]+)$/g;
|
1729
|
+
return DynamicPathSegment;
|
1730
|
+
}());
|
1731
|
+
var StarPathSegment = (function() {
|
1732
|
+
function StarPathSegment(name) {
|
1733
|
+
this.name = name;
|
1734
|
+
this.specificity = '0';
|
1735
|
+
this.hash = '*';
|
1736
|
+
}
|
1737
|
+
StarPathSegment.prototype.match = function(path) {
|
1738
|
+
return true;
|
1739
|
+
};
|
1740
|
+
StarPathSegment.prototype.generate = function(params) {
|
1741
|
+
return utils_1.normalizeString(params.get(this.name));
|
1742
|
+
};
|
1743
|
+
StarPathSegment.wildcardMatcher = /^\*([^\/]+)$/g;
|
1744
|
+
return StarPathSegment;
|
1745
|
+
}());
|
1746
|
+
var ParamRoutePath = (function() {
|
1747
|
+
function ParamRoutePath(routePath) {
|
1748
|
+
this.routePath = routePath;
|
1749
|
+
this.terminal = true;
|
1750
|
+
this._assertValidPath(routePath);
|
1751
|
+
this._parsePathString(routePath);
|
1752
|
+
this.specificity = this._calculateSpecificity();
|
1753
|
+
this.hash = this._calculateHash();
|
1754
|
+
var lastSegment = this._segments[this._segments.length - 1];
|
1755
|
+
this.terminal = !(lastSegment instanceof ContinuationPathSegment);
|
1756
|
+
}
|
1757
|
+
ParamRoutePath.prototype.matchUrl = function(url) {
|
1758
|
+
var nextUrlSegment = url;
|
1759
|
+
var currentUrlSegment;
|
1760
|
+
var positionalParams = {};
|
1761
|
+
var captured = [];
|
1762
|
+
for (var i = 0; i < this._segments.length; i += 1) {
|
1763
|
+
var pathSegment = this._segments[i];
|
1764
|
+
currentUrlSegment = nextUrlSegment;
|
1765
|
+
if (pathSegment instanceof ContinuationPathSegment) {
|
1766
|
+
break;
|
1767
|
+
}
|
1768
|
+
if (lang_1.isPresent(currentUrlSegment)) {
|
1769
|
+
if (pathSegment instanceof StarPathSegment) {
|
1770
|
+
positionalParams[pathSegment.name] = currentUrlSegment.toString();
|
1771
|
+
captured.push(currentUrlSegment.toString());
|
1772
|
+
nextUrlSegment = null;
|
1773
|
+
break;
|
1774
|
+
}
|
1775
|
+
captured.push(currentUrlSegment.path);
|
1776
|
+
if (pathSegment instanceof DynamicPathSegment) {
|
1777
|
+
positionalParams[pathSegment.name] = decodeDynamicSegment(currentUrlSegment.path);
|
1778
|
+
} else if (!pathSegment.match(currentUrlSegment.path)) {
|
1779
|
+
return null;
|
1780
|
+
}
|
1781
|
+
nextUrlSegment = currentUrlSegment.child;
|
1782
|
+
} else if (!pathSegment.match('')) {
|
1783
|
+
return null;
|
1784
|
+
}
|
1785
|
+
}
|
1786
|
+
if (this.terminal && lang_1.isPresent(nextUrlSegment)) {
|
1787
|
+
return null;
|
1788
|
+
}
|
1789
|
+
var urlPath = captured.join('/');
|
1790
|
+
var auxiliary = [];
|
1791
|
+
var urlParams = [];
|
1792
|
+
var allParams = positionalParams;
|
1793
|
+
if (lang_1.isPresent(currentUrlSegment)) {
|
1794
|
+
var paramsSegment = url instanceof url_parser_1.RootUrl ? url : currentUrlSegment;
|
1795
|
+
if (lang_1.isPresent(paramsSegment.params)) {
|
1796
|
+
allParams = collection_1.StringMapWrapper.merge(paramsSegment.params, positionalParams);
|
1797
|
+
urlParams = url_parser_1.convertUrlParamsToArray(paramsSegment.params);
|
1798
|
+
} else {
|
1799
|
+
allParams = positionalParams;
|
1800
|
+
}
|
1801
|
+
auxiliary = currentUrlSegment.auxiliary;
|
1802
|
+
}
|
1803
|
+
return new route_path_1.MatchedUrl(urlPath, urlParams, allParams, auxiliary, nextUrlSegment);
|
1804
|
+
};
|
1805
|
+
ParamRoutePath.prototype.generateUrl = function(params) {
|
1806
|
+
var paramTokens = new utils_1.TouchMap(params);
|
1807
|
+
var path = [];
|
1808
|
+
for (var i = 0; i < this._segments.length; i++) {
|
1809
|
+
var segment = this._segments[i];
|
1810
|
+
if (!(segment instanceof ContinuationPathSegment)) {
|
1811
|
+
path.push(segment.generate(paramTokens));
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
var urlPath = path.join('/');
|
1815
|
+
var nonPositionalParams = paramTokens.getUnused();
|
1816
|
+
var urlParams = nonPositionalParams;
|
1817
|
+
return new route_path_1.GeneratedUrl(urlPath, urlParams);
|
1818
|
+
};
|
1819
|
+
ParamRoutePath.prototype.toString = function() {
|
1820
|
+
return this.routePath;
|
1821
|
+
};
|
1822
|
+
ParamRoutePath.prototype._parsePathString = function(routePath) {
|
1823
|
+
if (routePath.startsWith("/")) {
|
1824
|
+
routePath = routePath.substring(1);
|
1825
|
+
}
|
1826
|
+
var segmentStrings = routePath.split('/');
|
1827
|
+
this._segments = [];
|
1828
|
+
var limit = segmentStrings.length - 1;
|
1829
|
+
for (var i = 0; i <= limit; i++) {
|
1830
|
+
var segment = segmentStrings[i],
|
1831
|
+
match;
|
1832
|
+
if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(DynamicPathSegment.paramMatcher, segment))) {
|
1833
|
+
this._segments.push(new DynamicPathSegment(match[1]));
|
1834
|
+
} else if (lang_1.isPresent(match = lang_1.RegExpWrapper.firstMatch(StarPathSegment.wildcardMatcher, segment))) {
|
1835
|
+
this._segments.push(new StarPathSegment(match[1]));
|
1836
|
+
} else if (segment == '...') {
|
1837
|
+
if (i < limit) {
|
1838
|
+
throw new exceptions_1.BaseException("Unexpected \"...\" before the end of the path for \"" + routePath + "\".");
|
1839
|
+
}
|
1840
|
+
this._segments.push(new ContinuationPathSegment());
|
1841
|
+
} else {
|
1842
|
+
this._segments.push(new StaticPathSegment(segment));
|
1843
|
+
}
|
1844
|
+
}
|
1845
|
+
};
|
1846
|
+
ParamRoutePath.prototype._calculateSpecificity = function() {
|
1847
|
+
var i,
|
1848
|
+
length = this._segments.length,
|
1849
|
+
specificity;
|
1850
|
+
if (length == 0) {
|
1851
|
+
specificity += '2';
|
1852
|
+
} else {
|
1853
|
+
specificity = '';
|
1854
|
+
for (i = 0; i < length; i++) {
|
1855
|
+
specificity += this._segments[i].specificity;
|
1856
|
+
}
|
1857
|
+
}
|
1858
|
+
return specificity;
|
1859
|
+
};
|
1860
|
+
ParamRoutePath.prototype._calculateHash = function() {
|
1861
|
+
var i,
|
1862
|
+
length = this._segments.length;
|
1863
|
+
var hashParts = [];
|
1864
|
+
for (i = 0; i < length; i++) {
|
1865
|
+
hashParts.push(this._segments[i].hash);
|
1866
|
+
}
|
1867
|
+
return hashParts.join('/');
|
1868
|
+
};
|
1869
|
+
ParamRoutePath.prototype._assertValidPath = function(path) {
|
1870
|
+
if (lang_1.StringWrapper.contains(path, '#')) {
|
1871
|
+
throw new exceptions_1.BaseException("Path \"" + path + "\" should not include \"#\". Use \"HashLocationStrategy\" instead.");
|
1872
|
+
}
|
1873
|
+
var illegalCharacter = lang_1.RegExpWrapper.firstMatch(ParamRoutePath.RESERVED_CHARS, path);
|
1874
|
+
if (lang_1.isPresent(illegalCharacter)) {
|
1875
|
+
throw new exceptions_1.BaseException("Path \"" + path + "\" contains \"" + illegalCharacter[0] + "\" which is not allowed in a route config.");
|
1876
|
+
}
|
1877
|
+
};
|
1878
|
+
ParamRoutePath.RESERVED_CHARS = lang_1.RegExpWrapper.create('//|\\(|\\)|;|\\?|=');
|
1879
|
+
return ParamRoutePath;
|
1880
|
+
}());
|
1881
|
+
exports.ParamRoutePath = ParamRoutePath;
|
1882
|
+
var REGEXP_PERCENT = /%/g;
|
1883
|
+
var REGEXP_SLASH = /\//g;
|
1884
|
+
var REGEXP_OPEN_PARENT = /\(/g;
|
1885
|
+
var REGEXP_CLOSE_PARENT = /\)/g;
|
1886
|
+
var REGEXP_SEMICOLON = /;/g;
|
1887
|
+
function encodeDynamicSegment(value) {
|
1888
|
+
if (lang_1.isBlank(value)) {
|
1889
|
+
return null;
|
1890
|
+
}
|
1891
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_PERCENT, '%25');
|
1892
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_SLASH, '%2F');
|
1893
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_OPEN_PARENT, '%28');
|
1894
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_CLOSE_PARENT, '%29');
|
1895
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_SEMICOLON, '%3B');
|
1896
|
+
return value;
|
1897
|
+
}
|
1898
|
+
var REGEXP_ENC_SEMICOLON = /%3B/ig;
|
1899
|
+
var REGEXP_ENC_CLOSE_PARENT = /%29/ig;
|
1900
|
+
var REGEXP_ENC_OPEN_PARENT = /%28/ig;
|
1901
|
+
var REGEXP_ENC_SLASH = /%2F/ig;
|
1902
|
+
var REGEXP_ENC_PERCENT = /%25/ig;
|
1903
|
+
function decodeDynamicSegment(value) {
|
1904
|
+
if (lang_1.isBlank(value)) {
|
1905
|
+
return null;
|
1906
|
+
}
|
1907
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_ENC_SEMICOLON, ';');
|
1908
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_ENC_CLOSE_PARENT, ')');
|
1909
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_ENC_OPEN_PARENT, '(');
|
1910
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_ENC_SLASH, '/');
|
1911
|
+
value = lang_1.StringWrapper.replaceAll(value, REGEXP_ENC_PERCENT, '%');
|
1912
|
+
return value;
|
1913
|
+
}
|
1914
|
+
global.define = __define;
|
1915
|
+
return module.exports;
|
1916
|
+
});
|
1917
|
+
|
1918
|
+
System.register("angular2/src/router/route_config/route_config_normalizer", ["angular2/src/router/route_config/route_config_decorator", "angular2/src/facade/lang", "angular2/src/facade/exceptions"], true, function(require, exports, module) {
|
1919
|
+
var global = System.global,
|
1920
|
+
__define = global.define;
|
1921
|
+
global.define = undefined;
|
1922
|
+
"use strict";
|
1923
|
+
var route_config_decorator_1 = require("angular2/src/router/route_config/route_config_decorator");
|
1924
|
+
var lang_1 = require("angular2/src/facade/lang");
|
1925
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
1926
|
+
function normalizeRouteConfig(config, registry) {
|
1927
|
+
if (config instanceof route_config_decorator_1.AsyncRoute) {
|
1928
|
+
var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
|
1929
|
+
return new route_config_decorator_1.AsyncRoute({
|
1930
|
+
path: config.path,
|
1931
|
+
loader: wrappedLoader,
|
1932
|
+
name: config.name,
|
1933
|
+
data: config.data,
|
1934
|
+
useAsDefault: config.useAsDefault
|
1935
|
+
});
|
1936
|
+
}
|
1937
|
+
if (config instanceof route_config_decorator_1.Route || config instanceof route_config_decorator_1.Redirect || config instanceof route_config_decorator_1.AuxRoute) {
|
1938
|
+
return config;
|
1939
|
+
}
|
1940
|
+
if ((+!!config.component) + (+!!config.redirectTo) + (+!!config.loader) != 1) {
|
1941
|
+
throw new exceptions_1.BaseException("Route config should contain exactly one \"component\", \"loader\", or \"redirectTo\" property.");
|
1942
|
+
}
|
1943
|
+
if (config.as && config.name) {
|
1944
|
+
throw new exceptions_1.BaseException("Route config should contain exactly one \"as\" or \"name\" property.");
|
1945
|
+
}
|
1946
|
+
if (config.as) {
|
1947
|
+
config.name = config.as;
|
1948
|
+
}
|
1949
|
+
if (config.loader) {
|
1950
|
+
var wrappedLoader = wrapLoaderToReconfigureRegistry(config.loader, registry);
|
1951
|
+
return new route_config_decorator_1.AsyncRoute({
|
1952
|
+
path: config.path,
|
1953
|
+
loader: wrappedLoader,
|
1954
|
+
name: config.name,
|
1955
|
+
data: config.data,
|
1956
|
+
useAsDefault: config.useAsDefault
|
1957
|
+
});
|
1958
|
+
}
|
1959
|
+
if (config.aux) {
|
1960
|
+
return new route_config_decorator_1.AuxRoute({
|
1961
|
+
path: config.aux,
|
1962
|
+
component: config.component,
|
1963
|
+
name: config.name
|
1964
|
+
});
|
1965
|
+
}
|
1966
|
+
if (config.component) {
|
1967
|
+
if (typeof config.component == 'object') {
|
1968
|
+
var componentDefinitionObject = config.component;
|
1969
|
+
if (componentDefinitionObject.type == 'constructor') {
|
1970
|
+
return new route_config_decorator_1.Route({
|
1971
|
+
path: config.path,
|
1972
|
+
component: componentDefinitionObject.constructor,
|
1973
|
+
name: config.name,
|
1974
|
+
data: config.data,
|
1975
|
+
useAsDefault: config.useAsDefault
|
1976
|
+
});
|
1977
|
+
} else if (componentDefinitionObject.type == 'loader') {
|
1978
|
+
return new route_config_decorator_1.AsyncRoute({
|
1979
|
+
path: config.path,
|
1980
|
+
loader: componentDefinitionObject.loader,
|
1981
|
+
name: config.name,
|
1982
|
+
data: config.data,
|
1983
|
+
useAsDefault: config.useAsDefault
|
1984
|
+
});
|
1985
|
+
} else {
|
1986
|
+
throw new exceptions_1.BaseException("Invalid component type \"" + componentDefinitionObject.type + "\". Valid types are \"constructor\" and \"loader\".");
|
1987
|
+
}
|
1988
|
+
}
|
1989
|
+
return new route_config_decorator_1.Route(config);
|
1990
|
+
}
|
1991
|
+
if (config.redirectTo) {
|
1992
|
+
return new route_config_decorator_1.Redirect({
|
1993
|
+
path: config.path,
|
1994
|
+
redirectTo: config.redirectTo
|
1995
|
+
});
|
1996
|
+
}
|
1997
|
+
return config;
|
1998
|
+
}
|
1999
|
+
exports.normalizeRouteConfig = normalizeRouteConfig;
|
2000
|
+
function wrapLoaderToReconfigureRegistry(loader, registry) {
|
2001
|
+
return function() {
|
2002
|
+
return loader().then(function(componentType) {
|
2003
|
+
registry.configFromComponent(componentType);
|
2004
|
+
return componentType;
|
2005
|
+
});
|
2006
|
+
};
|
2007
|
+
}
|
2008
|
+
function assertComponentExists(component, path) {
|
2009
|
+
if (!lang_1.isType(component)) {
|
2010
|
+
throw new exceptions_1.BaseException("Component for route \"" + path + "\" is not defined, or is not a class.");
|
2011
|
+
}
|
2012
|
+
}
|
2013
|
+
exports.assertComponentExists = assertComponentExists;
|
2014
|
+
global.define = __define;
|
2015
|
+
return module.exports;
|
2016
|
+
});
|
2017
|
+
|
2018
|
+
System.register("angular2/src/router/location/location", ["angular2/src/router/location/location_strategy", "angular2/src/facade/async", "angular2/core"], true, function(require, exports, module) {
|
2019
|
+
var global = System.global,
|
2020
|
+
__define = global.define;
|
2021
|
+
global.define = undefined;
|
2022
|
+
"use strict";
|
2023
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
2024
|
+
var c = arguments.length,
|
2025
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2026
|
+
d;
|
2027
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
2028
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
2029
|
+
else
|
2030
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
2031
|
+
if (d = decorators[i])
|
2032
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2033
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2034
|
+
};
|
2035
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
2036
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
2037
|
+
return Reflect.metadata(k, v);
|
2038
|
+
};
|
2039
|
+
var location_strategy_1 = require("angular2/src/router/location/location_strategy");
|
2040
|
+
var async_1 = require("angular2/src/facade/async");
|
2041
|
+
var core_1 = require("angular2/core");
|
2042
|
+
var Location = (function() {
|
2043
|
+
function Location(platformStrategy) {
|
2044
|
+
var _this = this;
|
2045
|
+
this.platformStrategy = platformStrategy;
|
2046
|
+
this._subject = new async_1.EventEmitter();
|
2047
|
+
var browserBaseHref = this.platformStrategy.getBaseHref();
|
2048
|
+
this._baseHref = stripTrailingSlash(stripIndexHtml(browserBaseHref));
|
2049
|
+
this.platformStrategy.onPopState(function(ev) {
|
2050
|
+
async_1.ObservableWrapper.callEmit(_this._subject, {
|
2051
|
+
'url': _this.path(),
|
2052
|
+
'pop': true,
|
2053
|
+
'type': ev.type
|
2054
|
+
});
|
2055
|
+
});
|
2056
|
+
}
|
2057
|
+
Location.prototype.path = function() {
|
2058
|
+
return this.normalize(this.platformStrategy.path());
|
2059
|
+
};
|
2060
|
+
Location.prototype.normalize = function(url) {
|
2061
|
+
return stripTrailingSlash(_stripBaseHref(this._baseHref, stripIndexHtml(url)));
|
2062
|
+
};
|
2063
|
+
Location.prototype.prepareExternalUrl = function(url) {
|
2064
|
+
if (url.length > 0 && !url.startsWith('/')) {
|
2065
|
+
url = '/' + url;
|
2066
|
+
}
|
2067
|
+
return this.platformStrategy.prepareExternalUrl(url);
|
2068
|
+
};
|
2069
|
+
Location.prototype.go = function(path, query) {
|
2070
|
+
if (query === void 0) {
|
2071
|
+
query = '';
|
2072
|
+
}
|
2073
|
+
this.platformStrategy.pushState(null, '', path, query);
|
2074
|
+
};
|
2075
|
+
Location.prototype.replaceState = function(path, query) {
|
2076
|
+
if (query === void 0) {
|
2077
|
+
query = '';
|
2078
|
+
}
|
2079
|
+
this.platformStrategy.replaceState(null, '', path, query);
|
2080
|
+
};
|
2081
|
+
Location.prototype.forward = function() {
|
2082
|
+
this.platformStrategy.forward();
|
2083
|
+
};
|
2084
|
+
Location.prototype.back = function() {
|
2085
|
+
this.platformStrategy.back();
|
2086
|
+
};
|
2087
|
+
Location.prototype.subscribe = function(onNext, onThrow, onReturn) {
|
2088
|
+
if (onThrow === void 0) {
|
2089
|
+
onThrow = null;
|
2090
|
+
}
|
2091
|
+
if (onReturn === void 0) {
|
2092
|
+
onReturn = null;
|
2093
|
+
}
|
2094
|
+
return async_1.ObservableWrapper.subscribe(this._subject, onNext, onThrow, onReturn);
|
2095
|
+
};
|
2096
|
+
Location = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [location_strategy_1.LocationStrategy])], Location);
|
2097
|
+
return Location;
|
2098
|
+
}());
|
2099
|
+
exports.Location = Location;
|
2100
|
+
function _stripBaseHref(baseHref, url) {
|
2101
|
+
if (baseHref.length > 0 && url.startsWith(baseHref)) {
|
2102
|
+
return url.substring(baseHref.length);
|
2103
|
+
}
|
2104
|
+
return url;
|
2105
|
+
}
|
2106
|
+
function stripIndexHtml(url) {
|
2107
|
+
if (/\/index.html$/g.test(url)) {
|
2108
|
+
return url.substring(0, url.length - 11);
|
2109
|
+
}
|
2110
|
+
return url;
|
2111
|
+
}
|
2112
|
+
function stripTrailingSlash(url) {
|
2113
|
+
if (/\/$/g.test(url)) {
|
2114
|
+
url = url.substring(0, url.length - 1);
|
2115
|
+
}
|
2116
|
+
return url;
|
2117
|
+
}
|
2118
|
+
global.define = __define;
|
2119
|
+
return module.exports;
|
2120
|
+
});
|
2121
|
+
|
2122
|
+
System.register("angular2/src/router/lifecycle/route_lifecycle_reflector", ["angular2/src/facade/lang", "angular2/src/router/lifecycle/lifecycle_annotations_impl", "angular2/src/core/reflection/reflection"], true, function(require, exports, module) {
|
2123
|
+
var global = System.global,
|
2124
|
+
__define = global.define;
|
2125
|
+
global.define = undefined;
|
2126
|
+
"use strict";
|
2127
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2128
|
+
var lifecycle_annotations_impl_1 = require("angular2/src/router/lifecycle/lifecycle_annotations_impl");
|
2129
|
+
var reflection_1 = require("angular2/src/core/reflection/reflection");
|
2130
|
+
function hasLifecycleHook(e, type) {
|
2131
|
+
if (!(type instanceof lang_1.Type))
|
2132
|
+
return false;
|
2133
|
+
return e.name in type.prototype;
|
2134
|
+
}
|
2135
|
+
exports.hasLifecycleHook = hasLifecycleHook;
|
2136
|
+
function getCanActivateHook(type) {
|
2137
|
+
var annotations = reflection_1.reflector.annotations(type);
|
2138
|
+
for (var i = 0; i < annotations.length; i += 1) {
|
2139
|
+
var annotation = annotations[i];
|
2140
|
+
if (annotation instanceof lifecycle_annotations_impl_1.CanActivate) {
|
2141
|
+
return annotation.fn;
|
2142
|
+
}
|
2143
|
+
}
|
2144
|
+
return null;
|
2145
|
+
}
|
2146
|
+
exports.getCanActivateHook = getCanActivateHook;
|
2147
|
+
global.define = __define;
|
2148
|
+
return module.exports;
|
2149
|
+
});
|
2150
|
+
|
2151
|
+
System.register("angular2/src/router/directives/router_outlet", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/core", "angular2/src/router/router", "angular2/src/router/instruction", "angular2/src/router/lifecycle/lifecycle_annotations", "angular2/src/router/lifecycle/route_lifecycle_reflector"], true, function(require, exports, module) {
|
2152
|
+
var global = System.global,
|
2153
|
+
__define = global.define;
|
2154
|
+
global.define = undefined;
|
2155
|
+
"use strict";
|
2156
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
2157
|
+
var c = arguments.length,
|
2158
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2159
|
+
d;
|
2160
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
2161
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
2162
|
+
else
|
2163
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
2164
|
+
if (d = decorators[i])
|
2165
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2166
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2167
|
+
};
|
2168
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
2169
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
2170
|
+
return Reflect.metadata(k, v);
|
2171
|
+
};
|
2172
|
+
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
2173
|
+
return function(target, key) {
|
2174
|
+
decorator(target, key, paramIndex);
|
2175
|
+
};
|
2176
|
+
};
|
2177
|
+
var async_1 = require("angular2/src/facade/async");
|
2178
|
+
var collection_1 = require("angular2/src/facade/collection");
|
2179
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2180
|
+
var core_1 = require("angular2/core");
|
2181
|
+
var routerMod = require("angular2/src/router/router");
|
2182
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
2183
|
+
var hookMod = require("angular2/src/router/lifecycle/lifecycle_annotations");
|
2184
|
+
var route_lifecycle_reflector_1 = require("angular2/src/router/lifecycle/route_lifecycle_reflector");
|
2185
|
+
var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
|
2186
|
+
var RouterOutlet = (function() {
|
2187
|
+
function RouterOutlet(_elementRef, _loader, _parentRouter, nameAttr) {
|
2188
|
+
this._elementRef = _elementRef;
|
2189
|
+
this._loader = _loader;
|
2190
|
+
this._parentRouter = _parentRouter;
|
2191
|
+
this.name = null;
|
2192
|
+
this._componentRef = null;
|
2193
|
+
this._currentInstruction = null;
|
2194
|
+
if (lang_1.isPresent(nameAttr)) {
|
2195
|
+
this.name = nameAttr;
|
2196
|
+
this._parentRouter.registerAuxOutlet(this);
|
2197
|
+
} else {
|
2198
|
+
this._parentRouter.registerPrimaryOutlet(this);
|
2199
|
+
}
|
2200
|
+
}
|
2201
|
+
RouterOutlet.prototype.activate = function(nextInstruction) {
|
2202
|
+
var _this = this;
|
2203
|
+
var previousInstruction = this._currentInstruction;
|
2204
|
+
this._currentInstruction = nextInstruction;
|
2205
|
+
var componentType = nextInstruction.componentType;
|
2206
|
+
var childRouter = this._parentRouter.childRouter(componentType);
|
2207
|
+
var providers = core_1.Injector.resolve([core_1.provide(instruction_1.RouteData, {useValue: nextInstruction.routeData}), core_1.provide(instruction_1.RouteParams, {useValue: new instruction_1.RouteParams(nextInstruction.params)}), core_1.provide(routerMod.Router, {useValue: childRouter})]);
|
2208
|
+
this._componentRef = this._loader.loadNextToLocation(componentType, this._elementRef, providers);
|
2209
|
+
return this._componentRef.then(function(componentRef) {
|
2210
|
+
if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnActivate, componentType)) {
|
2211
|
+
return _this._componentRef.then(function(ref) {
|
2212
|
+
return ref.instance.routerOnActivate(nextInstruction, previousInstruction);
|
2213
|
+
});
|
2214
|
+
} else {
|
2215
|
+
return componentRef;
|
2216
|
+
}
|
2217
|
+
});
|
2218
|
+
};
|
2219
|
+
RouterOutlet.prototype.reuse = function(nextInstruction) {
|
2220
|
+
var previousInstruction = this._currentInstruction;
|
2221
|
+
this._currentInstruction = nextInstruction;
|
2222
|
+
if (lang_1.isBlank(this._componentRef)) {
|
2223
|
+
return this.activate(nextInstruction);
|
2224
|
+
} else {
|
2225
|
+
return async_1.PromiseWrapper.resolve(route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnReuse, this._currentInstruction.componentType) ? this._componentRef.then(function(ref) {
|
2226
|
+
return ref.instance.routerOnReuse(nextInstruction, previousInstruction);
|
2227
|
+
}) : true);
|
2228
|
+
}
|
2229
|
+
};
|
2230
|
+
RouterOutlet.prototype.deactivate = function(nextInstruction) {
|
2231
|
+
var _this = this;
|
2232
|
+
var next = _resolveToTrue;
|
2233
|
+
if (lang_1.isPresent(this._componentRef) && lang_1.isPresent(this._currentInstruction) && route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerOnDeactivate, this._currentInstruction.componentType)) {
|
2234
|
+
next = this._componentRef.then(function(ref) {
|
2235
|
+
return ref.instance.routerOnDeactivate(nextInstruction, _this._currentInstruction);
|
2236
|
+
});
|
2237
|
+
}
|
2238
|
+
return next.then(function(_) {
|
2239
|
+
if (lang_1.isPresent(_this._componentRef)) {
|
2240
|
+
var onDispose = _this._componentRef.then(function(ref) {
|
2241
|
+
return ref.dispose();
|
2242
|
+
});
|
2243
|
+
_this._componentRef = null;
|
2244
|
+
return onDispose;
|
2245
|
+
}
|
2246
|
+
});
|
2247
|
+
};
|
2248
|
+
RouterOutlet.prototype.routerCanDeactivate = function(nextInstruction) {
|
2249
|
+
var _this = this;
|
2250
|
+
if (lang_1.isBlank(this._currentInstruction)) {
|
2251
|
+
return _resolveToTrue;
|
2252
|
+
}
|
2253
|
+
if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanDeactivate, this._currentInstruction.componentType)) {
|
2254
|
+
return this._componentRef.then(function(ref) {
|
2255
|
+
return ref.instance.routerCanDeactivate(nextInstruction, _this._currentInstruction);
|
2256
|
+
});
|
2257
|
+
} else {
|
2258
|
+
return _resolveToTrue;
|
2259
|
+
}
|
2260
|
+
};
|
2261
|
+
RouterOutlet.prototype.routerCanReuse = function(nextInstruction) {
|
2262
|
+
var _this = this;
|
2263
|
+
var result;
|
2264
|
+
if (lang_1.isBlank(this._currentInstruction) || this._currentInstruction.componentType != nextInstruction.componentType) {
|
2265
|
+
result = false;
|
2266
|
+
} else if (route_lifecycle_reflector_1.hasLifecycleHook(hookMod.routerCanReuse, this._currentInstruction.componentType)) {
|
2267
|
+
result = this._componentRef.then(function(ref) {
|
2268
|
+
return ref.instance.routerCanReuse(nextInstruction, _this._currentInstruction);
|
2269
|
+
});
|
2270
|
+
} else {
|
2271
|
+
result = nextInstruction == this._currentInstruction || (lang_1.isPresent(nextInstruction.params) && lang_1.isPresent(this._currentInstruction.params) && collection_1.StringMapWrapper.equals(nextInstruction.params, this._currentInstruction.params));
|
2272
|
+
}
|
2273
|
+
return async_1.PromiseWrapper.resolve(result);
|
2274
|
+
};
|
2275
|
+
RouterOutlet.prototype.ngOnDestroy = function() {
|
2276
|
+
this._parentRouter.unregisterPrimaryOutlet(this);
|
2277
|
+
};
|
2278
|
+
RouterOutlet = __decorate([core_1.Directive({selector: 'router-outlet'}), __param(3, core_1.Attribute('name')), __metadata('design:paramtypes', [core_1.ElementRef, core_1.DynamicComponentLoader, routerMod.Router, String])], RouterOutlet);
|
2279
|
+
return RouterOutlet;
|
2280
|
+
}());
|
2281
|
+
exports.RouterOutlet = RouterOutlet;
|
2282
|
+
global.define = __define;
|
2283
|
+
return module.exports;
|
2284
|
+
});
|
2285
|
+
|
2286
|
+
System.register("angular2/src/router/location/browser_platform_location", ["angular2/core", "angular2/src/router/location/platform_location", "angular2/src/platform/dom/dom_adapter"], true, function(require, exports, module) {
|
2287
|
+
var global = System.global,
|
2288
|
+
__define = global.define;
|
2289
|
+
global.define = undefined;
|
2290
|
+
"use strict";
|
2291
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
2292
|
+
for (var p in b)
|
2293
|
+
if (b.hasOwnProperty(p))
|
2294
|
+
d[p] = b[p];
|
2295
|
+
function __() {
|
2296
|
+
this.constructor = d;
|
2297
|
+
}
|
2298
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2299
|
+
};
|
2300
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
2301
|
+
var c = arguments.length,
|
2302
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2303
|
+
d;
|
2304
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
2305
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
2306
|
+
else
|
2307
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
2308
|
+
if (d = decorators[i])
|
2309
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2310
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2311
|
+
};
|
2312
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
2313
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
2314
|
+
return Reflect.metadata(k, v);
|
2315
|
+
};
|
2316
|
+
var core_1 = require("angular2/core");
|
2317
|
+
var platform_location_1 = require("angular2/src/router/location/platform_location");
|
2318
|
+
var dom_adapter_1 = require("angular2/src/platform/dom/dom_adapter");
|
2319
|
+
var BrowserPlatformLocation = (function(_super) {
|
2320
|
+
__extends(BrowserPlatformLocation, _super);
|
2321
|
+
function BrowserPlatformLocation() {
|
2322
|
+
_super.call(this);
|
2323
|
+
this._init();
|
2324
|
+
}
|
2325
|
+
BrowserPlatformLocation.prototype._init = function() {
|
2326
|
+
this._location = dom_adapter_1.DOM.getLocation();
|
2327
|
+
this._history = dom_adapter_1.DOM.getHistory();
|
2328
|
+
};
|
2329
|
+
Object.defineProperty(BrowserPlatformLocation.prototype, "location", {
|
2330
|
+
get: function() {
|
2331
|
+
return this._location;
|
2332
|
+
},
|
2333
|
+
enumerable: true,
|
2334
|
+
configurable: true
|
2335
|
+
});
|
2336
|
+
BrowserPlatformLocation.prototype.getBaseHrefFromDOM = function() {
|
2337
|
+
return dom_adapter_1.DOM.getBaseHref();
|
2338
|
+
};
|
2339
|
+
BrowserPlatformLocation.prototype.onPopState = function(fn) {
|
2340
|
+
dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('popstate', fn, false);
|
2341
|
+
};
|
2342
|
+
BrowserPlatformLocation.prototype.onHashChange = function(fn) {
|
2343
|
+
dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
|
2344
|
+
};
|
2345
|
+
Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
|
2346
|
+
get: function() {
|
2347
|
+
return this._location.pathname;
|
2348
|
+
},
|
2349
|
+
set: function(newPath) {
|
2350
|
+
this._location.pathname = newPath;
|
2351
|
+
},
|
2352
|
+
enumerable: true,
|
2353
|
+
configurable: true
|
2354
|
+
});
|
2355
|
+
Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
|
2356
|
+
get: function() {
|
2357
|
+
return this._location.search;
|
2358
|
+
},
|
2359
|
+
enumerable: true,
|
2360
|
+
configurable: true
|
2361
|
+
});
|
2362
|
+
Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
|
2363
|
+
get: function() {
|
2364
|
+
return this._location.hash;
|
2365
|
+
},
|
2366
|
+
enumerable: true,
|
2367
|
+
configurable: true
|
2368
|
+
});
|
2369
|
+
BrowserPlatformLocation.prototype.pushState = function(state, title, url) {
|
2370
|
+
this._history.pushState(state, title, url);
|
2371
|
+
};
|
2372
|
+
BrowserPlatformLocation.prototype.replaceState = function(state, title, url) {
|
2373
|
+
this._history.replaceState(state, title, url);
|
2374
|
+
};
|
2375
|
+
BrowserPlatformLocation.prototype.forward = function() {
|
2376
|
+
this._history.forward();
|
2377
|
+
};
|
2378
|
+
BrowserPlatformLocation.prototype.back = function() {
|
2379
|
+
this._history.back();
|
2380
|
+
};
|
2381
|
+
BrowserPlatformLocation = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [])], BrowserPlatformLocation);
|
2382
|
+
return BrowserPlatformLocation;
|
2383
|
+
}(platform_location_1.PlatformLocation));
|
2384
|
+
exports.BrowserPlatformLocation = BrowserPlatformLocation;
|
2385
|
+
global.define = __define;
|
2386
|
+
return module.exports;
|
2387
|
+
});
|
2388
|
+
|
2389
|
+
System.register("angular2/src/router/rules/rule_set", ["angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/router/rules/rules", "angular2/src/router/route_config/route_config_impl", "angular2/src/router/rules/route_handlers/async_route_handler", "angular2/src/router/rules/route_handlers/sync_route_handler", "angular2/src/router/rules/route_paths/param_route_path", "angular2/src/router/rules/route_paths/regex_route_path"], true, function(require, exports, module) {
|
2390
|
+
var global = System.global,
|
2391
|
+
__define = global.define;
|
2392
|
+
global.define = undefined;
|
2393
|
+
"use strict";
|
2394
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2395
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
2396
|
+
var collection_1 = require("angular2/src/facade/collection");
|
2397
|
+
var async_1 = require("angular2/src/facade/async");
|
2398
|
+
var rules_1 = require("angular2/src/router/rules/rules");
|
2399
|
+
var route_config_impl_1 = require("angular2/src/router/route_config/route_config_impl");
|
2400
|
+
var async_route_handler_1 = require("angular2/src/router/rules/route_handlers/async_route_handler");
|
2401
|
+
var sync_route_handler_1 = require("angular2/src/router/rules/route_handlers/sync_route_handler");
|
2402
|
+
var param_route_path_1 = require("angular2/src/router/rules/route_paths/param_route_path");
|
2403
|
+
var regex_route_path_1 = require("angular2/src/router/rules/route_paths/regex_route_path");
|
2404
|
+
var RuleSet = (function() {
|
2405
|
+
function RuleSet() {
|
2406
|
+
this.rulesByName = new collection_1.Map();
|
2407
|
+
this.auxRulesByName = new collection_1.Map();
|
2408
|
+
this.auxRulesByPath = new collection_1.Map();
|
2409
|
+
this.rules = [];
|
2410
|
+
this.defaultRule = null;
|
2411
|
+
}
|
2412
|
+
RuleSet.prototype.config = function(config) {
|
2413
|
+
var handler;
|
2414
|
+
if (lang_1.isPresent(config.name) && config.name[0].toUpperCase() != config.name[0]) {
|
2415
|
+
var suggestedName = config.name[0].toUpperCase() + config.name.substring(1);
|
2416
|
+
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 + "\".");
|
2417
|
+
}
|
2418
|
+
if (config instanceof route_config_impl_1.AuxRoute) {
|
2419
|
+
handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
|
2420
|
+
var routePath_1 = this._getRoutePath(config);
|
2421
|
+
var auxRule = new rules_1.RouteRule(routePath_1, handler, config.name);
|
2422
|
+
this.auxRulesByPath.set(routePath_1.toString(), auxRule);
|
2423
|
+
if (lang_1.isPresent(config.name)) {
|
2424
|
+
this.auxRulesByName.set(config.name, auxRule);
|
2425
|
+
}
|
2426
|
+
return auxRule.terminal;
|
2427
|
+
}
|
2428
|
+
var useAsDefault = false;
|
2429
|
+
if (config instanceof route_config_impl_1.Redirect) {
|
2430
|
+
var routePath_2 = this._getRoutePath(config);
|
2431
|
+
var redirector = new rules_1.RedirectRule(routePath_2, config.redirectTo);
|
2432
|
+
this._assertNoHashCollision(redirector.hash, config.path);
|
2433
|
+
this.rules.push(redirector);
|
2434
|
+
return true;
|
2435
|
+
}
|
2436
|
+
if (config instanceof route_config_impl_1.Route) {
|
2437
|
+
handler = new sync_route_handler_1.SyncRouteHandler(config.component, config.data);
|
2438
|
+
useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
|
2439
|
+
} else if (config instanceof route_config_impl_1.AsyncRoute) {
|
2440
|
+
handler = new async_route_handler_1.AsyncRouteHandler(config.loader, config.data);
|
2441
|
+
useAsDefault = lang_1.isPresent(config.useAsDefault) && config.useAsDefault;
|
2442
|
+
}
|
2443
|
+
var routePath = this._getRoutePath(config);
|
2444
|
+
var newRule = new rules_1.RouteRule(routePath, handler, config.name);
|
2445
|
+
this._assertNoHashCollision(newRule.hash, config.path);
|
2446
|
+
if (useAsDefault) {
|
2447
|
+
if (lang_1.isPresent(this.defaultRule)) {
|
2448
|
+
throw new exceptions_1.BaseException("Only one route can be default");
|
2449
|
+
}
|
2450
|
+
this.defaultRule = newRule;
|
2451
|
+
}
|
2452
|
+
this.rules.push(newRule);
|
2453
|
+
if (lang_1.isPresent(config.name)) {
|
2454
|
+
this.rulesByName.set(config.name, newRule);
|
2455
|
+
}
|
2456
|
+
return newRule.terminal;
|
2457
|
+
};
|
2458
|
+
RuleSet.prototype.recognize = function(urlParse) {
|
2459
|
+
var solutions = [];
|
2460
|
+
this.rules.forEach(function(routeRecognizer) {
|
2461
|
+
var pathMatch = routeRecognizer.recognize(urlParse);
|
2462
|
+
if (lang_1.isPresent(pathMatch)) {
|
2463
|
+
solutions.push(pathMatch);
|
2464
|
+
}
|
2465
|
+
});
|
2466
|
+
if (solutions.length == 0 && lang_1.isPresent(urlParse) && urlParse.auxiliary.length > 0) {
|
2467
|
+
return [async_1.PromiseWrapper.resolve(new rules_1.PathMatch(null, null, urlParse.auxiliary))];
|
2468
|
+
}
|
2469
|
+
return solutions;
|
2470
|
+
};
|
2471
|
+
RuleSet.prototype.recognizeAuxiliary = function(urlParse) {
|
2472
|
+
var routeRecognizer = this.auxRulesByPath.get(urlParse.path);
|
2473
|
+
if (lang_1.isPresent(routeRecognizer)) {
|
2474
|
+
return [routeRecognizer.recognize(urlParse)];
|
2475
|
+
}
|
2476
|
+
return [async_1.PromiseWrapper.resolve(null)];
|
2477
|
+
};
|
2478
|
+
RuleSet.prototype.hasRoute = function(name) {
|
2479
|
+
return this.rulesByName.has(name);
|
2480
|
+
};
|
2481
|
+
RuleSet.prototype.componentLoaded = function(name) {
|
2482
|
+
return this.hasRoute(name) && lang_1.isPresent(this.rulesByName.get(name).handler.componentType);
|
2483
|
+
};
|
2484
|
+
RuleSet.prototype.loadComponent = function(name) {
|
2485
|
+
return this.rulesByName.get(name).handler.resolveComponentType();
|
2486
|
+
};
|
2487
|
+
RuleSet.prototype.generate = function(name, params) {
|
2488
|
+
var rule = this.rulesByName.get(name);
|
2489
|
+
if (lang_1.isBlank(rule)) {
|
2490
|
+
return null;
|
2491
|
+
}
|
2492
|
+
return rule.generate(params);
|
2493
|
+
};
|
2494
|
+
RuleSet.prototype.generateAuxiliary = function(name, params) {
|
2495
|
+
var rule = this.auxRulesByName.get(name);
|
2496
|
+
if (lang_1.isBlank(rule)) {
|
2497
|
+
return null;
|
2498
|
+
}
|
2499
|
+
return rule.generate(params);
|
2500
|
+
};
|
2501
|
+
RuleSet.prototype._assertNoHashCollision = function(hash, path) {
|
2502
|
+
this.rules.forEach(function(rule) {
|
2503
|
+
if (hash == rule.hash) {
|
2504
|
+
throw new exceptions_1.BaseException("Configuration '" + path + "' conflicts with existing route '" + rule.path + "'");
|
2505
|
+
}
|
2506
|
+
});
|
2507
|
+
};
|
2508
|
+
RuleSet.prototype._getRoutePath = function(config) {
|
2509
|
+
if (lang_1.isPresent(config.regex)) {
|
2510
|
+
if (lang_1.isFunction(config.serializer)) {
|
2511
|
+
return new regex_route_path_1.RegexRoutePath(config.regex, config.serializer);
|
2512
|
+
} else {
|
2513
|
+
throw new exceptions_1.BaseException("Route provides a regex property, '" + config.regex + "', but no serializer property");
|
2514
|
+
}
|
2515
|
+
}
|
2516
|
+
if (lang_1.isPresent(config.path)) {
|
2517
|
+
var path = (config instanceof route_config_impl_1.AuxRoute && config.path.startsWith('/')) ? config.path.substring(1) : config.path;
|
2518
|
+
return new param_route_path_1.ParamRoutePath(path);
|
2519
|
+
}
|
2520
|
+
throw new exceptions_1.BaseException('Route must provide either a path or regex property');
|
2521
|
+
};
|
2522
|
+
return RuleSet;
|
2523
|
+
}());
|
2524
|
+
exports.RuleSet = RuleSet;
|
2525
|
+
global.define = __define;
|
2526
|
+
return module.exports;
|
2527
|
+
});
|
2528
|
+
|
2529
|
+
System.register("angular2/src/router/router_providers", ["angular2/src/router/router_providers_common", "angular2/core", "angular2/src/facade/lang", "angular2/src/router/location/browser_platform_location", "angular2/src/router/location/platform_location"], true, function(require, exports, module) {
|
2530
|
+
var global = System.global,
|
2531
|
+
__define = global.define;
|
2532
|
+
global.define = undefined;
|
2533
|
+
"use strict";
|
2534
|
+
var router_providers_common_1 = require("angular2/src/router/router_providers_common");
|
2535
|
+
var core_1 = require("angular2/core");
|
2536
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2537
|
+
var browser_platform_location_1 = require("angular2/src/router/location/browser_platform_location");
|
2538
|
+
var platform_location_1 = require("angular2/src/router/location/platform_location");
|
2539
|
+
exports.ROUTER_PROVIDERS = lang_1.CONST_EXPR([router_providers_common_1.ROUTER_PROVIDERS_COMMON, lang_1.CONST_EXPR(new core_1.Provider(platform_location_1.PlatformLocation, {useClass: browser_platform_location_1.BrowserPlatformLocation}))]);
|
2540
|
+
exports.ROUTER_BINDINGS = exports.ROUTER_PROVIDERS;
|
2541
|
+
global.define = __define;
|
2542
|
+
return module.exports;
|
2543
|
+
});
|
2544
|
+
|
2545
|
+
System.register("angular2/src/router/route_registry", ["angular2/src/facade/collection", "angular2/src/facade/async", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/src/core/reflection/reflection", "angular2/core", "angular2/src/router/route_config/route_config_impl", "angular2/src/router/rules/rules", "angular2/src/router/rules/rule_set", "angular2/src/router/instruction", "angular2/src/router/route_config/route_config_normalizer", "angular2/src/router/url_parser"], true, function(require, exports, module) {
|
2546
|
+
var global = System.global,
|
2547
|
+
__define = global.define;
|
2548
|
+
global.define = undefined;
|
2549
|
+
"use strict";
|
2550
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
2551
|
+
var c = arguments.length,
|
2552
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2553
|
+
d;
|
2554
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
2555
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
2556
|
+
else
|
2557
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
2558
|
+
if (d = decorators[i])
|
2559
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2560
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2561
|
+
};
|
2562
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
2563
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
2564
|
+
return Reflect.metadata(k, v);
|
2565
|
+
};
|
2566
|
+
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
2567
|
+
return function(target, key) {
|
2568
|
+
decorator(target, key, paramIndex);
|
2569
|
+
};
|
2570
|
+
};
|
2571
|
+
var collection_1 = require("angular2/src/facade/collection");
|
2572
|
+
var async_1 = require("angular2/src/facade/async");
|
2573
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2574
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
2575
|
+
var reflection_1 = require("angular2/src/core/reflection/reflection");
|
2576
|
+
var core_1 = require("angular2/core");
|
2577
|
+
var route_config_impl_1 = require("angular2/src/router/route_config/route_config_impl");
|
2578
|
+
var rules_1 = require("angular2/src/router/rules/rules");
|
2579
|
+
var rule_set_1 = require("angular2/src/router/rules/rule_set");
|
2580
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
2581
|
+
var route_config_normalizer_1 = require("angular2/src/router/route_config/route_config_normalizer");
|
2582
|
+
var url_parser_1 = require("angular2/src/router/url_parser");
|
2583
|
+
var _resolveToNull = async_1.PromiseWrapper.resolve(null);
|
2584
|
+
exports.ROUTER_PRIMARY_COMPONENT = lang_1.CONST_EXPR(new core_1.OpaqueToken('RouterPrimaryComponent'));
|
2585
|
+
var RouteRegistry = (function() {
|
2586
|
+
function RouteRegistry(_rootComponent) {
|
2587
|
+
this._rootComponent = _rootComponent;
|
2588
|
+
this._rules = new collection_1.Map();
|
2589
|
+
}
|
2590
|
+
RouteRegistry.prototype.config = function(parentComponent, config) {
|
2591
|
+
config = route_config_normalizer_1.normalizeRouteConfig(config, this);
|
2592
|
+
if (config instanceof route_config_impl_1.Route) {
|
2593
|
+
route_config_normalizer_1.assertComponentExists(config.component, config.path);
|
2594
|
+
} else if (config instanceof route_config_impl_1.AuxRoute) {
|
2595
|
+
route_config_normalizer_1.assertComponentExists(config.component, config.path);
|
2596
|
+
}
|
2597
|
+
var rules = this._rules.get(parentComponent);
|
2598
|
+
if (lang_1.isBlank(rules)) {
|
2599
|
+
rules = new rule_set_1.RuleSet();
|
2600
|
+
this._rules.set(parentComponent, rules);
|
2601
|
+
}
|
2602
|
+
var terminal = rules.config(config);
|
2603
|
+
if (config instanceof route_config_impl_1.Route) {
|
2604
|
+
if (terminal) {
|
2605
|
+
assertTerminalComponent(config.component, config.path);
|
2606
|
+
} else {
|
2607
|
+
this.configFromComponent(config.component);
|
2608
|
+
}
|
2609
|
+
}
|
2610
|
+
};
|
2611
|
+
RouteRegistry.prototype.configFromComponent = function(component) {
|
2612
|
+
var _this = this;
|
2613
|
+
if (!lang_1.isType(component)) {
|
2614
|
+
return ;
|
2615
|
+
}
|
2616
|
+
if (this._rules.has(component)) {
|
2617
|
+
return ;
|
2618
|
+
}
|
2619
|
+
var annotations = reflection_1.reflector.annotations(component);
|
2620
|
+
if (lang_1.isPresent(annotations)) {
|
2621
|
+
for (var i = 0; i < annotations.length; i++) {
|
2622
|
+
var annotation = annotations[i];
|
2623
|
+
if (annotation instanceof route_config_impl_1.RouteConfig) {
|
2624
|
+
var routeCfgs = annotation.configs;
|
2625
|
+
routeCfgs.forEach(function(config) {
|
2626
|
+
return _this.config(component, config);
|
2627
|
+
});
|
2628
|
+
}
|
2629
|
+
}
|
2630
|
+
}
|
2631
|
+
};
|
2632
|
+
RouteRegistry.prototype.recognize = function(url, ancestorInstructions) {
|
2633
|
+
var parsedUrl = url_parser_1.parser.parse(url);
|
2634
|
+
return this._recognize(parsedUrl, []);
|
2635
|
+
};
|
2636
|
+
RouteRegistry.prototype._recognize = function(parsedUrl, ancestorInstructions, _aux) {
|
2637
|
+
var _this = this;
|
2638
|
+
if (_aux === void 0) {
|
2639
|
+
_aux = false;
|
2640
|
+
}
|
2641
|
+
var parentInstruction = collection_1.ListWrapper.last(ancestorInstructions);
|
2642
|
+
var parentComponent = lang_1.isPresent(parentInstruction) ? parentInstruction.component.componentType : this._rootComponent;
|
2643
|
+
var rules = this._rules.get(parentComponent);
|
2644
|
+
if (lang_1.isBlank(rules)) {
|
2645
|
+
return _resolveToNull;
|
2646
|
+
}
|
2647
|
+
var possibleMatches = _aux ? rules.recognizeAuxiliary(parsedUrl) : rules.recognize(parsedUrl);
|
2648
|
+
var matchPromises = possibleMatches.map(function(candidate) {
|
2649
|
+
return candidate.then(function(candidate) {
|
2650
|
+
if (candidate instanceof rules_1.PathMatch) {
|
2651
|
+
var auxParentInstructions = ancestorInstructions.length > 0 ? [collection_1.ListWrapper.last(ancestorInstructions)] : [];
|
2652
|
+
var auxInstructions = _this._auxRoutesToUnresolved(candidate.remainingAux, auxParentInstructions);
|
2653
|
+
var instruction = new instruction_1.ResolvedInstruction(candidate.instruction, null, auxInstructions);
|
2654
|
+
if (lang_1.isBlank(candidate.instruction) || candidate.instruction.terminal) {
|
2655
|
+
return instruction;
|
2656
|
+
}
|
2657
|
+
var newAncestorInstructions = ancestorInstructions.concat([instruction]);
|
2658
|
+
return _this._recognize(candidate.remaining, newAncestorInstructions).then(function(childInstruction) {
|
2659
|
+
if (lang_1.isBlank(childInstruction)) {
|
2660
|
+
return null;
|
2661
|
+
}
|
2662
|
+
if (childInstruction instanceof instruction_1.RedirectInstruction) {
|
2663
|
+
return childInstruction;
|
2664
|
+
}
|
2665
|
+
instruction.child = childInstruction;
|
2666
|
+
return instruction;
|
2667
|
+
});
|
2668
|
+
}
|
2669
|
+
if (candidate instanceof rules_1.RedirectMatch) {
|
2670
|
+
var instruction = _this.generate(candidate.redirectTo, ancestorInstructions.concat([null]));
|
2671
|
+
return new instruction_1.RedirectInstruction(instruction.component, instruction.child, instruction.auxInstruction, candidate.specificity);
|
2672
|
+
}
|
2673
|
+
});
|
2674
|
+
});
|
2675
|
+
if ((lang_1.isBlank(parsedUrl) || parsedUrl.path == '') && possibleMatches.length == 0) {
|
2676
|
+
return async_1.PromiseWrapper.resolve(this.generateDefault(parentComponent));
|
2677
|
+
}
|
2678
|
+
return async_1.PromiseWrapper.all(matchPromises).then(mostSpecific);
|
2679
|
+
};
|
2680
|
+
RouteRegistry.prototype._auxRoutesToUnresolved = function(auxRoutes, parentInstructions) {
|
2681
|
+
var _this = this;
|
2682
|
+
var unresolvedAuxInstructions = {};
|
2683
|
+
auxRoutes.forEach(function(auxUrl) {
|
2684
|
+
unresolvedAuxInstructions[auxUrl.path] = new instruction_1.UnresolvedInstruction(function() {
|
2685
|
+
return _this._recognize(auxUrl, parentInstructions, true);
|
2686
|
+
});
|
2687
|
+
});
|
2688
|
+
return unresolvedAuxInstructions;
|
2689
|
+
};
|
2690
|
+
RouteRegistry.prototype.generate = function(linkParams, ancestorInstructions, _aux) {
|
2691
|
+
if (_aux === void 0) {
|
2692
|
+
_aux = false;
|
2693
|
+
}
|
2694
|
+
var params = splitAndFlattenLinkParams(linkParams);
|
2695
|
+
var prevInstruction;
|
2696
|
+
if (collection_1.ListWrapper.first(params) == '') {
|
2697
|
+
params.shift();
|
2698
|
+
prevInstruction = collection_1.ListWrapper.first(ancestorInstructions);
|
2699
|
+
ancestorInstructions = [];
|
2700
|
+
} else {
|
2701
|
+
prevInstruction = ancestorInstructions.length > 0 ? ancestorInstructions.pop() : null;
|
2702
|
+
if (collection_1.ListWrapper.first(params) == '.') {
|
2703
|
+
params.shift();
|
2704
|
+
} else if (collection_1.ListWrapper.first(params) == '..') {
|
2705
|
+
while (collection_1.ListWrapper.first(params) == '..') {
|
2706
|
+
if (ancestorInstructions.length <= 0) {
|
2707
|
+
throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" has too many \"../\" segments.");
|
2708
|
+
}
|
2709
|
+
prevInstruction = ancestorInstructions.pop();
|
2710
|
+
params = collection_1.ListWrapper.slice(params, 1);
|
2711
|
+
}
|
2712
|
+
} else {
|
2713
|
+
var routeName = collection_1.ListWrapper.first(params);
|
2714
|
+
var parentComponentType = this._rootComponent;
|
2715
|
+
var grandparentComponentType = null;
|
2716
|
+
if (ancestorInstructions.length > 1) {
|
2717
|
+
var parentComponentInstruction = ancestorInstructions[ancestorInstructions.length - 1];
|
2718
|
+
var grandComponentInstruction = ancestorInstructions[ancestorInstructions.length - 2];
|
2719
|
+
parentComponentType = parentComponentInstruction.component.componentType;
|
2720
|
+
grandparentComponentType = grandComponentInstruction.component.componentType;
|
2721
|
+
} else if (ancestorInstructions.length == 1) {
|
2722
|
+
parentComponentType = ancestorInstructions[0].component.componentType;
|
2723
|
+
grandparentComponentType = this._rootComponent;
|
2724
|
+
}
|
2725
|
+
var childRouteExists = this.hasRoute(routeName, parentComponentType);
|
2726
|
+
var parentRouteExists = lang_1.isPresent(grandparentComponentType) && this.hasRoute(routeName, grandparentComponentType);
|
2727
|
+
if (parentRouteExists && childRouteExists) {
|
2728
|
+
var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" is ambiguous, use \"./\" or \"../\" to disambiguate.";
|
2729
|
+
throw new exceptions_1.BaseException(msg);
|
2730
|
+
}
|
2731
|
+
if (parentRouteExists) {
|
2732
|
+
prevInstruction = ancestorInstructions.pop();
|
2733
|
+
}
|
2734
|
+
}
|
2735
|
+
}
|
2736
|
+
if (params[params.length - 1] == '') {
|
2737
|
+
params.pop();
|
2738
|
+
}
|
2739
|
+
if (params.length > 0 && params[0] == '') {
|
2740
|
+
params.shift();
|
2741
|
+
}
|
2742
|
+
if (params.length < 1) {
|
2743
|
+
var msg = "Link \"" + collection_1.ListWrapper.toJSON(linkParams) + "\" must include a route name.";
|
2744
|
+
throw new exceptions_1.BaseException(msg);
|
2745
|
+
}
|
2746
|
+
var generatedInstruction = this._generate(params, ancestorInstructions, prevInstruction, _aux, linkParams);
|
2747
|
+
for (var i = ancestorInstructions.length - 1; i >= 0; i--) {
|
2748
|
+
var ancestorInstruction = ancestorInstructions[i];
|
2749
|
+
if (lang_1.isBlank(ancestorInstruction)) {
|
2750
|
+
break;
|
2751
|
+
}
|
2752
|
+
generatedInstruction = ancestorInstruction.replaceChild(generatedInstruction);
|
2753
|
+
}
|
2754
|
+
return generatedInstruction;
|
2755
|
+
};
|
2756
|
+
RouteRegistry.prototype._generate = function(linkParams, ancestorInstructions, prevInstruction, _aux, _originalLink) {
|
2757
|
+
var _this = this;
|
2758
|
+
if (_aux === void 0) {
|
2759
|
+
_aux = false;
|
2760
|
+
}
|
2761
|
+
var parentComponentType = this._rootComponent;
|
2762
|
+
var componentInstruction = null;
|
2763
|
+
var auxInstructions = {};
|
2764
|
+
var parentInstruction = collection_1.ListWrapper.last(ancestorInstructions);
|
2765
|
+
if (lang_1.isPresent(parentInstruction) && lang_1.isPresent(parentInstruction.component)) {
|
2766
|
+
parentComponentType = parentInstruction.component.componentType;
|
2767
|
+
}
|
2768
|
+
if (linkParams.length == 0) {
|
2769
|
+
var defaultInstruction = this.generateDefault(parentComponentType);
|
2770
|
+
if (lang_1.isBlank(defaultInstruction)) {
|
2771
|
+
throw new exceptions_1.BaseException("Link \"" + collection_1.ListWrapper.toJSON(_originalLink) + "\" does not resolve to a terminal instruction.");
|
2772
|
+
}
|
2773
|
+
return defaultInstruction;
|
2774
|
+
}
|
2775
|
+
if (lang_1.isPresent(prevInstruction) && !_aux) {
|
2776
|
+
auxInstructions = collection_1.StringMapWrapper.merge(prevInstruction.auxInstruction, auxInstructions);
|
2777
|
+
componentInstruction = prevInstruction.component;
|
2778
|
+
}
|
2779
|
+
var rules = this._rules.get(parentComponentType);
|
2780
|
+
if (lang_1.isBlank(rules)) {
|
2781
|
+
throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponentType) + "\" has no route config.");
|
2782
|
+
}
|
2783
|
+
var linkParamIndex = 0;
|
2784
|
+
var routeParams = {};
|
2785
|
+
if (linkParamIndex < linkParams.length && lang_1.isString(linkParams[linkParamIndex])) {
|
2786
|
+
var routeName = linkParams[linkParamIndex];
|
2787
|
+
if (routeName == '' || routeName == '.' || routeName == '..') {
|
2788
|
+
throw new exceptions_1.BaseException("\"" + routeName + "/\" is only allowed at the beginning of a link DSL.");
|
2789
|
+
}
|
2790
|
+
linkParamIndex += 1;
|
2791
|
+
if (linkParamIndex < linkParams.length) {
|
2792
|
+
var linkParam = linkParams[linkParamIndex];
|
2793
|
+
if (lang_1.isStringMap(linkParam) && !lang_1.isArray(linkParam)) {
|
2794
|
+
routeParams = linkParam;
|
2795
|
+
linkParamIndex += 1;
|
2796
|
+
}
|
2797
|
+
}
|
2798
|
+
var routeRecognizer = (_aux ? rules.auxRulesByName : rules.rulesByName).get(routeName);
|
2799
|
+
if (lang_1.isBlank(routeRecognizer)) {
|
2800
|
+
throw new exceptions_1.BaseException("Component \"" + lang_1.getTypeNameForDebugging(parentComponentType) + "\" has no route named \"" + routeName + "\".");
|
2801
|
+
}
|
2802
|
+
if (lang_1.isBlank(routeRecognizer.handler.componentType)) {
|
2803
|
+
var generatedUrl = routeRecognizer.generateComponentPathValues(routeParams);
|
2804
|
+
return new instruction_1.UnresolvedInstruction(function() {
|
2805
|
+
return routeRecognizer.handler.resolveComponentType().then(function(_) {
|
2806
|
+
return _this._generate(linkParams, ancestorInstructions, prevInstruction, _aux, _originalLink);
|
2807
|
+
});
|
2808
|
+
}, generatedUrl.urlPath, url_parser_1.convertUrlParamsToArray(generatedUrl.urlParams));
|
2809
|
+
}
|
2810
|
+
componentInstruction = _aux ? rules.generateAuxiliary(routeName, routeParams) : rules.generate(routeName, routeParams);
|
2811
|
+
}
|
2812
|
+
while (linkParamIndex < linkParams.length && lang_1.isArray(linkParams[linkParamIndex])) {
|
2813
|
+
var auxParentInstruction = [parentInstruction];
|
2814
|
+
var auxInstruction = this._generate(linkParams[linkParamIndex], auxParentInstruction, null, true, _originalLink);
|
2815
|
+
auxInstructions[auxInstruction.component.urlPath] = auxInstruction;
|
2816
|
+
linkParamIndex += 1;
|
2817
|
+
}
|
2818
|
+
var instruction = new instruction_1.ResolvedInstruction(componentInstruction, null, auxInstructions);
|
2819
|
+
if (lang_1.isPresent(componentInstruction) && lang_1.isPresent(componentInstruction.componentType)) {
|
2820
|
+
var childInstruction = null;
|
2821
|
+
if (componentInstruction.terminal) {
|
2822
|
+
if (linkParamIndex >= linkParams.length) {}
|
2823
|
+
} else {
|
2824
|
+
var childAncestorComponents = ancestorInstructions.concat([instruction]);
|
2825
|
+
var remainingLinkParams = linkParams.slice(linkParamIndex);
|
2826
|
+
childInstruction = this._generate(remainingLinkParams, childAncestorComponents, null, false, _originalLink);
|
2827
|
+
}
|
2828
|
+
instruction.child = childInstruction;
|
2829
|
+
}
|
2830
|
+
return instruction;
|
2831
|
+
};
|
2832
|
+
RouteRegistry.prototype.hasRoute = function(name, parentComponent) {
|
2833
|
+
var rules = this._rules.get(parentComponent);
|
2834
|
+
if (lang_1.isBlank(rules)) {
|
2835
|
+
return false;
|
2836
|
+
}
|
2837
|
+
return rules.hasRoute(name);
|
2838
|
+
};
|
2839
|
+
RouteRegistry.prototype.generateDefault = function(componentCursor) {
|
2840
|
+
var _this = this;
|
2841
|
+
if (lang_1.isBlank(componentCursor)) {
|
2842
|
+
return null;
|
2843
|
+
}
|
2844
|
+
var rules = this._rules.get(componentCursor);
|
2845
|
+
if (lang_1.isBlank(rules) || lang_1.isBlank(rules.defaultRule)) {
|
2846
|
+
return null;
|
2847
|
+
}
|
2848
|
+
var defaultChild = null;
|
2849
|
+
if (lang_1.isPresent(rules.defaultRule.handler.componentType)) {
|
2850
|
+
var componentInstruction = rules.defaultRule.generate({});
|
2851
|
+
if (!rules.defaultRule.terminal) {
|
2852
|
+
defaultChild = this.generateDefault(rules.defaultRule.handler.componentType);
|
2853
|
+
}
|
2854
|
+
return new instruction_1.DefaultInstruction(componentInstruction, defaultChild);
|
2855
|
+
}
|
2856
|
+
return new instruction_1.UnresolvedInstruction(function() {
|
2857
|
+
return rules.defaultRule.handler.resolveComponentType().then(function(_) {
|
2858
|
+
return _this.generateDefault(componentCursor);
|
2859
|
+
});
|
2860
|
+
});
|
2861
|
+
};
|
2862
|
+
RouteRegistry = __decorate([core_1.Injectable(), __param(0, core_1.Inject(exports.ROUTER_PRIMARY_COMPONENT)), __metadata('design:paramtypes', [lang_1.Type])], RouteRegistry);
|
2863
|
+
return RouteRegistry;
|
2864
|
+
}());
|
2865
|
+
exports.RouteRegistry = RouteRegistry;
|
2866
|
+
function splitAndFlattenLinkParams(linkParams) {
|
2867
|
+
var accumulation = [];
|
2868
|
+
linkParams.forEach(function(item) {
|
2869
|
+
if (lang_1.isString(item)) {
|
2870
|
+
var strItem = item;
|
2871
|
+
accumulation = accumulation.concat(strItem.split('/'));
|
2872
|
+
} else {
|
2873
|
+
accumulation.push(item);
|
2874
|
+
}
|
2875
|
+
});
|
2876
|
+
return accumulation;
|
2877
|
+
}
|
2878
|
+
function mostSpecific(instructions) {
|
2879
|
+
instructions = instructions.filter(function(instruction) {
|
2880
|
+
return lang_1.isPresent(instruction);
|
2881
|
+
});
|
2882
|
+
if (instructions.length == 0) {
|
2883
|
+
return null;
|
2884
|
+
}
|
2885
|
+
if (instructions.length == 1) {
|
2886
|
+
return instructions[0];
|
2887
|
+
}
|
2888
|
+
var first = instructions[0];
|
2889
|
+
var rest = instructions.slice(1);
|
2890
|
+
return rest.reduce(function(instruction, contender) {
|
2891
|
+
if (compareSpecificityStrings(contender.specificity, instruction.specificity) == -1) {
|
2892
|
+
return contender;
|
2893
|
+
}
|
2894
|
+
return instruction;
|
2895
|
+
}, first);
|
2896
|
+
}
|
2897
|
+
function compareSpecificityStrings(a, b) {
|
2898
|
+
var l = lang_1.Math.min(a.length, b.length);
|
2899
|
+
for (var i = 0; i < l; i += 1) {
|
2900
|
+
var ai = lang_1.StringWrapper.charCodeAt(a, i);
|
2901
|
+
var bi = lang_1.StringWrapper.charCodeAt(b, i);
|
2902
|
+
var difference = bi - ai;
|
2903
|
+
if (difference != 0) {
|
2904
|
+
return difference;
|
2905
|
+
}
|
2906
|
+
}
|
2907
|
+
return a.length - b.length;
|
2908
|
+
}
|
2909
|
+
function assertTerminalComponent(component, path) {
|
2910
|
+
if (!lang_1.isType(component)) {
|
2911
|
+
return ;
|
2912
|
+
}
|
2913
|
+
var annotations = reflection_1.reflector.annotations(component);
|
2914
|
+
if (lang_1.isPresent(annotations)) {
|
2915
|
+
for (var i = 0; i < annotations.length; i++) {
|
2916
|
+
var annotation = annotations[i];
|
2917
|
+
if (annotation instanceof route_config_impl_1.RouteConfig) {
|
2918
|
+
throw new exceptions_1.BaseException("Child routes are not allowed for \"" + path + "\". Use \"...\" on the parent's route path.");
|
2919
|
+
}
|
2920
|
+
}
|
2921
|
+
}
|
2922
|
+
}
|
2923
|
+
global.define = __define;
|
2924
|
+
return module.exports;
|
2925
|
+
});
|
2926
|
+
|
2927
|
+
System.register("angular2/src/router/router", ["angular2/src/facade/async", "angular2/src/facade/collection", "angular2/src/facade/lang", "angular2/src/facade/exceptions", "angular2/core", "angular2/src/router/route_registry", "angular2/src/router/location/location", "angular2/src/router/lifecycle/route_lifecycle_reflector"], true, function(require, exports, module) {
|
2928
|
+
var global = System.global,
|
2929
|
+
__define = global.define;
|
2930
|
+
global.define = undefined;
|
2931
|
+
"use strict";
|
2932
|
+
var __extends = (this && this.__extends) || function(d, b) {
|
2933
|
+
for (var p in b)
|
2934
|
+
if (b.hasOwnProperty(p))
|
2935
|
+
d[p] = b[p];
|
2936
|
+
function __() {
|
2937
|
+
this.constructor = d;
|
2938
|
+
}
|
2939
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
2940
|
+
};
|
2941
|
+
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
|
2942
|
+
var c = arguments.length,
|
2943
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
2944
|
+
d;
|
2945
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
2946
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
2947
|
+
else
|
2948
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
2949
|
+
if (d = decorators[i])
|
2950
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
2951
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
2952
|
+
};
|
2953
|
+
var __metadata = (this && this.__metadata) || function(k, v) {
|
2954
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
2955
|
+
return Reflect.metadata(k, v);
|
2956
|
+
};
|
2957
|
+
var __param = (this && this.__param) || function(paramIndex, decorator) {
|
2958
|
+
return function(target, key) {
|
2959
|
+
decorator(target, key, paramIndex);
|
2960
|
+
};
|
2961
|
+
};
|
2962
|
+
var async_1 = require("angular2/src/facade/async");
|
2963
|
+
var collection_1 = require("angular2/src/facade/collection");
|
2964
|
+
var lang_1 = require("angular2/src/facade/lang");
|
2965
|
+
var exceptions_1 = require("angular2/src/facade/exceptions");
|
2966
|
+
var core_1 = require("angular2/core");
|
2967
|
+
var route_registry_1 = require("angular2/src/router/route_registry");
|
2968
|
+
var location_1 = require("angular2/src/router/location/location");
|
2969
|
+
var route_lifecycle_reflector_1 = require("angular2/src/router/lifecycle/route_lifecycle_reflector");
|
2970
|
+
var _resolveToTrue = async_1.PromiseWrapper.resolve(true);
|
2971
|
+
var _resolveToFalse = async_1.PromiseWrapper.resolve(false);
|
2972
|
+
var Router = (function() {
|
2973
|
+
function Router(registry, parent, hostComponent, root) {
|
2974
|
+
this.registry = registry;
|
2975
|
+
this.parent = parent;
|
2976
|
+
this.hostComponent = hostComponent;
|
2977
|
+
this.root = root;
|
2978
|
+
this.navigating = false;
|
2979
|
+
this.currentInstruction = null;
|
2980
|
+
this._currentNavigation = _resolveToTrue;
|
2981
|
+
this._outlet = null;
|
2982
|
+
this._auxRouters = new collection_1.Map();
|
2983
|
+
this._subject = new async_1.EventEmitter();
|
2984
|
+
}
|
2985
|
+
Router.prototype.childRouter = function(hostComponent) {
|
2986
|
+
return this._childRouter = new ChildRouter(this, hostComponent);
|
2987
|
+
};
|
2988
|
+
Router.prototype.auxRouter = function(hostComponent) {
|
2989
|
+
return new ChildRouter(this, hostComponent);
|
2990
|
+
};
|
2991
|
+
Router.prototype.registerPrimaryOutlet = function(outlet) {
|
2992
|
+
if (lang_1.isPresent(outlet.name)) {
|
2993
|
+
throw new exceptions_1.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");
|
2994
|
+
}
|
2995
|
+
if (lang_1.isPresent(this._outlet)) {
|
2996
|
+
throw new exceptions_1.BaseException("Primary outlet is already registered.");
|
2997
|
+
}
|
2998
|
+
this._outlet = outlet;
|
2999
|
+
if (lang_1.isPresent(this.currentInstruction)) {
|
3000
|
+
return this.commit(this.currentInstruction, false);
|
3001
|
+
}
|
3002
|
+
return _resolveToTrue;
|
3003
|
+
};
|
3004
|
+
Router.prototype.unregisterPrimaryOutlet = function(outlet) {
|
3005
|
+
if (lang_1.isPresent(outlet.name)) {
|
3006
|
+
throw new exceptions_1.BaseException("registerPrimaryOutlet expects to be called with an unnamed outlet.");
|
3007
|
+
}
|
3008
|
+
this._outlet = null;
|
3009
|
+
};
|
3010
|
+
Router.prototype.registerAuxOutlet = function(outlet) {
|
3011
|
+
var outletName = outlet.name;
|
3012
|
+
if (lang_1.isBlank(outletName)) {
|
3013
|
+
throw new exceptions_1.BaseException("registerAuxOutlet expects to be called with an outlet with a name.");
|
3014
|
+
}
|
3015
|
+
var router = this.auxRouter(this.hostComponent);
|
3016
|
+
this._auxRouters.set(outletName, router);
|
3017
|
+
router._outlet = outlet;
|
3018
|
+
var auxInstruction;
|
3019
|
+
if (lang_1.isPresent(this.currentInstruction) && lang_1.isPresent(auxInstruction = this.currentInstruction.auxInstruction[outletName])) {
|
3020
|
+
return router.commit(auxInstruction);
|
3021
|
+
}
|
3022
|
+
return _resolveToTrue;
|
3023
|
+
};
|
3024
|
+
Router.prototype.isRouteActive = function(instruction) {
|
3025
|
+
var _this = this;
|
3026
|
+
var router = this;
|
3027
|
+
if (lang_1.isBlank(this.currentInstruction)) {
|
3028
|
+
return false;
|
3029
|
+
}
|
3030
|
+
while (lang_1.isPresent(router.parent) && lang_1.isPresent(instruction.child)) {
|
3031
|
+
router = router.parent;
|
3032
|
+
instruction = instruction.child;
|
3033
|
+
}
|
3034
|
+
if (lang_1.isBlank(instruction.component) || lang_1.isBlank(this.currentInstruction.component) || this.currentInstruction.component.routeName != instruction.component.routeName) {
|
3035
|
+
return false;
|
3036
|
+
}
|
3037
|
+
var paramEquals = true;
|
3038
|
+
if (lang_1.isPresent(this.currentInstruction.component.params)) {
|
3039
|
+
collection_1.StringMapWrapper.forEach(instruction.component.params, function(value, key) {
|
3040
|
+
if (_this.currentInstruction.component.params[key] !== value) {
|
3041
|
+
paramEquals = false;
|
3042
|
+
}
|
3043
|
+
});
|
3044
|
+
}
|
3045
|
+
return paramEquals;
|
3046
|
+
};
|
3047
|
+
Router.prototype.config = function(definitions) {
|
3048
|
+
var _this = this;
|
3049
|
+
definitions.forEach(function(routeDefinition) {
|
3050
|
+
_this.registry.config(_this.hostComponent, routeDefinition);
|
3051
|
+
});
|
3052
|
+
return this.renavigate();
|
3053
|
+
};
|
3054
|
+
Router.prototype.navigate = function(linkParams) {
|
3055
|
+
var instruction = this.generate(linkParams);
|
3056
|
+
return this.navigateByInstruction(instruction, false);
|
3057
|
+
};
|
3058
|
+
Router.prototype.navigateByUrl = function(url, _skipLocationChange) {
|
3059
|
+
var _this = this;
|
3060
|
+
if (_skipLocationChange === void 0) {
|
3061
|
+
_skipLocationChange = false;
|
3062
|
+
}
|
3063
|
+
return this._currentNavigation = this._currentNavigation.then(function(_) {
|
3064
|
+
_this.lastNavigationAttempt = url;
|
3065
|
+
_this._startNavigating();
|
3066
|
+
return _this._afterPromiseFinishNavigating(_this.recognize(url).then(function(instruction) {
|
3067
|
+
if (lang_1.isBlank(instruction)) {
|
3068
|
+
return false;
|
3069
|
+
}
|
3070
|
+
return _this._navigate(instruction, _skipLocationChange);
|
3071
|
+
}));
|
3072
|
+
});
|
3073
|
+
};
|
3074
|
+
Router.prototype.navigateByInstruction = function(instruction, _skipLocationChange) {
|
3075
|
+
var _this = this;
|
3076
|
+
if (_skipLocationChange === void 0) {
|
3077
|
+
_skipLocationChange = false;
|
3078
|
+
}
|
3079
|
+
if (lang_1.isBlank(instruction)) {
|
3080
|
+
return _resolveToFalse;
|
3081
|
+
}
|
3082
|
+
return this._currentNavigation = this._currentNavigation.then(function(_) {
|
3083
|
+
_this._startNavigating();
|
3084
|
+
return _this._afterPromiseFinishNavigating(_this._navigate(instruction, _skipLocationChange));
|
3085
|
+
});
|
3086
|
+
};
|
3087
|
+
Router.prototype._settleInstruction = function(instruction) {
|
3088
|
+
var _this = this;
|
3089
|
+
return instruction.resolveComponent().then(function(_) {
|
3090
|
+
var unsettledInstructions = [];
|
3091
|
+
if (lang_1.isPresent(instruction.component)) {
|
3092
|
+
instruction.component.reuse = false;
|
3093
|
+
}
|
3094
|
+
if (lang_1.isPresent(instruction.child)) {
|
3095
|
+
unsettledInstructions.push(_this._settleInstruction(instruction.child));
|
3096
|
+
}
|
3097
|
+
collection_1.StringMapWrapper.forEach(instruction.auxInstruction, function(instruction, _) {
|
3098
|
+
unsettledInstructions.push(_this._settleInstruction(instruction));
|
3099
|
+
});
|
3100
|
+
return async_1.PromiseWrapper.all(unsettledInstructions);
|
3101
|
+
});
|
3102
|
+
};
|
3103
|
+
Router.prototype._navigate = function(instruction, _skipLocationChange) {
|
3104
|
+
var _this = this;
|
3105
|
+
return this._settleInstruction(instruction).then(function(_) {
|
3106
|
+
return _this._routerCanReuse(instruction);
|
3107
|
+
}).then(function(_) {
|
3108
|
+
return _this._canActivate(instruction);
|
3109
|
+
}).then(function(result) {
|
3110
|
+
if (!result) {
|
3111
|
+
return false;
|
3112
|
+
}
|
3113
|
+
return _this._routerCanDeactivate(instruction).then(function(result) {
|
3114
|
+
if (result) {
|
3115
|
+
return _this.commit(instruction, _skipLocationChange).then(function(_) {
|
3116
|
+
_this._emitNavigationFinish(instruction.toRootUrl());
|
3117
|
+
return true;
|
3118
|
+
});
|
3119
|
+
}
|
3120
|
+
});
|
3121
|
+
});
|
3122
|
+
};
|
3123
|
+
Router.prototype._emitNavigationFinish = function(url) {
|
3124
|
+
async_1.ObservableWrapper.callEmit(this._subject, url);
|
3125
|
+
};
|
3126
|
+
Router.prototype._emitNavigationFail = function(url) {
|
3127
|
+
async_1.ObservableWrapper.callError(this._subject, url);
|
3128
|
+
};
|
3129
|
+
Router.prototype._afterPromiseFinishNavigating = function(promise) {
|
3130
|
+
var _this = this;
|
3131
|
+
return async_1.PromiseWrapper.catchError(promise.then(function(_) {
|
3132
|
+
return _this._finishNavigating();
|
3133
|
+
}), function(err) {
|
3134
|
+
_this._finishNavigating();
|
3135
|
+
throw err;
|
3136
|
+
});
|
3137
|
+
};
|
3138
|
+
Router.prototype._routerCanReuse = function(instruction) {
|
3139
|
+
var _this = this;
|
3140
|
+
if (lang_1.isBlank(this._outlet)) {
|
3141
|
+
return _resolveToFalse;
|
3142
|
+
}
|
3143
|
+
if (lang_1.isBlank(instruction.component)) {
|
3144
|
+
return _resolveToTrue;
|
3145
|
+
}
|
3146
|
+
return this._outlet.routerCanReuse(instruction.component).then(function(result) {
|
3147
|
+
instruction.component.reuse = result;
|
3148
|
+
if (result && lang_1.isPresent(_this._childRouter) && lang_1.isPresent(instruction.child)) {
|
3149
|
+
return _this._childRouter._routerCanReuse(instruction.child);
|
3150
|
+
}
|
3151
|
+
});
|
3152
|
+
};
|
3153
|
+
Router.prototype._canActivate = function(nextInstruction) {
|
3154
|
+
return canActivateOne(nextInstruction, this.currentInstruction);
|
3155
|
+
};
|
3156
|
+
Router.prototype._routerCanDeactivate = function(instruction) {
|
3157
|
+
var _this = this;
|
3158
|
+
if (lang_1.isBlank(this._outlet)) {
|
3159
|
+
return _resolveToTrue;
|
3160
|
+
}
|
3161
|
+
var next;
|
3162
|
+
var childInstruction = null;
|
3163
|
+
var reuse = false;
|
3164
|
+
var componentInstruction = null;
|
3165
|
+
if (lang_1.isPresent(instruction)) {
|
3166
|
+
childInstruction = instruction.child;
|
3167
|
+
componentInstruction = instruction.component;
|
3168
|
+
reuse = lang_1.isBlank(instruction.component) || instruction.component.reuse;
|
3169
|
+
}
|
3170
|
+
if (reuse) {
|
3171
|
+
next = _resolveToTrue;
|
3172
|
+
} else {
|
3173
|
+
next = this._outlet.routerCanDeactivate(componentInstruction);
|
3174
|
+
}
|
3175
|
+
return next.then(function(result) {
|
3176
|
+
if (result == false) {
|
3177
|
+
return false;
|
3178
|
+
}
|
3179
|
+
if (lang_1.isPresent(_this._childRouter)) {
|
3180
|
+
return _this._childRouter._routerCanDeactivate(childInstruction);
|
3181
|
+
}
|
3182
|
+
return true;
|
3183
|
+
});
|
3184
|
+
};
|
3185
|
+
Router.prototype.commit = function(instruction, _skipLocationChange) {
|
3186
|
+
var _this = this;
|
3187
|
+
if (_skipLocationChange === void 0) {
|
3188
|
+
_skipLocationChange = false;
|
3189
|
+
}
|
3190
|
+
this.currentInstruction = instruction;
|
3191
|
+
var next = _resolveToTrue;
|
3192
|
+
if (lang_1.isPresent(this._outlet) && lang_1.isPresent(instruction.component)) {
|
3193
|
+
var componentInstruction = instruction.component;
|
3194
|
+
if (componentInstruction.reuse) {
|
3195
|
+
next = this._outlet.reuse(componentInstruction);
|
3196
|
+
} else {
|
3197
|
+
next = this.deactivate(instruction).then(function(_) {
|
3198
|
+
return _this._outlet.activate(componentInstruction);
|
3199
|
+
});
|
3200
|
+
}
|
3201
|
+
if (lang_1.isPresent(instruction.child)) {
|
3202
|
+
next = next.then(function(_) {
|
3203
|
+
if (lang_1.isPresent(_this._childRouter)) {
|
3204
|
+
return _this._childRouter.commit(instruction.child);
|
3205
|
+
}
|
3206
|
+
});
|
3207
|
+
}
|
3208
|
+
}
|
3209
|
+
var promises = [];
|
3210
|
+
this._auxRouters.forEach(function(router, name) {
|
3211
|
+
if (lang_1.isPresent(instruction.auxInstruction[name])) {
|
3212
|
+
promises.push(router.commit(instruction.auxInstruction[name]));
|
3213
|
+
}
|
3214
|
+
});
|
3215
|
+
return next.then(function(_) {
|
3216
|
+
return async_1.PromiseWrapper.all(promises);
|
3217
|
+
});
|
3218
|
+
};
|
3219
|
+
Router.prototype._startNavigating = function() {
|
3220
|
+
this.navigating = true;
|
3221
|
+
};
|
3222
|
+
Router.prototype._finishNavigating = function() {
|
3223
|
+
this.navigating = false;
|
3224
|
+
};
|
3225
|
+
Router.prototype.subscribe = function(onNext, onError) {
|
3226
|
+
return async_1.ObservableWrapper.subscribe(this._subject, onNext, onError);
|
3227
|
+
};
|
3228
|
+
Router.prototype.deactivate = function(instruction) {
|
3229
|
+
var _this = this;
|
3230
|
+
var childInstruction = null;
|
3231
|
+
var componentInstruction = null;
|
3232
|
+
if (lang_1.isPresent(instruction)) {
|
3233
|
+
childInstruction = instruction.child;
|
3234
|
+
componentInstruction = instruction.component;
|
3235
|
+
}
|
3236
|
+
var next = _resolveToTrue;
|
3237
|
+
if (lang_1.isPresent(this._childRouter)) {
|
3238
|
+
next = this._childRouter.deactivate(childInstruction);
|
3239
|
+
}
|
3240
|
+
if (lang_1.isPresent(this._outlet)) {
|
3241
|
+
next = next.then(function(_) {
|
3242
|
+
return _this._outlet.deactivate(componentInstruction);
|
3243
|
+
});
|
3244
|
+
}
|
3245
|
+
return next;
|
3246
|
+
};
|
3247
|
+
Router.prototype.recognize = function(url) {
|
3248
|
+
var ancestorComponents = this._getAncestorInstructions();
|
3249
|
+
return this.registry.recognize(url, ancestorComponents);
|
3250
|
+
};
|
3251
|
+
Router.prototype._getAncestorInstructions = function() {
|
3252
|
+
var ancestorInstructions = [this.currentInstruction];
|
3253
|
+
var ancestorRouter = this;
|
3254
|
+
while (lang_1.isPresent(ancestorRouter = ancestorRouter.parent)) {
|
3255
|
+
ancestorInstructions.unshift(ancestorRouter.currentInstruction);
|
3256
|
+
}
|
3257
|
+
return ancestorInstructions;
|
3258
|
+
};
|
3259
|
+
Router.prototype.renavigate = function() {
|
3260
|
+
if (lang_1.isBlank(this.lastNavigationAttempt)) {
|
3261
|
+
return this._currentNavigation;
|
3262
|
+
}
|
3263
|
+
return this.navigateByUrl(this.lastNavigationAttempt);
|
3264
|
+
};
|
3265
|
+
Router.prototype.generate = function(linkParams) {
|
3266
|
+
var ancestorInstructions = this._getAncestorInstructions();
|
3267
|
+
return this.registry.generate(linkParams, ancestorInstructions);
|
3268
|
+
};
|
3269
|
+
Router = __decorate([core_1.Injectable(), __metadata('design:paramtypes', [route_registry_1.RouteRegistry, Router, Object, Router])], Router);
|
3270
|
+
return Router;
|
3271
|
+
}());
|
3272
|
+
exports.Router = Router;
|
3273
|
+
var RootRouter = (function(_super) {
|
3274
|
+
__extends(RootRouter, _super);
|
3275
|
+
function RootRouter(registry, location, primaryComponent) {
|
3276
|
+
var _this = this;
|
3277
|
+
_super.call(this, registry, null, primaryComponent);
|
3278
|
+
this.root = this;
|
3279
|
+
this._location = location;
|
3280
|
+
this._locationSub = this._location.subscribe(function(change) {
|
3281
|
+
_this.recognize(change['url']).then(function(instruction) {
|
3282
|
+
if (lang_1.isPresent(instruction)) {
|
3283
|
+
_this.navigateByInstruction(instruction, lang_1.isPresent(change['pop'])).then(function(_) {
|
3284
|
+
if (lang_1.isPresent(change['pop']) && change['type'] != 'hashchange') {
|
3285
|
+
return ;
|
3286
|
+
}
|
3287
|
+
var emitPath = instruction.toUrlPath();
|
3288
|
+
var emitQuery = instruction.toUrlQuery();
|
3289
|
+
if (emitPath.length > 0 && emitPath[0] != '/') {
|
3290
|
+
emitPath = '/' + emitPath;
|
3291
|
+
}
|
3292
|
+
if (change['type'] == 'hashchange') {
|
3293
|
+
if (instruction.toRootUrl() != _this._location.path()) {
|
3294
|
+
_this._location.replaceState(emitPath, emitQuery);
|
3295
|
+
}
|
3296
|
+
} else {
|
3297
|
+
_this._location.go(emitPath, emitQuery);
|
3298
|
+
}
|
3299
|
+
});
|
3300
|
+
} else {
|
3301
|
+
_this._emitNavigationFail(change['url']);
|
3302
|
+
}
|
3303
|
+
});
|
3304
|
+
});
|
3305
|
+
this.registry.configFromComponent(primaryComponent);
|
3306
|
+
this.navigateByUrl(location.path());
|
3307
|
+
}
|
3308
|
+
RootRouter.prototype.commit = function(instruction, _skipLocationChange) {
|
3309
|
+
var _this = this;
|
3310
|
+
if (_skipLocationChange === void 0) {
|
3311
|
+
_skipLocationChange = false;
|
3312
|
+
}
|
3313
|
+
var emitPath = instruction.toUrlPath();
|
3314
|
+
var emitQuery = instruction.toUrlQuery();
|
3315
|
+
if (emitPath.length > 0 && emitPath[0] != '/') {
|
3316
|
+
emitPath = '/' + emitPath;
|
3317
|
+
}
|
3318
|
+
var promise = _super.prototype.commit.call(this, instruction);
|
3319
|
+
if (!_skipLocationChange) {
|
3320
|
+
promise = promise.then(function(_) {
|
3321
|
+
_this._location.go(emitPath, emitQuery);
|
3322
|
+
});
|
3323
|
+
}
|
3324
|
+
return promise;
|
3325
|
+
};
|
3326
|
+
RootRouter.prototype.dispose = function() {
|
3327
|
+
if (lang_1.isPresent(this._locationSub)) {
|
3328
|
+
async_1.ObservableWrapper.dispose(this._locationSub);
|
3329
|
+
this._locationSub = null;
|
3330
|
+
}
|
3331
|
+
};
|
3332
|
+
RootRouter = __decorate([core_1.Injectable(), __param(2, core_1.Inject(route_registry_1.ROUTER_PRIMARY_COMPONENT)), __metadata('design:paramtypes', [route_registry_1.RouteRegistry, location_1.Location, lang_1.Type])], RootRouter);
|
3333
|
+
return RootRouter;
|
3334
|
+
}(Router));
|
3335
|
+
exports.RootRouter = RootRouter;
|
3336
|
+
var ChildRouter = (function(_super) {
|
3337
|
+
__extends(ChildRouter, _super);
|
3338
|
+
function ChildRouter(parent, hostComponent) {
|
3339
|
+
_super.call(this, parent.registry, parent, hostComponent, parent.root);
|
3340
|
+
this.parent = parent;
|
3341
|
+
}
|
3342
|
+
ChildRouter.prototype.navigateByUrl = function(url, _skipLocationChange) {
|
3343
|
+
if (_skipLocationChange === void 0) {
|
3344
|
+
_skipLocationChange = false;
|
3345
|
+
}
|
3346
|
+
return this.parent.navigateByUrl(url, _skipLocationChange);
|
3347
|
+
};
|
3348
|
+
ChildRouter.prototype.navigateByInstruction = function(instruction, _skipLocationChange) {
|
3349
|
+
if (_skipLocationChange === void 0) {
|
3350
|
+
_skipLocationChange = false;
|
3351
|
+
}
|
3352
|
+
return this.parent.navigateByInstruction(instruction, _skipLocationChange);
|
3353
|
+
};
|
3354
|
+
return ChildRouter;
|
3355
|
+
}(Router));
|
3356
|
+
function canActivateOne(nextInstruction, prevInstruction) {
|
3357
|
+
var next = _resolveToTrue;
|
3358
|
+
if (lang_1.isBlank(nextInstruction.component)) {
|
3359
|
+
return next;
|
3360
|
+
}
|
3361
|
+
if (lang_1.isPresent(nextInstruction.child)) {
|
3362
|
+
next = canActivateOne(nextInstruction.child, lang_1.isPresent(prevInstruction) ? prevInstruction.child : null);
|
3363
|
+
}
|
3364
|
+
return next.then(function(result) {
|
3365
|
+
if (result == false) {
|
3366
|
+
return false;
|
3367
|
+
}
|
3368
|
+
if (nextInstruction.component.reuse) {
|
3369
|
+
return true;
|
3370
|
+
}
|
3371
|
+
var hook = route_lifecycle_reflector_1.getCanActivateHook(nextInstruction.component.componentType);
|
3372
|
+
if (lang_1.isPresent(hook)) {
|
3373
|
+
return hook(nextInstruction.component, lang_1.isPresent(prevInstruction) ? prevInstruction.component : null);
|
3374
|
+
}
|
3375
|
+
return true;
|
3376
|
+
});
|
3377
|
+
}
|
3378
|
+
global.define = __define;
|
3379
|
+
return module.exports;
|
3380
|
+
});
|
3381
|
+
|
3382
|
+
System.register("angular2/router", ["angular2/src/router/router", "angular2/src/router/directives/router_outlet", "angular2/src/router/directives/router_link", "angular2/src/router/instruction", "angular2/src/router/location/platform_location", "angular2/src/router/route_registry", "angular2/src/router/location/location_strategy", "angular2/src/router/location/hash_location_strategy", "angular2/src/router/location/path_location_strategy", "angular2/src/router/location/location", "angular2/src/router/route_config/route_config_decorator", "angular2/src/router/lifecycle/lifecycle_annotations", "angular2/src/router/instruction", "angular2/core", "angular2/src/router/router_providers_common", "angular2/src/router/router_providers", "angular2/src/router/directives/router_outlet", "angular2/src/router/directives/router_link", "angular2/src/facade/lang"], true, function(require, exports, module) {
|
3383
|
+
var global = System.global,
|
3384
|
+
__define = global.define;
|
3385
|
+
global.define = undefined;
|
3386
|
+
"use strict";
|
3387
|
+
function __export(m) {
|
3388
|
+
for (var p in m)
|
3389
|
+
if (!exports.hasOwnProperty(p))
|
3390
|
+
exports[p] = m[p];
|
3391
|
+
}
|
3392
|
+
var router_1 = require("angular2/src/router/router");
|
3393
|
+
exports.Router = router_1.Router;
|
3394
|
+
var router_outlet_1 = require("angular2/src/router/directives/router_outlet");
|
3395
|
+
exports.RouterOutlet = router_outlet_1.RouterOutlet;
|
3396
|
+
var router_link_1 = require("angular2/src/router/directives/router_link");
|
3397
|
+
exports.RouterLink = router_link_1.RouterLink;
|
3398
|
+
var instruction_1 = require("angular2/src/router/instruction");
|
3399
|
+
exports.RouteParams = instruction_1.RouteParams;
|
3400
|
+
exports.RouteData = instruction_1.RouteData;
|
3401
|
+
var platform_location_1 = require("angular2/src/router/location/platform_location");
|
3402
|
+
exports.PlatformLocation = platform_location_1.PlatformLocation;
|
3403
|
+
var route_registry_1 = require("angular2/src/router/route_registry");
|
3404
|
+
exports.RouteRegistry = route_registry_1.RouteRegistry;
|
3405
|
+
exports.ROUTER_PRIMARY_COMPONENT = route_registry_1.ROUTER_PRIMARY_COMPONENT;
|
3406
|
+
var location_strategy_1 = require("angular2/src/router/location/location_strategy");
|
3407
|
+
exports.LocationStrategy = location_strategy_1.LocationStrategy;
|
3408
|
+
exports.APP_BASE_HREF = location_strategy_1.APP_BASE_HREF;
|
3409
|
+
var hash_location_strategy_1 = require("angular2/src/router/location/hash_location_strategy");
|
3410
|
+
exports.HashLocationStrategy = hash_location_strategy_1.HashLocationStrategy;
|
3411
|
+
var path_location_strategy_1 = require("angular2/src/router/location/path_location_strategy");
|
3412
|
+
exports.PathLocationStrategy = path_location_strategy_1.PathLocationStrategy;
|
3413
|
+
var location_1 = require("angular2/src/router/location/location");
|
3414
|
+
exports.Location = location_1.Location;
|
3415
|
+
__export(require("angular2/src/router/route_config/route_config_decorator"));
|
3416
|
+
var lifecycle_annotations_1 = require("angular2/src/router/lifecycle/lifecycle_annotations");
|
3417
|
+
exports.CanActivate = lifecycle_annotations_1.CanActivate;
|
3418
|
+
var instruction_2 = require("angular2/src/router/instruction");
|
3419
|
+
exports.Instruction = instruction_2.Instruction;
|
3420
|
+
exports.ComponentInstruction = instruction_2.ComponentInstruction;
|
3421
|
+
var core_1 = require("angular2/core");
|
3422
|
+
exports.OpaqueToken = core_1.OpaqueToken;
|
3423
|
+
var router_providers_common_1 = require("angular2/src/router/router_providers_common");
|
3424
|
+
exports.ROUTER_PROVIDERS_COMMON = router_providers_common_1.ROUTER_PROVIDERS_COMMON;
|
3425
|
+
var router_providers_1 = require("angular2/src/router/router_providers");
|
3426
|
+
exports.ROUTER_PROVIDERS = router_providers_1.ROUTER_PROVIDERS;
|
3427
|
+
exports.ROUTER_BINDINGS = router_providers_1.ROUTER_BINDINGS;
|
3428
|
+
var router_outlet_2 = require("angular2/src/router/directives/router_outlet");
|
3429
|
+
var router_link_2 = require("angular2/src/router/directives/router_link");
|
3430
|
+
var lang_1 = require("angular2/src/facade/lang");
|
3431
|
+
exports.ROUTER_DIRECTIVES = lang_1.CONST_EXPR([router_outlet_2.RouterOutlet, router_link_2.RouterLink]);
|
3432
|
+
global.define = __define;
|
3433
|
+
return module.exports;
|
3434
|
+
});
|
3435
|
+
|
3436
|
+
//# sourceMappingURLDisabled=router.js.map
|