@angular-wave/angular.ts 0.17.0 → 0.19.0
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.
- package/@types/angular.d.ts +18 -6
- package/@types/animations/animate-css-driver.d.ts +2 -2
- package/@types/animations/animate-js-driver.d.ts +21 -3
- package/@types/animations/animate-js.d.ts +10 -2
- package/@types/animations/animate-swap.d.ts +4 -1
- package/@types/animations/animate.d.ts +11 -5
- package/@types/animations/animation.d.ts +8 -2
- package/@types/animations/css/animate-css.d.ts +16 -0
- package/@types/animations/interface.d.ts +315 -21
- package/@types/animations/queue/animate-queue.d.ts +17 -8
- package/@types/animations/queue/interface.d.ts +14 -7
- package/@types/animations/shared.d.ts +1 -1
- package/@types/core/compile/attributes.d.ts +5 -5
- package/@types/core/compile/compile.d.ts +28 -18
- package/@types/core/compile/interface.d.ts +209 -34
- package/@types/core/controller/controller.d.ts +30 -38
- package/@types/core/controller/interface.d.ts +12 -3
- package/@types/core/interpolate/interpolate.d.ts +1 -1
- package/@types/core/parse/interface.d.ts +2 -2
- package/@types/core/parse/interpreter.d.ts +110 -58
- package/@types/core/scope/interface.d.ts +6 -0
- package/@types/core/scope/scope.d.ts +2 -1
- package/@types/directive/aria/aria.d.ts +67 -27
- package/@types/directive/aria/interface.d.ts +9 -0
- package/@types/directive/class/class.d.ts +31 -0
- package/@types/directive/form/form.d.ts +54 -18
- package/@types/directive/input/input.d.ts +59 -18
- package/@types/directive/input/interface.d.ts +10 -0
- package/@types/directive/messages/messages.d.ts +73 -22
- package/@types/directive/model/interface.d.ts +19 -0
- package/@types/directive/model/model.d.ts +70 -33
- package/@types/directive/model-options/model-options.d.ts +1 -23
- package/@types/directive/repeat/repeat.d.ts +2 -3
- package/@types/directive/validators/validators.d.ts +1 -5
- package/@types/directive/worker/interface.d.ts +9 -0
- package/@types/docs.d.ts +24 -0
- package/@types/filters/json.d.ts +4 -0
- package/@types/interface.d.ts +22 -70
- package/@types/namespace.d.ts +73 -53
- package/@types/router/common/trace.d.ts +150 -42
- package/@types/router/directives/state-directives.d.ts +4 -4
- package/@types/router/directives/view-directive.d.ts +4 -7
- package/@types/router/hooks/core-resolvables.d.ts +11 -2
- package/@types/router/hooks/ignored-transition.d.ts +3 -1
- package/@types/router/hooks/invalid-transition.d.ts +3 -1
- package/@types/router/hooks/lazy-load.d.ts +17 -13
- package/@types/router/hooks/on-enter-exit-retain.d.ts +9 -3
- package/@types/router/hooks/redirect-to.d.ts +3 -3
- package/@types/router/hooks/resolve.d.ts +11 -3
- package/@types/router/hooks/views.d.ts +6 -4
- package/@types/router/params/interface.d.ts +3 -2
- package/@types/router/params/param-factory.d.ts +24 -3
- package/@types/router/params/param-type.d.ts +47 -11
- package/@types/router/params/param-types.d.ts +52 -0
- package/@types/router/params/param.d.ts +52 -28
- package/@types/router/params/state-params.d.ts +5 -3
- package/@types/router/path/interface.d.ts +3 -0
- package/@types/router/path/path-node.d.ts +34 -14
- package/@types/router/path/path-utils.d.ts +75 -25
- package/@types/router/resolve/resolvable.d.ts +34 -7
- package/@types/router/resolve/resolve-context.d.ts +52 -34
- package/@types/router/router.d.ts +10 -12
- package/@types/router/state/interface.d.ts +194 -31
- package/@types/router/state/state-builder.d.ts +29 -29
- package/@types/router/state/state-matcher.d.ts +29 -11
- package/@types/router/state/state-object.d.ts +68 -22
- package/@types/router/state/state-queue-manager.d.ts +19 -10
- package/@types/router/state/state-registry.d.ts +80 -28
- package/@types/router/state/state-service.d.ts +182 -123
- package/@types/router/state/target-state.d.ts +36 -27
- package/@types/router/state/views.d.ts +48 -19
- package/@types/router/template-factory.d.ts +8 -15
- package/@types/router/transition/hook-builder.d.ts +17 -6
- package/@types/router/transition/hook-registry.d.ts +80 -46
- package/@types/router/transition/interface.d.ts +138 -118
- package/@types/router/transition/reject-factory.d.ts +58 -22
- package/@types/router/transition/transition-event-type.d.ts +19 -8
- package/@types/router/transition/transition-hook.d.ts +50 -29
- package/@types/router/transition/transition-service.d.ts +186 -30
- package/@types/router/transition/transition.d.ts +201 -70
- package/@types/router/url/interface.d.ts +140 -0
- package/@types/router/url/url-config.d.ts +19 -16
- package/@types/router/url/url-matcher.d.ts +66 -46
- package/@types/router/url/url-rule.d.ts +58 -35
- package/@types/router/url/url-rules.d.ts +38 -28
- package/@types/router/url/url-service.d.ts +68 -41
- package/@types/router/view/interface.d.ts +10 -30
- package/@types/router/view/view.d.ts +35 -21
- package/@types/services/anchor-scroll/anchor-scroll.d.ts +1 -1
- package/@types/services/anchor-scroll/interface.d.ts +5 -8
- package/@types/services/http/http.d.ts +20 -23
- package/@types/services/http/interface.d.ts +11 -23
- package/@types/services/location/interface.d.ts +1 -4
- package/@types/services/location/location.d.ts +14 -14
- package/@types/services/sce/interface.d.ts +2 -2
- package/@types/services/sce/sce.d.ts +16 -10
- package/@types/services/template-request/template-request.d.ts +21 -4
- package/@types/shared/common.d.ts +5 -32
- package/@types/shared/dom.d.ts +10 -5
- package/@types/shared/interface.d.ts +4 -0
- package/@types/shared/utils.d.ts +17 -6
- package/dist/angular-ts.esm.js +6643 -3107
- package/dist/angular-ts.umd.js +6643 -3107
- package/dist/angular-ts.umd.min.js +1 -1
- package/dist/angular-ts.umd.min.js.gz +0 -0
- package/dist/angular-ts.umd.min.js.map +1 -1
- package/package.json +1 -2
- package/@types/animations/animate-css.d.ts +0 -11
- package/@types/filters/filters.d.ts +0 -38
- package/@types/router/hooks/update-globals.d.ts +0 -1
- package/@types/router/hooks/url.d.ts +0 -5
- package/@types/router/scroll/interface.d.ts +0 -3
- package/@types/router/scroll/view-scroll.d.ts +0 -8
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { StateDeclaration, TargetStateDef } from "../state/interface.ts";
|
|
2
|
+
import { TargetState } from "../state/target-state.js";
|
|
3
|
+
import { Param, StateObject } from "../state/state-object.js";
|
|
4
|
+
import { UrlMatcher } from "./url-matcher.js";
|
|
5
|
+
import { ParamType } from "../params/param-type.js";
|
|
6
|
+
export interface UrlMatcherCompileConfig {
|
|
7
|
+
state?: StateDeclaration;
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
caseInsensitive?: boolean;
|
|
10
|
+
decodeParams?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An object containing the three parts of a URL
|
|
14
|
+
*/
|
|
15
|
+
export interface UrlParts {
|
|
16
|
+
path: string;
|
|
17
|
+
search?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
hash?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A UrlRule match result
|
|
24
|
+
*
|
|
25
|
+
* The result of UrlRouter.match()
|
|
26
|
+
*/
|
|
27
|
+
export interface MatchResult {
|
|
28
|
+
/** The matched value from a [[UrlRule]] */
|
|
29
|
+
match: any;
|
|
30
|
+
/** The rule that matched */
|
|
31
|
+
rule: UrlRule;
|
|
32
|
+
/** The match result weight */
|
|
33
|
+
weight: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A function that matches the URL for a [[UrlRule]]
|
|
37
|
+
*
|
|
38
|
+
* Implementations should match against the provided [[UrlParts]] and return the matched value (truthy) if the rule matches.
|
|
39
|
+
* If this rule is selected, the matched value is passed to the [[UrlRuleHandlerFn]].
|
|
40
|
+
*
|
|
41
|
+
* @return the matched value, either truthy or falsey
|
|
42
|
+
*/
|
|
43
|
+
export interface UrlRuleMatchFn {
|
|
44
|
+
(url: UrlParts, router?: ng.RouterService): any;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Handler invoked when a rule is matched
|
|
48
|
+
*
|
|
49
|
+
* The matched value from the rule's [[UrlRuleMatchFn]] is passed as the first argument
|
|
50
|
+
* The handler should return a string (to redirect), a [[TargetState]]/[[TargetStateDef]], or void
|
|
51
|
+
*
|
|
52
|
+
* If the handler returns a string, the url is replaced with the string.
|
|
53
|
+
* If the handler returns a [[TargetState]], the target state is activated.
|
|
54
|
+
*/
|
|
55
|
+
export interface UrlRuleHandlerFn {
|
|
56
|
+
(
|
|
57
|
+
matchValue?: any,
|
|
58
|
+
url?: UrlParts,
|
|
59
|
+
router?: ng.RouterService,
|
|
60
|
+
): string | TargetState | TargetStateDef | void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The interface for a URL Rule
|
|
64
|
+
*
|
|
65
|
+
* If you are creating a rule for use with [[UrlRules.rule]], it should implement this interface.
|
|
66
|
+
*/
|
|
67
|
+
export interface UrlRule {
|
|
68
|
+
/**
|
|
69
|
+
* The rule's ID.
|
|
70
|
+
*
|
|
71
|
+
* IDs are auto-assigned when the rule is registered, in increasing order.
|
|
72
|
+
*/
|
|
73
|
+
$id: number;
|
|
74
|
+
/**
|
|
75
|
+
* The rule's priority (defaults to 0).
|
|
76
|
+
*
|
|
77
|
+
* This can be used to explicitly modify the rule's priority.
|
|
78
|
+
* Higher numbers are higher priority.
|
|
79
|
+
*/
|
|
80
|
+
priority: number;
|
|
81
|
+
/** The type of the rule */
|
|
82
|
+
type: UrlRuleType;
|
|
83
|
+
/**
|
|
84
|
+
* This function should match the url and return the match details
|
|
85
|
+
*
|
|
86
|
+
* See [[UrlRuleMatchFn]] for details
|
|
87
|
+
*/
|
|
88
|
+
match: UrlRuleMatchFn;
|
|
89
|
+
/**
|
|
90
|
+
* This function is called if the rule matched, and was selected as the "best match".
|
|
91
|
+
* This function handles the rule match event.
|
|
92
|
+
*
|
|
93
|
+
* See [[UrlRuleHandlerFn]] for details
|
|
94
|
+
*/
|
|
95
|
+
handler: UrlRuleHandlerFn;
|
|
96
|
+
/**
|
|
97
|
+
* The priority of a given match.
|
|
98
|
+
*
|
|
99
|
+
* Sometimes more than one UrlRule might have matched.
|
|
100
|
+
* This method is used to choose the best match.
|
|
101
|
+
*
|
|
102
|
+
* If multiple rules matched, each rule's `matchPriority` is called with the value from [[match]].
|
|
103
|
+
* The rule with the highest `matchPriority` has its [[handler]] called.
|
|
104
|
+
*/
|
|
105
|
+
matchPriority(match: any): number;
|
|
106
|
+
}
|
|
107
|
+
export interface MatcherUrlRule extends UrlRule {
|
|
108
|
+
type: "URLMATCHER" | "STATE";
|
|
109
|
+
urlMatcher: UrlMatcher;
|
|
110
|
+
}
|
|
111
|
+
export interface StateRule extends MatcherUrlRule {
|
|
112
|
+
type: "STATE";
|
|
113
|
+
state: StateObject;
|
|
114
|
+
}
|
|
115
|
+
export interface RegExpRule extends UrlRule {
|
|
116
|
+
type: "REGEXP";
|
|
117
|
+
regexp: RegExp;
|
|
118
|
+
}
|
|
119
|
+
export interface UrlMatcherCache {
|
|
120
|
+
segments?: any[];
|
|
121
|
+
weights?: number[] | (2 | 3 | 1 | undefined)[];
|
|
122
|
+
path?: UrlMatcher[];
|
|
123
|
+
parent?: UrlMatcher;
|
|
124
|
+
pattern?: RegExp | null;
|
|
125
|
+
}
|
|
126
|
+
export interface MatchDetails {
|
|
127
|
+
id: string;
|
|
128
|
+
regexp: string;
|
|
129
|
+
segment: string;
|
|
130
|
+
type: ParamType;
|
|
131
|
+
}
|
|
132
|
+
export declare const defaultConfig: UrlMatcherCompileConfig;
|
|
133
|
+
export interface ParamDetails {
|
|
134
|
+
param: Param;
|
|
135
|
+
value: any;
|
|
136
|
+
isValid: boolean;
|
|
137
|
+
isDefaultValue: boolean;
|
|
138
|
+
squash: boolean | string;
|
|
139
|
+
encoded: string | string[];
|
|
140
|
+
}
|
|
@@ -18,8 +18,8 @@ export class UrlConfigProvider {
|
|
|
18
18
|
_isCaseInsensitive: boolean;
|
|
19
19
|
/** @type {boolean} */
|
|
20
20
|
_isStrictMode: boolean;
|
|
21
|
-
/** @type {boolean} */
|
|
22
|
-
_defaultSquashPolicy: boolean;
|
|
21
|
+
/** @type {boolean | string} */
|
|
22
|
+
_defaultSquashPolicy: boolean | string;
|
|
23
23
|
$get: () => this;
|
|
24
24
|
/**
|
|
25
25
|
* Defines whether URL matching should be case sensitive (the default behavior), or not.
|
|
@@ -29,11 +29,10 @@ export class UrlConfigProvider {
|
|
|
29
29
|
* // Allow case insensitive url matches
|
|
30
30
|
* urlService.config.caseInsensitive(true);
|
|
31
31
|
* ```
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
* @returns the current value of caseInsensitive
|
|
32
|
+
* @param {boolean} [value] `false` to match URL in a case sensitive manner; otherwise `true`;
|
|
33
|
+
* @returns {boolean} the current value of caseInsensitive
|
|
35
34
|
*/
|
|
36
|
-
caseInsensitive(value
|
|
35
|
+
caseInsensitive(value?: boolean): boolean;
|
|
37
36
|
/**
|
|
38
37
|
* Sets the default behavior when generating or matching URLs with default parameter values.
|
|
39
38
|
*
|
|
@@ -43,15 +42,15 @@ export class UrlConfigProvider {
|
|
|
43
42
|
* urlService.config.defaultSquashPolicy(true);
|
|
44
43
|
* ```
|
|
45
44
|
*
|
|
46
|
-
* @param value A string that defines the default parameter URL squashing behavior.
|
|
45
|
+
* @param {boolean | string} [value] A string that defines the default parameter URL squashing behavior.
|
|
47
46
|
* - `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
|
|
48
47
|
* - `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
|
|
49
48
|
* parameter is surrounded by slashes, squash (remove) one slash from the URL
|
|
50
49
|
* - any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
|
|
51
50
|
* the parameter value from the URL and replace it with this string.
|
|
52
|
-
* @returns the current value of defaultSquashPolicy
|
|
51
|
+
* @returns {boolean | string} the current value of defaultSquashPolicy
|
|
53
52
|
*/
|
|
54
|
-
defaultSquashPolicy(value
|
|
53
|
+
defaultSquashPolicy(value?: boolean | string): boolean | string;
|
|
55
54
|
/**
|
|
56
55
|
* Defines whether URLs should match trailing slashes, or not (the default behavior).
|
|
57
56
|
*
|
|
@@ -61,10 +60,10 @@ export class UrlConfigProvider {
|
|
|
61
60
|
* urlService.config.strictMode(false);
|
|
62
61
|
* ```
|
|
63
62
|
*
|
|
64
|
-
* @param value `false` to match trailing slashes in URLs, otherwise `true`.
|
|
65
|
-
* @returns the current value of strictMode
|
|
63
|
+
* @param {boolean} value `false` to match trailing slashes in URLs, otherwise `true`.
|
|
64
|
+
* @returns {boolean} the current value of strictMode
|
|
66
65
|
*/
|
|
67
|
-
strictMode(value:
|
|
66
|
+
strictMode(value: boolean): boolean;
|
|
68
67
|
/**
|
|
69
68
|
* Creates and registers a custom [[ParamType]] object
|
|
70
69
|
*
|
|
@@ -86,14 +85,18 @@ export class UrlConfigProvider {
|
|
|
86
85
|
*
|
|
87
86
|
* See [[ParamTypeDefinition]] for more examples
|
|
88
87
|
*
|
|
89
|
-
* @param name The type name.
|
|
90
|
-
* @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
|
|
91
|
-
* @param definitionFn A function that is injected before the app runtime starts.
|
|
88
|
+
* @param {string} name The type name.
|
|
89
|
+
* @param {import("../params/interface.ts").ParamTypeDefinition} [definition] The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
|
|
90
|
+
* @param {() => import("../params/interface.ts").ParamTypeDefinition} [definitionFn] A function that is injected before the app runtime starts.
|
|
92
91
|
* The result of this function should be a [[ParamTypeDefinition]].
|
|
93
92
|
* The result is merged into the existing `definition`.
|
|
94
93
|
* See [[ParamType]] for information on the values accepted.
|
|
95
94
|
*
|
|
96
95
|
* @returns if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
|
|
97
96
|
*/
|
|
98
|
-
type(
|
|
97
|
+
type(
|
|
98
|
+
name: string,
|
|
99
|
+
definition?: import("../params/interface.ts").ParamTypeDefinition,
|
|
100
|
+
definitionFn?: () => import("../params/interface.ts").ParamTypeDefinition,
|
|
101
|
+
): any;
|
|
99
102
|
}
|
|
@@ -50,10 +50,17 @@
|
|
|
50
50
|
*
|
|
51
51
|
*/
|
|
52
52
|
export class UrlMatcher {
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @internal Given a matcher, return an array with the matcher's path segments and path params, in order
|
|
55
|
+
* @param {UrlMatcher} matcher
|
|
56
|
+
*/
|
|
57
|
+
static pathSegmentsAndParams(matcher: UrlMatcher): any;
|
|
58
|
+
/**
|
|
59
|
+
* @internal Given a matcher, return an array with the matcher's query params
|
|
60
|
+
* @param {UrlMatcher} matcher
|
|
61
|
+
* @returns {Param[]}
|
|
62
|
+
*/
|
|
63
|
+
static queryParams(matcher: UrlMatcher): Param[];
|
|
57
64
|
/**
|
|
58
65
|
* Compare two UrlMatchers
|
|
59
66
|
*
|
|
@@ -62,36 +69,53 @@ export class UrlMatcher {
|
|
|
62
69
|
* Each dynamic segment is a path parameter.
|
|
63
70
|
*
|
|
64
71
|
* The comparison function sorts static segments before dynamic ones.
|
|
72
|
+
* @param {UrlMatcher} a
|
|
73
|
+
* @param {UrlMatcher} b
|
|
65
74
|
*/
|
|
66
|
-
static compare(a:
|
|
75
|
+
static compare(a: UrlMatcher, b: UrlMatcher): number;
|
|
67
76
|
/**
|
|
68
|
-
* @param pattern The pattern to compile into a matcher.
|
|
69
|
-
* @param paramTypes The [[ParamTypes]] registry
|
|
70
|
-
* @param paramFactory A [[ParamFactory]] object
|
|
71
|
-
* @param config
|
|
77
|
+
* @param {string} pattern The pattern to compile into a matcher.
|
|
78
|
+
* @param {import("../params/param-types.js").ParamTypes} paramTypes The [[ParamTypes]] registry
|
|
79
|
+
* @param {import("../params/param-factory.js").ParamFactory} paramFactory A [[ParamFactory]] object
|
|
80
|
+
* @param {import("./interface.js").UrlMatcherCompileConfig} config A [[UrlMatcherCompileConfig]] configuration object
|
|
81
|
+
*/
|
|
82
|
+
constructor(
|
|
83
|
+
pattern: string,
|
|
84
|
+
paramTypes: import("../params/param-types.js").ParamTypes,
|
|
85
|
+
paramFactory: import("../params/param-factory.js").ParamFactory,
|
|
86
|
+
config: import("./interface.js").UrlMatcherCompileConfig,
|
|
87
|
+
);
|
|
88
|
+
_cache: import("./interface.js").UrlMatcherCache;
|
|
89
|
+
/**
|
|
90
|
+
* @type {any[]}
|
|
72
91
|
*/
|
|
73
|
-
constructor(pattern: any, paramTypes: any, paramFactory: any, config: any);
|
|
74
|
-
_cache: {
|
|
75
|
-
path: UrlMatcher[];
|
|
76
|
-
};
|
|
77
92
|
_children: any[];
|
|
78
|
-
_params:
|
|
79
|
-
_segments:
|
|
93
|
+
_params: Param[];
|
|
94
|
+
_segments: string[];
|
|
95
|
+
/**
|
|
96
|
+
* @type {any[]}
|
|
97
|
+
*/
|
|
80
98
|
_compiled: any[];
|
|
81
99
|
config: any;
|
|
82
|
-
pattern:
|
|
100
|
+
pattern: string;
|
|
83
101
|
/**
|
|
84
102
|
* Creates a new concatenated UrlMatcher
|
|
85
103
|
*
|
|
86
104
|
* Builds a new UrlMatcher by appending another UrlMatcher to this one.
|
|
87
105
|
*
|
|
88
|
-
* @param url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
|
|
106
|
+
* @param {UrlMatcher} url A `UrlMatcher` instance to append as a child of the current `UrlMatcher`.
|
|
107
|
+
* @returns {UrlMatcher} A new `UrlMatcher` instance representing the concatenation of this `UrlMatcher` and the provided `url` matcher.
|
|
89
108
|
*/
|
|
90
|
-
append(url:
|
|
109
|
+
append(url: UrlMatcher): UrlMatcher;
|
|
91
110
|
isRoot(): boolean;
|
|
92
111
|
/** Returns the input pattern string */
|
|
93
|
-
toString():
|
|
94
|
-
|
|
112
|
+
toString(): string;
|
|
113
|
+
/**
|
|
114
|
+
* @param {any} value
|
|
115
|
+
* @param {Param} param
|
|
116
|
+
* @returns {any}
|
|
117
|
+
*/
|
|
118
|
+
_getDecodedParamValue(value: any, param: Param): any;
|
|
95
119
|
/**
|
|
96
120
|
* Tests the specified url/path against this matcher.
|
|
97
121
|
*
|
|
@@ -110,47 +134,41 @@ export class UrlMatcher {
|
|
|
110
134
|
* });
|
|
111
135
|
* // returns { id: 'bob', q: 'hello', r: null }
|
|
112
136
|
* ```
|
|
113
|
-
*
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
116
|
-
* @
|
|
117
|
-
*
|
|
118
|
-
* @returns The captured parameter values.
|
|
137
|
+
* @param {string} path The URL path to match, e.g. `$location.getPath()`.
|
|
138
|
+
* @param {any} search URL search parameters, e.g. `$location.getSearch()`.
|
|
139
|
+
* @param {string} hash URL hash e.g. `$location.getHash()`.
|
|
140
|
+
* @returns {import("../params/interface.js").RawParams | null} The captured parameter values.
|
|
119
141
|
*/
|
|
120
142
|
exec(
|
|
121
|
-
path:
|
|
122
|
-
search:
|
|
123
|
-
hash:
|
|
124
|
-
):
|
|
125
|
-
"#": any;
|
|
126
|
-
};
|
|
143
|
+
path: string,
|
|
144
|
+
search: any,
|
|
145
|
+
hash: string,
|
|
146
|
+
): import("../params/interface.js").RawParams | null;
|
|
127
147
|
/**
|
|
128
148
|
* @internal
|
|
129
149
|
* Returns all the [[Param]] objects of all path and search parameters of this pattern in order of appearance.
|
|
130
150
|
*
|
|
151
|
+
* @param {any} [opts]
|
|
131
152
|
* @returns {Array.<Param>} An array of [[Param]] objects. Must be treated as read-only. If the
|
|
132
153
|
* pattern has no parameters, an empty array is returned.
|
|
133
154
|
*/
|
|
134
|
-
parameters(opts?:
|
|
155
|
+
parameters(opts?: any): Array<Param>;
|
|
135
156
|
/**
|
|
136
|
-
* @internal
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* @
|
|
140
|
-
* @param opts
|
|
141
|
-
* @returns {Param|any|boolean|UrlMatcher|null}
|
|
157
|
+
* @internal Returns a single parameter from this UrlMatcher by id
|
|
158
|
+
* @param {string} id
|
|
159
|
+
* @param {any} opts
|
|
160
|
+
* @returns {Param | any | boolean | UrlMatcher | null}
|
|
142
161
|
*/
|
|
143
|
-
parameter(id:
|
|
162
|
+
parameter(id: string, opts?: any): Param | any | boolean | UrlMatcher | null;
|
|
144
163
|
/**
|
|
145
164
|
* Validates the input parameter values against this UrlMatcher
|
|
146
165
|
*
|
|
147
166
|
* Checks an object hash of parameters to validate their correctness according to the parameter
|
|
148
167
|
* types of this `UrlMatcher`.
|
|
149
|
-
*
|
|
150
|
-
* @
|
|
151
|
-
* @returns Returns `true` if `params` validates, otherwise `false`.
|
|
168
|
+
* @param {import("../params/interface.js").RawParams} params The object hash of parameters to validate.
|
|
169
|
+
* @returns {boolean} Returns `true` if `params` validates, otherwise `false`.
|
|
152
170
|
*/
|
|
153
|
-
validates(params:
|
|
171
|
+
validates(params: import("../params/interface.js").RawParams): boolean;
|
|
154
172
|
/**
|
|
155
173
|
* Given a set of parameter values, creates a URL from this UrlMatcher.
|
|
156
174
|
*
|
|
@@ -163,12 +181,14 @@ export class UrlMatcher {
|
|
|
163
181
|
* // returns '/user/bob?q=yes'
|
|
164
182
|
* ```
|
|
165
183
|
*
|
|
166
|
-
* @param values the values to substitute for the parameters in this pattern.
|
|
184
|
+
* @param {import("../params/interface.js").RawParams} values the values to substitute for the parameters in this pattern.
|
|
167
185
|
* @returns the formatted URL (path and optionally search part).
|
|
168
186
|
*/
|
|
169
|
-
format(values?:
|
|
187
|
+
format(values?: import("../params/interface.js").RawParams): string;
|
|
170
188
|
}
|
|
171
189
|
export namespace UrlMatcher {
|
|
172
190
|
let nameValidator: RegExp;
|
|
173
191
|
}
|
|
192
|
+
export type UrlMatcherCache = import("./interface.js").UrlMatcherCache;
|
|
193
|
+
export type ParamDetails = import("./interface.ts").ParamDetails;
|
|
174
194
|
import { Param } from "../params/param.js";
|
|
@@ -17,11 +17,11 @@ export class UrlRuleFactory {
|
|
|
17
17
|
routerGlobals: ng.RouterService;
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {*} handler
|
|
22
|
-
* @returns {
|
|
20
|
+
* @param {StateObject} what
|
|
21
|
+
* @param {*} [handler]
|
|
22
|
+
* @returns {import("./url-rules.js").UrlRule}
|
|
23
23
|
*/
|
|
24
|
-
create(what:
|
|
24
|
+
create(what: StateObject, handler?: any): import("./url-rules.js").UrlRule;
|
|
25
25
|
/**
|
|
26
26
|
* A UrlRule which matches based on a UrlMatcher
|
|
27
27
|
*
|
|
@@ -57,15 +57,14 @@ export class UrlRuleFactory {
|
|
|
57
57
|
* var match = rule.match('/foo/123/456'); // results in { fooId: '123', barId: '456' }
|
|
58
58
|
* var result = rule.handler(match); // '/home/123/456'
|
|
59
59
|
* ```
|
|
60
|
+
* @param {UrlMatcher} urlMatcher
|
|
61
|
+
* @param {string | UrlMatcher | import("./interface.js").UrlRuleHandlerFn} handler
|
|
62
|
+
* @returns {import("./interface.js").MatcherUrlRule}
|
|
60
63
|
*/
|
|
61
64
|
fromUrlMatcher(
|
|
62
|
-
urlMatcher:
|
|
63
|
-
handler:
|
|
64
|
-
):
|
|
65
|
-
urlMatcher: any;
|
|
66
|
-
matchPriority: (params: any) => number;
|
|
67
|
-
type: string;
|
|
68
|
-
};
|
|
65
|
+
urlMatcher: UrlMatcher,
|
|
66
|
+
handler: string | UrlMatcher | import("./interface.js").UrlRuleHandlerFn,
|
|
67
|
+
): import("./interface.js").MatcherUrlRule;
|
|
69
68
|
/**
|
|
70
69
|
* A UrlRule which matches a state by its url
|
|
71
70
|
*
|
|
@@ -76,19 +75,16 @@ export class UrlRuleFactory {
|
|
|
76
75
|
* var result = rule.handler(match);
|
|
77
76
|
* // Starts a transition to 'foo' with params: { fooId: '123', barId: '456' }
|
|
78
77
|
* ```
|
|
78
|
+
* @param {StateObject | import("../state/interface.js").StateDeclaration} stateOrDecl
|
|
79
|
+
* @param {import("../state/state-service.js").StateProvider} stateService
|
|
80
|
+
* @param {import("../router.js").RouterProvider} globals
|
|
81
|
+
* @returns {import("./interface.js").StateRule}
|
|
79
82
|
*/
|
|
80
83
|
fromState(
|
|
81
|
-
stateOrDecl:
|
|
82
|
-
stateService:
|
|
83
|
-
globals:
|
|
84
|
-
):
|
|
85
|
-
urlMatcher: any;
|
|
86
|
-
matchPriority: (params: any) => number;
|
|
87
|
-
type: string;
|
|
88
|
-
} & {
|
|
89
|
-
state: any;
|
|
90
|
-
type: string;
|
|
91
|
-
};
|
|
84
|
+
stateOrDecl: StateObject | import("../state/interface.js").StateDeclaration,
|
|
85
|
+
stateService: import("../state/state-service.js").StateProvider,
|
|
86
|
+
globals: import("../router.js").RouterProvider,
|
|
87
|
+
): import("./interface.js").StateRule;
|
|
92
88
|
/**
|
|
93
89
|
* A UrlRule which matches based on a regular expression
|
|
94
90
|
*
|
|
@@ -120,17 +116,17 @@ export class UrlRuleFactory {
|
|
|
120
116
|
* var match = rule.match('/foo/bar'); // results in [ '/foo/bar', 'bar' ]
|
|
121
117
|
* var result = rule.handler(match); // '/home/bar'
|
|
122
118
|
* ```
|
|
119
|
+
* @param {RegExp} regexp
|
|
120
|
+
* @param {string | import("./interface.js").UrlRuleHandlerFn} handler
|
|
121
|
+
* @returns {import("./interface.js").RegExpRule}
|
|
123
122
|
*/
|
|
124
123
|
fromRegExp(
|
|
125
|
-
regexp:
|
|
126
|
-
handler:
|
|
127
|
-
):
|
|
128
|
-
regexp: any;
|
|
129
|
-
type: string;
|
|
130
|
-
};
|
|
124
|
+
regexp: RegExp,
|
|
125
|
+
handler: string | import("./interface.js").UrlRuleHandlerFn,
|
|
126
|
+
): import("./interface.js").RegExpRule;
|
|
131
127
|
}
|
|
132
128
|
export namespace UrlRuleFactory {
|
|
133
|
-
function isUrlRule(obj: any): boolean;
|
|
129
|
+
function isUrlRule(obj: { [x: string]: any }): boolean;
|
|
134
130
|
}
|
|
135
131
|
/**
|
|
136
132
|
* A base rule which calls `match`
|
|
@@ -138,13 +134,38 @@ export namespace UrlRuleFactory {
|
|
|
138
134
|
* The value from the `match` function is passed through to the `handler`.
|
|
139
135
|
*/
|
|
140
136
|
export class BaseUrlRule {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
/**
|
|
138
|
+
* @param {import("./interface.js").UrlRuleMatchFn} match
|
|
139
|
+
* @param {import("./interface.js").UrlRuleHandlerFn} handler
|
|
140
|
+
*/
|
|
141
|
+
constructor(
|
|
142
|
+
match: import("./interface.js").UrlRuleMatchFn,
|
|
143
|
+
handler: import("./interface.js").UrlRuleHandlerFn,
|
|
144
|
+
);
|
|
145
|
+
/**
|
|
146
|
+
* @type {import("./interface.js").UrlRuleMatchFn}
|
|
147
|
+
*/
|
|
148
|
+
match: import("./interface.js").UrlRuleMatchFn;
|
|
149
|
+
/**
|
|
150
|
+
* @type {import("./interface.js").UrlRuleType}
|
|
151
|
+
*/
|
|
152
|
+
type: import("./interface.js").UrlRuleType;
|
|
153
|
+
/**
|
|
154
|
+
* @type {number}
|
|
155
|
+
*/
|
|
144
156
|
$id: number;
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
/**
|
|
158
|
+
* @type {number | undefined}
|
|
159
|
+
*/
|
|
160
|
+
_group: number | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* @type {import("./interface.js").UrlRuleHandlerFn}
|
|
163
|
+
*/
|
|
164
|
+
handler: import("./interface.js").UrlRuleHandlerFn;
|
|
165
|
+
/**
|
|
166
|
+
* @type {number | undefined}
|
|
167
|
+
*/
|
|
168
|
+
priority: number | undefined;
|
|
148
169
|
/**
|
|
149
170
|
* This function should be overridden
|
|
150
171
|
* @param {*} [params]
|
|
@@ -152,3 +173,5 @@ export class BaseUrlRule {
|
|
|
152
173
|
*/
|
|
153
174
|
matchPriority(params?: any): number;
|
|
154
175
|
}
|
|
176
|
+
import { StateObject } from "../state/state-object.js";
|
|
177
|
+
import { UrlMatcher } from "./url-matcher.js";
|
|
@@ -12,15 +12,17 @@ export class UrlRules {
|
|
|
12
12
|
/** @param {UrlRuleFactory} urlRuleFactory */
|
|
13
13
|
constructor(urlRuleFactory: UrlRuleFactory);
|
|
14
14
|
_sortFn: typeof defaultRuleSortFn;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @type {UrlRule[]}
|
|
17
|
+
*/
|
|
18
|
+
_rules: UrlRule[];
|
|
16
19
|
_id: number;
|
|
17
20
|
_urlRuleFactory: UrlRuleFactory;
|
|
18
21
|
/**
|
|
19
22
|
* Remove a rule previously registered
|
|
20
|
-
*
|
|
21
|
-
* @param rule the matcher rule that was previously registered using [[rule]]
|
|
23
|
+
* @param {UrlRule} rule the matcher rule that was previously registered using [[rule]]
|
|
22
24
|
*/
|
|
23
|
-
removeRule(rule:
|
|
25
|
+
removeRule(rule: UrlRule): void;
|
|
24
26
|
/**
|
|
25
27
|
* Manually adds a URL Rule.
|
|
26
28
|
*
|
|
@@ -31,16 +33,17 @@ export class UrlRules {
|
|
|
31
33
|
* A rule should have a `match` function which returns truthy if the rule matched.
|
|
32
34
|
* It should also have a `handler` function which is invoked if the rule is the best match.
|
|
33
35
|
*
|
|
36
|
+
* @param {UrlRule} rule the rule to register
|
|
34
37
|
* @returns {() => void } a function that deregisters the rule
|
|
35
38
|
*/
|
|
36
|
-
rule(rule:
|
|
39
|
+
rule(rule: UrlRule): () => void;
|
|
37
40
|
_sorted: boolean;
|
|
38
41
|
/**
|
|
39
42
|
* Gets all registered rules
|
|
40
43
|
*
|
|
41
|
-
* @returns an array of all the registered rules
|
|
44
|
+
* @returns {import("./interface.ts").UrlRule[]} an array of all the registered rules
|
|
42
45
|
*/
|
|
43
|
-
rules():
|
|
46
|
+
rules(): import("./interface.ts").UrlRule[];
|
|
44
47
|
/**
|
|
45
48
|
* Defines URL Rule priorities
|
|
46
49
|
*
|
|
@@ -73,19 +76,21 @@ export class UrlRules {
|
|
|
73
76
|
* return a.$id - b.$id;
|
|
74
77
|
* }
|
|
75
78
|
* ```
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* See the [mozilla reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Description)
|
|
84
|
-
* for details.
|
|
79
|
+
* @param {((a: UrlRule, b: UrlRule) => number) | undefined} [compareFn] a function that compares to [[UrlRule]] objects.
|
|
80
|
+
* The `compareFn` should abide by the `Array.sort` compare function rules.
|
|
81
|
+
* Given two rules, `a` and `b`, return a negative number if `a` should be higher priority.
|
|
82
|
+
* Return a positive number if `b` should be higher priority.
|
|
83
|
+
* Return `0` if the rules are identical.
|
|
84
|
+
* See the [mozilla reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Description)
|
|
85
|
+
* for details.
|
|
85
86
|
*/
|
|
86
|
-
sort(compareFn:
|
|
87
|
+
sort(compareFn?: ((a: UrlRule, b: UrlRule) => number) | undefined): void;
|
|
87
88
|
ensureSorted(): void;
|
|
88
|
-
|
|
89
|
+
/**
|
|
90
|
+
* @param {any[]} arr
|
|
91
|
+
* @param {(arg0: any, arg1: any) => any} compareFn
|
|
92
|
+
*/
|
|
93
|
+
stableSort(arr: any[], compareFn: (arg0: any, arg1: any) => any): any[];
|
|
89
94
|
/**
|
|
90
95
|
* Registers a `matcher` and `handler` for custom URLs handling.
|
|
91
96
|
*
|
|
@@ -138,19 +143,22 @@ export class UrlRules {
|
|
|
138
143
|
* ```
|
|
139
144
|
*
|
|
140
145
|
* Note: the `handler` may also invoke arbitrary code, such as `$state.go()`
|
|
141
|
-
*
|
|
142
|
-
* @param
|
|
143
|
-
* @param
|
|
144
|
-
* @
|
|
145
|
-
*
|
|
146
|
-
* @return the registered [[UrlRule]]
|
|
146
|
+
* @param {import("../state/state-object.js").StateObject} matcher A pattern `string` to match, compiled as a [[UrlMatcher]], or a `RegExp`.
|
|
147
|
+
* @param {any} handler The path to redirect to, or a function that returns the path.
|
|
148
|
+
* @param {{ priority: any; }} options `{ priority: number }`
|
|
149
|
+
* @return {UrlRule} the registered [[UrlRule]]
|
|
147
150
|
*/
|
|
148
151
|
when(
|
|
149
|
-
matcher:
|
|
152
|
+
matcher: import("../state/state-object.js").StateObject,
|
|
150
153
|
handler: any,
|
|
151
|
-
options:
|
|
152
|
-
|
|
154
|
+
options: {
|
|
155
|
+
priority: any;
|
|
156
|
+
},
|
|
157
|
+
): UrlRule;
|
|
153
158
|
}
|
|
159
|
+
export type UrlRule = import("./interface.ts").UrlRule;
|
|
160
|
+
export type MatcherUrlRule = import("./interface.ts").MatcherUrlRule;
|
|
161
|
+
export type BaseUrlRule = import("./url-rule.js").BaseUrlRule;
|
|
154
162
|
/**
|
|
155
163
|
* Default rule priority sorting function.
|
|
156
164
|
*
|
|
@@ -162,7 +170,9 @@ export class UrlRules {
|
|
|
162
170
|
* - Rule registration order (for rule types other than STATE and URLMATCHER)
|
|
163
171
|
* - Equally sorted State and UrlMatcher rules will each match the URL.
|
|
164
172
|
* Then, the *best* match is chosen based on how many parameter values were matched.
|
|
173
|
+
* @param {UrlRule} a
|
|
174
|
+
* @param {UrlRule} b
|
|
165
175
|
*/
|
|
166
|
-
declare function defaultRuleSortFn(a:
|
|
176
|
+
declare function defaultRuleSortFn(a: UrlRule, b: UrlRule): number;
|
|
167
177
|
import { UrlRuleFactory } from "./url-rule.js";
|
|
168
178
|
export {};
|