@angular-wave/angular.ts 0.0.60 → 0.0.61

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 (119) hide show
  1. package/README.md +1 -1
  2. package/dist/angular-ts.esm.js +2 -2
  3. package/dist/angular-ts.umd.js +2 -2
  4. package/package.json +1 -1
  5. package/src/core/parser/parse.js +14 -0
  6. package/src/core/parser/parser.js +1 -1
  7. package/src/core/q/q.js +46 -289
  8. package/src/core/q/q.md +229 -0
  9. package/src/core/sanitize/sanitize-uri.js +2 -3
  10. package/src/core/scope/scope.js +18 -8
  11. package/src/directive/if/if.js +6 -1
  12. package/src/filters/limit-to.js +5 -2
  13. package/src/loader.js +1 -5
  14. package/src/router/params/param-type.js +2 -1
  15. package/src/router/state/views.js +3 -0
  16. package/src/router/transition/reject-factory.js +1 -0
  17. package/src/router/url/url-rule.js +1 -1
  18. package/src/router/url/url-service.js +4 -4
  19. package/src/services/http/http.js +7 -5
  20. package/src/services/template-request.js +2 -7
  21. package/src/shared/common.js +1 -1
  22. package/src/shared/utils.js +1 -1
  23. package/src/types.js +9 -1
  24. package/types/core/parser/parse.d.ts +3 -4
  25. package/types/core/parser/parser.d.ts +1 -1
  26. package/types/core/q/q.d.ts +2 -2
  27. package/types/core/sanitize/sanitize-uri.d.ts +4 -5
  28. package/types/core/scope/scope.d.ts +19 -7
  29. package/types/loader.d.ts +0 -4
  30. package/types/router/params/param-type.d.ts +2 -1
  31. package/types/router/state/views.d.ts +2 -0
  32. package/types/router/transition/reject-factory.d.ts +1 -0
  33. package/types/router/url/url-rule.d.ts +0 -1
  34. package/types/router/url/url-service.d.ts +7 -7
  35. package/types/services/template-request.d.ts +4 -9
  36. package/types/types.d.ts +6 -1
  37. package/types-back/README.md +0 -2
  38. package/types-back/angular.d.ts +0 -146
  39. package/types-back/index.d.ts +0 -2126
  40. package/types-back/jqlite.d.ts +0 -374
  41. package/types-back/router/core/common/common.d.ts +0 -416
  42. package/types-back/router/core/common/coreservices.d.ts +0 -77
  43. package/types-back/router/core/common/glob.d.ts +0 -60
  44. package/types-back/router/core/common/hof.d.ts +0 -168
  45. package/types-back/router/core/common/index.d.ts +0 -8
  46. package/types-back/router/core/common/predicates.d.ts +0 -25
  47. package/types-back/router/core/common/queue.d.ts +0 -15
  48. package/types-back/router/core/common/safeConsole.d.ts +0 -5
  49. package/types-back/router/core/common/strings.d.ts +0 -66
  50. package/types-back/router/core/common/trace.d.ts +0 -126
  51. package/types-back/router/core/globals.d.ts +0 -43
  52. package/types-back/router/core/hooks/coreResolvables.d.ts +0 -6
  53. package/types-back/router/core/hooks/ignoredTransition.d.ts +0 -4
  54. package/types-back/router/core/hooks/invalidTransition.d.ts +0 -4
  55. package/types-back/router/core/hooks/lazyLoad.d.ts +0 -17
  56. package/types-back/router/core/hooks/onEnterExitRetain.d.ts +0 -10
  57. package/types-back/router/core/hooks/redirectTo.d.ts +0 -4
  58. package/types-back/router/core/hooks/resolve.d.ts +0 -11
  59. package/types-back/router/core/hooks/updateGlobals.d.ts +0 -4
  60. package/types-back/router/core/hooks/url.d.ts +0 -4
  61. package/types-back/router/core/hooks/views.d.ts +0 -7
  62. package/types-back/router/core/index.d.ts +0 -11
  63. package/types-back/router/core/interface.d.ts +0 -91
  64. package/types-back/router/core/params/index.d.ts +0 -12
  65. package/types-back/router/core/params/interface.d.ts +0 -606
  66. package/types-back/router/core/params/param.d.ts +0 -77
  67. package/types-back/router/core/params/paramType.d.ts +0 -65
  68. package/types-back/router/core/params/paramTypes.d.ts +0 -193
  69. package/types-back/router/core/params/stateParams.d.ts +0 -15
  70. package/types-back/router/core/path/index.d.ts +0 -2
  71. package/types-back/router/core/path/pathNode.d.ts +0 -60
  72. package/types-back/router/core/path/pathUtils.d.ts +0 -105
  73. package/types-back/router/core/resolve/index.d.ts +0 -3
  74. package/types-back/router/core/resolve/interface.d.ts +0 -210
  75. package/types-back/router/core/resolve/resolvable.d.ts +0 -75
  76. package/types-back/router/core/resolve/resolveContext.d.ts +0 -97
  77. package/types-back/router/core/router.d.ts +0 -57
  78. package/types-back/router/core/state/index.d.ts +0 -28
  79. package/types-back/router/core/state/interface.d.ts +0 -732
  80. package/types-back/router/core/state/stateBuilder.d.ts +0 -107
  81. package/types-back/router/core/state/stateMatcher.d.ts +0 -13
  82. package/types-back/router/core/state/stateObject.d.ts +0 -170
  83. package/types-back/router/core/state/stateQueueManager.d.ts +0 -27
  84. package/types-back/router/core/state/stateRegistry.d.ts +0 -138
  85. package/types-back/router/core/state/stateService.d.ts +0 -386
  86. package/types-back/router/core/state/targetState.d.ts +0 -105
  87. package/types-back/router/core/transition/hookBuilder.d.ts +0 -49
  88. package/types-back/router/core/transition/hookRegistry.d.ts +0 -115
  89. package/types-back/router/core/transition/index.d.ts +0 -20
  90. package/types-back/router/core/transition/interface.d.ts +0 -862
  91. package/types-back/router/core/transition/rejectFactory.d.ts +0 -103
  92. package/types-back/router/core/transition/transition.d.ts +0 -575
  93. package/types-back/router/core/transition/transitionEventType.d.ts +0 -26
  94. package/types-back/router/core/transition/transitionHook.d.ts +0 -96
  95. package/types-back/router/core/transition/transitionService.d.ts +0 -253
  96. package/types-back/router/core/url/index.d.ts +0 -8
  97. package/types-back/router/core/url/interface.d.ts +0 -169
  98. package/types-back/router/core/url/urlConfig.d.ts +0 -144
  99. package/types-back/router/core/url/urlMatcher.d.ts +0 -185
  100. package/types-back/router/core/url/urlMatcherFactory.d.ts +0 -56
  101. package/types-back/router/core/url/urlRouter.d.ts +0 -101
  102. package/types-back/router/core/url/urlRule.d.ts +0 -143
  103. package/types-back/router/core/url/urlRules.d.ts +0 -251
  104. package/types-back/router/core/url/urlService.d.ts +0 -205
  105. package/types-back/router/core/view/index.d.ts +0 -2
  106. package/types-back/router/core/view/interface.d.ts +0 -46
  107. package/types-back/router/core/view/view.d.ts +0 -176
  108. package/types-back/router/directives/viewDirective.d.ts +0 -144
  109. package/types-back/router/index.d.ts +0 -17
  110. package/types-back/router/interface.d.ts +0 -500
  111. package/types-back/router/legacy/resolveService.d.ts +0 -47
  112. package/types-back/router/legacy/stateEvents.d.ts +0 -124
  113. package/types-back/router/services.d.ts +0 -15
  114. package/types-back/router/stateFilters.d.ts +0 -10
  115. package/types-back/router/stateProvider.d.ts +0 -258
  116. package/types-back/router/statebuilders/onEnterExitRetain.d.ts +0 -13
  117. package/types-back/router/statebuilders/views.d.ts +0 -53
  118. package/types-back/router/templateFactory.d.ts +0 -104
  119. package/types-back/router/viewScroll.d.ts +0 -9
@@ -1,185 +0,0 @@
1
- import { Param } from "../params/param";
2
- import { ParamTypes } from "../params/paramTypes";
3
- import { RawParams } from "../params/interface";
4
- import { UrlMatcherCompileConfig } from "./interface";
5
- import { ParamFactory } from "./urlMatcherFactory";
6
- /**
7
- * Matches URLs against patterns.
8
- *
9
- * Matches URLs against patterns and extracts named parameters from the path or the search
10
- * part of the URL.
11
- *
12
- * A URL pattern consists of a path pattern, optionally followed by '?' and a list of search (query)
13
- * parameters. Multiple search parameter names are separated by '&'. Search parameters
14
- * do not influence whether or not a URL is matched, but their values are passed through into
15
- * the matched parameters returned by [[UrlMatcher.exec]].
16
- *
17
- * - *Path parameters* are defined using curly brace placeholders (`/somepath/{param}`)
18
- * or colon placeholders (`/somePath/:param`).
19
- *
20
- * - *A parameter RegExp* may be defined for a param after a colon
21
- * (`/somePath/{param:[a-zA-Z0-9]+}`) in a curly brace placeholder.
22
- * The regexp must match for the url to be matched.
23
- * Should the regexp itself contain curly braces, they must be in matched pairs or escaped with a backslash.
24
- *
25
- * Note: a RegExp parameter will encode its value using either [[ParamTypes.path]] or [[ParamTypes.query]].
26
- *
27
- * - *Custom parameter types* may also be specified after a colon (`/somePath/{param:int}`) in curly brace parameters.
28
- * See [[UrlMatcherFactory.type]] for more information.
29
- *
30
- * - *Catch-all parameters* are defined using an asterisk placeholder (`/somepath/*catchallparam`).
31
- * A catch-all * parameter value will contain the remainder of the URL.
32
- *
33
- * ---
34
- *
35
- * Parameter names may contain only word characters (latin letters, digits, and underscore) and
36
- * must be unique within the pattern (across both path and search parameters).
37
- * A path parameter matches any number of characters other than '/'. For catch-all
38
- * placeholders the path parameter matches any number of characters.
39
- *
40
- * Examples:
41
- *
42
- * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for
43
- * trailing slashes, and patterns have to match the entire path, not just a prefix.
44
- * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or
45
- * '/user/bob/details'. The second path segment will be captured as the parameter 'id'.
46
- * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax.
47
- * * `'/user/{id:[^/]*}'` - Same as the previous example.
48
- * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id
49
- * parameter consists of 1 to 8 hex digits.
50
- * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the
51
- * path into the parameter 'path'.
52
- * * `'/files/*path'` - ditto.
53
- * * `'/calendar/{start:date}'` - Matches "/calendar/2014-11-12" (because the pattern defined
54
- * in the built-in `date` ParamType matches `2014-11-12`) and provides a Date object in $stateParams.start
55
- *
56
- */
57
- export declare class UrlMatcher {
58
- /** @internal */
59
- static nameValidator: RegExp;
60
- /** @internal */
61
- private _cache;
62
- /** @internal */
63
- private _children;
64
- /** @internal */
65
- private _params;
66
- /** @internal */
67
- private _segments;
68
- /** @internal */
69
- private _compiled;
70
- /** @internal */
71
- private readonly config;
72
- /** The pattern that was passed into the constructor */
73
- pattern: string;
74
- /** @internal */
75
- static encodeDashes(str: string): string;
76
- /** @internal Given a matcher, return an array with the matcher's path segments and path params, in order */
77
- static pathSegmentsAndParams(matcher: UrlMatcher): any;
78
- /** @internal Given a matcher, return an array with the matcher's query params */
79
- static queryParams(matcher: UrlMatcher): Param[];
80
- /**
81
- * Compare two UrlMatchers
82
- *
83
- * This comparison function converts a UrlMatcher into static and dynamic path segments.
84
- * Each static path segment is a static string between a path separator (slash character).
85
- * Each dynamic segment is a path parameter.
86
- *
87
- * The comparison function sorts static segments before dynamic ones.
88
- */
89
- static compare(a: UrlMatcher, b: UrlMatcher): number;
90
- /**
91
- * @param pattern The pattern to compile into a matcher.
92
- * @param paramTypes The [[ParamTypes]] registry
93
- * @param paramFactory A [[ParamFactory]] object
94
- * @param config A [[UrlMatcherCompileConfig]] configuration object
95
- */
96
- constructor(
97
- pattern: string,
98
- paramTypes: ParamTypes,
99
- paramFactory: ParamFactory,
100
- config?: UrlMatcherCompileConfig,
101
- );
102
- /**
103
- * Creates a new concatenated UrlMatcher
104
- *
105
- * Builds a new UrlMatcher by appending another UrlMatcher to this one.
106
- *
107
- * @param url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
108
- */
109
- append(url: UrlMatcher): UrlMatcher;
110
- /** @internal */
111
- isRoot(): boolean;
112
- /** Returns the input pattern string */
113
- toString(): string;
114
- private _getDecodedParamValue;
115
- /**
116
- * Tests the specified url/path against this matcher.
117
- *
118
- * Tests if the given url matches this matcher's pattern, and returns an object containing the captured
119
- * parameter values. Returns null if the path does not match.
120
- *
121
- * The returned object contains the values
122
- * of any search parameters that are mentioned in the pattern, but their value may be null if
123
- * they are not present in `search`. This means that search parameters are always treated
124
- * as optional.
125
- *
126
- * #### Example:
127
- * ```js
128
- * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
129
- * x: '1', q: 'hello'
130
- * });
131
- * // returns { id: 'bob', q: 'hello', r: null }
132
- * ```
133
- *
134
- * @param path The URL path to match, e.g. `$location.path()`.
135
- * @param search URL search parameters, e.g. `$location.search()`.
136
- * @param hash URL hash e.g. `$location.hash()`.
137
- * @param options
138
- *
139
- * @returns The captured parameter values.
140
- */
141
- exec(path: string, search?: any, hash?: string, options?: any): RawParams;
142
- /**
143
- * @internal
144
- * Returns all the [[Param]] objects of all path and search parameters of this pattern in order of appearance.
145
- *
146
- * @returns {Array.<Param>} An array of [[Param]] objects. Must be treated as read-only. If the
147
- * pattern has no parameters, an empty array is returned.
148
- */
149
- parameters(opts?: any): Param[];
150
- /**
151
- * @internal
152
- * Returns a single parameter from this UrlMatcher by id
153
- *
154
- * @param id
155
- * @param opts
156
- * @returns {T|Param|any|boolean|UrlMatcher|null}
157
- */
158
- parameter(id: string, opts?: any): Param;
159
- /**
160
- * Validates the input parameter values against this UrlMatcher
161
- *
162
- * Checks an object hash of parameters to validate their correctness according to the parameter
163
- * types of this `UrlMatcher`.
164
- *
165
- * @param params The object hash of parameters to validate.
166
- * @returns Returns `true` if `params` validates, otherwise `false`.
167
- */
168
- validates(params: RawParams): boolean;
169
- /**
170
- * Given a set of parameter values, creates a URL from this UrlMatcher.
171
- *
172
- * Creates a URL that matches this pattern by substituting the specified values
173
- * for the path and search parameters.
174
- *
175
- * #### Example:
176
- * ```js
177
- * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
178
- * // returns '/user/bob?q=yes'
179
- * ```
180
- *
181
- * @param values the values to substitute for the parameters in this pattern.
182
- * @returns the formatted URL (path and optionally search part).
183
- */
184
- format(values?: RawParams): string;
185
- }
@@ -1,56 +0,0 @@
1
- import { UrlMatcher } from "./urlMatcher";
2
- import { Param, ParamType, ParamTypeDefinition } from "../params";
3
- import { UrlMatcherCompileConfig } from "./interface";
4
- import { StateDeclaration } from "../state";
5
- import { Router } from "../router";
6
- export declare class ParamFactory {
7
- private router;
8
- fromConfig(id: string, type: ParamType, state: StateDeclaration): Param;
9
- fromPath(id: string, type: ParamType, state: StateDeclaration): Param;
10
- fromSearch(id: string, type: ParamType, state: StateDeclaration): Param;
11
- constructor(router: Router);
12
- }
13
- /**
14
- * Factory for [[UrlMatcher]] instances.
15
- *
16
- * The factory is available to ng1 services as
17
- * `$urlMatcherFactory` or ng1 providers as `$urlServiceProvider`.
18
- */
19
- export declare class UrlMatcherFactory {
20
- private router;
21
- /** Creates a new [[Param]] for a given location (DefType) */
22
- paramFactory: ParamFactory;
23
- UrlMatcher: typeof UrlMatcher;
24
- Param: typeof Param;
25
- constructor(/** @internal */ router: Router);
26
- /**
27
- * Creates a [[UrlMatcher]] for the specified pattern.
28
- *
29
- * @param pattern The URL pattern.
30
- * @param config The config object hash.
31
- * @returns The UrlMatcher.
32
- */
33
- compile(pattern: string, config?: UrlMatcherCompileConfig): UrlMatcher;
34
- /**
35
- * Returns true if the specified object is a [[UrlMatcher]], or false otherwise.
36
- *
37
- * @param object The object to perform the type check against.
38
- * @returns `true` if the object matches the `UrlMatcher` interface, by
39
- * implementing all the same methods.
40
- */
41
- isMatcher(object: any): boolean;
42
- /** @internal */
43
- $get(): this;
44
- /** @deprecated use [[UrlConfig.caseInsensitive]] */
45
- caseInsensitive: (value?: boolean) => boolean;
46
- /** @deprecated use [[UrlConfig.defaultSquashPolicy]] */
47
- defaultSquashPolicy: (value?: boolean | string) => string | boolean;
48
- /** @deprecated use [[UrlConfig.strictMode]] */
49
- strictMode: (value?: boolean) => boolean;
50
- /** @deprecated use [[UrlConfig.type]] */
51
- type: (
52
- name: string,
53
- definition?: ParamTypeDefinition,
54
- definitionFn?: () => ParamTypeDefinition,
55
- ) => any;
56
- }
@@ -1,101 +0,0 @@
1
- import { UrlMatcher } from "./urlMatcher";
2
- import { RawParams } from "../params";
3
- import { Router } from "../router";
4
- import { UrlRuleFactory } from "./urlRule";
5
- import { MatchResult, UrlParts, UrlRule, UrlRuleHandlerFn } from "./interface";
6
- import { 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
- */
15
- export 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: Router);
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(
35
- urlMatcher: UrlMatcher,
36
- params?: RawParams,
37
- options?: {
38
- replace?: string | boolean;
39
- },
40
- ): void;
41
- /**
42
- * Builds and returns a URL with interpolated parameters
43
- *
44
- * #### Example:
45
- * ```js
46
- * matcher = $umf.compile("/about/:person");
47
- * params = { person: "bob" };
48
- * $bob = $urlRouter.href(matcher, params);
49
- * // $bob == "/about/bob";
50
- * ```
51
- *
52
- * @param urlMatcher The [[UrlMatcher]] object which is used as the template of the URL to generate.
53
- * @param params An object of parameter values to fill the matcher's required parameters.
54
- * @param options Options object. The options are:
55
- *
56
- * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
57
- *
58
- * @returns Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
59
- */
60
- href(
61
- urlMatcher: UrlMatcher,
62
- params?: any,
63
- options?: {
64
- absolute: boolean;
65
- },
66
- ): string;
67
- /** @deprecated use [[UrlService.sync]]*/
68
- sync: (evt?: any) => void;
69
- /** @deprecated use [[UrlService.listen]]*/
70
- listen: (enabled?: boolean) => Function;
71
- /** @deprecated use [[UrlService.deferIntercept]]*/
72
- deferIntercept: (defer?: boolean) => void;
73
- /** @deprecated use [[UrlService.interceptDeferred]]*/
74
- interceptDeferred: boolean;
75
- /** @deprecated use [[UrlService.match]]*/
76
- match: (urlParts: UrlParts) => MatchResult;
77
- /** @deprecated use [[UrlRules.initial]]*/
78
- initial: (
79
- handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef,
80
- ) => void;
81
- /** @deprecated use [[UrlRules.otherwise]]*/
82
- otherwise: (
83
- handler: string | UrlRuleHandlerFn | TargetState | TargetStateDef,
84
- ) => void;
85
- /** @deprecated use [[UrlRules.removeRule]]*/
86
- removeRule: (rule: UrlRule) => void;
87
- /** @deprecated use [[UrlRules.rule]]*/
88
- rule: (rule: UrlRule) => Function;
89
- /** @deprecated use [[UrlRules.rules]]*/
90
- rules: () => UrlRule[];
91
- /** @deprecated use [[UrlRules.sort]]*/
92
- sort: (compareFn?: (a: UrlRule, b: UrlRule) => number) => void;
93
- /** @deprecated use [[UrlRules.when]]*/
94
- when: (
95
- matcher: RegExp | UrlMatcher | string,
96
- handler: string | UrlRuleHandlerFn,
97
- options?: {
98
- priority: number;
99
- },
100
- ) => UrlRule;
101
- }
@@ -1,143 +0,0 @@
1
- import { StateDeclaration } from "../state";
2
- import { UrlMatcher } from "./urlMatcher";
3
- import { Router } from "../router";
4
- import { StateObject } from "../state/stateObject";
5
- import {
6
- UrlRule,
7
- UrlRuleMatchFn,
8
- UrlRuleHandlerFn,
9
- UrlRuleType,
10
- MatcherUrlRule,
11
- StateRule,
12
- RegExpRule,
13
- } from "./interface";
14
- /**
15
- * Creates a [[UrlRule]]
16
- *
17
- * Creates a [[UrlRule]] from a:
18
- *
19
- * - `string`
20
- * - [[UrlMatcher]]
21
- * - `RegExp`
22
- * - [[StateObject]]
23
- */
24
- export declare class UrlRuleFactory {
25
- router: Router;
26
- static isUrlRule: (obj: any) => boolean;
27
- constructor(router: Router);
28
- compile(str: string): UrlMatcher;
29
- create(
30
- what:
31
- | string
32
- | UrlMatcher
33
- | StateObject
34
- | StateDeclaration
35
- | RegExp
36
- | UrlRuleMatchFn,
37
- handler?: string | UrlRuleHandlerFn,
38
- ): UrlRule;
39
- /**
40
- * A UrlRule which matches based on a UrlMatcher
41
- *
42
- * The `handler` may be either a `string`, a [[UrlRuleHandlerFn]] or another [[UrlMatcher]]
43
- *
44
- * ## Handler as a function
45
- *
46
- * If `handler` is a function, the function is invoked with:
47
- *
48
- * - matched parameter values ([[RawParams]] from [[UrlMatcher.exec]])
49
- * - url: the current Url ([[UrlParts]])
50
- * - router: the router object ([[Router]])
51
- *
52
- * #### Example:
53
- * ```js
54
- * var urlMatcher = $umf.compile("/foo/:fooId/:barId");
55
- * var rule = factory.fromUrlMatcher(urlMatcher, match => "/home/" + match.fooId + "/" + match.barId);
56
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
57
- * var result = rule.handler(match); // '/home/123/456'
58
- * ```
59
- *
60
- * ## Handler as UrlMatcher
61
- *
62
- * If `handler` is a UrlMatcher, the handler matcher is used to create the new url.
63
- * The `handler` UrlMatcher is formatted using the matched param from the first matcher.
64
- * The url is replaced with the result.
65
- *
66
- * #### Example:
67
- * ```js
68
- * var urlMatcher = $umf.compile("/foo/:fooId/:barId");
69
- * var handler = $umf.compile("/home/:fooId/:barId");
70
- * var rule = factory.fromUrlMatcher(urlMatcher, handler);
71
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
72
- * var result = rule.handler(match); // '/home/123/456'
73
- * ```
74
- */
75
- fromUrlMatcher(
76
- urlMatcher: UrlMatcher,
77
- handler: string | UrlMatcher | UrlRuleHandlerFn,
78
- ): MatcherUrlRule;
79
- /**
80
- * A UrlRule which matches a state by its url
81
- *
82
- * #### Example:
83
- * ```js
84
- * var rule = factory.fromState($state.get('foo'), router);
85
- * var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
86
- * var result = rule.handler(match);
87
- * // Starts a transition to 'foo' with params: { fooId: '123', barId: '456' }
88
- * ```
89
- */
90
- fromState(
91
- stateOrDecl: StateObject | StateDeclaration,
92
- router: Router,
93
- ): StateRule;
94
- /**
95
- * A UrlRule which matches based on a regular expression
96
- *
97
- * The `handler` may be either a [[UrlRuleHandlerFn]] or a string.
98
- *
99
- * ## Handler as a function
100
- *
101
- * If `handler` is a function, the function is invoked with:
102
- *
103
- * - regexp match array (from `regexp`)
104
- * - url: the current Url ([[UrlParts]])
105
- * - router: the router object ([[Router]])
106
- *
107
- * #### Example:
108
- * ```js
109
- * var rule = factory.fromRegExp(/^\/foo\/(bar|baz)$/, match => "/home/" + match[1])
110
- * var match = rule.match('/foo/bar'); // results in [ '/foo/bar', 'bar' ]
111
- * var result = rule.handler(match); // '/home/bar'
112
- * ```
113
- *
114
- * ## Handler as string
115
- *
116
- * If `handler` is a string, the url is *replaced by the string* when the Rule is invoked.
117
- * The string is first interpolated using `string.replace()` style pattern.
118
- *
119
- * #### Example:
120
- * ```js
121
- * var rule = factory.fromRegExp(/^\/foo\/(bar|baz)$/, "/home/$1")
122
- * var match = rule.match('/foo/bar'); // results in [ '/foo/bar', 'bar' ]
123
- * var result = rule.handler(match); // '/home/bar'
124
- * ```
125
- */
126
- fromRegExp(regexp: RegExp, handler: string | UrlRuleHandlerFn): RegExpRule;
127
- }
128
- /**
129
- * A base rule which calls `match`
130
- *
131
- * The value from the `match` function is passed through to the `handler`.
132
- * @internal
133
- */
134
- export declare class BaseUrlRule implements UrlRule {
135
- match: UrlRuleMatchFn;
136
- $id: number;
137
- priority: number;
138
- _group: number;
139
- type: UrlRuleType;
140
- handler: UrlRuleHandlerFn;
141
- matchPriority: (match: any) => number;
142
- constructor(match: UrlRuleMatchFn, handler?: UrlRuleHandlerFn);
143
- }