@angular/router 21.1.0-next.4 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,14 @@
1
1
  /**
2
- * @license Angular v21.1.0-next.4
3
- * (c) 2010-2025 Google LLC. https://angular.dev/
2
+ * @license Angular v21.1.0
3
+ * (c) 2010-2026 Google LLC. https://angular.dev/
4
4
  * License: MIT
5
5
  */
6
6
 
7
7
  import * as i3 from '@angular/common';
8
- import { ViewportScroller, PlatformNavigation, PlatformLocation, Location, ɵNavigationAdapterForLocation as _NavigationAdapterForLocation, LOCATION_INITIALIZED, LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
8
+ import { ViewportScroller, PlatformNavigation, PlatformLocation, ɵPRECOMMIT_HANDLER_SUPPORTED as _PRECOMMIT_HANDLER_SUPPORTED, Location, ɵNavigationAdapterForLocation as _NavigationAdapterForLocation, LOCATION_INITIALIZED, LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
9
9
  import * as i0 from '@angular/core';
10
10
  import { signal, untracked, inject, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, HostAttributeToken, ɵRuntimeError as _RuntimeError, booleanAttribute, Directive, Attribute, HostBinding, Input, HostListener, EventEmitter, ContentChildren, Output, Injectable, createEnvironmentInjector, InjectionToken, NgZone, EnvironmentInjector, DestroyRef, afterNextRender, ɵpromiseWithResolvers as _promiseWithResolvers, ɵpublishExternalGlobalUtil as _publishExternalGlobalUtil, makeEnvironmentProviders, APP_BOOTSTRAP_LISTENER, provideEnvironmentInitializer, Injector, ApplicationRef, ɵIS_ENABLED_BLOCKING_INITIAL_NAVIGATION as _IS_ENABLED_BLOCKING_INITIAL_NAVIGATION, provideAppInitializer, ɵperformanceMarkFeature as _performanceMarkFeature, ENVIRONMENT_INITIALIZER, NgModule } from '@angular/core';
11
- import { ROUTER_CONFIGURATION, NavigationEnd, isUrlTree, Router, ActivatedRoute, RouterConfigLoader, IMPERATIVE_NAVIGATION, UrlSerializer, NavigationTransitions, NavigationStart, NavigationSkipped, NavigationSkippedCode, Scroll, StateManager, RoutesRecognized, BeforeActivateRoutes, NavigationCancel, NavigationError, isRedirectingEvent, NavigationCancellationCode, ROUTES, afterNextNavigation, stringifyEvent, NAVIGATION_ERROR_HANDLER, RoutedComponentInputBinder, INPUT_BINDER, CREATE_VIEW_TRANSITION, createViewTransition, VIEW_TRANSITION_OPTIONS, DefaultUrlSerializer, ChildrenOutletContexts, RouterOutlet, ɵEmptyOutletComponent as _EmptyOutletComponent } from './_router-chunk.mjs';
11
+ import { ROUTER_CONFIGURATION, NavigationEnd, isUrlTree, Router, ActivatedRoute, isActive, exactMatchOptions, subsetMatchOptions, RouterConfigLoader, IMPERATIVE_NAVIGATION, UrlSerializer, NavigationTransitions, NavigationStart, NavigationSkipped, NavigationSkippedCode, Scroll, StateManager, RoutesRecognized, BeforeActivateRoutes, NavigationCancel, NavigationError, isRedirectingEvent, NavigationCancellationCode, ROUTES, afterNextNavigation, ROUTE_INJECTOR_CLEANUP, routeInjectorCleanup, stringifyEvent, NAVIGATION_ERROR_HANDLER, RoutedComponentInputBinder, INPUT_BINDER, CREATE_VIEW_TRANSITION, createViewTransition, VIEW_TRANSITION_OPTIONS, DefaultUrlSerializer, ChildrenOutletContexts, RouterOutlet, ɵEmptyOutletComponent as _EmptyOutletComponent } from './_router-chunk.mjs';
12
12
  import { Subject, of, from } from 'rxjs';
13
13
  import { mergeAll, catchError, filter, concatMap, mergeMap } from 'rxjs/operators';
14
14
 
@@ -54,21 +54,13 @@ class RouterLink {
54
54
  }));
55
55
  const tagName = el.nativeElement.tagName?.toLowerCase();
56
56
  this.isAnchorElement = tagName === 'a' || tagName === 'area' || !!(typeof customElements === 'object' && customElements.get(tagName)?.observedAttributes?.includes?.('href'));
57
- if (!this.isAnchorElement) {
58
- this.subscribeToNavigationEventsIfNecessary();
59
- } else {
57
+ if (this.isAnchorElement) {
60
58
  this.setTabIndexIfNotOnNativeEl('0');
59
+ this.subscribeToNavigationEventsIfNecessary();
61
60
  }
62
61
  }
63
62
  subscribeToNavigationEventsIfNecessary() {
64
- if (this.subscription !== undefined || !this.isAnchorElement) {
65
- return;
66
- }
67
- let createSubcription = this.preserveFragment;
68
- const dependsOnRouterState = handling => handling === 'merge' || handling === 'preserve';
69
- createSubcription ||= dependsOnRouterState(this.queryParamsHandling);
70
- createSubcription ||= !this.queryParamsHandling && !dependsOnRouterState(this.options?.defaultQueryParamsHandling);
71
- if (!createSubcription) {
63
+ if (this.subscription !== undefined) {
72
64
  return;
73
65
  }
74
66
  this.subscription = this.router.events.subscribe(s => {
@@ -92,7 +84,6 @@ class RouterLink {
92
84
  }
93
85
  if (this.isAnchorElement) {
94
86
  this.updateHref();
95
- this.subscribeToNavigationEventsIfNecessary();
96
87
  }
97
88
  this.onChanges.next(this);
98
89
  }
@@ -166,7 +157,7 @@ class RouterLink {
166
157
  }
167
158
  static ɵfac = i0.ɵɵngDeclareFactory({
168
159
  minVersion: "12.0.0",
169
- version: "21.1.0-next.4",
160
+ version: "21.1.0",
170
161
  ngImport: i0,
171
162
  type: RouterLink,
172
163
  deps: [{
@@ -187,7 +178,7 @@ class RouterLink {
187
178
  });
188
179
  static ɵdir = i0.ɵɵngDeclareDirective({
189
180
  minVersion: "16.1.0",
190
- version: "21.1.0-next.4",
181
+ version: "21.1.0",
191
182
  type: RouterLink,
192
183
  isStandalone: true,
193
184
  selector: "[routerLink]",
@@ -219,7 +210,7 @@ class RouterLink {
219
210
  }
220
211
  i0.ɵɵngDeclareClassMetadata({
221
212
  minVersion: "12.0.0",
222
- version: "21.1.0-next.4",
213
+ version: "21.1.0",
223
214
  ngImport: i0,
224
215
  type: RouterLink,
225
216
  decorators: [{
@@ -383,10 +374,14 @@ class RouterLinkActive {
383
374
  });
384
375
  }
385
376
  isLinkActive(router) {
386
- const options = isActiveMatchOptions(this.routerLinkActiveOptions) ? this.routerLinkActiveOptions : this.routerLinkActiveOptions.exact || false;
377
+ const options = isActiveMatchOptions(this.routerLinkActiveOptions) ? this.routerLinkActiveOptions : this.routerLinkActiveOptions.exact ?? false ? {
378
+ ...exactMatchOptions
379
+ } : {
380
+ ...subsetMatchOptions
381
+ };
387
382
  return link => {
388
383
  const urlTree = link.urlTree;
389
- return urlTree ? router.isActive(urlTree, options) : false;
384
+ return urlTree ? untracked(isActive(urlTree, router, options)) : false;
390
385
  };
391
386
  }
392
387
  hasActiveLinks() {
@@ -395,7 +390,7 @@ class RouterLinkActive {
395
390
  }
396
391
  static ɵfac = i0.ɵɵngDeclareFactory({
397
392
  minVersion: "12.0.0",
398
- version: "21.1.0-next.4",
393
+ version: "21.1.0",
399
394
  ngImport: i0,
400
395
  type: RouterLinkActive,
401
396
  deps: [{
@@ -411,7 +406,7 @@ class RouterLinkActive {
411
406
  });
412
407
  static ɵdir = i0.ɵɵngDeclareDirective({
413
408
  minVersion: "14.0.0",
414
- version: "21.1.0-next.4",
409
+ version: "21.1.0",
415
410
  type: RouterLinkActive,
416
411
  isStandalone: true,
417
412
  selector: "[routerLinkActive]",
@@ -435,7 +430,7 @@ class RouterLinkActive {
435
430
  }
436
431
  i0.ɵɵngDeclareClassMetadata({
437
432
  minVersion: "12.0.0",
438
- version: "21.1.0-next.4",
433
+ version: "21.1.0",
439
434
  ngImport: i0,
440
435
  type: RouterLinkActive,
441
436
  decorators: [{
@@ -486,7 +481,7 @@ class PreloadAllModules {
486
481
  }
487
482
  static ɵfac = i0.ɵɵngDeclareFactory({
488
483
  minVersion: "12.0.0",
489
- version: "21.1.0-next.4",
484
+ version: "21.1.0",
490
485
  ngImport: i0,
491
486
  type: PreloadAllModules,
492
487
  deps: [],
@@ -494,7 +489,7 @@ class PreloadAllModules {
494
489
  });
495
490
  static ɵprov = i0.ɵɵngDeclareInjectable({
496
491
  minVersion: "12.0.0",
497
- version: "21.1.0-next.4",
492
+ version: "21.1.0",
498
493
  ngImport: i0,
499
494
  type: PreloadAllModules,
500
495
  providedIn: 'root'
@@ -502,7 +497,7 @@ class PreloadAllModules {
502
497
  }
503
498
  i0.ɵɵngDeclareClassMetadata({
504
499
  minVersion: "12.0.0",
505
- version: "21.1.0-next.4",
500
+ version: "21.1.0",
506
501
  ngImport: i0,
507
502
  type: PreloadAllModules,
508
503
  decorators: [{
@@ -518,7 +513,7 @@ class NoPreloading {
518
513
  }
519
514
  static ɵfac = i0.ɵɵngDeclareFactory({
520
515
  minVersion: "12.0.0",
521
- version: "21.1.0-next.4",
516
+ version: "21.1.0",
522
517
  ngImport: i0,
523
518
  type: NoPreloading,
524
519
  deps: [],
@@ -526,7 +521,7 @@ class NoPreloading {
526
521
  });
527
522
  static ɵprov = i0.ɵɵngDeclareInjectable({
528
523
  minVersion: "12.0.0",
529
- version: "21.1.0-next.4",
524
+ version: "21.1.0",
530
525
  ngImport: i0,
531
526
  type: NoPreloading,
532
527
  providedIn: 'root'
@@ -534,7 +529,7 @@ class NoPreloading {
534
529
  }
535
530
  i0.ɵɵngDeclareClassMetadata({
536
531
  minVersion: "12.0.0",
537
- version: "21.1.0-next.4",
532
+ version: "21.1.0",
538
533
  ngImport: i0,
539
534
  type: NoPreloading,
540
535
  decorators: [{
@@ -563,17 +558,18 @@ class RouterPreloader {
563
558
  return this.processRoutes(this.injector, this.router.config);
564
559
  }
565
560
  ngOnDestroy() {
566
- if (this.subscription) {
567
- this.subscription.unsubscribe();
568
- }
561
+ this.subscription?.unsubscribe();
569
562
  }
570
563
  processRoutes(injector, routes) {
571
564
  const res = [];
572
565
  for (const route of routes) {
573
566
  if (route.providers && !route._injector) {
574
- route._injector = createEnvironmentInjector(route.providers, injector, `Route: ${route.path}`);
567
+ route._injector = createEnvironmentInjector(route.providers, injector, typeof ngDevMode === 'undefined' || ngDevMode ? `Route: ${route.path}` : '');
575
568
  }
576
569
  const injectorForCurrentRoute = route._injector ?? injector;
570
+ if (route._loadedNgModuleFactory && !route._loadedInjector) {
571
+ route._loadedInjector = route._loadedNgModuleFactory.create(injectorForCurrentRoute).injector;
572
+ }
577
573
  const injectorForChildren = route._loadedInjector ?? injectorForCurrentRoute;
578
574
  if (route.loadChildren && !route._loadedRoutes && route.canLoad === undefined || route.loadComponent && !route._loadedComponent) {
579
575
  res.push(this.preloadConfig(injectorForCurrentRoute, route));
@@ -586,6 +582,9 @@ class RouterPreloader {
586
582
  }
587
583
  preloadConfig(injector, route) {
588
584
  return this.preloadingStrategy.preload(route, () => {
585
+ if (injector.destroyed) {
586
+ return of(null);
587
+ }
589
588
  let loadedChildren$;
590
589
  if (route.loadChildren && route.canLoad === undefined) {
591
590
  loadedChildren$ = from(this.loader.loadChildren(injector, route));
@@ -598,6 +597,7 @@ class RouterPreloader {
598
597
  }
599
598
  route._loadedRoutes = config.routes;
600
599
  route._loadedInjector = config.injector;
600
+ route._loadedNgModuleFactory = config.factory;
601
601
  return this.processRoutes(config.injector ?? injector, config.routes);
602
602
  }));
603
603
  if (route.loadComponent && !route._loadedComponent) {
@@ -610,7 +610,7 @@ class RouterPreloader {
610
610
  }
611
611
  static ɵfac = i0.ɵɵngDeclareFactory({
612
612
  minVersion: "12.0.0",
613
- version: "21.1.0-next.4",
613
+ version: "21.1.0",
614
614
  ngImport: i0,
615
615
  type: RouterPreloader,
616
616
  deps: [{
@@ -626,7 +626,7 @@ class RouterPreloader {
626
626
  });
627
627
  static ɵprov = i0.ɵɵngDeclareInjectable({
628
628
  minVersion: "12.0.0",
629
- version: "21.1.0-next.4",
629
+ version: "21.1.0",
630
630
  ngImport: i0,
631
631
  type: RouterPreloader,
632
632
  providedIn: 'root'
@@ -634,7 +634,7 @@ class RouterPreloader {
634
634
  }
635
635
  i0.ɵɵngDeclareClassMetadata({
636
636
  minVersion: "12.0.0",
637
- version: "21.1.0-next.4",
637
+ version: "21.1.0",
638
638
  ngImport: i0,
639
639
  type: RouterPreloader,
640
640
  decorators: [{
@@ -736,7 +736,7 @@ class RouterScroller {
736
736
  }
737
737
  static ɵfac = i0.ɵɵngDeclareFactory({
738
738
  minVersion: "12.0.0",
739
- version: "21.1.0-next.4",
739
+ version: "21.1.0",
740
740
  ngImport: i0,
741
741
  type: RouterScroller,
742
742
  deps: "invalid",
@@ -744,14 +744,14 @@ class RouterScroller {
744
744
  });
745
745
  static ɵprov = i0.ɵɵngDeclareInjectable({
746
746
  minVersion: "12.0.0",
747
- version: "21.1.0-next.4",
747
+ version: "21.1.0",
748
748
  ngImport: i0,
749
749
  type: RouterScroller
750
750
  });
751
751
  }
752
752
  i0.ɵɵngDeclareClassMetadata({
753
753
  minVersion: "12.0.0",
754
- version: "21.1.0-next.4",
754
+ version: "21.1.0",
755
755
  ngImport: i0,
756
756
  type: RouterScroller,
757
757
  decorators: [{
@@ -785,6 +785,7 @@ class NavigationStateManager extends StateManager {
785
785
  }) !== null;
786
786
  base = new URL(inject(PlatformLocation).href).origin;
787
787
  appRootURL = new URL(this.location.prepareExternalUrl?.('/') ?? '/', this.base).href;
788
+ precommitHandlerSupported = inject(_PRECOMMIT_HANDLER_SUPPORTED);
788
789
  activeHistoryEntry = this.navigation.currentEntry;
789
790
  currentNavigation = {};
790
791
  nonRouterCurrentEntryChangeSubject = new Subject();
@@ -992,7 +993,7 @@ class NavigationStateManager extends StateManager {
992
993
  }
993
994
  static ɵfac = i0.ɵɵngDeclareFactory({
994
995
  minVersion: "12.0.0",
995
- version: "21.1.0-next.4",
996
+ version: "21.1.0",
996
997
  ngImport: i0,
997
998
  type: NavigationStateManager,
998
999
  deps: [],
@@ -1000,7 +1001,7 @@ class NavigationStateManager extends StateManager {
1000
1001
  });
1001
1002
  static ɵprov = i0.ɵɵngDeclareInjectable({
1002
1003
  minVersion: "12.0.0",
1003
- version: "21.1.0-next.4",
1004
+ version: "21.1.0",
1004
1005
  ngImport: i0,
1005
1006
  type: NavigationStateManager,
1006
1007
  providedIn: 'root'
@@ -1008,7 +1009,7 @@ class NavigationStateManager extends StateManager {
1008
1009
  }
1009
1010
  i0.ɵɵngDeclareClassMetadata({
1010
1011
  minVersion: "12.0.0",
1011
- version: "21.1.0-next.4",
1012
+ version: "21.1.0",
1012
1013
  ngImport: i0,
1013
1014
  type: NavigationStateManager,
1014
1015
  decorators: [{
@@ -1084,14 +1085,14 @@ function withInMemoryScrolling(options = {}) {
1084
1085
  }];
1085
1086
  return routerFeature(4, providers);
1086
1087
  }
1087
- function withPlatformNavigation() {
1088
+ function withExperimentalPlatformNavigation() {
1088
1089
  const devModeLocationCheck = typeof ngDevMode === 'undefined' || ngDevMode ? [provideEnvironmentInitializer(() => {
1089
1090
  const locationInstance = inject(Location);
1090
1091
  if (!(locationInstance instanceof _NavigationAdapterForLocation)) {
1091
1092
  const locationConstructorName = locationInstance.constructor.name;
1092
- let message = `'withPlatformNavigation' provides a 'Location' implementation that ensures navigation APIs are consistently used.` + ` An instance of ${locationConstructorName} was found instead.`;
1093
+ let message = `'withExperimentalPlatformNavigation' provides a 'Location' implementation that ensures navigation APIs are consistently used.` + ` An instance of ${locationConstructorName} was found instead.`;
1093
1094
  if (locationConstructorName === 'SpyLocation') {
1094
- message += ` One of 'RouterTestingModule' or 'provideLocationMocks' was likely used. 'withPlatformNavigation' does not work with these because they override the Location implementation.`;
1095
+ message += ` One of 'RouterTestingModule' or 'provideLocationMocks' was likely used. 'withExperimentalPlatformNavigation' does not work with these because they override the Location implementation.`;
1095
1096
  }
1096
1097
  throw new Error(message);
1097
1098
  }
@@ -1103,7 +1104,7 @@ function withPlatformNavigation() {
1103
1104
  provide: Location,
1104
1105
  useClass: _NavigationAdapterForLocation
1105
1106
  }, devModeLocationCheck];
1106
- return routerFeature(4, providers);
1107
+ return routerFeature(11, providers);
1107
1108
  }
1108
1109
  function getBootstrapListener() {
1109
1110
  const injector = inject(Injector);
@@ -1228,6 +1229,12 @@ function withNavigationErrorHandler(handler) {
1228
1229
  }];
1229
1230
  return routerFeature(7, providers);
1230
1231
  }
1232
+ function withExperimentalAutoCleanupInjectors() {
1233
+ return routerFeature(10, [{
1234
+ provide: ROUTE_INJECTOR_CLEANUP,
1235
+ useValue: routeInjectorCleanup
1236
+ }]);
1237
+ }
1231
1238
  function withComponentInputBinding() {
1232
1239
  const providers = [RoutedComponentInputBinder, {
1233
1240
  provide: INPUT_BINDER,
@@ -1301,7 +1308,7 @@ class RouterModule {
1301
1308
  }
1302
1309
  static ɵfac = i0.ɵɵngDeclareFactory({
1303
1310
  minVersion: "12.0.0",
1304
- version: "21.1.0-next.4",
1311
+ version: "21.1.0",
1305
1312
  ngImport: i0,
1306
1313
  type: RouterModule,
1307
1314
  deps: [],
@@ -1309,7 +1316,7 @@ class RouterModule {
1309
1316
  });
1310
1317
  static ɵmod = i0.ɵɵngDeclareNgModule({
1311
1318
  minVersion: "14.0.0",
1312
- version: "21.1.0-next.4",
1319
+ version: "21.1.0",
1313
1320
  ngImport: i0,
1314
1321
  type: RouterModule,
1315
1322
  imports: [RouterOutlet, RouterLink, RouterLinkActive, _EmptyOutletComponent],
@@ -1317,14 +1324,14 @@ class RouterModule {
1317
1324
  });
1318
1325
  static ɵinj = i0.ɵɵngDeclareInjector({
1319
1326
  minVersion: "12.0.0",
1320
- version: "21.1.0-next.4",
1327
+ version: "21.1.0",
1321
1328
  ngImport: i0,
1322
1329
  type: RouterModule
1323
1330
  });
1324
1331
  }
1325
1332
  i0.ɵɵngDeclareClassMetadata({
1326
1333
  minVersion: "12.0.0",
1327
- version: "21.1.0-next.4",
1334
+ version: "21.1.0",
1328
1335
  ngImport: i0,
1329
1336
  type: RouterModule,
1330
1337
  decorators: [{
@@ -1386,5 +1393,5 @@ function provideRouterInitializer() {
1386
1393
  }];
1387
1394
  }
1388
1395
 
1389
- export { NoPreloading, PreloadAllModules, PreloadingStrategy, ROUTER_INITIALIZER, ROUTER_PROVIDERS, RouterLink, RouterLinkActive, RouterModule, RouterPreloader, provideRouter, provideRoutes, withComponentInputBinding, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withHashLocation, withInMemoryScrolling, withNavigationErrorHandler, withPlatformNavigation, withPreloading, withRouterConfig, withViewTransitions };
1396
+ export { NoPreloading, PreloadAllModules, PreloadingStrategy, ROUTER_INITIALIZER, ROUTER_PROVIDERS, RouterLink, RouterLinkActive, RouterModule, RouterPreloader, provideRouter, provideRoutes, withComponentInputBinding, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withExperimentalAutoCleanupInjectors, withExperimentalPlatformNavigation, withHashLocation, withInMemoryScrolling, withNavigationErrorHandler, withPreloading, withRouterConfig, withViewTransitions };
1390
1397
  //# sourceMappingURL=_router_module-chunk.mjs.map