@angular/router 14.2.0-next.0 → 14.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.2.0-next.0
2
+ * @license Angular v14.2.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -101,9 +101,9 @@ class RouterTestingModule {
101
101
  };
102
102
  }
103
103
  }
104
- RouterTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0-next.0", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
105
- RouterTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.0-next.0", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] });
106
- RouterTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.0-next.0", ngImport: i0, type: RouterTestingModule, providers: [
104
+ RouterTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0-next.1", ngImport: i0, type: RouterTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
105
+ RouterTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.0-next.1", ngImport: i0, type: RouterTestingModule, exports: [RouterModule] });
106
+ RouterTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.0-next.1", ngImport: i0, type: RouterTestingModule, providers: [
107
107
  ɵROUTER_PROVIDERS,
108
108
  EXTRA_ROUTER_TESTING_PROVIDERS,
109
109
  { provide: Location, useClass: SpyLocation },
@@ -127,7 +127,7 @@ RouterTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
127
127
  ɵprovidePreloading(NoPreloading),
128
128
  provideRoutes([]),
129
129
  ], imports: [RouterModule] });
130
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0-next.0", ngImport: i0, type: RouterTestingModule, decorators: [{
130
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0-next.1", ngImport: i0, type: RouterTestingModule, decorators: [{
131
131
  type: NgModule,
132
132
  args: [{
133
133
  exports: [RouterModule],
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v14.2.0-next.0
2
+ * @license Angular v14.2.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 v14.2.0-next.0
2
+ * @license Angular v14.2.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -262,7 +262,7 @@ export declare abstract class BaseRouteReuseStrategy implements RouteReuseStrate
262
262
  * ```
263
263
  * class UserToken {}
264
264
  * class Permissions {
265
- * canActivate(user: UserToken, id: string): boolean {
265
+ * canActivate(): boolean {
266
266
  * return true;
267
267
  * }
268
268
  * }
@@ -299,7 +299,7 @@ export declare abstract class BaseRouteReuseStrategy implements RouteReuseStrate
299
299
  * class AppModule {}
300
300
  * ```
301
301
  *
302
- * You can alternatively provide an in-line function with the `canActivate` signature:
302
+ * You can alternatively provide an in-line function with the `CanActivateFn` signature:
303
303
  *
304
304
  * ```
305
305
  * @NgModule({
@@ -308,16 +308,10 @@ export declare abstract class BaseRouteReuseStrategy implements RouteReuseStrate
308
308
  * {
309
309
  * path: 'team/:id',
310
310
  * component: TeamComponent,
311
- * canActivate: ['canActivateTeam']
311
+ * canActivate: [(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true]
312
312
  * }
313
313
  * ])
314
314
  * ],
315
- * providers: [
316
- * {
317
- * provide: 'canActivateTeam',
318
- * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
319
- * }
320
- * ]
321
315
  * })
322
316
  * class AppModule {}
323
317
  * ```
@@ -384,7 +378,7 @@ export declare interface CanActivate {
384
378
  * class AppModule {}
385
379
  * ```
386
380
  *
387
- * You can alternatively provide an in-line function with the `canActivateChild` signature:
381
+ * You can alternatively provide an in-line function with the `CanActivateChildFn` signature:
388
382
  *
389
383
  * ```
390
384
  * @NgModule({
@@ -392,7 +386,7 @@ export declare interface CanActivate {
392
386
  * RouterModule.forRoot([
393
387
  * {
394
388
  * path: 'root',
395
- * canActivateChild: ['canActivateTeam'],
389
+ * canActivateChild: [(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true],
396
390
  * children: [
397
391
  * {
398
392
  * path: 'team/:id',
@@ -402,12 +396,6 @@ export declare interface CanActivate {
402
396
  * }
403
397
  * ])
404
398
  * ],
405
- * providers: [
406
- * {
407
- * provide: 'canActivateTeam',
408
- * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => true
409
- * }
410
- * ]
411
399
  * })
412
400
  * class AppModule {}
413
401
  * ```
@@ -418,6 +406,24 @@ export declare interface CanActivateChild {
418
406
  canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
419
407
  }
420
408
 
409
+ /**
410
+ * The signature of a function used as a `canActivateChild` guard on a `Route`.
411
+ *
412
+ * @publicApi
413
+ * @see `CanActivateChild`
414
+ * @see `Route`
415
+ */
416
+ export declare type CanActivateChildFn = (childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
417
+
418
+ /**
419
+ * The signature of a function used as a `canActivate` guard on a `Route`.
420
+ *
421
+ * @publicApi
422
+ * @see `CanActivate`
423
+ * @see `Route`
424
+ */
425
+ export declare type CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
426
+
421
427
  /**
422
428
  * @description
423
429
  *
@@ -472,7 +478,7 @@ export declare interface CanActivateChild {
472
478
  * class AppModule {}
473
479
  * ```
474
480
  *
475
- * You can alternatively provide an in-line function with the `canDeactivate` signature:
481
+ * You can alternatively provide an in-line function with the `CanDeactivateFn` signature:
476
482
  *
477
483
  * ```
478
484
  * @NgModule({
@@ -481,17 +487,11 @@ export declare interface CanActivateChild {
481
487
  * {
482
488
  * path: 'team/:id',
483
489
  * component: TeamComponent,
484
- * canDeactivate: ['canDeactivateTeam']
490
+ * canDeactivate: [(component: TeamComponent, currentRoute: ActivatedRouteSnapshot,
491
+ * currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) => true]
485
492
  * }
486
493
  * ])
487
494
  * ],
488
- * providers: [
489
- * {
490
- * provide: 'canDeactivateTeam',
491
- * useValue: (component: TeamComponent, currentRoute: ActivatedRouteSnapshot, currentState:
492
- * RouterStateSnapshot, nextState: RouterStateSnapshot) => true
493
- * }
494
- * ]
495
495
  * })
496
496
  * class AppModule {}
497
497
  * ```
@@ -502,6 +502,15 @@ export declare interface CanDeactivate<T> {
502
502
  canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
503
503
  }
504
504
 
505
+ /**
506
+ * The signature of a function used as a `canDeactivate` guard on a `Route`.
507
+ *
508
+ * @publicApi
509
+ * @see `CanDeactivate`
510
+ * @see `Route`
511
+ */
512
+ export declare type CanDeactivateFn<T> = (component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
513
+
505
514
  /**
506
515
  * @description
507
516
  *
@@ -553,7 +562,7 @@ export declare interface CanDeactivate<T> {
553
562
  * class AppModule {}
554
563
  * ```
555
564
  *
556
- * You can alternatively provide an in-line function with the `canLoad` signature:
565
+ * You can alternatively provide an in-line function with the `CanLoadFn` signature:
557
566
  *
558
567
  * ```
559
568
  * @NgModule({
@@ -563,16 +572,10 @@ export declare interface CanDeactivate<T> {
563
572
  * path: 'team/:id',
564
573
  * component: TeamComponent,
565
574
  * loadChildren: () => import('./team').then(mod => mod.TeamModule),
566
- * canLoad: ['canLoadTeamSection']
575
+ * canLoad: [(route: Route, segments: UrlSegment[]) => true]
567
576
  * }
568
577
  * ])
569
578
  * ],
570
- * providers: [
571
- * {
572
- * provide: 'canLoadTeamSection',
573
- * useValue: (route: Route, segments: UrlSegment[]) => true
574
- * }
575
- * ]
576
579
  * })
577
580
  * class AppModule {}
578
581
  * ```
@@ -583,6 +586,15 @@ export declare interface CanLoad {
583
586
  canLoad(route: Route, segments: UrlSegment[]): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
584
587
  }
585
588
 
589
+ /**
590
+ * The signature of a function used as a `canLoad` guard on a `Route`.
591
+ *
592
+ * @publicApi
593
+ * @see `CanLoad`
594
+ * @see `Route`
595
+ */
596
+ export declare type CanLoadFn = (route: Route, segments: UrlSegment[]) => Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
597
+
586
598
  /**
587
599
  * @description
588
600
  *
@@ -642,11 +654,9 @@ export declare interface CanLoad {
642
654
  * `team/:id` URL, but would load the `NotFoundComponent` because the `Route` for `'team/:id'`
643
655
  * could not be used for a URL match but the catch-all `**` `Route` did instead.
644
656
  *
645
- * You can alternatively provide an in-line function with the `canMatch` signature:
657
+ * You can alternatively provide an in-line function with the `CanMatchFn` signature:
646
658
  *
647
659
  * ```
648
- * const CAN_MATCH_TEAM_SECTION = new InjectionToken('CanMatchTeamSection');
649
- *
650
660
  * @NgModule({
651
661
  * imports: [
652
662
  * RouterModule.forRoot([
@@ -654,7 +664,7 @@ export declare interface CanLoad {
654
664
  * path: 'team/:id',
655
665
  * component: TeamComponent,
656
666
  * loadChildren: () => import('./team').then(mod => mod.TeamModule),
657
- * canMatch: [CAN_MATCH_TEAM_SECTION]
667
+ * canMatch: [(route: Route, segments: UrlSegment[]) => true]
658
668
  * },
659
669
  * {
660
670
  * path: '**',
@@ -662,12 +672,6 @@ export declare interface CanLoad {
662
672
  * }
663
673
  * ])
664
674
  * ],
665
- * providers: [
666
- * {
667
- * provide: CAN_MATCH_TEAM_SECTION,
668
- * useValue: (route: Route, segments: UrlSegment[]) => true
669
- * }
670
- * ]
671
675
  * })
672
676
  * class AppModule {}
673
677
  * ```
@@ -1880,7 +1884,7 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
1880
1884
  * export class AppRoutingModule {}
1881
1885
  * ```
1882
1886
  *
1883
- * You can alternatively provide an in-line function with the `resolve()` signature:
1887
+ * You can alternatively provide an in-line function with the `ResolveFn` signature:
1884
1888
  *
1885
1889
  * ```
1886
1890
  * export const myHero: Hero = {
@@ -1894,17 +1898,11 @@ export declare type QueryParamsHandling = 'merge' | 'preserve' | '';
1894
1898
  * path: 'detail/:id',
1895
1899
  * component: HeroComponent,
1896
1900
  * resolve: {
1897
- * hero: 'heroResolver'
1901
+ * hero: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => myHero
1898
1902
  * }
1899
1903
  * }
1900
1904
  * ])
1901
1905
  * ],
1902
- * providers: [
1903
- * {
1904
- * provide: 'heroResolver',
1905
- * useValue: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => myHero
1906
- * }
1907
- * ]
1908
1906
  * })
1909
1907
  * export class AppModule {}
1910
1908
  * ```
@@ -1967,7 +1965,7 @@ export declare interface Resolve<T> {
1967
1965
  * @publicApi
1968
1966
  */
1969
1967
  export declare type ResolveData = {
1970
- [key: string | symbol]: any;
1968
+ [key: string | symbol]: any | ResolveFn<unknown>;
1971
1969
  };
1972
1970
 
1973
1971
  /**
@@ -1994,6 +1992,14 @@ export declare class ResolveEnd extends RouterEvent {
1994
1992
  toString(): string;
1995
1993
  }
1996
1994
 
1995
+ /**
1996
+ * Function type definition for a data provider.
1997
+ *
1998
+ * @see `Route#resolve`.
1999
+ * @publicApi
2000
+ */
2001
+ export declare type ResolveFn<T> = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => Observable<T> | Promise<T> | T;
2002
+
1997
2003
  /**
1998
2004
  * An event triggered at the start of the Resolve phase of routing.
1999
2005
  *
@@ -2254,7 +2260,7 @@ export declare interface Route {
2254
2260
  *
2255
2261
  * @see `PageTitleStrategy`
2256
2262
  */
2257
- title?: string | Type<Resolve<string>>;
2263
+ title?: string | Type<Resolve<string>> | ResolveFn<string>;
2258
2264
  /**
2259
2265
  * The path to match against. Cannot be used together with a custom `matcher` function.
2260
2266
  * A URL string that uses router matching notation.
@@ -2311,36 +2317,50 @@ export declare interface Route {
2311
2317
  */
2312
2318
  outlet?: string;
2313
2319
  /**
2314
- * An array of dependency-injection tokens used to look up `CanActivate()`
2320
+ * An array of `CanActivateFn` or DI tokens used to look up `CanActivate()`
2315
2321
  * handlers, in order to determine if the current user is allowed to
2316
2322
  * activate the component. By default, any user can activate.
2323
+ *
2324
+ * When using a function rather than DI tokens, the function can call `inject` to get any required
2325
+ * dependencies. This `inject` call must be done in a synchronous context.
2317
2326
  */
2318
- canActivate?: any[];
2327
+ canActivate?: Array<CanActivateFn | any>;
2319
2328
  /**
2320
- * An array of DI tokens used to look up `CanMatch()`
2329
+ * An array of `CanMatchFn` or DI tokens used to look up `CanMatch()`
2321
2330
  * handlers, in order to determine if the current user is allowed to
2322
2331
  * match the `Route`. By default, any route can match.
2332
+ *
2333
+ * When using a function rather than DI tokens, the function can call `inject` to get any required
2334
+ * dependencies. This `inject` call must be done in a synchronous context.
2323
2335
  */
2324
- canMatch?: Array<Type<CanMatch> | InjectionToken<CanMatchFn>>;
2336
+ canMatch?: Array<Type<CanMatch> | InjectionToken<CanMatchFn> | CanMatchFn>;
2325
2337
  /**
2326
- * An array of DI tokens used to look up `CanActivateChild()` handlers,
2338
+ * An array of `CanActivateChildFn` or DI tokens used to look up `CanActivateChild()` handlers,
2327
2339
  * in order to determine if the current user is allowed to activate
2328
2340
  * a child of the component. By default, any user can activate a child.
2341
+ *
2342
+ * When using a function rather than DI tokens, the function can call `inject` to get any required
2343
+ * dependencies. This `inject` call must be done in a synchronous context.
2329
2344
  */
2330
- canActivateChild?: any[];
2345
+ canActivateChild?: Array<CanActivateChildFn | any>;
2331
2346
  /**
2332
- * An array of DI tokens used to look up `CanDeactivate()`
2347
+ * An array of `CanDeactivateFn` or DI tokens used to look up `CanDeactivate()`
2333
2348
  * handlers, in order to determine if the current user is allowed to
2334
2349
  * deactivate the component. By default, any user can deactivate.
2335
2350
  *
2351
+ * When using a function rather than DI tokens, the function can call `inject` to get any required
2352
+ * dependencies. This `inject` call must be done in a synchronous context.
2336
2353
  */
2337
- canDeactivate?: any[];
2354
+ canDeactivate?: Array<CanDeactivateFn<any> | any>;
2338
2355
  /**
2339
- * An array of DI tokens used to look up `CanLoad()`
2356
+ * An array of `CanLoadFn` or DI tokens used to look up `CanLoad()`
2340
2357
  * handlers, in order to determine if the current user is allowed to
2341
2358
  * load the component. By default, any user can load.
2359
+ *
2360
+ * When using a function rather than DI tokens, the function can call `inject` to get any required
2361
+ * dependencies. This `inject` call must be done in a synchronous context.
2342
2362
  */
2343
- canLoad?: any[];
2363
+ canLoad?: Array<CanLoadFn | any>;
2344
2364
  /**
2345
2365
  * Additional developer-defined data provided to the component via
2346
2366
  * `ActivatedRoute`. By default, no additional data is passed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/router",
3
- "version": "14.2.0-next.0",
3
+ "version": "14.2.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": "14.2.0-next.0",
28
- "@angular/common": "14.2.0-next.0",
29
- "@angular/platform-browser": "14.2.0-next.0",
27
+ "@angular/core": "14.2.0-next.1",
28
+ "@angular/common": "14.2.0-next.1",
29
+ "@angular/platform-browser": "14.2.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 v14.2.0-next.0
2
+ * @license Angular v14.2.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 v14.2.0-next.0
2
+ * @license Angular v14.2.0-next.1
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */