@angular/router 12.0.4 → 12.0.5
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.
- package/bundles/router-testing.umd.js +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router.umd.js +99 -23
- package/bundles/router.umd.js.map +1 -1
- package/esm2015/src/router.js +98 -22
- package/esm2015/src/version.js +1 -1
- package/fesm2015/router.js +99 -23
- package/fesm2015/router.js.map +1 -1
- package/fesm2015/testing.js +1 -1
- package/fesm2015/upgrade.js +1 -1
- package/package.json +4 -4
- package/router.d.ts +15 -1
- package/router.metadata.json +1 -1
- package/testing/testing.d.ts +1 -1
- package/testing.d.ts +1 -1
- package/upgrade/upgrade.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/esm2015/src/version.js
CHANGED
|
@@ -14,5 +14,5 @@ import { Version } from '@angular/core';
|
|
|
14
14
|
/**
|
|
15
15
|
* @publicApi
|
|
16
16
|
*/
|
|
17
|
-
export const VERSION = new Version('12.0.
|
|
17
|
+
export const VERSION = new Version('12.0.5');
|
|
18
18
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyc2lvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL3JvdXRlci9zcmMvdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSDs7OztHQUlHO0FBRUgsT0FBTyxFQUFDLE9BQU8sRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUV0Qzs7R0FFRztBQUNILE1BQU0sQ0FBQyxNQUFNLE9BQU8sR0FBRyxJQUFJLE9BQU8sQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAbGljZW5zZVxuICogQ29weXJpZ2h0IEdvb2dsZSBMTEMgQWxsIFJpZ2h0cyBSZXNlcnZlZC5cbiAqXG4gKiBVc2Ugb2YgdGhpcyBzb3VyY2UgY29kZSBpcyBnb3Zlcm5lZCBieSBhbiBNSVQtc3R5bGUgbGljZW5zZSB0aGF0IGNhbiBiZVxuICogZm91bmQgaW4gdGhlIExJQ0VOU0UgZmlsZSBhdCBodHRwczovL2FuZ3VsYXIuaW8vbGljZW5zZVxuICovXG5cbi8qKlxuICogQG1vZHVsZVxuICogQGRlc2NyaXB0aW9uXG4gKiBFbnRyeSBwb2ludCBmb3IgYWxsIHB1YmxpYyBBUElzIG9mIHRoZSByb3V0ZXIgcGFja2FnZS5cbiAqL1xuXG5pbXBvcnQge1ZlcnNpb259IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuXG4vKipcbiAqIEBwdWJsaWNBcGlcbiAqL1xuZXhwb3J0IGNvbnN0IFZFUlNJT04gPSBuZXcgVmVyc2lvbignMC4wLjAtUExBQ0VIT0xERVInKTtcbiJdfQ==
|
package/fesm2015/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.0.
|
|
2
|
+
* @license Angular v12.0.5
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -3876,6 +3876,11 @@ class Router {
|
|
|
3876
3876
|
*/
|
|
3877
3877
|
this.lastLocationChangeInfo = null;
|
|
3878
3878
|
this.navigationId = 0;
|
|
3879
|
+
/**
|
|
3880
|
+
* The id of the currently active page in the router.
|
|
3881
|
+
* Updated to the transition's target id on a successful navigation.
|
|
3882
|
+
*/
|
|
3883
|
+
this.currentPageId = 0;
|
|
3879
3884
|
this.isNgZoneEnabled = false;
|
|
3880
3885
|
/**
|
|
3881
3886
|
* An event stream for routing events in this NgModule.
|
|
@@ -3952,6 +3957,24 @@ class Router {
|
|
|
3952
3957
|
* @see `RouterModule`
|
|
3953
3958
|
*/
|
|
3954
3959
|
this.relativeLinkResolution = 'corrected';
|
|
3960
|
+
/**
|
|
3961
|
+
* Configures how the Router attempts to restore state when a navigation is cancelled.
|
|
3962
|
+
*
|
|
3963
|
+
* 'replace' - Always uses `location.replaceState` to set the browser state to the state of the
|
|
3964
|
+
* router before the navigation started.
|
|
3965
|
+
*
|
|
3966
|
+
* 'computed' - Will always return to the same state that corresponds to the actual Angular route
|
|
3967
|
+
* when the navigation gets cancelled right after triggering a `popstate` event.
|
|
3968
|
+
*
|
|
3969
|
+
* The default value is `replace`
|
|
3970
|
+
*
|
|
3971
|
+
* @internal
|
|
3972
|
+
*/
|
|
3973
|
+
// TODO(atscott): Determine how/when/if to make this public API
|
|
3974
|
+
// This shouldn’t be an option at all but may need to be in order to allow migration without a
|
|
3975
|
+
// breaking change. We need to determine if it should be made into public api (or if we forgo
|
|
3976
|
+
// the option and release as a breaking change bug fix in a major version).
|
|
3977
|
+
this.canceledNavigationResolution = 'replace';
|
|
3955
3978
|
const onLoadStart = (r) => this.triggerEvent(new RouteConfigLoadStart(r));
|
|
3956
3979
|
const onLoadEnd = (r) => this.triggerEvent(new RouteConfigLoadEnd(r));
|
|
3957
3980
|
this.ngModule = injector.get(NgModuleRef);
|
|
@@ -3966,6 +3989,7 @@ class Router {
|
|
|
3966
3989
|
this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
|
|
3967
3990
|
this.transitions = new BehaviorSubject({
|
|
3968
3991
|
id: 0,
|
|
3992
|
+
targetPageId: 0,
|
|
3969
3993
|
currentUrlTree: this.currentUrlTree,
|
|
3970
3994
|
currentRawUrl: this.currentUrlTree,
|
|
3971
3995
|
extractedUrl: this.urlHandlingStrategy.extract(this.currentUrlTree),
|
|
@@ -4038,7 +4062,7 @@ class Router {
|
|
|
4038
4062
|
tap(t => {
|
|
4039
4063
|
if (this.urlUpdateStrategy === 'eager') {
|
|
4040
4064
|
if (!t.extras.skipLocationChange) {
|
|
4041
|
-
this.setBrowserUrl(t.urlAfterRedirects,
|
|
4065
|
+
this.setBrowserUrl(t.urlAfterRedirects, t);
|
|
4042
4066
|
}
|
|
4043
4067
|
this.browserUrlTree = t.urlAfterRedirects;
|
|
4044
4068
|
}
|
|
@@ -4098,10 +4122,7 @@ class Router {
|
|
|
4098
4122
|
this.triggerEvent(guardsEnd);
|
|
4099
4123
|
}), filter(t => {
|
|
4100
4124
|
if (!t.guardsResult) {
|
|
4101
|
-
this.
|
|
4102
|
-
const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), '');
|
|
4103
|
-
eventsSubject.next(navCancel);
|
|
4104
|
-
t.resolve(false);
|
|
4125
|
+
this.cancelNavigationTransition(t, '');
|
|
4105
4126
|
return false;
|
|
4106
4127
|
}
|
|
4107
4128
|
return true;
|
|
@@ -4118,9 +4139,7 @@ class Router {
|
|
|
4118
4139
|
next: () => dataResolved = true,
|
|
4119
4140
|
complete: () => {
|
|
4120
4141
|
if (!dataResolved) {
|
|
4121
|
-
|
|
4122
|
-
eventsSubject.next(navCancel);
|
|
4123
|
-
t.resolve(false);
|
|
4142
|
+
this.cancelNavigationTransition(t, `At least one route resolver didn't emit any value.`);
|
|
4124
4143
|
}
|
|
4125
4144
|
}
|
|
4126
4145
|
}));
|
|
@@ -4157,7 +4176,7 @@ class Router {
|
|
|
4157
4176
|
this.routerState = t.targetRouterState;
|
|
4158
4177
|
if (this.urlUpdateStrategy === 'deferred') {
|
|
4159
4178
|
if (!t.extras.skipLocationChange) {
|
|
4160
|
-
this.setBrowserUrl(this.rawUrlTree,
|
|
4179
|
+
this.setBrowserUrl(this.rawUrlTree, t);
|
|
4161
4180
|
}
|
|
4162
4181
|
this.browserUrlTree = t.urlAfterRedirects;
|
|
4163
4182
|
}
|
|
@@ -4184,10 +4203,7 @@ class Router {
|
|
|
4184
4203
|
// sync code which looks for a value here in order to determine whether or
|
|
4185
4204
|
// not to handle a given popstate event or to leave it to the Angular
|
|
4186
4205
|
// router.
|
|
4187
|
-
this.
|
|
4188
|
-
const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}`);
|
|
4189
|
-
eventsSubject.next(navCancel);
|
|
4190
|
-
t.resolve(false);
|
|
4206
|
+
this.cancelNavigationTransition(t, `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}`);
|
|
4191
4207
|
}
|
|
4192
4208
|
// currentNavigation should always be reset to null here. If navigation was
|
|
4193
4209
|
// successful, lastSuccessfulTransition will have already been set. Therefore
|
|
@@ -4299,6 +4315,7 @@ class Router {
|
|
|
4299
4315
|
if (state) {
|
|
4300
4316
|
const stateCopy = Object.assign({}, state);
|
|
4301
4317
|
delete stateCopy.navigationId;
|
|
4318
|
+
delete stateCopy.ɵrouterPageId;
|
|
4302
4319
|
if (Object.keys(stateCopy).length !== 0) {
|
|
4303
4320
|
extras.state = stateCopy;
|
|
4304
4321
|
}
|
|
@@ -4493,7 +4510,14 @@ class Router {
|
|
|
4493
4510
|
}
|
|
4494
4511
|
const urlTree = isUrlTree(url) ? url : this.parseUrl(url);
|
|
4495
4512
|
const mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
|
|
4496
|
-
|
|
4513
|
+
let restoredState = null;
|
|
4514
|
+
if (this.canceledNavigationResolution === 'computed') {
|
|
4515
|
+
const isInitialPage = this.currentPageId === 0;
|
|
4516
|
+
if (isInitialPage || extras.skipLocationChange || extras.replaceUrl) {
|
|
4517
|
+
restoredState = this.location.getState();
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
return this.scheduleNavigation(mergedTree, 'imperative', restoredState, extras);
|
|
4497
4521
|
}
|
|
4498
4522
|
/**
|
|
4499
4523
|
* Navigate based on the provided array of commands and a starting point.
|
|
@@ -4574,6 +4598,7 @@ class Router {
|
|
|
4574
4598
|
this.navigations.subscribe(t => {
|
|
4575
4599
|
this.navigated = true;
|
|
4576
4600
|
this.lastSuccessfulId = t.id;
|
|
4601
|
+
this.currentPageId = t.targetPageId;
|
|
4577
4602
|
this.events
|
|
4578
4603
|
.next(new NavigationEnd(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(this.currentUrlTree)));
|
|
4579
4604
|
this.lastSuccessfulNavigation = this.currentNavigation;
|
|
@@ -4624,8 +4649,24 @@ class Router {
|
|
|
4624
4649
|
});
|
|
4625
4650
|
}
|
|
4626
4651
|
const id = ++this.navigationId;
|
|
4652
|
+
let targetPageId;
|
|
4653
|
+
if (this.canceledNavigationResolution === 'computed') {
|
|
4654
|
+
// If the `ɵrouterPageId` exist in the state then `targetpageId` should have the value of
|
|
4655
|
+
// `ɵrouterPageId`
|
|
4656
|
+
if (restoredState && restoredState.ɵrouterPageId) {
|
|
4657
|
+
targetPageId = restoredState.ɵrouterPageId;
|
|
4658
|
+
}
|
|
4659
|
+
else {
|
|
4660
|
+
targetPageId = this.currentPageId + 1;
|
|
4661
|
+
}
|
|
4662
|
+
}
|
|
4663
|
+
else {
|
|
4664
|
+
// This is unused when `canceledNavigationResolution` is not computed.
|
|
4665
|
+
targetPageId = 0;
|
|
4666
|
+
}
|
|
4627
4667
|
this.setTransition({
|
|
4628
4668
|
id,
|
|
4669
|
+
targetPageId,
|
|
4629
4670
|
source,
|
|
4630
4671
|
restoredState,
|
|
4631
4672
|
currentUrlTree: this.currentUrlTree,
|
|
@@ -4644,15 +4685,14 @@ class Router {
|
|
|
4644
4685
|
return Promise.reject(e);
|
|
4645
4686
|
});
|
|
4646
4687
|
}
|
|
4647
|
-
setBrowserUrl(url,
|
|
4688
|
+
setBrowserUrl(url, t) {
|
|
4648
4689
|
const path = this.urlSerializer.serialize(url);
|
|
4649
|
-
state = state
|
|
4650
|
-
if (this.location.isCurrentPathEqualTo(path) || replaceUrl) {
|
|
4651
|
-
|
|
4652
|
-
this.location.replaceState(path, '', Object.assign(Object.assign({}, state), { navigationId: id }));
|
|
4690
|
+
const state = Object.assign(Object.assign({}, t.extras.state), this.generateNgRouterState(t.id, t.targetPageId));
|
|
4691
|
+
if (this.location.isCurrentPathEqualTo(path) || !!t.extras.replaceUrl) {
|
|
4692
|
+
this.location.replaceState(path, '', state);
|
|
4653
4693
|
}
|
|
4654
4694
|
else {
|
|
4655
|
-
this.location.go(path, '',
|
|
4695
|
+
this.location.go(path, '', state);
|
|
4656
4696
|
}
|
|
4657
4697
|
}
|
|
4658
4698
|
resetStateAndUrl(storedState, storedUrl, rawUrl) {
|
|
@@ -4662,7 +4702,43 @@ class Router {
|
|
|
4662
4702
|
this.resetUrlToCurrentUrlTree();
|
|
4663
4703
|
}
|
|
4664
4704
|
resetUrlToCurrentUrlTree() {
|
|
4665
|
-
this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '',
|
|
4705
|
+
this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
|
|
4706
|
+
}
|
|
4707
|
+
/**
|
|
4708
|
+
* Responsible for handling the cancellation of a navigation:
|
|
4709
|
+
* - performs the necessary rollback action to restore the browser URL to the
|
|
4710
|
+
* state before the transition
|
|
4711
|
+
* - triggers the `NavigationCancel` event
|
|
4712
|
+
* - resolves the transition promise with `false`
|
|
4713
|
+
*/
|
|
4714
|
+
cancelNavigationTransition(t, reason) {
|
|
4715
|
+
if (this.canceledNavigationResolution === 'computed') {
|
|
4716
|
+
// The navigator change the location before triggered the browser event,
|
|
4717
|
+
// so we need to go back to the current url if the navigation is canceled.
|
|
4718
|
+
// Also, when navigation gets cancelled while using url update strategy eager, then we need to
|
|
4719
|
+
// go back. Because, when `urlUpdateSrategy` is `eager`; `setBrowserUrl` method is called
|
|
4720
|
+
// before any verification.
|
|
4721
|
+
if (t.source === 'popstate' || this.urlUpdateStrategy === 'eager') {
|
|
4722
|
+
const targetPagePosition = this.currentPageId - t.targetPageId;
|
|
4723
|
+
this.location.historyGo(targetPagePosition);
|
|
4724
|
+
}
|
|
4725
|
+
else {
|
|
4726
|
+
// If update is not 'eager' and the transition navigation source isn't 'popstate', then the
|
|
4727
|
+
// navigation was cancelled before any browser url change so nothing needs to be restored.
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
else {
|
|
4731
|
+
this.resetUrlToCurrentUrlTree();
|
|
4732
|
+
}
|
|
4733
|
+
const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), reason);
|
|
4734
|
+
this.triggerEvent(navCancel);
|
|
4735
|
+
t.resolve(false);
|
|
4736
|
+
}
|
|
4737
|
+
generateNgRouterState(navigationId, routerPageId) {
|
|
4738
|
+
if (this.canceledNavigationResolution === 'computed') {
|
|
4739
|
+
return { navigationId, ɵrouterPageId: routerPageId };
|
|
4740
|
+
}
|
|
4741
|
+
return { navigationId };
|
|
4666
4742
|
}
|
|
4667
4743
|
}
|
|
4668
4744
|
Router.decorators = [
|
|
@@ -5903,7 +5979,7 @@ function provideRouterInitializer() {
|
|
|
5903
5979
|
/**
|
|
5904
5980
|
* @publicApi
|
|
5905
5981
|
*/
|
|
5906
|
-
const VERSION = new Version('12.0.
|
|
5982
|
+
const VERSION = new Version('12.0.5');
|
|
5907
5983
|
|
|
5908
5984
|
/**
|
|
5909
5985
|
* @license
|