@angular/router 2.0.0-rc.1 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/{router.umd.js → bundles/router.umd.js} +727 -637
  2. package/bundles/router.umd.min.js +2 -0
  3. package/esm/index.d.ts +7 -25
  4. package/esm/index.js +10 -30
  5. package/esm/index.js.map +1 -1
  6. package/esm/src/constants.js +4 -4
  7. package/esm/src/constants.js.map +1 -1
  8. package/esm/src/constants.metadata.json +1 -1
  9. package/esm/src/core_private.d.ts +3 -2
  10. package/esm/src/core_private.js +3 -2
  11. package/esm/src/core_private.js.map +1 -1
  12. package/esm/src/core_private.metadata.json +1 -1
  13. package/esm/src/directives/router_directives.d.ts +21 -0
  14. package/esm/src/directives/router_directives.js +24 -0
  15. package/esm/src/directives/router_directives.js.map +1 -0
  16. package/esm/src/directives/router_directives.metadata.json +1 -0
  17. package/esm/src/directives/router_link.d.ts +4 -2
  18. package/esm/src/directives/router_link.js +21 -13
  19. package/esm/src/directives/router_link.js.map +1 -1
  20. package/esm/src/directives/router_link.metadata.json +1 -1
  21. package/esm/src/directives/router_outlet.d.ts +6 -6
  22. package/esm/src/directives/router_outlet.js +13 -11
  23. package/esm/src/directives/router_outlet.js.map +1 -1
  24. package/esm/src/directives/router_outlet.metadata.json +1 -1
  25. package/esm/src/facade/async.d.ts +11 -4
  26. package/esm/src/facade/async.js +25 -15
  27. package/esm/src/facade/async.js.map +1 -1
  28. package/esm/src/facade/base_wrapped_exception.js +4 -4
  29. package/esm/src/facade/base_wrapped_exception.js.map +1 -1
  30. package/esm/src/facade/collection.js +1 -1
  31. package/esm/src/facade/collection.js.map +1 -1
  32. package/esm/src/facade/collection.metadata.json +1 -1
  33. package/esm/src/facade/exception_handler.d.ts +2 -11
  34. package/esm/src/facade/exception_handler.js +8 -7
  35. package/esm/src/facade/exception_handler.js.map +1 -1
  36. package/esm/src/facade/exceptions.d.ts +4 -0
  37. package/esm/src/facade/exceptions.js +6 -2
  38. package/esm/src/facade/exceptions.js.map +1 -1
  39. package/esm/src/facade/exceptions.metadata.json +1 -0
  40. package/esm/src/facade/lang.d.ts +6 -4
  41. package/esm/src/facade/lang.js +12 -11
  42. package/esm/src/facade/lang.js.map +1 -1
  43. package/esm/src/facade/lang.metadata.json +1 -1
  44. package/esm/src/facade/promise.js.map +1 -1
  45. package/esm/src/interfaces.js.map +1 -1
  46. package/esm/src/lifecycle_reflector.js.map +1 -1
  47. package/esm/src/link.d.ts +1 -1
  48. package/esm/src/link.js +31 -18
  49. package/esm/src/link.js.map +1 -1
  50. package/esm/src/metadata/decorators.d.ts +1 -1
  51. package/esm/src/metadata/decorators.js +1 -1
  52. package/esm/src/metadata/decorators.js.map +1 -1
  53. package/esm/src/metadata/decorators.metadata.json +1 -1
  54. package/esm/src/metadata/metadata.d.ts +3 -3
  55. package/esm/src/metadata/metadata.js +1 -1
  56. package/esm/src/metadata/metadata.js.map +1 -1
  57. package/esm/src/recognize.d.ts +3 -3
  58. package/esm/src/recognize.js +57 -41
  59. package/esm/src/recognize.js.map +1 -1
  60. package/esm/src/router.d.ts +3 -23
  61. package/esm/src/router.js +54 -58
  62. package/esm/src/router.js.map +1 -1
  63. package/esm/src/router_providers.d.ts +1 -1
  64. package/esm/src/router_providers.js +3 -7
  65. package/esm/src/router_providers.js.map +1 -1
  66. package/esm/src/router_providers.metadata.json +1 -1
  67. package/esm/src/router_providers_common.d.ts +7 -0
  68. package/esm/src/router_providers_common.js +10 -7
  69. package/esm/src/router_providers_common.js.map +1 -1
  70. package/esm/src/router_providers_common.metadata.json +1 -1
  71. package/esm/src/router_url_serializer.js +9 -9
  72. package/esm/src/router_url_serializer.js.map +1 -1
  73. package/esm/src/segments.d.ts +7 -12
  74. package/esm/src/segments.js +27 -45
  75. package/esm/src/segments.js.map +1 -1
  76. package/esm/src/segments.metadata.json +1 -0
  77. package/esm/testing/router_testing_providers.js +10 -3
  78. package/esm/testing/router_testing_providers.js.map +1 -1
  79. package/esm/testing/router_testing_providers.metadata.json +1 -1
  80. package/esm/testing.js.map +1 -1
  81. package/index.d.ts +7 -25
  82. package/index.js +22 -39
  83. package/index.js.map +1 -1
  84. package/package.json +8 -4
  85. package/src/constants.js +4 -4
  86. package/src/constants.js.map +1 -1
  87. package/src/constants.metadata.json +1 -1
  88. package/src/core_private.d.ts +3 -2
  89. package/src/core_private.js +1 -0
  90. package/src/core_private.js.map +1 -1
  91. package/src/core_private.metadata.json +1 -1
  92. package/src/directives/router_directives.d.ts +21 -0
  93. package/src/directives/router_directives.js +25 -0
  94. package/src/directives/router_directives.js.map +1 -0
  95. package/src/directives/router_directives.metadata.json +1 -0
  96. package/src/directives/router_link.d.ts +4 -2
  97. package/src/directives/router_link.js +20 -12
  98. package/src/directives/router_link.js.map +1 -1
  99. package/src/directives/router_link.metadata.json +1 -1
  100. package/src/directives/router_outlet.d.ts +6 -6
  101. package/src/directives/router_outlet.js +13 -11
  102. package/src/directives/router_outlet.js.map +1 -1
  103. package/src/directives/router_outlet.metadata.json +1 -1
  104. package/src/facade/async.d.ts +11 -4
  105. package/src/facade/async.js +27 -17
  106. package/src/facade/async.js.map +1 -1
  107. package/src/facade/base_wrapped_exception.js +4 -4
  108. package/src/facade/base_wrapped_exception.js.map +1 -1
  109. package/src/facade/collection.js.map +1 -1
  110. package/src/facade/collection.metadata.json +1 -1
  111. package/src/facade/exception_handler.d.ts +2 -11
  112. package/src/facade/exception_handler.js +8 -7
  113. package/src/facade/exception_handler.js.map +1 -1
  114. package/src/facade/exceptions.d.ts +4 -0
  115. package/src/facade/exceptions.js +6 -2
  116. package/src/facade/exceptions.js.map +1 -1
  117. package/src/facade/exceptions.metadata.json +1 -0
  118. package/src/facade/lang.d.ts +6 -4
  119. package/src/facade/lang.js +12 -11
  120. package/src/facade/lang.js.map +1 -1
  121. package/src/facade/lang.metadata.json +1 -1
  122. package/src/facade/promise.js.map +1 -1
  123. package/src/interfaces.js.map +1 -1
  124. package/src/lifecycle_reflector.js.map +1 -1
  125. package/src/link.d.ts +1 -1
  126. package/src/link.js +33 -18
  127. package/src/link.js.map +1 -1
  128. package/src/metadata/decorators.d.ts +1 -1
  129. package/src/metadata/decorators.js +1 -1
  130. package/src/metadata/decorators.js.map +1 -1
  131. package/src/metadata/decorators.metadata.json +1 -1
  132. package/src/metadata/metadata.d.ts +3 -3
  133. package/src/metadata/metadata.js +1 -1
  134. package/src/metadata/metadata.js.map +1 -1
  135. package/src/recognize.d.ts +3 -3
  136. package/src/recognize.js +62 -42
  137. package/src/recognize.js.map +1 -1
  138. package/src/router.d.ts +3 -23
  139. package/src/router.js +64 -64
  140. package/src/router.js.map +1 -1
  141. package/src/router_providers.d.ts +1 -1
  142. package/src/router_providers.js +3 -7
  143. package/src/router_providers.js.map +1 -1
  144. package/src/router_providers.metadata.json +1 -1
  145. package/src/router_providers_common.d.ts +7 -0
  146. package/src/router_providers_common.js +10 -5
  147. package/src/router_providers_common.js.map +1 -1
  148. package/src/router_providers_common.metadata.json +1 -1
  149. package/src/router_url_serializer.js +8 -8
  150. package/src/router_url_serializer.js.map +1 -1
  151. package/src/segments.d.ts +7 -12
  152. package/src/segments.js +26 -44
  153. package/src/segments.js.map +1 -1
  154. package/src/segments.metadata.json +1 -0
  155. package/testing/router_testing_providers.js +9 -2
  156. package/testing/router_testing_providers.js.map +1 -1
  157. package/testing/router_testing_providers.metadata.json +1 -1
  158. package/testing.js.map +1 -1
  159. package/esm/index.metadata.json +0 -1
  160. package/index.metadata.json +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v2.0.0-rc.1
2
+ * @license AngularJS v0.0.0-PLACEHOLDER
3
3
  * (c) 2010-2016 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -9,10 +9,10 @@ var __extends = (this && this.__extends) || function (d, b) {
9
9
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10
10
  };
11
11
  (function (global, factory) {
12
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/Subject'), require('rxjs/observable/PromiseObservable'), require('rxjs/operator/toPromise'), require('rxjs/Observable'), require('@angular/common'), require('@angular/platform-browser')) :
13
- typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/Subject', 'rxjs/observable/PromiseObservable', 'rxjs/operator/toPromise', 'rxjs/Observable', '@angular/common', '@angular/platform-browser'], factory) :
14
- (factory((global.ng = global.ng || {}, global.ng.router = global.ng.router || {}), global.ng.core, global.Rx, global.Rx, global.Rx.Observable.prototype, global.Rx, global.ng.common, global.ng.platformBrowser));
15
- }(this, function (exports, _angular_core, rxjs_Subject, rxjs_observable_PromiseObservable, rxjs_operator_toPromise, rxjs_Observable, _angular_common, _angular_platformBrowser) {
12
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('rxjs/Subject'), require('rxjs/observable/PromiseObservable'), require('rxjs/operator/toPromise'), require('rxjs/Observable')) :
13
+ typeof define === 'function' && define.amd ? define(['exports', '@angular/common', '@angular/core', 'rxjs/Subject', 'rxjs/observable/PromiseObservable', 'rxjs/operator/toPromise', 'rxjs/Observable'], factory) :
14
+ (factory((global.ng = global.ng || {}, global.ng.router = global.ng.router || {}), global.ng.common, global.ng.core, global.Rx, global.Rx, global.Rx.Observable.prototype, global.Rx));
15
+ }(this, function (exports, _angular_common, _angular_core, rxjs_Subject, rxjs_observable_PromiseObservable, rxjs_operator_toPromise, rxjs_Observable) {
16
16
  'use strict';
17
17
  var globalScope;
18
18
  if (typeof window === 'undefined') {
@@ -44,7 +44,7 @@ var __extends = (this && this.__extends) || function (d, b) {
44
44
  return obj === undefined || obj === null;
45
45
  }
46
46
  function isString(obj) {
47
- return typeof obj === "string";
47
+ return typeof obj === 'string';
48
48
  }
49
49
  function isStringMap(obj) {
50
50
  return typeof obj === 'object' && obj !== null;
@@ -67,9 +67,60 @@ var __extends = (this && this.__extends) || function (d, b) {
67
67
  return token.overriddenName;
68
68
  }
69
69
  var res = token.toString();
70
- var newLineIndex = res.indexOf("\n");
70
+ var newLineIndex = res.indexOf('\n');
71
71
  return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
72
72
  }
73
+ var NumberParseError = (function (_super) {
74
+ __extends(NumberParseError, _super);
75
+ function NumberParseError(message) {
76
+ _super.call(this);
77
+ this.message = message;
78
+ }
79
+ NumberParseError.prototype.toString = function () { return this.message; };
80
+ return NumberParseError;
81
+ }(Error));
82
+ var NumberWrapper = (function () {
83
+ function NumberWrapper() {
84
+ }
85
+ NumberWrapper.toFixed = function (n, fractionDigits) { return n.toFixed(fractionDigits); };
86
+ NumberWrapper.equal = function (a, b) { return a === b; };
87
+ NumberWrapper.parseIntAutoRadix = function (text) {
88
+ var result = parseInt(text);
89
+ if (isNaN(result)) {
90
+ throw new NumberParseError('Invalid integer literal when parsing ' + text);
91
+ }
92
+ return result;
93
+ };
94
+ NumberWrapper.parseInt = function (text, radix) {
95
+ if (radix == 10) {
96
+ if (/^(\-|\+)?[0-9]+$/.test(text)) {
97
+ return parseInt(text, radix);
98
+ }
99
+ }
100
+ else if (radix == 16) {
101
+ if (/^(\-|\+)?[0-9ABCDEFabcdef]+$/.test(text)) {
102
+ return parseInt(text, radix);
103
+ }
104
+ }
105
+ else {
106
+ var result = parseInt(text, radix);
107
+ if (!isNaN(result)) {
108
+ return result;
109
+ }
110
+ }
111
+ throw new NumberParseError('Invalid integer literal when parsing ' + text + ' in base ' + radix);
112
+ };
113
+ // TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
114
+ NumberWrapper.parseFloat = function (text) { return parseFloat(text); };
115
+ Object.defineProperty(NumberWrapper, "NaN", {
116
+ get: function () { return NaN; },
117
+ enumerable: true,
118
+ configurable: true
119
+ });
120
+ NumberWrapper.isNaN = function (value) { return isNaN(value); };
121
+ NumberWrapper.isInteger = function (value) { return Number.isInteger(value); };
122
+ return NumberWrapper;
123
+ }());
73
124
  var RegExpWrapper = (function () {
74
125
  function RegExpWrapper() {
75
126
  }
@@ -111,6 +162,182 @@ var __extends = (this && this.__extends) || function (d, b) {
111
162
  };
112
163
  return RegExpWrapper;
113
164
  }());
165
+ var PromiseCompleter = (function () {
166
+ function PromiseCompleter() {
167
+ var _this = this;
168
+ this.promise = new Promise(function (res, rej) {
169
+ _this.resolve = res;
170
+ _this.reject = rej;
171
+ });
172
+ }
173
+ return PromiseCompleter;
174
+ }());
175
+ var PromiseWrapper = (function () {
176
+ function PromiseWrapper() {
177
+ }
178
+ PromiseWrapper.resolve = function (obj) { return Promise.resolve(obj); };
179
+ PromiseWrapper.reject = function (obj, _) { return Promise.reject(obj); };
180
+ // Note: We can't rename this method into `catch`, as this is not a valid
181
+ // method name in Dart.
182
+ PromiseWrapper.catchError = function (promise, onError) {
183
+ return promise.catch(onError);
184
+ };
185
+ PromiseWrapper.all = function (promises) {
186
+ if (promises.length == 0)
187
+ return Promise.resolve([]);
188
+ return Promise.all(promises);
189
+ };
190
+ PromiseWrapper.then = function (promise, success, rejection) {
191
+ return promise.then(success, rejection);
192
+ };
193
+ PromiseWrapper.wrap = function (computation) {
194
+ return new Promise(function (res, rej) {
195
+ try {
196
+ res(computation());
197
+ }
198
+ catch (e) {
199
+ rej(e);
200
+ }
201
+ });
202
+ };
203
+ PromiseWrapper.scheduleMicrotask = function (computation) {
204
+ PromiseWrapper.then(PromiseWrapper.resolve(null), computation, function (_) { });
205
+ };
206
+ PromiseWrapper.isPromise = function (obj) { return obj instanceof Promise; };
207
+ PromiseWrapper.completer = function () { return new PromiseCompleter(); };
208
+ return PromiseWrapper;
209
+ }());
210
+ var ObservableWrapper = (function () {
211
+ function ObservableWrapper() {
212
+ }
213
+ // TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
214
+ ObservableWrapper.subscribe = function (emitter, onNext, onError, onComplete) {
215
+ if (onComplete === void 0) { onComplete = function () { }; }
216
+ onError = (typeof onError === 'function') && onError || noop;
217
+ onComplete = (typeof onComplete === 'function') && onComplete || noop;
218
+ return emitter.subscribe({ next: onNext, error: onError, complete: onComplete });
219
+ };
220
+ ObservableWrapper.isObservable = function (obs) { return !!obs.subscribe; };
221
+ /**
222
+ * Returns whether `obs` has any subscribers listening to events.
223
+ */
224
+ ObservableWrapper.hasSubscribers = function (obs) { return obs.observers.length > 0; };
225
+ ObservableWrapper.dispose = function (subscription) { subscription.unsubscribe(); };
226
+ /**
227
+ * @deprecated - use callEmit() instead
228
+ */
229
+ ObservableWrapper.callNext = function (emitter, value) { emitter.next(value); };
230
+ ObservableWrapper.callEmit = function (emitter, value) { emitter.emit(value); };
231
+ ObservableWrapper.callError = function (emitter, error) { emitter.error(error); };
232
+ ObservableWrapper.callComplete = function (emitter) { emitter.complete(); };
233
+ ObservableWrapper.fromPromise = function (promise) {
234
+ return rxjs_observable_PromiseObservable.PromiseObservable.create(promise);
235
+ };
236
+ ObservableWrapper.toPromise = function (obj) { return rxjs_operator_toPromise.toPromise.call(obj); };
237
+ return ObservableWrapper;
238
+ }());
239
+ /**
240
+ * Use by directives and components to emit custom Events.
241
+ *
242
+ * ### Examples
243
+ *
244
+ * In the following example, `Zippy` alternatively emits `open` and `close` events when its
245
+ * title gets clicked:
246
+ *
247
+ * ```
248
+ * @Component({
249
+ * selector: 'zippy',
250
+ * template: `
251
+ * <div class="zippy">
252
+ * <div (click)="toggle()">Toggle</div>
253
+ * <div [hidden]="!visible">
254
+ * <ng-content></ng-content>
255
+ * </div>
256
+ * </div>`})
257
+ * export class Zippy {
258
+ * visible: boolean = true;
259
+ * @Output() open: EventEmitter<any> = new EventEmitter();
260
+ * @Output() close: EventEmitter<any> = new EventEmitter();
261
+ *
262
+ * toggle() {
263
+ * this.visible = !this.visible;
264
+ * if (this.visible) {
265
+ * this.open.emit(null);
266
+ * } else {
267
+ * this.close.emit(null);
268
+ * }
269
+ * }
270
+ * }
271
+ * ```
272
+ *
273
+ * The events payload can be accessed by the parameter `$event` on the components output event
274
+ * handler:
275
+ *
276
+ * ```
277
+ * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
278
+ * ```
279
+ *
280
+ * Uses Rx.Observable but provides an adapter to make it work as specified here:
281
+ * https://github.com/jhusain/observable-spec
282
+ *
283
+ * Once a reference implementation of the spec is available, switch to it.
284
+ * @stable
285
+ */
286
+ var EventEmitter = (function (_super) {
287
+ __extends(EventEmitter, _super);
288
+ /**
289
+ * Creates an instance of [EventEmitter], which depending on [isAsync],
290
+ * delivers events synchronously or asynchronously.
291
+ */
292
+ function EventEmitter(isAsync) {
293
+ if (isAsync === void 0) { isAsync = false; }
294
+ _super.call(this);
295
+ this.__isAsync = isAsync;
296
+ }
297
+ EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
298
+ /**
299
+ * @deprecated - use .emit(value) instead
300
+ */
301
+ EventEmitter.prototype.next = function (value) { _super.prototype.next.call(this, value); };
302
+ EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
303
+ var schedulerFn;
304
+ var errorFn = function (err) { return null; };
305
+ var completeFn = function () { return null; };
306
+ if (generatorOrNext && typeof generatorOrNext === 'object') {
307
+ schedulerFn = this.__isAsync ? function (value /** TODO #9100 */) {
308
+ setTimeout(function () { return generatorOrNext.next(value); });
309
+ } : function (value /** TODO #9100 */) { generatorOrNext.next(value); };
310
+ if (generatorOrNext.error) {
311
+ errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
312
+ function (err) { generatorOrNext.error(err); };
313
+ }
314
+ if (generatorOrNext.complete) {
315
+ completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
316
+ function () { generatorOrNext.complete(); };
317
+ }
318
+ }
319
+ else {
320
+ schedulerFn = this.__isAsync ? function (value /** TODO #9100 */) {
321
+ setTimeout(function () { return generatorOrNext(value); });
322
+ } : function (value /** TODO #9100 */) { generatorOrNext(value); };
323
+ if (error) {
324
+ errorFn =
325
+ this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
326
+ }
327
+ if (complete) {
328
+ completeFn =
329
+ this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
330
+ }
331
+ }
332
+ return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
333
+ };
334
+ return EventEmitter;
335
+ }(rxjs_Subject.Subject));
336
+ /**
337
+ * Name of the default outlet outlet.
338
+ * @type {string}
339
+ */
340
+ var DEFAULT_OUTLET_NAME = '__DEFAULT';
114
341
  var Map$1 = global$1.Map;
115
342
  var Set = global$1.Set;
116
343
  // Safari and Internet Explorer do not support the iterable parameter to the
@@ -403,196 +630,57 @@ var __extends = (this && this.__extends) || function (d, b) {
403
630
  };
404
631
  }
405
632
  })();
406
- var PromiseCompleter = (function () {
407
- function PromiseCompleter() {
408
- var _this = this;
409
- this.promise = new Promise(function (res, rej) {
410
- _this.resolve = res;
411
- _this.reject = rej;
412
- });
633
+ function hasLifecycleHook(name, obj) {
634
+ if (isBlank(obj))
635
+ return false;
636
+ var type = obj.constructor;
637
+ if (!(type instanceof Type))
638
+ return false;
639
+ return name in type.prototype;
640
+ }
641
+ /**
642
+ * @stable
643
+ */
644
+ var BaseException$1 = (function (_super) {
645
+ __extends(BaseException$1, _super);
646
+ function BaseException$1(message) {
647
+ if (message === void 0) { message = '--'; }
648
+ _super.call(this, message);
649
+ this.message = message;
650
+ this.stack = (new Error(message)).stack;
413
651
  }
414
- return PromiseCompleter;
415
- }());
416
- var PromiseWrapper = (function () {
417
- function PromiseWrapper() {
652
+ BaseException$1.prototype.toString = function () { return this.message; };
653
+ return BaseException$1;
654
+ }(Error));
655
+ var Tree = (function () {
656
+ function Tree(root) {
657
+ this._root = root;
418
658
  }
419
- PromiseWrapper.resolve = function (obj) { return Promise.resolve(obj); };
420
- PromiseWrapper.reject = function (obj, _) { return Promise.reject(obj); };
421
- // Note: We can't rename this method into `catch`, as this is not a valid
422
- // method name in Dart.
423
- PromiseWrapper.catchError = function (promise, onError) {
424
- return promise.catch(onError);
425
- };
426
- PromiseWrapper.all = function (promises) {
427
- if (promises.length == 0)
428
- return Promise.resolve([]);
429
- return Promise.all(promises);
430
- };
431
- PromiseWrapper.then = function (promise, success, rejection) {
432
- return promise.then(success, rejection);
659
+ Object.defineProperty(Tree.prototype, "root", {
660
+ get: function () { return this._root.value; },
661
+ enumerable: true,
662
+ configurable: true
663
+ });
664
+ Tree.prototype.parent = function (t) {
665
+ var p = this.pathFromRoot(t);
666
+ return p.length > 1 ? p[p.length - 2] : null;
433
667
  };
434
- PromiseWrapper.wrap = function (computation) {
435
- return new Promise(function (res, rej) {
436
- try {
437
- res(computation());
438
- }
439
- catch (e) {
440
- rej(e);
441
- }
442
- });
668
+ Tree.prototype.children = function (t) {
669
+ var n = _findNode(t, this._root);
670
+ return isPresent(n) ? n.children.map(function (t) { return t.value; }) : null;
443
671
  };
444
- PromiseWrapper.scheduleMicrotask = function (computation) {
445
- PromiseWrapper.then(PromiseWrapper.resolve(null), computation, function (_) { });
672
+ Tree.prototype.firstChild = function (t) {
673
+ var n = _findNode(t, this._root);
674
+ return isPresent(n) && n.children.length > 0 ? n.children[0].value : null;
446
675
  };
447
- PromiseWrapper.isPromise = function (obj) { return obj instanceof Promise; };
448
- PromiseWrapper.completer = function () { return new PromiseCompleter(); };
449
- return PromiseWrapper;
676
+ Tree.prototype.pathFromRoot = function (t) { return _findPath(t, this._root, []).map(function (s) { return s.value; }); };
677
+ Tree.prototype.contains = function (tree) { return _contains(this._root, tree._root); };
678
+ return Tree;
450
679
  }());
451
- var ObservableWrapper = (function () {
452
- function ObservableWrapper() {
453
- }
454
- // TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
455
- ObservableWrapper.subscribe = function (emitter, onNext, onError, onComplete) {
456
- if (onComplete === void 0) { onComplete = function () { }; }
457
- onError = (typeof onError === "function") && onError || noop;
458
- onComplete = (typeof onComplete === "function") && onComplete || noop;
459
- return emitter.subscribe({ next: onNext, error: onError, complete: onComplete });
460
- };
461
- ObservableWrapper.isObservable = function (obs) { return !!obs.subscribe; };
462
- /**
463
- * Returns whether `obs` has any subscribers listening to events.
464
- */
465
- ObservableWrapper.hasSubscribers = function (obs) { return obs.observers.length > 0; };
466
- ObservableWrapper.dispose = function (subscription) { subscription.unsubscribe(); };
467
- /**
468
- * @deprecated - use callEmit() instead
469
- */
470
- ObservableWrapper.callNext = function (emitter, value) { emitter.next(value); };
471
- ObservableWrapper.callEmit = function (emitter, value) { emitter.emit(value); };
472
- ObservableWrapper.callError = function (emitter, error) { emitter.error(error); };
473
- ObservableWrapper.callComplete = function (emitter) { emitter.complete(); };
474
- ObservableWrapper.fromPromise = function (promise) {
475
- return rxjs_observable_PromiseObservable.PromiseObservable.create(promise);
476
- };
477
- ObservableWrapper.toPromise = function (obj) { return rxjs_operator_toPromise.toPromise.call(obj); };
478
- return ObservableWrapper;
479
- }());
480
- /**
481
- * Use by directives and components to emit custom Events.
482
- *
483
- * ### Examples
484
- *
485
- * In the following example, `Zippy` alternatively emits `open` and `close` events when its
486
- * title gets clicked:
487
- *
488
- * ```
489
- * @Component({
490
- * selector: 'zippy',
491
- * template: `
492
- * <div class="zippy">
493
- * <div (click)="toggle()">Toggle</div>
494
- * <div [hidden]="!visible">
495
- * <ng-content></ng-content>
496
- * </div>
497
- * </div>`})
498
- * export class Zippy {
499
- * visible: boolean = true;
500
- * @Output() open: EventEmitter<any> = new EventEmitter();
501
- * @Output() close: EventEmitter<any> = new EventEmitter();
502
- *
503
- * toggle() {
504
- * this.visible = !this.visible;
505
- * if (this.visible) {
506
- * this.open.emit(null);
507
- * } else {
508
- * this.close.emit(null);
509
- * }
510
- * }
511
- * }
512
- * ```
513
- *
514
- * Use Rx.Observable but provides an adapter to make it work as specified here:
515
- * https://github.com/jhusain/observable-spec
516
- *
517
- * Once a reference implementation of the spec is available, switch to it.
518
- */
519
- var EventEmitter = (function (_super) {
520
- __extends(EventEmitter, _super);
521
- /**
522
- * Creates an instance of [EventEmitter], which depending on [isAsync],
523
- * delivers events synchronously or asynchronously.
524
- */
525
- function EventEmitter(isAsync) {
526
- if (isAsync === void 0) { isAsync = true; }
527
- _super.call(this);
528
- this._isAsync = isAsync;
529
- }
530
- EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
531
- /**
532
- * @deprecated - use .emit(value) instead
533
- */
534
- EventEmitter.prototype.next = function (value) { _super.prototype.next.call(this, value); };
535
- EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
536
- var schedulerFn;
537
- var errorFn = function (err) { return null; };
538
- var completeFn = function () { return null; };
539
- if (generatorOrNext && typeof generatorOrNext === 'object') {
540
- schedulerFn = this._isAsync ? function (value) { setTimeout(function () { return generatorOrNext.next(value); }); } :
541
- function (value) { generatorOrNext.next(value); };
542
- if (generatorOrNext.error) {
543
- errorFn = this._isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
544
- function (err) { generatorOrNext.error(err); };
545
- }
546
- if (generatorOrNext.complete) {
547
- completeFn = this._isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
548
- function () { generatorOrNext.complete(); };
549
- }
550
- }
551
- else {
552
- schedulerFn = this._isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
553
- function (value) { generatorOrNext(value); };
554
- if (error) {
555
- errorFn =
556
- this._isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
557
- }
558
- if (complete) {
559
- completeFn =
560
- this._isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
561
- }
562
- }
563
- return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
564
- };
565
- return EventEmitter;
566
- }(rxjs_Subject.Subject));
567
- var Tree = (function () {
568
- function Tree(root) {
569
- this._root = root;
570
- }
571
- Object.defineProperty(Tree.prototype, "root", {
572
- get: function () { return this._root.value; },
573
- enumerable: true,
574
- configurable: true
575
- });
576
- Tree.prototype.parent = function (t) {
577
- var p = this.pathFromRoot(t);
578
- return p.length > 1 ? p[p.length - 2] : null;
579
- };
580
- Tree.prototype.children = function (t) {
581
- var n = _findNode(t, this._root);
582
- return isPresent(n) ? n.children.map(function (t) { return t.value; }) : null;
583
- };
584
- Tree.prototype.firstChild = function (t) {
585
- var n = _findNode(t, this._root);
586
- return isPresent(n) && n.children.length > 0 ? n.children[0].value : null;
587
- };
588
- Tree.prototype.pathFromRoot = function (t) { return _findPath(t, this._root, []).map(function (s) { return s.value; }); };
589
- Tree.prototype.contains = function (tree) { return _contains(this._root, tree._root); };
590
- return Tree;
591
- }());
592
- var UrlTree = (function (_super) {
593
- __extends(UrlTree, _super);
594
- function UrlTree(root) {
595
- _super.call(this, root);
680
+ var UrlTree = (function (_super) {
681
+ __extends(UrlTree, _super);
682
+ function UrlTree(root) {
683
+ _super.call(this, root);
596
684
  }
597
685
  return UrlTree;
598
686
  }(Tree));
@@ -607,9 +695,6 @@ var __extends = (this && this.__extends) || function (d, b) {
607
695
  return tree._root;
608
696
  }
609
697
  function _findNode(expected, c) {
610
- // TODO: vsavkin remove it once recognize is fixed
611
- if (expected instanceof RouteSegment && equalSegments(expected, c.value))
612
- return c;
613
698
  if (expected === c.value)
614
699
  return c;
615
700
  for (var _i = 0, _a = c.children; _i < _a.length; _i++) {
@@ -622,8 +707,7 @@ var __extends = (this && this.__extends) || function (d, b) {
622
707
  }
623
708
  function _findPath(expected, c, collected) {
624
709
  collected.push(c);
625
- // TODO: vsavkin remove it once recognize is fixed
626
- if (_equalValues(expected, c.value))
710
+ if (expected === c.value)
627
711
  return collected;
628
712
  for (var _i = 0, _a = c.children; _i < _a.length; _i++) {
629
713
  var cc = _a[_i];
@@ -634,10 +718,10 @@ var __extends = (this && this.__extends) || function (d, b) {
634
718
  return null;
635
719
  }
636
720
  function _contains(tree, subtree) {
637
- if (!_equalValues(tree.value, subtree.value))
721
+ if (tree.value !== subtree.value)
638
722
  return false;
639
723
  var _loop_1 = function(subtreeNode) {
640
- var s = tree.children.filter(function (child) { return _equalValues(child.value, subtreeNode.value); });
724
+ var s = tree.children.filter(function (child) { return child.value === subtreeNode.value; });
641
725
  if (s.length === 0)
642
726
  return { value: false };
643
727
  if (!_contains(s[0], subtreeNode))
@@ -650,13 +734,6 @@ var __extends = (this && this.__extends) || function (d, b) {
650
734
  }
651
735
  return true;
652
736
  }
653
- function _equalValues(a, b) {
654
- if (a instanceof RouteSegment)
655
- return equalSegments(a, b);
656
- if (a instanceof UrlSegment)
657
- return equalUrlSegments(a, b);
658
- return a === b;
659
- }
660
737
  var TreeNode = (function () {
661
738
  function TreeNode(value, children) {
662
739
  this.value = value;
@@ -671,14 +748,14 @@ var __extends = (this && this.__extends) || function (d, b) {
671
748
  this.outlet = outlet;
672
749
  }
673
750
  UrlSegment.prototype.toString = function () {
674
- var outletPrefix = isBlank(this.outlet) ? "" : this.outlet + ":";
751
+ var outletPrefix = isBlank(this.outlet) ? '' : this.outlet + ":";
675
752
  return "" + outletPrefix + this.segment + _serializeParams(this.parameters);
676
753
  };
677
754
  return UrlSegment;
678
755
  }());
679
756
  function _serializeParams(params) {
680
- var res = "";
681
- StringMapWrapper.forEach(params, function (v, k) { return res += ";" + k + "=" + v; });
757
+ var res = '';
758
+ StringMapWrapper.forEach(params, function (v /** TODO #9100 */, k /** TODO #9100 */) { return res += ";" + k + "=" + v; });
682
759
  return res;
683
760
  }
684
761
  var RouteSegment = (function () {
@@ -692,233 +769,41 @@ var __extends = (this && this.__extends) || function (d, b) {
692
769
  RouteSegment.prototype.getParam = function (param) {
693
770
  return isPresent(this.parameters) ? this.parameters[param] : null;
694
771
  };
772
+ RouteSegment.prototype.getParamAsNumber = function (param) {
773
+ return isPresent(this.parameters) ? NumberWrapper.parseFloat(this.parameters[param]) : null;
774
+ };
695
775
  Object.defineProperty(RouteSegment.prototype, "type", {
696
776
  get: function () { return this._type; },
697
777
  enumerable: true,
698
778
  configurable: true
699
779
  });
700
780
  Object.defineProperty(RouteSegment.prototype, "stringifiedUrlSegments", {
701
- get: function () { return this.urlSegments.map(function (s) { return s.toString(); }).join("/"); },
781
+ get: function () { return this.urlSegments.map(function (s) { return s.toString(); }).join('/'); },
702
782
  enumerable: true,
703
783
  configurable: true
704
784
  });
705
785
  return RouteSegment;
706
786
  }());
707
- function equalSegments(a, b) {
708
- if (isBlank(a) && !isBlank(b))
709
- return false;
710
- if (!isBlank(a) && isBlank(b))
711
- return false;
712
- if (a._type !== b._type)
713
- return false;
714
- if (a.outlet != b.outlet)
715
- return false;
716
- return StringMapWrapper.equals(a.parameters, b.parameters);
787
+ function createEmptyRouteTree(type) {
788
+ var root = new RouteSegment([new UrlSegment('', {}, null)], {}, DEFAULT_OUTLET_NAME, type, null);
789
+ return new RouteTree(new TreeNode(root, []));
717
790
  }
718
791
  function equalUrlSegments(a, b) {
719
- if (isBlank(a) && !isBlank(b))
720
- return false;
721
- if (!isBlank(a) && isBlank(b))
722
- return false;
723
- if (a.segment != b.segment)
792
+ if (a.length !== b.length)
724
793
  return false;
725
- if (a.outlet != b.outlet)
726
- return false;
727
- if (isBlank(a.parameters)) {
728
- console.log("a", a);
729
- }
730
- if (isBlank(b.parameters)) {
731
- console.log("b", b);
794
+ for (var i = 0; i < a.length; ++i) {
795
+ if (a[i].segment != b[i].segment)
796
+ return false;
797
+ if (a[i].outlet != b[i].outlet)
798
+ return false;
799
+ if (!StringMapWrapper.equals(a[i].parameters, b[i].parameters))
800
+ return false;
732
801
  }
733
- return StringMapWrapper.equals(a.parameters, b.parameters);
802
+ return true;
734
803
  }
735
804
  function routeSegmentComponentFactory(a) {
736
805
  return a._componentFactory;
737
806
  }
738
- /**
739
- * See {@link RouteMetadata} for more information.
740
- * @ts2dart_const
741
- */
742
- var Route = (function () {
743
- function Route(_a) {
744
- var _b = _a === void 0 ? {} : _a, path = _b.path, component = _b.component;
745
- this.path = path;
746
- this.component = component;
747
- }
748
- Route.prototype.toString = function () { return "@Route(" + this.path + ", " + stringify(this.component) + ")"; };
749
- return Route;
750
- }());
751
- /**
752
- * Defines routes for a given component.
753
- *
754
- * It takes an array of {@link RouteMetadata}s.
755
- * @ts2dart_const
756
- */
757
- var RoutesMetadata = (function () {
758
- function RoutesMetadata(routes) {
759
- this.routes = routes;
760
- }
761
- RoutesMetadata.prototype.toString = function () { return "@Routes(" + this.routes + ")"; };
762
- return RoutesMetadata;
763
- }());
764
- /**
765
- * Name of the default outlet outlet.
766
- * @type {string}
767
- */
768
- var DEFAULT_OUTLET_NAME = "__DEFAULT";
769
- // TODO: vsavkin: recognize should take the old tree and merge it
770
- function recognize(componentResolver, type, url) {
771
- var matched = new _MatchResult(type, [url.root], {}, rootNode(url).children, []);
772
- return _constructSegment(componentResolver, matched).then(function (roots) { return new RouteTree(roots[0]); });
773
- }
774
- function _recognize(componentResolver, parentType, url) {
775
- var metadata = _readMetadata(parentType); // should read from the factory instead
776
- if (isBlank(metadata)) {
777
- throw new _angular_core.BaseException("Component '" + stringify(parentType) + "' does not have route configuration");
778
- }
779
- var match;
780
- try {
781
- match = _match(metadata, url);
782
- }
783
- catch (e) {
784
- return PromiseWrapper.reject(e, null);
785
- }
786
- var main = _constructSegment(componentResolver, match);
787
- var aux = _recognizeMany(componentResolver, parentType, match.aux).then(_checkOutletNameUniqueness);
788
- return PromiseWrapper.all([main, aux]).then(ListWrapper.flatten);
789
- }
790
- function _recognizeMany(componentResolver, parentType, urls) {
791
- var recognized = urls.map(function (u) { return _recognize(componentResolver, parentType, u); });
792
- return PromiseWrapper.all(recognized).then(ListWrapper.flatten);
793
- }
794
- function _constructSegment(componentResolver, matched) {
795
- return componentResolver.resolveComponent(matched.component)
796
- .then(function (factory) {
797
- var urlOutlet = matched.consumedUrlSegments.length === 0 ||
798
- isBlank(matched.consumedUrlSegments[0].outlet) ?
799
- DEFAULT_OUTLET_NAME :
800
- matched.consumedUrlSegments[0].outlet;
801
- var segment = new RouteSegment(matched.consumedUrlSegments, matched.parameters, urlOutlet, matched.component, factory);
802
- if (matched.leftOverUrl.length > 0) {
803
- return _recognizeMany(componentResolver, matched.component, matched.leftOverUrl)
804
- .then(function (children) { return [new TreeNode(segment, children)]; });
805
- }
806
- else {
807
- return _recognizeLeftOvers(componentResolver, matched.component)
808
- .then(function (children) { return [new TreeNode(segment, children)]; });
809
- }
810
- });
811
- }
812
- function _recognizeLeftOvers(componentResolver, parentType) {
813
- return componentResolver.resolveComponent(parentType)
814
- .then(function (factory) {
815
- var metadata = _readMetadata(parentType);
816
- if (isBlank(metadata)) {
817
- return [];
818
- }
819
- var r = metadata.routes.filter(function (r) { return r.path == "" || r.path == "/"; });
820
- if (r.length === 0) {
821
- return PromiseWrapper.resolve([]);
822
- }
823
- else {
824
- return _recognizeLeftOvers(componentResolver, r[0].component)
825
- .then(function (children) {
826
- return componentResolver.resolveComponent(r[0].component)
827
- .then(function (factory) {
828
- var segment = new RouteSegment([], {}, DEFAULT_OUTLET_NAME, r[0].component, factory);
829
- return [new TreeNode(segment, children)];
830
- });
831
- });
832
- }
833
- });
834
- }
835
- function _match(metadata, url) {
836
- for (var _i = 0, _a = metadata.routes; _i < _a.length; _i++) {
837
- var r = _a[_i];
838
- var matchingResult = _matchWithParts(r, url);
839
- if (isPresent(matchingResult)) {
840
- return matchingResult;
841
- }
842
- }
843
- var availableRoutes = metadata.routes.map(function (r) { return ("'" + r.path + "'"); }).join(", ");
844
- throw new _angular_core.BaseException("Cannot match any routes. Current segment: '" + url.value + "'. Available routes: [" + availableRoutes + "].");
845
- }
846
- function _matchWithParts(route, url) {
847
- var path = route.path.startsWith("/") ? route.path.substring(1) : route.path;
848
- if (path == "*") {
849
- return new _MatchResult(route.component, [], null, [], []);
850
- }
851
- var parts = path.split("/");
852
- var positionalParams = {};
853
- var consumedUrlSegments = [];
854
- var lastParent = null;
855
- var lastSegment = null;
856
- var current = url;
857
- for (var i = 0; i < parts.length; ++i) {
858
- if (isBlank(current))
859
- return null;
860
- var p_1 = parts[i];
861
- var isLastSegment = i === parts.length - 1;
862
- var isLastParent = i === parts.length - 2;
863
- var isPosParam = p_1.startsWith(":");
864
- if (!isPosParam && p_1 != current.value.segment)
865
- return null;
866
- if (isLastSegment) {
867
- lastSegment = current;
868
- }
869
- if (isLastParent) {
870
- lastParent = current;
871
- }
872
- if (isPosParam) {
873
- positionalParams[p_1.substring(1)] = current.value.segment;
874
- }
875
- consumedUrlSegments.push(current.value);
876
- current = ListWrapper.first(current.children);
877
- }
878
- var p = lastSegment.value.parameters;
879
- var parameters = StringMapWrapper.merge(p, positionalParams);
880
- var axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : [];
881
- return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children, axuUrlSubtrees);
882
- }
883
- function _checkOutletNameUniqueness(nodes) {
884
- var names = {};
885
- nodes.forEach(function (n) {
886
- var segmentWithSameOutletName = names[n.value.outlet];
887
- if (isPresent(segmentWithSameOutletName)) {
888
- var p = segmentWithSameOutletName.stringifiedUrlSegments;
889
- var c = n.value.stringifiedUrlSegments;
890
- throw new _angular_core.BaseException("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
891
- }
892
- names[n.value.outlet] = n.value;
893
- });
894
- return nodes;
895
- }
896
- var _MatchResult = (function () {
897
- function _MatchResult(component, consumedUrlSegments, parameters, leftOverUrl, aux) {
898
- this.component = component;
899
- this.consumedUrlSegments = consumedUrlSegments;
900
- this.parameters = parameters;
901
- this.leftOverUrl = leftOverUrl;
902
- this.aux = aux;
903
- }
904
- return _MatchResult;
905
- }());
906
- function _readMetadata(componentType) {
907
- var metadata = _angular_core.reflector.annotations(componentType).filter(function (f) { return f instanceof RoutesMetadata; });
908
- return ListWrapper.first(metadata);
909
- }
910
- var BaseException$1 = (function (_super) {
911
- __extends(BaseException$1, _super);
912
- function BaseException$1(message) {
913
- if (message === void 0) { message = "--"; }
914
- _super.call(this, message);
915
- this.message = message;
916
- this.stack = (new Error(message)).stack;
917
- }
918
- BaseException$1.prototype.toString = function () { return this.message; };
919
- return BaseException$1;
920
- }(Error));
921
- // TODO: vsavkin: should reuse segments
922
807
  function link(segment, routeTree, urlTree, commands) {
923
808
  if (commands.length === 0)
924
809
  return urlTree;
@@ -928,12 +813,14 @@ var __extends = (this && this.__extends) || function (d, b) {
928
813
  }
929
814
  var startingNode = _findStartingNode(normalizedCommands, urlTree, segment, routeTree);
930
815
  var updated = normalizedCommands.commands.length > 0 ?
931
- _updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) : [];
816
+ _updateMany(ListWrapper.clone(startingNode.children), normalizedCommands.commands) :
817
+ [];
932
818
  var newRoot = _constructNewTree(rootNode(urlTree), startingNode, updated);
933
819
  return new UrlTree(newRoot);
934
820
  }
935
821
  function _navigateToRoot(normalizedChange) {
936
- return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 && normalizedChange.commands[0] == "/";
822
+ return normalizedChange.isAbsolute && normalizedChange.commands.length === 1 &&
823
+ normalizedChange.commands[0] == '/';
937
824
  }
938
825
  var _NormalizedNavigationCommands = (function () {
939
826
  function _NormalizedNavigationCommands(isAbsolute, numberOfDoubleDots, commands) {
@@ -944,9 +831,7 @@ var __extends = (this && this.__extends) || function (d, b) {
944
831
  return _NormalizedNavigationCommands;
945
832
  }());
946
833
  function _normalizeCommands(commands) {
947
- ;
948
- '';
949
- if (isString(commands[0]) && commands.length === 1 && commands[0] == "/") {
834
+ if (isString(commands[0]) && commands.length === 1 && commands[0] == '/') {
950
835
  return new _NormalizedNavigationCommands(true, 0, commands);
951
836
  }
952
837
  var numberOfDoubleDots = 0;
@@ -963,12 +848,12 @@ var __extends = (this && this.__extends) || function (d, b) {
963
848
  var cc = parts[j];
964
849
  // first exp is treated in a special way
965
850
  if (i == 0) {
966
- if (j == 0 && cc == ".") {
851
+ if (j == 0 && cc == '.') {
967
852
  }
968
- else if (j == 0 && cc == "") {
853
+ else if (j == 0 && cc == '') {
969
854
  isAbsolute = true;
970
855
  }
971
- else if (cc == "..") {
856
+ else if (cc == '..') {
972
857
  numberOfDoubleDots++;
973
858
  }
974
859
  else if (cc != '') {
@@ -992,7 +877,7 @@ var __extends = (this && this.__extends) || function (d, b) {
992
877
  var urlSegment = ListWrapper.last(s.urlSegments);
993
878
  var path = urlTree.pathFromRoot(urlSegment);
994
879
  if (path.length <= numberOfDoubleDots) {
995
- throw new BaseException$1("Invalid number of '../'");
880
+ throw new BaseException$1('Invalid number of \'../\'');
996
881
  }
997
882
  return path[path.length - 1 - numberOfDoubleDots];
998
883
  }
@@ -1036,25 +921,39 @@ var __extends = (this && this.__extends) || function (d, b) {
1036
921
  return new TreeNode(urlSegment, children);
1037
922
  }
1038
923
  else if (isBlank(node) && isStringMap(next)) {
1039
- var urlSegment = new UrlSegment(segment, next, outlet);
924
+ var urlSegment = new UrlSegment(segment, _stringify(next), outlet);
1040
925
  return _recurse(urlSegment, node, rest.slice(1));
1041
926
  }
1042
927
  else if (outlet != node.value.outlet) {
1043
928
  return node;
1044
929
  }
1045
930
  else if (isStringMap(segment)) {
1046
- var newSegment = new UrlSegment(node.value.segment, segment, node.value.outlet);
931
+ var newSegment = new UrlSegment(node.value.segment, _stringify(segment), node.value.outlet);
1047
932
  return _recurse(newSegment, node, rest);
1048
933
  }
934
+ else if (isStringMap(next) && _compare(segment, _stringify(next), node.value)) {
935
+ return _recurse(node.value, node, rest.slice(1));
936
+ }
1049
937
  else if (isStringMap(next)) {
1050
- var urlSegment = new UrlSegment(segment, next, outlet);
938
+ var urlSegment = new UrlSegment(segment, _stringify(next), outlet);
1051
939
  return _recurse(urlSegment, node, rest.slice(1));
1052
940
  }
941
+ else if (_compare(segment, {}, node.value)) {
942
+ return _recurse(node.value, node, rest);
943
+ }
1053
944
  else {
1054
945
  var urlSegment = new UrlSegment(segment, {}, outlet);
1055
946
  return _recurse(urlSegment, node, rest);
1056
947
  }
1057
948
  }
949
+ function _stringify(params) {
950
+ var res = {};
951
+ StringMapWrapper.forEach(params, function (v /** TODO #9100 */, k /** TODO #9100 */) { return res[k] = v.toString(); });
952
+ return res;
953
+ }
954
+ function _compare(path, params, segment) {
955
+ return path == segment.segment && StringMapWrapper.equals(params, segment.parameters);
956
+ }
1058
957
  function _recurse(urlSegment, node, rest) {
1059
958
  if (rest.length === 0) {
1060
959
  return new TreeNode(urlSegment, []);
@@ -1076,26 +975,204 @@ var __extends = (this && this.__extends) || function (d, b) {
1076
975
  function _segment(commands) {
1077
976
  if (!isString(commands[0]))
1078
977
  return commands[0];
1079
- var parts = commands[0].toString().split(":");
978
+ var parts = commands[0].toString().split(':');
1080
979
  return parts.length > 1 ? parts[1] : commands[0];
1081
980
  }
1082
981
  function _outlet(commands) {
1083
982
  if (!isString(commands[0]))
1084
983
  return null;
1085
- var parts = commands[0].toString().split(":");
984
+ var parts = commands[0].toString().split(':');
1086
985
  return parts.length > 1 ? parts[0] : null;
1087
986
  }
1088
- function hasLifecycleHook(name, obj) {
1089
- if (isBlank(obj))
1090
- return false;
1091
- var type = obj.constructor;
1092
- if (!(type instanceof Type))
1093
- return false;
1094
- return name in type.prototype;
987
+ var makeDecorator = _angular_core.__core_private__.makeDecorator;
988
+ var reflector = _angular_core.__core_private__.reflector;
989
+ /**
990
+ * See {@link RouteMetadata} for more information.
991
+ * @ts2dart_const
992
+ */
993
+ var Route = (function () {
994
+ function Route(_a) {
995
+ var _b = _a === void 0 ? {} : _a, path = _b.path, component = _b.component;
996
+ this.path = path;
997
+ this.component = component;
998
+ }
999
+ Route.prototype.toString = function () { return "@Route(" + this.path + ", " + stringify(this.component) + ")"; };
1000
+ return Route;
1001
+ }());
1002
+ /**
1003
+ * Defines routes for a given component.
1004
+ *
1005
+ * It takes an array of {@link RouteMetadata}s.
1006
+ * @ts2dart_const
1007
+ */
1008
+ var RoutesMetadata = (function () {
1009
+ function RoutesMetadata(routes) {
1010
+ this.routes = routes;
1011
+ }
1012
+ RoutesMetadata.prototype.toString = function () { return "@Routes(" + this.routes + ")"; };
1013
+ return RoutesMetadata;
1014
+ }());
1015
+ function recognize(componentResolver, rootComponent, url, existingTree) {
1016
+ var matched = new _MatchResult(rootComponent, [url.root], {}, rootNode(url).children, []);
1017
+ return _constructSegment(componentResolver, matched, rootNode(existingTree))
1018
+ .then(function (roots) { return new RouteTree(roots[0]); });
1019
+ }
1020
+ function _recognize(componentResolver, parentComponent, url, existingSegments) {
1021
+ var metadata = _readMetadata(parentComponent); // should read from the factory instead
1022
+ if (isBlank(metadata)) {
1023
+ throw new _angular_core.BaseException("Component '" + stringify(parentComponent) + "' does not have route configuration");
1024
+ }
1025
+ var match;
1026
+ try {
1027
+ match = _match(metadata, url);
1028
+ }
1029
+ catch (e) {
1030
+ return PromiseWrapper.reject(e, null);
1031
+ }
1032
+ var segmentsWithRightOutlet = existingSegments.filter(function (r) { return r.value.outlet == match.outlet; });
1033
+ var segmentWithRightOutlet = segmentsWithRightOutlet.length > 0 ? segmentsWithRightOutlet[0] : null;
1034
+ var main = _constructSegment(componentResolver, match, segmentWithRightOutlet);
1035
+ var aux = _recognizeMany(componentResolver, parentComponent, match.aux, existingSegments)
1036
+ .then(_checkOutletNameUniqueness);
1037
+ return PromiseWrapper.all([main, aux]).then(ListWrapper.flatten);
1038
+ }
1039
+ function _recognizeMany(componentResolver, parentComponent, urls, existingSegments) {
1040
+ var recognized = urls.map(function (u) { return _recognize(componentResolver, parentComponent, u, existingSegments); });
1041
+ return PromiseWrapper.all(recognized).then(ListWrapper.flatten);
1042
+ }
1043
+ function _constructSegment(componentResolver, matched, existingSegment) {
1044
+ return componentResolver.resolveComponent(matched.component).then(function (factory) {
1045
+ var segment = _createOrReuseSegment(matched, factory, existingSegment);
1046
+ var existingChildren = isPresent(existingSegment) ? existingSegment.children : [];
1047
+ if (matched.leftOverUrl.length > 0) {
1048
+ return _recognizeMany(componentResolver, factory.componentType, matched.leftOverUrl, existingChildren)
1049
+ .then(function (children) { return [new TreeNode(segment, children)]; });
1050
+ }
1051
+ else {
1052
+ return _recognizeLeftOvers(componentResolver, factory.componentType, existingChildren)
1053
+ .then(function (children) { return [new TreeNode(segment, children)]; });
1054
+ }
1055
+ });
1056
+ }
1057
+ function _createOrReuseSegment(matched, factory, segmentNode) {
1058
+ var segment = isPresent(segmentNode) ? segmentNode.value : null;
1059
+ if (isPresent(segment) && equalUrlSegments(segment.urlSegments, matched.consumedUrlSegments) &&
1060
+ StringMapWrapper.equals(segment.parameters, matched.parameters) &&
1061
+ segment.outlet == matched.outlet && factory.componentType == segment.type) {
1062
+ return segment;
1063
+ }
1064
+ else {
1065
+ return new RouteSegment(matched.consumedUrlSegments, matched.parameters, matched.outlet, factory.componentType, factory);
1066
+ }
1067
+ }
1068
+ function _recognizeLeftOvers(componentResolver, parentComponent, existingSegments) {
1069
+ return componentResolver.resolveComponent(parentComponent).then(function (factory) {
1070
+ var metadata = _readMetadata(factory.componentType);
1071
+ if (isBlank(metadata)) {
1072
+ return [];
1073
+ }
1074
+ var r = metadata.routes.filter(function (r) { return r.path == '' || r.path == '/'; });
1075
+ if (r.length === 0) {
1076
+ return PromiseWrapper.resolve([]);
1077
+ }
1078
+ else {
1079
+ var segmentsWithMatchingOutlet = existingSegments.filter(function (r) { return r.value.outlet == DEFAULT_OUTLET_NAME; });
1080
+ var segmentWithMatchingOutlet_1 = segmentsWithMatchingOutlet.length > 0 ? segmentsWithMatchingOutlet[0] : null;
1081
+ var existingChildren = isPresent(segmentWithMatchingOutlet_1) ? segmentWithMatchingOutlet_1.children : [];
1082
+ return _recognizeLeftOvers(componentResolver, r[0].component, existingChildren)
1083
+ .then(function (children) {
1084
+ return componentResolver.resolveComponent(r[0].component).then(function (factory) {
1085
+ var segment = _createOrReuseSegment(new _MatchResult(r[0].component, [], {}, [], []), factory, segmentWithMatchingOutlet_1);
1086
+ return [new TreeNode(segment, children)];
1087
+ });
1088
+ });
1089
+ }
1090
+ });
1091
+ }
1092
+ function _match(metadata, url) {
1093
+ for (var _i = 0, _a = metadata.routes; _i < _a.length; _i++) {
1094
+ var r = _a[_i];
1095
+ var matchingResult = _matchWithParts(r, url);
1096
+ if (isPresent(matchingResult)) {
1097
+ return matchingResult;
1098
+ }
1099
+ }
1100
+ var availableRoutes = metadata.routes.map(function (r) { return ("'" + r.path + "'"); }).join(', ');
1101
+ throw new _angular_core.BaseException("Cannot match any routes. Current segment: '" + url.value + "'. Available routes: [" + availableRoutes + "].");
1102
+ }
1103
+ function _matchWithParts(route, url) {
1104
+ var path = route.path.startsWith('/') ? route.path.substring(1) : route.path;
1105
+ if (path == '*') {
1106
+ return new _MatchResult(route.component, [], null, [], []);
1107
+ }
1108
+ var parts = path.split('/');
1109
+ var positionalParams = {};
1110
+ var consumedUrlSegments = [];
1111
+ var lastParent = null;
1112
+ var lastSegment = null;
1113
+ var current = url;
1114
+ for (var i = 0; i < parts.length; ++i) {
1115
+ if (isBlank(current))
1116
+ return null;
1117
+ var p_1 = parts[i];
1118
+ var isLastSegment = i === parts.length - 1;
1119
+ var isLastParent = i === parts.length - 2;
1120
+ var isPosParam = p_1.startsWith(':');
1121
+ if (!isPosParam && p_1 != current.value.segment)
1122
+ return null;
1123
+ if (isLastSegment) {
1124
+ lastSegment = current;
1125
+ }
1126
+ if (isLastParent) {
1127
+ lastParent = current;
1128
+ }
1129
+ if (isPosParam) {
1130
+ positionalParams[p_1.substring(1)] = current.value.segment;
1131
+ }
1132
+ consumedUrlSegments.push(current.value);
1133
+ current = ListWrapper.first(current.children);
1134
+ }
1135
+ var p = lastSegment.value.parameters;
1136
+ var parameters = StringMapWrapper.merge(p, positionalParams);
1137
+ var axuUrlSubtrees = isPresent(lastParent) ? lastParent.children.slice(1) : [];
1138
+ return new _MatchResult(route.component, consumedUrlSegments, parameters, lastSegment.children, axuUrlSubtrees);
1139
+ }
1140
+ function _checkOutletNameUniqueness(nodes) {
1141
+ var names = {};
1142
+ nodes.forEach(function (n) {
1143
+ var segmentWithSameOutletName = names[n.value.outlet];
1144
+ if (isPresent(segmentWithSameOutletName)) {
1145
+ var p = segmentWithSameOutletName.stringifiedUrlSegments;
1146
+ var c = n.value.stringifiedUrlSegments;
1147
+ throw new _angular_core.BaseException("Two segments cannot have the same outlet name: '" + p + "' and '" + c + "'.");
1148
+ }
1149
+ names[n.value.outlet] = n.value;
1150
+ });
1151
+ return nodes;
1152
+ }
1153
+ var _MatchResult = (function () {
1154
+ function _MatchResult(component, consumedUrlSegments, parameters, leftOverUrl, aux) {
1155
+ this.component = component;
1156
+ this.consumedUrlSegments = consumedUrlSegments;
1157
+ this.parameters = parameters;
1158
+ this.leftOverUrl = leftOverUrl;
1159
+ this.aux = aux;
1160
+ }
1161
+ Object.defineProperty(_MatchResult.prototype, "outlet", {
1162
+ get: function () {
1163
+ return this.consumedUrlSegments.length === 0 || isBlank(this.consumedUrlSegments[0].outlet) ?
1164
+ DEFAULT_OUTLET_NAME :
1165
+ this.consumedUrlSegments[0].outlet;
1166
+ },
1167
+ enumerable: true,
1168
+ configurable: true
1169
+ });
1170
+ return _MatchResult;
1171
+ }());
1172
+ function _readMetadata(componentType) {
1173
+ var metadata = reflector.annotations(componentType).filter(function (f) { return f instanceof RoutesMetadata; });
1174
+ return ListWrapper.first(metadata);
1095
1175
  }
1096
- /**
1097
- * @internal
1098
- */
1099
1176
  var RouterOutletMap = (function () {
1100
1177
  function RouterOutletMap() {
1101
1178
  /** @internal */
@@ -1122,7 +1199,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1122
1199
  this._routerOutletMap = _routerOutletMap;
1123
1200
  this._location = _location;
1124
1201
  this._changes = new EventEmitter();
1125
- this._prevTree = this._createInitialTree();
1202
+ this._routeTree = createEmptyRouteTree(this._rootComponentType);
1126
1203
  this._setUpLocationChangeListener();
1127
1204
  this.navigateByUrl(this._location.path());
1128
1205
  }
@@ -1138,7 +1215,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1138
1215
  /**
1139
1216
  * Returns the current route tree.
1140
1217
  */
1141
- get: function () { return this._prevTree; },
1218
+ get: function () { return this._routeTree; },
1142
1219
  enumerable: true,
1143
1220
  configurable: true
1144
1221
  });
@@ -1211,32 +1288,36 @@ var __extends = (this && this.__extends) || function (d, b) {
1211
1288
  * ```
1212
1289
  */
1213
1290
  Router.prototype.createUrlTree = function (commands, segment) {
1214
- var s = isPresent(segment) ? segment : this._prevTree.root;
1215
- return link(s, this._prevTree, this.urlTree, commands);
1291
+ var s = isPresent(segment) ? segment : this._routeTree.root;
1292
+ return link(s, this._routeTree, this.urlTree, commands);
1216
1293
  };
1217
1294
  /**
1218
1295
  * Serializes a {@link UrlTree} into a string.
1219
1296
  */
1220
1297
  Router.prototype.serializeUrl = function (url) { return this._urlSerializer.serialize(url); };
1221
- Router.prototype._createInitialTree = function () {
1222
- var root = new RouteSegment([new UrlSegment("", {}, null)], {}, DEFAULT_OUTLET_NAME, this._rootComponentType, null);
1223
- return new RouteTree(new TreeNode(root, []));
1224
- };
1225
1298
  Router.prototype._setUpLocationChangeListener = function () {
1226
1299
  var _this = this;
1227
- this._locationSubscription = this._location.subscribe(function (change) { _this._navigate(_this._urlSerializer.parse(change['url'])); });
1300
+ this._locationSubscription = this._location.subscribe(function (change) { _this._navigate(_this._urlSerializer.parse(change['url']), change['pop']); });
1228
1301
  };
1229
- Router.prototype._navigate = function (url) {
1302
+ Router.prototype._navigate = function (url, preventPushState) {
1230
1303
  var _this = this;
1231
1304
  this._urlTree = url;
1232
- return recognize(this._componentResolver, this._rootComponentType, url)
1305
+ return recognize(this._componentResolver, this._rootComponentType, url, this._routeTree)
1233
1306
  .then(function (currTree) {
1234
- return new _LoadSegments(currTree, _this._prevTree)
1235
- .load(_this._routerOutletMap, _this._rootComponent)
1307
+ return new _ActivateSegments(currTree, _this._routeTree)
1308
+ .activate(_this._routerOutletMap, _this._rootComponent)
1236
1309
  .then(function (updated) {
1237
1310
  if (updated) {
1238
- _this._prevTree = currTree;
1239
- _this._location.go(_this._urlSerializer.serialize(_this._urlTree));
1311
+ _this._routeTree = currTree;
1312
+ if (isBlank(preventPushState) || !preventPushState) {
1313
+ var path = _this._urlSerializer.serialize(_this._urlTree);
1314
+ if (_this._location.isCurrentPathEqualTo(path)) {
1315
+ _this._location.replaceState(path);
1316
+ }
1317
+ else {
1318
+ _this._location.go(path);
1319
+ }
1320
+ }
1240
1321
  _this._changes.emit(null);
1241
1322
  }
1242
1323
  });
@@ -1244,39 +1325,38 @@ var __extends = (this && this.__extends) || function (d, b) {
1244
1325
  };
1245
1326
  return Router;
1246
1327
  }());
1247
- var _LoadSegments = (function () {
1248
- function _LoadSegments(currTree, prevTree) {
1328
+ var _ActivateSegments = (function () {
1329
+ function _ActivateSegments(currTree, prevTree) {
1249
1330
  this.currTree = currTree;
1250
1331
  this.prevTree = prevTree;
1251
1332
  this.deactivations = [];
1252
1333
  this.performMutation = true;
1253
1334
  }
1254
- _LoadSegments.prototype.load = function (parentOutletMap, rootComponent) {
1335
+ _ActivateSegments.prototype.activate = function (parentOutletMap, rootComponent) {
1255
1336
  var _this = this;
1256
1337
  var prevRoot = isPresent(this.prevTree) ? rootNode(this.prevTree) : null;
1257
1338
  var currRoot = rootNode(this.currTree);
1258
- return this.canDeactivate(currRoot, prevRoot, parentOutletMap, rootComponent)
1259
- .then(function (res) {
1339
+ return this.canDeactivate(currRoot, prevRoot, parentOutletMap, rootComponent).then(function (res) {
1260
1340
  _this.performMutation = true;
1261
1341
  if (res) {
1262
- _this.loadChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]);
1342
+ _this.activateChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]);
1263
1343
  }
1264
1344
  return res;
1265
1345
  });
1266
1346
  };
1267
- _LoadSegments.prototype.canDeactivate = function (currRoot, prevRoot, outletMap, rootComponent) {
1347
+ _ActivateSegments.prototype.canDeactivate = function (currRoot, prevRoot, outletMap, rootComponent) {
1268
1348
  var _this = this;
1269
1349
  this.performMutation = false;
1270
- this.loadChildSegments(currRoot, prevRoot, outletMap, [rootComponent]);
1350
+ this.activateChildSegments(currRoot, prevRoot, outletMap, [rootComponent]);
1271
1351
  var allPaths = PromiseWrapper.all(this.deactivations.map(function (r) { return _this.checkCanDeactivatePath(r); }));
1272
1352
  return allPaths.then(function (values) { return values.filter(function (v) { return v; }).length === values.length; });
1273
1353
  };
1274
- _LoadSegments.prototype.checkCanDeactivatePath = function (path) {
1354
+ _ActivateSegments.prototype.checkCanDeactivatePath = function (path) {
1275
1355
  var _this = this;
1276
1356
  var curr = PromiseWrapper.resolve(true);
1277
1357
  var _loop_2 = function(p) {
1278
1358
  curr = curr.then(function (_) {
1279
- if (hasLifecycleHook("routerCanDeactivate", p)) {
1359
+ if (hasLifecycleHook('routerCanDeactivate', p)) {
1280
1360
  return p.routerCanDeactivate(_this.prevTree, _this.currTree);
1281
1361
  }
1282
1362
  else {
@@ -1290,45 +1370,43 @@ var __extends = (this && this.__extends) || function (d, b) {
1290
1370
  }
1291
1371
  return curr;
1292
1372
  };
1293
- _LoadSegments.prototype.loadChildSegments = function (currNode, prevNode, outletMap, components) {
1373
+ _ActivateSegments.prototype.activateChildSegments = function (currNode, prevNode, outletMap, components) {
1294
1374
  var _this = this;
1295
- var prevChildren = isPresent(prevNode) ?
1296
- prevNode.children.reduce(function (m, c) {
1297
- m[c.value.outlet] = c;
1298
- return m;
1299
- }, {}) :
1300
- {};
1375
+ var prevChildren = isPresent(prevNode) ? prevNode.children.reduce(function (m, c) {
1376
+ m[c.value.outlet] = c;
1377
+ return m;
1378
+ }, {}) : {};
1301
1379
  currNode.children.forEach(function (c) {
1302
- _this.loadSegments(c, prevChildren[c.value.outlet], outletMap, components);
1380
+ _this.activateSegments(c, prevChildren[c.value.outlet], outletMap, components);
1303
1381
  StringMapWrapper.delete(prevChildren, c.value.outlet);
1304
1382
  });
1305
- StringMapWrapper.forEach(prevChildren, function (v, k) { return _this.unloadOutlet(outletMap._outlets[k], components); });
1383
+ StringMapWrapper.forEach(prevChildren, function (v /** TODO #9100 */, k /** TODO #9100 */) { return _this.deactivateOutlet(outletMap._outlets[k], components); });
1306
1384
  };
1307
- _LoadSegments.prototype.loadSegments = function (currNode, prevNode, parentOutletMap, components) {
1385
+ _ActivateSegments.prototype.activateSegments = function (currNode, prevNode, parentOutletMap, components) {
1308
1386
  var curr = currNode.value;
1309
1387
  var prev = isPresent(prevNode) ? prevNode.value : null;
1310
1388
  var outlet = this.getOutlet(parentOutletMap, currNode.value);
1311
- if (equalSegments(curr, prev)) {
1312
- this.loadChildSegments(currNode, prevNode, outlet.outletMap, components.concat([outlet.loadedComponent]));
1389
+ if (curr === prev) {
1390
+ this.activateChildSegments(currNode, prevNode, outlet.outletMap, components.concat([outlet.component]));
1313
1391
  }
1314
1392
  else {
1315
- this.unloadOutlet(outlet, components);
1393
+ this.deactivateOutlet(outlet, components);
1316
1394
  if (this.performMutation) {
1317
1395
  var outletMap = new RouterOutletMap();
1318
- var loadedComponent = this.loadNewSegment(outletMap, curr, prev, outlet);
1319
- this.loadChildSegments(currNode, prevNode, outletMap, components.concat([loadedComponent]));
1396
+ var component = this.activateNewSegments(outletMap, curr, prev, outlet);
1397
+ this.activateChildSegments(currNode, prevNode, outletMap, components.concat([component]));
1320
1398
  }
1321
1399
  }
1322
1400
  };
1323
- _LoadSegments.prototype.loadNewSegment = function (outletMap, curr, prev, outlet) {
1324
- var resolved = _angular_core.ReflectiveInjector.resolve([_angular_core.provide(RouterOutletMap, { useValue: outletMap }), _angular_core.provide(RouteSegment, { useValue: curr })]);
1325
- var ref = outlet.load(routeSegmentComponentFactory(curr), resolved, outletMap);
1326
- if (hasLifecycleHook("routerOnActivate", ref.instance)) {
1401
+ _ActivateSegments.prototype.activateNewSegments = function (outletMap, curr, prev, outlet) {
1402
+ var resolved = _angular_core.ReflectiveInjector.resolve([{ provide: RouterOutletMap, useValue: outletMap }, { provide: RouteSegment, useValue: curr }]);
1403
+ var ref = outlet.activate(routeSegmentComponentFactory(curr), resolved, outletMap);
1404
+ if (hasLifecycleHook('routerOnActivate', ref.instance)) {
1327
1405
  ref.instance.routerOnActivate(curr, prev, this.currTree, this.prevTree);
1328
1406
  }
1329
1407
  return ref.instance;
1330
1408
  };
1331
- _LoadSegments.prototype.getOutlet = function (outletMap, segment) {
1409
+ _ActivateSegments.prototype.getOutlet = function (outletMap, segment) {
1332
1410
  var outlet = outletMap._outlets[segment.outlet];
1333
1411
  if (isBlank(outlet)) {
1334
1412
  if (segment.outlet == DEFAULT_OUTLET_NAME) {
@@ -1340,21 +1418,154 @@ var __extends = (this && this.__extends) || function (d, b) {
1340
1418
  }
1341
1419
  return outlet;
1342
1420
  };
1343
- _LoadSegments.prototype.unloadOutlet = function (outlet, components) {
1421
+ _ActivateSegments.prototype.deactivateOutlet = function (outlet, components) {
1344
1422
  var _this = this;
1345
- if (isPresent(outlet) && outlet.isLoaded) {
1346
- StringMapWrapper.forEach(outlet.outletMap._outlets, function (v, k) { return _this.unloadOutlet(v, components); });
1423
+ if (isPresent(outlet) && outlet.isActivated) {
1424
+ StringMapWrapper.forEach(outlet.outletMap._outlets, function (v /** TODO #9100 */, k /** TODO #9100 */) { return _this.deactivateOutlet(v, components); });
1347
1425
  if (this.performMutation) {
1348
- outlet.unload();
1426
+ outlet.deactivate();
1349
1427
  }
1350
1428
  else {
1351
- this.deactivations.push(components.concat([outlet.loadedComponent]));
1429
+ this.deactivations.push(components.concat([outlet.component]));
1352
1430
  }
1353
1431
  }
1354
1432
  };
1355
- return _LoadSegments;
1433
+ return _ActivateSegments;
1356
1434
  }());
1357
- var makeDecorator = _angular_core.__core_private__.makeDecorator;
1435
+ var RouterLink = (function () {
1436
+ function RouterLink(_routeSegment, _router, _locationStrategy) {
1437
+ var _this = this;
1438
+ this._routeSegment = _routeSegment;
1439
+ this._router = _router;
1440
+ this._locationStrategy = _locationStrategy;
1441
+ this._commands = [];
1442
+ this.isActive = false;
1443
+ // because auxiliary links take existing primary and auxiliary routes into account,
1444
+ // we need to update the link whenever params or other routes change.
1445
+ this._subscription =
1446
+ ObservableWrapper.subscribe(_router.changes, function (_) { _this._updateTargetUrlAndHref(); });
1447
+ }
1448
+ RouterLink.prototype.ngOnDestroy = function () { ObservableWrapper.dispose(this._subscription); };
1449
+ Object.defineProperty(RouterLink.prototype, "routerLink", {
1450
+ set: function (data) {
1451
+ if (isArray(data)) {
1452
+ this._commands = data;
1453
+ }
1454
+ else {
1455
+ this._commands = [data];
1456
+ }
1457
+ this._updateTargetUrlAndHref();
1458
+ },
1459
+ enumerable: true,
1460
+ configurable: true
1461
+ });
1462
+ RouterLink.prototype.onClick = function (button, ctrlKey, metaKey) {
1463
+ if (button != 0 || ctrlKey || metaKey) {
1464
+ return true;
1465
+ }
1466
+ if (isString(this.target) && this.target != '_self') {
1467
+ return true;
1468
+ }
1469
+ this._router.navigate(this._commands, this._routeSegment);
1470
+ return false;
1471
+ };
1472
+ RouterLink.prototype._updateTargetUrlAndHref = function () {
1473
+ var tree = this._router.createUrlTree(this._commands, this._routeSegment);
1474
+ if (isPresent(tree)) {
1475
+ this.href = this._locationStrategy.prepareExternalUrl(this._router.serializeUrl(tree));
1476
+ this.isActive = this._router.urlTree.contains(tree);
1477
+ }
1478
+ else {
1479
+ this.isActive = false;
1480
+ }
1481
+ };
1482
+ return RouterLink;
1483
+ }());
1484
+ /** @nocollapse */
1485
+ RouterLink.decorators = [
1486
+ { type: _angular_core.Directive, args: [{ selector: '[routerLink]' },] },
1487
+ ];
1488
+ /** @nocollapse */
1489
+ RouterLink.ctorParameters = [
1490
+ { type: RouteSegment, },
1491
+ { type: Router, },
1492
+ { type: _angular_common.LocationStrategy, },
1493
+ ];
1494
+ /** @nocollapse */
1495
+ RouterLink.propDecorators = {
1496
+ 'target': [{ type: _angular_core.Input },],
1497
+ 'href': [{ type: _angular_core.HostBinding },],
1498
+ 'isActive': [{ type: _angular_core.HostBinding, args: ['class.router-link-active',] },],
1499
+ 'routerLink': [{ type: _angular_core.Input },],
1500
+ 'onClick': [{ type: _angular_core.HostListener, args: ['click', ['$event.button', '$event.ctrlKey', '$event.metaKey'],] },],
1501
+ };
1502
+ var RouterOutlet = (function () {
1503
+ function RouterOutlet(parentOutletMap, _location, name) {
1504
+ this._location = _location;
1505
+ parentOutletMap.registerOutlet(isBlank(name) ? DEFAULT_OUTLET_NAME : name, this);
1506
+ }
1507
+ RouterOutlet.prototype.deactivate = function () {
1508
+ this._activated.destroy();
1509
+ this._activated = null;
1510
+ };
1511
+ Object.defineProperty(RouterOutlet.prototype, "component", {
1512
+ /**
1513
+ * Returns the loaded component.
1514
+ */
1515
+ get: function () { return isPresent(this._activated) ? this._activated.instance : null; },
1516
+ enumerable: true,
1517
+ configurable: true
1518
+ });
1519
+ Object.defineProperty(RouterOutlet.prototype, "isActivated", {
1520
+ /**
1521
+ * Returns true is the outlet is not empty.
1522
+ */
1523
+ get: function () { return isPresent(this._activated); },
1524
+ enumerable: true,
1525
+ configurable: true
1526
+ });
1527
+ /**
1528
+ * Called by the Router to instantiate a new component.
1529
+ */
1530
+ RouterOutlet.prototype.activate = function (factory, providers, outletMap) {
1531
+ this.outletMap = outletMap;
1532
+ var inj = _angular_core.ReflectiveInjector.fromResolvedProviders(providers, this._location.parentInjector);
1533
+ this._activated = this._location.createComponent(factory, this._location.length, inj, []);
1534
+ return this._activated;
1535
+ };
1536
+ return RouterOutlet;
1537
+ }());
1538
+ /** @nocollapse */
1539
+ RouterOutlet.decorators = [
1540
+ { type: _angular_core.Directive, args: [{ selector: 'router-outlet' },] },
1541
+ ];
1542
+ /** @nocollapse */
1543
+ RouterOutlet.ctorParameters = [
1544
+ { type: RouterOutletMap, },
1545
+ { type: _angular_core.ViewContainerRef, },
1546
+ { type: undefined, decorators: [{ type: _angular_core.Attribute, args: ['name',] },] },
1547
+ ];
1548
+ /**
1549
+ * A list of directives. To use the router directives like {@link RouterOutlet} and
1550
+ * {@link RouterLink}, add this to your `directives` array in the {@link View} decorator of your
1551
+ * component.
1552
+ *
1553
+ * ```
1554
+ * import {Component} from '@angular/core';
1555
+ * import {ROUTER_DIRECTIVES, Routes} from '@angular/router';
1556
+ *
1557
+ * @Component({directives: [ROUTER_DIRECTIVES]})
1558
+ * @Routes([
1559
+ * {...},
1560
+ * ])
1561
+ * class AppCmp {
1562
+ * // ...
1563
+ * }
1564
+ *
1565
+ * bootstrap(AppCmp);
1566
+ * ```
1567
+ */
1568
+ var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink];
1358
1569
  /**
1359
1570
  * Defines routes for a given component.
1360
1571
  *
@@ -1390,7 +1601,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1390
1601
  function _serializeUrlTreeNodes(nodes) {
1391
1602
  var main = nodes[0].value.toString();
1392
1603
  var auxNodes = nodes.slice(1);
1393
- var aux = auxNodes.length > 0 ? "(" + auxNodes.map(_serializeUrlTreeNode).join("//") + ")" : "";
1604
+ var aux = auxNodes.length > 0 ? "(" + auxNodes.map(_serializeUrlTreeNode).join("//") + ")" : '';
1394
1605
  var children = _serializeChildren(nodes[0]);
1395
1606
  return "" + main + aux + children;
1396
1607
  }
@@ -1399,7 +1610,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1399
1610
  return "/" + _serializeUrlTreeNodes(node.children);
1400
1611
  }
1401
1612
  else {
1402
- return "";
1613
+ return '';
1403
1614
  }
1404
1615
  }
1405
1616
  var SEGMENT_RE = RegExpWrapper.create('^[^\\/\\(\\)\\?;=&#]+');
@@ -1445,8 +1656,8 @@ var __extends = (this && this.__extends) || function (d, b) {
1445
1656
  }
1446
1657
  var path = matchUrlSegment(this._remaining);
1447
1658
  this.capture(path);
1448
- if (path.indexOf(":") > -1) {
1449
- var parts = path.split(":");
1659
+ if (path.indexOf(':') > -1) {
1660
+ var parts = path.split(':');
1450
1661
  outletName = parts[0];
1451
1662
  path = parts[1];
1452
1663
  }
@@ -1491,7 +1702,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1491
1702
  return;
1492
1703
  }
1493
1704
  this.capture(key);
1494
- var value = "true";
1705
+ var value = 'true';
1495
1706
  if (this.peekStartsWith('=')) {
1496
1707
  this.capture('=');
1497
1708
  var valueMatch = matchUrlSegment(this._remaining);
@@ -1508,7 +1719,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1508
1719
  return;
1509
1720
  }
1510
1721
  this.capture(key);
1511
- var value = "true";
1722
+ var value = 'true';
1512
1723
  if (this.peekStartsWith('=')) {
1513
1724
  this.capture('=');
1514
1725
  var valueMatch = matchUrlQueryParamValue(this._remaining);
@@ -1523,7 +1734,7 @@ var __extends = (this && this.__extends) || function (d, b) {
1523
1734
  var segments = [];
1524
1735
  this.capture('(');
1525
1736
  while (!this.peekStartsWith(')') && this._remaining.length > 0) {
1526
- segments = segments.concat(this.parseSegments("aux"));
1737
+ segments = segments.concat(this.parseSegments('aux'));
1527
1738
  if (this.peekStartsWith('//')) {
1528
1739
  this.capture('//');
1529
1740
  }
@@ -1545,18 +1756,22 @@ var __extends = (this && this.__extends) || function (d, b) {
1545
1756
  useFactory: routerFactory,
1546
1757
  deps: /*@ts2dart_const*/ [_angular_core.ApplicationRef, _angular_core.ComponentResolver, RouterUrlSerializer, RouterOutletMap, _angular_common.Location],
1547
1758
  },
1759
+ /*@ts2dart_Provider*/ { provide: RouteSegment, useFactory: routeSegmentFactory, deps: [Router] }
1548
1760
  ];
1549
1761
  function routerFactory(app, componentResolver, urlSerializer, routerOutletMap, location) {
1550
1762
  if (app.componentTypes.length == 0) {
1551
- throw new _angular_core.BaseException("Bootstrap at least one component before injecting Router.");
1763
+ throw new _angular_core.BaseException('Bootstrap at least one component before injecting Router.');
1552
1764
  }
1553
1765
  // TODO: vsavkin this should not be null
1554
1766
  var router = new Router(null, app.componentTypes[0], componentResolver, urlSerializer, routerOutletMap, location);
1555
1767
  app.registerDisposeListener(function () { return router.dispose(); });
1556
1768
  return router;
1557
1769
  }
1770
+ function routeSegmentFactory(router) {
1771
+ return router.routeTree.root;
1772
+ }
1558
1773
  /**
1559
- * A list of {@link Provider}s. To use the router, you must add this to your application.
1774
+ * A list of providers. To use the router, you must add this to your application.
1560
1775
  *
1561
1776
  * ```
1562
1777
  * import {Component} from '@angular/core';
@@ -1577,146 +1792,21 @@ var __extends = (this && this.__extends) || function (d, b) {
1577
1792
  * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
1578
1793
  * ```
1579
1794
  */
1580
- var ROUTER_PROVIDERS = [
1581
- ROUTER_PROVIDERS_COMMON,
1582
- /*@ts2dart_Provider*/ { provide: _angular_common.PlatformLocation, useClass: _angular_platformBrowser.BrowserPlatformLocation },
1583
- ];
1584
- var RouterOutlet = (function () {
1585
- function RouterOutlet(parentOutletMap, _location, name) {
1586
- this._location = _location;
1587
- parentOutletMap.registerOutlet(isBlank(name) ? DEFAULT_OUTLET_NAME : name, this);
1588
- }
1589
- RouterOutlet.prototype.unload = function () {
1590
- this._loaded.destroy();
1591
- this._loaded = null;
1592
- };
1593
- Object.defineProperty(RouterOutlet.prototype, "loadedComponent", {
1594
- /**
1595
- * Returns the loaded component.
1596
- */
1597
- get: function () { return isPresent(this._loaded) ? this._loaded.instance : null; },
1598
- enumerable: true,
1599
- configurable: true
1600
- });
1601
- Object.defineProperty(RouterOutlet.prototype, "isLoaded", {
1602
- /**
1603
- * Returns true is the outlet is not empty.
1604
- */
1605
- get: function () { return isPresent(this._loaded); },
1606
- enumerable: true,
1607
- configurable: true
1608
- });
1609
- /**
1610
- * Called by the Router to instantiate a new component.
1611
- */
1612
- RouterOutlet.prototype.load = function (factory, providers, outletMap) {
1613
- this.outletMap = outletMap;
1614
- var inj = _angular_core.ReflectiveInjector.fromResolvedProviders(providers, this._location.parentInjector);
1615
- this._loaded = this._location.createComponent(factory, this._location.length, inj, []);
1616
- return this._loaded;
1617
- };
1618
- return RouterOutlet;
1619
- }());
1620
- RouterOutlet.decorators = [
1621
- { type: _angular_core.Directive, args: [{ selector: 'router-outlet' },] },
1622
- ];
1623
- RouterOutlet.ctorParameters = [
1624
- { type: RouterOutletMap, },
1625
- { type: _angular_core.ViewContainerRef, },
1626
- { type: undefined, decorators: [{ type: _angular_core.Attribute, args: ['name',] },] },
1627
- ];
1628
- var RouterLink = (function () {
1629
- function RouterLink(_routeSegment, _router) {
1630
- var _this = this;
1631
- this._routeSegment = _routeSegment;
1632
- this._router = _router;
1633
- this._commands = [];
1634
- this.isActive = false;
1635
- // because auxiliary links take existing primary and auxiliary routes into account,
1636
- // we need to update the link whenever params or other routes change.
1637
- this._subscription =
1638
- ObservableWrapper.subscribe(_router.changes, function (_) { _this._updateTargetUrlAndHref(); });
1639
- }
1640
- RouterLink.prototype.ngOnDestroy = function () { ObservableWrapper.dispose(this._subscription); };
1641
- Object.defineProperty(RouterLink.prototype, "routerLink", {
1642
- set: function (data) {
1643
- if (isArray(data)) {
1644
- this._commands = data;
1645
- }
1646
- else {
1647
- this._commands = [data];
1648
- }
1649
- this._updateTargetUrlAndHref();
1650
- },
1651
- enumerable: true,
1652
- configurable: true
1653
- });
1654
- RouterLink.prototype.onClick = function () {
1655
- // If no target, or if target is _self, prevent default browser behavior
1656
- if (!isString(this.target) || this.target == '_self') {
1657
- this._router.navigate(this._commands, this._routeSegment);
1658
- return false;
1659
- }
1660
- return true;
1661
- };
1662
- RouterLink.prototype._updateTargetUrlAndHref = function () {
1663
- var tree = this._router.createUrlTree(this._commands, this._routeSegment);
1664
- if (isPresent(tree)) {
1665
- this.href = this._router.serializeUrl(tree);
1666
- this.isActive = this._router.urlTree.contains(tree);
1667
- }
1668
- else {
1669
- this.isActive = false;
1670
- }
1671
- };
1672
- return RouterLink;
1673
- }());
1674
- RouterLink.decorators = [
1675
- { type: _angular_core.Directive, args: [{ selector: '[routerLink]' },] },
1676
- ];
1677
- RouterLink.ctorParameters = [
1678
- { type: RouteSegment, decorators: [{ type: _angular_core.Optional },] },
1679
- { type: Router, },
1680
- ];
1681
- RouterLink.propDecorators = {
1682
- 'target': [{ type: _angular_core.Input },],
1683
- 'href': [{ type: _angular_core.HostBinding },],
1684
- 'isActive': [{ type: _angular_core.HostBinding, args: ['class.router-link-active',] },],
1685
- 'routerLink': [{ type: _angular_core.Input },],
1686
- 'onClick': [{ type: _angular_core.HostListener, args: ["click",] },],
1687
- };
1688
- /**
1689
- * A list of directives. To use the router directives like {@link RouterOutlet} and
1690
- * {@link RouterLink}, add this to your `directives` array in the {@link View} decorator of your
1691
- * component.
1692
- *
1693
- * ```
1694
- * import {Component} from '@angular/core';
1695
- * import {ROUTER_DIRECTIVES, Routes} from '@angular/router-deprecated';
1696
- *
1697
- * @Component({directives: [ROUTER_DIRECTIVES]})
1698
- * @RouteConfig([
1699
- * {...},
1700
- * ])
1701
- * class AppCmp {
1702
- * // ...
1703
- * }
1704
- *
1705
- * bootstrap(AppCmp);
1706
- * ```
1707
- */
1708
- var ROUTER_DIRECTIVES = [RouterOutlet, RouterLink];
1795
+ // TODO: merge with router_providers_common.ts
1796
+ var ROUTER_PROVIDERS = [ROUTER_PROVIDERS_COMMON];
1709
1797
  exports.ROUTER_DIRECTIVES = ROUTER_DIRECTIVES;
1798
+ exports.RouterLink = RouterLink;
1799
+ exports.RouterOutlet = RouterOutlet;
1800
+ exports.Routes = Routes;
1801
+ exports.Route = Route;
1710
1802
  exports.Router = Router;
1711
1803
  exports.RouterOutletMap = RouterOutletMap;
1804
+ exports.ROUTER_PROVIDERS = ROUTER_PROVIDERS;
1805
+ exports.DefaultRouterUrlSerializer = DefaultRouterUrlSerializer;
1806
+ exports.RouterUrlSerializer = RouterUrlSerializer;
1712
1807
  exports.RouteSegment = RouteSegment;
1713
- exports.UrlSegment = UrlSegment;
1808
+ exports.RouteTree = RouteTree;
1714
1809
  exports.Tree = Tree;
1810
+ exports.UrlSegment = UrlSegment;
1715
1811
  exports.UrlTree = UrlTree;
1716
- exports.RouteTree = RouteTree;
1717
- exports.Routes = Routes;
1718
- exports.Route = Route;
1719
- exports.RouterUrlSerializer = RouterUrlSerializer;
1720
- exports.DefaultRouterUrlSerializer = DefaultRouterUrlSerializer;
1721
- exports.ROUTER_PROVIDERS = ROUTER_PROVIDERS;
1722
1812
  }));