UNPKG

3.38 kBTypeScriptView Raw
1import { UrlMatcher } from './urlMatcher';
2import { RawParams } from '../params';
3import { UIRouter } from '../router';
4import { UrlRuleFactory } from './urlRule';
5import { MatchResult, UrlParts, UrlRule, UrlRuleHandlerFn } from './interface';
6import { TargetState, TargetStateDef } from '../state';
7/**
8 * Updates URL and responds to URL changes
9 *
10 * ### Deprecation warning:
11 * This class is now considered to be an internal API
12 * Use the [[UrlService]] instead.
13 * For configuring URL rules, use the [[UrlRules]] which can be found as [[UrlService.rules]].
14 */
15export declare class UrlRouter {
16 private router;
17 /** used to create [[UrlRule]] objects for common cases */
18 urlRuleFactory: UrlRuleFactory;
19 /** @internal */ private location;
20 /** @internal */
21 constructor(/** @internal */ router: UIRouter);
22 /** Internal API. */
23 update(read?: boolean): void;
24 /**
25 * Internal API.
26 *
27 * Pushes a new location to the browser history.
28 *
29 * @internal
30 * @param urlMatcher
31 * @param params
32 * @param options
33 */
34 push(urlMatcher: UrlMatcher, params?: RawParams, options?: {
35 replace?: string | boolean;
36 }): void;
37 /**
38 * Builds and returns a URL with interpolated parameters
39 *
40 * #### Example:
41 * ```js
42 * matcher = $umf.compile("/about/:person");
43 * params = { person: "bob" };
44 * $bob = $urlRouter.href(matcher, params);
45 * // $bob == "/about/bob";
46 * ```
47 *
48 * @param urlMatcher The [[UrlMatcher]] object which is used as the template of the URL to generate.
49 * @param params An object of parameter values to fill the matcher's required parameters.
50 * @param options Options object. The options are:
51 *
52 * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
53 *
54 * @returns Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
55 */
56 href(urlMatcher: UrlMatcher, params?: any, options?: {
57 absolute: boolean;
58 }): string;
59 /** @deprecated use [[UrlService.sync]]*/
60 sync: (evt?: any) => void;
61 /** @deprecated use [[UrlService.listen]]*/
62 listen: (enabled?: boolean) => Function;
63 /** @deprecated use [[UrlService.deferIntercept]]*/
64 deferIntercept: (defer?: boolean) => void;
65 /** @deprecated use [[UrlService.interceptDeferred]]*/
66 interceptDeferred: boolean;
67 /** @deprecated use [[UrlService.match]]*/
68 match: (urlParts: UrlParts) => MatchResult;
69 /** @deprecated use [[UrlRules.initial]]*/
70 initial: (handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef) => void;
71 /** @deprecated use [[UrlRules.otherwise]]*/
72 otherwise: (handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef) => void;
73 /** @deprecated use [[UrlRules.removeRule]]*/
74 removeRule: (rule: UrlRule) => void;
75 /** @deprecated use [[UrlRules.rule]]*/
76 rule: (rule: UrlRule) => Function;
77 /** @deprecated use [[UrlRules.rules]]*/
78 rules: () => UrlRule[];
79 /** @deprecated use [[UrlRules.sort]]*/
80 sort: (compareFn?: (a: UrlRule, b: UrlRule) => number) => void;
81 /** @deprecated use [[UrlRules.when]]*/
82 when: (matcher: RegExp | UrlMatcher | string, handler: string | UrlRuleHandlerFn, options?: {
83 priority: number;
84 }) => UrlRule;
85}
86
\No newline at end of file