@angular/router 12.1.1 → 12.1.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.
- package/bundles/router-testing.umd.js +1 -1
- package/bundles/router-upgrade.umd.js +1 -1
- package/bundles/router.umd.js +67 -27
- package/bundles/router.umd.js.map +1 -1
- package/esm2015/src/events.js +1 -1
- package/esm2015/src/router.js +60 -24
- package/esm2015/src/router_state.js +1 -1
- package/esm2015/src/version.js +1 -1
- package/fesm2015/router.js +61 -25
- 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 +19 -7
- package/router.metadata.json +1 -1
- package/testing/testing.d.ts +4 -4
- package/testing.d.ts +1 -1
- package/upgrade/upgrade.d.ts +1 -1
- package/upgrade.d.ts +1 -1
package/bundles/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.1.
|
|
2
|
+
* @license Angular v12.1.2
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -4472,6 +4472,10 @@
|
|
|
4472
4472
|
/**
|
|
4473
4473
|
* The id of the currently active page in the router.
|
|
4474
4474
|
* Updated to the transition's target id on a successful navigation.
|
|
4475
|
+
*
|
|
4476
|
+
* This is used to track what page the router last activated. When an attempted navigation fails,
|
|
4477
|
+
* the router can then use this to compute how to restore the state back to the previously active
|
|
4478
|
+
* page.
|
|
4475
4479
|
*/
|
|
4476
4480
|
this.currentPageId = 0;
|
|
4477
4481
|
this.isNgZoneEnabled = false;
|
|
@@ -4604,6 +4608,19 @@
|
|
|
4604
4608
|
this.navigations = this.setupNavigations(this.transitions);
|
|
4605
4609
|
this.processNavigations();
|
|
4606
4610
|
}
|
|
4611
|
+
Object.defineProperty(Router.prototype, "browserPageId", {
|
|
4612
|
+
/**
|
|
4613
|
+
* The ɵrouterPageId of whatever page is currently active in the browser history. This is
|
|
4614
|
+
* important for computing the target page id for new navigations because we need to ensure each
|
|
4615
|
+
* page id in the browser history is 1 more than the previous entry.
|
|
4616
|
+
*/
|
|
4617
|
+
get: function () {
|
|
4618
|
+
var _a;
|
|
4619
|
+
return (_a = this.location.getState()) === null || _a === void 0 ? void 0 : _a.ɵrouterPageId;
|
|
4620
|
+
},
|
|
4621
|
+
enumerable: false,
|
|
4622
|
+
configurable: true
|
|
4623
|
+
});
|
|
4607
4624
|
Router.prototype.setupNavigations = function (transitions) {
|
|
4608
4625
|
var _this = this;
|
|
4609
4626
|
var eventsSubject = this.events;
|
|
@@ -4693,7 +4710,7 @@
|
|
|
4693
4710
|
}),
|
|
4694
4711
|
// Before Preactivation
|
|
4695
4712
|
switchTap(function (t) {
|
|
4696
|
-
var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl,
|
|
4713
|
+
var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _c = t.extras, skipLocationChange = _c.skipLocationChange, replaceUrl = _c.replaceUrl;
|
|
4697
4714
|
return _this.hooks.beforePreactivation(targetSnapshot, {
|
|
4698
4715
|
navigationId: navigationId,
|
|
4699
4716
|
appliedUrlTree: appliedUrlTree,
|
|
@@ -4716,7 +4733,7 @@
|
|
|
4716
4733
|
_this.triggerEvent(guardsEnd);
|
|
4717
4734
|
}), operators.filter(function (t) {
|
|
4718
4735
|
if (!t.guardsResult) {
|
|
4719
|
-
_this.
|
|
4736
|
+
_this.cancelNavigationTransitionRestoreHistory(t, '');
|
|
4720
4737
|
return false;
|
|
4721
4738
|
}
|
|
4722
4739
|
return true;
|
|
@@ -4733,7 +4750,7 @@
|
|
|
4733
4750
|
next: function () { return dataResolved = true; },
|
|
4734
4751
|
complete: function () {
|
|
4735
4752
|
if (!dataResolved) {
|
|
4736
|
-
_this.
|
|
4753
|
+
_this.cancelNavigationTransitionRestoreHistory(t, "At least one route resolver didn't emit any value.");
|
|
4737
4754
|
}
|
|
4738
4755
|
}
|
|
4739
4756
|
}));
|
|
@@ -4746,7 +4763,7 @@
|
|
|
4746
4763
|
}),
|
|
4747
4764
|
// --- AFTER PREACTIVATION ---
|
|
4748
4765
|
switchTap(function (t) {
|
|
4749
|
-
var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl,
|
|
4766
|
+
var targetSnapshot = t.targetSnapshot, navigationId = t.id, appliedUrlTree = t.extractedUrl, rawUrlTree = t.rawUrl, _c = t.extras, skipLocationChange = _c.skipLocationChange, replaceUrl = _c.replaceUrl;
|
|
4750
4767
|
return _this.hooks.afterPreactivation(targetSnapshot, {
|
|
4751
4768
|
navigationId: navigationId,
|
|
4752
4769
|
appliedUrlTree: appliedUrlTree,
|
|
@@ -4790,14 +4807,28 @@
|
|
|
4790
4807
|
* event is fired when a navigation gets cancelled but not caught by other
|
|
4791
4808
|
* means. */
|
|
4792
4809
|
if (!completed && !errored) {
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4810
|
+
var cancelationReason = "Navigation ID " + t.id + " is not equal to the current navigation id " + _this.navigationId;
|
|
4811
|
+
if (_this.canceledNavigationResolution === 'replace') {
|
|
4812
|
+
// Must reset to current URL tree here to ensure history.state is set. On
|
|
4813
|
+
// a fresh page load, if a new navigation comes in before a successful
|
|
4814
|
+
// navigation completes, there will be nothing in
|
|
4815
|
+
// history.state.navigationId. This can cause sync problems with
|
|
4816
|
+
// AngularJS sync code which looks for a value here in order to determine
|
|
4817
|
+
// whether or not to handle a given popstate event or to leave it to the
|
|
4818
|
+
// Angular router.
|
|
4819
|
+
_this.cancelNavigationTransitionRestoreHistory(t, cancelationReason);
|
|
4820
|
+
}
|
|
4821
|
+
else {
|
|
4822
|
+
// We cannot trigger a `location.historyGo` if the
|
|
4823
|
+
// cancellation was due to a new navigation before the previous could
|
|
4824
|
+
// complete. This is because `location.historyGo` triggers a `popstate`
|
|
4825
|
+
// which would also trigger another navigation. Instead, treat this as a
|
|
4826
|
+
// redirect and do not reset the state.
|
|
4827
|
+
_this.cancelNavigationTransition(t, cancelationReason);
|
|
4828
|
+
// TODO(atscott): The same problem happens here with a fresh page load
|
|
4829
|
+
// and a new navigation before that completes where we won't set a page
|
|
4830
|
+
// id.
|
|
4831
|
+
}
|
|
4801
4832
|
}
|
|
4802
4833
|
// currentNavigation should always be reset to null here. If navigation was
|
|
4803
4834
|
// successful, lastSuccessfulTransition will have already been set. Therefore
|
|
@@ -4901,9 +4932,9 @@
|
|
|
4901
4932
|
if (!this.locationSubscription) {
|
|
4902
4933
|
this.locationSubscription = this.location.subscribe(function (event) {
|
|
4903
4934
|
var currentChange = _this.extractLocationChangeInfoFromEvent(event);
|
|
4935
|
+
// The `setTimeout` was added in #12160 and is likely to support Angular/AngularJS
|
|
4936
|
+
// hybrid apps.
|
|
4904
4937
|
if (_this.shouldScheduleNavigation(_this.lastLocationChangeInfo, currentChange)) {
|
|
4905
|
-
// The `setTimeout` was added in #12160 and is likely to support Angular/AngularJS
|
|
4906
|
-
// hybrid apps.
|
|
4907
4938
|
setTimeout(function () {
|
|
4908
4939
|
var source = currentChange.source, state = currentChange.state, urlTree = currentChange.urlTree;
|
|
4909
4940
|
var extras = { replaceUrl: true };
|
|
@@ -5111,14 +5142,7 @@
|
|
|
5111
5142
|
}
|
|
5112
5143
|
var urlTree = isUrlTree(url) ? url : this.parseUrl(url);
|
|
5113
5144
|
var mergedTree = this.urlHandlingStrategy.merge(urlTree, this.rawUrlTree);
|
|
5114
|
-
|
|
5115
|
-
if (this.canceledNavigationResolution === 'computed') {
|
|
5116
|
-
var isInitialPage = this.currentPageId === 0;
|
|
5117
|
-
if (isInitialPage || extras.skipLocationChange || extras.replaceUrl) {
|
|
5118
|
-
restoredState = this.location.getState();
|
|
5119
|
-
}
|
|
5120
|
-
}
|
|
5121
|
-
return this.scheduleNavigation(mergedTree, 'imperative', restoredState, extras);
|
|
5145
|
+
return this.scheduleNavigation(mergedTree, 'imperative', null, extras);
|
|
5122
5146
|
};
|
|
5123
5147
|
/**
|
|
5124
5148
|
* Navigate based on the provided array of commands and a starting point.
|
|
@@ -5211,6 +5235,7 @@
|
|
|
5211
5235
|
});
|
|
5212
5236
|
};
|
|
5213
5237
|
Router.prototype.scheduleNavigation = function (rawUrl, source, restoredState, extras, priorPromise) {
|
|
5238
|
+
var _a, _b;
|
|
5214
5239
|
if (this.disposed) {
|
|
5215
5240
|
return Promise.resolve(false);
|
|
5216
5241
|
}
|
|
@@ -5254,13 +5279,25 @@
|
|
|
5254
5279
|
var id = ++this.navigationId;
|
|
5255
5280
|
var targetPageId;
|
|
5256
5281
|
if (this.canceledNavigationResolution === 'computed') {
|
|
5282
|
+
var isInitialPage = this.currentPageId === 0;
|
|
5283
|
+
if (isInitialPage) {
|
|
5284
|
+
restoredState = this.location.getState();
|
|
5285
|
+
}
|
|
5257
5286
|
// If the `ɵrouterPageId` exist in the state then `targetpageId` should have the value of
|
|
5258
|
-
// `ɵrouterPageId
|
|
5287
|
+
// `ɵrouterPageId`. This is the case for something like a page refresh where we assign the
|
|
5288
|
+
// target id to the previously set value for that page.
|
|
5259
5289
|
if (restoredState && restoredState.ɵrouterPageId) {
|
|
5260
5290
|
targetPageId = restoredState.ɵrouterPageId;
|
|
5261
5291
|
}
|
|
5262
5292
|
else {
|
|
5263
|
-
|
|
5293
|
+
// If we're replacing the URL or doing a silent navigation, we do not want to increment the
|
|
5294
|
+
// page id because we aren't pushing a new entry to history.
|
|
5295
|
+
if (extras.replaceUrl || extras.skipLocationChange) {
|
|
5296
|
+
targetPageId = (_a = this.browserPageId) !== null && _a !== void 0 ? _a : 0;
|
|
5297
|
+
}
|
|
5298
|
+
else {
|
|
5299
|
+
targetPageId = ((_b = this.browserPageId) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
5300
|
+
}
|
|
5264
5301
|
}
|
|
5265
5302
|
}
|
|
5266
5303
|
else {
|
|
@@ -5314,7 +5351,7 @@
|
|
|
5314
5351
|
* - triggers the `NavigationCancel` event
|
|
5315
5352
|
* - resolves the transition promise with `false`
|
|
5316
5353
|
*/
|
|
5317
|
-
Router.prototype.
|
|
5354
|
+
Router.prototype.cancelNavigationTransitionRestoreHistory = function (t, reason) {
|
|
5318
5355
|
if (this.canceledNavigationResolution === 'computed') {
|
|
5319
5356
|
// The navigator change the location before triggered the browser event,
|
|
5320
5357
|
// so we need to go back to the current url if the navigation is canceled.
|
|
@@ -5333,6 +5370,9 @@
|
|
|
5333
5370
|
else {
|
|
5334
5371
|
this.resetUrlToCurrentUrlTree();
|
|
5335
5372
|
}
|
|
5373
|
+
this.cancelNavigationTransition(t, reason);
|
|
5374
|
+
};
|
|
5375
|
+
Router.prototype.cancelNavigationTransition = function (t, reason) {
|
|
5336
5376
|
var navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), reason);
|
|
5337
5377
|
this.triggerEvent(navCancel);
|
|
5338
5378
|
t.resolve(false);
|
|
@@ -6655,7 +6695,7 @@
|
|
|
6655
6695
|
/**
|
|
6656
6696
|
* @publicApi
|
|
6657
6697
|
*/
|
|
6658
|
-
var VERSION = new core.Version('12.1.
|
|
6698
|
+
var VERSION = new core.Version('12.1.2');
|
|
6659
6699
|
|
|
6660
6700
|
/**
|
|
6661
6701
|
* @license
|