@angular-wave/angular.ts 0.0.21 → 0.0.23
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/Makefile +1 -1
- package/TODO.md +14 -0
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +8 -2
- package/package.json +1 -1
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +15 -6
- package/src/animations/animate-js.js +1 -1
- package/src/animations/animate-queue.js +1 -1
- package/src/animations/shared.js +0 -14
- package/src/core/compile.js +6 -3
- package/src/directive/if.js +0 -79
- package/src/directive/if.md +80 -0
- package/src/directive/include.js +0 -82
- package/src/directive/include.md +86 -0
- package/src/directive/repeat.js +0 -1
- package/src/filters/order-by.js +8 -8
- package/src/loader.js +0 -1
- package/src/router/common/trace.js +1 -1
- package/src/router/directives/stateDirectives.js +16 -14
- package/src/router/directives/viewDirective.js +5 -13
- package/src/router/hooks/resolve.js +3 -4
- package/src/router/hooks/views.js +3 -2
- package/src/router/state/stateService.js +1 -2
- package/src/router/stateProvider.js +8 -0
- package/src/router/templateFactory.js +13 -7
- package/src/router/transition/interface.js +14 -14
- package/src/router/transition/rejectFactory.js +29 -20
- package/src/router/transition/transition.js +5 -1
- package/src/router/transition/transitionHook.js +5 -5
- package/src/router/url/urlMatcher.js +1 -2
- package/src/router/url/urlRule.js +10 -2
- package/src/router/url/urlRules.js +1 -1
- package/src/services/browser.js +3 -18
- package/src/shared/common.js +0 -1
- package/test/module-test.html +44 -12
- package/test/router/ng-state-builder.spec.js +81 -0
- package/test/router/services.spec.js +70 -0
- package/test/router/state-directives.spec.js +1182 -0
- package/test/router/template-factory.spec.js +146 -0
- package/test/router/url-matcher-factory.spec.js +1313 -0
- package/test/router/view-directive.spec.js +2013 -0
- package/test/router/view-hook.spec.js +217 -0
- package/test/router/view-scroll.spec.js +77 -0
- package/test/router/view.spec.js +117 -0
- package/types/angular.d.ts +132 -124
- package/types/index.d.ts +2350 -2187
- package/types/jqlite.d.ts +463 -418
- package/types/router/core/common/common.d.ts +70 -24
- package/types/router/core/common/coreservices.d.ts +30 -32
- package/types/router/core/common/glob.d.ts +9 -9
- package/types/router/core/common/hof.d.ts +12 -4
- package/types/router/core/common/index.d.ts +8 -8
- package/types/router/core/common/predicates.d.ts +1 -1
- package/types/router/core/common/queue.d.ts +13 -13
- package/types/router/core/common/safeConsole.d.ts +3 -3
- package/types/router/core/common/strings.d.ts +4 -2
- package/types/router/core/common/trace.d.ts +94 -82
- package/types/router/core/globals.d.ts +37 -37
- package/types/router/core/hooks/coreResolvables.d.ts +5 -3
- package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
- package/types/router/core/hooks/invalidTransition.d.ts +4 -2
- package/types/router/core/hooks/lazyLoad.d.ts +10 -5
- package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
- package/types/router/core/hooks/redirectTo.d.ts +4 -2
- package/types/router/core/hooks/resolve.d.ts +10 -4
- package/types/router/core/hooks/updateGlobals.d.ts +4 -2
- package/types/router/core/hooks/url.d.ts +4 -2
- package/types/router/core/hooks/views.d.ts +7 -3
- package/types/router/core/index.d.ts +11 -12
- package/types/router/core/interface.d.ts +83 -81
- package/types/router/core/params/index.d.ts +5 -5
- package/types/router/core/params/interface.d.ts +439 -439
- package/types/router/core/params/param.d.ts +72 -60
- package/types/router/core/params/paramType.d.ts +40 -40
- package/types/router/core/params/paramTypes.d.ts +169 -165
- package/types/router/core/params/stateParams.d.ts +13 -13
- package/types/router/core/path/index.d.ts +2 -2
- package/types/router/core/path/pathNode.d.ts +49 -49
- package/types/router/core/path/pathUtils.d.ts +100 -74
- package/types/router/core/resolve/index.d.ts +3 -3
- package/types/router/core/resolve/interface.d.ts +137 -137
- package/types/router/core/resolve/resolvable.d.ts +60 -54
- package/types/router/core/resolve/resolveContext.d.ts +84 -79
- package/types/router/core/router.d.ts +95 -86
- package/types/router/core/state/index.d.ts +8 -8
- package/types/router/core/state/interface.d.ts +667 -643
- package/types/router/core/state/stateBuilder.d.ts +41 -38
- package/types/router/core/state/stateMatcher.d.ts +11 -9
- package/types/router/core/state/stateObject.d.ts +154 -139
- package/types/router/core/state/stateQueueManager.d.ts +26 -21
- package/types/router/core/state/stateRegistry.d.ts +124 -121
- package/types/router/core/state/stateService.d.ts +380 -343
- package/types/router/core/state/targetState.d.ts +74 -69
- package/types/router/core/transition/hookBuilder.d.ts +34 -30
- package/types/router/core/transition/hookRegistry.d.ts +96 -74
- package/types/router/core/transition/index.d.ts +8 -8
- package/types/router/core/transition/interface.d.ts +652 -609
- package/types/router/core/transition/rejectFactory.d.ts +97 -97
- package/types/router/core/transition/transition.d.ts +565 -517
- package/types/router/core/transition/transitionEventType.d.ts +20 -11
- package/types/router/core/transition/transitionHook.d.ts +90 -82
- package/types/router/core/transition/transitionService.d.ts +228 -161
- package/types/router/core/url/index.d.ts +8 -8
- package/types/router/core/url/interface.d.ts +100 -87
- package/types/router/core/url/urlConfig.d.ts +130 -126
- package/types/router/core/url/urlMatcher.d.ts +132 -127
- package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
- package/types/router/core/url/urlRouter.d.ts +91 -75
- package/types/router/core/url/urlRule.d.ts +123 -100
- package/types/router/core/url/urlRules.d.ts +240 -232
- package/types/router/core/url/urlService.d.ts +201 -201
- package/types/router/core/view/index.d.ts +2 -2
- package/types/router/core/view/interface.d.ts +26 -26
- package/types/router/core/view/view.d.ts +152 -143
- package/types/router/directives/viewDirective.d.ts +12 -11
- package/types/router/index.d.ts +11 -12
- package/types/router/interface.d.ts +361 -351
- package/types/router/legacy/resolveService.d.ts +44 -40
- package/types/router/legacy/stateEvents.d.ts +1 -1
- package/types/router/locationServices.d.ts +45 -37
- package/types/router/services.d.ts +9 -9
- package/types/router/stateFilters.d.ts +3 -3
- package/types/router/stateProvider.d.ts +240 -235
- package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
- package/types/router/statebuilders/views.d.ts +35 -22
- package/types/router/templateFactory.d.ts +99 -79
- package/types/router/viewScroll.d.ts +7 -7
- package/src/directive/a.js +0 -37
- package/types/router/angular.d.ts +0 -1
- package/types/router/core/vanilla.d.ts +0 -1
- package/types/router/directives/stateDirectives.d.ts +0 -3
- package/types/router/injectables.d.ts +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StateDeclaration } from
|
|
2
|
-
import { PredicateBinary } from
|
|
3
|
-
import { Transition } from
|
|
4
|
-
import { StateObject } from
|
|
5
|
-
import { PathNode } from
|
|
6
|
-
import { TargetState } from
|
|
7
|
-
import { RegisteredHook } from
|
|
1
|
+
import { StateDeclaration } from "../state/interface";
|
|
2
|
+
import { PredicateBinary } from "../common/common";
|
|
3
|
+
import { Transition } from "./transition";
|
|
4
|
+
import { StateObject } from "../state/stateObject";
|
|
5
|
+
import { PathNode } from "../path/pathNode";
|
|
6
|
+
import { TargetState } from "../state/targetState";
|
|
7
|
+
import { RegisteredHook } from "./hookRegistry";
|
|
8
8
|
/**
|
|
9
9
|
* The TransitionOptions object can be used to change the behavior of a transition.
|
|
10
10
|
*
|
|
@@ -12,91 +12,91 @@ import { RegisteredHook } from './hookRegistry';
|
|
|
12
12
|
* It can also be used with a `uiSref`.
|
|
13
13
|
*/
|
|
14
14
|
export interface TransitionOptions {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
15
|
+
/**
|
|
16
|
+
* This option changes how the Transition interacts with the browser's location bar (URL).
|
|
17
|
+
*
|
|
18
|
+
* - If `true`, it will update the url in the location bar.
|
|
19
|
+
* - If `false`, it will not update the url in the location bar.
|
|
20
|
+
* - If it is the string `"replace"`, it will update the url and also replace the last history record.
|
|
21
|
+
*
|
|
22
|
+
* @default `true`
|
|
23
|
+
*/
|
|
24
|
+
location?: boolean | "replace";
|
|
25
|
+
/**
|
|
26
|
+
* When transitioning to relative path (e.g '`^`'), this option defines which state to be relative from.
|
|
27
|
+
* @default `$state.current`
|
|
28
|
+
*/
|
|
29
|
+
relative?: string | StateDeclaration | StateObject;
|
|
30
|
+
/**
|
|
31
|
+
* This option sets whether or not the transition's parameter values should be inherited from
|
|
32
|
+
* the current parameter values.
|
|
33
|
+
*
|
|
34
|
+
* - If `true`, it will inherit parameter values from the current parameter values.
|
|
35
|
+
* - If `false`, only the parameters which are provided to `transitionTo` will be used.
|
|
36
|
+
*
|
|
37
|
+
* @default `true`
|
|
38
|
+
*/
|
|
39
|
+
inherit?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated
|
|
42
|
+
*/
|
|
43
|
+
notify?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* This option may be used to force states which are currently active to reload.
|
|
46
|
+
*
|
|
47
|
+
* During a normal transition, a state is "retained" if:
|
|
48
|
+
* - It was previously active
|
|
49
|
+
* - The state's parameter values have not changed
|
|
50
|
+
* - All the parent states' parameter values have not changed
|
|
51
|
+
*
|
|
52
|
+
* Forcing a reload of a state will cause it to be exited and entered, which will:
|
|
53
|
+
* - Refetch that state's resolve data
|
|
54
|
+
* - Exit the state (onExit hook)
|
|
55
|
+
* - Re-enter the state (onEnter hook)
|
|
56
|
+
* - Re-render the views (controllers and templates)
|
|
57
|
+
*
|
|
58
|
+
* - When `true`, the destination state (and all parent states) will be reloaded.
|
|
59
|
+
* - When it is a string and is the name of a state, or when it is a State object,
|
|
60
|
+
* that state and any children states will be reloaded.
|
|
61
|
+
*
|
|
62
|
+
* @default `false`
|
|
63
|
+
*/
|
|
64
|
+
reload?: boolean | string | StateDeclaration | StateObject;
|
|
65
|
+
/**
|
|
66
|
+
* You can define your own Transition Options inside this property and use them, e.g., from a Transition Hook
|
|
67
|
+
*/
|
|
68
|
+
custom?: any;
|
|
69
|
+
/**
|
|
70
|
+
* This option may be used to cancel the active transition (if one is active) in favour of the this one.
|
|
71
|
+
* This is the default behaviour or ui-router.
|
|
72
|
+
*
|
|
73
|
+
*
|
|
74
|
+
* - When `true`, the active transition will be canceled and new transition will begin.
|
|
75
|
+
* - when `false`, the transition will be canceled if a transition is already running. This can be useful in cases where
|
|
76
|
+
* you only want to navigate to a different state if you are not already navigating somewhere.
|
|
77
|
+
*
|
|
78
|
+
* @default `true`
|
|
79
|
+
*/
|
|
80
|
+
supercede?: boolean;
|
|
81
|
+
/** @internal */
|
|
82
|
+
reloadState?: StateObject;
|
|
83
|
+
/** @internal
|
|
84
|
+
* If this transition is a redirect, this property should be the original Transition (which was redirected to this one)
|
|
85
|
+
*/
|
|
86
|
+
redirectedFrom?: Transition;
|
|
87
|
+
/** @internal */
|
|
88
|
+
current?: () => Transition;
|
|
89
|
+
/** @internal */
|
|
90
|
+
source?: "sref" | "url" | "redirect" | "otherwise" | "unknown";
|
|
91
91
|
}
|
|
92
92
|
export interface TransitionHookOptions {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
current?: () => Transition;
|
|
94
|
+
transition?: Transition;
|
|
95
|
+
hookType?: string;
|
|
96
|
+
target?: any;
|
|
97
|
+
traceData?: any;
|
|
98
|
+
bind?: any;
|
|
99
|
+
stateHook?: boolean;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* TreeChanges encapsulates the various Paths that are involved in a Transition.
|
|
@@ -119,50 +119,54 @@ export interface TransitionHookOptions {
|
|
|
119
119
|
* @todo show visual state tree
|
|
120
120
|
*/
|
|
121
121
|
export interface TreeChanges {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
122
|
+
/** @nodoc */
|
|
123
|
+
[key: string]: PathNode[] | undefined;
|
|
124
|
+
/** The path of nodes in the state tree that the transition is coming *from* */
|
|
125
|
+
from: PathNode[];
|
|
126
|
+
/** The path of nodes in the state tree that the transition is going *to* */
|
|
127
|
+
to: PathNode[];
|
|
128
|
+
/**
|
|
129
|
+
* The path of active nodes that the transition is retaining.
|
|
130
|
+
*
|
|
131
|
+
* These nodes are neither exited, nor entered.
|
|
132
|
+
* Before and after the transition is successful, these nodes are active.
|
|
133
|
+
*/
|
|
134
|
+
retained: PathNode[];
|
|
135
|
+
/**
|
|
136
|
+
* The path of active nodes that the transition is retaining with updated "to params" applied.
|
|
137
|
+
*
|
|
138
|
+
* These nodes are neither exited, nor entered.
|
|
139
|
+
* Before and after the transition is successful, these nodes are active.
|
|
140
|
+
*
|
|
141
|
+
* This is a shallow copy of [[retained]], but with new (dynamic) parameter values from [[to]] applied.
|
|
142
|
+
*/
|
|
143
|
+
retainedWithToParams: PathNode[];
|
|
144
|
+
/**
|
|
145
|
+
* The path of previously active nodes that the transition is exiting.
|
|
146
|
+
*
|
|
147
|
+
* After the Transition is successful, these nodes are no longer active.
|
|
148
|
+
*
|
|
149
|
+
* Note that a state that is being reloaded (due to parameter values changing, or `reload: true`) may be in both the
|
|
150
|
+
* `exiting` and `entering` paths.
|
|
151
|
+
*/
|
|
152
|
+
exiting: PathNode[];
|
|
153
|
+
/**
|
|
154
|
+
* The path of nodes that the transition is entering.
|
|
155
|
+
*
|
|
156
|
+
* After the Transition is successful, these nodes will be active.
|
|
157
|
+
* Because they are entering, they have their resolves fetched, `onEnter` hooks run, and their views
|
|
158
|
+
* (component(s) or controller(s)+template(s)) refreshed.
|
|
159
|
+
*
|
|
160
|
+
* Note that a state that is reloaded (due to parameter values changing, or `reload: true`) may be in both the
|
|
161
|
+
* `exiting` and `entering` paths.
|
|
162
|
+
*/
|
|
163
|
+
entering: PathNode[];
|
|
164
164
|
}
|
|
165
|
-
export declare type IHookRegistration = (
|
|
165
|
+
export declare type IHookRegistration = (
|
|
166
|
+
matchCriteria: HookMatchCriteria,
|
|
167
|
+
callback: HookFn,
|
|
168
|
+
options?: HookRegOptions,
|
|
169
|
+
) => Function;
|
|
166
170
|
/**
|
|
167
171
|
* The signature for Transition Hooks.
|
|
168
172
|
*
|
|
@@ -187,7 +191,7 @@ export declare type IHookRegistration = (matchCriteria: HookMatchCriteria, callb
|
|
|
187
191
|
*
|
|
188
192
|
*/
|
|
189
193
|
export interface TransitionHookFn {
|
|
190
|
-
|
|
194
|
+
(transition: Transition): HookResult;
|
|
191
195
|
}
|
|
192
196
|
/**
|
|
193
197
|
* The signature for Transition State Hooks.
|
|
@@ -211,7 +215,7 @@ export interface TransitionHookFn {
|
|
|
211
215
|
* @returns a [[HookResult]] which may alter the transition
|
|
212
216
|
*/
|
|
213
217
|
export interface TransitionStateHookFn {
|
|
214
|
-
|
|
218
|
+
(transition: Transition, state: StateDeclaration): HookResult;
|
|
215
219
|
}
|
|
216
220
|
/**
|
|
217
221
|
* The signature for Transition onCreate Hooks.
|
|
@@ -223,9 +227,12 @@ export interface TransitionStateHookFn {
|
|
|
223
227
|
* @return a [[Transition]] which will then be returned from [[TransitionService.create]]
|
|
224
228
|
*/
|
|
225
229
|
export interface TransitionCreateHookFn {
|
|
226
|
-
|
|
230
|
+
(transition: Transition): void;
|
|
227
231
|
}
|
|
228
|
-
export declare type HookFn =
|
|
232
|
+
export declare type HookFn =
|
|
233
|
+
| TransitionHookFn
|
|
234
|
+
| TransitionStateHookFn
|
|
235
|
+
| TransitionCreateHookFn;
|
|
229
236
|
/**
|
|
230
237
|
* The return value of a [[TransitionHookFn]] or [[TransitionStateHookFn]]
|
|
231
238
|
*
|
|
@@ -239,29 +246,33 @@ export declare type HookFn = TransitionHookFn | TransitionStateHookFn | Transiti
|
|
|
239
246
|
* - If the promise resolves to anything else, the transition will resume
|
|
240
247
|
* - Anything else: the transition will resume
|
|
241
248
|
*/
|
|
242
|
-
export declare type HookResult =
|
|
249
|
+
export declare type HookResult =
|
|
250
|
+
| boolean
|
|
251
|
+
| TargetState
|
|
252
|
+
| void
|
|
253
|
+
| Promise<boolean | TargetState | void>;
|
|
243
254
|
/**
|
|
244
255
|
* These options may be provided when registering a Transition Hook (such as `onStart`)
|
|
245
256
|
*/
|
|
246
257
|
export interface HookRegOptions {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Sets the priority of the registered hook
|
|
260
|
+
*
|
|
261
|
+
* Hooks of the same type (onBefore, onStart, etc) are invoked in priority order. A hook with a higher priority
|
|
262
|
+
* is invoked before a hook with a lower priority.
|
|
263
|
+
*
|
|
264
|
+
* The default hook priority is 0
|
|
265
|
+
*/
|
|
266
|
+
priority?: number;
|
|
267
|
+
/**
|
|
268
|
+
* Specifies what `this` is bound to during hook invocation.
|
|
269
|
+
*/
|
|
270
|
+
bind?: any;
|
|
271
|
+
/**
|
|
272
|
+
* Limits the number of times that the hook will be invoked.
|
|
273
|
+
* Once the hook has been invoked this many times, it is automatically deregistered.
|
|
274
|
+
*/
|
|
275
|
+
invokeLimit?: number;
|
|
265
276
|
}
|
|
266
277
|
/**
|
|
267
278
|
* This interface specifies the api for registering Transition Hooks. Both the
|
|
@@ -269,426 +280,458 @@ export interface HookRegOptions {
|
|
|
269
280
|
* Note: the Transition object only allows hooks to be registered before the Transition is started.
|
|
270
281
|
*/
|
|
271
282
|
export interface IHookRegistry {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
283
|
+
/** @internal place to store the hooks */
|
|
284
|
+
_registeredHooks: {
|
|
285
|
+
[key: string]: RegisteredHook[];
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* Registers a [[TransitionHookFn]], called *before a transition starts*.
|
|
289
|
+
*
|
|
290
|
+
* Registers a transition lifecycle hook, which is invoked before a transition even begins.
|
|
291
|
+
* This hook can be useful to implement logic which prevents a transition from even starting, such
|
|
292
|
+
* as authentication, redirection
|
|
293
|
+
*
|
|
294
|
+
* See [[TransitionHookFn]] for the signature of the function.
|
|
295
|
+
*
|
|
296
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
297
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
298
|
+
*
|
|
299
|
+
* ### Lifecycle
|
|
300
|
+
*
|
|
301
|
+
* `onBefore` hooks are invoked *before a Transition starts*.
|
|
302
|
+
* No resolves have been fetched yet.
|
|
303
|
+
* Each `onBefore` hook is invoked synchronously, in the same call stack as [[StateService.transitionTo]].
|
|
304
|
+
* The registered `onBefore` hooks are invoked in priority order.
|
|
305
|
+
*
|
|
306
|
+
* Note: during the `onBefore` phase, additional hooks can be added to the specific [[Transition]] instance.
|
|
307
|
+
* These "on-the-fly" hooks only affect the currently running transition..
|
|
308
|
+
*
|
|
309
|
+
* ### Return value
|
|
310
|
+
*
|
|
311
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
312
|
+
* See [[HookResult]] for more information.
|
|
313
|
+
*
|
|
314
|
+
* If any hook modifies the transition *synchronously* (by throwing, returning `false`, or returning
|
|
315
|
+
* a [[TargetState]]), the remainder of the hooks are skipped.
|
|
316
|
+
* If a hook returns a promise, the remainder of the `onBefore` hooks are still invoked synchronously.
|
|
317
|
+
* All promises are resolved, and processed asynchronously before the `onStart` phase of the Transition.
|
|
318
|
+
*
|
|
319
|
+
* ### Examples
|
|
320
|
+
*
|
|
321
|
+
* #### Default Substate
|
|
322
|
+
*
|
|
323
|
+
* This example redirects any transition from 'home' to 'home.dashboard'. This is commonly referred to as a
|
|
324
|
+
* "default substate".
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```js
|
|
328
|
+
* // ng2
|
|
329
|
+
* transitionService.onBefore({ to: 'home' }, (trans: Transition) =>
|
|
330
|
+
* trans.router.stateService.target("home.dashboard"));
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* #### Data Driven Default Substate
|
|
334
|
+
*
|
|
335
|
+
* This example provides data-driven default substate functionality. It matches on a transition to any state
|
|
336
|
+
* which has `defaultSubstate: "some.sub.state"` defined. See: [[Transition.to]] which returns the "to state"
|
|
337
|
+
* definition.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```js
|
|
341
|
+
* // ng1
|
|
342
|
+
* // state declaration
|
|
343
|
+
* {
|
|
344
|
+
* name: 'home',
|
|
345
|
+
* template: '<div ui-view/>',
|
|
346
|
+
* defaultSubstate: 'home.dashboard'
|
|
347
|
+
* }
|
|
348
|
+
*
|
|
349
|
+
* var criteria = {
|
|
350
|
+
* to: function(state) {
|
|
351
|
+
* return state.defaultSubstate != null;
|
|
352
|
+
* }
|
|
353
|
+
* }
|
|
354
|
+
*
|
|
355
|
+
* $transitions.onBefore(criteria, function(trans: Transition) {
|
|
356
|
+
* var substate = trans.to().defaultSubstate;
|
|
357
|
+
* return trans.router.stateService.target(substate);
|
|
358
|
+
* });
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
*
|
|
362
|
+
* #### Require authentication
|
|
363
|
+
*
|
|
364
|
+
* This example cancels a transition to a state which requires authentication, if the user is not currently authenticated.
|
|
365
|
+
*
|
|
366
|
+
* This example assumes a state tree where all states which require authentication are children of a parent `'requireauth'` state.
|
|
367
|
+
* This example assumes `MyAuthService` synchronously returns a boolean from `isAuthenticated()`.
|
|
368
|
+
*
|
|
369
|
+
* #### Example:
|
|
370
|
+
* ```js
|
|
371
|
+
* // ng1
|
|
372
|
+
* $transitions.onBefore( { to: 'requireauth.**' }, function(trans) {
|
|
373
|
+
* var myAuthService = trans.injector().get('MyAuthService');
|
|
374
|
+
* // If isAuthenticated returns false, the transition is cancelled.
|
|
375
|
+
* return myAuthService.isAuthenticated();
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
380
|
+
* @param callback the hook function which will be invoked.
|
|
381
|
+
* @returns a function which deregisters the hook.
|
|
382
|
+
*/
|
|
383
|
+
onBefore(
|
|
384
|
+
matchCriteria: HookMatchCriteria,
|
|
385
|
+
callback: TransitionHookFn,
|
|
386
|
+
options?: HookRegOptions,
|
|
387
|
+
): Function;
|
|
388
|
+
/**
|
|
389
|
+
* Registers a [[TransitionHookFn]], called when a transition starts.
|
|
390
|
+
*
|
|
391
|
+
* Registers a transition lifecycle hook, which is invoked as a transition starts running.
|
|
392
|
+
* This hook can be useful to perform some asynchronous action before completing a transition.
|
|
393
|
+
*
|
|
394
|
+
* See [[TransitionHookFn]] for the signature of the function.
|
|
395
|
+
*
|
|
396
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
397
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
398
|
+
*
|
|
399
|
+
* ### Lifecycle
|
|
400
|
+
*
|
|
401
|
+
* `onStart` hooks are invoked asynchronously when the Transition starts running.
|
|
402
|
+
* This happens after the `onBefore` phase is complete.
|
|
403
|
+
* At this point, the Transition has not yet exited nor entered any states.
|
|
404
|
+
* The registered `onStart` hooks are invoked in priority order.
|
|
405
|
+
*
|
|
406
|
+
* Note: A built-in `onStart` hook with high priority is used to fetch any eager resolve data.
|
|
407
|
+
*
|
|
408
|
+
* ### Return value
|
|
409
|
+
*
|
|
410
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
411
|
+
* See [[HookResult]] for more information.
|
|
412
|
+
*
|
|
413
|
+
* ### Example
|
|
414
|
+
*
|
|
415
|
+
* #### Login during transition
|
|
416
|
+
*
|
|
417
|
+
* This example intercepts any transition to a state which requires authentication, when the user is
|
|
418
|
+
* not currently authenticated. It allows the user to authenticate asynchronously, then resumes the
|
|
419
|
+
* transition. If the user did not authenticate successfully, it redirects to the "guest" state, which
|
|
420
|
+
* does not require authentication.
|
|
421
|
+
*
|
|
422
|
+
* This example assumes:
|
|
423
|
+
* - a state tree where all states which require authentication are children of a parent `'auth'` state.
|
|
424
|
+
* - `MyAuthService.isAuthenticated()` synchronously returns a boolean.
|
|
425
|
+
* - `MyAuthService.authenticate()` presents a login dialog, and returns a promise which is resolved
|
|
426
|
+
* or rejected, whether or not the login attempt was successful.
|
|
427
|
+
*
|
|
428
|
+
* #### Example:
|
|
429
|
+
* ```js
|
|
430
|
+
* // ng1
|
|
431
|
+
* $transitions.onStart( { to: 'auth.**' }, function(trans) {
|
|
432
|
+
* var $state = trans.router.stateService;
|
|
433
|
+
* var MyAuthService = trans.injector().get('MyAuthService');
|
|
434
|
+
*
|
|
435
|
+
* // If the user is not authenticated
|
|
436
|
+
* if (!MyAuthService.isAuthenticated()) {
|
|
437
|
+
*
|
|
438
|
+
* // Then return a promise for a successful login.
|
|
439
|
+
* // The transition will wait for this promise to settle
|
|
440
|
+
*
|
|
441
|
+
* return MyAuthService.authenticate().catch(function() {
|
|
442
|
+
*
|
|
443
|
+
* // If the authenticate() method failed for whatever reason,
|
|
444
|
+
* // redirect to a 'guest' state which doesn't require auth.
|
|
445
|
+
* return $state.target("guest");
|
|
446
|
+
* });
|
|
447
|
+
* }
|
|
448
|
+
* });
|
|
449
|
+
* ```
|
|
450
|
+
*
|
|
451
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
452
|
+
* @param callback the hook function which will be injected and invoked.
|
|
453
|
+
* @returns a function which deregisters the hook.
|
|
454
|
+
*/
|
|
455
|
+
onStart(
|
|
456
|
+
matchCriteria: HookMatchCriteria,
|
|
457
|
+
callback: TransitionHookFn,
|
|
458
|
+
options?: HookRegOptions,
|
|
459
|
+
): Function;
|
|
460
|
+
/**
|
|
461
|
+
* Registers a [[TransitionStateHookFn]], called when a specific state is entered.
|
|
462
|
+
*
|
|
463
|
+
* Registers a lifecycle hook, which is invoked (during a transition) when a specific state is being entered.
|
|
464
|
+
*
|
|
465
|
+
* Since this hook is run only when the specific state is being *entered*, it can be useful for
|
|
466
|
+
* performing tasks when entering a submodule/feature area such as initializing a stateful service,
|
|
467
|
+
* or for guarding access to a submodule/feature area.
|
|
468
|
+
*
|
|
469
|
+
* See [[TransitionStateHookFn]] for the signature of the function.
|
|
470
|
+
*
|
|
471
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
472
|
+
* `onEnter` hooks generally specify `{ entering: 'somestate' }`.
|
|
473
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
474
|
+
*
|
|
475
|
+
* ### Lifecycle
|
|
476
|
+
*
|
|
477
|
+
* `onEnter` hooks are invoked when the Transition is entering a state.
|
|
478
|
+
* States are entered after the `onRetain` phase is complete.
|
|
479
|
+
* If more than one state is being entered, the parent state is entered first.
|
|
480
|
+
* The registered `onEnter` hooks for a state are invoked in priority order.
|
|
481
|
+
*
|
|
482
|
+
* Note: A built-in `onEnter` hook with high priority is used to fetch lazy resolve data for states being entered.
|
|
483
|
+
*
|
|
484
|
+
* ### Return value
|
|
485
|
+
*
|
|
486
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
487
|
+
* See [[HookResult]] for more information.
|
|
488
|
+
*
|
|
489
|
+
* ### Inside a state declaration
|
|
490
|
+
*
|
|
491
|
+
* Instead of registering `onEnter` hooks using the [[TransitionService]], you may define an `onEnter` hook
|
|
492
|
+
* directly on a state declaration (see: [[StateDeclaration.onEnter]]).
|
|
493
|
+
*
|
|
494
|
+
*
|
|
495
|
+
* ### Examples
|
|
496
|
+
*
|
|
497
|
+
* #### Audit Log
|
|
498
|
+
*
|
|
499
|
+
* This example uses a service to log that a user has entered the admin section of an app.
|
|
500
|
+
* This assumes that there are substates of the "admin" state, such as "admin.users", "admin.pages", etc.
|
|
501
|
+
* @example
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* $transitions.onEnter({ entering: 'admin' }, function(transition, state) {
|
|
505
|
+
* var AuditService = trans.injector().get('AuditService');
|
|
506
|
+
* AuditService.log("Entered " + state.name + " module while transitioning to " + transition.to().name);
|
|
507
|
+
* }
|
|
508
|
+
* ```
|
|
509
|
+
*
|
|
510
|
+
* #### Audit Log (inside a state declaration)
|
|
511
|
+
*
|
|
512
|
+
* The `onEnter` inside this state declaration is syntactic sugar for the previous Audit Log example.
|
|
513
|
+
* ```
|
|
514
|
+
* {
|
|
515
|
+
* name: 'admin',
|
|
516
|
+
* component: 'admin',
|
|
517
|
+
* onEnter: function($transition$, $state$) {
|
|
518
|
+
* var AuditService = $transition$.injector().get('AuditService');
|
|
519
|
+
* AuditService.log("Entered " + state.name + " module while transitioning to " + transition.to().name);
|
|
520
|
+
* }
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
523
|
+
*
|
|
524
|
+
* Note: A state declaration's `onEnter` function is injected for Angular 1 only.
|
|
525
|
+
*
|
|
526
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
527
|
+
* @param callback the hook function which will be injected and invoked.
|
|
528
|
+
* @returns a function which deregisters the hook.
|
|
529
|
+
*/
|
|
530
|
+
onEnter(
|
|
531
|
+
matchCriteria: HookMatchCriteria,
|
|
532
|
+
callback: TransitionStateHookFn,
|
|
533
|
+
options?: HookRegOptions,
|
|
534
|
+
): Function;
|
|
535
|
+
/**
|
|
536
|
+
* Registers a [[TransitionStateHookFn]], called when a specific state is retained/kept.
|
|
537
|
+
*
|
|
538
|
+
* Registers a lifecycle hook, which is invoked (during a transition) for
|
|
539
|
+
* a specific state that was previously active will remain active (is not being entered nor exited).
|
|
540
|
+
*
|
|
541
|
+
* This hook is invoked when a state is "retained" or "kept".
|
|
542
|
+
* It means the transition is coming *from* a substate of the retained state *to* a substate of the retained state.
|
|
543
|
+
* This hook can be used to perform actions when the user moves from one substate to another, such as between steps in a wizard.
|
|
544
|
+
*
|
|
545
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
546
|
+
* `onRetain` hooks generally specify `{ retained: 'somestate' }`.
|
|
547
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
548
|
+
*
|
|
549
|
+
* ### Lifecycle
|
|
550
|
+
*
|
|
551
|
+
* `onRetain` hooks are invoked after any `onExit` hooks have been fired.
|
|
552
|
+
* If more than one state is retained, the child states' `onRetain` hooks are invoked first.
|
|
553
|
+
* The registered `onRetain` hooks for a state are invoked in priority order.
|
|
554
|
+
*
|
|
555
|
+
* ### Return value
|
|
556
|
+
*
|
|
557
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
558
|
+
* See [[HookResult]] for more information.
|
|
559
|
+
*
|
|
560
|
+
* ### Inside a state declaration
|
|
561
|
+
*
|
|
562
|
+
* Instead of registering `onRetain` hooks using the [[TransitionService]], you may define an `onRetain` hook
|
|
563
|
+
* directly on a state declaration (see: [[StateDeclaration.onRetain]]).
|
|
564
|
+
*
|
|
565
|
+
* Note: A state declaration's `onRetain` function is injected for Angular 1 only.
|
|
566
|
+
*
|
|
567
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
568
|
+
* @param callback the hook function which will be injected and invoked.
|
|
569
|
+
* @returns a function which deregisters the hook.
|
|
570
|
+
*/
|
|
571
|
+
onRetain(
|
|
572
|
+
matchCriteria: HookMatchCriteria,
|
|
573
|
+
callback: TransitionStateHookFn,
|
|
574
|
+
options?: HookRegOptions,
|
|
575
|
+
): Function;
|
|
576
|
+
/**
|
|
577
|
+
* Registers a [[TransitionStateHookFn]], called when a specific state is exited.
|
|
578
|
+
*
|
|
579
|
+
* Registers a lifecycle hook, which is invoked (during a transition) when a specific state is being exited.
|
|
580
|
+
*
|
|
581
|
+
* Since this hook is run only when the specific state is being *exited*, it can be useful for
|
|
582
|
+
* performing tasks when leaving a submodule/feature area such as cleaning up a stateful service,
|
|
583
|
+
* or for preventing the user from leaving a state or submodule until some criteria is satisfied.
|
|
584
|
+
*
|
|
585
|
+
* See [[TransitionStateHookFn]] for the signature of the function.
|
|
586
|
+
*
|
|
587
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
588
|
+
* `onExit` hooks generally specify `{ exiting: 'somestate' }`.
|
|
589
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
590
|
+
*
|
|
591
|
+
* ### Lifecycle
|
|
592
|
+
*
|
|
593
|
+
* `onExit` hooks are invoked when the Transition is exiting a state.
|
|
594
|
+
* States are exited after any `onStart` phase is complete.
|
|
595
|
+
* If more than one state is being exited, the child states are exited first.
|
|
596
|
+
* The registered `onExit` hooks for a state are invoked in priority order.
|
|
597
|
+
*
|
|
598
|
+
* ### Return value
|
|
599
|
+
*
|
|
600
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
601
|
+
* See [[HookResult]] for more information.
|
|
602
|
+
*
|
|
603
|
+
* ### Inside a state declaration
|
|
604
|
+
*
|
|
605
|
+
* Instead of registering `onExit` hooks using the [[TransitionService]], you may define an `onExit` hook
|
|
606
|
+
* directly on a state declaration (see: [[StateDeclaration.onExit]]).
|
|
607
|
+
*
|
|
608
|
+
* Note: A state declaration's `onExit` function is injected for Angular 1 only.
|
|
609
|
+
*
|
|
610
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
611
|
+
* @param callback the hook function which will be injected and invoked.
|
|
612
|
+
* @returns a function which deregisters the hook.
|
|
613
|
+
*/
|
|
614
|
+
onExit(
|
|
615
|
+
matchCriteria: HookMatchCriteria,
|
|
616
|
+
callback: TransitionStateHookFn,
|
|
617
|
+
options?: HookRegOptions,
|
|
618
|
+
): Function;
|
|
619
|
+
/**
|
|
620
|
+
* Registers a [[TransitionHookFn]], called *just before a transition finishes*.
|
|
621
|
+
*
|
|
622
|
+
* Registers a transition lifecycle hook, which is invoked just before a transition finishes.
|
|
623
|
+
* This hook is a last chance to cancel or redirect a transition.
|
|
624
|
+
*
|
|
625
|
+
* See [[TransitionHookFn]] for the signature of the function.
|
|
626
|
+
*
|
|
627
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
628
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
629
|
+
*
|
|
630
|
+
* ### Lifecycle
|
|
631
|
+
*
|
|
632
|
+
* `onFinish` hooks are invoked after the `onEnter` phase is complete.
|
|
633
|
+
* These hooks are invoked just before the transition is "committed".
|
|
634
|
+
* Each hook is invoked in priority order.
|
|
635
|
+
*
|
|
636
|
+
* ### Return value
|
|
637
|
+
*
|
|
638
|
+
* The hook's return value can be used to pause, cancel, or redirect the current Transition.
|
|
639
|
+
* See [[HookResult]] for more information.
|
|
640
|
+
*
|
|
641
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
642
|
+
* @param callback the hook function which will be injected and invoked.
|
|
643
|
+
* @returns a function which deregisters the hook.
|
|
644
|
+
*/
|
|
645
|
+
onFinish(
|
|
646
|
+
matchCriteria: HookMatchCriteria,
|
|
647
|
+
callback: TransitionHookFn,
|
|
648
|
+
options?: HookRegOptions,
|
|
649
|
+
): Function;
|
|
650
|
+
/**
|
|
651
|
+
* Registers a [[TransitionHookFn]], called after a successful transition completed.
|
|
652
|
+
*
|
|
653
|
+
* Registers a transition lifecycle hook, which is invoked after a transition successfully completes.
|
|
654
|
+
*
|
|
655
|
+
* See [[TransitionHookFn]] for the signature of the function.
|
|
656
|
+
*
|
|
657
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
658
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
659
|
+
*
|
|
660
|
+
* ### Lifecycle
|
|
661
|
+
*
|
|
662
|
+
* `onSuccess` hooks are chained off the Transition's promise (see [[Transition.promise]]).
|
|
663
|
+
* If the Transition is successful and its promise is resolved, then the `onSuccess` hooks are invoked.
|
|
664
|
+
* Since these hooks are run after the transition is over, their return value is ignored.
|
|
665
|
+
* The `onSuccess` hooks are invoked in priority order.
|
|
666
|
+
*
|
|
667
|
+
* ### Return value
|
|
668
|
+
*
|
|
669
|
+
* Since the Transition is already completed, the hook's return value is ignored
|
|
670
|
+
*
|
|
671
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
672
|
+
* @param callback the hook function which will be injected and invoked.
|
|
673
|
+
* @returns a function which deregisters the hook.
|
|
674
|
+
*/
|
|
675
|
+
onSuccess(
|
|
676
|
+
matchCriteria: HookMatchCriteria,
|
|
677
|
+
callback: TransitionHookFn,
|
|
678
|
+
options?: HookRegOptions,
|
|
679
|
+
): Function;
|
|
680
|
+
/**
|
|
681
|
+
* Registers a [[TransitionHookFn]], called after a transition has errored.
|
|
682
|
+
*
|
|
683
|
+
* Registers a transition lifecycle hook, which is invoked after a transition has been rejected for any reason.
|
|
684
|
+
*
|
|
685
|
+
* See [[TransitionHookFn]] for the signature of the function.
|
|
686
|
+
*
|
|
687
|
+
* The [[HookMatchCriteria]] is used to determine which Transitions the hook should be invoked for.
|
|
688
|
+
* To match all Transitions, use an empty criteria object `{}`.
|
|
689
|
+
*
|
|
690
|
+
* ### Lifecycle
|
|
691
|
+
*
|
|
692
|
+
* The `onError` hooks are chained off the Transition's promise (see [[Transition.promise]]).
|
|
693
|
+
* If a Transition fails, its promise is rejected and the `onError` hooks are invoked.
|
|
694
|
+
* The `onError` hooks are invoked in priority order.
|
|
695
|
+
*
|
|
696
|
+
* Since these hooks are run after the transition is over, their return value is ignored.
|
|
697
|
+
*
|
|
698
|
+
* A transition "errors" if it was started, but failed to complete (for any reason).
|
|
699
|
+
* A *non-exhaustive list* of reasons a transition can error:
|
|
700
|
+
*
|
|
701
|
+
* - A transition was cancelled because a new transition started while it was still running (`Transition superseded`)
|
|
702
|
+
* - A transition was cancelled by a Transition Hook returning false
|
|
703
|
+
* - A transition was redirected by a Transition Hook returning a [[TargetState]]
|
|
704
|
+
* - A Transition Hook or resolve function threw an error
|
|
705
|
+
* - A Transition Hook returned a rejected promise
|
|
706
|
+
* - A resolve function returned a rejected promise
|
|
707
|
+
*
|
|
708
|
+
* To check the failure reason, inspect the return value of [[Transition.error]].
|
|
709
|
+
*
|
|
710
|
+
* Note: `onError` should be used for targeted error handling, or error recovery.
|
|
711
|
+
* For simple catch-all error reporting, use [[StateService.defaultErrorHandler]].
|
|
712
|
+
*
|
|
713
|
+
* ### Return value
|
|
714
|
+
*
|
|
715
|
+
* Since the Transition is already completed, the hook's return value is ignored
|
|
716
|
+
*
|
|
717
|
+
* @param matchCriteria defines which Transitions the Hook should be invoked for.
|
|
718
|
+
* @param callback the hook function which will be injected and invoked.
|
|
719
|
+
* @returns a function which deregisters the hook.
|
|
720
|
+
*/
|
|
721
|
+
onError(
|
|
722
|
+
matchCriteria: HookMatchCriteria,
|
|
723
|
+
callback: TransitionHookFn,
|
|
724
|
+
options?: HookRegOptions,
|
|
725
|
+
): Function;
|
|
726
|
+
/**
|
|
727
|
+
* Returns all the registered hooks of a given `hookName` type
|
|
728
|
+
*
|
|
729
|
+
* #### Example:
|
|
730
|
+
* ```
|
|
731
|
+
* $transitions.getHooks("onEnter")
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
getHooks(hookName: string): RegisteredHook[];
|
|
692
735
|
}
|
|
693
736
|
/** A predicate type which tests if a [[StateObject]] and [[Transition]] passes some test. Returns a boolean. */
|
|
694
737
|
export declare type IStateMatch = PredicateBinary<StateObject, Transition>;
|
|
@@ -756,43 +799,43 @@ export declare type IStateMatch = PredicateBinary<StateObject, Transition>;
|
|
|
756
799
|
* ```
|
|
757
800
|
*/
|
|
758
801
|
export interface HookMatchCriteria {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
802
|
+
[key: string]: HookMatchCriterion | undefined;
|
|
803
|
+
/** A [[HookMatchCriterion]] to match the destination state */
|
|
804
|
+
to?: HookMatchCriterion;
|
|
805
|
+
/** A [[HookMatchCriterion]] to match the original (from) state */
|
|
806
|
+
from?: HookMatchCriterion;
|
|
807
|
+
/** A [[HookMatchCriterion]] to match any state that would be exiting */
|
|
808
|
+
exiting?: HookMatchCriterion;
|
|
809
|
+
/** A [[HookMatchCriterion]] to match any state that would be retained */
|
|
810
|
+
retained?: HookMatchCriterion;
|
|
811
|
+
/** A [[HookMatchCriterion]] to match any state that would be entering */
|
|
812
|
+
entering?: HookMatchCriterion;
|
|
770
813
|
}
|
|
771
814
|
export interface IMatchingNodes {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
815
|
+
[key: string]: PathNode[];
|
|
816
|
+
to: PathNode[];
|
|
817
|
+
from: PathNode[];
|
|
818
|
+
exiting: PathNode[];
|
|
819
|
+
retained: PathNode[];
|
|
820
|
+
entering: PathNode[];
|
|
778
821
|
}
|
|
779
822
|
/** @internal */
|
|
780
823
|
export interface RegisteredHooks {
|
|
781
|
-
|
|
824
|
+
[key: string]: RegisteredHook[];
|
|
782
825
|
}
|
|
783
826
|
/** @internal */
|
|
784
827
|
export interface PathTypes {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
828
|
+
[key: string]: PathType;
|
|
829
|
+
to: PathType;
|
|
830
|
+
from: PathType;
|
|
831
|
+
exiting: PathType;
|
|
832
|
+
retained: PathType;
|
|
833
|
+
entering: PathType;
|
|
791
834
|
}
|
|
792
835
|
/** @internal */
|
|
793
836
|
export interface PathType {
|
|
794
|
-
|
|
795
|
-
|
|
837
|
+
name: string;
|
|
838
|
+
scope: TransitionHookScope;
|
|
796
839
|
}
|
|
797
840
|
/**
|
|
798
841
|
* Hook Criterion used to match a transition.
|
|
@@ -806,14 +849,14 @@ export interface PathType {
|
|
|
806
849
|
*/
|
|
807
850
|
export declare type HookMatchCriterion = string | IStateMatch | boolean;
|
|
808
851
|
declare enum TransitionHookPhase {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
852
|
+
CREATE = 0,
|
|
853
|
+
BEFORE = 1,
|
|
854
|
+
RUN = 2,
|
|
855
|
+
SUCCESS = 3,
|
|
856
|
+
ERROR = 4,
|
|
814
857
|
}
|
|
815
858
|
declare enum TransitionHookScope {
|
|
816
|
-
|
|
817
|
-
|
|
859
|
+
TRANSITION = 0,
|
|
860
|
+
STATE = 1,
|
|
818
861
|
}
|
|
819
862
|
export { TransitionHookPhase, TransitionHookScope };
|