@angular/router 0.1.0 → 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 (190) hide show
  1. package/bundles/router.umd.js +1812 -0
  2. package/bundles/router.umd.min.js +2 -0
  3. package/esm/index.d.ts +15 -0
  4. package/esm/index.js +15 -0
  5. package/esm/index.js.map +1 -0
  6. package/esm/src/constants.d.ts +5 -0
  7. package/esm/src/constants.js +6 -0
  8. package/esm/src/constants.js.map +1 -0
  9. package/esm/src/constants.metadata.json +1 -0
  10. package/esm/src/core_private.d.ts +3 -0
  11. package/esm/src/core_private.js +4 -0
  12. package/esm/src/core_private.js.map +1 -0
  13. package/esm/src/core_private.metadata.json +1 -0
  14. package/esm/src/directives/router_directives.d.ts +21 -0
  15. package/esm/src/directives/router_directives.js +24 -0
  16. package/esm/src/directives/router_directives.js.map +1 -0
  17. package/esm/src/directives/router_directives.metadata.json +1 -0
  18. package/esm/src/directives/router_link.d.ts +49 -0
  19. package/esm/src/directives/router_link.js +68 -0
  20. package/esm/src/directives/router_link.js.map +1 -0
  21. package/esm/src/directives/router_link.metadata.json +1 -0
  22. package/esm/src/directives/router_outlet.d.ts +36 -0
  23. package/esm/src/directives/router_outlet.js +42 -0
  24. package/esm/src/directives/router_outlet.js.map +1 -0
  25. package/esm/src/directives/router_outlet.metadata.json +1 -0
  26. package/esm/src/facade/async.d.ts +90 -0
  27. package/esm/src/facade/async.js +137 -0
  28. package/esm/src/facade/async.js.map +1 -0
  29. package/esm/src/facade/base_wrapped_exception.d.ts +14 -0
  30. package/esm/src/facade/base_wrapped_exception.js +17 -0
  31. package/esm/src/facade/base_wrapped_exception.js.map +1 -0
  32. package/esm/src/facade/collection.d.ts +103 -0
  33. package/esm/src/facade/collection.js +343 -0
  34. package/esm/src/facade/collection.js.map +1 -0
  35. package/esm/src/facade/collection.metadata.json +1 -0
  36. package/esm/src/facade/exception_handler.d.ts +29 -0
  37. package/esm/src/facade/exception_handler.js +124 -0
  38. package/esm/src/facade/exception_handler.js.map +1 -0
  39. package/esm/src/facade/exceptions.d.ts +32 -0
  40. package/esm/src/facade/exceptions.js +42 -0
  41. package/esm/src/facade/exceptions.js.map +1 -0
  42. package/esm/src/facade/exceptions.metadata.json +1 -0
  43. package/esm/src/facade/lang.d.ts +158 -0
  44. package/esm/src/facade/lang.js +386 -0
  45. package/esm/src/facade/lang.js.map +1 -0
  46. package/esm/src/facade/lang.metadata.json +1 -0
  47. package/esm/src/facade/promise.d.ts +17 -0
  48. package/esm/src/facade/promise.js +41 -0
  49. package/esm/src/facade/promise.js.map +1 -0
  50. package/esm/src/interfaces.d.ts +23 -0
  51. package/esm/src/interfaces.js +1 -0
  52. package/esm/src/interfaces.js.map +1 -0
  53. package/esm/src/lifecycle_reflector.d.ts +1 -0
  54. package/esm/src/lifecycle_reflector.js +10 -0
  55. package/esm/src/lifecycle_reflector.js.map +1 -0
  56. package/esm/src/link.d.ts +2 -0
  57. package/esm/src/link.js +183 -0
  58. package/esm/src/link.js.map +1 -0
  59. package/esm/src/metadata/decorators.d.ts +16 -0
  60. package/esm/src/metadata/decorators.js +9 -0
  61. package/esm/src/metadata/decorators.js.map +1 -0
  62. package/esm/src/metadata/decorators.metadata.json +1 -0
  63. package/esm/src/metadata/metadata.d.ts +48 -0
  64. package/esm/src/metadata/metadata.js +48 -0
  65. package/esm/src/metadata/metadata.js.map +1 -0
  66. package/esm/src/recognize.d.ts +4 -0
  67. package/esm/src/recognize.js +164 -0
  68. package/esm/src/recognize.js.map +1 -0
  69. package/esm/src/router.d.ts +95 -0
  70. package/esm/src/router.js +243 -0
  71. package/esm/src/router.js.map +1 -0
  72. package/esm/src/router_providers.d.ts +23 -0
  73. package/esm/src/router_providers.js +26 -0
  74. package/esm/src/router_providers.js.map +1 -0
  75. package/esm/src/router_providers.metadata.json +1 -0
  76. package/esm/src/router_providers_common.d.ts +11 -0
  77. package/esm/src/router_providers_common.js +32 -0
  78. package/esm/src/router_providers_common.js.map +1 -0
  79. package/esm/src/router_providers_common.metadata.json +1 -0
  80. package/esm/src/router_url_serializer.d.ts +21 -0
  81. package/esm/src/router_url_serializer.js +164 -0
  82. package/esm/src/router_url_serializer.js.map +1 -0
  83. package/esm/src/segments.d.ts +51 -0
  84. package/esm/src/segments.js +137 -0
  85. package/esm/src/segments.js.map +1 -0
  86. package/esm/src/segments.metadata.json +1 -0
  87. package/esm/testing/router_testing_providers.d.ts +1 -0
  88. package/esm/testing/router_testing_providers.js +31 -0
  89. package/esm/testing/router_testing_providers.js.map +1 -0
  90. package/esm/testing/router_testing_providers.metadata.json +1 -0
  91. package/esm/testing.d.ts +1 -0
  92. package/esm/testing.js +2 -0
  93. package/esm/testing.js.map +1 -0
  94. package/index.d.ts +15 -0
  95. package/index.js +31 -0
  96. package/index.js.map +1 -0
  97. package/package.json +16 -1
  98. package/src/constants.d.ts +5 -0
  99. package/src/constants.js +7 -0
  100. package/src/constants.js.map +1 -0
  101. package/src/constants.metadata.json +1 -0
  102. package/src/core_private.d.ts +3 -0
  103. package/src/core_private.js +5 -0
  104. package/src/core_private.js.map +1 -0
  105. package/src/core_private.metadata.json +1 -0
  106. package/src/directives/router_directives.d.ts +21 -0
  107. package/src/directives/router_directives.js +25 -0
  108. package/src/directives/router_directives.js.map +1 -0
  109. package/src/directives/router_directives.metadata.json +1 -0
  110. package/src/directives/router_link.d.ts +49 -0
  111. package/src/directives/router_link.js +76 -0
  112. package/src/directives/router_link.js.map +1 -0
  113. package/src/directives/router_link.metadata.json +1 -0
  114. package/src/directives/router_outlet.d.ts +36 -0
  115. package/src/directives/router_outlet.js +53 -0
  116. package/src/directives/router_outlet.js.map +1 -0
  117. package/src/directives/router_outlet.metadata.json +1 -0
  118. package/src/facade/async.d.ts +90 -0
  119. package/src/facade/async.js +160 -0
  120. package/src/facade/async.js.map +1 -0
  121. package/src/facade/base_wrapped_exception.d.ts +14 -0
  122. package/src/facade/base_wrapped_exception.js +50 -0
  123. package/src/facade/base_wrapped_exception.js.map +1 -0
  124. package/src/facade/collection.d.ts +103 -0
  125. package/src/facade/collection.js +368 -0
  126. package/src/facade/collection.js.map +1 -0
  127. package/src/facade/collection.metadata.json +1 -0
  128. package/src/facade/exception_handler.d.ts +29 -0
  129. package/src/facade/exception_handler.js +133 -0
  130. package/src/facade/exception_handler.js.map +1 -0
  131. package/src/facade/exceptions.d.ts +32 -0
  132. package/src/facade/exceptions.js +82 -0
  133. package/src/facade/exceptions.js.map +1 -0
  134. package/src/facade/exceptions.metadata.json +1 -0
  135. package/src/facade/lang.d.ts +158 -0
  136. package/src/facade/lang.js +480 -0
  137. package/src/facade/lang.js.map +1 -0
  138. package/src/facade/lang.metadata.json +1 -0
  139. package/src/facade/promise.d.ts +17 -0
  140. package/src/facade/promise.js +49 -0
  141. package/src/facade/promise.js.map +1 -0
  142. package/src/interfaces.d.ts +23 -0
  143. package/src/interfaces.js +2 -0
  144. package/src/interfaces.js.map +1 -0
  145. package/src/lifecycle_reflector.d.ts +1 -0
  146. package/src/lifecycle_reflector.js +12 -0
  147. package/src/lifecycle_reflector.js.map +1 -0
  148. package/src/link.d.ts +2 -0
  149. package/src/link.js +189 -0
  150. package/src/link.js.map +1 -0
  151. package/src/metadata/decorators.d.ts +16 -0
  152. package/src/metadata/decorators.js +10 -0
  153. package/src/metadata/decorators.js.map +1 -0
  154. package/src/metadata/decorators.metadata.json +1 -0
  155. package/src/metadata/metadata.d.ts +48 -0
  156. package/src/metadata/metadata.js +66 -0
  157. package/src/metadata/metadata.js.map +1 -0
  158. package/src/recognize.d.ts +4 -0
  159. package/src/recognize.js +172 -0
  160. package/src/recognize.js.map +1 -0
  161. package/src/router.d.ts +95 -0
  162. package/src/router.js +276 -0
  163. package/src/router.js.map +1 -0
  164. package/src/router_providers.d.ts +23 -0
  165. package/src/router_providers.js +27 -0
  166. package/src/router_providers.js.map +1 -0
  167. package/src/router_providers.metadata.json +1 -0
  168. package/src/router_providers_common.d.ts +11 -0
  169. package/src/router_providers_common.js +35 -0
  170. package/src/router_providers_common.js.map +1 -0
  171. package/src/router_providers_common.metadata.json +1 -0
  172. package/src/router_url_serializer.d.ts +21 -0
  173. package/src/router_url_serializer.js +184 -0
  174. package/src/router_url_serializer.js.map +1 -0
  175. package/src/segments.d.ts +51 -0
  176. package/src/segments.js +181 -0
  177. package/src/segments.js.map +1 -0
  178. package/src/segments.metadata.json +1 -0
  179. package/testing/router_testing_providers.d.ts +1 -0
  180. package/testing/router_testing_providers.js +35 -0
  181. package/testing/router_testing_providers.js.map +1 -0
  182. package/testing/router_testing_providers.metadata.json +1 -0
  183. package/testing.d.ts +1 -0
  184. package/testing.js +6 -0
  185. package/testing.js.map +1 -0
  186. package/angular1/angular_1_router.js +0 -2922
  187. package/angular1/ng_route_shim.js +0 -349
  188. package/angular2/router.dev.js +0 -3107
  189. package/angular2/router.js +0 -3107
  190. package/angular2/router.min.js +0 -3
@@ -0,0 +1,95 @@
1
+ import { RouterOutlet } from './directives/router_outlet';
2
+ import { Observable } from './facade/async';
3
+ import { RouteSegment, RouteTree, UrlTree } from './segments';
4
+ export declare class RouterOutletMap {
5
+ registerOutlet(name: string, outlet: RouterOutlet): void;
6
+ }
7
+ /**
8
+ * The `Router` is responsible for mapping URLs to components.
9
+ *
10
+ * You can see the state of the router by inspecting the read-only fields `router.urlTree`
11
+ * and `router.routeTree`.
12
+ */
13
+ export declare class Router {
14
+ private _rootComponent;
15
+ private _rootComponentType;
16
+ private _componentResolver;
17
+ private _urlSerializer;
18
+ private _routerOutletMap;
19
+ private _location;
20
+ private _routeTree;
21
+ private _urlTree;
22
+ private _locationSubscription;
23
+ private _changes;
24
+ /**
25
+ * Returns the current url tree.
26
+ */
27
+ readonly urlTree: UrlTree;
28
+ /**
29
+ * Returns the current route tree.
30
+ */
31
+ readonly routeTree: RouteTree;
32
+ /**
33
+ * An observable or url changes from the router.
34
+ */
35
+ readonly changes: Observable<void>;
36
+ /**
37
+ * Navigate based on the provided url. This navigation is always absolute.
38
+ *
39
+ * ### Usage
40
+ *
41
+ * ```
42
+ * router.navigateByUrl("/team/33/user/11");
43
+ * ```
44
+ */
45
+ navigateByUrl(url: string): Promise<void>;
46
+ /**
47
+ * Navigate based on the provided array of commands and a starting point.
48
+ * If no segment is provided, the navigation is absolute.
49
+ *
50
+ * ### Usage
51
+ *
52
+ * ```
53
+ * router.navigate(['team', 33, 'team', '11], segment);
54
+ * ```
55
+ */
56
+ navigate(commands: any[], segment?: RouteSegment): Promise<void>;
57
+ /**
58
+ * Applies an array of commands to the current url tree and creates
59
+ * a new url tree.
60
+ *
61
+ * When given a segment, applies the given commands starting from the segment.
62
+ * When not given a segment, applies the given command starting from the root.
63
+ *
64
+ * ### Usage
65
+ *
66
+ * ```
67
+ * // create /team/33/user/11
68
+ * router.createUrlTree(['/team', 33, 'user', 11]);
69
+ *
70
+ * // create /team/33;expand=true/user/11
71
+ * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
72
+ *
73
+ * // you can collapse static fragments like this
74
+ * router.createUrlTree(['/team/33/user', userId]);
75
+ *
76
+ * // assuming the current url is `/team/33/user/11` and the segment points to `user/11`
77
+ *
78
+ * // navigate to /team/33/user/11/details
79
+ * router.createUrlTree(['details'], segment);
80
+ *
81
+ * // navigate to /team/33/user/22
82
+ * router.createUrlTree(['../22'], segment);
83
+ *
84
+ * // navigate to /team/44/user/22
85
+ * router.createUrlTree(['../../team/44/user/22'], segment);
86
+ * ```
87
+ */
88
+ createUrlTree(commands: any[], segment?: RouteSegment): UrlTree;
89
+ /**
90
+ * Serializes a {@link UrlTree} into a string.
91
+ */
92
+ serializeUrl(url: UrlTree): string;
93
+ private _setUpLocationChangeListener();
94
+ private _navigate(url, preventPushState?);
95
+ }
@@ -0,0 +1,243 @@
1
+ import { BaseException, ReflectiveInjector } from '@angular/core';
2
+ import { DEFAULT_OUTLET_NAME } from './constants';
3
+ import { EventEmitter, ObservableWrapper, PromiseWrapper } from './facade/async';
4
+ import { ListWrapper, StringMapWrapper } from './facade/collection';
5
+ import { isBlank, isPresent } from './facade/lang';
6
+ import { hasLifecycleHook } from './lifecycle_reflector';
7
+ import { link } from './link';
8
+ import { recognize } from './recognize';
9
+ import { RouteSegment, createEmptyRouteTree, rootNode, routeSegmentComponentFactory } from './segments';
10
+ export class RouterOutletMap {
11
+ constructor() {
12
+ /** @internal */
13
+ this._outlets = {};
14
+ }
15
+ registerOutlet(name, outlet) { this._outlets[name] = outlet; }
16
+ }
17
+ /**
18
+ * The `Router` is responsible for mapping URLs to components.
19
+ *
20
+ * You can see the state of the router by inspecting the read-only fields `router.urlTree`
21
+ * and `router.routeTree`.
22
+ */
23
+ export class Router {
24
+ /**
25
+ * @internal
26
+ */
27
+ constructor(_rootComponent, _rootComponentType, _componentResolver, _urlSerializer, _routerOutletMap, _location) {
28
+ this._rootComponent = _rootComponent;
29
+ this._rootComponentType = _rootComponentType;
30
+ this._componentResolver = _componentResolver;
31
+ this._urlSerializer = _urlSerializer;
32
+ this._routerOutletMap = _routerOutletMap;
33
+ this._location = _location;
34
+ this._changes = new EventEmitter();
35
+ this._routeTree = createEmptyRouteTree(this._rootComponentType);
36
+ this._setUpLocationChangeListener();
37
+ this.navigateByUrl(this._location.path());
38
+ }
39
+ /**
40
+ * Returns the current url tree.
41
+ */
42
+ get urlTree() { return this._urlTree; }
43
+ /**
44
+ * Returns the current route tree.
45
+ */
46
+ get routeTree() { return this._routeTree; }
47
+ /**
48
+ * An observable or url changes from the router.
49
+ */
50
+ get changes() { return this._changes; }
51
+ /**
52
+ * Navigate based on the provided url. This navigation is always absolute.
53
+ *
54
+ * ### Usage
55
+ *
56
+ * ```
57
+ * router.navigateByUrl("/team/33/user/11");
58
+ * ```
59
+ */
60
+ navigateByUrl(url) {
61
+ return this._navigate(this._urlSerializer.parse(url));
62
+ }
63
+ /**
64
+ * Navigate based on the provided array of commands and a starting point.
65
+ * If no segment is provided, the navigation is absolute.
66
+ *
67
+ * ### Usage
68
+ *
69
+ * ```
70
+ * router.navigate(['team', 33, 'team', '11], segment);
71
+ * ```
72
+ */
73
+ navigate(commands, segment) {
74
+ return this._navigate(this.createUrlTree(commands, segment));
75
+ }
76
+ /**
77
+ * @internal
78
+ */
79
+ dispose() { ObservableWrapper.dispose(this._locationSubscription); }
80
+ /**
81
+ * Applies an array of commands to the current url tree and creates
82
+ * a new url tree.
83
+ *
84
+ * When given a segment, applies the given commands starting from the segment.
85
+ * When not given a segment, applies the given command starting from the root.
86
+ *
87
+ * ### Usage
88
+ *
89
+ * ```
90
+ * // create /team/33/user/11
91
+ * router.createUrlTree(['/team', 33, 'user', 11]);
92
+ *
93
+ * // create /team/33;expand=true/user/11
94
+ * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
95
+ *
96
+ * // you can collapse static fragments like this
97
+ * router.createUrlTree(['/team/33/user', userId]);
98
+ *
99
+ * // assuming the current url is `/team/33/user/11` and the segment points to `user/11`
100
+ *
101
+ * // navigate to /team/33/user/11/details
102
+ * router.createUrlTree(['details'], segment);
103
+ *
104
+ * // navigate to /team/33/user/22
105
+ * router.createUrlTree(['../22'], segment);
106
+ *
107
+ * // navigate to /team/44/user/22
108
+ * router.createUrlTree(['../../team/44/user/22'], segment);
109
+ * ```
110
+ */
111
+ createUrlTree(commands, segment) {
112
+ let s = isPresent(segment) ? segment : this._routeTree.root;
113
+ return link(s, this._routeTree, this.urlTree, commands);
114
+ }
115
+ /**
116
+ * Serializes a {@link UrlTree} into a string.
117
+ */
118
+ serializeUrl(url) { return this._urlSerializer.serialize(url); }
119
+ _setUpLocationChangeListener() {
120
+ this._locationSubscription = this._location.subscribe((change) => { this._navigate(this._urlSerializer.parse(change['url']), change['pop']); });
121
+ }
122
+ _navigate(url, preventPushState) {
123
+ this._urlTree = url;
124
+ return recognize(this._componentResolver, this._rootComponentType, url, this._routeTree)
125
+ .then(currTree => {
126
+ return new _ActivateSegments(currTree, this._routeTree)
127
+ .activate(this._routerOutletMap, this._rootComponent)
128
+ .then(updated => {
129
+ if (updated) {
130
+ this._routeTree = currTree;
131
+ if (isBlank(preventPushState) || !preventPushState) {
132
+ let path = this._urlSerializer.serialize(this._urlTree);
133
+ if (this._location.isCurrentPathEqualTo(path)) {
134
+ this._location.replaceState(path);
135
+ }
136
+ else {
137
+ this._location.go(path);
138
+ }
139
+ }
140
+ this._changes.emit(null);
141
+ }
142
+ });
143
+ });
144
+ }
145
+ }
146
+ class _ActivateSegments {
147
+ constructor(currTree, prevTree) {
148
+ this.currTree = currTree;
149
+ this.prevTree = prevTree;
150
+ this.deactivations = [];
151
+ this.performMutation = true;
152
+ }
153
+ activate(parentOutletMap, rootComponent) {
154
+ let prevRoot = isPresent(this.prevTree) ? rootNode(this.prevTree) : null;
155
+ let currRoot = rootNode(this.currTree);
156
+ return this.canDeactivate(currRoot, prevRoot, parentOutletMap, rootComponent).then(res => {
157
+ this.performMutation = true;
158
+ if (res) {
159
+ this.activateChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]);
160
+ }
161
+ return res;
162
+ });
163
+ }
164
+ canDeactivate(currRoot, prevRoot, outletMap, rootComponent) {
165
+ this.performMutation = false;
166
+ this.activateChildSegments(currRoot, prevRoot, outletMap, [rootComponent]);
167
+ let allPaths = PromiseWrapper.all(this.deactivations.map(r => this.checkCanDeactivatePath(r)));
168
+ return allPaths.then((values) => values.filter(v => v).length === values.length);
169
+ }
170
+ checkCanDeactivatePath(path) {
171
+ let curr = PromiseWrapper.resolve(true);
172
+ for (let p of ListWrapper.reversed(path)) {
173
+ curr = curr.then(_ => {
174
+ if (hasLifecycleHook('routerCanDeactivate', p)) {
175
+ return p.routerCanDeactivate(this.prevTree, this.currTree);
176
+ }
177
+ else {
178
+ return _;
179
+ }
180
+ });
181
+ }
182
+ return curr;
183
+ }
184
+ activateChildSegments(currNode, prevNode, outletMap, components) {
185
+ let prevChildren = isPresent(prevNode) ? prevNode.children.reduce((m, c) => {
186
+ m[c.value.outlet] = c;
187
+ return m;
188
+ }, {}) : {};
189
+ currNode.children.forEach(c => {
190
+ this.activateSegments(c, prevChildren[c.value.outlet], outletMap, components);
191
+ StringMapWrapper.delete(prevChildren, c.value.outlet);
192
+ });
193
+ StringMapWrapper.forEach(prevChildren, (v /** TODO #9100 */, k /** TODO #9100 */) => this.deactivateOutlet(outletMap._outlets[k], components));
194
+ }
195
+ activateSegments(currNode, prevNode, parentOutletMap, components) {
196
+ let curr = currNode.value;
197
+ let prev = isPresent(prevNode) ? prevNode.value : null;
198
+ let outlet = this.getOutlet(parentOutletMap, currNode.value);
199
+ if (curr === prev) {
200
+ this.activateChildSegments(currNode, prevNode, outlet.outletMap, components.concat([outlet.component]));
201
+ }
202
+ else {
203
+ this.deactivateOutlet(outlet, components);
204
+ if (this.performMutation) {
205
+ let outletMap = new RouterOutletMap();
206
+ let component = this.activateNewSegments(outletMap, curr, prev, outlet);
207
+ this.activateChildSegments(currNode, prevNode, outletMap, components.concat([component]));
208
+ }
209
+ }
210
+ }
211
+ activateNewSegments(outletMap, curr, prev, outlet) {
212
+ let resolved = ReflectiveInjector.resolve([{ provide: RouterOutletMap, useValue: outletMap }, { provide: RouteSegment, useValue: curr }]);
213
+ let ref = outlet.activate(routeSegmentComponentFactory(curr), resolved, outletMap);
214
+ if (hasLifecycleHook('routerOnActivate', ref.instance)) {
215
+ ref.instance.routerOnActivate(curr, prev, this.currTree, this.prevTree);
216
+ }
217
+ return ref.instance;
218
+ }
219
+ getOutlet(outletMap, segment) {
220
+ let outlet = outletMap._outlets[segment.outlet];
221
+ if (isBlank(outlet)) {
222
+ if (segment.outlet == DEFAULT_OUTLET_NAME) {
223
+ throw new BaseException(`Cannot find default outlet`);
224
+ }
225
+ else {
226
+ throw new BaseException(`Cannot find the outlet ${segment.outlet}`);
227
+ }
228
+ }
229
+ return outlet;
230
+ }
231
+ deactivateOutlet(outlet, components) {
232
+ if (isPresent(outlet) && outlet.isActivated) {
233
+ StringMapWrapper.forEach(outlet.outletMap._outlets, (v /** TODO #9100 */, k /** TODO #9100 */) => this.deactivateOutlet(v, components));
234
+ if (this.performMutation) {
235
+ outlet.deactivate();
236
+ }
237
+ else {
238
+ this.deactivations.push(components.concat([outlet.component]));
239
+ }
240
+ }
241
+ }
242
+ }
243
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../../../../modules/@angular/router/src/router.ts"],"names":[],"mappings":"OACO,EAAC,aAAa,EAAqB,kBAAkB,EAAU,MAAM,eAAe;OAEpF,EAAC,mBAAmB,EAAC,MAAM,aAAa;OAExC,EAAC,YAAY,EAAc,iBAAiB,EAAE,cAAc,EAAC,MAAM,gBAAgB;OACnF,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,qBAAqB;OAC1D,EAAO,OAAO,EAAE,SAAS,EAAC,MAAM,eAAe;OAE/C,EAAC,gBAAgB,EAAC,MAAM,uBAAuB;OAC/C,EAAC,IAAI,EAAC,MAAM,QAAQ;OACpB,EAAC,SAAS,EAAC,MAAM,aAAa;OAE9B,EAAC,YAAY,EAA4C,oBAAoB,EAAE,QAAQ,EAAE,4BAA4B,EAA4B,MAAM,YAAY;AAE1K;IAAA;QACE,gBAAgB;QAChB,aAAQ,GAAmC,EAAE,CAAC;IAEhD,CAAC;IADC,cAAc,CAAC,IAAY,EAAE,MAAoB,IAAU,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;GAKG;AACH;IAME;;OAEG;IACH,YACY,cAAsB,EAAU,kBAAwB,EACxD,kBAAqC,EAAU,cAAmC,EAClF,gBAAiC,EAAU,SAAmB;QAF9D,mBAAc,GAAd,cAAc,CAAQ;QAAU,uBAAkB,GAAlB,kBAAkB,CAAM;QACxD,uBAAkB,GAAlB,kBAAkB,CAAmB;QAAU,mBAAc,GAAd,cAAc,CAAqB;QAClF,qBAAgB,GAAhB,gBAAgB,CAAiB;QAAU,cAAS,GAAT,SAAS,CAAU;QARlE,aAAQ,GAAuB,IAAI,Y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CAAC,CAAC;gBAC1C,MAAM,IAAI,aAAa,CAAC,4BAA4B,CAAC,CAAC;YACxD,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,MAAM,IAAI,aAAa,CAAC,0BAA0B,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;QACD,MAAM,CAAC,MAAM,CAAC;IAChB,CAAC;IAEO,gBAAgB,CAAC,MAAoB,EAAE,UAAoB;QACjE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;YAC5C,gBAAgB,CAAC,OAAO,CACpB,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAM,CAAC,iBAAiB,EAAE,CAAM,CAAC,iBAAiB,KAC/C,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;YACzE,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;gBACzB,MAAM,CAAC,UAAU,EAAE,CAAC;YACtB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAAA","sourcesContent":["import {Location} from '@angular/common';\nimport {BaseException, ComponentResolver, ReflectiveInjector, provide} from '@angular/core';\n\nimport {DEFAULT_OUTLET_NAME} from './constants';\nimport {RouterOutlet} from './directives/router_outlet';\nimport {EventEmitter, Observable, ObservableWrapper, PromiseWrapper} from './facade/async';\nimport {ListWrapper, StringMapWrapper} from './facade/collection';\nimport {Type, isBlank, isPresent} from './facade/lang';\nimport {CanDeactivate} from './interfaces';\nimport {hasLifecycleHook} from './lifecycle_reflector';\nimport {link} from './link';\nimport {recognize} from './recognize';\nimport {RouterUrlSerializer} from './router_url_serializer';\nimport {RouteSegment, RouteTree, TreeNode, UrlSegment, UrlTree, createEmptyRouteTree, rootNode, routeSegmentComponentFactory, serializeRouteSegmentTree} from './segments';\n\nexport class RouterOutletMap {\n /** @internal */\n _outlets: {[name: string]: RouterOutlet} = {};\n registerOutlet(name: string, outlet: RouterOutlet): void { this._outlets[name] = outlet; }\n}\n\n/**\n * The `Router` is responsible for mapping URLs to components.\n *\n * You can see the state of the router by inspecting the read-only fields `router.urlTree`\n * and `router.routeTree`.\n */\nexport class Router {\n private _routeTree: RouteTree;\n private _urlTree: UrlTree;\n private _locationSubscription: any;\n private _changes: EventEmitter<void> = new EventEmitter<void>();\n\n /**\n * @internal\n */\n constructor(\n private _rootComponent: Object, private _rootComponentType: Type,\n private _componentResolver: ComponentResolver, private _urlSerializer: RouterUrlSerializer,\n private _routerOutletMap: RouterOutletMap, private _location: Location) {\n this._routeTree = createEmptyRouteTree(this._rootComponentType);\n this._setUpLocationChangeListener();\n this.navigateByUrl(this._location.path());\n }\n\n /**\n * Returns the current url tree.\n */\n get urlTree(): UrlTree { return this._urlTree; }\n\n /**\n * Returns the current route tree.\n */\n get routeTree(): RouteTree { return this._routeTree; }\n\n /**\n * An observable or url changes from the router.\n */\n get changes(): Observable<void> { return this._changes; }\n\n /**\n * Navigate based on the provided url. This navigation is always absolute.\n *\n * ### Usage\n *\n * ```\n * router.navigateByUrl(\"/team/33/user/11\");\n * ```\n */\n navigateByUrl(url: string): Promise<void> {\n return this._navigate(this._urlSerializer.parse(url));\n }\n\n /**\n * Navigate based on the provided array of commands and a starting point.\n * If no segment is provided, the navigation is absolute.\n *\n * ### Usage\n *\n * ```\n * router.navigate(['team', 33, 'team', '11], segment);\n * ```\n */\n navigate(commands: any[], segment?: RouteSegment): Promise<void> {\n return this._navigate(this.createUrlTree(commands, segment));\n }\n\n /**\n * @internal\n */\n dispose(): void { ObservableWrapper.dispose(this._locationSubscription); }\n\n /**\n * Applies an array of commands to the current url tree and creates\n * a new url tree.\n *\n * When given a segment, applies the given commands starting from the segment.\n * When not given a segment, applies the given command starting from the root.\n *\n * ### Usage\n *\n * ```\n * // create /team/33/user/11\n * router.createUrlTree(['/team', 33, 'user', 11]);\n *\n * // create /team/33;expand=true/user/11\n * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);\n *\n * // you can collapse static fragments like this\n * router.createUrlTree(['/team/33/user', userId]);\n *\n * // assuming the current url is `/team/33/user/11` and the segment points to `user/11`\n *\n * // navigate to /team/33/user/11/details\n * router.createUrlTree(['details'], segment);\n *\n * // navigate to /team/33/user/22\n * router.createUrlTree(['../22'], segment);\n *\n * // navigate to /team/44/user/22\n * router.createUrlTree(['../../team/44/user/22'], segment);\n * ```\n */\n createUrlTree(commands: any[], segment?: RouteSegment): UrlTree {\n let s = isPresent(segment) ? segment : this._routeTree.root;\n return link(s, this._routeTree, this.urlTree, commands);\n }\n\n /**\n * Serializes a {@link UrlTree} into a string.\n */\n serializeUrl(url: UrlTree): string { return this._urlSerializer.serialize(url); }\n\n private _setUpLocationChangeListener(): void {\n this._locationSubscription = this._location.subscribe(\n (change) => { this._navigate(this._urlSerializer.parse(change['url']), change['pop']); });\n }\n\n private _navigate(url: UrlTree, preventPushState?: boolean): Promise<void> {\n this._urlTree = url;\n return recognize(this._componentResolver, this._rootComponentType, url, this._routeTree)\n .then(currTree => {\n return new _ActivateSegments(currTree, this._routeTree)\n .activate(this._routerOutletMap, this._rootComponent)\n .then(updated => {\n if (updated) {\n this._routeTree = currTree;\n if (isBlank(preventPushState) || !preventPushState) {\n let path = this._urlSerializer.serialize(this._urlTree);\n if (this._location.isCurrentPathEqualTo(path)) {\n this._location.replaceState(path);\n } else {\n this._location.go(path);\n }\n }\n this._changes.emit(null);\n }\n });\n });\n }\n}\n\n\nclass _ActivateSegments {\n private deactivations: Object[][] = [];\n private performMutation: boolean = true;\n\n constructor(private currTree: RouteTree, private prevTree: RouteTree) {}\n\n activate(parentOutletMap: RouterOutletMap, rootComponent: Object): Promise<boolean> {\n let prevRoot = isPresent(this.prevTree) ? rootNode(this.prevTree) : null;\n let currRoot = rootNode(this.currTree);\n\n return this.canDeactivate(currRoot, prevRoot, parentOutletMap, rootComponent).then(res => {\n this.performMutation = true;\n if (res) {\n this.activateChildSegments(currRoot, prevRoot, parentOutletMap, [rootComponent]);\n }\n return res;\n });\n }\n\n private canDeactivate(\n currRoot: TreeNode<RouteSegment>, prevRoot: TreeNode<RouteSegment>,\n outletMap: RouterOutletMap, rootComponent: Object): Promise<boolean> {\n this.performMutation = false;\n this.activateChildSegments(currRoot, prevRoot, outletMap, [rootComponent]);\n\n let allPaths = PromiseWrapper.all(this.deactivations.map(r => this.checkCanDeactivatePath(r)));\n return allPaths.then((values: boolean[]) => values.filter(v => v).length === values.length);\n }\n\n private checkCanDeactivatePath(path: Object[]): Promise<boolean> {\n let curr = PromiseWrapper.resolve(true);\n for (let p of ListWrapper.reversed(path)) {\n curr = curr.then(_ => {\n if (hasLifecycleHook('routerCanDeactivate', p)) {\n return (<CanDeactivate>p).routerCanDeactivate(this.prevTree, this.currTree);\n } else {\n return _;\n }\n });\n }\n return curr;\n }\n\n private activateChildSegments(\n currNode: TreeNode<RouteSegment>, prevNode: TreeNode<RouteSegment>,\n outletMap: RouterOutletMap, components: Object[]): void {\n let prevChildren = isPresent(prevNode) ? prevNode.children.reduce((m, c) => {\n (m as any /** TODO #9100 */)[c.value.outlet] = c;\n return m;\n }, {}) : {};\n\n currNode.children.forEach(c => {\n this.activateSegments(\n c, (prevChildren as any /** TODO #9100 */)[c.value.outlet], outletMap, components);\n StringMapWrapper.delete(prevChildren, c.value.outlet);\n });\n\n StringMapWrapper.forEach(\n prevChildren, (v: any /** TODO #9100 */, k: any /** TODO #9100 */) =>\n this.deactivateOutlet(outletMap._outlets[k], components));\n }\n\n activateSegments(\n currNode: TreeNode<RouteSegment>, prevNode: TreeNode<RouteSegment>,\n parentOutletMap: RouterOutletMap, components: Object[]): void {\n let curr = currNode.value;\n let prev = isPresent(prevNode) ? prevNode.value : null;\n let outlet = this.getOutlet(parentOutletMap, currNode.value);\n\n if (curr === prev) {\n this.activateChildSegments(\n currNode, prevNode, outlet.outletMap, components.concat([outlet.component]));\n } else {\n this.deactivateOutlet(outlet, components);\n if (this.performMutation) {\n let outletMap = new RouterOutletMap();\n let component = this.activateNewSegments(outletMap, curr, prev, outlet);\n this.activateChildSegments(currNode, prevNode, outletMap, components.concat([component]));\n }\n }\n }\n\n private activateNewSegments(\n outletMap: RouterOutletMap, curr: RouteSegment, prev: RouteSegment,\n outlet: RouterOutlet): Object {\n let resolved = ReflectiveInjector.resolve(\n [{provide: RouterOutletMap, useValue: outletMap}, {provide: RouteSegment, useValue: curr}]);\n let ref = outlet.activate(routeSegmentComponentFactory(curr), resolved, outletMap);\n if (hasLifecycleHook('routerOnActivate', ref.instance)) {\n ref.instance.routerOnActivate(curr, prev, this.currTree, this.prevTree);\n }\n return ref.instance;\n }\n\n private getOutlet(outletMap: RouterOutletMap, segment: RouteSegment): RouterOutlet {\n let outlet = outletMap._outlets[segment.outlet];\n if (isBlank(outlet)) {\n if (segment.outlet == DEFAULT_OUTLET_NAME) {\n throw new BaseException(`Cannot find default outlet`);\n } else {\n throw new BaseException(`Cannot find the outlet ${segment.outlet}`);\n }\n }\n return outlet;\n }\n\n private deactivateOutlet(outlet: RouterOutlet, components: Object[]): void {\n if (isPresent(outlet) && outlet.isActivated) {\n StringMapWrapper.forEach(\n outlet.outletMap._outlets, (v: any /** TODO #9100 */, k: any /** TODO #9100 */) =>\n this.deactivateOutlet(v, components));\n if (this.performMutation) {\n outlet.deactivate();\n } else {\n this.deactivations.push(components.concat([outlet.component]));\n }\n }\n }\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A list of providers. To use the router, you must add this to your application.
3
+ *
4
+ * ```
5
+ * import {Component} from '@angular/core';
6
+ * import {
7
+ * ROUTER_DIRECTIVES,
8
+ * ROUTER_PROVIDERS,
9
+ * Routes
10
+ * } from '@angular/router';
11
+ *
12
+ * @Component({directives: [ROUTER_DIRECTIVES]})
13
+ * @Routes([
14
+ * {...},
15
+ * ])
16
+ * class AppCmp {
17
+ * // ...
18
+ * }
19
+ *
20
+ * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
21
+ * ```
22
+ */
23
+ export declare const ROUTER_PROVIDERS: any[];
@@ -0,0 +1,26 @@
1
+ import { ROUTER_PROVIDERS_COMMON } from './router_providers_common';
2
+ /**
3
+ * A list of providers. To use the router, you must add this to your application.
4
+ *
5
+ * ```
6
+ * import {Component} from '@angular/core';
7
+ * import {
8
+ * ROUTER_DIRECTIVES,
9
+ * ROUTER_PROVIDERS,
10
+ * Routes
11
+ * } from '@angular/router';
12
+ *
13
+ * @Component({directives: [ROUTER_DIRECTIVES]})
14
+ * @Routes([
15
+ * {...},
16
+ * ])
17
+ * class AppCmp {
18
+ * // ...
19
+ * }
20
+ *
21
+ * bootstrap(AppCmp, [ROUTER_PROVIDERS]);
22
+ * ```
23
+ */
24
+ // TODO: merge with router_providers_common.ts
25
+ export const ROUTER_PROVIDERS = [ROUTER_PROVIDERS_COMMON];
26
+ //# sourceMappingURL=router_providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router_providers.js","sourceRoot":"","sources":["../../../../../modules/@angular/router/src/router_providers.ts"],"names":[],"mappings":"OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B;AAEjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8CAA8C;AAC9C,OAAO,MAAM,gBAAgB,GAA4B,CAAC,uBAAuB,CAAC,CAAC","sourcesContent":["import {ROUTER_PROVIDERS_COMMON} from './router_providers_common';\n\n/**\n * A list of providers. To use the router, you must add this to your application.\n *\n * ```\n * import {Component} from '@angular/core';\n * import {\n * ROUTER_DIRECTIVES,\n * ROUTER_PROVIDERS,\n * Routes\n * } from '@angular/router';\n *\n * @Component({directives: [ROUTER_DIRECTIVES]})\n * @Routes([\n * {...},\n * ])\n * class AppCmp {\n * // ...\n * }\n *\n * bootstrap(AppCmp, [ROUTER_PROVIDERS]);\n * ```\n */\n// TODO: merge with router_providers_common.ts\nexport const ROUTER_PROVIDERS: any[] = /*@ts2dart_const*/[ROUTER_PROVIDERS_COMMON];\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
@@ -0,0 +1 @@
1
+ {"__symbolic":"module","version":1,"metadata":{"ROUTER_PROVIDERS":[{"__symbolic":"reference","module":"./router_providers_common","name":"ROUTER_PROVIDERS_COMMON"}]}}
@@ -0,0 +1,11 @@
1
+ import { Location } from '@angular/common';
2
+ import { ApplicationRef, ComponentResolver } from '@angular/core';
3
+ import { Router, RouterOutletMap } from './router';
4
+ import { RouterUrlSerializer } from './router_url_serializer';
5
+ import { RouteSegment } from './segments';
6
+ /**
7
+ * The Platform agnostic ROUTER PROVIDERS
8
+ */
9
+ export declare const ROUTER_PROVIDERS_COMMON: any[];
10
+ export declare function routerFactory(app: ApplicationRef, componentResolver: ComponentResolver, urlSerializer: RouterUrlSerializer, routerOutletMap: RouterOutletMap, location: Location): Router;
11
+ export declare function routeSegmentFactory(router: Router): RouteSegment;
@@ -0,0 +1,32 @@
1
+ import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
2
+ import { ApplicationRef, BaseException, ComponentResolver } from '@angular/core';
3
+ import { Router, RouterOutletMap } from './router';
4
+ import { DefaultRouterUrlSerializer, RouterUrlSerializer } from './router_url_serializer';
5
+ import { RouteSegment } from './segments';
6
+ /**
7
+ * The Platform agnostic ROUTER PROVIDERS
8
+ */
9
+ export const ROUTER_PROVIDERS_COMMON = [
10
+ RouterOutletMap,
11
+ /*@ts2dart_Provider*/ { provide: RouterUrlSerializer, useClass: DefaultRouterUrlSerializer },
12
+ /*@ts2dart_Provider*/ { provide: LocationStrategy, useClass: PathLocationStrategy }, Location,
13
+ /*@ts2dart_Provider*/ {
14
+ provide: Router,
15
+ useFactory: routerFactory,
16
+ deps: /*@ts2dart_const*/ [ApplicationRef, ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location],
17
+ },
18
+ /*@ts2dart_Provider*/ { provide: RouteSegment, useFactory: routeSegmentFactory, deps: [Router] }
19
+ ];
20
+ export function routerFactory(app, componentResolver, urlSerializer, routerOutletMap, location) {
21
+ if (app.componentTypes.length == 0) {
22
+ throw new BaseException('Bootstrap at least one component before injecting Router.');
23
+ }
24
+ // TODO: vsavkin this should not be null
25
+ let router = new Router(null, app.componentTypes[0], componentResolver, urlSerializer, routerOutletMap, location);
26
+ app.registerDisposeListener(() => router.dispose());
27
+ return router;
28
+ }
29
+ export function routeSegmentFactory(router) {
30
+ return router.routeTree.root;
31
+ }
32
+ //# sourceMappingURL=router_providers_common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router_providers_common.js","sourceRoot":"","sources":["../../../../../modules/@angular/router/src/router_providers_common.ts"],"names":[],"mappings":"OAAO,EAAC,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,iBAAiB;OACzE,EAAC,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAC,MAAM,eAAe;OAEvE,EAAC,MAAM,EAAE,eAAe,EAAC,MAAM,UAAU;OACzC,EAAC,0BAA0B,EAAE,mBAAmB,EAAC,MAAM,yBAAyB;OAChF,EAAC,YAAY,EAAC,MAAM,YAAY;AAGvC;;GAEG;AACH,OAAO,MAAM,uBAAuB,GAA4B;IAC9D,eAAe;IACf,qBAAqB,CAAC,EAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,0BAA0B,EAAC;IAC1F,qBAAqB,CAAC,EAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,oBAAoB,EAAC,EAAE,QAAQ;IAC3F,qBAAqB,CAAC;QACpB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,aAAa;QACzB,IAAI,EAAE,kBAAkB,CACpB,CAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,CAAC;KACxF;IACD,qBAAqB,CAAC,EAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAC;CAC/F,CAAC;AAEF,8BACI,GAAmB,EAAE,iBAAoC,EAAE,aAAkC,EAC7F,eAAgC,EAAE,QAAkB;IACtD,EAAE,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,MAAM,IAAI,aAAa,CAAC,2DAA2D,CAAC,CAAC;IACvF,CAAC;IACD,wCAAwC;IACxC,IAAI,MAAM,GAAG,IAAI,MAAM,CACnB,IAAI,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IAC9F,GAAG,CAAC,uBAAuB,CAAC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACpD,MAAM,CAAC,MAAM,CAAC;AAChB,CAAC;AAED,oCAAoC,MAAc;IAChD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;AAC/B,CAAC","sourcesContent":["import {Location, LocationStrategy, PathLocationStrategy} from '@angular/common';\nimport {ApplicationRef, BaseException, ComponentResolver} from '@angular/core';\n\nimport {Router, RouterOutletMap} from './router';\nimport {DefaultRouterUrlSerializer, RouterUrlSerializer} from './router_url_serializer';\nimport {RouteSegment} from './segments';\n\n\n/**\n * The Platform agnostic ROUTER PROVIDERS\n */\nexport const ROUTER_PROVIDERS_COMMON: any[] = /*@ts2dart_const*/[\n RouterOutletMap,\n /*@ts2dart_Provider*/ {provide: RouterUrlSerializer, useClass: DefaultRouterUrlSerializer},\n /*@ts2dart_Provider*/ {provide: LocationStrategy, useClass: PathLocationStrategy}, Location,\n /*@ts2dart_Provider*/ {\n provide: Router,\n useFactory: routerFactory,\n deps: /*@ts2dart_const*/\n [ApplicationRef, ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location],\n },\n /*@ts2dart_Provider*/ {provide: RouteSegment, useFactory: routeSegmentFactory, deps: [Router]}\n];\n\nexport function routerFactory(\n app: ApplicationRef, componentResolver: ComponentResolver, urlSerializer: RouterUrlSerializer,\n routerOutletMap: RouterOutletMap, location: Location): Router {\n if (app.componentTypes.length == 0) {\n throw new BaseException('Bootstrap at least one component before injecting Router.');\n }\n // TODO: vsavkin this should not be null\n let router = new Router(\n null, app.componentTypes[0], componentResolver, urlSerializer, routerOutletMap, location);\n app.registerDisposeListener(() => router.dispose());\n return router;\n}\n\nexport function routeSegmentFactory(router: Router): RouteSegment {\n return router.routeTree.root;\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]}
@@ -0,0 +1 @@
1
+ {"__symbolic":"module","version":1,"metadata":{"ROUTER_PROVIDERS_COMMON":[{"__symbolic":"reference","module":"./router","name":"RouterOutletMap"},{"provide":{"__symbolic":"reference","module":"./router_url_serializer","name":"RouterUrlSerializer"},"useClass":{"__symbolic":"reference","module":"./router_url_serializer","name":"DefaultRouterUrlSerializer"}},{"provide":{"__symbolic":"reference","module":"@angular/common","name":"LocationStrategy"},"useClass":{"__symbolic":"reference","module":"@angular/common","name":"PathLocationStrategy"}},{"__symbolic":"reference","module":"@angular/common","name":"Location"},{"provide":{"__symbolic":"reference","module":"./router","name":"Router"},"useFactory":{"__symbolic":"reference","name":"routerFactory"},"deps":[{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef"},{"__symbolic":"reference","module":"@angular/core","name":"ComponentResolver"},{"__symbolic":"reference","module":"./router_url_serializer","name":"RouterUrlSerializer"},{"__symbolic":"reference","module":"./router","name":"RouterOutletMap"},{"__symbolic":"reference","module":"@angular/common","name":"Location"}]},{"provide":{"__symbolic":"reference","module":"./segments","name":"RouteSegment"},"useFactory":{"__symbolic":"reference","name":"routeSegmentFactory"},"deps":[{"__symbolic":"reference","module":"./router","name":"Router"}]}],"routeSegmentFactory":{"__symbolic":"function","parameters":["router"],"value":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"router"},"member":"routeTree"},"member":"root"}}}}
@@ -0,0 +1,21 @@
1
+ import { UrlTree } from './segments';
2
+ /**
3
+ * Defines a way to serialize/deserialize a url tree.
4
+ */
5
+ export declare abstract class RouterUrlSerializer {
6
+ /**
7
+ * Parse a url into a {@Link UrlTree}
8
+ */
9
+ abstract parse(url: string): UrlTree;
10
+ /**
11
+ * Converts a {@Link UrlTree} into a url
12
+ */
13
+ abstract serialize(tree: UrlTree): string;
14
+ }
15
+ /**
16
+ * A default implementation of the serialization.
17
+ */
18
+ export declare class DefaultRouterUrlSerializer extends RouterUrlSerializer {
19
+ parse(url: string): UrlTree;
20
+ serialize(tree: UrlTree): string;
21
+ }