PageRenderTime 37ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/client/node_modules/@angular/router/src/router.d.ts

https://gitlab.com/Adongo/Blog-Site-final
TypeScript Typings | 443 lines | 123 code | 0 blank | 320 comment | 6 complexity | 76ca11271c2fa710466834473caa2d29 MD5 | raw file
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. import { Location } from '@angular/common';
  9. import { Compiler, Injector, NgModuleFactoryLoader, Type } from '@angular/core';
  10. import { Observable } from 'rxjs/Observable';
  11. import { Routes } from './config';
  12. import { RouterOutletMap } from './router_outlet_map';
  13. import { ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot } from './router_state';
  14. import { Params } from './shared';
  15. import { UrlSerializer, UrlTree } from './url_tree';
  16. import { TreeNode } from './utils/tree';
  17. /**
  18. * @whatItDoes Represents the extra options used during navigation.
  19. *
  20. * @stable
  21. */
  22. export interface NavigationExtras {
  23. /**
  24. * Enables relative navigation from the current ActivatedRoute.
  25. *
  26. * Configuration:
  27. *
  28. * ```
  29. * [{
  30. * path: 'parent',
  31. * component: ParentComponent,
  32. * children: [
  33. * {
  34. * path: 'list',
  35. * component: ListComponent
  36. * },
  37. * {
  38. * path: 'child',
  39. * component: ChildComponent
  40. * }
  41. * ]
  42. * }]
  43. * ```
  44. *
  45. * Navigate to list route from child route:
  46. *
  47. * ```
  48. * @Component({...})
  49. * class ChildComponent {
  50. * constructor(private router: Router, private route: ActivatedRoute) {}
  51. *
  52. * go() {
  53. * this.router.navigate(['../list'], { relativeTo: this.route });
  54. * }
  55. * }
  56. * ```
  57. */
  58. relativeTo?: ActivatedRoute;
  59. /**
  60. * Sets query parameters to the URL.
  61. *
  62. * ```
  63. * // Navigate to /results?page=1
  64. * this.router.navigate(['/results'], { queryParams: { page: 1 } });
  65. * ```
  66. */
  67. queryParams?: Params;
  68. /**
  69. * Sets the hash fragment for the URL.
  70. *
  71. * ```
  72. * // Navigate to /results#top
  73. * this.router.navigate(['/results'], { fragment: 'top' });
  74. * ```
  75. */
  76. fragment?: string;
  77. /**
  78. * Preserves the query parameters for the next navigation.
  79. *
  80. * ```
  81. * // Preserve query params from /results?page=1 to /view?page=1
  82. * this.router.navigate(['/view'], { preserveQueryParams: true });
  83. * ```
  84. */
  85. preserveQueryParams?: boolean;
  86. /**
  87. * Preserves the fragment for the next navigation
  88. *
  89. * ```
  90. * // Preserve fragment from /results#top to /view#top
  91. * this.router.navigate(['/view'], { preserveFragment: true });
  92. * ```
  93. */
  94. preserveFragment?: boolean;
  95. /**
  96. * Navigates without pushing a new state into history.
  97. *
  98. * ```
  99. * // Navigate silently to /view
  100. * this.router.navigate(['/view'], { skipLocationChange: true });
  101. * ```
  102. */
  103. skipLocationChange?: boolean;
  104. /**
  105. * Navigates while replacing the current state in history.
  106. *
  107. * ```
  108. * // Navigate to /view
  109. * this.router.navigate(['/view'], { replaceUrl: true });
  110. * ```
  111. */
  112. replaceUrl?: boolean;
  113. }
  114. /**
  115. * @whatItDoes Represents an event triggered when a navigation starts.
  116. *
  117. * @stable
  118. */
  119. export declare class NavigationStart {
  120. /** @docsNotRequired */
  121. id: number;
  122. /** @docsNotRequired */
  123. url: string;
  124. constructor(
  125. /** @docsNotRequired */
  126. id: number,
  127. /** @docsNotRequired */
  128. url: string);
  129. /** @docsNotRequired */
  130. toString(): string;
  131. }
  132. /**
  133. * @whatItDoes Represents an event triggered when a navigation ends successfully.
  134. *
  135. * @stable
  136. */
  137. export declare class NavigationEnd {
  138. /** @docsNotRequired */
  139. id: number;
  140. /** @docsNotRequired */
  141. url: string;
  142. /** @docsNotRequired */
  143. urlAfterRedirects: string;
  144. constructor(
  145. /** @docsNotRequired */
  146. id: number,
  147. /** @docsNotRequired */
  148. url: string,
  149. /** @docsNotRequired */
  150. urlAfterRedirects: string);
  151. /** @docsNotRequired */
  152. toString(): string;
  153. }
  154. /**
  155. * @whatItDoes Represents an event triggered when a navigation is canceled.
  156. *
  157. * @stable
  158. */
  159. export declare class NavigationCancel {
  160. /** @docsNotRequired */
  161. id: number;
  162. /** @docsNotRequired */
  163. url: string;
  164. /** @docsNotRequired */
  165. reason: string;
  166. constructor(
  167. /** @docsNotRequired */
  168. id: number,
  169. /** @docsNotRequired */
  170. url: string,
  171. /** @docsNotRequired */
  172. reason: string);
  173. /** @docsNotRequired */
  174. toString(): string;
  175. }
  176. /**
  177. * @whatItDoes Represents an event triggered when a navigation fails due to an unexpected error.
  178. *
  179. * @stable
  180. */
  181. export declare class NavigationError {
  182. /** @docsNotRequired */
  183. id: number;
  184. /** @docsNotRequired */
  185. url: string;
  186. /** @docsNotRequired */
  187. error: any;
  188. constructor(
  189. /** @docsNotRequired */
  190. id: number,
  191. /** @docsNotRequired */
  192. url: string,
  193. /** @docsNotRequired */
  194. error: any);
  195. /** @docsNotRequired */
  196. toString(): string;
  197. }
  198. /**
  199. * @whatItDoes Represents an event triggered when routes are recognized.
  200. *
  201. * @stable
  202. */
  203. export declare class RoutesRecognized {
  204. /** @docsNotRequired */
  205. id: number;
  206. /** @docsNotRequired */
  207. url: string;
  208. /** @docsNotRequired */
  209. urlAfterRedirects: string;
  210. /** @docsNotRequired */
  211. state: RouterStateSnapshot;
  212. constructor(
  213. /** @docsNotRequired */
  214. id: number,
  215. /** @docsNotRequired */
  216. url: string,
  217. /** @docsNotRequired */
  218. urlAfterRedirects: string,
  219. /** @docsNotRequired */
  220. state: RouterStateSnapshot);
  221. /** @docsNotRequired */
  222. toString(): string;
  223. }
  224. /**
  225. * @whatItDoes Represents a router event.
  226. *
  227. * Please see {@link NavigationStart}, {@link NavigationEnd}, {@link NavigationCancel}, {@link
  228. * NavigationError},
  229. * {@link RoutesRecognized} for more information.
  230. *
  231. * @stable
  232. */
  233. export declare type Event = NavigationStart | NavigationEnd | NavigationCancel | NavigationError | RoutesRecognized;
  234. /**
  235. * @whatItDoes Error handler that is invoked when a navigation errors.
  236. *
  237. * @description
  238. * If the handler returns a value, the navigation promise will be resolved with this value.
  239. * If the handler throws an exception, the navigation promise will be rejected with
  240. * the exception.
  241. *
  242. * @stable
  243. */
  244. export declare type ErrorHandler = (error: any) => any;
  245. /**
  246. * @whatItDoes Provides the navigation and url manipulation capabilities.
  247. *
  248. * See {@link Routes} for more details and examples.
  249. *
  250. * @ngModule RouterModule
  251. *
  252. * @stable
  253. */
  254. export declare class Router {
  255. private rootComponentType;
  256. private urlSerializer;
  257. private outletMap;
  258. private location;
  259. private injector;
  260. config: Routes;
  261. private currentUrlTree;
  262. private currentRouterState;
  263. private locationSubscription;
  264. private routerEvents;
  265. private navigationId;
  266. private configLoader;
  267. /**
  268. * Error handler that is invoked when a navigation errors.
  269. *
  270. * See {@link ErrorHandler} for more information.
  271. */
  272. errorHandler: ErrorHandler;
  273. /**
  274. * Indicates if at least one navigation happened.
  275. */
  276. navigated: boolean;
  277. /**
  278. * Creates the router service.
  279. */
  280. constructor(rootComponentType: Type<any>, urlSerializer: UrlSerializer, outletMap: RouterOutletMap, location: Location, injector: Injector, loader: NgModuleFactoryLoader, compiler: Compiler, config: Routes);
  281. /**
  282. * Sets up the location change listener and performs the initial navigation.
  283. */
  284. initialNavigation(): void;
  285. /**
  286. * Sets up the location change listener.
  287. */
  288. setUpLocationChangeListener(): void;
  289. /**
  290. * Returns the current route state.
  291. */
  292. routerState: RouterState;
  293. /**
  294. * Returns the current url.
  295. */
  296. url: string;
  297. /**
  298. * Returns an observable of route events
  299. */
  300. events: Observable<Event>;
  301. /**
  302. * Resets the configuration used for navigation and generating links.
  303. *
  304. * ### Usage
  305. *
  306. * ```
  307. * router.resetConfig([
  308. * { path: 'team/:id', component: TeamCmp, children: [
  309. * { path: 'simple', component: SimpleCmp },
  310. * { path: 'user/:name', component: UserCmp }
  311. * ] }
  312. * ]);
  313. * ```
  314. */
  315. resetConfig(config: Routes): void;
  316. /**
  317. * @docsNotRequired
  318. */
  319. ngOnDestroy(): void;
  320. /**
  321. * Disposes of the router.
  322. */
  323. dispose(): void;
  324. /**
  325. * Applies an array of commands to the current url tree and creates a new url tree.
  326. *
  327. * When given an activate route, applies the given commands starting from the route.
  328. * When not given a route, applies the given command starting from the root.
  329. *
  330. * ### Usage
  331. *
  332. * ```
  333. * // create /team/33/user/11
  334. * router.createUrlTree(['/team', 33, 'user', 11]);
  335. *
  336. * // create /team/33;expand=true/user/11
  337. * router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]);
  338. *
  339. * // you can collapse static segments like this (this works only with the first passed-in value):
  340. * router.createUrlTree(['/team/33/user', userId]);
  341. *
  342. * // If the first segment can contain slashes, and you do not want the router to split it, you
  343. * // can do the following:
  344. *
  345. * router.createUrlTree([{segmentPath: '/one/two'}]);
  346. *
  347. * // create /team/33/(user/11//right:chat)
  348. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]);
  349. *
  350. * // remove the right secondary node
  351. * router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]);
  352. *
  353. * // assuming the current url is `/team/33/user/11` and the route points to `user/11`
  354. *
  355. * // navigate to /team/33/user/11/details
  356. * router.createUrlTree(['details'], {relativeTo: route});
  357. *
  358. * // navigate to /team/33/user/22
  359. * router.createUrlTree(['../22'], {relativeTo: route});
  360. *
  361. * // navigate to /team/44/user/22
  362. * router.createUrlTree(['../../team/44/user/22'], {relativeTo: route});
  363. * ```
  364. */
  365. createUrlTree(commands: any[], {relativeTo, queryParams, fragment, preserveQueryParams, preserveFragment}?: NavigationExtras): UrlTree;
  366. /**
  367. * Navigate based on the provided url. This navigation is always absolute.
  368. *
  369. * Returns a promise that:
  370. * - is resolved with 'true' when navigation succeeds
  371. * - is resolved with 'false' when navigation fails
  372. * - is rejected when an error happens
  373. *
  374. * ### Usage
  375. *
  376. * ```
  377. * router.navigateByUrl("/team/33/user/11");
  378. *
  379. * // Navigate without updating the URL
  380. * router.navigateByUrl("/team/33/user/11", { skipLocationChange: true });
  381. * ```
  382. *
  383. * In opposite to `navigate`, `navigateByUrl` takes a whole URL
  384. * and does not apply any delta to the current one.
  385. */
  386. navigateByUrl(url: string | UrlTree, extras?: NavigationExtras): Promise<boolean>;
  387. /**
  388. * Navigate based on the provided array of commands and a starting point.
  389. * If no starting route is provided, the navigation is absolute.
  390. *
  391. * Returns a promise that:
  392. * - is resolved with 'true' when navigation succeeds
  393. * - is resolved with 'false' when navigation fails
  394. * - is rejected when an error happens
  395. *
  396. * ### Usage
  397. *
  398. * ```
  399. * router.navigate(['team', 33, 'user', 11], {relativeTo: route});
  400. *
  401. * // Navigate without updating the URL
  402. * router.navigate(['team', 33, 'user', 11], {relativeTo: route, skipLocationChange: true });
  403. * ```
  404. *
  405. * In opposite to `navigateByUrl`, `navigate` always takes a delta
  406. * that is applied to the current URL.
  407. */
  408. navigate(commands: any[], extras?: NavigationExtras): Promise<boolean>;
  409. /**
  410. * Serializes a {@link UrlTree} into a string.
  411. */
  412. serializeUrl(url: UrlTree): string;
  413. /**
  414. * Parses a string into a {@link UrlTree}.
  415. */
  416. parseUrl(url: string): UrlTree;
  417. /**
  418. * Returns if the url is activated or not.
  419. */
  420. isActive(url: string | UrlTree, exact: boolean): boolean;
  421. private scheduleNavigation(url, extras);
  422. private runNavigate(url, shouldPreventPushState, shouldReplaceUrl, id);
  423. }
  424. export declare class PreActivation {
  425. private future;
  426. private curr;
  427. private injector;
  428. private checks;
  429. constructor(future: RouterStateSnapshot, curr: RouterStateSnapshot, injector: Injector);
  430. traverse(parentOutletMap: RouterOutletMap): void;
  431. checkGuards(): Observable<boolean>;
  432. resolveData(): Observable<any>;
  433. private traverseChildRoutes(futureNode, currNode, outletMap, futurePath);
  434. traverseRoutes(futureNode: TreeNode<ActivatedRouteSnapshot>, currNode: TreeNode<ActivatedRouteSnapshot>, parentOutletMap: RouterOutletMap, futurePath: ActivatedRouteSnapshot[]): void;
  435. private deactiveRouteAndItsChildren(route, outlet);
  436. private runCanActivate(future);
  437. private runCanActivateChild(path);
  438. private extractCanActivateChild(p);
  439. private runCanDeactivate(component, curr);
  440. private runResolve(future);
  441. private resolveNode(resolve, future);
  442. private getToken(token, snapshot);
  443. }