index.d.ts 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. /**
  2. * @license Angular v19.2.13
  3. * (c) 2010-2025 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { ActivatedRouteSnapshot, Params, UrlTree, RouterOutletContract, ActivatedRoute, RouterStateSnapshot, Route, LoadedRouterConfig, Router, Routes, InMemoryScrollingOptions, NavigationError, RedirectCommand, RouterConfigOptions, CanActivate, CanActivateFn, CanActivateChild, CanActivateChildFn, CanDeactivate, CanDeactivateFn, CanMatch, CanMatchFn, Resolve, ResolveFn, Event } from './router_module.d-Bx9ArA6K.js';
  7. export { ActivationEnd, ActivationStart, BaseRouteReuseStrategy, CanLoad, CanLoadFn, ChildActivationEnd, ChildActivationStart, Data, DefaultExport, DefaultUrlSerializer, DeprecatedGuard, DetachedRouteHandle, EventType, ExtraOptions, GuardResult, GuardsCheckEnd, GuardsCheckStart, InitialNavigation, IsActiveMatchOptions, LoadChildren, LoadChildrenCallback, MaybeAsync, Navigation, NavigationBehaviorOptions, NavigationCancel, NavigationCancellationCode, NavigationEnd, NavigationExtras, NavigationSkipped, NavigationSkippedCode, NavigationStart, OnSameUrlNavigation, PRIMARY_OUTLET, ParamMap, QueryParamsHandling, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, ROUTER_OUTLET_DATA, RedirectFunction, ResolveData, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, RouterEvent, RouterLink, RouterLinkActive, RouterLink as RouterLinkWithHref, RouterModule, RouterOutlet, RouterState, RoutesRecognized, RunGuardsAndResolvers, Scroll, UrlCreationOptions, UrlMatchResult, UrlMatcher, UrlSegment, UrlSegmentGroup, UrlSerializer, convertToParamMap, defaultUrlMatcher, ɵEmptyOutletComponent, ROUTER_PROVIDERS as ɵROUTER_PROVIDERS, RestoredState as ɵRestoredState } from './router_module.d-Bx9ArA6K.js';
  8. import { Title } from '@angular/platform-browser';
  9. import * as i0 from '@angular/core';
  10. import { EnvironmentInjector, ComponentRef, InjectionToken, Type, Injector, Compiler, OnDestroy, Provider, EnvironmentProviders, Version } from '@angular/core';
  11. import { Observable } from 'rxjs';
  12. import '@angular/common';
  13. /**
  14. * Creates a `UrlTree` relative to an `ActivatedRouteSnapshot`.
  15. *
  16. * @publicApi
  17. *
  18. *
  19. * @param relativeTo The `ActivatedRouteSnapshot` to apply the commands to
  20. * @param commands An array of URL fragments with which to construct the new URL tree.
  21. * If the path is static, can be the literal URL string. For a dynamic path, pass an array of path
  22. * segments, followed by the parameters for each segment.
  23. * The fragments are applied to the one provided in the `relativeTo` parameter.
  24. * @param queryParams The query parameters for the `UrlTree`. `null` if the `UrlTree` does not have
  25. * any query parameters.
  26. * @param fragment The fragment for the `UrlTree`. `null` if the `UrlTree` does not have a fragment.
  27. *
  28. * @usageNotes
  29. *
  30. * ```ts
  31. * // create /team/33/user/11
  32. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, 'user', 11]);
  33. *
  34. * // create /team/33;expand=true/user/11
  35. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {expand: true}, 'user', 11]);
  36. *
  37. * // you can collapse static segments like this (this works only with the first passed-in value):
  38. * createUrlTreeFromSnapshot(snapshot, ['/team/33/user', userId]);
  39. *
  40. * // If the first segment can contain slashes, and you do not want the router to split it,
  41. * // you can do the following:
  42. * createUrlTreeFromSnapshot(snapshot, [{segmentPath: '/one/two'}]);
  43. *
  44. * // create /team/33/(user/11//right:chat)
  45. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {outlets: {primary: 'user/11', right:
  46. * 'chat'}}], null, null);
  47. *
  48. * // remove the right secondary node
  49. * createUrlTreeFromSnapshot(snapshot, ['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  50. *
  51. * // For the examples below, assume the current URL is for the `/team/33/user/11` and the
  52. * `ActivatedRouteSnapshot` points to `user/11`:
  53. *
  54. * // navigate to /team/33/user/11/details
  55. * createUrlTreeFromSnapshot(snapshot, ['details']);
  56. *
  57. * // navigate to /team/33/user/22
  58. * createUrlTreeFromSnapshot(snapshot, ['../22']);
  59. *
  60. * // navigate to /team/44/user/22
  61. * createUrlTreeFromSnapshot(snapshot, ['../../team/44/user/22']);
  62. * ```
  63. */
  64. declare function createUrlTreeFromSnapshot(relativeTo: ActivatedRouteSnapshot, commands: any[], queryParams?: Params | null, fragment?: string | null): UrlTree;
  65. /**
  66. * Store contextual information about a `RouterOutlet`
  67. *
  68. * @publicApi
  69. */
  70. declare class OutletContext {
  71. private readonly rootInjector;
  72. outlet: RouterOutletContract | null;
  73. route: ActivatedRoute | null;
  74. children: ChildrenOutletContexts;
  75. attachRef: ComponentRef<any> | null;
  76. get injector(): EnvironmentInjector;
  77. constructor(rootInjector: EnvironmentInjector);
  78. }
  79. /**
  80. * Store contextual information about the children (= nested) `RouterOutlet`
  81. *
  82. * @publicApi
  83. */
  84. declare class ChildrenOutletContexts {
  85. private rootInjector;
  86. private contexts;
  87. /** @docs-private */
  88. constructor(rootInjector: EnvironmentInjector);
  89. /** Called when a `RouterOutlet` directive is instantiated */
  90. onChildOutletCreated(childName: string, outlet: RouterOutletContract): void;
  91. /**
  92. * Called when a `RouterOutlet` directive is destroyed.
  93. * We need to keep the context as the outlet could be destroyed inside a NgIf and might be
  94. * re-created later.
  95. */
  96. onChildOutletDestroyed(childName: string): void;
  97. /**
  98. * Called when the corresponding route is deactivated during navigation.
  99. * Because the component get destroyed, all children outlet are destroyed.
  100. */
  101. onOutletDeactivated(): Map<string, OutletContext>;
  102. onOutletReAttached(contexts: Map<string, OutletContext>): void;
  103. getOrCreateContext(childName: string): OutletContext;
  104. getContext(childName: string): OutletContext | null;
  105. static ɵfac: i0.ɵɵFactoryDeclaration<ChildrenOutletContexts, never>;
  106. static ɵprov: i0.ɵɵInjectableDeclaration<ChildrenOutletContexts>;
  107. }
  108. /**
  109. * Options to configure the View Transitions integration in the Router.
  110. *
  111. * @experimental
  112. * @publicApi
  113. * @see withViewTransitions
  114. */
  115. interface ViewTransitionsFeatureOptions {
  116. /**
  117. * Skips the very first call to `startViewTransition`. This can be useful for disabling the
  118. * animation during the application's initial loading phase.
  119. */
  120. skipInitialTransition?: boolean;
  121. /**
  122. * A function to run after the `ViewTransition` is created.
  123. *
  124. * This function is run in an injection context and can use `inject`.
  125. */
  126. onViewTransitionCreated?: (transitionInfo: ViewTransitionInfo) => void;
  127. }
  128. /**
  129. * The information passed to the `onViewTransitionCreated` function provided in the
  130. * `withViewTransitions` feature options.
  131. *
  132. * @publicApi
  133. * @experimental
  134. */
  135. interface ViewTransitionInfo {
  136. /**
  137. * The `ViewTransition` returned by the call to `startViewTransition`.
  138. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition
  139. */
  140. transition: {
  141. /**
  142. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/finished
  143. */
  144. finished: Promise<void>;
  145. /**
  146. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/ready
  147. */
  148. ready: Promise<void>;
  149. /**
  150. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/updateCallbackDone
  151. */
  152. updateCallbackDone: Promise<void>;
  153. /**
  154. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition/skipTransition
  155. */
  156. skipTransition(): void;
  157. /**
  158. * @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition#browser_compatibility
  159. * @see https://developer.chrome.com/docs/web-platform/view-transitions/same-document#default_style_and_transition_reference
  160. */
  161. readonly types: Set<string>;
  162. };
  163. /**
  164. * The `ActivatedRouteSnapshot` that the navigation is transitioning from.
  165. */
  166. from: ActivatedRouteSnapshot;
  167. /**
  168. * The `ActivatedRouteSnapshot` that the navigation is transitioning to.
  169. */
  170. to: ActivatedRouteSnapshot;
  171. }
  172. /**
  173. * Provides a strategy for setting the page title after a router navigation.
  174. *
  175. * The built-in implementation traverses the router state snapshot and finds the deepest primary
  176. * outlet with `title` property. Given the `Routes` below, navigating to
  177. * `/base/child(popup:aux)` would result in the document title being set to "child".
  178. * ```ts
  179. * [
  180. * {path: 'base', title: 'base', children: [
  181. * {path: 'child', title: 'child'},
  182. * ],
  183. * {path: 'aux', outlet: 'popup', title: 'popupTitle'}
  184. * ]
  185. * ```
  186. *
  187. * This class can be used as a base class for custom title strategies. That is, you can create your
  188. * own class that extends the `TitleStrategy`. Note that in the above example, the `title`
  189. * from the named outlet is never used. However, a custom strategy might be implemented to
  190. * incorporate titles in named outlets.
  191. *
  192. * @publicApi
  193. * @see [Page title guide](guide/routing/common-router-tasks#setting-the-page-title)
  194. */
  195. declare abstract class TitleStrategy {
  196. /** Performs the application title update. */
  197. abstract updateTitle(snapshot: RouterStateSnapshot): void;
  198. /**
  199. * @returns The `title` of the deepest primary route.
  200. */
  201. buildTitle(snapshot: RouterStateSnapshot): string | undefined;
  202. /**
  203. * Given an `ActivatedRouteSnapshot`, returns the final value of the
  204. * `Route.title` property, which can either be a static string or a resolved value.
  205. */
  206. getResolvedTitleForRoute(snapshot: ActivatedRouteSnapshot): any;
  207. static ɵfac: i0.ɵɵFactoryDeclaration<TitleStrategy, never>;
  208. static ɵprov: i0.ɵɵInjectableDeclaration<TitleStrategy>;
  209. }
  210. /**
  211. * The default `TitleStrategy` used by the router that updates the title using the `Title` service.
  212. */
  213. declare class DefaultTitleStrategy extends TitleStrategy {
  214. readonly title: Title;
  215. constructor(title: Title);
  216. /**
  217. * Sets the title of the browser to the given value.
  218. *
  219. * @param title The `pageTitle` from the deepest primary route.
  220. */
  221. updateTitle(snapshot: RouterStateSnapshot): void;
  222. static ɵfac: i0.ɵɵFactoryDeclaration<DefaultTitleStrategy, never>;
  223. static ɵprov: i0.ɵɵInjectableDeclaration<DefaultTitleStrategy>;
  224. }
  225. /**
  226. * The DI token for a router configuration.
  227. *
  228. * `ROUTES` is a low level API for router configuration via dependency injection.
  229. *
  230. * We recommend that in almost all cases to use higher level APIs such as `RouterModule.forRoot()`,
  231. * `provideRouter`, or `Router.resetConfig()`.
  232. *
  233. * @publicApi
  234. */
  235. declare const ROUTES: InjectionToken<Route[][]>;
  236. declare class RouterConfigLoader {
  237. private componentLoaders;
  238. private childrenLoaders;
  239. onLoadStartListener?: (r: Route) => void;
  240. onLoadEndListener?: (r: Route) => void;
  241. private readonly compiler;
  242. loadComponent(route: Route): Observable<Type<unknown>>;
  243. loadChildren(parentInjector: Injector, route: Route): Observable<LoadedRouterConfig>;
  244. static ɵfac: i0.ɵɵFactoryDeclaration<RouterConfigLoader, never>;
  245. static ɵprov: i0.ɵɵInjectableDeclaration<RouterConfigLoader>;
  246. }
  247. /**
  248. * Executes a `route.loadChildren` callback and converts the result to an array of child routes and
  249. * an injector if that callback returned a module.
  250. *
  251. * This function is used for the route discovery during prerendering
  252. * in @angular-devkit/build-angular. If there are any updates to the contract here, it will require
  253. * an update to the extractor.
  254. */
  255. declare function loadChildren(route: Route, compiler: Compiler, parentInjector: Injector, onLoadEndListener?: (r: Route) => void): Observable<LoadedRouterConfig>;
  256. /**
  257. * @description
  258. *
  259. * Provides a preloading strategy.
  260. *
  261. * @publicApi
  262. */
  263. declare abstract class PreloadingStrategy {
  264. abstract preload(route: Route, fn: () => Observable<any>): Observable<any>;
  265. }
  266. /**
  267. * @description
  268. *
  269. * Provides a preloading strategy that preloads all modules as quickly as possible.
  270. *
  271. * ```ts
  272. * RouterModule.forRoot(ROUTES, {preloadingStrategy: PreloadAllModules})
  273. * ```
  274. *
  275. * @publicApi
  276. */
  277. declare class PreloadAllModules implements PreloadingStrategy {
  278. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  279. static ɵfac: i0.ɵɵFactoryDeclaration<PreloadAllModules, never>;
  280. static ɵprov: i0.ɵɵInjectableDeclaration<PreloadAllModules>;
  281. }
  282. /**
  283. * @description
  284. *
  285. * Provides a preloading strategy that does not preload any modules.
  286. *
  287. * This strategy is enabled by default.
  288. *
  289. * @publicApi
  290. */
  291. declare class NoPreloading implements PreloadingStrategy {
  292. preload(route: Route, fn: () => Observable<any>): Observable<any>;
  293. static ɵfac: i0.ɵɵFactoryDeclaration<NoPreloading, never>;
  294. static ɵprov: i0.ɵɵInjectableDeclaration<NoPreloading>;
  295. }
  296. /**
  297. * The preloader optimistically loads all router configurations to
  298. * make navigations into lazily-loaded sections of the application faster.
  299. *
  300. * The preloader runs in the background. When the router bootstraps, the preloader
  301. * starts listening to all navigation events. After every such event, the preloader
  302. * will check if any configurations can be loaded lazily.
  303. *
  304. * If a route is protected by `canLoad` guards, the preloaded will not load it.
  305. *
  306. * @publicApi
  307. */
  308. declare class RouterPreloader implements OnDestroy {
  309. private router;
  310. private injector;
  311. private preloadingStrategy;
  312. private loader;
  313. private subscription?;
  314. constructor(router: Router, injector: EnvironmentInjector, preloadingStrategy: PreloadingStrategy, loader: RouterConfigLoader);
  315. setUpPreloading(): void;
  316. preload(): Observable<any>;
  317. /** @docs-private */
  318. ngOnDestroy(): void;
  319. private processRoutes;
  320. private preloadConfig;
  321. static ɵfac: i0.ɵɵFactoryDeclaration<RouterPreloader, never>;
  322. static ɵprov: i0.ɵɵInjectableDeclaration<RouterPreloader>;
  323. }
  324. /**
  325. * Sets up providers necessary to enable `Router` functionality for the application.
  326. * Allows to configure a set of routes as well as extra features that should be enabled.
  327. *
  328. * @usageNotes
  329. *
  330. * Basic example of how you can add a Router to your application:
  331. * ```ts
  332. * const appRoutes: Routes = [];
  333. * bootstrapApplication(AppComponent, {
  334. * providers: [provideRouter(appRoutes)]
  335. * });
  336. * ```
  337. *
  338. * You can also enable optional features in the Router by adding functions from the `RouterFeatures`
  339. * type:
  340. * ```ts
  341. * const appRoutes: Routes = [];
  342. * bootstrapApplication(AppComponent,
  343. * {
  344. * providers: [
  345. * provideRouter(appRoutes,
  346. * withDebugTracing(),
  347. * withRouterConfig({paramsInheritanceStrategy: 'always'}))
  348. * ]
  349. * }
  350. * );
  351. * ```
  352. *
  353. * @see {@link RouterFeatures}
  354. *
  355. * @publicApi
  356. * @param routes A set of `Route`s to use for the application routing table.
  357. * @param features Optional features to configure additional router behaviors.
  358. * @returns A set of providers to setup a Router.
  359. */
  360. declare function provideRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders;
  361. /**
  362. * Helper type to represent a Router feature.
  363. *
  364. * @publicApi
  365. */
  366. interface RouterFeature<FeatureKind extends RouterFeatureKind> {
  367. ɵkind: FeatureKind;
  368. ɵproviders: Array<Provider | EnvironmentProviders>;
  369. }
  370. /**
  371. * Registers a DI provider for a set of routes.
  372. * @param routes The route configuration to provide.
  373. *
  374. * @usageNotes
  375. *
  376. * ```ts
  377. * @NgModule({
  378. * providers: [provideRoutes(ROUTES)]
  379. * })
  380. * class LazyLoadedChildModule {}
  381. * ```
  382. *
  383. * @deprecated If necessary, provide routes using the `ROUTES` `InjectionToken`.
  384. * @see {@link ROUTES}
  385. * @publicApi
  386. */
  387. declare function provideRoutes(routes: Routes): Provider[];
  388. /**
  389. * A type alias for providers returned by `withInMemoryScrolling` for use with `provideRouter`.
  390. *
  391. * @see {@link withInMemoryScrolling}
  392. * @see {@link provideRouter}
  393. *
  394. * @publicApi
  395. */
  396. type InMemoryScrollingFeature = RouterFeature<RouterFeatureKind.InMemoryScrollingFeature>;
  397. /**
  398. * Enables customizable scrolling behavior for router navigations.
  399. *
  400. * @usageNotes
  401. *
  402. * Basic example of how you can enable scrolling feature:
  403. * ```ts
  404. * const appRoutes: Routes = [];
  405. * bootstrapApplication(AppComponent,
  406. * {
  407. * providers: [
  408. * provideRouter(appRoutes, withInMemoryScrolling())
  409. * ]
  410. * }
  411. * );
  412. * ```
  413. *
  414. * @see {@link provideRouter}
  415. * @see {@link ViewportScroller}
  416. *
  417. * @publicApi
  418. * @param options Set of configuration parameters to customize scrolling behavior, see
  419. * `InMemoryScrollingOptions` for additional information.
  420. * @returns A set of providers for use with `provideRouter`.
  421. */
  422. declare function withInMemoryScrolling(options?: InMemoryScrollingOptions): InMemoryScrollingFeature;
  423. /**
  424. * A type alias for providers returned by `withEnabledBlockingInitialNavigation` for use with
  425. * `provideRouter`.
  426. *
  427. * @see {@link withEnabledBlockingInitialNavigation}
  428. * @see {@link provideRouter}
  429. *
  430. * @publicApi
  431. */
  432. type EnabledBlockingInitialNavigationFeature = RouterFeature<RouterFeatureKind.EnabledBlockingInitialNavigationFeature>;
  433. /**
  434. * A type alias for providers returned by `withEnabledBlockingInitialNavigation` or
  435. * `withDisabledInitialNavigation` functions for use with `provideRouter`.
  436. *
  437. * @see {@link withEnabledBlockingInitialNavigation}
  438. * @see {@link withDisabledInitialNavigation}
  439. * @see {@link provideRouter}
  440. *
  441. * @publicApi
  442. */
  443. type InitialNavigationFeature = EnabledBlockingInitialNavigationFeature | DisabledInitialNavigationFeature;
  444. /**
  445. * Configures initial navigation to start before the root component is created.
  446. *
  447. * The bootstrap is blocked until the initial navigation is complete. This should be set in case
  448. * you use [server-side rendering](guide/ssr), but do not enable [hydration](guide/hydration) for
  449. * your application.
  450. *
  451. * @usageNotes
  452. *
  453. * Basic example of how you can enable this navigation behavior:
  454. * ```ts
  455. * const appRoutes: Routes = [];
  456. * bootstrapApplication(AppComponent,
  457. * {
  458. * providers: [
  459. * provideRouter(appRoutes, withEnabledBlockingInitialNavigation())
  460. * ]
  461. * }
  462. * );
  463. * ```
  464. *
  465. * @see {@link provideRouter}
  466. *
  467. * @publicApi
  468. * @returns A set of providers for use with `provideRouter`.
  469. */
  470. declare function withEnabledBlockingInitialNavigation(): EnabledBlockingInitialNavigationFeature;
  471. /**
  472. * A type alias for providers returned by `withDisabledInitialNavigation` for use with
  473. * `provideRouter`.
  474. *
  475. * @see {@link withDisabledInitialNavigation}
  476. * @see {@link provideRouter}
  477. *
  478. * @publicApi
  479. */
  480. type DisabledInitialNavigationFeature = RouterFeature<RouterFeatureKind.DisabledInitialNavigationFeature>;
  481. /**
  482. * Disables initial navigation.
  483. *
  484. * Use if there is a reason to have more control over when the router starts its initial navigation
  485. * due to some complex initialization logic.
  486. *
  487. * @usageNotes
  488. *
  489. * Basic example of how you can disable initial navigation:
  490. * ```ts
  491. * const appRoutes: Routes = [];
  492. * bootstrapApplication(AppComponent,
  493. * {
  494. * providers: [
  495. * provideRouter(appRoutes, withDisabledInitialNavigation())
  496. * ]
  497. * }
  498. * );
  499. * ```
  500. *
  501. * @see {@link provideRouter}
  502. *
  503. * @returns A set of providers for use with `provideRouter`.
  504. *
  505. * @publicApi
  506. */
  507. declare function withDisabledInitialNavigation(): DisabledInitialNavigationFeature;
  508. /**
  509. * A type alias for providers returned by `withDebugTracing` for use with `provideRouter`.
  510. *
  511. * @see {@link withDebugTracing}
  512. * @see {@link provideRouter}
  513. *
  514. * @publicApi
  515. */
  516. type DebugTracingFeature = RouterFeature<RouterFeatureKind.DebugTracingFeature>;
  517. /**
  518. * Enables logging of all internal navigation events to the console.
  519. * Extra logging might be useful for debugging purposes to inspect Router event sequence.
  520. *
  521. * @usageNotes
  522. *
  523. * Basic example of how you can enable debug tracing:
  524. * ```ts
  525. * const appRoutes: Routes = [];
  526. * bootstrapApplication(AppComponent,
  527. * {
  528. * providers: [
  529. * provideRouter(appRoutes, withDebugTracing())
  530. * ]
  531. * }
  532. * );
  533. * ```
  534. *
  535. * @see {@link provideRouter}
  536. *
  537. * @returns A set of providers for use with `provideRouter`.
  538. *
  539. * @publicApi
  540. */
  541. declare function withDebugTracing(): DebugTracingFeature;
  542. /**
  543. * A type alias that represents a feature which enables preloading in Router.
  544. * The type is used to describe the return value of the `withPreloading` function.
  545. *
  546. * @see {@link withPreloading}
  547. * @see {@link provideRouter}
  548. *
  549. * @publicApi
  550. */
  551. type PreloadingFeature = RouterFeature<RouterFeatureKind.PreloadingFeature>;
  552. /**
  553. * Allows to configure a preloading strategy to use. The strategy is configured by providing a
  554. * reference to a class that implements a `PreloadingStrategy`.
  555. *
  556. * @usageNotes
  557. *
  558. * Basic example of how you can configure preloading:
  559. * ```ts
  560. * const appRoutes: Routes = [];
  561. * bootstrapApplication(AppComponent,
  562. * {
  563. * providers: [
  564. * provideRouter(appRoutes, withPreloading(PreloadAllModules))
  565. * ]
  566. * }
  567. * );
  568. * ```
  569. *
  570. * @see {@link provideRouter}
  571. *
  572. * @param preloadingStrategy A reference to a class that implements a `PreloadingStrategy` that
  573. * should be used.
  574. * @returns A set of providers for use with `provideRouter`.
  575. *
  576. * @publicApi
  577. */
  578. declare function withPreloading(preloadingStrategy: Type<PreloadingStrategy>): PreloadingFeature;
  579. /**
  580. * A type alias for providers returned by `withRouterConfig` for use with `provideRouter`.
  581. *
  582. * @see {@link withRouterConfig}
  583. * @see {@link provideRouter}
  584. *
  585. * @publicApi
  586. */
  587. type RouterConfigurationFeature = RouterFeature<RouterFeatureKind.RouterConfigurationFeature>;
  588. /**
  589. * Allows to provide extra parameters to configure Router.
  590. *
  591. * @usageNotes
  592. *
  593. * Basic example of how you can provide extra configuration options:
  594. * ```ts
  595. * const appRoutes: Routes = [];
  596. * bootstrapApplication(AppComponent,
  597. * {
  598. * providers: [
  599. * provideRouter(appRoutes, withRouterConfig({
  600. * onSameUrlNavigation: 'reload'
  601. * }))
  602. * ]
  603. * }
  604. * );
  605. * ```
  606. *
  607. * @see {@link provideRouter}
  608. *
  609. * @param options A set of parameters to configure Router, see `RouterConfigOptions` for
  610. * additional information.
  611. * @returns A set of providers for use with `provideRouter`.
  612. *
  613. * @publicApi
  614. */
  615. declare function withRouterConfig(options: RouterConfigOptions): RouterConfigurationFeature;
  616. /**
  617. * A type alias for providers returned by `withHashLocation` for use with `provideRouter`.
  618. *
  619. * @see {@link withHashLocation}
  620. * @see {@link provideRouter}
  621. *
  622. * @publicApi
  623. */
  624. type RouterHashLocationFeature = RouterFeature<RouterFeatureKind.RouterHashLocationFeature>;
  625. /**
  626. * Provides the location strategy that uses the URL fragment instead of the history API.
  627. *
  628. * @usageNotes
  629. *
  630. * Basic example of how you can use the hash location option:
  631. * ```ts
  632. * const appRoutes: Routes = [];
  633. * bootstrapApplication(AppComponent,
  634. * {
  635. * providers: [
  636. * provideRouter(appRoutes, withHashLocation())
  637. * ]
  638. * }
  639. * );
  640. * ```
  641. *
  642. * @see {@link provideRouter}
  643. * @see {@link /api/common/HashLocationStrategy HashLocationStrategy}
  644. *
  645. * @returns A set of providers for use with `provideRouter`.
  646. *
  647. * @publicApi
  648. */
  649. declare function withHashLocation(): RouterHashLocationFeature;
  650. /**
  651. * A type alias for providers returned by `withNavigationErrorHandler` for use with `provideRouter`.
  652. *
  653. * @see {@link withNavigationErrorHandler}
  654. * @see {@link provideRouter}
  655. *
  656. * @publicApi
  657. */
  658. type NavigationErrorHandlerFeature = RouterFeature<RouterFeatureKind.NavigationErrorHandlerFeature>;
  659. /**
  660. * Provides a function which is called when a navigation error occurs.
  661. *
  662. * This function is run inside application's [injection context](guide/di/dependency-injection-context)
  663. * so you can use the [`inject`](api/core/inject) function.
  664. *
  665. * This function can return a `RedirectCommand` to convert the error to a redirect, similar to returning
  666. * a `UrlTree` or `RedirectCommand` from a guard. This will also prevent the `Router` from emitting
  667. * `NavigationError`; it will instead emit `NavigationCancel` with code NavigationCancellationCode.Redirect.
  668. * Return values other than `RedirectCommand` are ignored and do not change any behavior with respect to
  669. * how the `Router` handles the error.
  670. *
  671. * @usageNotes
  672. *
  673. * Basic example of how you can use the error handler option:
  674. * ```ts
  675. * const appRoutes: Routes = [];
  676. * bootstrapApplication(AppComponent,
  677. * {
  678. * providers: [
  679. * provideRouter(appRoutes, withNavigationErrorHandler((e: NavigationError) =>
  680. * inject(MyErrorTracker).trackError(e)))
  681. * ]
  682. * }
  683. * );
  684. * ```
  685. *
  686. * @see {@link NavigationError}
  687. * @see {@link /api/core/inject inject}
  688. * @see {@link runInInjectionContext}
  689. *
  690. * @returns A set of providers for use with `provideRouter`.
  691. *
  692. * @publicApi
  693. */
  694. declare function withNavigationErrorHandler(handler: (error: NavigationError) => unknown | RedirectCommand): NavigationErrorHandlerFeature;
  695. /**
  696. * A type alias for providers returned by `withComponentInputBinding` for use with `provideRouter`.
  697. *
  698. * @see {@link withComponentInputBinding}
  699. * @see {@link provideRouter}
  700. *
  701. * @publicApi
  702. */
  703. type ComponentInputBindingFeature = RouterFeature<RouterFeatureKind.ComponentInputBindingFeature>;
  704. /**
  705. * A type alias for providers returned by `withViewTransitions` for use with `provideRouter`.
  706. *
  707. * @see {@link withViewTransitions}
  708. * @see {@link provideRouter}
  709. *
  710. * @publicApi
  711. */
  712. type ViewTransitionsFeature = RouterFeature<RouterFeatureKind.ViewTransitionsFeature>;
  713. /**
  714. * Enables binding information from the `Router` state directly to the inputs of the component in
  715. * `Route` configurations.
  716. *
  717. * @usageNotes
  718. *
  719. * Basic example of how you can enable the feature:
  720. * ```ts
  721. * const appRoutes: Routes = [];
  722. * bootstrapApplication(AppComponent,
  723. * {
  724. * providers: [
  725. * provideRouter(appRoutes, withComponentInputBinding())
  726. * ]
  727. * }
  728. * );
  729. * ```
  730. *
  731. * The router bindings information from any of the following sources:
  732. *
  733. * - query parameters
  734. * - path and matrix parameters
  735. * - static route data
  736. * - data from resolvers
  737. *
  738. * Duplicate keys are resolved in the same order from above, from least to greatest,
  739. * meaning that resolvers have the highest precedence and override any of the other information
  740. * from the route.
  741. *
  742. * Importantly, when an input does not have an item in the route data with a matching key, this
  743. * input is set to `undefined`. This prevents previous information from being
  744. * retained if the data got removed from the route (i.e. if a query parameter is removed).
  745. * Default values can be provided with a resolver on the route to ensure the value is always present
  746. * or an input and use an input transform in the component.
  747. *
  748. * @see {@link /guide/components/inputs#input-transforms Input Transforms}
  749. * @returns A set of providers for use with `provideRouter`.
  750. */
  751. declare function withComponentInputBinding(): ComponentInputBindingFeature;
  752. /**
  753. * Enables view transitions in the Router by running the route activation and deactivation inside of
  754. * `document.startViewTransition`.
  755. *
  756. * Note: The View Transitions API is not available in all browsers. If the browser does not support
  757. * view transitions, the Router will not attempt to start a view transition and continue processing
  758. * the navigation as usual.
  759. *
  760. * @usageNotes
  761. *
  762. * Basic example of how you can enable the feature:
  763. * ```ts
  764. * const appRoutes: Routes = [];
  765. * bootstrapApplication(AppComponent,
  766. * {
  767. * providers: [
  768. * provideRouter(appRoutes, withViewTransitions())
  769. * ]
  770. * }
  771. * );
  772. * ```
  773. *
  774. * @returns A set of providers for use with `provideRouter`.
  775. * @see https://developer.chrome.com/docs/web-platform/view-transitions/
  776. * @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
  777. * @developerPreview
  778. */
  779. declare function withViewTransitions(options?: ViewTransitionsFeatureOptions): ViewTransitionsFeature;
  780. /**
  781. * A type alias that represents all Router features available for use with `provideRouter`.
  782. * Features can be enabled by adding special functions to the `provideRouter` call.
  783. * See documentation for each symbol to find corresponding function name. See also `provideRouter`
  784. * documentation on how to use those functions.
  785. *
  786. * @see {@link provideRouter}
  787. *
  788. * @publicApi
  789. */
  790. type RouterFeatures = PreloadingFeature | DebugTracingFeature | InitialNavigationFeature | InMemoryScrollingFeature | RouterConfigurationFeature | NavigationErrorHandlerFeature | ComponentInputBindingFeature | ViewTransitionsFeature | RouterHashLocationFeature;
  791. /**
  792. * The list of features as an enum to uniquely type each feature.
  793. */
  794. declare const enum RouterFeatureKind {
  795. PreloadingFeature = 0,
  796. DebugTracingFeature = 1,
  797. EnabledBlockingInitialNavigationFeature = 2,
  798. DisabledInitialNavigationFeature = 3,
  799. InMemoryScrollingFeature = 4,
  800. RouterConfigurationFeature = 5,
  801. RouterHashLocationFeature = 6,
  802. NavigationErrorHandlerFeature = 7,
  803. ComponentInputBindingFeature = 8,
  804. ViewTransitionsFeature = 9
  805. }
  806. /**
  807. * @description
  808. *
  809. * Provides a way to migrate AngularJS applications to Angular.
  810. *
  811. * @publicApi
  812. */
  813. declare abstract class UrlHandlingStrategy {
  814. /**
  815. * Tells the router if this URL should be processed.
  816. *
  817. * When it returns true, the router will execute the regular navigation.
  818. * When it returns false, the router will set the router state to an empty state.
  819. * As a result, all the active components will be destroyed.
  820. *
  821. */
  822. abstract shouldProcessUrl(url: UrlTree): boolean;
  823. /**
  824. * Extracts the part of the URL that should be handled by the router.
  825. * The rest of the URL will remain untouched.
  826. */
  827. abstract extract(url: UrlTree): UrlTree;
  828. /**
  829. * Merges the URL fragment with the rest of the URL.
  830. */
  831. abstract merge(newUrlPart: UrlTree, rawUrl: UrlTree): UrlTree;
  832. static ɵfac: i0.ɵɵFactoryDeclaration<UrlHandlingStrategy, never>;
  833. static ɵprov: i0.ɵɵInjectableDeclaration<UrlHandlingStrategy>;
  834. }
  835. /**
  836. * Maps an array of injectable classes with canMatch functions to an array of equivalent
  837. * `CanMatchFn` for use in a `Route` definition.
  838. *
  839. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  840. *
  841. * @publicApi
  842. * @see {@link Route}
  843. */
  844. declare function mapToCanMatch(providers: Array<Type<CanMatch>>): CanMatchFn[];
  845. /**
  846. * Maps an array of injectable classes with canActivate functions to an array of equivalent
  847. * `CanActivateFn` for use in a `Route` definition.
  848. *
  849. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  850. *
  851. * @publicApi
  852. * @see {@link Route}
  853. */
  854. declare function mapToCanActivate(providers: Array<Type<CanActivate>>): CanActivateFn[];
  855. /**
  856. * Maps an array of injectable classes with canActivateChild functions to an array of equivalent
  857. * `CanActivateChildFn` for use in a `Route` definition.
  858. *
  859. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  860. *
  861. * @publicApi
  862. * @see {@link Route}
  863. */
  864. declare function mapToCanActivateChild(providers: Array<Type<CanActivateChild>>): CanActivateChildFn[];
  865. /**
  866. * Maps an array of injectable classes with canDeactivate functions to an array of equivalent
  867. * `CanDeactivateFn` for use in a `Route` definition.
  868. *
  869. * Usage {@example router/utils/functional_guards.ts region='CanActivate'}
  870. *
  871. * @publicApi
  872. * @see {@link Route}
  873. */
  874. declare function mapToCanDeactivate<T = unknown>(providers: Array<Type<CanDeactivate<T>>>): CanDeactivateFn<T>[];
  875. /**
  876. * Maps an injectable class with a resolve function to an equivalent `ResolveFn`
  877. * for use in a `Route` definition.
  878. *
  879. * Usage {@example router/utils/functional_guards.ts region='Resolve'}
  880. *
  881. * @publicApi
  882. * @see {@link Route}
  883. */
  884. declare function mapToResolve<T>(provider: Type<Resolve<T>>): ResolveFn<T>;
  885. /**
  886. * @module
  887. * @description
  888. * Entry point for all public APIs of the router package.
  889. */
  890. /**
  891. * @publicApi
  892. */
  893. declare const VERSION: Version;
  894. /**
  895. * Performs the given action once the router finishes its next/current navigation.
  896. *
  897. * The navigation is considered complete under the following conditions:
  898. * - `NavigationCancel` event emits and the code is not `NavigationCancellationCode.Redirect` or
  899. * `NavigationCancellationCode.SupersededByNewNavigation`. In these cases, the
  900. * redirecting/superseding navigation must finish.
  901. * - `NavigationError`, `NavigationEnd`, or `NavigationSkipped` event emits
  902. */
  903. declare function afterNextNavigation(router: {
  904. events: Observable<Event>;
  905. }, action: () => void): void;
  906. export { ActivatedRoute, ActivatedRouteSnapshot, CanActivate, CanActivateChild, CanActivateChildFn, CanActivateFn, CanDeactivate, CanDeactivateFn, CanMatch, CanMatchFn, ChildrenOutletContexts, DefaultTitleStrategy, Event, InMemoryScrollingOptions, NavigationError, NoPreloading, OutletContext, Params, PreloadAllModules, PreloadingStrategy, ROUTES, RedirectCommand, Resolve, ResolveFn, Route, Router, RouterConfigOptions, RouterOutletContract, RouterPreloader, RouterStateSnapshot, Routes, TitleStrategy, UrlHandlingStrategy, UrlTree, VERSION, createUrlTreeFromSnapshot, mapToCanActivate, mapToCanActivateChild, mapToCanDeactivate, mapToCanMatch, mapToResolve, provideRouter, provideRoutes, withComponentInputBinding, withDebugTracing, withDisabledInitialNavigation, withEnabledBlockingInitialNavigation, withHashLocation, withInMemoryScrolling, withNavigationErrorHandler, withPreloading, withRouterConfig, withViewTransitions, afterNextNavigation as ɵafterNextNavigation, loadChildren as ɵloadChildren };
  907. export type { ComponentInputBindingFeature, DebugTracingFeature, DisabledInitialNavigationFeature, EnabledBlockingInitialNavigationFeature, InMemoryScrollingFeature, InitialNavigationFeature, NavigationErrorHandlerFeature, PreloadingFeature, RouterConfigurationFeature, RouterFeature, RouterFeatures, RouterHashLocationFeature, ViewTransitionInfo, ViewTransitionsFeature, ViewTransitionsFeatureOptions };