@angular-wave/angular.ts 0.18.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 +11 -1
- 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 +7 -0
- package/@types/animations/css/animate-css.d.ts +16 -0
- package/@types/animations/interface.d.ts +308 -19
- package/@types/animations/queue/animate-queue.d.ts +16 -7
- package/@types/animations/queue/interface.d.ts +14 -7
- package/@types/core/compile/attributes.d.ts +1 -1
- package/@types/core/compile/compile.d.ts +25 -15
- 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/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 +66 -26
- 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 +63 -12
- 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 -69
- package/@types/namespace.d.ts +66 -40
- 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 +2 -5
- 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 +67 -21
- 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/interface.d.ts +1 -1
- package/@types/services/http/http.d.ts +19 -22
- 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 +13 -13
- package/@types/services/sce/sce.d.ts +14 -8
- 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 +6424 -2850
- package/dist/angular-ts.umd.js +6424 -2850
- 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
|
@@ -19,8 +19,11 @@ export namespace resolvePolicies {
|
|
|
19
19
|
* The ResolveContext closes over the [[PathNode]]s, and provides DI for the last node in the path.
|
|
20
20
|
*/
|
|
21
21
|
export class ResolveContext {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @param {import("../resolve/resolve-context.js").PathNode[]} _path
|
|
24
|
+
*/
|
|
25
|
+
constructor(_path: import("../resolve/resolve-context.js").PathNode[]);
|
|
26
|
+
_path: import("../path/path-node.js").PathNode[];
|
|
24
27
|
/** Gets all the tokens found in the resolve context, de-duplicated */
|
|
25
28
|
getTokens(): any;
|
|
26
29
|
/**
|
|
@@ -28,34 +31,39 @@ export class ResolveContext {
|
|
|
28
31
|
*
|
|
29
32
|
* Gets the last Resolvable that matches the token in this context, or undefined.
|
|
30
33
|
* Throws an error if it doesn't exist in the ResolveContext
|
|
34
|
+
* @param {string} token
|
|
35
|
+
* @return {Resolvable}
|
|
31
36
|
*/
|
|
32
|
-
getResolvable(token:
|
|
33
|
-
/** Returns the [[ResolvePolicy]] for the given [[Resolvable]] */
|
|
34
|
-
getPolicy(resolvable: any): any;
|
|
37
|
+
getResolvable(token: string): Resolvable;
|
|
35
38
|
/**
|
|
36
|
-
* Returns
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* The new context starts at the first node (root) and stops at the node for the `state` parameter.
|
|
40
|
-
*
|
|
41
|
-
* #### Why
|
|
42
|
-
*
|
|
43
|
-
* When a transition is created, the nodes in the "To Path" are injected from a ResolveContext.
|
|
44
|
-
* A ResolveContext closes over a path of [[PathNode]]s and processes the resolvables.
|
|
45
|
-
* The "To State" can inject values from its own resolvables, as well as those from all its ancestor state's (node's).
|
|
46
|
-
* This method is used to create a narrower context when injecting ancestor nodes.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* `let ABCD = new ResolveContext([A, B, C, D]);`
|
|
50
|
-
*
|
|
51
|
-
* Given a path `[A, B, C, D]`, where `A`, `B`, `C` and `D` are nodes for states `a`, `b`, `c`, `d`:
|
|
52
|
-
* When injecting `D`, `D` should have access to all resolvables from `A`, `B`, `C`, `D`.
|
|
53
|
-
* However, `B` should only be able to access resolvables from `A`, `B`.
|
|
54
|
-
*
|
|
55
|
-
* When resolving for the `B` node, first take the full "To Path" Context `[A,B,C,D]` and limit to the subpath `[A,B]`.
|
|
56
|
-
* `let AB = ABCD.subcontext(a)`
|
|
39
|
+
* Returns the [[ResolvePolicy]] for the given [[Resolvable]]
|
|
40
|
+
* @param {Resolvable} resolvable
|
|
41
|
+
* @return {import("./interface.ts").ResolvePolicy}
|
|
57
42
|
*/
|
|
58
|
-
|
|
43
|
+
getPolicy(resolvable: Resolvable): import("./interface.ts").ResolvePolicy;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a ResolveContext that includes a portion of this one
|
|
46
|
+
*
|
|
47
|
+
* Given a state, this method creates a new ResolveContext from this one.
|
|
48
|
+
* The new context starts at the first node (root) and stops at the node for the `state` parameter.
|
|
49
|
+
*
|
|
50
|
+
* #### Why
|
|
51
|
+
*
|
|
52
|
+
* When a transition is created, the nodes in the "To Path" are injected from a ResolveContext.
|
|
53
|
+
* A ResolveContext closes over a path of [[PathNode]]s and processes the resolvables.
|
|
54
|
+
* The "To State" can inject values from its own resolvables, as well as those from all its ancestor state's (node's).
|
|
55
|
+
* This method is used to create a narrower context when injecting ancestor nodes.
|
|
56
|
+
* @example `let ABCD = new ResolveContext([A, B, C, D]);`
|
|
57
|
+
|
|
58
|
+
Given a path `[A, B, C, D]`, where `A`, `B`, `C` and `D` are nodes for states `a`, `b`, `c`, `d`:
|
|
59
|
+
When injecting `D`, `D` should have access to all resolvables from `A`, `B`, `C`, `D`.
|
|
60
|
+
However, `B` should only be able to access resolvables from `A`, `B`.
|
|
61
|
+
|
|
62
|
+
When resolving for the `B` node, first take the full "To Path" Context `[A,B,C,D]` and limit to the subpath `[A,B]`.
|
|
63
|
+
`let AB = ABCD.subcontext(a)`
|
|
64
|
+
* @param {ng.BuiltStateDeclaration} state
|
|
65
|
+
*/
|
|
66
|
+
subContext(state: ng.BuiltStateDeclaration): ResolveContext;
|
|
59
67
|
/**
|
|
60
68
|
* Adds Resolvables to the node that matches the state
|
|
61
69
|
*
|
|
@@ -68,19 +76,28 @@ export class ResolveContext {
|
|
|
68
76
|
*
|
|
69
77
|
* Note: each resolvable's [[ResolvePolicy]] is merged with the state's policy, and the global default.
|
|
70
78
|
*
|
|
71
|
-
* @param {Resolvable[]} newResolvables the new Resolvables
|
|
72
|
-
* @param state Used to find the node to put the resolvable on
|
|
79
|
+
* @param {Resolvable[] | import("./interface.ts").ResolvableLiteral[]} newResolvables the new Resolvables
|
|
80
|
+
* @param {ng.StateObject} state Used to find the node to put the resolvable on
|
|
73
81
|
*/
|
|
74
|
-
addResolvables(
|
|
82
|
+
addResolvables(
|
|
83
|
+
newResolvables: Resolvable[] | import("./interface.ts").ResolvableLiteral[],
|
|
84
|
+
state: ng.StateObject,
|
|
85
|
+
): void;
|
|
75
86
|
/**
|
|
76
87
|
* Returns a promise for an array of resolved path Element promises
|
|
77
88
|
*
|
|
78
|
-
* @param {
|
|
79
|
-
* @param trans
|
|
89
|
+
* @param {import("./interface.ts").PolicyWhen} when
|
|
90
|
+
* @param {ng.Transition} trans
|
|
80
91
|
* @returns {Promise<any>|any}
|
|
81
92
|
*/
|
|
82
|
-
resolvePath(
|
|
83
|
-
|
|
93
|
+
resolvePath(
|
|
94
|
+
when: import("./interface.ts").PolicyWhen,
|
|
95
|
+
trans: ng.Transition,
|
|
96
|
+
): Promise<any> | any;
|
|
97
|
+
/**
|
|
98
|
+
* @param {Resolvable} resolvable
|
|
99
|
+
*/
|
|
100
|
+
findNode(resolvable: Resolvable): any;
|
|
84
101
|
/**
|
|
85
102
|
* Gets the async dependencies of a Resolvable
|
|
86
103
|
*
|
|
@@ -90,4 +107,5 @@ export class ResolveContext {
|
|
|
90
107
|
*/
|
|
91
108
|
getDependencies(resolvable: Resolvable): Resolvable[];
|
|
92
109
|
}
|
|
110
|
+
export type PathNode = import("../path/path-node.js").PathNode;
|
|
93
111
|
import { Resolvable } from "./resolvable.js";
|
|
@@ -18,27 +18,25 @@ export class RouterProvider {
|
|
|
18
18
|
*/
|
|
19
19
|
_lastStartedTransitionId: number;
|
|
20
20
|
/**
|
|
21
|
-
* @type {Queue<
|
|
21
|
+
* @type {Queue<ng.Transition>}
|
|
22
22
|
*/
|
|
23
|
-
_transitionHistory: Queue<
|
|
23
|
+
_transitionHistory: Queue<ng.Transition>;
|
|
24
24
|
/**
|
|
25
|
-
* @type {Queue<
|
|
25
|
+
* @type {Queue<ng.Transition>}
|
|
26
26
|
*/
|
|
27
|
-
_successfulTransitions: Queue<
|
|
28
|
-
import("./transition/transition.js").Transition
|
|
29
|
-
>;
|
|
27
|
+
_successfulTransitions: Queue<ng.Transition>;
|
|
30
28
|
/**
|
|
31
|
-
* @type {
|
|
29
|
+
* @type {ng.StateDeclaration|undefined}
|
|
32
30
|
*/
|
|
33
|
-
current:
|
|
31
|
+
current: ng.StateDeclaration | undefined;
|
|
34
32
|
/**
|
|
35
|
-
* @type {
|
|
33
|
+
* @type {ng.StateObject|undefined}
|
|
36
34
|
*/
|
|
37
|
-
$current:
|
|
35
|
+
$current: ng.StateObject | undefined;
|
|
38
36
|
/**
|
|
39
|
-
* @type {
|
|
37
|
+
* @type {ng.Transition|undefined}
|
|
40
38
|
*/
|
|
41
|
-
transition:
|
|
39
|
+
transition: ng.Transition | undefined;
|
|
42
40
|
$get: () => this;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
@@ -6,6 +6,7 @@ import { Transition } from "../transition/transition.js";
|
|
|
6
6
|
import {
|
|
7
7
|
TransitionStateHookFn,
|
|
8
8
|
TransitionOptions,
|
|
9
|
+
HookResult,
|
|
9
10
|
} from "../transition/interface.ts";
|
|
10
11
|
import {
|
|
11
12
|
ResolvePolicy,
|
|
@@ -26,11 +27,11 @@ export interface TargetStateDef {
|
|
|
26
27
|
options?: TransitionOptions;
|
|
27
28
|
}
|
|
28
29
|
export type ResolveTypes = Resolvable | ResolvableLiteral | ProviderLike;
|
|
30
|
+
export type RawViewConfig = ViewDeclaration | string;
|
|
29
31
|
/**
|
|
30
32
|
* Interface for declaring a view
|
|
31
33
|
*
|
|
32
34
|
* This interface defines the basic data that a normalized view declaration will have on it.
|
|
33
|
-
* Add any additional fields that the framework requires to that interface.
|
|
34
35
|
*/
|
|
35
36
|
export interface ViewDeclaration {
|
|
36
37
|
/**
|
|
@@ -38,29 +39,22 @@ export interface ViewDeclaration {
|
|
|
38
39
|
*/
|
|
39
40
|
$name?: string;
|
|
40
41
|
/**
|
|
41
|
-
* The normalized address for the `
|
|
42
|
+
* The normalized address for the `ng-view` which this ViewConfig targets.
|
|
42
43
|
*
|
|
43
|
-
* A ViewConfig targets a `
|
|
44
|
+
* A ViewConfig targets a `ng-view` in the DOM (relative to the `ngVIewContextAnchor`) which has
|
|
44
45
|
* a specific name.
|
|
45
46
|
* @example `header` or `$default`
|
|
46
47
|
*
|
|
47
|
-
* The `
|
|
48
|
+
* The `ngVIewName` can also target a _nested view_ by providing a dot-notation address
|
|
48
49
|
* @example `foo.bar` or `foo.$default.bar`
|
|
49
50
|
*/
|
|
50
|
-
$
|
|
51
|
+
$ngViewName?: string;
|
|
51
52
|
/**
|
|
52
|
-
* The normalized context anchor (state name) for the `
|
|
53
|
+
* The normalized context anchor (state name) for the `ngVIewName`
|
|
53
54
|
*
|
|
54
|
-
* When targeting a `
|
|
55
|
+
* When targeting a `ng-view`, the `ngVIewName` address is anchored to a context name (state name).
|
|
55
56
|
*/
|
|
56
|
-
$
|
|
57
|
-
/**
|
|
58
|
-
* A type identifier for the View
|
|
59
|
-
*
|
|
60
|
-
* This is used when loading prerequisites for the view, before it enters the DOM. Different types of views
|
|
61
|
-
* may load differently (e.g., templateProvider+controllerProvider vs component class)
|
|
62
|
-
*/
|
|
63
|
-
$type?: string;
|
|
57
|
+
$ngViewContextAnchor?: string;
|
|
64
58
|
/**
|
|
65
59
|
* The context that this view is declared within.
|
|
66
60
|
*/
|
|
@@ -188,7 +182,7 @@ export interface ViewDeclaration {
|
|
|
188
182
|
* A property of [[StateDeclaration]] or [[ViewDeclaration]]:
|
|
189
183
|
*
|
|
190
184
|
* The controller function, or the name of a registered controller. The controller function will be used
|
|
191
|
-
* to control the contents of the [[directives.
|
|
185
|
+
* to control the contents of the [[directives.ngVIew]] directive.
|
|
192
186
|
*
|
|
193
187
|
* If specified as a string, controllerAs can be declared here, i.e., "FooController as foo" instead of in
|
|
194
188
|
* a separate [[controllerAs]] property.
|
|
@@ -247,7 +241,7 @@ export interface ViewDeclaration {
|
|
|
247
241
|
* A property of [[StateDeclaration]] or [[ViewDeclaration]]:
|
|
248
242
|
*
|
|
249
243
|
* HTML template as a string, or a function which returns an html template as a string.
|
|
250
|
-
* This template will be used to render the corresponding [[directives.
|
|
244
|
+
* This template will be used to render the corresponding [[directives.ngVIew]] directive.
|
|
251
245
|
*
|
|
252
246
|
* This property takes precedence over templateUrl.
|
|
253
247
|
*
|
|
@@ -255,7 +249,7 @@ export interface ViewDeclaration {
|
|
|
255
249
|
*
|
|
256
250
|
* #### Example:
|
|
257
251
|
* ```js
|
|
258
|
-
* template: "<h1>inline template definition</h1><div
|
|
252
|
+
* template: "<h1>inline template definition</h1><div ng-view></div>"
|
|
259
253
|
* ```
|
|
260
254
|
*
|
|
261
255
|
* #### Example:
|
|
@@ -272,7 +266,7 @@ export interface ViewDeclaration {
|
|
|
272
266
|
* A property of [[StateDeclaration]] or [[ViewDeclaration]]:
|
|
273
267
|
*
|
|
274
268
|
* A path or a function that returns a path to an html template.
|
|
275
|
-
* The template will be fetched and used to render the corresponding [[directives.
|
|
269
|
+
* The template will be fetched and used to render the corresponding [[directives.ngVIew]] directive.
|
|
276
270
|
*
|
|
277
271
|
* If `templateUrl` is a function, it will be called with the Transition parameters as the first argument.
|
|
278
272
|
*
|
|
@@ -295,7 +289,7 @@ export interface ViewDeclaration {
|
|
|
295
289
|
* A property of [[StateDeclaration]] or [[ViewDeclaration]]:
|
|
296
290
|
*
|
|
297
291
|
* Injected function which returns the HTML template.
|
|
298
|
-
* The template will be used to render the corresponding [[directives.
|
|
292
|
+
* The template will be used to render the corresponding [[directives.ngVIew]] directive.
|
|
299
293
|
*
|
|
300
294
|
* #### Example:
|
|
301
295
|
* ```js
|
|
@@ -324,8 +318,6 @@ export type RedirectToResult =
|
|
|
324
318
|
/**
|
|
325
319
|
* The StateDeclaration object is used to define a state or nested state.
|
|
326
320
|
*
|
|
327
|
-
* Note: Each implementation of UI-Router (for a specific framework)
|
|
328
|
-
* extends this interface as necessary.
|
|
329
321
|
*
|
|
330
322
|
* #### Example:
|
|
331
323
|
* ```js
|
|
@@ -387,6 +379,131 @@ export interface StateDeclaration {
|
|
|
387
379
|
* ```
|
|
388
380
|
*/
|
|
389
381
|
parent?: string | StateDeclaration;
|
|
382
|
+
/**
|
|
383
|
+
* Resolve - a mechanism to asynchronously fetch data, participating in the Transition lifecycle
|
|
384
|
+
*
|
|
385
|
+
* The `resolve:` property defines data (or other dependencies) to be fetched asynchronously when the state is being entered.
|
|
386
|
+
* After the data is fetched, it may be used in views, transition hooks or other resolves that belong to this state.
|
|
387
|
+
* The data may also be used in any views or resolves that belong to nested states.
|
|
388
|
+
*
|
|
389
|
+
* ### As an array
|
|
390
|
+
*
|
|
391
|
+
* Each array element should be a [[ResolvableLiteral]] object.
|
|
392
|
+
*
|
|
393
|
+
* #### Example:
|
|
394
|
+
* The `user` resolve injects the current `Transition` and the `UserService` (using its token, which is a string).
|
|
395
|
+
* The [[ResolvableLiteral.resolvePolicy]] sets how the resolve is processed.
|
|
396
|
+
* The `user` data, fetched asynchronously, can then be used in a view.
|
|
397
|
+
* ```js
|
|
398
|
+
* var state = {
|
|
399
|
+
* name: 'user',
|
|
400
|
+
* url: '/user/:userId
|
|
401
|
+
* resolve: [
|
|
402
|
+
* {
|
|
403
|
+
* token: 'user',
|
|
404
|
+
* policy: { when: 'EAGER' },
|
|
405
|
+
* deps: ['UserService', Transition],
|
|
406
|
+
* resolveFn: (userSvc, trans) => userSvc.fetchUser(trans.params().userId) },
|
|
407
|
+
* }
|
|
408
|
+
* ]
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* Note: an Angular 2 style [`useFactory` provider literal](https://angular.io/docs/ts/latest/cookbook/dependency-injection.html#!#provide)
|
|
413
|
+
* may also be used. See [[ProviderLike]].
|
|
414
|
+
* #### Example:
|
|
415
|
+
* ```
|
|
416
|
+
* resolve: [
|
|
417
|
+
* { provide: 'token', useFactory: (http) => http.get('/'), deps: [ Http ] },
|
|
418
|
+
* ]
|
|
419
|
+
* ```
|
|
420
|
+
*
|
|
421
|
+
* ### As an object
|
|
422
|
+
*
|
|
423
|
+
* The `resolve` property may be an object where:
|
|
424
|
+
* - Each key (string) is the name of the dependency.
|
|
425
|
+
* - Each value (function) is an injectable function which returns the dependency, or a promise for the dependency.
|
|
426
|
+
*
|
|
427
|
+
* This style is based on AngularTS injectable functions, but can be used with any UI-Router implementation.
|
|
428
|
+
* If your code will be minified, the function should be ["annotated" in the AngularTS manner](https://docs.angularjs.org/guide/di#dependency-annotation).
|
|
429
|
+
*
|
|
430
|
+
* #### AngularTS Example:
|
|
431
|
+
* ```js
|
|
432
|
+
* resolve: {
|
|
433
|
+
* // If you inject `myStateDependency` into a controller, you'll get "abc"
|
|
434
|
+
* myStateDependency: function() {
|
|
435
|
+
* return "abc";
|
|
436
|
+
* },
|
|
437
|
+
* // Dependencies are annotated in "Inline Array Annotation"
|
|
438
|
+
* myAsyncData: ['$http', '$transition$' function($http, $transition$) {
|
|
439
|
+
* // Return a promise (async) for the data
|
|
440
|
+
* return $http.get("/foos/" + $transition$.params().foo);
|
|
441
|
+
* }]
|
|
442
|
+
* }
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* Note: You cannot specify a policy for each Resolvable, nor can you use non-string
|
|
446
|
+
* tokens when using the object style `resolve:` block.
|
|
447
|
+
*
|
|
448
|
+
* ### Lifecycle
|
|
449
|
+
*
|
|
450
|
+
* Since a resolve function can return a promise, the router will delay entering the state until the promises are ready.
|
|
451
|
+
* If any of the promises are rejected, the Transition is aborted with an Error.
|
|
452
|
+
*
|
|
453
|
+
* By default, resolves for a state are fetched just before that state is entered.
|
|
454
|
+
* Note that only states which are being *entered* during the `Transition` have their resolves fetched.
|
|
455
|
+
* States that are "retained" do not have their resolves re-fetched.
|
|
456
|
+
*
|
|
457
|
+
* If you are currently in a parent state `parent` and are transitioning to a child state `parent.child`, the
|
|
458
|
+
* previously resolved data for state `parent` can be injected into `parent.child` without delay.
|
|
459
|
+
*
|
|
460
|
+
* Any resolved data for `parent.child` is retained until `parent.child` is exited, e.g., by transitioning back to the `parent` state.
|
|
461
|
+
*
|
|
462
|
+
* Because of this scoping and lifecycle, resolves are a great place to fetch your application's primary data.
|
|
463
|
+
*
|
|
464
|
+
* ### Injecting resolves into other things
|
|
465
|
+
*
|
|
466
|
+
* During a transition, Resolve data can be injected into:
|
|
467
|
+
*
|
|
468
|
+
* - Views (the components which fill a `ng-view` tag)
|
|
469
|
+
* - Transition Hooks
|
|
470
|
+
* - Other resolves (a resolve may depend on asynchronous data from a different resolve)
|
|
471
|
+
*
|
|
472
|
+
* ### Injecting other things into resolves
|
|
473
|
+
*
|
|
474
|
+
* Resolve functions usually have dependencies on some other API(s).
|
|
475
|
+
* The dependencies are usually declared and injected into the resolve function.
|
|
476
|
+
* A common pattern is to inject a custom service such as `UserService`.
|
|
477
|
+
* The resolve then delegates to a service method, such as `UserService.list()`;
|
|
478
|
+
*
|
|
479
|
+
* #### Special injectable tokens
|
|
480
|
+
*
|
|
481
|
+
* - `UIRouter`: The [[UIRouter]] instance which has references to all the UI-Router services.
|
|
482
|
+
* - `Transition`: The current [[Transition]] object; information and API about the current transition, such as
|
|
483
|
+
* "to" and "from" State Parameters and transition options.
|
|
484
|
+
* - `'$transition$'`: A string alias for the `Transition` injectable
|
|
485
|
+
* - `'$state$'`: For `onEnter`/`onExit`/`onRetain`, the state being entered/exited/retained.
|
|
486
|
+
* - Other resolve tokens: A resolve can depend on another resolve, either from the same state, or from any parent state.
|
|
487
|
+
*
|
|
488
|
+
* #### Example:
|
|
489
|
+
* ```js
|
|
490
|
+
* // Injecting a resolve into another resolve
|
|
491
|
+
* resolve: [
|
|
492
|
+
* // Define a resolve 'allusers' which delegates to the UserService.list()
|
|
493
|
+
* // which returns a promise (async) for all the users
|
|
494
|
+
* { provide: 'allusers', useFactory: (UserService) => UserService.list(), deps: [UserService] },
|
|
495
|
+
*
|
|
496
|
+
* // Define a resolve 'user' which depends on the allusers resolve.
|
|
497
|
+
* // This resolve function is not called until 'allusers' is ready.
|
|
498
|
+
* { provide: 'user', (allusers, trans) => _.find(allusers, trans.params().userId, deps: ['allusers', Transition] }
|
|
499
|
+
* }
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
resolve?:
|
|
503
|
+
| ResolveTypes[]
|
|
504
|
+
| {
|
|
505
|
+
[key: string]: Injectable<any>;
|
|
506
|
+
};
|
|
390
507
|
/**
|
|
391
508
|
* Sets the resolve policy defaults for all resolves on this state
|
|
392
509
|
*
|
|
@@ -455,16 +572,16 @@ export interface StateDeclaration {
|
|
|
455
572
|
/**
|
|
456
573
|
* Named views
|
|
457
574
|
*
|
|
458
|
-
* An optional object which defines multiple views, or explicitly targets specific named
|
|
575
|
+
* An optional object which defines multiple views, or explicitly targets specific named ng-views.
|
|
459
576
|
*
|
|
460
577
|
* - What is a view urlConfig
|
|
461
|
-
* - What is a
|
|
578
|
+
* - What is a ng-view
|
|
462
579
|
* - Shorthand controller/template
|
|
463
580
|
* - Incompatible with ^
|
|
464
581
|
*
|
|
465
582
|
* Examples:
|
|
466
583
|
*
|
|
467
|
-
* Targets three named
|
|
584
|
+
* Targets three named ng-views in the parent state's template
|
|
468
585
|
*
|
|
469
586
|
* #### Example:
|
|
470
587
|
* ```js
|
|
@@ -484,8 +601,8 @@ export interface StateDeclaration {
|
|
|
484
601
|
*
|
|
485
602
|
* @example
|
|
486
603
|
* ```js
|
|
487
|
-
* // Targets named
|
|
488
|
-
* // named `
|
|
604
|
+
* // Targets named ng-view="header" from ancestor state 'top''s template, and
|
|
605
|
+
* // named `ng-view="body" from parent state's template.
|
|
489
606
|
* views: {
|
|
490
607
|
* 'header@top': {
|
|
491
608
|
* controller: "msgHeaderCtrl",
|
|
@@ -497,9 +614,7 @@ export interface StateDeclaration {
|
|
|
497
614
|
* }
|
|
498
615
|
* ```
|
|
499
616
|
*/
|
|
500
|
-
views?:
|
|
501
|
-
[key: string]: ViewDeclaration;
|
|
502
|
-
};
|
|
617
|
+
views?: Record<string, RawViewConfig>;
|
|
503
618
|
/**
|
|
504
619
|
* An inherited property to store state data
|
|
505
620
|
*
|
|
@@ -825,7 +940,7 @@ export type BuiltStateDeclaration = StateDeclaration & {
|
|
|
825
940
|
/** Computed parameters of this state */
|
|
826
941
|
params?: Record<string, any>;
|
|
827
942
|
/** Optional parent state */
|
|
828
|
-
parent?:
|
|
943
|
+
parent?: StateDeclaration | null;
|
|
829
944
|
/** Optional inherited data */
|
|
830
945
|
data?: any;
|
|
831
946
|
_stateObjectCache?: {
|
|
@@ -876,3 +991,51 @@ export type _StateDeclaration =
|
|
|
876
991
|
| {
|
|
877
992
|
new (): StateDeclaration;
|
|
878
993
|
};
|
|
994
|
+
/**
|
|
995
|
+
* The signature for the callback function provided to [[StateRegistry.onStatesChanged]].
|
|
996
|
+
*
|
|
997
|
+
* This callback receives two parameters:
|
|
998
|
+
*
|
|
999
|
+
* @param event a string; either "registered" or "deregistered"
|
|
1000
|
+
* @param states the list of [[StateDeclaration]]s that were registered (or deregistered).
|
|
1001
|
+
*/
|
|
1002
|
+
export type StateRegistryListener = (
|
|
1003
|
+
event: "registered" | "deregistered",
|
|
1004
|
+
states: StateDeclaration[],
|
|
1005
|
+
) => void;
|
|
1006
|
+
/**
|
|
1007
|
+
* A function that builds the final value for a specific field on a [[StateObject]].
|
|
1008
|
+
*
|
|
1009
|
+
* A series of builder functions for a given field are chained together.
|
|
1010
|
+
* The final value returned from the chain of builders is applied to the built [[StateObject]].
|
|
1011
|
+
* Builder functions should call the [[parent]] function either first or last depending on the desired composition behavior.
|
|
1012
|
+
*
|
|
1013
|
+
* @param state the _partially built_ [[StateObject]]. The [[StateDeclaration]] can be inspected via [[StateObject.self]]
|
|
1014
|
+
* @param parent the previous builder function in the series.
|
|
1015
|
+
*/
|
|
1016
|
+
export type BuilderFunction = (
|
|
1017
|
+
state: ng.StateObject & ng.BuiltStateDeclaration,
|
|
1018
|
+
parent?: BuilderFunction,
|
|
1019
|
+
) => any;
|
|
1020
|
+
export type OnInvalidCallback = (
|
|
1021
|
+
toState?: TargetState,
|
|
1022
|
+
fromState?: TargetState,
|
|
1023
|
+
injector?: ng.InjectorService,
|
|
1024
|
+
) => HookResult;
|
|
1025
|
+
export type LazyLoadFn = (
|
|
1026
|
+
transition: Transition,
|
|
1027
|
+
state: StateDeclaration,
|
|
1028
|
+
) => Promise<LazyLoadResult>;
|
|
1029
|
+
export interface Builders {
|
|
1030
|
+
[key: string]: BuilderFunction[];
|
|
1031
|
+
name: BuilderFunction[];
|
|
1032
|
+
parent: BuilderFunction[];
|
|
1033
|
+
data: BuilderFunction[];
|
|
1034
|
+
url: BuilderFunction[];
|
|
1035
|
+
navigable: BuilderFunction[];
|
|
1036
|
+
params: BuilderFunction[];
|
|
1037
|
+
views: BuilderFunction[];
|
|
1038
|
+
path: BuilderFunction[];
|
|
1039
|
+
includes: BuilderFunction[];
|
|
1040
|
+
resolvables: BuilderFunction[];
|
|
1041
|
+
}
|
|
@@ -39,9 +39,11 @@
|
|
|
39
39
|
* { provide: "myBazResolve", useFactory: function(dep) { dep.fetchSomethingAsPromise() }, deps: [ "DependencyName" ] }
|
|
40
40
|
* ]
|
|
41
41
|
* @param {ng.StateObject & ng.StateDeclaration} state
|
|
42
|
+
* @param {boolean | undefined} strictDi
|
|
42
43
|
*/
|
|
43
44
|
export function resolvablesBuilder(
|
|
44
45
|
state: ng.StateObject & ng.StateDeclaration,
|
|
46
|
+
strictDi: boolean | undefined,
|
|
45
47
|
): any[];
|
|
46
48
|
/**
|
|
47
49
|
* A internal global service
|
|
@@ -65,38 +67,36 @@ export class StateBuilder {
|
|
|
65
67
|
urlService: ng.UrlService,
|
|
66
68
|
);
|
|
67
69
|
_matcher: import("./state-matcher.js").StateMatcher;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
views: any[];
|
|
82
|
-
path: (typeof pathBuilder)[];
|
|
83
|
-
includes: (typeof includesBuilder)[];
|
|
84
|
-
resolvables: (typeof resolvablesBuilder)[];
|
|
85
|
-
};
|
|
86
|
-
builder(name: any, fn: any): any;
|
|
70
|
+
/** @type {ng.InjectorService | undefined} */
|
|
71
|
+
_$injector: ng.InjectorService | undefined;
|
|
72
|
+
/** @type {Builders} */
|
|
73
|
+
_builders: Builders;
|
|
74
|
+
/**
|
|
75
|
+
* @param {string} name
|
|
76
|
+
* @param {*} fn
|
|
77
|
+
* @returns {BuilderFunction | BuilderFunction[] | null | undefined}
|
|
78
|
+
*/
|
|
79
|
+
builder(
|
|
80
|
+
name: string,
|
|
81
|
+
fn: any,
|
|
82
|
+
): BuilderFunction | BuilderFunction[] | null | undefined;
|
|
87
83
|
/**
|
|
88
84
|
* Builds all of the properties on an essentially blank State object, returning a State object which has all its
|
|
89
85
|
* properties and API built.
|
|
90
86
|
*
|
|
91
|
-
* @param state an uninitialized State object
|
|
92
|
-
* @returns the built State object
|
|
87
|
+
* @param {ng.StateObject} state an uninitialized State object
|
|
88
|
+
* @returns {ng.StateObject | null} the built State object
|
|
89
|
+
*/
|
|
90
|
+
build(state: ng.StateObject): ng.StateObject | null;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param {ng.StateObject} state
|
|
94
|
+
* @returns {string}
|
|
93
95
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
name(state:
|
|
96
|
+
parentName(state: ng.StateObject): string;
|
|
97
|
+
/** @param {ng.StateObject} state*/
|
|
98
|
+
name(state: ng.StateObject): string;
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
declare function includesBuilder(state: any): any;
|
|
102
|
-
export {};
|
|
100
|
+
export type BuilderFunction = import("./interface.js").BuilderFunction;
|
|
101
|
+
export type Builders = import("./interface.js").Builders;
|
|
102
|
+
export type UrlMatcher = import("../url/url-matcher.js").UrlMatcher;
|
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
/** @typedef {import("./state-object.js").StateObject} StateObject */
|
|
2
|
+
/** @typedef {import("./interface.ts").StateOrName} StateOrName */
|
|
3
|
+
/** @typedef {import("./interface.ts").StateStore} StateStore */
|
|
1
4
|
export class StateMatcher {
|
|
2
|
-
/** @param {
|
|
3
|
-
constructor(states:
|
|
4
|
-
/** @type {
|
|
5
|
-
_states:
|
|
6
|
-
|
|
5
|
+
/** @param {StateStore} states */
|
|
6
|
+
constructor(states: StateStore);
|
|
7
|
+
/** @type {StateStore} */
|
|
8
|
+
_states: StateStore;
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} stateName
|
|
11
|
+
*/
|
|
12
|
+
isRelative(stateName: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @param {StateOrName} stateOrName
|
|
15
|
+
* @param {StateOrName | undefined} [base]
|
|
16
|
+
* @returns {StateObject | undefined}
|
|
17
|
+
*/
|
|
7
18
|
find(
|
|
8
|
-
stateOrName:
|
|
9
|
-
base
|
|
19
|
+
stateOrName: StateOrName,
|
|
20
|
+
base?: StateOrName | undefined,
|
|
10
21
|
matchGlob?: boolean,
|
|
11
|
-
):
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
): StateObject | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* `
|
|
25
|
+
* @param {string} name
|
|
26
|
+
* @param {StateOrName} base
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
resolvePath(name: string, base: StateOrName): string;
|
|
15
30
|
}
|
|
31
|
+
export type StateObject = import("./state-object.js").StateObject;
|
|
32
|
+
export type StateOrName = import("./interface.ts").StateOrName;
|
|
33
|
+
export type StateStore = import("./interface.ts").StateStore;
|