@angular/router 15.1.0-next.0 → 15.1.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/esm2020/src/components/empty_outlet.mjs +3 -3
  2. package/esm2020/src/deprecated_load_children.mjs +3 -1
  3. package/esm2020/src/directives/router_link.mjs +3 -3
  4. package/esm2020/src/directives/router_link_active.mjs +3 -3
  5. package/esm2020/src/directives/router_outlet.mjs +3 -3
  6. package/esm2020/src/index.mjs +1 -1
  7. package/esm2020/src/models.mjs +1 -1
  8. package/esm2020/src/navigation_transition.mjs +145 -84
  9. package/esm2020/src/page_title_strategy.mjs +6 -6
  10. package/esm2020/src/private_export.mjs +1 -2
  11. package/esm2020/src/provide_router.mjs +6 -7
  12. package/esm2020/src/route_reuse_strategy.mjs +6 -6
  13. package/esm2020/src/router.mjs +58 -165
  14. package/esm2020/src/router_config.mjs +1 -1
  15. package/esm2020/src/router_config_loader.mjs +3 -3
  16. package/esm2020/src/router_module.mjs +11 -9
  17. package/esm2020/src/router_outlet_context.mjs +3 -3
  18. package/esm2020/src/router_preloader.mjs +9 -9
  19. package/esm2020/src/router_scroller.mjs +20 -21
  20. package/esm2020/src/router_state.mjs +7 -7
  21. package/esm2020/src/url_handling_strategy.mjs +6 -6
  22. package/esm2020/src/url_tree.mjs +4 -4
  23. package/esm2020/src/utils/config.mjs +2 -2
  24. package/esm2020/src/version.mjs +1 -1
  25. package/esm2020/testing/src/router_testing_module.mjs +56 -17
  26. package/fesm2015/router.mjs +428 -471
  27. package/fesm2015/router.mjs.map +1 -1
  28. package/fesm2015/testing.mjs +56 -17
  29. package/fesm2015/testing.mjs.map +1 -1
  30. package/fesm2015/upgrade.mjs +1 -1
  31. package/fesm2020/router.mjs +419 -467
  32. package/fesm2020/router.mjs.map +1 -1
  33. package/fesm2020/testing.mjs +56 -17
  34. package/fesm2020/testing.mjs.map +1 -1
  35. package/fesm2020/upgrade.mjs +1 -1
  36. package/index.d.ts +76 -58
  37. package/package.json +4 -4
  38. package/testing/index.d.ts +1 -1
  39. package/upgrade/index.d.ts +1 -1
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license Angular v15.1.0-next.0
2
+ * @license Angular v15.1.0-next.2
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, Injectable, EventEmitter, inject, ViewContainerRef, ChangeDetectorRef, EnvironmentInjector, Directive, Input, Output, Component, createEnvironmentInjector, ɵisStandalone, ComponentFactoryResolver, ɵisInjectable, InjectionToken, InjectFlags, NgModuleFactory, Injector, Compiler, NgModuleRef, ɵConsole, NgZone, ɵcoerceToBoolean, ɵɵsanitizeUrlOrResourceUrl, Attribute, HostBinding, HostListener, Optional, ContentChildren, makeEnvironmentProviders, APP_BOOTSTRAP_LISTENER, ENVIRONMENT_INITIALIZER, ApplicationRef, APP_INITIALIZER, NgProbeToken, SkipSelf, NgModule, Inject, Version } from '@angular/core';
8
+ import { ɵisObservable, ɵisPromise, ɵRuntimeError, Injectable, EventEmitter, inject, ViewContainerRef, ChangeDetectorRef, EnvironmentInjector, Directive, Input, Output, Component, createEnvironmentInjector, isStandalone, ComponentFactoryResolver, ɵisInjectable, InjectionToken, InjectFlags, NgModuleFactory, ɵConsole, NgZone, ɵcoerceToBoolean, ɵɵsanitizeUrlOrResourceUrl, Attribute, HostBinding, HostListener, Optional, ContentChildren, makeEnvironmentProviders, APP_BOOTSTRAP_LISTENER, ENVIRONMENT_INITIALIZER, Injector, ApplicationRef, APP_INITIALIZER, NgProbeToken, SkipSelf, NgModule, Inject, Version } from '@angular/core';
9
9
  import { from, of, BehaviorSubject, EmptyError, combineLatest, concat, defer, pipe, throwError, Observable, EMPTY, ConnectableObservable, Subject } from 'rxjs';
10
10
  import * as i3 from '@angular/common';
11
11
  import { Location, ViewportScroller, LOCATION_INITIALIZED, LocationStrategy, HashLocationStrategy, PathLocationStrategy } from '@angular/common';
@@ -461,9 +461,9 @@ function mapChildrenIntoArray(segment, fn) {
461
461
  */
462
462
  class UrlSerializer {
463
463
  }
464
- UrlSerializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlSerializer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
465
- UrlSerializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlSerializer, providedIn: 'root', useFactory: () => new DefaultUrlSerializer() });
466
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlSerializer, decorators: [{
464
+ UrlSerializer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlSerializer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
465
+ UrlSerializer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlSerializer, providedIn: 'root', useFactory: () => new DefaultUrlSerializer() });
466
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlSerializer, decorators: [{
467
467
  type: Injectable,
468
468
  args: [{ providedIn: 'root', useFactory: () => new DefaultUrlSerializer() }]
469
469
  }] });
@@ -2083,6 +2083,13 @@ function flattenInherited(pathFromRoot) {
2083
2083
  * @publicApi
2084
2084
  */
2085
2085
  class ActivatedRouteSnapshot {
2086
+ /** The resolved route title */
2087
+ get title() {
2088
+ var _a;
2089
+ // Note: This _must_ be a getter because the data is mutated in the resolvers. Title will not be
2090
+ // available at the time of class instantiation.
2091
+ return (_a = this.data) === null || _a === void 0 ? void 0 : _a[RouteTitleKey];
2092
+ }
2086
2093
  /** @internal */
2087
2094
  constructor(
2088
2095
  /** The URL segments matched by this route */
@@ -2129,13 +2136,6 @@ class ActivatedRouteSnapshot {
2129
2136
  this._lastPathIndex = lastPathIndex;
2130
2137
  this._resolve = resolve;
2131
2138
  }
2132
- /** The resolved route title */
2133
- get title() {
2134
- var _a;
2135
- // Note: This _must_ be a getter because the data is mutated in the resolvers. Title will not be
2136
- // available at the time of class instantiation.
2137
- return (_a = this.data) === null || _a === void 0 ? void 0 : _a[RouteTitleKey];
2138
- }
2139
2139
  /** The root of the router state */
2140
2140
  get root() {
2141
2141
  return this._routerState.root;
@@ -2419,9 +2419,9 @@ class ChildrenOutletContexts {
2419
2419
  return this.contexts.get(childName) || null;
2420
2420
  }
2421
2421
  }
2422
- ChildrenOutletContexts.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: ChildrenOutletContexts, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2423
- ChildrenOutletContexts.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: ChildrenOutletContexts, providedIn: 'root' });
2424
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: ChildrenOutletContexts, decorators: [{
2422
+ ChildrenOutletContexts.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: ChildrenOutletContexts, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2423
+ ChildrenOutletContexts.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: ChildrenOutletContexts, providedIn: 'root' });
2424
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: ChildrenOutletContexts, decorators: [{
2425
2425
  type: Injectable,
2426
2426
  args: [{ providedIn: 'root' }]
2427
2427
  }] });
@@ -2642,9 +2642,9 @@ class RouterOutlet {
2642
2642
  this.activateEvents.emit(this.activated.instance);
2643
2643
  }
2644
2644
  }
2645
- RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterOutlet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2646
- RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.0", type: RouterOutlet, isStandalone: true, selector: "router-outlet", inputs: { name: "name" }, outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], usesOnChanges: true, ngImport: i0 });
2647
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterOutlet, decorators: [{
2645
+ RouterOutlet.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterOutlet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2646
+ RouterOutlet.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.2", type: RouterOutlet, isStandalone: true, selector: "router-outlet", inputs: { name: "name" }, outputs: { activateEvents: "activate", deactivateEvents: "deactivate", attachEvents: "attach", detachEvents: "detach" }, exportAs: ["outlet"], usesOnChanges: true, ngImport: i0 });
2647
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterOutlet, decorators: [{
2648
2648
  type: Directive,
2649
2649
  args: [{
2650
2650
  selector: 'router-outlet',
@@ -2704,9 +2704,9 @@ function isComponentFactoryResolver(item) {
2704
2704
  */
2705
2705
  class ɵEmptyOutletComponent {
2706
2706
  }
2707
- ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2708
- ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0-next.0", type: ɵEmptyOutletComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2709
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2707
+ ɵEmptyOutletComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: ɵEmptyOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2708
+ ɵEmptyOutletComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.0-next.2", type: ɵEmptyOutletComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: `<router-outlet></router-outlet>`, isInline: true, dependencies: [{ kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }] });
2709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: ɵEmptyOutletComponent, decorators: [{
2710
2710
  type: Component,
2711
2711
  args: [{
2712
2712
  template: `<router-outlet></router-outlet>`,
@@ -2759,7 +2759,7 @@ function validateConfig(config, parentPath = '', requireStandaloneComponents = f
2759
2759
  }
2760
2760
  }
2761
2761
  function assertStandalone(fullPath, component) {
2762
- if (component && isStandalone(component)) {
2762
+ if (component && !isStandalone(component)) {
2763
2763
  throw new ɵRuntimeError(4014 /* RuntimeErrorCode.INVALID_ROUTE_CONFIG */, `Invalid configuration of route '${fullPath}'. The component must be standalone.`);
2764
2764
  }
2765
2765
  }
@@ -4340,6 +4340,19 @@ function switchTap(next) {
4340
4340
  });
4341
4341
  }
4342
4342
 
4343
+ /**
4344
+ * @license
4345
+ * Copyright Google LLC All Rights Reserved.
4346
+ *
4347
+ * Use of this source code is governed by an MIT-style license that can be
4348
+ * found in the LICENSE file at https://angular.io/license
4349
+ */
4350
+ // This file exists to support the legacy `loadChildren: string` behavior being patched back into
4351
+ // Angular.
4352
+ function deprecatedLoadChildrenString(injector, loadChildren) {
4353
+ return null;
4354
+ }
4355
+
4343
4356
  /**
4344
4357
  * @license
4345
4358
  * Copyright Google LLC All Rights Reserved.
@@ -4348,16 +4361,188 @@ function switchTap(next) {
4348
4361
  * found in the LICENSE file at https://angular.io/license
4349
4362
  */
4350
4363
  const NG_DEV_MODE$5 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4364
+ /**
4365
+ * The [DI token](guide/glossary/#di-token) for a router configuration.
4366
+ *
4367
+ * `ROUTES` is a low level API for router configuration via dependency injection.
4368
+ *
4369
+ * We recommend that in almost all cases to use higher level APIs such as `RouterModule.forRoot()`,
4370
+ * `RouterModule.forChild()`, `provideRoutes`, or `Router.resetConfig()`.
4371
+ *
4372
+ * @publicApi
4373
+ */
4374
+ const ROUTES = new InjectionToken('ROUTES');
4375
+ class RouterConfigLoader {
4376
+ constructor(injector, compiler) {
4377
+ this.injector = injector;
4378
+ this.compiler = compiler;
4379
+ this.componentLoaders = new WeakMap();
4380
+ this.childrenLoaders = new WeakMap();
4381
+ }
4382
+ loadComponent(route) {
4383
+ if (this.componentLoaders.get(route)) {
4384
+ return this.componentLoaders.get(route);
4385
+ }
4386
+ else if (route._loadedComponent) {
4387
+ return of(route._loadedComponent);
4388
+ }
4389
+ if (this.onLoadStartListener) {
4390
+ this.onLoadStartListener(route);
4391
+ }
4392
+ const loadRunner = wrapIntoObservable(route.loadComponent())
4393
+ .pipe(map(maybeUnwrapDefaultExport), tap(component => {
4394
+ var _a;
4395
+ if (this.onLoadEndListener) {
4396
+ this.onLoadEndListener(route);
4397
+ }
4398
+ NG_DEV_MODE$5 && assertStandalone((_a = route.path) !== null && _a !== void 0 ? _a : '', component);
4399
+ route._loadedComponent = component;
4400
+ }), finalize(() => {
4401
+ this.componentLoaders.delete(route);
4402
+ }));
4403
+ // Use custom ConnectableObservable as share in runners pipe increasing the bundle size too much
4404
+ const loader = new ConnectableObservable(loadRunner, () => new Subject()).pipe(refCount());
4405
+ this.componentLoaders.set(route, loader);
4406
+ return loader;
4407
+ }
4408
+ loadChildren(parentInjector, route) {
4409
+ if (this.childrenLoaders.get(route)) {
4410
+ return this.childrenLoaders.get(route);
4411
+ }
4412
+ else if (route._loadedRoutes) {
4413
+ return of({ routes: route._loadedRoutes, injector: route._loadedInjector });
4414
+ }
4415
+ if (this.onLoadStartListener) {
4416
+ this.onLoadStartListener(route);
4417
+ }
4418
+ const moduleFactoryOrRoutes$ = this.loadModuleFactoryOrRoutes(route.loadChildren);
4419
+ const loadRunner = moduleFactoryOrRoutes$.pipe(map((factoryOrRoutes) => {
4420
+ if (this.onLoadEndListener) {
4421
+ this.onLoadEndListener(route);
4422
+ }
4423
+ // This injector comes from the `NgModuleRef` when lazy loading an `NgModule`. There is no
4424
+ // injector associated with lazy loading a `Route` array.
4425
+ let injector;
4426
+ let rawRoutes;
4427
+ let requireStandaloneComponents = false;
4428
+ if (Array.isArray(factoryOrRoutes)) {
4429
+ rawRoutes = factoryOrRoutes;
4430
+ requireStandaloneComponents = true;
4431
+ }
4432
+ else {
4433
+ injector = factoryOrRoutes.create(parentInjector).injector;
4434
+ // When loading a module that doesn't provide `RouterModule.forChild()` preloader
4435
+ // will get stuck in an infinite loop. The child module's Injector will look to
4436
+ // its parent `Injector` when it doesn't find any ROUTES so it will return routes
4437
+ // for it's parent module instead.
4438
+ rawRoutes = flatten(injector.get(ROUTES, [], InjectFlags.Self | InjectFlags.Optional));
4439
+ }
4440
+ const routes = rawRoutes.map(standardizeConfig);
4441
+ NG_DEV_MODE$5 && validateConfig(routes, route.path, requireStandaloneComponents);
4442
+ return { routes, injector };
4443
+ }), finalize(() => {
4444
+ this.childrenLoaders.delete(route);
4445
+ }));
4446
+ // Use custom ConnectableObservable as share in runners pipe increasing the bundle size too much
4447
+ const loader = new ConnectableObservable(loadRunner, () => new Subject())
4448
+ .pipe(refCount());
4449
+ this.childrenLoaders.set(route, loader);
4450
+ return loader;
4451
+ }
4452
+ loadModuleFactoryOrRoutes(loadChildren) {
4453
+ const deprecatedResult = deprecatedLoadChildrenString(this.injector, loadChildren);
4454
+ if (deprecatedResult) {
4455
+ return deprecatedResult;
4456
+ }
4457
+ return wrapIntoObservable(loadChildren())
4458
+ .pipe(map(maybeUnwrapDefaultExport), mergeMap((t) => {
4459
+ if (t instanceof NgModuleFactory || Array.isArray(t)) {
4460
+ return of(t);
4461
+ }
4462
+ else {
4463
+ return from(this.compiler.compileModuleAsync(t));
4464
+ }
4465
+ }));
4466
+ }
4467
+ }
4468
+ RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4469
+ RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterConfigLoader, providedIn: 'root' });
4470
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterConfigLoader, decorators: [{
4471
+ type: Injectable,
4472
+ args: [{ providedIn: 'root' }]
4473
+ }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }]; } });
4474
+ function isWrappedDefaultExport(value) {
4475
+ // We use `in` here with a string key `'default'`, because we expect `DefaultExport` objects to be
4476
+ // dynamically imported ES modules with a spec-mandated `default` key. Thus we don't expect that
4477
+ // `default` will be a renamed property.
4478
+ return value && typeof value === 'object' && 'default' in value;
4479
+ }
4480
+ function maybeUnwrapDefaultExport(input) {
4481
+ // As per `isWrappedDefaultExport`, the `default` key here is generated by the browser and not
4482
+ // subject to property renaming, so we reference it with bracket access.
4483
+ return isWrappedDefaultExport(input) ? input['default'] : input;
4484
+ }
4485
+
4486
+ /**
4487
+ * @license
4488
+ * Copyright Google LLC All Rights Reserved.
4489
+ *
4490
+ * Use of this source code is governed by an MIT-style license that can be
4491
+ * found in the LICENSE file at https://angular.io/license
4492
+ */
4493
+ const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4351
4494
  class NavigationTransitions {
4352
- constructor(router) {
4353
- this.router = router;
4495
+ get hasRequestedNavigation() {
4496
+ return this.navigationId !== 0;
4497
+ }
4498
+ constructor() {
4354
4499
  this.currentNavigation = null;
4500
+ this.lastSuccessfulNavigation = null;
4501
+ this.events = new Subject();
4502
+ this.configLoader = inject(RouterConfigLoader);
4503
+ this.environmentInjector = inject(EnvironmentInjector);
4504
+ this.urlSerializer = inject(UrlSerializer);
4505
+ this.rootContexts = inject(ChildrenOutletContexts);
4506
+ this.navigationId = 0;
4507
+ const onLoadStart = (r) => this.events.next(new RouteConfigLoadStart(r));
4508
+ const onLoadEnd = (r) => this.events.next(new RouteConfigLoadEnd(r));
4509
+ this.configLoader.onLoadEndListener = onLoadEnd;
4510
+ this.configLoader.onLoadStartListener = onLoadStart;
4511
+ }
4512
+ complete() {
4513
+ var _a;
4514
+ (_a = this.transitions) === null || _a === void 0 ? void 0 : _a.complete();
4355
4515
  }
4356
- setupNavigations(transitions) {
4357
- const eventsSubject = this.router.events;
4358
- return transitions.pipe(filter(t => t.id !== 0),
4516
+ handleNavigationRequest(request) {
4517
+ var _a;
4518
+ const id = ++this.navigationId;
4519
+ (_a = this.transitions) === null || _a === void 0 ? void 0 : _a.next(Object.assign(Object.assign(Object.assign({}, this.transitions.value), request), { id }));
4520
+ }
4521
+ setupNavigations(router) {
4522
+ this.transitions = new BehaviorSubject({
4523
+ id: 0,
4524
+ targetPageId: 0,
4525
+ currentUrlTree: router.currentUrlTree,
4526
+ currentRawUrl: router.currentUrlTree,
4527
+ extractedUrl: router.urlHandlingStrategy.extract(router.currentUrlTree),
4528
+ urlAfterRedirects: router.urlHandlingStrategy.extract(router.currentUrlTree),
4529
+ rawUrl: router.currentUrlTree,
4530
+ extras: {},
4531
+ resolve: null,
4532
+ reject: null,
4533
+ promise: Promise.resolve(true),
4534
+ source: 'imperative',
4535
+ restoredState: null,
4536
+ currentSnapshot: router.routerState.snapshot,
4537
+ targetSnapshot: null,
4538
+ currentRouterState: router.routerState,
4539
+ targetRouterState: null,
4540
+ guards: { canActivateChecks: [], canDeactivateChecks: [] },
4541
+ guardsResult: null,
4542
+ });
4543
+ return this.transitions.pipe(filter(t => t.id !== 0),
4359
4544
  // Extract URL
4360
- map(t => (Object.assign(Object.assign({}, t), { extractedUrl: this.router.urlHandlingStrategy.extract(t.rawUrl) }))),
4545
+ map(t => (Object.assign(Object.assign({}, t), { extractedUrl: router.urlHandlingStrategy.extract(t.rawUrl) }))),
4361
4546
  // Using switchMap so we cancel executing navigations when a new one comes in
4362
4547
  switchMap(overallTransitionState => {
4363
4548
  let completed = false;
@@ -4372,38 +4557,41 @@ class NavigationTransitions {
4372
4557
  extractedUrl: t.extractedUrl,
4373
4558
  trigger: t.source,
4374
4559
  extras: t.extras,
4375
- previousNavigation: !this.router.lastSuccessfulNavigation ? null : Object.assign(Object.assign({}, this.router.lastSuccessfulNavigation), { previousNavigation: null }),
4560
+ previousNavigation: !this.lastSuccessfulNavigation ? null : Object.assign(Object.assign({}, this.lastSuccessfulNavigation), { previousNavigation: null }),
4376
4561
  };
4377
4562
  }), switchMap(t => {
4378
- const browserUrlTree = this.router.browserUrlTree.toString();
4379
- const urlTransition = !this.router.navigated ||
4563
+ var _a;
4564
+ const browserUrlTree = router.browserUrlTree.toString();
4565
+ const urlTransition = !router.navigated ||
4380
4566
  t.extractedUrl.toString() !== browserUrlTree ||
4381
4567
  // Navigations which succeed or ones which fail and are cleaned up
4382
4568
  // correctly should result in `browserUrlTree` and `currentUrlTree`
4383
4569
  // matching. If this is not the case, assume something went wrong and
4384
4570
  // try processing the URL again.
4385
- browserUrlTree !== this.router.currentUrlTree.toString();
4386
- if (!urlTransition && this.router.onSameUrlNavigation !== 'reload') {
4387
- const reason = NG_DEV_MODE$5 ?
4571
+ browserUrlTree !== router.currentUrlTree.toString();
4572
+ const onSameUrlNavigation = (_a = t.extras.onSameUrlNavigation) !== null && _a !== void 0 ? _a : router.onSameUrlNavigation;
4573
+ if (!urlTransition && onSameUrlNavigation !== 'reload') {
4574
+ const reason = NG_DEV_MODE$4 ?
4388
4575
  `Navigation to ${t.rawUrl} was ignored because it is the same as the current Router URL.` :
4389
4576
  '';
4390
- this.router.triggerEvent(new NavigationSkipped(t.id, this.router.serializeUrl(overallTransitionState.rawUrl), reason, 0 /* NavigationSkippedCode.IgnoredSameUrlNavigation */));
4391
- this.router.rawUrlTree = t.rawUrl;
4577
+ this.events.next(new NavigationSkipped(t.id, router.serializeUrl(overallTransitionState.rawUrl), reason, 0 /* NavigationSkippedCode.IgnoredSameUrlNavigation */));
4578
+ router.rawUrlTree = t.rawUrl;
4392
4579
  t.resolve(null);
4393
4580
  return EMPTY;
4394
4581
  }
4395
- if (this.router.urlHandlingStrategy.shouldProcessUrl(t.rawUrl)) {
4582
+ if (router.urlHandlingStrategy.shouldProcessUrl(t.rawUrl)) {
4396
4583
  // If the source of the navigation is from a browser event, the URL is
4397
4584
  // already updated. We already need to sync the internal state.
4398
4585
  if (isBrowserTriggeredNavigation(t.source)) {
4399
- this.router.browserUrlTree = t.extractedUrl;
4586
+ router.browserUrlTree = t.extractedUrl;
4400
4587
  }
4401
4588
  return of(t).pipe(
4402
4589
  // Fire NavigationStart event
4403
4590
  switchMap(t => {
4404
- const transition = this.router.transitions.getValue();
4405
- eventsSubject.next(new NavigationStart(t.id, this.router.serializeUrl(t.extractedUrl), t.source, t.restoredState));
4406
- if (transition !== this.router.transitions.getValue()) {
4591
+ var _a, _b;
4592
+ const transition = (_a = this.transitions) === null || _a === void 0 ? void 0 : _a.getValue();
4593
+ this.events.next(new NavigationStart(t.id, this.urlSerializer.serialize(t.extractedUrl), t.source, t.restoredState));
4594
+ if (transition !== ((_b = this.transitions) === null || _b === void 0 ? void 0 : _b.getValue())) {
4407
4595
  return EMPTY;
4408
4596
  }
4409
4597
  // This delay is required to match old behavior that forced
@@ -4411,7 +4599,7 @@ class NavigationTransitions {
4411
4599
  return Promise.resolve(t);
4412
4600
  }),
4413
4601
  // ApplyRedirects
4414
- applyRedirects(this.router.ngModule.injector, this.router.configLoader, this.router.urlSerializer, this.router.config),
4602
+ applyRedirects(this.environmentInjector, this.configLoader, this.urlSerializer, router.config),
4415
4603
  // Update the currentNavigation
4416
4604
  // `urlAfterRedirects` is guaranteed to be set after this point
4417
4605
  tap(t => {
@@ -4419,32 +4607,31 @@ class NavigationTransitions {
4419
4607
  overallTransitionState.urlAfterRedirects = t.urlAfterRedirects;
4420
4608
  }),
4421
4609
  // Recognize
4422
- recognize(this.router.ngModule.injector, this.router.rootComponentType, this.router.config, this.router.urlSerializer, this.router.paramsInheritanceStrategy),
4610
+ recognize(this.environmentInjector, router.rootComponentType, router.config, this.urlSerializer, router.paramsInheritanceStrategy),
4423
4611
  // Update URL if in `eager` update mode
4424
4612
  tap(t => {
4425
4613
  overallTransitionState.targetSnapshot = t.targetSnapshot;
4426
- if (this.router.urlUpdateStrategy === 'eager') {
4614
+ if (router.urlUpdateStrategy === 'eager') {
4427
4615
  if (!t.extras.skipLocationChange) {
4428
- const rawUrl = this.router.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
4429
- this.router.setBrowserUrl(rawUrl, t);
4616
+ const rawUrl = router.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
4617
+ router.setBrowserUrl(rawUrl, t);
4430
4618
  }
4431
- this.router.browserUrlTree = t.urlAfterRedirects;
4619
+ router.browserUrlTree = t.urlAfterRedirects;
4432
4620
  }
4433
4621
  // Fire RoutesRecognized
4434
- const routesRecognized = new RoutesRecognized(t.id, this.router.serializeUrl(t.extractedUrl), this.router.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4435
- eventsSubject.next(routesRecognized);
4622
+ const routesRecognized = new RoutesRecognized(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4623
+ this.events.next(routesRecognized);
4436
4624
  }));
4437
4625
  }
4438
4626
  else if (urlTransition &&
4439
- this.router.urlHandlingStrategy.shouldProcessUrl(this.router.rawUrlTree)) {
4440
- // When the current URL shouldn't be processed, but the previous one
4441
- // was, we handle this by navigating from the current URL to an empty
4442
- // state so deactivate guards can run.
4627
+ router.urlHandlingStrategy.shouldProcessUrl(router.rawUrlTree)) {
4628
+ /* When the current URL shouldn't be processed, but the previous one
4629
+ * was, we handle this "error condition" by navigating to the
4630
+ * previously successful URL, but leaving the URL intact.*/
4443
4631
  const { id, extractedUrl, source, restoredState, extras } = t;
4444
- const navStart = new NavigationStart(id, this.router.serializeUrl(extractedUrl), source, restoredState);
4445
- eventsSubject.next(navStart);
4446
- const targetSnapshot = createEmptyState(extractedUrl, this.router.rootComponentType)
4447
- .snapshot;
4632
+ const navStart = new NavigationStart(id, this.urlSerializer.serialize(extractedUrl), source, restoredState);
4633
+ this.events.next(navStart);
4634
+ const targetSnapshot = createEmptyState(extractedUrl, router.rootComponentType).snapshot;
4448
4635
  overallTransitionState = Object.assign(Object.assign({}, t), { targetSnapshot, urlAfterRedirects: extractedUrl, extras: Object.assign(Object.assign({}, extras), { skipLocationChange: false, replaceUrl: false }) });
4449
4636
  return of(overallTransitionState);
4450
4637
  }
@@ -4454,34 +4641,34 @@ class NavigationTransitions {
4454
4641
  * current "settled" URL. This way the next navigation will be coming
4455
4642
  * from the current URL in the browser.
4456
4643
  */
4457
- const reason = NG_DEV_MODE$5 ?
4644
+ const reason = NG_DEV_MODE$4 ?
4458
4645
  `Navigation was ignored because the UrlHandlingStrategy` +
4459
- ` indicated neither the current URL ${this.router.rawUrlTree} nor target URL ${t.rawUrl} should be processed.` :
4646
+ ` indicated neither the current URL ${router.rawUrlTree} nor target URL ${t.rawUrl} should be processed.` :
4460
4647
  '';
4461
- this.router.triggerEvent(new NavigationSkipped(t.id, this.router.serializeUrl(overallTransitionState.extractedUrl), reason, 1 /* NavigationSkippedCode.IgnoredByUrlHandlingStrategy */));
4462
- this.router.rawUrlTree = t.rawUrl;
4648
+ this.events.next(new NavigationSkipped(t.id, router.serializeUrl(overallTransitionState.extractedUrl), reason, 1 /* NavigationSkippedCode.IgnoredByUrlHandlingStrategy */));
4649
+ router.rawUrlTree = t.rawUrl;
4463
4650
  t.resolve(null);
4464
4651
  return EMPTY;
4465
4652
  }
4466
4653
  }),
4467
4654
  // --- GUARDS ---
4468
4655
  tap(t => {
4469
- const guardsStart = new GuardsCheckStart(t.id, this.router.serializeUrl(t.extractedUrl), this.router.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4470
- this.router.triggerEvent(guardsStart);
4656
+ const guardsStart = new GuardsCheckStart(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4657
+ this.events.next(guardsStart);
4471
4658
  }), map(t => {
4472
- overallTransitionState = Object.assign(Object.assign({}, t), { guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.router.rootContexts) });
4659
+ overallTransitionState = Object.assign(Object.assign({}, t), { guards: getAllRouteGuards(t.targetSnapshot, t.currentSnapshot, this.rootContexts) });
4473
4660
  return overallTransitionState;
4474
- }), checkGuards(this.router.ngModule.injector, (evt) => this.router.triggerEvent(evt)), tap(t => {
4661
+ }), checkGuards(this.environmentInjector, (evt) => this.events.next(evt)), tap(t => {
4475
4662
  overallTransitionState.guardsResult = t.guardsResult;
4476
4663
  if (isUrlTree(t.guardsResult)) {
4477
- throw redirectingNavigationError(this.router.urlSerializer, t.guardsResult);
4664
+ throw redirectingNavigationError(this.urlSerializer, t.guardsResult);
4478
4665
  }
4479
- const guardsEnd = new GuardsCheckEnd(t.id, this.router.serializeUrl(t.extractedUrl), this.router.serializeUrl(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
4480
- this.router.triggerEvent(guardsEnd);
4666
+ const guardsEnd = new GuardsCheckEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot, !!t.guardsResult);
4667
+ this.events.next(guardsEnd);
4481
4668
  }), filter(t => {
4482
4669
  if (!t.guardsResult) {
4483
- this.router.restoreHistory(t);
4484
- this.router.cancelNavigationTransition(t, '', 3 /* NavigationCancellationCode.GuardRejected */);
4670
+ router.restoreHistory(t);
4671
+ this.cancelNavigationTransition(t, '', 3 /* NavigationCancellationCode.GuardRejected */, router);
4485
4672
  return false;
4486
4673
  }
4487
4674
  return true;
@@ -4490,24 +4677,24 @@ class NavigationTransitions {
4490
4677
  switchTap(t => {
4491
4678
  if (t.guards.canActivateChecks.length) {
4492
4679
  return of(t).pipe(tap(t => {
4493
- const resolveStart = new ResolveStart(t.id, this.router.serializeUrl(t.extractedUrl), this.router.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4494
- this.router.triggerEvent(resolveStart);
4680
+ const resolveStart = new ResolveStart(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4681
+ this.events.next(resolveStart);
4495
4682
  }), switchMap(t => {
4496
4683
  let dataResolved = false;
4497
- return of(t).pipe(resolveData(this.router.paramsInheritanceStrategy, this.router.ngModule.injector), tap({
4684
+ return of(t).pipe(resolveData(router.paramsInheritanceStrategy, this.environmentInjector), tap({
4498
4685
  next: () => dataResolved = true,
4499
4686
  complete: () => {
4500
4687
  if (!dataResolved) {
4501
- this.router.restoreHistory(t);
4502
- this.router.cancelNavigationTransition(t, NG_DEV_MODE$5 ?
4688
+ router.restoreHistory(t);
4689
+ this.cancelNavigationTransition(t, NG_DEV_MODE$4 ?
4503
4690
  `At least one route resolver didn't emit any value.` :
4504
- '', 2 /* NavigationCancellationCode.NoDataFromResolver */);
4691
+ '', 2 /* NavigationCancellationCode.NoDataFromResolver */, router);
4505
4692
  }
4506
4693
  }
4507
4694
  }));
4508
4695
  }), tap(t => {
4509
- const resolveEnd = new ResolveEnd(t.id, this.router.serializeUrl(t.extractedUrl), this.router.serializeUrl(t.urlAfterRedirects), t.targetSnapshot);
4510
- this.router.triggerEvent(resolveEnd);
4696
+ const resolveEnd = new ResolveEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(t.urlAfterRedirects), t.targetSnapshot);
4697
+ this.events.next(resolveEnd);
4511
4698
  }));
4512
4699
  }
4513
4700
  return undefined;
@@ -4519,7 +4706,7 @@ class NavigationTransitions {
4519
4706
  const loaders = [];
4520
4707
  if (((_a = route.routeConfig) === null || _a === void 0 ? void 0 : _a.loadComponent) &&
4521
4708
  !route.routeConfig._loadedComponent) {
4522
- loaders.push(this.router.configLoader.loadComponent(route.routeConfig)
4709
+ loaders.push(this.configLoader.loadComponent(route.routeConfig)
4523
4710
  .pipe(tap(loadedComponent => {
4524
4711
  route.component = loadedComponent;
4525
4712
  }), map(() => void 0)));
@@ -4531,8 +4718,8 @@ class NavigationTransitions {
4531
4718
  };
4532
4719
  return combineLatest(loadComponents(t.targetSnapshot.root))
4533
4720
  .pipe(defaultIfEmpty(), take(1));
4534
- }), switchTap(() => this.router.afterPreactivation()), map((t) => {
4535
- const targetRouterState = createRouterState(this.router.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4721
+ }), switchTap(() => router.afterPreactivation()), map((t) => {
4722
+ const targetRouterState = createRouterState(router.routeReuseStrategy, t.targetSnapshot, t.currentRouterState);
4536
4723
  overallTransitionState = Object.assign(Object.assign({}, t), { targetRouterState });
4537
4724
  return (overallTransitionState);
4538
4725
  }),
@@ -4542,21 +4729,28 @@ class NavigationTransitions {
4542
4729
  the current URL and the RouterState, as well as updated the browser URL.
4543
4730
  All this should happen *before* activating. */
4544
4731
  tap((t) => {
4545
- this.router.currentUrlTree = t.urlAfterRedirects;
4546
- this.router.rawUrlTree = this.router.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
4547
- this.router.routerState =
4732
+ router.currentUrlTree = t.urlAfterRedirects;
4733
+ router.rawUrlTree =
4734
+ router.urlHandlingStrategy.merge(t.urlAfterRedirects, t.rawUrl);
4735
+ router.routerState =
4548
4736
  t.targetRouterState;
4549
- if (this.router.urlUpdateStrategy === 'deferred') {
4737
+ if (router.urlUpdateStrategy === 'deferred') {
4550
4738
  if (!t.extras.skipLocationChange) {
4551
- this.router.setBrowserUrl(this.router.rawUrlTree, t);
4739
+ router.setBrowserUrl(router.rawUrlTree, t);
4552
4740
  }
4553
- this.router.browserUrlTree = t.urlAfterRedirects;
4741
+ router.browserUrlTree = t.urlAfterRedirects;
4554
4742
  }
4555
- }), activateRoutes(this.router.rootContexts, this.router.routeReuseStrategy, (evt) => this.router.triggerEvent(evt)), tap({
4556
- next() {
4743
+ }), activateRoutes(this.rootContexts, router.routeReuseStrategy, (evt) => this.events.next(evt)), tap({
4744
+ next: (t) => {
4745
+ var _a;
4557
4746
  completed = true;
4747
+ this.lastSuccessfulNavigation = this.currentNavigation;
4748
+ router.navigated = true;
4749
+ this.events.next(new NavigationEnd(t.id, this.urlSerializer.serialize(t.extractedUrl), this.urlSerializer.serialize(router.currentUrlTree)));
4750
+ (_a = router.titleStrategy) === null || _a === void 0 ? void 0 : _a.updateTitle(t.targetRouterState.snapshot);
4751
+ t.resolve(true);
4558
4752
  },
4559
- complete() {
4753
+ complete: () => {
4560
4754
  completed = true;
4561
4755
  }
4562
4756
  }), finalize(() => {
@@ -4568,11 +4762,11 @@ class NavigationTransitions {
4568
4762
  * catch-all to make sure the NavigationCancel event is fired when a
4569
4763
  * navigation gets cancelled but not caught by other means. */
4570
4764
  if (!completed && !errored) {
4571
- const cancelationReason = NG_DEV_MODE$5 ?
4765
+ const cancelationReason = NG_DEV_MODE$4 ?
4572
4766
  `Navigation ID ${overallTransitionState
4573
- .id} is not equal to the current navigation id ${this.router.navigationId}` :
4767
+ .id} is not equal to the current navigation id ${this.navigationId}` :
4574
4768
  '';
4575
- this.router.cancelNavigationTransition(overallTransitionState, cancelationReason, 1 /* NavigationCancellationCode.SupersededByNewNavigation */);
4769
+ this.cancelNavigationTransition(overallTransitionState, cancelationReason, 1 /* NavigationCancellationCode.SupersededByNewNavigation */, router);
4576
4770
  }
4577
4771
  // Only clear current navigation if it is still set to the one that
4578
4772
  // finalized.
@@ -4592,28 +4786,28 @@ class NavigationTransitions {
4592
4786
  // navigate. This is only applicable with initial navigation, so
4593
4787
  // setting `navigated` only when not redirecting resolves this
4594
4788
  // scenario.
4595
- this.router.navigated = true;
4596
- this.router.restoreHistory(overallTransitionState, true);
4789
+ router.navigated = true;
4790
+ router.restoreHistory(overallTransitionState, true);
4597
4791
  }
4598
- const navCancel = new NavigationCancel(overallTransitionState.id, this.router.serializeUrl(overallTransitionState.extractedUrl), e.message, e.cancellationCode);
4599
- eventsSubject.next(navCancel);
4792
+ const navCancel = new NavigationCancel(overallTransitionState.id, this.urlSerializer.serialize(overallTransitionState.extractedUrl), e.message, e.cancellationCode);
4793
+ this.events.next(navCancel);
4600
4794
  // When redirecting, we need to delay resolving the navigation
4601
4795
  // promise and push it to the redirect navigation
4602
4796
  if (!isRedirectingNavigationCancelingError$1(e)) {
4603
4797
  overallTransitionState.resolve(false);
4604
4798
  }
4605
4799
  else {
4606
- const mergedTree = this.router.urlHandlingStrategy.merge(e.url, this.router.rawUrlTree);
4800
+ const mergedTree = router.urlHandlingStrategy.merge(e.url, router.rawUrlTree);
4607
4801
  const extras = {
4608
4802
  skipLocationChange: overallTransitionState.extras.skipLocationChange,
4609
4803
  // The URL is already updated at this point if we have 'eager' URL
4610
4804
  // updates or if the navigation was triggered by the browser (back
4611
4805
  // button, URL bar, etc). We want to replace that item in history
4612
4806
  // if the navigation is rejected.
4613
- replaceUrl: this.router.urlUpdateStrategy === 'eager' ||
4807
+ replaceUrl: router.urlUpdateStrategy === 'eager' ||
4614
4808
  isBrowserTriggeredNavigation(overallTransitionState.source)
4615
4809
  };
4616
- this.router.scheduleNavigation(mergedTree, 'imperative', null, extras, {
4810
+ router.scheduleNavigation(mergedTree, 'imperative', null, extras, {
4617
4811
  resolve: overallTransitionState.resolve,
4618
4812
  reject: overallTransitionState.reject,
4619
4813
  promise: overallTransitionState.promise
@@ -4623,11 +4817,11 @@ class NavigationTransitions {
4623
4817
  * to the pre-error state. */
4624
4818
  }
4625
4819
  else {
4626
- this.router.restoreHistory(overallTransitionState, true);
4627
- const navError = new NavigationError(overallTransitionState.id, this.router.serializeUrl(overallTransitionState.extractedUrl), e, (_a = overallTransitionState.targetSnapshot) !== null && _a !== void 0 ? _a : undefined);
4628
- eventsSubject.next(navError);
4820
+ router.restoreHistory(overallTransitionState, true);
4821
+ const navError = new NavigationError(overallTransitionState.id, this.urlSerializer.serialize(overallTransitionState.extractedUrl), e, (_a = overallTransitionState.targetSnapshot) !== null && _a !== void 0 ? _a : undefined);
4822
+ this.events.next(navError);
4629
4823
  try {
4630
- overallTransitionState.resolve(this.router.errorHandler(e));
4824
+ overallTransitionState.resolve(router.errorHandler(e));
4631
4825
  }
4632
4826
  catch (ee) {
4633
4827
  overallTransitionState.reject(ee);
@@ -4638,7 +4832,18 @@ class NavigationTransitions {
4638
4832
  // TODO(jasonaden): remove cast once g3 is on updated TypeScript
4639
4833
  }));
4640
4834
  }
4835
+ cancelNavigationTransition(t, reason, code, router) {
4836
+ const navCancel = new NavigationCancel(t.id, this.urlSerializer.serialize(t.extractedUrl), reason, code);
4837
+ this.events.next(navCancel);
4838
+ t.resolve(false);
4839
+ }
4641
4840
  }
4841
+ NavigationTransitions.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NavigationTransitions, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4842
+ NavigationTransitions.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NavigationTransitions, providedIn: 'root' });
4843
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NavigationTransitions, decorators: [{
4844
+ type: Injectable,
4845
+ args: [{ providedIn: 'root' }]
4846
+ }], ctorParameters: function () { return []; } });
4642
4847
  function isBrowserTriggeredNavigation(source) {
4643
4848
  return source !== 'imperative';
4644
4849
  }
@@ -4695,9 +4900,9 @@ class TitleStrategy {
4695
4900
  return snapshot.data[RouteTitleKey];
4696
4901
  }
4697
4902
  }
4698
- TitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: TitleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4699
- TitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: TitleStrategy, providedIn: 'root', useFactory: () => inject(DefaultTitleStrategy) });
4700
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: TitleStrategy, decorators: [{
4903
+ TitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: TitleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4904
+ TitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: TitleStrategy, providedIn: 'root', useFactory: () => inject(DefaultTitleStrategy) });
4905
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: TitleStrategy, decorators: [{
4701
4906
  type: Injectable,
4702
4907
  args: [{ providedIn: 'root', useFactory: () => inject(DefaultTitleStrategy) }]
4703
4908
  }] });
@@ -4721,9 +4926,9 @@ class DefaultTitleStrategy extends TitleStrategy {
4721
4926
  }
4722
4927
  }
4723
4928
  }
4724
- DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
4725
- DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
4726
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
4929
+ DefaultTitleStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultTitleStrategy, deps: [{ token: i1.Title }], target: i0.ɵɵFactoryTarget.Injectable });
4930
+ DefaultTitleStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultTitleStrategy, providedIn: 'root' });
4931
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultTitleStrategy, decorators: [{
4727
4932
  type: Injectable,
4728
4933
  args: [{ providedIn: 'root' }]
4729
4934
  }], ctorParameters: function () { return [{ type: i1.Title }]; } });
@@ -4744,9 +4949,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0",
4744
4949
  */
4745
4950
  class RouteReuseStrategy {
4746
4951
  }
4747
- RouteReuseStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouteReuseStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4748
- RouteReuseStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouteReuseStrategy, providedIn: 'root', useFactory: () => inject(DefaultRouteReuseStrategy) });
4749
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouteReuseStrategy, decorators: [{
4952
+ RouteReuseStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouteReuseStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4953
+ RouteReuseStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouteReuseStrategy, providedIn: 'root', useFactory: () => inject(DefaultRouteReuseStrategy) });
4954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouteReuseStrategy, decorators: [{
4750
4955
  type: Injectable,
4751
4956
  args: [{ providedIn: 'root', useFactory: () => inject(DefaultRouteReuseStrategy) }]
4752
4957
  }] });
@@ -4798,9 +5003,9 @@ class BaseRouteReuseStrategy {
4798
5003
  }
4799
5004
  class DefaultRouteReuseStrategy extends BaseRouteReuseStrategy {
4800
5005
  }
4801
- DefaultRouteReuseStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultRouteReuseStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
4802
- DefaultRouteReuseStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultRouteReuseStrategy, providedIn: 'root' });
4803
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultRouteReuseStrategy, decorators: [{
5006
+ DefaultRouteReuseStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultRouteReuseStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
5007
+ DefaultRouteReuseStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultRouteReuseStrategy, providedIn: 'root' });
5008
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultRouteReuseStrategy, decorators: [{
4804
5009
  type: Injectable,
4805
5010
  args: [{ providedIn: 'root' }]
4806
5011
  }] });
@@ -4812,158 +5017,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0",
4812
5017
  * Use of this source code is governed by an MIT-style license that can be
4813
5018
  * found in the LICENSE file at https://angular.io/license
4814
5019
  */
4815
- const NG_DEV_MODE$4 = typeof ngDevMode === 'undefined' || !!ngDevMode;
5020
+ const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4816
5021
  /**
4817
5022
  * A [DI token](guide/glossary/#di-token) for the router service.
4818
5023
  *
4819
5024
  * @publicApi
4820
5025
  */
4821
- const ROUTER_CONFIGURATION = new InjectionToken(NG_DEV_MODE$4 ? 'router config' : '', {
5026
+ const ROUTER_CONFIGURATION = new InjectionToken(NG_DEV_MODE$3 ? 'router config' : '', {
4822
5027
  providedIn: 'root',
4823
5028
  factory: () => ({}),
4824
5029
  });
4825
5030
 
4826
- /**
4827
- * @license
4828
- * Copyright Google LLC All Rights Reserved.
4829
- *
4830
- * Use of this source code is governed by an MIT-style license that can be
4831
- * found in the LICENSE file at https://angular.io/license
4832
- */
4833
- function deprecatedLoadChildrenString(injector, loadChildren) {
4834
- return null;
4835
- }
4836
-
4837
- /**
4838
- * @license
4839
- * Copyright Google LLC All Rights Reserved.
4840
- *
4841
- * Use of this source code is governed by an MIT-style license that can be
4842
- * found in the LICENSE file at https://angular.io/license
4843
- */
4844
- const NG_DEV_MODE$3 = typeof ngDevMode === 'undefined' || !!ngDevMode;
4845
- /**
4846
- * The [DI token](guide/glossary/#di-token) for a router configuration.
4847
- *
4848
- * `ROUTES` is a low level API for router configuration via dependency injection.
4849
- *
4850
- * We recommend that in almost all cases to use higher level APIs such as `RouterModule.forRoot()`,
4851
- * `RouterModule.forChild()`, `provideRoutes`, or `Router.resetConfig()`.
4852
- *
4853
- * @publicApi
4854
- */
4855
- const ROUTES = new InjectionToken('ROUTES');
4856
- class RouterConfigLoader {
4857
- constructor(injector, compiler) {
4858
- this.injector = injector;
4859
- this.compiler = compiler;
4860
- this.componentLoaders = new WeakMap();
4861
- this.childrenLoaders = new WeakMap();
4862
- }
4863
- loadComponent(route) {
4864
- if (this.componentLoaders.get(route)) {
4865
- return this.componentLoaders.get(route);
4866
- }
4867
- else if (route._loadedComponent) {
4868
- return of(route._loadedComponent);
4869
- }
4870
- if (this.onLoadStartListener) {
4871
- this.onLoadStartListener(route);
4872
- }
4873
- const loadRunner = wrapIntoObservable(route.loadComponent())
4874
- .pipe(map(maybeUnwrapDefaultExport), tap(component => {
4875
- var _a;
4876
- if (this.onLoadEndListener) {
4877
- this.onLoadEndListener(route);
4878
- }
4879
- NG_DEV_MODE$3 && assertStandalone((_a = route.path) !== null && _a !== void 0 ? _a : '', component);
4880
- route._loadedComponent = component;
4881
- }), finalize(() => {
4882
- this.componentLoaders.delete(route);
4883
- }));
4884
- // Use custom ConnectableObservable as share in runners pipe increasing the bundle size too much
4885
- const loader = new ConnectableObservable(loadRunner, () => new Subject()).pipe(refCount());
4886
- this.componentLoaders.set(route, loader);
4887
- return loader;
4888
- }
4889
- loadChildren(parentInjector, route) {
4890
- if (this.childrenLoaders.get(route)) {
4891
- return this.childrenLoaders.get(route);
4892
- }
4893
- else if (route._loadedRoutes) {
4894
- return of({ routes: route._loadedRoutes, injector: route._loadedInjector });
4895
- }
4896
- if (this.onLoadStartListener) {
4897
- this.onLoadStartListener(route);
4898
- }
4899
- const moduleFactoryOrRoutes$ = this.loadModuleFactoryOrRoutes(route.loadChildren);
4900
- const loadRunner = moduleFactoryOrRoutes$.pipe(map((factoryOrRoutes) => {
4901
- if (this.onLoadEndListener) {
4902
- this.onLoadEndListener(route);
4903
- }
4904
- // This injector comes from the `NgModuleRef` when lazy loading an `NgModule`. There is no
4905
- // injector associated with lazy loading a `Route` array.
4906
- let injector;
4907
- let rawRoutes;
4908
- let requireStandaloneComponents = false;
4909
- if (Array.isArray(factoryOrRoutes)) {
4910
- rawRoutes = factoryOrRoutes;
4911
- requireStandaloneComponents = true;
4912
- }
4913
- else {
4914
- injector = factoryOrRoutes.create(parentInjector).injector;
4915
- // When loading a module that doesn't provide `RouterModule.forChild()` preloader
4916
- // will get stuck in an infinite loop. The child module's Injector will look to
4917
- // its parent `Injector` when it doesn't find any ROUTES so it will return routes
4918
- // for it's parent module instead.
4919
- rawRoutes = flatten(injector.get(ROUTES, [], InjectFlags.Self | InjectFlags.Optional));
4920
- }
4921
- const routes = rawRoutes.map(standardizeConfig);
4922
- NG_DEV_MODE$3 && validateConfig(routes, route.path, requireStandaloneComponents);
4923
- return { routes, injector };
4924
- }), finalize(() => {
4925
- this.childrenLoaders.delete(route);
4926
- }));
4927
- // Use custom ConnectableObservable as share in runners pipe increasing the bundle size too much
4928
- const loader = new ConnectableObservable(loadRunner, () => new Subject())
4929
- .pipe(refCount());
4930
- this.childrenLoaders.set(route, loader);
4931
- return loader;
4932
- }
4933
- loadModuleFactoryOrRoutes(loadChildren) {
4934
- const deprecatedResult = deprecatedLoadChildrenString(this.injector, loadChildren);
4935
- if (deprecatedResult) {
4936
- return deprecatedResult;
4937
- }
4938
- return wrapIntoObservable(loadChildren())
4939
- .pipe(map(maybeUnwrapDefaultExport), mergeMap((t) => {
4940
- if (t instanceof NgModuleFactory || Array.isArray(t)) {
4941
- return of(t);
4942
- }
4943
- else {
4944
- return from(this.compiler.compileModuleAsync(t));
4945
- }
4946
- }));
4947
- }
4948
- }
4949
- RouterConfigLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterConfigLoader, deps: [{ token: i0.Injector }, { token: i0.Compiler }], target: i0.ɵɵFactoryTarget.Injectable });
4950
- RouterConfigLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterConfigLoader, providedIn: 'root' });
4951
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterConfigLoader, decorators: [{
4952
- type: Injectable,
4953
- args: [{ providedIn: 'root' }]
4954
- }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.Compiler }]; } });
4955
- function isWrappedDefaultExport(value) {
4956
- // We use `in` here with a string key `'default'`, because we expect `DefaultExport` objects to be
4957
- // dynamically imported ES modules with a spec-mandated `default` key. Thus we don't expect that
4958
- // `default` will be a renamed property.
4959
- return value && typeof value === 'object' && 'default' in value;
4960
- }
4961
- function maybeUnwrapDefaultExport(input) {
4962
- // As per `isWrappedDefaultExport`, the `default` key here is generated by the browser and not
4963
- // subject to property renaming, so we reference it with bracket access.
4964
- return isWrappedDefaultExport(input) ? input['default'] : input;
4965
- }
4966
-
4967
5031
  /**
4968
5032
  * @license
4969
5033
  * Copyright Google LLC All Rights Reserved.
@@ -4980,9 +5044,9 @@ function maybeUnwrapDefaultExport(input) {
4980
5044
  */
4981
5045
  class UrlHandlingStrategy {
4982
5046
  }
4983
- UrlHandlingStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlHandlingStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4984
- UrlHandlingStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlHandlingStrategy, providedIn: 'root', useFactory: () => inject(DefaultUrlHandlingStrategy) });
4985
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: UrlHandlingStrategy, decorators: [{
5047
+ UrlHandlingStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlHandlingStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5048
+ UrlHandlingStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlHandlingStrategy, providedIn: 'root', useFactory: () => inject(DefaultUrlHandlingStrategy) });
5049
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: UrlHandlingStrategy, decorators: [{
4986
5050
  type: Injectable,
4987
5051
  args: [{ providedIn: 'root', useFactory: () => inject(DefaultUrlHandlingStrategy) }]
4988
5052
  }] });
@@ -5000,9 +5064,9 @@ class DefaultUrlHandlingStrategy {
5000
5064
  return newUrlPart;
5001
5065
  }
5002
5066
  }
5003
- DefaultUrlHandlingStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultUrlHandlingStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5004
- DefaultUrlHandlingStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultUrlHandlingStrategy, providedIn: 'root' });
5005
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: DefaultUrlHandlingStrategy, decorators: [{
5067
+ DefaultUrlHandlingStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultUrlHandlingStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5068
+ DefaultUrlHandlingStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultUrlHandlingStrategy, providedIn: 'root' });
5069
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: DefaultUrlHandlingStrategy, decorators: [{
5006
5070
  type: Injectable,
5007
5071
  args: [{ providedIn: 'root' }]
5008
5072
  }] });
@@ -5041,39 +5105,6 @@ const subsetMatchOptions = {
5041
5105
  matrixParams: 'ignored',
5042
5106
  queryParams: 'subset'
5043
5107
  };
5044
- function assignExtraOptionsToRouter(opts, router) {
5045
- if (opts.errorHandler) {
5046
- router.errorHandler = opts.errorHandler;
5047
- }
5048
- if (opts.malformedUriErrorHandler) {
5049
- router.malformedUriErrorHandler = opts.malformedUriErrorHandler;
5050
- }
5051
- if (opts.onSameUrlNavigation) {
5052
- router.onSameUrlNavigation = opts.onSameUrlNavigation;
5053
- }
5054
- if (opts.paramsInheritanceStrategy) {
5055
- router.paramsInheritanceStrategy = opts.paramsInheritanceStrategy;
5056
- }
5057
- if (opts.urlUpdateStrategy) {
5058
- router.urlUpdateStrategy = opts.urlUpdateStrategy;
5059
- }
5060
- if (opts.canceledNavigationResolution) {
5061
- router.canceledNavigationResolution = opts.canceledNavigationResolution;
5062
- }
5063
- }
5064
- function setupRouter() {
5065
- var _a, _b;
5066
- const urlSerializer = inject(UrlSerializer);
5067
- const contexts = inject(ChildrenOutletContexts);
5068
- const location = inject(Location);
5069
- const injector = inject(Injector);
5070
- const compiler = inject(Compiler);
5071
- const config = (_a = inject(ROUTES, { optional: true })) !== null && _a !== void 0 ? _a : [];
5072
- const opts = (_b = inject(ROUTER_CONFIGURATION, { optional: true })) !== null && _b !== void 0 ? _b : {};
5073
- const router = new Router(null, urlSerializer, contexts, location, injector, compiler, flatten(config));
5074
- assignExtraOptionsToRouter(opts, router);
5075
- return router;
5076
- }
5077
5108
  /**
5078
5109
  * @description
5079
5110
  *
@@ -5087,29 +5118,33 @@ function setupRouter() {
5087
5118
  * @publicApi
5088
5119
  */
5089
5120
  class Router {
5121
+ // TODO(b/260747083): This should not exist and navigationId should be private in
5122
+ // `NavigationTransitions`
5123
+ get navigationId() {
5124
+ return this.navigationTransitions.navigationId;
5125
+ }
5090
5126
  /**
5091
- * Creates the router service.
5127
+ * The ɵrouterPageId of whatever page is currently active in the browser history. This is
5128
+ * important for computing the target page id for new navigations because we need to ensure each
5129
+ * page id in the browser history is 1 more than the previous entry.
5092
5130
  */
5093
- // TODO: vsavkin make internal after the final is out.
5094
- constructor(
5095
- /** @internal */
5096
- rootComponentType,
5097
- /** @internal */
5098
- urlSerializer,
5099
- /** @internal */
5100
- rootContexts,
5101
- /** @internal */
5102
- location, injector, compiler, config) {
5103
- this.rootComponentType = rootComponentType;
5104
- this.urlSerializer = urlSerializer;
5105
- this.rootContexts = rootContexts;
5106
- this.location = location;
5107
- this.config = config;
5108
- /** @internal */
5109
- this.lastSuccessfulNavigation = null;
5131
+ get browserPageId() {
5132
+ var _a;
5133
+ return (_a = this.location.getState()) === null || _a === void 0 ? void 0 : _a.ɵrouterPageId;
5134
+ }
5135
+ /**
5136
+ * An event stream for routing events.
5137
+ */
5138
+ get events() {
5139
+ // TODO(atscott): This _should_ be events.asObservable(). However, this change requires internal
5140
+ // cleanup: tests are doing `(route.events as Subject<Event>).next(...)`. This isn't
5141
+ // allowed/supported but we still have to fix these or file bugs against the teams before making
5142
+ // the change.
5143
+ return this.navigationTransitions.events;
5144
+ }
5145
+ constructor() {
5146
+ var _a;
5110
5147
  this.disposed = false;
5111
- /** @internal */
5112
- this.navigationId = 0;
5113
5148
  /**
5114
5149
  * The id of the currently active page in the router.
5115
5150
  * Updated to the transition's target id on a successful navigation.
@@ -5119,17 +5154,15 @@ class Router {
5119
5154
  * page.
5120
5155
  */
5121
5156
  this.currentPageId = 0;
5157
+ this.console = inject(ɵConsole);
5122
5158
  this.isNgZoneEnabled = false;
5123
- /**
5124
- * An event stream for routing events in this NgModule.
5125
- */
5126
- this.events = new Subject();
5159
+ this.options = inject(ROUTER_CONFIGURATION, { optional: true }) || {};
5127
5160
  /**
5128
5161
  * A handler for navigation errors in this NgModule.
5129
5162
  *
5130
5163
  * @deprecated Subscribe to the `Router` events and watch for `NavigationError` instead.
5131
5164
  */
5132
- this.errorHandler = defaultErrorHandler;
5165
+ this.errorHandler = this.options.errorHandler || defaultErrorHandler;
5133
5166
  /**
5134
5167
  * A handler for errors thrown by `Router.parseUrl(url)`
5135
5168
  * when `url` contains an invalid character.
@@ -5140,7 +5173,7 @@ class Router {
5140
5173
  * `RouterModule.forRoot(routes, {malformedUriErrorHandler: myHandler})`
5141
5174
  * @see `RouterModule`
5142
5175
  */
5143
- this.malformedUriErrorHandler = defaultMalformedUriErrorHandler;
5176
+ this.malformedUriErrorHandler = this.options.malformedUriErrorHandler || defaultMalformedUriErrorHandler;
5144
5177
  /**
5145
5178
  * True if at least one navigation event has occurred,
5146
5179
  * false otherwise.
@@ -5177,24 +5210,15 @@ class Router {
5177
5210
  */
5178
5211
  this.titleStrategy = inject(TitleStrategy);
5179
5212
  /**
5180
- * How to handle a navigation request to the current URL. One of:
5181
- *
5182
- * - `'ignore'` : The router ignores the request.
5183
- * - `'reload'` : The router reloads the URL. Use to implement a "refresh" feature.
5213
+ * How to handle a navigation request to the current URL.
5184
5214
  *
5185
- * Note that this only configures whether the Route reprocesses the URL and triggers related
5186
- * action and events like redirects, guards, and resolvers. By default, the router re-uses a
5187
- * component instance when it re-navigates to the same component type without visiting a different
5188
- * component first. This behavior is configured by the `RouteReuseStrategy`. In order to reload
5189
- * routed components on same url navigation, you need to set `onSameUrlNavigation` to `'reload'`
5190
- * _and_ provide a `RouteReuseStrategy` which returns `false` for `shouldReuseRoute`.
5191
5215
  *
5192
5216
  * @deprecated Configure this through `provideRouter` or `RouterModule.forRoot` instead.
5193
5217
  * @see `withRouterConfig`
5194
5218
  * @see `provideRouter`
5195
5219
  * @see `RouterModule`
5196
5220
  */
5197
- this.onSameUrlNavigation = 'ignore';
5221
+ this.onSameUrlNavigation = this.options.onSameUrlNavigation || 'ignore';
5198
5222
  /**
5199
5223
  * How to merge parameters, data, resolved data, and title from parent to child
5200
5224
  * routes. One of:
@@ -5209,7 +5233,7 @@ class Router {
5209
5233
  * @see `provideRouter`
5210
5234
  * @see `RouterModule`
5211
5235
  */
5212
- this.paramsInheritanceStrategy = 'emptyOnly';
5236
+ this.paramsInheritanceStrategy = this.options.paramsInheritanceStrategy || 'emptyOnly';
5213
5237
  /**
5214
5238
  * Determines when the router updates the browser URL.
5215
5239
  * By default (`"deferred"`), updates the browser URL after navigation has finished.
@@ -5222,7 +5246,7 @@ class Router {
5222
5246
  * @see `provideRouter`
5223
5247
  * @see `RouterModule`
5224
5248
  */
5225
- this.urlUpdateStrategy = 'deferred';
5249
+ this.urlUpdateStrategy = this.options.urlUpdateStrategy || 'deferred';
5226
5250
  /**
5227
5251
  * Configures how the Router attempts to restore state when a navigation is cancelled.
5228
5252
  *
@@ -5249,73 +5273,39 @@ class Router {
5249
5273
  * @see `provideRouter`
5250
5274
  * @see `RouterModule`
5251
5275
  */
5252
- this.canceledNavigationResolution = 'replace';
5253
- this.navigationTransitions = new NavigationTransitions(this);
5254
- const onLoadStart = (r) => this.triggerEvent(new RouteConfigLoadStart(r));
5255
- const onLoadEnd = (r) => this.triggerEvent(new RouteConfigLoadEnd(r));
5256
- this.configLoader = injector.get(RouterConfigLoader);
5257
- this.configLoader.onLoadEndListener = onLoadEnd;
5258
- this.configLoader.onLoadStartListener = onLoadStart;
5259
- this.ngModule = injector.get(NgModuleRef);
5260
- this.console = injector.get(ɵConsole);
5261
- const ngZone = injector.get(NgZone);
5262
- this.isNgZoneEnabled = ngZone instanceof NgZone && NgZone.isInAngularZone();
5263
- this.resetConfig(config);
5276
+ this.canceledNavigationResolution = this.options.canceledNavigationResolution || 'replace';
5277
+ this.config = flatten((_a = inject(ROUTES, { optional: true })) !== null && _a !== void 0 ? _a : []);
5278
+ this.navigationTransitions = inject(NavigationTransitions);
5279
+ this.urlSerializer = inject(UrlSerializer);
5280
+ this.location = inject(Location);
5281
+ /** @internal */
5282
+ this.rootComponentType = null;
5283
+ this.isNgZoneEnabled = inject(NgZone) instanceof NgZone && NgZone.isInAngularZone();
5284
+ this.resetConfig(this.config);
5264
5285
  this.currentUrlTree = new UrlTree();
5265
5286
  this.rawUrlTree = this.currentUrlTree;
5266
5287
  this.browserUrlTree = this.currentUrlTree;
5267
5288
  this.routerState = createEmptyState(this.currentUrlTree, this.rootComponentType);
5268
- this.transitions = new BehaviorSubject({
5269
- id: 0,
5270
- targetPageId: 0,
5271
- currentUrlTree: this.currentUrlTree,
5272
- extractedUrl: this.urlHandlingStrategy.extract(this.currentUrlTree),
5273
- urlAfterRedirects: this.urlHandlingStrategy.extract(this.currentUrlTree),
5274
- rawUrl: this.currentUrlTree,
5275
- extras: {},
5276
- resolve: null,
5277
- reject: null,
5278
- promise: Promise.resolve(true),
5279
- source: 'imperative',
5280
- restoredState: null,
5281
- currentSnapshot: this.routerState.snapshot,
5282
- targetSnapshot: null,
5283
- currentRouterState: this.routerState,
5284
- targetRouterState: null,
5285
- guards: { canActivateChecks: [], canDeactivateChecks: [] },
5286
- guardsResult: null,
5289
+ this.navigationTransitions.setupNavigations(this).subscribe(t => {
5290
+ this.lastSuccessfulId = t.id;
5291
+ this.currentPageId = t.targetPageId;
5292
+ }, e => {
5293
+ this.console.warn(`Unhandled Navigation Error: ${e}`);
5287
5294
  });
5288
- this.navigations = this.navigationTransitions.setupNavigations(this.transitions);
5289
- this.processNavigations();
5290
5295
  }
5291
- /**
5292
- * The ɵrouterPageId of whatever page is currently active in the browser history. This is
5293
- * important for computing the target page id for new navigations because we need to ensure each
5294
- * page id in the browser history is 1 more than the previous entry.
5295
- */
5296
- get browserPageId() {
5297
- var _a;
5298
- return (_a = this.location.getState()) === null || _a === void 0 ? void 0 : _a.ɵrouterPageId;
5299
- }
5300
- /**
5301
- * @internal
5302
- * TODO: this should be removed once the constructor of the router made internal
5303
- */
5296
+ /** @internal */
5304
5297
  resetRootComponentType(rootComponentType) {
5305
5298
  this.rootComponentType = rootComponentType;
5306
5299
  // TODO: vsavkin router 4.0 should make the root component set to null
5307
5300
  // this will simplify the lifecycle of the router.
5308
5301
  this.routerState.root.component = this.rootComponentType;
5309
5302
  }
5310
- setTransition(t) {
5311
- this.transitions.next(Object.assign(Object.assign({}, this.transitions.value), t));
5312
- }
5313
5303
  /**
5314
5304
  * Sets up the location change listener and performs the initial navigation.
5315
5305
  */
5316
5306
  initialNavigation() {
5317
5307
  this.setUpLocationChangeListener();
5318
- if (this.navigationId === 0) {
5308
+ if (!this.navigationTransitions.hasRequestedNavigation) {
5319
5309
  this.navigateByUrl(this.location.path(true), { replaceUrl: true });
5320
5310
  }
5321
5311
  }
@@ -5373,10 +5363,6 @@ class Router {
5373
5363
  getCurrentNavigation() {
5374
5364
  return this.navigationTransitions.currentNavigation;
5375
5365
  }
5376
- /** @internal */
5377
- triggerEvent(event) {
5378
- this.events.next(event);
5379
- }
5380
5366
  /**
5381
5367
  * Resets the route configuration used for navigation and generating links.
5382
5368
  *
@@ -5405,7 +5391,7 @@ class Router {
5405
5391
  }
5406
5392
  /** Disposes of the router. */
5407
5393
  dispose() {
5408
- this.transitions.complete();
5394
+ this.navigationTransitions.complete();
5409
5395
  if (this.locationSubscription) {
5410
5396
  this.locationSubscription.unsubscribe();
5411
5397
  this.locationSubscription = undefined;
@@ -5590,21 +5576,6 @@ class Router {
5590
5576
  return result;
5591
5577
  }, {});
5592
5578
  }
5593
- processNavigations() {
5594
- this.navigations.subscribe(t => {
5595
- var _a;
5596
- this.navigated = true;
5597
- this.lastSuccessfulId = t.id;
5598
- this.currentPageId = t.targetPageId;
5599
- this.events
5600
- .next(new NavigationEnd(t.id, this.serializeUrl(t.extractedUrl), this.serializeUrl(this.currentUrlTree)));
5601
- this.lastSuccessfulNavigation = this.getCurrentNavigation();
5602
- (_a = this.titleStrategy) === null || _a === void 0 ? void 0 : _a.updateTitle(this.routerState.snapshot);
5603
- t.resolve(true);
5604
- }, e => {
5605
- this.console.warn(`Unhandled Navigation Error: ${e}`);
5606
- });
5607
- }
5608
5579
  /** @internal */
5609
5580
  scheduleNavigation(rawUrl, source, restoredState, extras, priorPromise) {
5610
5581
  var _a, _b;
@@ -5625,7 +5596,6 @@ class Router {
5625
5596
  reject = rej;
5626
5597
  });
5627
5598
  }
5628
- const id = ++this.navigationId;
5629
5599
  let targetPageId;
5630
5600
  if (this.canceledNavigationResolution === 'computed') {
5631
5601
  const isInitialPage = this.currentPageId === 0;
@@ -5653,12 +5623,12 @@ class Router {
5653
5623
  // This is unused when `canceledNavigationResolution` is not computed.
5654
5624
  targetPageId = 0;
5655
5625
  }
5656
- this.setTransition({
5657
- id,
5626
+ this.navigationTransitions.handleNavigationRequest({
5658
5627
  targetPageId,
5659
5628
  source,
5660
5629
  restoredState,
5661
5630
  currentUrlTree: this.currentUrlTree,
5631
+ currentRawUrl: this.currentUrlTree,
5662
5632
  rawUrl,
5663
5633
  extras,
5664
5634
  resolve,
@@ -5743,12 +5713,6 @@ class Router {
5743
5713
  resetUrlToCurrentUrlTree() {
5744
5714
  this.location.replaceState(this.urlSerializer.serialize(this.rawUrlTree), '', this.generateNgRouterState(this.lastSuccessfulId, this.currentPageId));
5745
5715
  }
5746
- /** @internal */
5747
- cancelNavigationTransition(transition, reason, code) {
5748
- const navCancel = new NavigationCancel(transition.id, this.serializeUrl(transition.extractedUrl), reason, code);
5749
- this.triggerEvent(navCancel);
5750
- transition.resolve(false);
5751
- }
5752
5716
  generateNgRouterState(navigationId, routerPageId) {
5753
5717
  if (this.canceledNavigationResolution === 'computed') {
5754
5718
  return { navigationId, ɵrouterPageId: routerPageId };
@@ -5756,15 +5720,12 @@ class Router {
5756
5720
  return { navigationId };
5757
5721
  }
5758
5722
  }
5759
- Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: Router, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
5760
- Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: Router, providedIn: 'root', useFactory: setupRouter });
5761
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: Router, decorators: [{
5723
+ Router.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: Router, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5724
+ Router.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: Router, providedIn: 'root' });
5725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: Router, decorators: [{
5762
5726
  type: Injectable,
5763
- args: [{
5764
- providedIn: 'root',
5765
- useFactory: setupRouter,
5766
- }]
5767
- }], ctorParameters: function () { return [{ type: i0.Type }, { type: UrlSerializer }, { type: ChildrenOutletContexts }, { type: i3.Location }, { type: i0.Injector }, { type: i0.Compiler }, { type: undefined }]; } });
5727
+ args: [{ providedIn: 'root' }]
5728
+ }], ctorParameters: function () { return []; } });
5768
5729
  function validateCommands(commands) {
5769
5730
  for (let i = 0; i < commands.length; i++) {
5770
5731
  const cmd = commands[i];
@@ -6049,9 +6010,9 @@ class RouterLink {
6049
6010
  });
6050
6011
  }
6051
6012
  }
6052
- RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
6053
- RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.0", type: RouterLink, isStandalone: true, selector: "[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", state: "state", relativeTo: "relativeTo", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target" } }, usesOnChanges: true, ngImport: i0 });
6054
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterLink, decorators: [{
6013
+ RouterLink.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterLink, deps: [{ token: Router }, { token: ActivatedRoute }, { token: 'tabindex', attribute: true }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i3.LocationStrategy }], target: i0.ɵɵFactoryTarget.Directive });
6014
+ RouterLink.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.2", type: RouterLink, isStandalone: true, selector: "[routerLink]", inputs: { target: "target", queryParams: "queryParams", fragment: "fragment", queryParamsHandling: "queryParamsHandling", state: "state", relativeTo: "relativeTo", preserveFragment: "preserveFragment", skipLocationChange: "skipLocationChange", replaceUrl: "replaceUrl", routerLink: "routerLink" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" }, properties: { "attr.target": "this.target" } }, usesOnChanges: true, ngImport: i0 });
6015
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterLink, decorators: [{
6055
6016
  type: Directive,
6056
6017
  args: [{
6057
6018
  selector: '[routerLink]',
@@ -6280,9 +6241,9 @@ class RouterLinkActive {
6280
6241
  return this.link && isActiveCheckFn(this.link) || this.links.some(isActiveCheckFn);
6281
6242
  }
6282
6243
  }
6283
- RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
6284
- RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.0", type: RouterLinkActive, isStandalone: true, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
6285
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterLinkActive, decorators: [{
6244
+ RouterLinkActive.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterLinkActive, deps: [{ token: Router }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.ChangeDetectorRef }, { token: RouterLink, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
6245
+ RouterLinkActive.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.0-next.2", type: RouterLinkActive, isStandalone: true, selector: "[routerLinkActive]", inputs: { routerLinkActiveOptions: "routerLinkActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive", routerLinkActive: "routerLinkActive" }, outputs: { isActiveChange: "isActiveChange" }, queries: [{ propertyName: "links", predicate: RouterLink, descendants: true }], exportAs: ["routerLinkActive"], usesOnChanges: true, ngImport: i0 });
6246
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterLinkActive, decorators: [{
6286
6247
  type: Directive,
6287
6248
  args: [{
6288
6249
  selector: '[routerLinkActive]',
@@ -6344,9 +6305,9 @@ class PreloadAllModules {
6344
6305
  return fn().pipe(catchError(() => of(null)));
6345
6306
  }
6346
6307
  }
6347
- PreloadAllModules.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: PreloadAllModules, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6348
- PreloadAllModules.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: PreloadAllModules, providedIn: 'root' });
6349
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: PreloadAllModules, decorators: [{
6308
+ PreloadAllModules.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: PreloadAllModules, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6309
+ PreloadAllModules.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: PreloadAllModules, providedIn: 'root' });
6310
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: PreloadAllModules, decorators: [{
6350
6311
  type: Injectable,
6351
6312
  args: [{ providedIn: 'root' }]
6352
6313
  }] });
@@ -6364,9 +6325,9 @@ class NoPreloading {
6364
6325
  return of(null);
6365
6326
  }
6366
6327
  }
6367
- NoPreloading.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: NoPreloading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6368
- NoPreloading.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: NoPreloading, providedIn: 'root' });
6369
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: NoPreloading, decorators: [{
6328
+ NoPreloading.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NoPreloading, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6329
+ NoPreloading.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NoPreloading, providedIn: 'root' });
6330
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: NoPreloading, decorators: [{
6370
6331
  type: Injectable,
6371
6332
  args: [{ providedIn: 'root' }]
6372
6333
  }] });
@@ -6462,18 +6423,19 @@ class RouterPreloader {
6462
6423
  });
6463
6424
  }
6464
6425
  }
6465
- RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6466
- RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterPreloader, providedIn: 'root' });
6467
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterPreloader, decorators: [{
6426
+ RouterPreloader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterPreloader, deps: [{ token: Router }, { token: i0.Compiler }, { token: i0.EnvironmentInjector }, { token: PreloadingStrategy }, { token: RouterConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
6427
+ RouterPreloader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterPreloader, providedIn: 'root' });
6428
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterPreloader, decorators: [{
6468
6429
  type: Injectable,
6469
6430
  args: [{ providedIn: 'root' }]
6470
6431
  }], ctorParameters: function () { return [{ type: Router }, { type: i0.Compiler }, { type: i0.EnvironmentInjector }, { type: PreloadingStrategy }, { type: RouterConfigLoader }]; } });
6471
6432
 
6472
6433
  const ROUTER_SCROLLER = new InjectionToken('');
6473
6434
  class RouterScroller {
6474
- constructor(router,
6475
- /** @docsNotRequired */ viewportScroller, zone, options = {}) {
6476
- this.router = router;
6435
+ /** @nodoc */
6436
+ constructor(urlSerializer, transitions, viewportScroller, zone, options = {}) {
6437
+ this.urlSerializer = urlSerializer;
6438
+ this.transitions = transitions;
6477
6439
  this.viewportScroller = viewportScroller;
6478
6440
  this.zone = zone;
6479
6441
  this.options = options;
@@ -6496,7 +6458,7 @@ class RouterScroller {
6496
6458
  this.scrollEventsSubscription = this.consumeScrollEvents();
6497
6459
  }
6498
6460
  createScrollEvents() {
6499
- return this.router.events.subscribe(e => {
6461
+ return this.transitions.events.subscribe(e => {
6500
6462
  if (e instanceof NavigationStart) {
6501
6463
  // store the scroll position of the current stable navigations.
6502
6464
  this.store[this.lastId] = this.viewportScroller.getScrollPosition();
@@ -6505,12 +6467,12 @@ class RouterScroller {
6505
6467
  }
6506
6468
  else if (e instanceof NavigationEnd) {
6507
6469
  this.lastId = e.id;
6508
- this.scheduleScrollEvent(e, this.router.parseUrl(e.urlAfterRedirects).fragment);
6470
+ this.scheduleScrollEvent(e, this.urlSerializer.parse(e.urlAfterRedirects).fragment);
6509
6471
  }
6510
6472
  });
6511
6473
  }
6512
6474
  consumeScrollEvents() {
6513
- return this.router.events.subscribe(e => {
6475
+ return this.transitions.events.subscribe(e => {
6514
6476
  if (!(e instanceof Scroll))
6515
6477
  return;
6516
6478
  // a popstate event. The pop state event will always ignore anchor scrolling.
@@ -6540,26 +6502,23 @@ class RouterScroller {
6540
6502
  // component by executing its update block of the template function.
6541
6503
  setTimeout(() => {
6542
6504
  this.zone.run(() => {
6543
- this.router.triggerEvent(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
6505
+ this.transitions.events.next(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
6544
6506
  });
6545
6507
  }, 0);
6546
6508
  });
6547
6509
  }
6548
6510
  /** @nodoc */
6549
6511
  ngOnDestroy() {
6550
- if (this.routerEventsSubscription) {
6551
- this.routerEventsSubscription.unsubscribe();
6552
- }
6553
- if (this.scrollEventsSubscription) {
6554
- this.scrollEventsSubscription.unsubscribe();
6555
- }
6512
+ var _a, _b;
6513
+ (_a = this.routerEventsSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
6514
+ (_b = this.scrollEventsSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
6556
6515
  }
6557
6516
  }
6558
- RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6559
- RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterScroller });
6560
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterScroller, decorators: [{
6517
+ RouterScroller.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterScroller, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
6518
+ RouterScroller.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterScroller });
6519
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterScroller, decorators: [{
6561
6520
  type: Injectable
6562
- }], ctorParameters: function () { return [{ type: Router }, { type: i3.ViewportScroller }, { type: i0.NgZone }, { type: undefined }]; } });
6521
+ }], ctorParameters: function () { return [{ type: UrlSerializer }, { type: NavigationTransitions }, { type: i3.ViewportScroller }, { type: i0.NgZone }, { type: undefined }]; } });
6563
6522
 
6564
6523
  /**
6565
6524
  * @license
@@ -6612,10 +6571,6 @@ function provideRouter(routes, ...features) {
6612
6571
  { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
6613
6572
  { provide: APP_BOOTSTRAP_LISTENER, multi: true, useFactory: getBootstrapListener },
6614
6573
  features.map(feature => feature.ɵproviders),
6615
- // TODO: All options used by the `assignExtraOptionsToRouter` factory need to be reviewed for
6616
- // how we want them to be configured. This API doesn't currently have a way to configure them
6617
- // and we should decide what the _best_ way to do that is rather than just sticking with the
6618
- // status quo of how it's done today.
6619
6574
  ]);
6620
6575
  }
6621
6576
  function rootRoute(router) {
@@ -6696,10 +6651,11 @@ function withInMemoryScrolling(options = {}) {
6696
6651
  const providers = [{
6697
6652
  provide: ROUTER_SCROLLER,
6698
6653
  useFactory: () => {
6699
- const router = inject(Router);
6700
6654
  const viewportScroller = inject(ViewportScroller);
6701
6655
  const zone = inject(NgZone);
6702
- return new RouterScroller(router, viewportScroller, zone, options);
6656
+ const transitions = inject(NavigationTransitions);
6657
+ const urlSerializer = inject(UrlSerializer);
6658
+ return new RouterScroller(urlSerializer, transitions, viewportScroller, zone, options);
6703
6659
  },
6704
6660
  }];
6705
6661
  return routerFeature(4 /* RouterFeatureKind.InMemoryScrollingFeature */, providers);
@@ -7004,7 +6960,7 @@ const ROUTER_FORROOT_GUARD = new InjectionToken(NG_DEV_MODE ? 'router duplicate
7004
6960
  const ROUTER_PROVIDERS = [
7005
6961
  Location,
7006
6962
  { provide: UrlSerializer, useClass: DefaultUrlSerializer },
7007
- { provide: Router, useFactory: setupRouter },
6963
+ Router,
7008
6964
  ChildrenOutletContexts,
7009
6965
  { provide: ActivatedRoute, useFactory: rootRoute, deps: [Router] },
7010
6966
  RouterConfigLoader,
@@ -7101,10 +7057,10 @@ class RouterModule {
7101
7057
  };
7102
7058
  }
7103
7059
  }
7104
- RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
7105
- RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterModule, imports: [RouterOutlet, RouterLink, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkActive, ɵEmptyOutletComponent] });
7106
- RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterModule, imports: [ɵEmptyOutletComponent] });
7107
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.0", ngImport: i0, type: RouterModule, decorators: [{
7060
+ RouterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterModule, deps: [{ token: ROUTER_FORROOT_GUARD, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
7061
+ RouterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterModule, imports: [RouterOutlet, RouterLink, RouterLinkActive, ɵEmptyOutletComponent], exports: [RouterOutlet, RouterLink, RouterLinkActive, ɵEmptyOutletComponent] });
7062
+ RouterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterModule, imports: [ɵEmptyOutletComponent] });
7063
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0-next.2", ngImport: i0, type: RouterModule, decorators: [{
7108
7064
  type: NgModule,
7109
7065
  args: [{
7110
7066
  imports: ROUTER_DIRECTIVES,
@@ -7126,14 +7082,15 @@ function provideRouterScroller() {
7126
7082
  return {
7127
7083
  provide: ROUTER_SCROLLER,
7128
7084
  useFactory: () => {
7129
- const router = inject(Router);
7130
7085
  const viewportScroller = inject(ViewportScroller);
7131
7086
  const zone = inject(NgZone);
7132
7087
  const config = inject(ROUTER_CONFIGURATION);
7088
+ const transitions = inject(NavigationTransitions);
7089
+ const urlSerializer = inject(UrlSerializer);
7133
7090
  if (config.scrollOffset) {
7134
7091
  viewportScroller.setOffset(config.scrollOffset);
7135
7092
  }
7136
- return new RouterScroller(router, viewportScroller, zone, config);
7093
+ return new RouterScroller(urlSerializer, transitions, viewportScroller, zone, config);
7137
7094
  },
7138
7095
  };
7139
7096
  }
@@ -7191,7 +7148,7 @@ function provideRouterInitializer() {
7191
7148
  /**
7192
7149
  * @publicApi
7193
7150
  */
7194
- const VERSION = new Version('15.1.0-next.0');
7151
+ const VERSION = new Version('15.1.0-next.2');
7195
7152
 
7196
7153
  /**
7197
7154
  * @license
@@ -7230,5 +7187,5 @@ const VERSION = new Version('15.1.0-next.0');
7230
7187
  * Generated bundle index. Do not edit.
7231
7188
  */
7232
7189
 
7233
- export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationSkipped, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLink as RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, createUrlTreeFromSnapshot, defaultUrlMatcher, provideRouter, provideRoutes, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withInMemoryScrolling, withPreloading, withRouterConfig, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, assignExtraOptionsToRouter as ɵassignExtraOptionsToRouter, flatten as ɵflatten, withPreloading as ɵwithPreloading };
7190
+ export { ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, BaseRouteReuseStrategy, ChildActivationEnd, ChildActivationStart, ChildrenOutletContexts, DefaultTitleStrategy, DefaultUrlSerializer, GuardsCheckEnd, GuardsCheckStart, NavigationCancel, NavigationEnd, NavigationError, NavigationSkipped, NavigationStart, NoPreloading, OutletContext, PRIMARY_OUTLET, PreloadAllModules, PreloadingStrategy, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTES, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterLink, RouterLinkActive, RouterLink as RouterLinkWithHref, RouterModule, RouterOutlet, RouterPreloader, RouterState, RouterStateSnapshot, RoutesRecognized, Scroll, TitleStrategy, UrlHandlingStrategy, UrlSegment, UrlSegmentGroup, UrlSerializer, UrlTree, VERSION, convertToParamMap, createUrlTreeFromSnapshot, defaultUrlMatcher, provideRouter, provideRoutes, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withInMemoryScrolling, withPreloading, withRouterConfig, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, flatten as ɵflatten, withPreloading as ɵwithPreloading };
7234
7191
  //# sourceMappingURL=router.mjs.map