@angular/router 14.1.0-next.4 → 14.1.1

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 (39) hide show
  1. package/esm2020/src/apply_redirects.mjs +6 -5
  2. package/esm2020/src/components/empty_outlet.mjs +3 -3
  3. package/esm2020/src/directives/router_link.mjs +6 -6
  4. package/esm2020/src/directives/router_link_active.mjs +3 -3
  5. package/esm2020/src/directives/router_outlet.mjs +4 -4
  6. package/esm2020/src/events.mjs +10 -2
  7. package/esm2020/src/index.mjs +3 -2
  8. package/esm2020/src/models.mjs +1 -1
  9. package/esm2020/src/navigation_canceling_error.mjs +32 -0
  10. package/esm2020/src/operators/check_guards.mjs +5 -6
  11. package/esm2020/src/operators/prioritized_guard_value.mjs +22 -27
  12. package/esm2020/src/operators/recognize.mjs +1 -1
  13. package/esm2020/src/page_title_strategy.mjs +11 -5
  14. package/esm2020/src/private_export.mjs +3 -2
  15. package/esm2020/src/router.mjs +134 -83
  16. package/esm2020/src/router_config.mjs +19 -0
  17. package/esm2020/src/router_config_loader.mjs +3 -3
  18. package/esm2020/src/router_module.mjs +21 -78
  19. package/esm2020/src/router_preloader.mjs +19 -11
  20. package/esm2020/src/router_scroller.mjs +3 -3
  21. package/esm2020/src/shared.mjs +1 -11
  22. package/esm2020/src/url_tree.mjs +4 -1
  23. package/esm2020/src/utils/type_guards.mjs +9 -5
  24. package/esm2020/src/version.mjs +1 -1
  25. package/esm2020/testing/src/router_testing_module.mjs +10 -12
  26. package/fesm2015/router.mjs +388 -323
  27. package/fesm2015/router.mjs.map +1 -1
  28. package/fesm2015/testing.mjs +10 -12
  29. package/fesm2015/testing.mjs.map +1 -1
  30. package/fesm2015/upgrade.mjs +1 -1
  31. package/fesm2020/router.mjs +382 -326
  32. package/fesm2020/router.mjs.map +1 -1
  33. package/fesm2020/testing.mjs +10 -12
  34. package/fesm2020/testing.mjs.map +1 -1
  35. package/fesm2020/upgrade.mjs +1 -1
  36. package/index.d.ts +22 -9
  37. package/package.json +4 -4
  38. package/testing/index.d.ts +2 -3
  39. package/upgrade/index.d.ts +1 -1
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @license Angular v14.1.0-next.4
2
+ * @license Angular v14.1.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i0 from '@angular/core';
8
- import { ɵisObservable, ɵisPromise, ɵRuntimeError, EventEmitter, Directive, Attribute, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, InjectionToken, InjectFlags, NgModuleFactory, Injectable, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, Injector, Compiler, NgProbeToken, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, inject, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, Inject, ApplicationRef, ENVIRONMENT_INITIALIZER, Version } from '@angular/core';
8
+ import { ɵisObservable, ɵisPromise, ɵRuntimeError, EventEmitter, Directive, Attribute, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, inject, Injectable, InjectionToken, InjectFlags, NgModuleFactory, Injector, Compiler, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, Input, HostListener, HostBinding, Optional, ContentChildren, NgProbeToken, SkipSelf, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule, Inject, ApplicationRef, ENVIRONMENT_INITIALIZER, Version } from '@angular/core';
9
9
  import { from, of, BehaviorSubject, combineLatest, concat, defer, pipe, throwError, EmptyError, Observable, EMPTY, ConnectableObservable, Subject } from 'rxjs';
10
10
  import * as i3 from '@angular/common';
11
11
  import { Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy, ViewportScroller, LOCATION_INITIALIZED } from '@angular/common';
12
- import { map, switchMap, take, startWith, scan, filter, mergeMap, first, concatMap, tap, catchError, last as last$1, takeWhile, defaultIfEmpty, takeLast, mapTo, finalize, refCount, mergeAll } from 'rxjs/operators';
12
+ import { map, switchMap, take, startWith, filter, mergeMap, first, concatMap, tap, catchError, scan, last as last$1, takeWhile, defaultIfEmpty, takeLast, mapTo, finalize, refCount, mergeAll } from 'rxjs/operators';
13
13
  import * as i1 from '@angular/platform-browser';
14
14
 
15
15
  /**
@@ -60,16 +60,6 @@ class ParamsAsMap {
60
60
  function convertToParamMap(params) {
61
61
  return new ParamsAsMap(params);
62
62
  }
63
- const REDIRECTING_CANCELLATION_REASON = 'Redirecting to ';
64
- const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
65
- function navigationCancelingError(message) {
66
- const error = Error('NavigationCancelingError: ' + (message || ''));
67
- error[NAVIGATION_CANCELING_ERROR] = true;
68
- return error;
69
- }
70
- function isNavigationCancelingError(error) {
71
- return error && error[NAVIGATION_CANCELING_ERROR];
72
- }
73
63
  // Matches the route configuration (`route`) against the actual URL (`segments`).
74
64
  function defaultUrlMatcher(segments, segmentGroup, route) {
75
65
  const parts = route.path.split('/');
@@ -192,7 +182,7 @@ function wrapIntoObservable(value) {
192
182
  * Use of this source code is governed by an MIT-style license that can be
193
183
  * found in the LICENSE file at https://angular.io/license
194
184
  */
195
- const NG_DEV_MODE$7 = typeof ngDevMode === 'undefined' || ngDevMode;
185
+ const NG_DEV_MODE$8 = typeof ngDevMode === 'undefined' || ngDevMode;
196
186
  function createEmptyUrlTree() {
197
187
  return new UrlTree(new UrlSegmentGroup([], {}), {}, null);
198
188
  }
@@ -657,7 +647,7 @@ class UrlParser {
657
647
  parseSegment() {
658
648
  const path = matchSegments(this.remaining);
659
649
  if (path === '' && this.peekStartsWith(';')) {
660
- throw new ɵRuntimeError(4009 /* RuntimeErrorCode.EMPTY_PATH_WITH_PARAMS */, NG_DEV_MODE$7 && `Empty path url segment cannot have parameters: '${this.remaining}'.`);
650
+ throw new ɵRuntimeError(4009 /* RuntimeErrorCode.EMPTY_PATH_WITH_PARAMS */, NG_DEV_MODE$8 && `Empty path url segment cannot have parameters: '${this.remaining}'.`);
661
651
  }
662
652
  this.capture(path);
663
653
  return new UrlSegment(decode(path), this.parseMatrixParams());
@@ -726,7 +716,7 @@ class UrlParser {
726
716
  // if is is not one of these characters, then the segment was unescaped
727
717
  // or the group was not closed
728
718
  if (next !== '/' && next !== ')' && next !== ';') {
729
- throw new ɵRuntimeError(4010 /* RuntimeErrorCode.UNPARSABLE_URL */, NG_DEV_MODE$7 && `Cannot parse url '${this.url}'`);
719
+ throw new ɵRuntimeError(4010 /* RuntimeErrorCode.UNPARSABLE_URL */, NG_DEV_MODE$8 && `Cannot parse url '${this.url}'`);
730
720
  }
731
721
  let outletName = undefined;
732
722
  if (path.indexOf(':') > -1) {
@@ -757,7 +747,7 @@ class UrlParser {
757
747
  }
758
748
  capture(str) {
759
749
  if (!this.consumeOptional(str)) {
760
- throw new ɵRuntimeError(4011 /* RuntimeErrorCode.UNEXPECTED_VALUE_IN_URL */, NG_DEV_MODE$7 && `Expected "${str}".`);
750
+ throw new ɵRuntimeError(4011 /* RuntimeErrorCode.UNEXPECTED_VALUE_IN_URL */, NG_DEV_MODE$8 && `Expected "${str}".`);
761
751
  }
762
752
  }
763
753
  }
@@ -799,6 +789,9 @@ function mergeTrivialChildren(s) {
799
789
  }
800
790
  return s;
801
791
  }
792
+ function isUrlTree(v) {
793
+ return v instanceof UrlTree;
794
+ }
802
795
 
803
796
  /**
804
797
  * @license
@@ -807,7 +800,7 @@ function mergeTrivialChildren(s) {
807
800
  * Use of this source code is governed by an MIT-style license that can be
808
801
  * found in the LICENSE file at https://angular.io/license
809
802
  */
810
- const NG_DEV_MODE$6 = typeof ngDevMode === 'undefined' || ngDevMode;
803
+ const NG_DEV_MODE$7 = typeof ngDevMode === 'undefined' || ngDevMode;
811
804
  /**
812
805
  * Creates a `UrlTree` relative to an `ActivatedRouteSnapshot`.
813
806
  *
@@ -983,11 +976,11 @@ class Navigation {
983
976
  this.numberOfDoubleDots = numberOfDoubleDots;
984
977
  this.commands = commands;
985
978
  if (isAbsolute && commands.length > 0 && isMatrixParams(commands[0])) {
986
- throw new ɵRuntimeError(4003 /* RuntimeErrorCode.ROOT_SEGMENT_MATRIX_PARAMS */, NG_DEV_MODE$6 && 'Root segment cannot have matrix parameters');
979
+ throw new ɵRuntimeError(4003 /* RuntimeErrorCode.ROOT_SEGMENT_MATRIX_PARAMS */, NG_DEV_MODE$7 && 'Root segment cannot have matrix parameters');
987
980
  }
988
981
  const cmdWithOutlet = commands.find(isCommandWithOutlets);
989
982
  if (cmdWithOutlet && cmdWithOutlet !== last(commands)) {
990
- throw new ɵRuntimeError(4004 /* RuntimeErrorCode.MISPLACED_OUTLETS_COMMAND */, NG_DEV_MODE$6 && '{outlets:{}} has to be the last command');
983
+ throw new ɵRuntimeError(4004 /* RuntimeErrorCode.MISPLACED_OUTLETS_COMMAND */, NG_DEV_MODE$7 && '{outlets:{}} has to be the last command');
991
984
  }
992
985
  }
993
986
  toRoot() {
@@ -1086,7 +1079,7 @@ function createPositionApplyingDoubleDots(group, index, numberOfDoubleDots) {
1086
1079
  dd -= ci;
1087
1080
  g = g.parent;
1088
1081
  if (!g) {
1089
- throw new ɵRuntimeError(4005 /* RuntimeErrorCode.INVALID_DOUBLE_DOTS */, NG_DEV_MODE$6 && 'Invalid number of \'../\'');
1082
+ throw new ɵRuntimeError(4005 /* RuntimeErrorCode.INVALID_DOUBLE_DOTS */, NG_DEV_MODE$7 && 'Invalid number of \'../\'');
1090
1083
  }
1091
1084
  ci = g.segments.length;
1092
1085
  }
@@ -1378,9 +1371,17 @@ class NavigationError extends RouterEvent {
1378
1371
  /** @docsNotRequired */
1379
1372
  url,
1380
1373
  /** @docsNotRequired */
1381
- error) {
1374
+ error,
1375
+ /**
1376
+ * The target of the navigation when the error occurred.
1377
+ *
1378
+ * Note that this can be `undefined` because an error could have occurred before the
1379
+ * `RouterStateSnapshot` was created for the navigation.
1380
+ */
1381
+ target) {
1382
1382
  super(id, url);
1383
1383
  this.error = error;
1384
+ this.target = target;
1384
1385
  this.type = 3 /* EventType.NavigationError */;
1385
1386
  }
1386
1387
  /** @docsNotRequired */
@@ -2242,6 +2243,37 @@ function createActivatedRoute(c) {
2242
2243
  return new ActivatedRoute(new BehaviorSubject(c.url), new BehaviorSubject(c.params), new BehaviorSubject(c.queryParams), new BehaviorSubject(c.fragment), new BehaviorSubject(c.data), c.outlet, c.component, c);
2243
2244
  }
2244
2245
 
2246
+ /**
2247
+ * @license
2248
+ * Copyright Google LLC All Rights Reserved.
2249
+ *
2250
+ * Use of this source code is governed by an MIT-style license that can be
2251
+ * found in the LICENSE file at https://angular.io/license
2252
+ */
2253
+ const NAVIGATION_CANCELING_ERROR = 'ngNavigationCancelingError';
2254
+ function redirectingNavigationError(urlSerializer, redirect) {
2255
+ const { redirectTo, navigationBehaviorOptions } = isUrlTree(redirect) ? { redirectTo: redirect, navigationBehaviorOptions: undefined } : redirect;
2256
+ const error = navigationCancelingError(ngDevMode && `Redirecting to "${urlSerializer.serialize(redirectTo)}"`, 0 /* NavigationCancellationCode.Redirect */, redirect);
2257
+ error.url = redirectTo;
2258
+ error.navigationBehaviorOptions = navigationBehaviorOptions;
2259
+ return error;
2260
+ }
2261
+ function navigationCancelingError(message, code, redirectUrl) {
2262
+ const error = new Error('NavigationCancelingError: ' + (message || ''));
2263
+ error[NAVIGATION_CANCELING_ERROR] = true;
2264
+ error.cancellationCode = code;
2265
+ if (redirectUrl) {
2266
+ error.url = redirectUrl;
2267
+ }
2268
+ return error;
2269
+ }
2270
+ function isRedirectingNavigationCancelingError$1(error) {
2271
+ return isNavigationCancelingError$1(error) && isUrlTree(error.url);
2272
+ }
2273
+ function isNavigationCancelingError$1(error) {
2274
+ return error && error[NAVIGATION_CANCELING_ERROR];
2275
+ }
2276
+
2245
2277
  /**
2246
2278
  * @license
2247
2279
  * Copyright Google LLC All Rights Reserved.
@@ -2328,7 +2360,7 @@ class ChildrenOutletContexts {
2328
2360
  * Use of this source code is governed by an MIT-style license that can be
2329
2361
  * found in the LICENSE file at https://angular.io/license
2330
2362
  */
2331
- const NG_DEV_MODE$5 = typeof ngDevMode === 'undefined' || ngDevMode;
2363
+ const NG_DEV_MODE$6 = typeof ngDevMode === 'undefined' || ngDevMode;
2332
2364
  /**
2333
2365
  * @description
2334
2366
  *
@@ -2437,12 +2469,12 @@ class RouterOutlet {
2437
2469
  */
2438
2470
  get component() {
2439
2471
  if (!this.activated)
2440
- throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2472
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$6 && 'Outlet is not activated');
2441
2473
  return this.activated.instance;
2442
2474
  }
2443
2475
  get activatedRoute() {
2444
2476
  if (!this.activated)
2445
- throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2477
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$6 && 'Outlet is not activated');
2446
2478
  return this._activatedRoute;
2447
2479
  }
2448
2480
  get activatedRouteData() {
@@ -2456,7 +2488,7 @@ class RouterOutlet {
2456
2488
  */
2457
2489
  detach() {
2458
2490
  if (!this.activated)
2459
- throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$5 && 'Outlet is not activated');
2491
+ throw new ɵRuntimeError(4012 /* RuntimeErrorCode.OUTLET_NOT_ACTIVATED */, NG_DEV_MODE$6 && 'Outlet is not activated');
2460
2492
  this.location.detach();
2461
2493
  const cmp = this.activated;
2462
2494
  this.activated = null;
@@ -2484,7 +2516,7 @@ class RouterOutlet {
2484
2516
  }
2485
2517
  activateWith(activatedRoute, resolverOrInjector) {
2486
2518
  if (this.isActivated) {
2487
- throw new ɵRuntimeError(4013 /* RuntimeErrorCode.OUTLET_ALREADY_ACTIVATED */, NG_DEV_MODE$5 && 'Cannot activate an already activated outlet');
2519
+ throw new ɵRuntimeError(4013 /* RuntimeErrorCode.OUTLET_ALREADY_ACTIVATED */, NG_DEV_MODE$6 && 'Cannot activate an already activated outlet');
2488
2520
  }
2489
2521
  this._activatedRoute = activatedRoute;
2490
2522
  const location = this.location;
@@ -2506,9 +2538,9 @@ class RouterOutlet {
2506
2538
  this.activateEvents.emit(this.activated.instance);
2507
2539
  }
2508
2540
  }
2509
- RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2510
- RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2511
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterOutlet, decorators: [{
2541
+ RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterOutlet, deps: [{ token: ChildrenOutletContexts }, { token: i0.ViewContainerRef }, { token: 'name', attribute: true }, { token: i0.ChangeDetectorRef }, { token: i0.EnvironmentInjector }], target: i0.ɵɵFactoryTarget.Directive });
2542
+ RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: RouterOutlet, selector: "router-outlet", outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], ngImport: i0 });
2543
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterOutlet, decorators: [{
2512
2544
  type: Directive,
2513
2545
  args: [{ selector: 'router-outlet', exportAs: 'outlet' }]
2514
2546
  }], ctorParameters: function () { return [{ type: ChildrenOutletContexts }, { type: i0.ViewContainerRef }, { type: undefined, decorators: [{
@@ -2565,9 +2597,9 @@ function isComponentFactoryResolver(item) {
2565
2597
  */
2566
2598
  class ɵEmptyOutletComponent {
2567
2599
  }
2568
- ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2569
- ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0-next.4", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2600
+ ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2601
+ ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: ɵEmptyOutletComponent, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2602
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2571
2603
  type: Component,
2572
2604
  args: [{ template: `<router-outlet></router-outlet>` }]
2573
2605
  }] });
@@ -3103,9 +3135,6 @@ function isFunction(v) {
3103
3135
  function isBoolean(v) {
3104
3136
  return typeof v === 'boolean';
3105
3137
  }
3106
- function isUrlTree(v) {
3107
- return v instanceof UrlTree;
3108
- }
3109
3138
  function isCanLoad(guard) {
3110
3139
  return guard && isFunction(guard.canLoad);
3111
3140
  }
@@ -3121,6 +3150,12 @@ function isCanDeactivate(guard) {
3121
3150
  function isCanMatch(guard) {
3122
3151
  return guard && isFunction(guard.canMatch);
3123
3152
  }
3153
+ function isRedirectingNavigationCancelingError(error) {
3154
+ return isNavigationCancelingError(error) && isUrlTree(error.url);
3155
+ }
3156
+ function isNavigationCancelingError(error) {
3157
+ return error && error[NAVIGATION_CANCELING_ERROR];
3158
+ }
3124
3159
 
3125
3160
  /**
3126
3161
  * @license
@@ -3133,31 +3168,26 @@ const INITIAL_VALUE = Symbol('INITIAL_VALUE');
3133
3168
  function prioritizedGuardValue() {
3134
3169
  return switchMap(obs => {
3135
3170
  return combineLatest(obs.map(o => o.pipe(take(1), startWith(INITIAL_VALUE))))
3136
- .pipe(scan((acc, list) => {
3137
- let isPending = false;
3138
- return list.reduce((innerAcc, val, i) => {
3139
- if (innerAcc !== INITIAL_VALUE)
3140
- return innerAcc;
3141
- // Toggle pending flag if any values haven't been set yet
3142
- if (val === INITIAL_VALUE)
3143
- isPending = true;
3144
- // Any other return values are only valid if we haven't yet hit a pending
3145
- // call. This guarantees that in the case of a guard at the bottom of the
3146
- // tree that returns a redirect, we will wait for the higher priority
3147
- // guard at the top to finish before performing the redirect.
3148
- if (!isPending) {
3149
- // Early return when we hit a `false` value as that should always
3150
- // cancel navigation
3151
- if (val === false)
3152
- return val;
3153
- if (i === list.length - 1 || isUrlTree(val)) {
3154
- return val;
3155
- }
3171
+ .pipe(map((results) => {
3172
+ for (const result of results) {
3173
+ if (result === true) {
3174
+ // If result is true, check the next one
3175
+ continue;
3156
3176
  }
3157
- return innerAcc;
3158
- }, acc);
3159
- }, INITIAL_VALUE), filter(item => item !== INITIAL_VALUE), map(item => isUrlTree(item) ? item : item === true), //
3160
- take(1));
3177
+ else if (result === INITIAL_VALUE) {
3178
+ // If guard has not finished, we need to stop processing.
3179
+ return INITIAL_VALUE;
3180
+ }
3181
+ else if (result === false || result instanceof UrlTree) {
3182
+ // Result finished and was not true. Return the result.
3183
+ // Note that we only allow false/UrlTree. Other values are considered invalid and
3184
+ // ignored.
3185
+ return result;
3186
+ }
3187
+ }
3188
+ // Everything resolved to true. Return true.
3189
+ return true;
3190
+ }), filter((item) => item !== INITIAL_VALUE), take(1));
3161
3191
  });
3162
3192
  }
3163
3193
 
@@ -3285,9 +3315,7 @@ function redirectIfUrlTree(urlSerializer) {
3285
3315
  return pipe(tap((result) => {
3286
3316
  if (!isUrlTree(result))
3287
3317
  return;
3288
- const error = navigationCancelingError(REDIRECTING_CANCELLATION_REASON + urlSerializer.serialize(result));
3289
- error.url = result;
3290
- throw error;
3318
+ throw redirectingNavigationError(urlSerializer, result);
3291
3319
  }), map(result => result === true));
3292
3320
  }
3293
3321
  function runCanMatchGuards(injector, route, segments, urlSerializer) {
@@ -3465,7 +3493,7 @@ function noLeftoversInUrl(segmentGroup, segments, outlet) {
3465
3493
  * Use of this source code is governed by an MIT-style license that can be
3466
3494
  * found in the LICENSE file at https://angular.io/license
3467
3495
  */
3468
- const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || ngDevMode;
3496
+ const NG_DEV_MODE$5 = typeof ngDevMode === 'undefined' || ngDevMode;
3469
3497
  class NoMatch$1 {
3470
3498
  constructor(segmentGroup) {
3471
3499
  this.segmentGroup = segmentGroup || null;
@@ -3483,12 +3511,12 @@ function absoluteRedirect(newTree) {
3483
3511
  return throwError(new AbsoluteRedirect(newTree));
3484
3512
  }
3485
3513
  function namedOutletsRedirect(redirectTo) {
3486
- return throwError(new ɵRuntimeError(4000 /* RuntimeErrorCode.NAMED_OUTLET_REDIRECT */, NG_DEV_MODE$4 &&
3514
+ return throwError(new ɵRuntimeError(4000 /* RuntimeErrorCode.NAMED_OUTLET_REDIRECT */, NG_DEV_MODE$5 &&
3487
3515
  `Only absolute redirects can have named outlets. redirectTo: '${redirectTo}'`));
3488
3516
  }
3489
3517
  function canLoadFails(route) {
3490
- return throwError(navigationCancelingError(NG_DEV_MODE$4 &&
3491
- `Cannot load children because the guard of the route "path: '${route.path}'" returned false`));
3518
+ return throwError(navigationCancelingError(NG_DEV_MODE$5 &&
3519
+ `Cannot load children because the guard of the route "path: '${route.path}'" returned false`, 3 /* NavigationCancellationCode.GuardRejected */));
3492
3520
  }
3493
3521
  /**
3494
3522
  * Returns the `UrlTree` with the redirection applied.
@@ -3547,7 +3575,7 @@ class ApplyRedirects {
3547
3575
  }));
3548
3576
  }
3549
3577
  noMatchError(e) {
3550
- return new ɵRuntimeError(4002 /* RuntimeErrorCode.NO_MATCH */, NG_DEV_MODE$4 && `Cannot match any routes. URL Segment: '${e.segmentGroup}'`);
3578
+ return new ɵRuntimeError(4002 /* RuntimeErrorCode.NO_MATCH */, NG_DEV_MODE$5 && `Cannot match any routes. URL Segment: '${e.segmentGroup}'`);
3551
3579
  }
3552
3580
  createUrlTree(rootCandidate, queryParams, fragment) {
3553
3581
  const root = createRoot(rootCandidate);
@@ -3727,9 +3755,9 @@ class ApplyRedirects {
3727
3755
  }
3728
3756
  }
3729
3757
  applyRedirectCommands(segments, redirectTo, posParams) {
3730
- return this.applyRedirectCreatreUrlTree(redirectTo, this.urlSerializer.parse(redirectTo), segments, posParams);
3758
+ return this.applyRedirectCreateUrlTree(redirectTo, this.urlSerializer.parse(redirectTo), segments, posParams);
3731
3759
  }
3732
- applyRedirectCreatreUrlTree(redirectTo, urlTree, segments, posParams) {
3760
+ applyRedirectCreateUrlTree(redirectTo, urlTree, segments, posParams) {
3733
3761
  const newRoot = this.createSegmentGroup(redirectTo, urlTree.root, segments, posParams);
3734
3762
  return new UrlTree(newRoot, this.createQueryParams(urlTree.queryParams, this.urlTree.queryParams), urlTree.fragment);
3735
3763
  }
@@ -3762,7 +3790,7 @@ class ApplyRedirects {
3762
3790
  findPosParam(redirectTo, redirectToUrlSegment, posParams) {
3763
3791
  const pos = posParams[redirectToUrlSegment.path.substring(1)];
3764
3792
  if (!pos)
3765
- throw new ɵRuntimeError(4001 /* RuntimeErrorCode.MISSING_REDIRECT */, NG_DEV_MODE$4 &&
3793
+ throw new ɵRuntimeError(4001 /* RuntimeErrorCode.MISSING_REDIRECT */, NG_DEV_MODE$5 &&
3766
3794
  `Cannot redirect to '${redirectTo}'. Cannot find '${redirectToUrlSegment.path}'.`);
3767
3795
  return pos;
3768
3796
  }
@@ -3798,7 +3826,7 @@ function applyRedirects(environmentInjector, configLoader, urlSerializer, config
3798
3826
  * Use of this source code is governed by an MIT-style license that can be
3799
3827
  * found in the LICENSE file at https://angular.io/license
3800
3828
  */
3801
- const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || !!ngDevMode;
3829
+ const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || !!ngDevMode;
3802
3830
  class NoMatch {
3803
3831
  }
3804
3832
  function newObservableError(e) {
@@ -3887,7 +3915,7 @@ class Recognizer {
3887
3915
  // multiple activated results for the same outlet. We should merge the children of
3888
3916
  // these results so the final return value is only one `TreeNode` per outlet.
3889
3917
  const mergedChildren = mergeEmptyPathMatches(children);
3890
- if (NG_DEV_MODE$3) {
3918
+ if (NG_DEV_MODE$4) {
3891
3919
  // This should really never happen - we are only taking the first match for each
3892
3920
  // outlet and merge the empty path matches.
3893
3921
  checkOutletNameUniqueness(mergedChildren);
@@ -3920,7 +3948,7 @@ class Recognizer {
3920
3948
  // NG_DEV_MODE is used to prevent the getCorrectedPathIndexShift function from affecting
3921
3949
  // production bundle size. This value is intended only to surface a warning to users
3922
3950
  // depending on `relativeLinkResolution: 'legacy'` in dev mode.
3923
- (NG_DEV_MODE$3 ? getCorrectedPathIndexShift(rawSegment) + segments.length :
3951
+ (NG_DEV_MODE$4 ? getCorrectedPathIndexShift(rawSegment) + segments.length :
3924
3952
  pathIndexShift));
3925
3953
  matchResult = of({
3926
3954
  snapshot,
@@ -3936,7 +3964,7 @@ class Recognizer {
3936
3964
  return null;
3937
3965
  }
3938
3966
  const pathIndexShift = getPathIndexShift(rawSegment) + consumedSegments.length;
3939
- const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({ ...this.urlTree.queryParams }), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$3 ?
3967
+ const snapshot = new ActivatedRouteSnapshot(consumedSegments, parameters, Object.freeze({ ...this.urlTree.queryParams }), this.urlTree.fragment, getData(route), getOutlet(route), route.component ?? route._loadedComponent ?? null, route, getSourceSegmentGroup(rawSegment), pathIndexShift, getResolve(route), (NG_DEV_MODE$4 ?
3940
3968
  getCorrectedPathIndexShift(rawSegment) + consumedSegments.length :
3941
3969
  pathIndexShift));
3942
3970
  return { snapshot, consumedSegments, remainingSegments };
@@ -4049,7 +4077,7 @@ function checkOutletNameUniqueness(nodes) {
4049
4077
  if (routeWithSameOutletName) {
4050
4078
  const p = routeWithSameOutletName.url.map(s => s.toString()).join('/');
4051
4079
  const c = n.value.url.map(s => s.toString()).join('/');
4052
- throw new ɵRuntimeError(4006 /* RuntimeErrorCode.TWO_SEGMENTS_WITH_SAME_OUTLET */, NG_DEV_MODE$3 && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
4080
+ throw new ɵRuntimeError(4006 /* RuntimeErrorCode.TWO_SEGMENTS_WITH_SAME_OUTLET */, NG_DEV_MODE$4 && `Two segments cannot have the same outlet name: '${p}' and '${c}'.`);
4053
4081
  }
4054
4082
  names[n.value.outlet] = n.value;
4055
4083
  });
@@ -4184,6 +4212,90 @@ function switchTap(next) {
4184
4212
  });
4185
4213
  }
4186
4214
 
4215
+ /**
4216
+ * @license
4217
+ * Copyright Google LLC All Rights Reserved.
4218
+ *
4219
+ * Use of this source code is governed by an MIT-style license that can be
4220
+ * found in the LICENSE file at https://angular.io/license
4221
+ */
4222
+ /**
4223
+ * Provides a strategy for setting the page title after a router navigation.
4224
+ *
4225
+ * The built-in implementation traverses the router state snapshot and finds the deepest primary
4226
+ * outlet with `title` property. Given the `Routes` below, navigating to
4227
+ * `/base/child(popup:aux)` would result in the document title being set to "child".
4228
+ * ```
4229
+ * [
4230
+ * {path: 'base', title: 'base', children: [
4231
+ * {path: 'child', title: 'child'},
4232
+ * ],
4233
+ * {path: 'aux', outlet: 'popup', title: 'popupTitle'}
4234
+ * ]
4235
+ * ```
4236
+ *
4237
+ * This class can be used as a base class for custom title strategies. That is, you can create your
4238
+ * own class that extends the `TitleStrategy`. Note that in the above example, the `title`
4239
+ * from the named outlet is never used. However, a custom strategy might be implemented to
4240
+ * incorporate titles in named outlets.
4241
+ *
4242
+ * @publicApi
4243
+ * @see [Page title guide](guide/router#setting-the-page-title)
4244
+ */
4245
+ class TitleStrategy {
4246
+ /**
4247
+ * @returns The `title` of the deepest primary route.
4248
+ */
4249
+ buildTitle(snapshot) {
4250
+ let pageTitle;
4251
+ let route = snapshot.root;
4252
+ while (route !== undefined) {
4253
+ pageTitle = this.getResolvedTitleForRoute(route) ?? pageTitle;
4254
+ route = route.children.find(child => child.outlet === PRIMARY_OUTLET);
4255
+ }
4256
+ return pageTitle;
4257
+ }
4258
+ /**
4259
+ * Given an `ActivatedRouteSnapshot`, returns the final value of the
4260
+ * `Route.title` property, which can either be a static string or a resolved value.
4261
+ */
4262
+ getResolvedTitleForRoute(snapshot) {
4263
+ return snapshot.data[RouteTitle];
4264
+ }
4265
+ }
4266
+ TitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: TitleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4267
+ TitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: TitleStrategy, providedIn: 'root', useFactory: () => inject(DefaultTitleStrategy) });
4268
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: TitleStrategy, decorators: [{
4269
+ type: Injectable,
4270
+ args: [{ providedIn: 'root', useFactory: () => inject(DefaultTitleStrategy) }]
4271
+ }] });
4272
+ /**
4273
+ * The default `TitleStrategy` used by the router that updates the title using the `Title` service.
4274
+ */
4275
+ class DefaultTitleStrategy extends TitleStrategy {
4276
+ constructor(title) {
4277
+ super();
4278
+ this.title = title;
4279
+ }
4280
+ /**
4281
+ * Sets the title of the browser to the given value.
4282
+ *
4283
+ * @param title The `pageTitle` from the deepest primary route.
4284
+ */
4285
+ updateTitle(snapshot) {
4286
+ const title = this.buildTitle(snapshot);
4287
+ if (title !== undefined) {
4288
+ this.title.setTitle(title);
4289
+ }
4290
+ }
4291
+ }
4292
+ DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
4293
+ DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
4294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
4295
+ type: Injectable,
4296
+ args: [{ providedIn: 'root' }]
4297
+ }], ctorParameters: function () { return [{ type: i1.Title }]; } });
4298
+
4187
4299
  /**
4188
4300
  * @license
4189
4301
  * Copyright Google LLC All Rights Reserved.
@@ -4249,6 +4361,24 @@ class BaseRouteReuseStrategy {
4249
4361
  class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
4250
4362
  }
4251
4363
 
4364
+ /**
4365
+ * @license
4366
+ * Copyright Google LLC All Rights Reserved.
4367
+ *
4368
+ * Use of this source code is governed by an MIT-style license that can be
4369
+ * found in the LICENSE file at https://angular.io/license
4370
+ */
4371
+ const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4372
+ /**
4373
+ * A [DI token](guide/glossary/#di-token) for the router service.
4374
+ *
4375
+ * @publicApi
4376
+ */
4377
+ const ROUTER_CONFIGURATION = new InjectionToken(NG_DEV_MODE$3 ? 'router config' : '', {
4378
+ providedIn: 'root',
4379
+ factory: () => ({}),
4380
+ });
4381
+
4252
4382
  /**
4253
4383
  * @license
4254
4384
  * Copyright Google LLC All Rights Reserved.
@@ -4355,9 +4485,9 @@ class RouterConfigLoader {
4355
4485
  }));
4356
4486
  }
4357
4487
  }
4358
- RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4359
- RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader });
4360
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterConfigLoader, decorators: [{
4488
+ RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4489
+ RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterConfigLoader });
4490
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterConfigLoader, decorators: [{
4361
4491
  type: Injectable
4362
4492
  }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }]; } });
4363
4493
 
@@ -4426,6 +4556,52 @@ const subsetMatchOptions = {
4426
4556
  matrixParams: 'ignored',
4427
4557
  queryParams: 'subset'
4428
4558
  };
4559
+ function assignExtraOptionsToRouter(opts, router) {
4560
+ if (opts.errorHandler) {
4561
+ router.errorHandler = opts.errorHandler;
4562
+ }
4563
+ if (opts.malformedUriErrorHandler) {
4564
+ router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
4565
+ }
4566
+ if (opts.onSameUrlNavigation) {
4567
+ router.onSameUrlNavigation = opts.onSameUrlNavigation;
4568
+ }
4569
+ if (opts.paramsInheritanceStrategy) {
4570
+ router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
4571
+ }
4572
+ if (opts.relativeLinkResolution) {
4573
+ router.relativeLinkResolution = opts.relativeLinkResolution;
4574
+ }
4575
+ if (opts.urlUpdateStrategy) {
4576
+ router.urlUpdateStrategy = opts.urlUpdateStrategy;
4577
+ }
4578
+ if (opts.canceledNavigationResolution) {
4579
+ router.canceledNavigationResolution = opts.canceledNavigationResolution;
4580
+ }
4581
+ }
4582
+ function setupRouter() {
4583
+ const urlSerializer = inject(UrlSerializer);
4584
+ const contexts = inject(ChildrenOutletContexts);
4585
+ const location = inject(Location);
4586
+ const injector = inject(Injector);
4587
+ const compiler = inject(Compiler);
4588
+ const config = inject(ROUTES, { optional: true }) ?? [];
4589
+ const opts = inject(ROUTER_CONFIGURATION, { optional: true }) ?? {};
4590
+ const defaultTitleStrategy = inject(DefaultTitleStrategy);
4591
+ const titleStrategy = inject(TitleStrategy, { optional: true });
4592
+ const urlHandlingStrategy = inject(UrlHandlingStrategy, { optional: true });
4593
+ const routeReuseStrategy = inject(RouteReuseStrategy, { optional: true });
4594
+ const router = new Router(null, urlSerializer, contexts, location, injector, compiler, flatten(config));
4595
+ if (urlHandlingStrategy) {
4596
+ router.urlHandlingStrategy = urlHandlingStrategy;
4597
+ }
4598
+ if (routeReuseStrategy) {
4599
+ router.routeReuseStrategy = routeReuseStrategy;
4600
+ }
4601
+ router.titleStrategy = titleStrategy ?? defaultTitleStrategy;
4602
+ assignExtraOptionsToRouter(opts, router);
4603
+ return router;
4604
+ }
4429
4605
  /**
4430
4606
  * @description
4431
4607
  *
@@ -4614,10 +4790,11 @@ class Router {
4614
4790
  // Extract URL
4615
4791
  map(t => ({ ...t, extractedUrl: this.urlHandlingStrategy.extract(t.rawUrl) })),
4616
4792
  // Using switchMap so we cancel executing navigations when a new one comes in
4617
- switchMap(t => {
4793
+ switchMap(overallTransitionState => {
4618
4794
  let completed = false;
4619
4795
  let errored = false;
4620
- return of(t).pipe(
4796
+ return of(overallTransitionState)
4797
+ .pipe(
4621
4798
  // Store the Navigation object
4622
4799
  tap(t => {
4623
4800
  this.currentNavigation = {
@@ -4636,8 +4813,8 @@ class Router {
4636
4813
  t.extractedUrl.toString() !== browserUrlTree ||
4637
4814
  // Navigations which succeed or ones which fail and are cleaned up
4638
4815
  // correctly should result in `browserUrlTree` and `currentUrlTree`
4639
- // matching. If this is not the case, assume something went wrong and try
4640
- // processing the URL again.
4816
+ // matching. If this is not the case, assume something went wrong and
4817
+ // try processing the URL again.
4641
4818
  browserUrlTree !== this.currentUrlTree.toString();
4642
4819
  const processCurrentUrl = (this.onSameUrlNavigation === 'reload' ? true : urlTransition) &&
4643
4820
  this.urlHandlingStrategy.shouldProcessUrl(t.rawUrl);
@@ -4668,11 +4845,13 @@ class Router {
4668
4845
  ...this.currentNavigation,
4669
4846
  finalUrl: t.urlAfterRedirects
4670
4847
  };
4848
+ overallTransitionState.urlAfterRedirects = t.urlAfterRedirects;
4671
4849
  }),
4672
4850
  // Recognize
4673
4851
  recognize(this.ngModule.injector, this.rootComponentType, this.config, this.urlSerializer, this.paramsInheritanceStrategy, this.relativeLinkResolution),
4674
4852
  // Update URL if in `eager` update mode
4675
4853
  tap(t => {
4854
+ overallTransitionState.targetSnapshot = t.targetSnapshot;
4676
4855
  if (this.urlUpdateStrategy === 'eager') {
4677
4856
  if (!t.extras.skipLocationChange) {
4678
4857
  const rawUrl = this.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
@@ -4688,26 +4867,27 @@ class Router {
4688
4867
  else {
4689
4868
  const processPreviousUrl = urlTransition && this.rawUrlTree &&
4690
4869
  this.urlHandlingStrategy.shouldProcessUrl(this.rawUrlTree);
4691
- /* When the current URL shouldn't be processed, but the previous one was,
4692
- * we handle this "error condition" by navigating to the previously
4693
- * successful URL, but leaving the URL intact.*/
4870
+ /* When the current URL shouldn't be processed, but the previous one
4871
+ * was, we handle this "error condition" by navigating to the
4872
+ * previously successful URL, but leaving the URL intact.*/
4694
4873
  if (processPreviousUrl) {
4695
4874
  const { id, extractedUrl, source, restoredState, extras } = t;
4696
4875
  const navStart = new NavigationStart(id, this.serializeUrl(extractedUrl), source, restoredState);
4697
4876
  eventsSubject.next(navStart);
4698
4877
  const targetSnapshot = createEmptyState(extractedUrl, this.rootComponentType).snapshot;
4699
- return of({
4878
+ overallTransitionState = {
4700
4879
  ...t,
4701
4880
  targetSnapshot,
4702
4881
  urlAfterRedirects: extractedUrl,
4703
4882
  extras: { ...extras, skipLocationChange: false, replaceUrl: false },
4704
- });
4883
+ };
4884
+ return of(overallTransitionState);
4705
4885
  }
4706
4886
  else {
4707
- /* When neither the current or previous URL can be processed, do nothing
4708
- * other than update router's internal reference to the current "settled"
4709
- * URL. This way the next navigation will be coming from the current URL
4710
- * in the browser.
4887
+ /* When neither the current or previous URL can be processed, do
4888
+ * nothing other than update router's internal reference to the
4889
+ * current "settled" URL. This way the next navigation will be coming
4890
+ * from the current URL in the browser.
4711
4891
  */
4712
4892
  this.rawUrlTree = t.rawUrl;
4713
4893
  t.resolve(null);
@@ -4719,15 +4899,16 @@ class Router {
4719
4899
  tap(t => {
4720
4900
  const guardsStart = new GuardsCheckStart(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4721
4901
  this.triggerEvent(guardsStart);
4722
- }), map(t => ({
4723
- ...t,
4724
- guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.rootContexts)
4725
- })), checkGuards(this.ngModule.injector, (evt) => this.triggerEvent(evt)), tap(t => {
4902
+ }), map(t => {
4903
+ overallTransitionState = {
4904
+ ...t,
4905
+ guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.rootContexts)
4906
+ };
4907
+ return overallTransitionState;
4908
+ }), checkGuards(this.ngModule.injector, (evt) => this.triggerEvent(evt)), tap(t => {
4909
+ overallTransitionState.guardsResult = t.guardsResult;
4726
4910
  if (isUrlTree(t.guardsResult)) {
4727
- const error = navigationCancelingError(REDIRECTING_CANCELLATION_REASON +
4728
- `"${this.serializeUrl(t.guardsResult)}"`);
4729
- error.url = t.guardsResult;
4730
- throw error;
4911
+ throw redirectingNavigationError(this.urlSerializer, t.guardsResult);
4731
4912
  }
4732
4913
  const guardsEnd = new GuardsCheckEnd(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
4733
4914
  this.triggerEvent(guardsEnd);
@@ -4785,13 +4966,14 @@ class Router {
4785
4966
  .pipe(defaultIfEmpty(), take(1));
4786
4967
  }), switchTap(() => this.afterPreactivation()), map((t) => {
4787
4968
  const targetRouterState = createRouterState(this.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4788
- return ({ ...t, targetRouterState });
4969
+ overallTransitionState = { ...t, targetRouterState };
4970
+ return (overallTransitionState);
4789
4971
  }),
4790
- /* Once here, we are about to activate syncronously. The assumption is this
4791
- will succeed, and user code may read from the Router service. Therefore
4792
- before activation, we need to update router properties storing the current
4793
- URL and the RouterState, as well as updated the browser URL. All this should
4794
- happen *before* activating. */
4972
+ /* Once here, we are about to activate synchronously. The assumption is
4973
+ this will succeed, and user code may read from the Router service.
4974
+ Therefore before activation, we need to update router properties storing
4975
+ the current URL and the RouterState, as well as updated the browser URL.
4976
+ All this should happen *before* activating. */
4795
4977
  tap((t) => {
4796
4978
  this.currentUrlTree = t.urlAfterRedirects;
4797
4979
  this.rawUrlTree =
@@ -4811,82 +4993,75 @@ class Router {
4811
4993
  completed = true;
4812
4994
  }
4813
4995
  }), finalize(() => {
4814
- /* When the navigation stream finishes either through error or success, we
4815
- * set the `completed` or `errored` flag. However, there are some situations
4816
- * where we could get here without either of those being set. For instance, a
4817
- * redirect during NavigationStart. Therefore, this is a catch-all to make
4818
- * sure the NavigationCancel
4819
- * event is fired when a navigation gets cancelled but not caught by other
4820
- * means. */
4996
+ /* When the navigation stream finishes either through error or success,
4997
+ * we set the `completed` or `errored` flag. However, there are some
4998
+ * situations where we could get here without either of those being set.
4999
+ * For instance, a redirect during NavigationStart. Therefore, this is a
5000
+ * catch-all to make sure the NavigationCancel event is fired when a
5001
+ * navigation gets cancelled but not caught by other means. */
4821
5002
  if (!completed && !errored) {
4822
5003
  const cancelationReason = NG_DEV_MODE$1 ?
4823
- `Navigation ID ${t.id} is not equal to the current navigation id ${this.navigationId}` :
5004
+ `Navigation ID ${overallTransitionState
5005
+ .id} is not equal to the current navigation id ${this.navigationId}` :
4824
5006
  '';
4825
- this.cancelNavigationTransition(t, cancelationReason, 1 /* NavigationCancellationCode.SupersededByNewNavigation */);
5007
+ this.cancelNavigationTransition(overallTransitionState, cancelationReason, 1 /* NavigationCancellationCode.SupersededByNewNavigation */);
4826
5008
  }
4827
5009
  // Only clear current navigation if it is still set to the one that
4828
5010
  // finalized.
4829
- if (this.currentNavigation?.id === t.id) {
5011
+ if (this.currentNavigation?.id === overallTransitionState.id) {
4830
5012
  this.currentNavigation = null;
4831
5013
  }
4832
5014
  }), catchError((e) => {
4833
- // TODO(atscott): The NavigationTransition `t` used here does not accurately
4834
- // reflect the current state of the whole transition because some operations
4835
- // return a new object rather than modifying the one in the outermost
4836
- // `switchMap`.
4837
- // The fix can likely be to:
4838
- // 1. Rename the outer `t` variable so it's not shadowed all the time and
4839
- // confusing
4840
- // 2. Keep reassigning to the outer variable after each stage to ensure it
4841
- // gets updated. Or change the implementations to not return a copy.
4842
- // Not changed yet because it affects existing code and would need to be
4843
- // tested more thoroughly.
4844
5015
  errored = true;
4845
5016
  /* This error type is issued during Redirect, and is handled as a
4846
5017
  * cancellation rather than an error. */
4847
- if (isNavigationCancelingError(e)) {
4848
- const redirecting = isUrlTree(e.url);
4849
- if (!redirecting) {
4850
- // Set property only if we're not redirecting. If we landed on a page and
4851
- // redirect to `/` route, the new navigation is going to see the `/`
4852
- // isn't a change from the default currentUrlTree and won't navigate.
4853
- // This is only applicable with initial navigation, so setting
4854
- // `navigated` only when not redirecting resolves this scenario.
5018
+ if (isNavigationCancelingError$1(e)) {
5019
+ if (!isRedirectingNavigationCancelingError$1(e)) {
5020
+ // Set property only if we're not redirecting. If we landed on a page
5021
+ // and redirect to `/` route, the new navigation is going to see the
5022
+ // `/` isn't a change from the default currentUrlTree and won't
5023
+ // navigate. This is only applicable with initial navigation, so
5024
+ // setting `navigated` only when not redirecting resolves this
5025
+ // scenario.
4855
5026
  this.navigated = true;
4856
- this.restoreHistory(t, true);
5027
+ this.restoreHistory(overallTransitionState, true);
4857
5028
  }
4858
- const navCancel = new NavigationCancel(t.id, this.serializeUrl(t.extractedUrl), e.message, 0 /* NavigationCancellationCode.Redirect */);
5029
+ const navCancel = new NavigationCancel(overallTransitionState.id, this.serializeUrl(overallTransitionState.extractedUrl), e.message, e.cancellationCode);
4859
5030
  eventsSubject.next(navCancel);
4860
5031
  // When redirecting, we need to delay resolving the navigation
4861
5032
  // promise and push it to the redirect navigation
4862
- if (!redirecting) {
4863
- t.resolve(false);
5033
+ if (!isRedirectingNavigationCancelingError$1(e)) {
5034
+ overallTransitionState.resolve(false);
4864
5035
  }
4865
5036
  else {
4866
5037
  const mergedTree = this.urlHandlingStrategy.merge(e.url, this.rawUrlTree);
4867
5038
  const extras = {
4868
- skipLocationChange: t.extras.skipLocationChange,
5039
+ skipLocationChange: overallTransitionState.extras.skipLocationChange,
4869
5040
  // The URL is already updated at this point if we have 'eager' URL
4870
5041
  // updates or if the navigation was triggered by the browser (back
4871
- // button, URL bar, etc). We want to replace that item in history if
4872
- // the navigation is rejected.
5042
+ // button, URL bar, etc). We want to replace that item in history
5043
+ // if the navigation is rejected.
4873
5044
  replaceUrl: this.urlUpdateStrategy === 'eager' ||
4874
- isBrowserTriggeredNavigation(t.source)
5045
+ isBrowserTriggeredNavigation(overallTransitionState.source)
4875
5046
  };
4876
- this.scheduleNavigation(mergedTree, 'imperative', null, extras, { resolve: t.resolve, reject: t.reject, promise: t.promise });
5047
+ this.scheduleNavigation(mergedTree, 'imperative', null, extras, {
5048
+ resolve: overallTransitionState.resolve,
5049
+ reject: overallTransitionState.reject,
5050
+ promise: overallTransitionState.promise
5051
+ });
4877
5052
  }
4878
- /* All other errors should reset to the router's internal URL reference to
4879
- * the pre-error state. */
5053
+ /* All other errors should reset to the router's internal URL reference
5054
+ * to the pre-error state. */
4880
5055
  }
4881
5056
  else {
4882
- this.restoreHistory(t, true);
4883
- const navError = new NavigationError(t.id, this.serializeUrl(t.extractedUrl), e);
5057
+ this.restoreHistory(overallTransitionState, true);
5058
+ const navError = new NavigationError(overallTransitionState.id, this.serializeUrl(overallTransitionState.extractedUrl), e, overallTransitionState.targetSnapshot ?? undefined);
4884
5059
  eventsSubject.next(navError);
4885
5060
  try {
4886
- t.resolve(this.errorHandler(e));
5061
+ overallTransitionState.resolve(this.errorHandler(e));
4887
5062
  }
4888
5063
  catch (ee) {
4889
- t.reject(ee);
5064
+ overallTransitionState.reject(ee);
4890
5065
  }
4891
5066
  }
4892
5067
  return EMPTY;
@@ -5280,7 +5455,7 @@ class Router {
5280
5455
  // The navigator change the location before triggered the browser event,
5281
5456
  // so we need to go back to the current url if the navigation is canceled.
5282
5457
  // Also, when navigation gets cancelled while using url update strategy eager, then we need to
5283
- // go back. Because, when `urlUpdateSrategy` is `eager`; `setBrowserUrl` method is called
5458
+ // go back. Because, when `urlUpdateStrategy` is `eager`; `setBrowserUrl` method is called
5284
5459
  // before any verification.
5285
5460
  const browserUrlUpdateOccurred = (t.source === 'popstate' || this.urlUpdateStrategy === 'eager' ||
5286
5461
  this.currentUrlTree === this.currentNavigation?.finalUrl);
@@ -5338,10 +5513,14 @@ class Router {
5338
5513
  return { navigationId };
5339
5514
  }
5340
5515
  }
5341
- Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5342
- Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router });
5343
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: Router, decorators: [{
5344
- type: Injectable
5516
+ Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5517
+ Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Router, providedIn: 'root', useFactory: setupRouter });
5518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: Router, decorators: [{
5519
+ type: Injectable,
5520
+ args: [{
5521
+ providedIn: 'root',
5522
+ useFactory: setupRouter,
5523
+ }]
5345
5524
  }], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
5346
5525
  function validateCommands(commands) {
5347
5526
  for (let i = 0; i < commands.length; i++) {
@@ -5539,9 +5718,9 @@ class RouterLink {
5539
5718
  });
5540
5719
  }
5541
5720
  }
5542
- RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5543
- RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5544
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLink, decorators: [{
5721
+ RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
5722
+ RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: { queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick()" } }, usesOnChanges: true, ngImport: i0 });
5723
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLink, decorators: [{
5545
5724
  type: Directive,
5546
5725
  args: [{ selector: ':not(a):not(area)[routerLink]' }]
5547
5726
  }], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: undefined, decorators: [{
@@ -5658,9 +5837,9 @@ class RouterLinkWithHref {
5658
5837
  });
5659
5838
  }
5660
5839
  }
5661
- RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5662
- RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5663
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5840
+ RouterLinkWithHref.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLinkWithHref, deps: [{ token: Router }, { token: ActivatedRoute }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
5841
+ RouterLinkWithHref.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", state: "state", relativeTo: "relativeTo", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target", "attr.href": "this.href" } }, usesOnChanges: true, ngImport: i0 });
5842
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLinkWithHref, decorators: [{
5664
5843
  type: Directive,
5665
5844
  args: [{ selector: 'a[routerLink],area[routerLink]' }]
5666
5845
  }], ctorParameters: function () { return [{ type: Router }, { type: ActivatedRoute }, { type: i3.LocationStrategy }]; }, propDecorators: { target: [{
@@ -5885,9 +6064,9 @@ class RouterLinkActive {
5885
6064
  this.links.some(isActiveCheckFn) || this.linksWithHrefs.some(isActiveCheckFn);
5886
6065
  }
5887
6066
  }
5888
- RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
5889
- RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0-next.4", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
5890
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterLinkActive, decorators: [{
6067
+ RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }, { token: RouterLinkWithHref, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
6068
+ RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.1", type: RouterLinkActive, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }, { propertyName: "linksWithHrefs", predicate: RouterLinkWithHref, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
6069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterLinkActive, decorators: [{
5891
6070
  type: Directive,
5892
6071
  args: [{
5893
6072
  selector: '[routerLinkActive]',
@@ -5919,84 +6098,6 @@ function isActiveMatchOptions(options) {
5919
6098
  return !!options.paths;
5920
6099
  }
5921
6100
 
5922
- /**
5923
- * @license
5924
- * Copyright Google LLC All Rights Reserved.
5925
- *
5926
- * Use of this source code is governed by an MIT-style license that can be
5927
- * found in the LICENSE file at https://angular.io/license
5928
- */
5929
- /**
5930
- * Provides a strategy for setting the page title after a router navigation.
5931
- *
5932
- * The built-in implementation traverses the router state snapshot and finds the deepest primary
5933
- * outlet with `title` property. Given the `Routes` below, navigating to
5934
- * `/base/child(popup:aux)` would result in the document title being set to "child".
5935
- * ```
5936
- * [
5937
- * {path: 'base', title: 'base', children: [
5938
- * {path: 'child', title: 'child'},
5939
- * ],
5940
- * {path: 'aux', outlet: 'popup', title: 'popupTitle'}
5941
- * ]
5942
- * ```
5943
- *
5944
- * This class can be used as a base class for custom title strategies. That is, you can create your
5945
- * own class that extends the `TitleStrategy`. Note that in the above example, the `title`
5946
- * from the named outlet is never used. However, a custom strategy might be implemented to
5947
- * incorporate titles in named outlets.
5948
- *
5949
- * @publicApi
5950
- * @see [Page title guide](guide/router#setting-the-page-title)
5951
- */
5952
- class TitleStrategy {
5953
- /**
5954
- * @returns The `title` of the deepest primary route.
5955
- */
5956
- buildTitle(snapshot) {
5957
- let pageTitle;
5958
- let route = snapshot.root;
5959
- while (route !== undefined) {
5960
- pageTitle = this.getResolvedTitleForRoute(route) ?? pageTitle;
5961
- route = route.children.find(child => child.outlet === PRIMARY_OUTLET);
5962
- }
5963
- return pageTitle;
5964
- }
5965
- /**
5966
- * Given an `ActivatedRouteSnapshot`, returns the final value of the
5967
- * `Route.title` property, which can either be a static string or a resolved value.
5968
- */
5969
- getResolvedTitleForRoute(snapshot) {
5970
- return snapshot.data[RouteTitle];
5971
- }
5972
- }
5973
- /**
5974
- * The default `TitleStrategy` used by the router that updates the title using the `Title` service.
5975
- */
5976
- class DefaultTitleStrategy extends TitleStrategy {
5977
- constructor(title) {
5978
- super();
5979
- this.title = title;
5980
- }
5981
- /**
5982
- * Sets the title of the browser to the given value.
5983
- *
5984
- * @param title The `pageTitle` from the deepest primary route.
5985
- */
5986
- updateTitle(snapshot) {
5987
- const title = this.buildTitle(snapshot);
5988
- if (title !== undefined) {
5989
- this.title.setTitle(title);
5990
- }
5991
- }
5992
- }
5993
- DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
5994
- DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
5995
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
5996
- type: Injectable,
5997
- args: [{ providedIn: 'root' }]
5998
- }], ctorParameters: function () { return [{ type: i1.Title }]; } });
5999
-
6000
6101
  /**
6001
6102
  * @license
6002
6103
  * Copyright Google LLC All Rights Reserved.
@@ -6029,9 +6130,9 @@ class PreloadAllModules {
6029
6130
  return fn().pipe(catchError(() => of(null)));
6030
6131
  }
6031
6132
  }
6032
- PreloadAllModules.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6033
- PreloadAllModules.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, providedIn: 'root' });
6034
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: PreloadAllModules, decorators: [{
6133
+ PreloadAllModules.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: PreloadAllModules, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6134
+ PreloadAllModules.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: PreloadAllModules, providedIn: 'root' });
6135
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: PreloadAllModules, decorators: [{
6035
6136
  type: Injectable,
6036
6137
  args: [{ providedIn: 'root' }]
6037
6138
  }] });
@@ -6049,9 +6150,9 @@ class NoPreloading {
6049
6150
  return of(null);
6050
6151
  }
6051
6152
  }
6052
- NoPreloading.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6053
- NoPreloading.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, providedIn: 'root' });
6054
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: NoPreloading, decorators: [{
6153
+ NoPreloading.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NoPreloading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6154
+ NoPreloading.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NoPreloading, providedIn: 'root' });
6155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: NoPreloading, decorators: [{
6055
6156
  type: Injectable,
6056
6157
  args: [{ providedIn: 'root' }]
6057
6158
  }] });
@@ -6098,7 +6199,15 @@ class RouterPreloader {
6098
6199
  }
6099
6200
  const injectorForCurrentRoute = route._injector ?? injector;
6100
6201
  const injectorForChildren = route._loadedInjector ?? injectorForCurrentRoute;
6101
- if ((route.loadChildren && !route._loadedRoutes) ||
6202
+ // Note that `canLoad` is only checked as a condition that prevents `loadChildren` and not
6203
+ // `loadComponent`. `canLoad` guards only block loading of child routes by design. This
6204
+ // happens as a consequence of needing to descend into children for route matching immediately
6205
+ // while component loading is deferred until route activation. Because `canLoad` guards can
6206
+ // have side effects, we cannot execute them here so we instead skip preloading altogether
6207
+ // when present. Lastly, it remains to be decided whether `canLoad` should behave this way
6208
+ // at all. Code splitting and lazy loading is separate from client-side authorization checks
6209
+ // and should not be used as a security measure to prevent loading of code.
6210
+ if ((route.loadChildren && !route._loadedRoutes && route.canLoad === undefined) ||
6102
6211
  (route.loadComponent && !route._loadedComponent)) {
6103
6212
  res.push(this.preloadConfig(injectorForCurrentRoute, route));
6104
6213
  }
@@ -6137,9 +6246,9 @@ class RouterPreloader {
6137
6246
  });
6138
6247
  }
6139
6248
  }
6140
- RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6141
- RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader });
6142
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterPreloader, decorators: [{
6249
+ RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6250
+ RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterPreloader });
6251
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterPreloader, decorators: [{
6143
6252
  type: Injectable
6144
6253
  }], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.EnvironmentInjector }, { type: PreloadingStrategy }, { type: RouterConfigLoader }]; } });
6145
6254
 
@@ -6226,9 +6335,9 @@ class RouterScroller {
6226
6335
  }
6227
6336
  }
6228
6337
  }
6229
- RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6230
- RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller });
6231
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterScroller, decorators: [{
6338
+ RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6339
+ RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterScroller });
6340
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterScroller, decorators: [{
6232
6341
  type: Injectable
6233
6342
  }], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: undefined }]; } });
6234
6343
 
@@ -6244,36 +6353,26 @@ const NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
6244
6353
  * The directives defined in the `RouterModule`.
6245
6354
  */
6246
6355
  const ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent];
6247
- /**
6248
- * A [DI token](guide/glossary/#di-token) for the router service.
6249
- *
6250
- * @publicApi
6251
- */
6252
- const ROUTER_CONFIGURATION = new InjectionToken(NG_DEV_MODE ? 'router config' : 'ROUTER_CONFIGURATION', {
6253
- providedIn: 'root',
6254
- factory: () => ({}),
6255
- });
6256
6356
  /**
6257
6357
  * @docsNotRequired
6258
6358
  */
6259
6359
  const ROUTER_FORROOT_GUARD = new InjectionToken(NG_DEV_MODE ? 'router duplicate forRoot guard' : 'ROUTER_FORROOT_GUARD');
6260
6360
  const ROUTER_PRELOADER = new InjectionToken(NG_DEV_MODE ? 'router preloader' : '');
6361
+ // TODO(atscott): All of these except `ActivatedRoute` are `providedIn: 'root'`. They are only kept
6362
+ // here to avoid a breaking change whereby the provider order matters based on where the
6363
+ // `RouterModule`/`RouterTestingModule` is imported. These can/should be removed as a "breaking"
6364
+ // change in a major version.
6261
6365
  const ROUTER_PROVIDERS = [
6262
6366
  Location,
6263
6367
  { provide: UrlSerializer, useClass: DefaultUrlSerializer },
6264
- {
6265
- provide: Router,
6266
- useFactory: setupRouter,
6267
- deps: [
6268
- UrlSerializer, ChildrenOutletContexts, Location, Injector, Compiler, ROUTES,
6269
- ROUTER_CONFIGURATION, DefaultTitleStrategy, [TitleStrategy, new Optional()],
6270
- [UrlHandlingStrategy, new Optional()], [RouteReuseStrategy, new Optional()]
6271
- ]
6272
- },
6368
+ { provide: Router, useFactory: setupRouter },
6273
6369
  ChildrenOutletContexts,
6274
6370
  { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
6275
6371
  RouterConfigLoader,
6276
6372
  ];
6373
+ function rootRoute(router) {
6374
+ return router.routerState.root;
6375
+ }
6277
6376
  function routerNgProbeToken() {
6278
6377
  return new NgProbeToken('Router', Router);
6279
6378
  }
@@ -6299,8 +6398,7 @@ function routerNgProbeToken() {
6299
6398
  * @publicApi
6300
6399
  */
6301
6400
  class RouterModule {
6302
- // Note: We are injecting the Router so it gets created eagerly...
6303
- constructor(guard, router) { }
6401
+ constructor(guard) { }
6304
6402
  /**
6305
6403
  * Creates and configures a module with all the router providers and directives.
6306
6404
  * Optionally sets up an application listener to perform an initial navigation.
@@ -6361,10 +6459,10 @@ class RouterModule {
6361
6459
  return { ngModule: RouterModule, providers: [provideRoutes(routes)] };
6362
6460
  }
6363
6461
  }
6364
- RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }, { token: Router, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6365
- RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6366
- RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule });
6367
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4", ngImport: i0, type: RouterModule, decorators: [{
6462
+ RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
6463
+ RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: RouterModule, declarations: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkWithHref, RouterLinkActive, ɵEmptyOutletComponent] });
6464
+ RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterModule });
6465
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: RouterModule, decorators: [{
6368
6466
  type: NgModule,
6369
6467
  args: [{
6370
6468
  declarations: ROUTER_DIRECTIVES,
@@ -6375,8 +6473,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0-next.4",
6375
6473
  }, {
6376
6474
  type: Inject,
6377
6475
  args: [ROUTER_FORROOT_GUARD]
6378
- }] }, { type: Router, decorators: [{
6379
- type: Optional
6380
6476
  }] }]; } });
6381
6477
  function provideRouterScroller() {
6382
6478
  return {
@@ -6422,48 +6518,9 @@ function provideForRootGuard(router) {
6422
6518
  */
6423
6519
  function provideRoutes(routes) {
6424
6520
  return [
6425
- { provide: ANALYZE_FOR_ENTRY_COMPONENTS, multi: true, useValue: routes },
6426
6521
  { provide: ROUTES, multi: true, useValue: routes },
6427
6522
  ];
6428
6523
  }
6429
- function setupRouter(urlSerializer, contexts, location, injector, compiler, config, opts = {}, defaultTitleStrategy, titleStrategy, urlHandlingStrategy, routeReuseStrategy) {
6430
- const router = new Router(null, urlSerializer, contexts, location, injector, compiler, flatten(config));
6431
- if (urlHandlingStrategy) {
6432
- router.urlHandlingStrategy = urlHandlingStrategy;
6433
- }
6434
- if (routeReuseStrategy) {
6435
- router.routeReuseStrategy = routeReuseStrategy;
6436
- }
6437
- router.titleStrategy = titleStrategy ?? defaultTitleStrategy;
6438
- assignExtraOptionsToRouter(opts, router);
6439
- return router;
6440
- }
6441
- function assignExtraOptionsToRouter(opts, router) {
6442
- if (opts.errorHandler) {
6443
- router.errorHandler = opts.errorHandler;
6444
- }
6445
- if (opts.malformedUriErrorHandler) {
6446
- router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
6447
- }
6448
- if (opts.onSameUrlNavigation) {
6449
- router.onSameUrlNavigation = opts.onSameUrlNavigation;
6450
- }
6451
- if (opts.paramsInheritanceStrategy) {
6452
- router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
6453
- }
6454
- if (opts.relativeLinkResolution) {
6455
- router.relativeLinkResolution = opts.relativeLinkResolution;
6456
- }
6457
- if (opts.urlUpdateStrategy) {
6458
- router.urlUpdateStrategy = opts.urlUpdateStrategy;
6459
- }
6460
- if (opts.canceledNavigationResolution) {
6461
- router.canceledNavigationResolution = opts.canceledNavigationResolution;
6462
- }
6463
- }
6464
- function rootRoute(router) {
6465
- return router.routerState.root;
6466
- }
6467
6524
  function getBootstrapListener() {
6468
6525
  const injector = inject(Injector);
6469
6526
  return (bootstrappedComponentRef) => {
@@ -6473,8 +6530,7 @@ function getBootstrapListener() {
6473
6530
  }
6474
6531
  const router = injector.get(Router);
6475
6532
  const bootstrapDone = injector.get(BOOTSTRAP_DONE);
6476
- // Default case
6477
- if (injector.get(INITIAL_NAVIGATION, null, InjectFlags.Optional) === null) {
6533
+ if (injector.get(INITIAL_NAVIGATION) === 1 /* InitialNavigation.EnabledNonBlocking */) {
6478
6534
  router.initialNavigation();
6479
6535
  }
6480
6536
  injector.get(ROUTER_PRELOADER, null, InjectFlags.Optional)?.setUpPreloading();
@@ -6518,7 +6574,7 @@ const BOOTSTRAP_DONE = new InjectionToken(NG_DEV_MODE ? 'bootstrap done indicato
6518
6574
  });
6519
6575
  function provideEnabledBlockingInitialNavigation() {
6520
6576
  return [
6521
- { provide: INITIAL_NAVIGATION, useValue: 'enabledBlocking' },
6577
+ { provide: INITIAL_NAVIGATION, useValue: 0 /* InitialNavigation.EnabledBlocking */ },
6522
6578
  {
6523
6579
  provide: APP_INITIALIZER,
6524
6580
  multi: true,
@@ -6584,7 +6640,7 @@ function provideEnabledBlockingInitialNavigation() {
6584
6640
  },
6585
6641
  ];
6586
6642
  }
6587
- const INITIAL_NAVIGATION = new InjectionToken(NG_DEV_MODE ? 'initial navigation' : '');
6643
+ const INITIAL_NAVIGATION = new InjectionToken(NG_DEV_MODE ? 'initial navigation' : '', { providedIn: 'root', factory: () => 1 /* InitialNavigation.EnabledNonBlocking */ });
6588
6644
  function provideDisabledInitialNavigation() {
6589
6645
  return [
6590
6646
  {
@@ -6597,7 +6653,7 @@ function provideDisabledInitialNavigation() {
6597
6653
  };
6598
6654
  }
6599
6655
  },
6600
- { provide: INITIAL_NAVIGATION, useValue: 'disabled' }
6656
+ { provide: INITIAL_NAVIGATION, useValue: 2 /* InitialNavigation.Disabled */ }
6601
6657
  ];
6602
6658
  }
6603
6659
  function provideTracing() {
@@ -6640,7 +6696,7 @@ function providePreloading(preloadingStrategy) {
6640
6696
  /**
6641
6697
  * @publicApi
6642
6698
  */
6643
- const VERSION = new Version('14.1.0-next.4');
6699
+ const VERSION = new Version('14.1.1');
6644
6700
 
6645
6701
  /**
6646
6702
  * @license