@angular/router 17.3.1 → 18.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2022/src/apply_redirects.mjs +16 -7
  2. package/esm2022/src/components/empty_outlet.mjs +3 -3
  3. package/esm2022/src/directives/router_link.mjs +3 -3
  4. package/esm2022/src/directives/router_link_active.mjs +3 -3
  5. package/esm2022/src/directives/router_outlet.mjs +6 -6
  6. package/esm2022/src/events.mjs +3 -2
  7. package/esm2022/src/index.mjs +2 -1
  8. package/esm2022/src/models.mjs +16 -2
  9. package/esm2022/src/navigation_canceling_error.mjs +1 -1
  10. package/esm2022/src/navigation_transition.mjs +7 -7
  11. package/esm2022/src/operators/check_guards.mjs +2 -3
  12. package/esm2022/src/operators/prioritized_guard_value.mjs +8 -4
  13. package/esm2022/src/page_title_strategy.mjs +6 -6
  14. package/esm2022/src/recognize.mjs +36 -39
  15. package/esm2022/src/route_reuse_strategy.mjs +6 -6
  16. package/esm2022/src/router.mjs +8 -5
  17. package/esm2022/src/router_config_loader.mjs +3 -3
  18. package/esm2022/src/router_module.mjs +4 -4
  19. package/esm2022/src/router_outlet_context.mjs +3 -3
  20. package/esm2022/src/router_preloader.mjs +9 -9
  21. package/esm2022/src/router_scroller.mjs +3 -3
  22. package/esm2022/src/shared.mjs +2 -2
  23. package/esm2022/src/statemanager/state_manager.mjs +6 -6
  24. package/esm2022/src/url_handling_strategy.mjs +6 -6
  25. package/esm2022/src/url_tree.mjs +3 -3
  26. package/esm2022/src/version.mjs +1 -1
  27. package/esm2022/testing/src/router_testing_harness.mjs +6 -6
  28. package/esm2022/testing/src/router_testing_module.mjs +4 -4
  29. package/fesm2022/router.mjs +153 -124
  30. package/fesm2022/router.mjs.map +1 -1
  31. package/fesm2022/testing.mjs +11 -11
  32. package/fesm2022/upgrade.mjs +1 -1
  33. package/index.d.ts +41 -5
  34. package/package.json +4 -4
  35. package/testing/index.d.ts +1 -1
  36. package/upgrade/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v18.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -59,16 +59,16 @@ class RouterTestingModule {
59
59
  ],
60
60
  };
61
61
  }
62
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.1", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] }); }
64
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RouterTestingModule, providers: [
62
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
63
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.0-next.1", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] }); }
64
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RouterTestingModule, providers: [
65
65
  ɵROUTER_PROVIDERS,
66
66
  provideLocationMocks(),
67
67
  withPreloading(NoPreloading).ɵproviders,
68
68
  { provide: ROUTES, multi: true, useValue: [] },
69
69
  ], imports: [RouterModule] }); }
70
70
  }
71
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RouterTestingModule, decorators: [{
71
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RouterTestingModule, decorators: [{
72
72
  type: NgModule,
73
73
  args: [{
74
74
  exports: [RouterModule],
@@ -97,18 +97,18 @@ class RootFixtureService {
97
97
  this.fixture.detectChanges();
98
98
  return this.fixture;
99
99
  }
100
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RootFixtureService, providedIn: 'root' }); }
100
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RootFixtureService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
101
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RootFixtureService, providedIn: 'root' }); }
102
102
  }
103
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RootFixtureService, decorators: [{
103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RootFixtureService, decorators: [{
104
104
  type: Injectable,
105
105
  args: [{ providedIn: 'root' }]
106
106
  }] });
107
107
  class RootCmp {
108
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
109
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.1", type: RootCmp, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "outlet", first: true, predicate: RouterOutlet, descendants: true }], 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"] }] }); }
108
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RootCmp, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
109
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.0-next.1", type: RootCmp, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "outlet", first: true, predicate: RouterOutlet, descendants: true }], 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"] }] }); }
110
110
  }
111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: RootCmp, decorators: [{
111
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.1", ngImport: i0, type: RootCmp, decorators: [{
112
112
  type: Component,
113
113
  args: [{
114
114
  standalone: true,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v18.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v18.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1073,7 +1073,7 @@ export declare interface ExtraOptions extends InMemoryScrollingOptions, RouterCo
1073
1073
  * @see [Routing tutorial](guide/router-tutorial-toh#milestone-5-route-guards)
1074
1074
  * @publicApi
1075
1075
  */
1076
- export declare type GuardResult = boolean | UrlTree;
1076
+ export declare type GuardResult = boolean | UrlTree | RedirectCommand;
1077
1077
 
1078
1078
  /**
1079
1079
  * An event triggered at the end of the Guard phase of routing.
@@ -2080,6 +2080,38 @@ export declare function provideRoutes(routes: Routes): Provider[];
2080
2080
  */
2081
2081
  export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
2082
2082
 
2083
+ /**
2084
+ * Can be returned by a `Router` guard to instruct the `Router` to redirect rather than continue
2085
+ * processing the path of the in-flight navigation. The `redirectTo` indicates _where_ the new
2086
+ * navigation should go to and the optional `navigationBehaviorOptions` can provide more information
2087
+ * about _how_ to perform the navigation.
2088
+ *
2089
+ * @see [Routing tutorial](guide/router-tutorial-toh#milestone-5-route-guards)
2090
+ * @publicApi
2091
+ */
2092
+ export declare class RedirectCommand {
2093
+ readonly redirectTo: UrlTree;
2094
+ readonly navigationBehaviorOptions?: NavigationBehaviorOptions | undefined;
2095
+ constructor(redirectTo: UrlTree, navigationBehaviorOptions?: NavigationBehaviorOptions | undefined);
2096
+ }
2097
+
2098
+ /**
2099
+ * The type for the function that returns a used to handle redirects when the path matches a `Route` config.
2100
+ *
2101
+ * The `RedirectFunction` does have access to the full
2102
+ * `ActivatedRouteSnapshot` interface. Some data are not accurately known
2103
+ * at the route matching phase. For example, resolvers are not run until
2104
+ * later, so any resolved title would not be populated. The same goes for lazy
2105
+ * loaded components. This is also true for all the snapshots up to the
2106
+ * root, so properties that include parents (root, parent, pathFromRoot)
2107
+ * are also excluded. And naturally, the full route matching hasn't yet
2108
+ * happened so firstChild and children are not available either.
2109
+ *
2110
+ * @see {@link Route#redirectTo}
2111
+ * @publicApi
2112
+ */
2113
+ export declare type RedirectFunction = (redirectData: Pick<ActivatedRouteSnapshot, 'routeConfig' | 'url' | 'params' | 'queryParams' | 'fragment' | 'data' | 'outlet' | 'title'>) => string | UrlTree;
2114
+
2083
2115
  /**
2084
2116
  * @description
2085
2117
  *
@@ -2563,13 +2595,17 @@ export declare interface Route {
2563
2595
  */
2564
2596
  loadComponent?: () => Type<unknown> | Observable<Type<unknown> | DefaultExport<Type<unknown>>> | Promise<Type<unknown> | DefaultExport<Type<unknown>>>;
2565
2597
  /**
2566
- * A URL to redirect to when the path matches.
2598
+ * A URL or function that returns a URL to redirect to when the path matches.
2599
+ *
2600
+ * Absolute if the URL begins with a slash (/) or the function returns a `UrlTree`, otherwise
2601
+ * relative to the path URL.
2567
2602
  *
2568
- * Absolute if the URL begins with a slash (/), otherwise relative to the path URL.
2603
+ * The `RedirectFunction` is run in an injection context so it can call `inject` to get any
2604
+ * required dependencies.
2569
2605
  *
2570
2606
  * When not present, router does not redirect.
2571
2607
  */
2572
- redirectTo?: string;
2608
+ redirectTo?: string | RedirectFunction;
2573
2609
  /**
2574
2610
  * Name of a `RouterOutlet` object where the component can be placed
2575
2611
  * when the path matches.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/router",
3
- "version": "17.3.1",
3
+ "version": "18.0.0-next.1",
4
4
  "description": "Angular - the routing library",
5
5
  "keywords": [
6
6
  "angular",
@@ -24,9 +24,9 @@
24
24
  "tslib": "^2.3.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@angular/core": "17.3.1",
28
- "@angular/common": "17.3.1",
29
- "@angular/platform-browser": "17.3.1",
27
+ "@angular/core": "18.0.0-next.1",
28
+ "@angular/common": "18.0.0-next.1",
29
+ "@angular/platform-browser": "18.0.0-next.1",
30
30
  "rxjs": "^6.5.3 || ^7.4.0"
31
31
  },
32
32
  "ng-update": {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v18.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v17.3.1
2
+ * @license Angular v18.0.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */