@angular/router 7.2.0-beta.0 → 7.2.0

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 (130) hide show
  1. package/bundles/router-testing.umd.js +1 -1
  2. package/bundles/router-testing.umd.js.map +1 -1
  3. package/bundles/router-testing.umd.min.js +1 -1
  4. package/bundles/router-testing.umd.min.js.map +1 -1
  5. package/bundles/router-upgrade.umd.js +1 -1
  6. package/bundles/router-upgrade.umd.js.map +1 -1
  7. package/bundles/router-upgrade.umd.min.js +1 -1
  8. package/bundles/router-upgrade.umd.min.js.map +1 -1
  9. package/bundles/router.umd.js +87 -18
  10. package/bundles/router.umd.js.map +1 -1
  11. package/bundles/router.umd.min.js +6 -6
  12. package/bundles/router.umd.min.js.map +1 -1
  13. package/esm2015/index.js +2 -3
  14. package/esm2015/public_api.js +2 -4
  15. package/esm2015/router.externs.js +7 -3
  16. package/esm2015/router.js +1 -2
  17. package/esm2015/src/apply_redirects.js +60 -21
  18. package/esm2015/src/components/empty_outlet.js +2 -3
  19. package/esm2015/src/config.js +40 -66
  20. package/esm2015/src/create_router_state.js +3 -4
  21. package/esm2015/src/create_url_tree.js +3 -6
  22. package/esm2015/src/directives/router_link.js +71 -13
  23. package/esm2015/src/directives/router_link_active.js +30 -10
  24. package/esm2015/src/directives/router_outlet.js +46 -15
  25. package/esm2015/src/events.js +47 -35
  26. package/esm2015/src/index.js +2 -3
  27. package/esm2015/src/interfaces.js +44 -25
  28. package/esm2015/src/operators/activate_routes.js +31 -9
  29. package/esm2015/src/operators/apply_redirects.js +2 -3
  30. package/esm2015/src/operators/check_guards.js +8 -9
  31. package/esm2015/src/operators/prioritized_guard_value.js +4 -6
  32. package/esm2015/src/operators/recognize.js +2 -3
  33. package/esm2015/src/operators/resolve_data.js +3 -4
  34. package/esm2015/src/operators/switch_tap.js +2 -3
  35. package/esm2015/src/private_export.js +2 -3
  36. package/esm2015/src/recognize.js +41 -21
  37. package/esm2015/src/route_reuse_strategy.js +2 -9
  38. package/esm2015/src/router.js +304 -199
  39. package/esm2015/src/router_config_loader.js +24 -10
  40. package/esm2015/src/router_module.js +202 -188
  41. package/esm2015/src/router_outlet_context.js +7 -4
  42. package/esm2015/src/router_preloader.js +27 -8
  43. package/esm2015/src/router_scroller.js +37 -11
  44. package/esm2015/src/router_state.js +12 -19
  45. package/esm2015/src/shared.js +42 -34
  46. package/esm2015/src/url_handling_strategy.js +2 -3
  47. package/esm2015/src/url_tree.js +31 -7
  48. package/esm2015/src/utils/collection.js +2 -3
  49. package/esm2015/src/utils/preactivation.js +10 -5
  50. package/esm2015/src/utils/tree.js +5 -3
  51. package/esm2015/src/utils/type_guards.js +2 -3
  52. package/esm2015/src/version.js +11 -6
  53. package/esm2015/testing/index.js +2 -3
  54. package/esm2015/testing/public_api.js +2 -4
  55. package/esm2015/testing/src/router_testing_module.js +9 -6
  56. package/esm2015/testing/src/testing.js +2 -3
  57. package/esm2015/testing/testing.js +1 -2
  58. package/esm2015/upgrade/index.js +2 -3
  59. package/esm2015/upgrade/public_api.js +2 -4
  60. package/esm2015/upgrade/src/upgrade.js +9 -8
  61. package/esm2015/upgrade/upgrade.js +1 -2
  62. package/esm5/index.js +1 -2
  63. package/esm5/public_api.js +1 -2
  64. package/esm5/router.js +1 -2
  65. package/esm5/src/apply_redirects.js +1 -2
  66. package/esm5/src/components/empty_outlet.js +1 -2
  67. package/esm5/src/config.js +1 -2
  68. package/esm5/src/create_router_state.js +1 -2
  69. package/esm5/src/create_url_tree.js +1 -2
  70. package/esm5/src/directives/router_link.js +31 -2
  71. package/esm5/src/directives/router_link_active.js +1 -2
  72. package/esm5/src/directives/router_outlet.js +1 -2
  73. package/esm5/src/events.js +1 -2
  74. package/esm5/src/index.js +1 -2
  75. package/esm5/src/interfaces.js +1 -2
  76. package/esm5/src/operators/activate_routes.js +1 -2
  77. package/esm5/src/operators/apply_redirects.js +1 -2
  78. package/esm5/src/operators/check_guards.js +1 -2
  79. package/esm5/src/operators/prioritized_guard_value.js +1 -2
  80. package/esm5/src/operators/recognize.js +1 -2
  81. package/esm5/src/operators/resolve_data.js +1 -2
  82. package/esm5/src/operators/switch_tap.js +1 -2
  83. package/esm5/src/private_export.js +1 -2
  84. package/esm5/src/recognize.js +1 -2
  85. package/esm5/src/route_reuse_strategy.js +1 -2
  86. package/esm5/src/router.js +50 -18
  87. package/esm5/src/router_config_loader.js +1 -2
  88. package/esm5/src/router_module.js +1 -2
  89. package/esm5/src/router_outlet_context.js +1 -2
  90. package/esm5/src/router_preloader.js +1 -2
  91. package/esm5/src/router_scroller.js +1 -2
  92. package/esm5/src/router_state.js +1 -2
  93. package/esm5/src/shared.js +1 -2
  94. package/esm5/src/url_handling_strategy.js +1 -2
  95. package/esm5/src/url_tree.js +1 -2
  96. package/esm5/src/utils/collection.js +1 -2
  97. package/esm5/src/utils/preactivation.js +7 -2
  98. package/esm5/src/utils/tree.js +1 -2
  99. package/esm5/src/utils/type_guards.js +1 -2
  100. package/esm5/src/version.js +2 -3
  101. package/esm5/testing/index.js +1 -2
  102. package/esm5/testing/public_api.js +1 -2
  103. package/esm5/testing/src/router_testing_module.js +1 -2
  104. package/esm5/testing/src/testing.js +1 -2
  105. package/esm5/testing/testing.js +1 -2
  106. package/esm5/upgrade/index.js +1 -2
  107. package/esm5/upgrade/public_api.js +1 -2
  108. package/esm5/upgrade/src/upgrade.js +1 -2
  109. package/esm5/upgrade/upgrade.js +1 -2
  110. package/fesm2015/router.js +387 -202
  111. package/fesm2015/router.js.map +1 -1
  112. package/fesm2015/testing.js +7 -8
  113. package/fesm2015/testing.js.map +1 -1
  114. package/fesm2015/upgrade.js +11 -10
  115. package/fesm2015/upgrade.js.map +1 -1
  116. package/fesm5/router.js +87 -18
  117. package/fesm5/router.js.map +1 -1
  118. package/fesm5/testing.js +1 -1
  119. package/fesm5/testing.js.map +1 -1
  120. package/fesm5/upgrade.js +1 -1
  121. package/fesm5/upgrade.js.map +1 -1
  122. package/package.json +4 -4
  123. package/router.metadata.json +1 -1
  124. package/src/config.d.ts +9 -2
  125. package/src/directives/router_link.d.ts +27 -0
  126. package/src/events.d.ts +6 -2
  127. package/src/index.d.ts +1 -1
  128. package/src/router.d.ts +74 -3
  129. package/testing.d.ts +5 -0
  130. package/upgrade.d.ts +5 -0
package/src/router.d.ts CHANGED
@@ -125,6 +125,20 @@ export interface NavigationExtras {
125
125
  * ```
126
126
  */
127
127
  replaceUrl?: boolean;
128
+ /**
129
+ * State passed to any navigation. This value will be accessible through the `extras` object
130
+ * returned from `router.getCurrentNavigation()` while a navigation is executing. Once a
131
+ * navigation completes, this value will be written to `history.state` when the `location.go`
132
+ * or `location.replaceState` method is called before activating of this route. Note that
133
+ * `history.state` will not pass an object equality test because the `navigationId` will be
134
+ * added to the state before being written.
135
+ *
136
+ * While `history.state` can accept any type of value, because the router adds the `navigationId`
137
+ * on each navigation, the `state` must always be an object.
138
+ */
139
+ state?: {
140
+ [k: string]: any;
141
+ };
128
142
  }
129
143
  /**
130
144
  * @description
@@ -138,6 +152,56 @@ export interface NavigationExtras {
138
152
  * @publicApi
139
153
  */
140
154
  export declare type ErrorHandler = (error: any) => any;
155
+ export declare type RestoredState = {
156
+ [k: string]: any;
157
+ navigationId: number;
158
+ };
159
+ /**
160
+ * @description
161
+ *
162
+ * Information about any given navigation. This information can be gotten from the router at
163
+ * any time using the `router.getCurrentNavigation()` method.
164
+ *
165
+ * @publicApi
166
+ */
167
+ export declare type Navigation = {
168
+ /**
169
+ * The ID of the current navigation.
170
+ */
171
+ id: number;
172
+ /**
173
+ * Target URL passed into the {@link Router#navigateByUrl} call before navigation. This is
174
+ * the value before the router has parsed or applied redirects to it.
175
+ */
176
+ initialUrl: string | UrlTree;
177
+ /**
178
+ * The initial target URL after being parsed with {@link UrlSerializer.extract()}.
179
+ */
180
+ extractedUrl: UrlTree;
181
+ /**
182
+ * Extracted URL after redirects have been applied. This URL may not be available immediately,
183
+ * therefore this property can be `undefined`. It is guaranteed to be set after the
184
+ * {@link RoutesRecognized} event fires.
185
+ */
186
+ finalUrl?: UrlTree;
187
+ /**
188
+ * Identifies the trigger of the navigation.
189
+ *
190
+ * * 'imperative'--triggered by `router.navigateByUrl` or `router.navigate`.
191
+ * * 'popstate'--triggered by a popstate event
192
+ * * 'hashchange'--triggered by a hashchange event
193
+ */
194
+ trigger: 'imperative' | 'popstate' | 'hashchange';
195
+ /**
196
+ * The NavigationExtras used in this navigation. See {@link NavigationExtras} for more info.
197
+ */
198
+ extras: NavigationExtras;
199
+ /**
200
+ * Previously successful Navigation object. Only a single previous Navigation is available,
201
+ * therefore this previous Navigation will always have a `null` value for `previousNavigation`.
202
+ */
203
+ previousNavigation: Navigation | null;
204
+ };
141
205
  export declare type NavigationTransition = {
142
206
  id: number;
143
207
  currentUrlTree: UrlTree;
@@ -150,9 +214,7 @@ export declare type NavigationTransition = {
150
214
  reject: any;
151
215
  promise: Promise<boolean>;
152
216
  source: NavigationTrigger;
153
- state: {
154
- navigationId: number;
155
- } | null;
217
+ restoredState: RestoredState | null;
156
218
  currentSnapshot: RouterStateSnapshot;
157
219
  targetSnapshot: RouterStateSnapshot | null;
158
220
  currentRouterState: RouterState;
@@ -181,6 +243,8 @@ export declare class Router {
181
243
  private rawUrlTree;
182
244
  private readonly transitions;
183
245
  private navigations;
246
+ private lastSuccessfulNavigation;
247
+ private currentNavigation;
184
248
  private locationSubscription;
185
249
  private navigationId;
186
250
  private configLoader;
@@ -259,6 +323,8 @@ export declare class Router {
259
323
  setUpLocationChangeListener(): void;
260
324
  /** The current url */
261
325
  readonly url: string;
326
+ /** The current Navigation object if one exists */
327
+ getCurrentNavigation(): Navigation | null;
262
328
  /**
263
329
  * Resets the configuration used for navigation and generating links.
264
330
  *
@@ -372,6 +438,11 @@ export declare class Router {
372
438
  * The first parameter of `navigate()` is a delta to be applied to the current URL
373
439
  * or the one provided in the `relativeTo` property of the second parameter (the
374
440
  * `NavigationExtras`).
441
+ *
442
+ * In order to affect this browser's `history.state` entry, the `state`
443
+ * parameter can be passed. This must be an object because the router
444
+ * will add the `navigationId` property to this object before creating
445
+ * the new history item.
375
446
  */
376
447
  navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
377
448
  /** Serializes a `UrlTree` into a string */
package/testing.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @license Angular v7.2.0
3
+ * (c) 2010-2018 Google, Inc. https://angular.io/
4
+ * License: MIT
5
+ */
1
6
 
2
7
  export * from './testing/testing';
3
8
 
package/upgrade.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @license Angular v7.2.0
3
+ * (c) 2010-2018 Google, Inc. https://angular.io/
4
+ * License: MIT
5
+ */
1
6
 
2
7
  export * from './upgrade/upgrade';
3
8