@angular-wave/angular.ts 0.0.60 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +1 -1
  2. package/dist/angular-ts.esm.js +2 -2
  3. package/dist/angular-ts.umd.js +2 -2
  4. package/package.json +2 -1
  5. package/src/angular.spec.js +2 -2
  6. package/src/core/parser/parse.js +14 -0
  7. package/src/core/parser/parse.spec.js +7 -5
  8. package/src/core/parser/parser.js +1 -1
  9. package/src/core/q/q.js +46 -289
  10. package/src/core/q/q.md +229 -0
  11. package/src/core/sanitize/sanitize-uri.js +2 -3
  12. package/src/core/scope/scope.js +18 -8
  13. package/src/directive/if/if.js +6 -1
  14. package/src/filters/limit-to.js +5 -2
  15. package/src/filters/order-by.js +1 -2
  16. package/src/index.js +1 -1
  17. package/src/loader.js +1 -55
  18. package/src/router/params/param-type.js +2 -1
  19. package/src/router/state/views.js +3 -0
  20. package/src/router/state-provider.js +1 -1
  21. package/src/router/transition/reject-factory.js +1 -0
  22. package/src/router/url/url-rule.js +1 -1
  23. package/src/router/url/url-service.js +4 -4
  24. package/src/router/url/url-service.spec.js +4 -3
  25. package/src/services/http/http.js +7 -5
  26. package/src/services/template-request.js +2 -7
  27. package/src/shared/common.js +1 -1
  28. package/src/shared/utils.js +2 -11
  29. package/src/types.js +9 -1
  30. package/types/core/parser/parse.d.ts +3 -4
  31. package/types/core/parser/parser.d.ts +1 -1
  32. package/types/core/q/q.d.ts +2 -2
  33. package/types/core/sanitize/sanitize-uri.d.ts +4 -5
  34. package/types/core/scope/scope.d.ts +19 -7
  35. package/types/index.d.ts +5 -1
  36. package/types/loader.d.ts +0 -52
  37. package/types/router/params/param-type.d.ts +2 -1
  38. package/types/router/state/views.d.ts +2 -0
  39. package/types/router/state-provider.d.ts +1 -1
  40. package/types/router/transition/reject-factory.d.ts +1 -0
  41. package/types/router/url/url-rule.d.ts +0 -1
  42. package/types/router/url/url-service.d.ts +7 -7
  43. package/types/services/template-request.d.ts +4 -9
  44. package/types/shared/utils.d.ts +1 -7
  45. package/types/types.d.ts +6 -1
  46. package/types-back/README.md +0 -2
  47. package/types-back/angular.d.ts +0 -146
  48. package/types-back/index.d.ts +0 -2126
  49. package/types-back/jqlite.d.ts +0 -374
  50. package/types-back/router/core/common/common.d.ts +0 -416
  51. package/types-back/router/core/common/coreservices.d.ts +0 -77
  52. package/types-back/router/core/common/glob.d.ts +0 -60
  53. package/types-back/router/core/common/hof.d.ts +0 -168
  54. package/types-back/router/core/common/index.d.ts +0 -8
  55. package/types-back/router/core/common/predicates.d.ts +0 -25
  56. package/types-back/router/core/common/queue.d.ts +0 -15
  57. package/types-back/router/core/common/safeConsole.d.ts +0 -5
  58. package/types-back/router/core/common/strings.d.ts +0 -66
  59. package/types-back/router/core/common/trace.d.ts +0 -126
  60. package/types-back/router/core/globals.d.ts +0 -43
  61. package/types-back/router/core/hooks/coreResolvables.d.ts +0 -6
  62. package/types-back/router/core/hooks/ignoredTransition.d.ts +0 -4
  63. package/types-back/router/core/hooks/invalidTransition.d.ts +0 -4
  64. package/types-back/router/core/hooks/lazyLoad.d.ts +0 -17
  65. package/types-back/router/core/hooks/onEnterExitRetain.d.ts +0 -10
  66. package/types-back/router/core/hooks/redirectTo.d.ts +0 -4
  67. package/types-back/router/core/hooks/resolve.d.ts +0 -11
  68. package/types-back/router/core/hooks/updateGlobals.d.ts +0 -4
  69. package/types-back/router/core/hooks/url.d.ts +0 -4
  70. package/types-back/router/core/hooks/views.d.ts +0 -7
  71. package/types-back/router/core/index.d.ts +0 -11
  72. package/types-back/router/core/interface.d.ts +0 -91
  73. package/types-back/router/core/params/index.d.ts +0 -12
  74. package/types-back/router/core/params/interface.d.ts +0 -606
  75. package/types-back/router/core/params/param.d.ts +0 -77
  76. package/types-back/router/core/params/paramType.d.ts +0 -65
  77. package/types-back/router/core/params/paramTypes.d.ts +0 -193
  78. package/types-back/router/core/params/stateParams.d.ts +0 -15
  79. package/types-back/router/core/path/index.d.ts +0 -2
  80. package/types-back/router/core/path/pathNode.d.ts +0 -60
  81. package/types-back/router/core/path/pathUtils.d.ts +0 -105
  82. package/types-back/router/core/resolve/index.d.ts +0 -3
  83. package/types-back/router/core/resolve/interface.d.ts +0 -210
  84. package/types-back/router/core/resolve/resolvable.d.ts +0 -75
  85. package/types-back/router/core/resolve/resolveContext.d.ts +0 -97
  86. package/types-back/router/core/router.d.ts +0 -57
  87. package/types-back/router/core/state/index.d.ts +0 -28
  88. package/types-back/router/core/state/interface.d.ts +0 -732
  89. package/types-back/router/core/state/stateBuilder.d.ts +0 -107
  90. package/types-back/router/core/state/stateMatcher.d.ts +0 -13
  91. package/types-back/router/core/state/stateObject.d.ts +0 -170
  92. package/types-back/router/core/state/stateQueueManager.d.ts +0 -27
  93. package/types-back/router/core/state/stateRegistry.d.ts +0 -138
  94. package/types-back/router/core/state/stateService.d.ts +0 -386
  95. package/types-back/router/core/state/targetState.d.ts +0 -105
  96. package/types-back/router/core/transition/hookBuilder.d.ts +0 -49
  97. package/types-back/router/core/transition/hookRegistry.d.ts +0 -115
  98. package/types-back/router/core/transition/index.d.ts +0 -20
  99. package/types-back/router/core/transition/interface.d.ts +0 -862
  100. package/types-back/router/core/transition/rejectFactory.d.ts +0 -103
  101. package/types-back/router/core/transition/transition.d.ts +0 -575
  102. package/types-back/router/core/transition/transitionEventType.d.ts +0 -26
  103. package/types-back/router/core/transition/transitionHook.d.ts +0 -96
  104. package/types-back/router/core/transition/transitionService.d.ts +0 -253
  105. package/types-back/router/core/url/index.d.ts +0 -8
  106. package/types-back/router/core/url/interface.d.ts +0 -169
  107. package/types-back/router/core/url/urlConfig.d.ts +0 -144
  108. package/types-back/router/core/url/urlMatcher.d.ts +0 -185
  109. package/types-back/router/core/url/urlMatcherFactory.d.ts +0 -56
  110. package/types-back/router/core/url/urlRouter.d.ts +0 -101
  111. package/types-back/router/core/url/urlRule.d.ts +0 -143
  112. package/types-back/router/core/url/urlRules.d.ts +0 -251
  113. package/types-back/router/core/url/urlService.d.ts +0 -205
  114. package/types-back/router/core/view/index.d.ts +0 -2
  115. package/types-back/router/core/view/interface.d.ts +0 -46
  116. package/types-back/router/core/view/view.d.ts +0 -176
  117. package/types-back/router/directives/viewDirective.d.ts +0 -144
  118. package/types-back/router/index.d.ts +0 -17
  119. package/types-back/router/interface.d.ts +0 -500
  120. package/types-back/router/legacy/resolveService.d.ts +0 -47
  121. package/types-back/router/legacy/stateEvents.d.ts +0 -124
  122. package/types-back/router/services.d.ts +0 -15
  123. package/types-back/router/stateFilters.d.ts +0 -10
  124. package/types-back/router/stateProvider.d.ts +0 -258
  125. package/types-back/router/statebuilders/onEnterExitRetain.d.ts +0 -13
  126. package/types-back/router/statebuilders/views.d.ts +0 -53
  127. package/types-back/router/templateFactory.d.ts +0 -104
  128. package/types-back/router/viewScroll.d.ts +0 -9
@@ -1,732 +0,0 @@
1
- import { ParamDeclaration, RawParams } from "../params/interface";
2
- import { StateObject } from "./stateObject";
3
- import { ViewContext } from "../view/interface";
4
- import { IInjectable } from "../common/common";
5
- import { Transition } from "../transition/transition";
6
- import {
7
- TransitionStateHookFn,
8
- TransitionOptions,
9
- } from "../transition/interface";
10
- import {
11
- ResolvePolicy,
12
- ResolvableLiteral,
13
- ProviderLike,
14
- } from "../resolve/interface";
15
- import { Resolvable } from "../resolve/resolvable";
16
- import { TargetState } from "./targetState";
17
- export declare type StateOrName = string | StateDeclaration | StateObject;
18
- export interface TransitionPromise extends Promise<StateObject> {
19
- transition: Transition;
20
- }
21
- export interface TargetStateDef {
22
- state: StateOrName;
23
- params?: RawParams;
24
- options?: TransitionOptions;
25
- }
26
- export declare type ResolveTypes =
27
- | Resolvable
28
- | ResolvableLiteral
29
- | ProviderLike;
30
- /**
31
- * Base interface for declaring a view
32
- *
33
- * This interface defines the basic data that a normalized view declaration will have on it.
34
- * Each implementation of Router (for a specific framework) should define its own extension of this interface.
35
- * Add any additional fields that the framework requires to that interface.
36
- */
37
- export interface _ViewDeclaration {
38
- /**
39
- * The raw name for the view declaration, i.e., the [[StateDeclaration.views]] property name.
40
- */
41
- $name?: string;
42
- /**
43
- * The normalized address for the `ui-view` which this ViewConfig targets.
44
- *
45
- * A ViewConfig targets a `ui-view` in the DOM (relative to the `ngViewContextAnchor`) which has
46
- * a specific name.
47
- * @example `header` or `$default`
48
- *
49
- * The `ngViewName` can also target a _nested view_ by providing a dot-notation address
50
- * @example `foo.bar` or `foo.$default.bar`
51
- */
52
- $ngViewName?: string;
53
- /**
54
- * The normalized context anchor (state name) for the `ngViewName`
55
- *
56
- * When targeting a `ui-view`, the `ngViewName` address is anchored to a context name (state name).
57
- */
58
- $ngViewContextAnchor?: string;
59
- /**
60
- * A type identifier for the View
61
- *
62
- * This is used when loading prerequisites for the view, before it enters the DOM. Different types of views
63
- * may load differently (e.g., templateProvider+controllerProvider vs component class)
64
- */
65
- $type?: string;
66
- /**
67
- * The context that this view is declared within.
68
- */
69
- $context?: ViewContext;
70
- }
71
- /**
72
- * The return value of a [[redirectTo]] function
73
- *
74
- * - string: a state name
75
- * - TargetState: a target state, parameters, and options
76
- * - object: an object with a state name and parameters
77
- */
78
- export declare type RedirectToResult =
79
- | string
80
- | TargetState
81
- | {
82
- state?: string;
83
- params?: RawParams;
84
- }
85
- | void;
86
- /**
87
- * The StateDeclaration object is used to define a state or nested state.
88
- *
89
- * Note: Each implementation of Router (for a specific framework)
90
- * extends this interface as necessary.
91
- *
92
- * #### Example:
93
- * ```js
94
- * // StateDeclaration object
95
- * var foldersState = {
96
- * name: 'folders',
97
- * url: '/folders',
98
- * component: FoldersComponent,
99
- * resolve: {
100
- * allfolders: function(FolderService) {
101
- * return FolderService.list();
102
- * }
103
- * },
104
- * }
105
- *
106
- * registry.register(foldersState);
107
- * ```
108
- */
109
- export interface StateDeclaration {
110
- /**
111
- * The state name (required)
112
- *
113
- * A unique state name, e.g. `"home"`, `"about"`, `"contacts"`.
114
- * To create a parent/child state use a dot, e.g. `"about.sales"`, `"home.newest"`.
115
- *
116
- * Note: [State] objects require unique names.
117
- * The name is used like an id.
118
- */
119
- name?: string;
120
- /**
121
- * Abstract state indicator
122
- *
123
- * An abstract state can never be directly activated.
124
- * Use an abstract state to provide inherited properties (url, resolve, data, etc) to children states.
125
- */
126
- abstract?: boolean;
127
- /**
128
- * The parent state
129
- *
130
- * Normally, a state's parent is implied from the state's [[name]], e.g., `"parentstate.childstate"`.
131
- *
132
- * Alternatively, you can explicitly set the parent state using this property.
133
- * This allows shorter state names, e.g., `<a ui-sref="childstate">Child</a>`
134
- * instead of `<a ui-sref="parentstate.childstate">Child</a>
135
- *
136
- * When using this property, the state's name should not have any dots in it.
137
- *
138
- * #### Example:
139
- * ```js
140
- * var parentstate = {
141
- * name: 'parentstate'
142
- * }
143
- * var childstate = {
144
- * name: 'childstate',
145
- * parent: 'parentstate'
146
- * // or use a JS var which is the parent StateDeclaration, i.e.:
147
- * // parent: parentstate
148
- * }
149
- * ```
150
- */
151
- parent?: string | StateDeclaration;
152
- /**
153
- * Gets the internal State object API
154
- *
155
- * Gets the *internal API* for a registered state.
156
- *
157
- * Note: the internal [[StateObject]] API is subject to change without notice
158
- * @internal
159
- */
160
- $$state?: () => StateObject;
161
- /**
162
- * Resolve - a mechanism to asynchronously fetch data, participating in the Transition lifecycle
163
- *
164
- * The `resolve:` property defines data (or other dependencies) to be fetched asynchronously when the state is being entered.
165
- * After the data is fetched, it may be used in views, transition hooks or other resolves that belong to this state.
166
- * The data may also be used in any views or resolves that belong to nested states.
167
- *
168
- * ### As an array
169
- *
170
- * Each array element should be a [[ResolvableLiteral]] object.
171
- *
172
- * #### Example:
173
- * The `user` resolve injects the current `Transition` and the `UserService` (using its token, which is a string).
174
- * The [[ResolvableLiteral.resolvePolicy]] sets how the resolve is processed.
175
- * The `user` data, fetched asynchronously, can then be used in a view.
176
- * ```js
177
- * var state = {
178
- * name: 'user',
179
- * url: '/user/:userId
180
- * resolve: [
181
- * {
182
- * token: 'user',
183
- * policy: { when: 'EAGER' },
184
- * deps: ['UserService', Transition],
185
- * resolveFn: (userSvc, trans) => userSvc.fetchUser(trans.params().userId) },
186
- * }
187
- * ]
188
- * }
189
- * ```
190
- *
191
- * Note: an Angular 2 style [`useFactory` provider literal](https://angular.io/docs/ts/latest/cookbook/dependency-injection.html#!#provide)
192
- * may also be used. See [[ProviderLike]].
193
- * #### Example:
194
- * ```
195
- * resolve: [
196
- * { provide: 'token', useFactory: (http) => http.get('/'), deps: [ Http ] },
197
- * ]
198
- * ```
199
- *
200
- * ### As an object
201
- *
202
- * The `resolve` property may be an object where:
203
- * - Each key (string) is the name of the dependency.
204
- * - Each value (function) is an injectable function which returns the dependency, or a promise for the dependency.
205
- *
206
- * This style is based on AngularJS injectable functions, but can be used with any Router implementation.
207
- * If your code will be minified, the function should be ["annotated" in the AngularJS manner](https://docs.angularjs.org/guide/di#dependency-annotation).
208
- *
209
- * #### AngularJS Example:
210
- * ```js
211
- * resolve: {
212
- * // If you inject `myStateDependency` into a controller, you'll get "abc"
213
- * myStateDependency: function() {
214
- * return "abc";
215
- * },
216
- * // Dependencies are annotated in "Inline Array Annotation"
217
- * myAsyncData: ['$http', '$transition$' function($http, $transition$) {
218
- * // Return a promise (async) for the data
219
- * return $http.get("/foos/" + $transition$.params().foo);
220
- * }]
221
- * }
222
- * ```
223
- *
224
- * Note: You cannot specify a policy for each Resolvable, nor can you use non-string
225
- * tokens when using the object style `resolve:` block.
226
- *
227
- * ### Lifecycle
228
- *
229
- * Since a resolve function can return a promise, the router will delay entering the state until the promises are ready.
230
- * If any of the promises are rejected, the Transition is aborted with an Error.
231
- *
232
- * By default, resolves for a state are fetched just before that state is entered.
233
- * Note that only states which are being *entered* during the `Transition` have their resolves fetched.
234
- * States that are "retained" do not have their resolves re-fetched.
235
- *
236
- * If you are currently in a parent state `parent` and are transitioning to a child state `parent.child`, the
237
- * previously resolved data for state `parent` can be injected into `parent.child` without delay.
238
- *
239
- * Any resolved data for `parent.child` is retained until `parent.child` is exited, e.g., by transitioning back to the `parent` state.
240
- *
241
- * Because of this scoping and lifecycle, resolves are a great place to fetch your application's primary data.
242
- *
243
- * ### Injecting resolves into other things
244
- *
245
- * During a transition, Resolve data can be injected into:
246
- *
247
- * - Views (the components which fill a `ui-view` tag)
248
- * - Transition Hooks
249
- * - Other resolves (a resolve may depend on asynchronous data from a different resolve)
250
- *
251
- * ### Injecting other things into resolves
252
- *
253
- * Resolve functions usually have dependencies on some other API(s).
254
- * The dependencies are usually declared and injected into the resolve function.
255
- * A common pattern is to inject a custom service such as `UserService`.
256
- * The resolve then delegates to a service method, such as `UserService.list()`;
257
- *
258
- * #### Special injectable tokens
259
- *
260
- * - `Router`: The [[Router]] instance which has references to all the Router services.
261
- * - `Transition`: The current [[Transition]] object; information and API about the current transition, such as
262
- * "to" and "from" State Parameters and transition options.
263
- * - `'$transition$'`: A string alias for the `Transition` injectable
264
- * - `'$state$'`: For `onEnter`/`onExit`/`onRetain`, the state being entered/exited/retained.
265
- * - Other resolve tokens: A resolve can depend on another resolve, either from the same state, or from any parent state.
266
- *
267
- * #### Example:
268
- * ```js
269
- * // Injecting a resolve into another resolve
270
- * resolve: [
271
- * // Define a resolve 'allusers' which delegates to the UserService.list()
272
- * // which returns a promise (async) for all the users
273
- * { provide: 'allusers', useFactory: (UserService) => UserService.list(), deps: [UserService] },
274
- *
275
- * // Define a resolve 'user' which depends on the allusers resolve.
276
- * // This resolve function is not called until 'allusers' is ready.
277
- * { provide: 'user', (allusers, trans) => _.find(allusers, trans.params().userId, deps: ['allusers', Transition] }
278
- * }
279
- * ```
280
- */
281
- resolve?:
282
- | ResolveTypes[]
283
- | {
284
- [key: string]: IInjectable;
285
- };
286
- /**
287
- * Sets the resolve policy defaults for all resolves on this state
288
- *
289
- * This should be an [[ResolvePolicy]] object.
290
- *
291
- * It can contain the following optional keys/values:
292
- *
293
- * - `when`: (optional) defines when the resolve is fetched. Accepted values: "LAZY" or "EAGER"
294
- * - `async`: (optional) if the transition waits for the resolve. Accepted values: "WAIT", "NOWAIT", {@link CustomAsyncPolicy}
295
- *
296
- * See [[ResolvePolicy]] for more details.
297
- */
298
- resolvePolicy?: ResolvePolicy;
299
- /**
300
- * The url fragment for the state
301
- *
302
- * A URL fragment (with optional parameters) which is used to match the browser location with this state.
303
- *
304
- * This fragment will be appended to the parent state's URL in order to build up the overall URL for this state.
305
- * See [[UrlMatcher]] for details on acceptable patterns.
306
- *
307
- * @examples
308
- * ```js
309
- *
310
- * url: "/home"
311
- * // Define a parameter named 'userid'
312
- * url: "/users/:userid"
313
- * // param 'bookid' has a custom regexp
314
- * url: "/books/{bookid:[a-zA-Z_-]}"
315
- * // param 'categoryid' is of type 'int'
316
- * url: "/books/{categoryid:int}"
317
- * // two parameters for this state
318
- * url: "/books/{publishername:string}/{categoryid:int}"
319
- * // Query parameters
320
- * url: "/messages?before&after"
321
- * // Query parameters of type 'date'
322
- * url: "/messages?{before:date}&{after:date}"
323
- * // Path and query parameters
324
- * url: "/messages/:mailboxid?{before:date}&{after:date}"
325
- * ```
326
- */
327
- url?: string;
328
- /**
329
- * Params configuration
330
- *
331
- * An object which optionally configures parameters declared in the url, or defines additional non-url
332
- * parameters. For each parameter being configured, add a [[ParamDeclaration]] keyed to the name of the parameter.
333
- *
334
- * #### Example:
335
- * ```js
336
- * params: {
337
- * param1: {
338
- * type: "int",
339
- * array: true,
340
- * value: []
341
- * },
342
- * param2: {
343
- * value: "index"
344
- * }
345
- * }
346
- * ```
347
- */
348
- params?: {
349
- [key: string]: ParamDeclaration | any;
350
- };
351
- /**
352
- * Named views
353
- *
354
- * An optional object which defines multiple views, or explicitly targets specific named ui-views.
355
- *
356
- * - What is a view config
357
- * - What is a ui-view
358
- * - Shorthand controller/template
359
- * - Incompatible with ^
360
- *
361
- * Examples:
362
- *
363
- * Targets three named ui-views in the parent state's template
364
- *
365
- * #### Example:
366
- * ```js
367
- * views: {
368
- * header: {
369
- * controller: "headerCtrl",
370
- * templateUrl: "header.html"
371
- * }, body: {
372
- * controller: "bodyCtrl",
373
- * templateUrl: "body.html"
374
- * }, footer: {
375
- * controller: "footCtrl",
376
- * templateUrl: "footer.html"
377
- * }
378
- * }
379
- * ```
380
- *
381
- * @example
382
- * ```js
383
- * // Targets named ui-view="header" from ancestor state 'top''s template, and
384
- * // named `ui-view="body" from parent state's template.
385
- * views: {
386
- * 'header@top': {
387
- * controller: "msgHeaderCtrl",
388
- * templateUrl: "msgHeader.html"
389
- * }, 'body': {
390
- * controller: "messagesCtrl",
391
- * templateUrl: "messages.html"
392
- * }
393
- * }
394
- * ```
395
- */
396
- views?: {
397
- [key: string]: _ViewDeclaration;
398
- };
399
- /**
400
- * An inherited property to store state data
401
- *
402
- * This is a spot for you to store inherited state metadata.
403
- * Child states' `data` object will prototypally inherit from their parent state.
404
- *
405
- * This is a good spot to put metadata such as `requiresAuth`.
406
- *
407
- * Note: because prototypal inheritance is used, changes to parent `data` objects reflect in the child `data` objects.
408
- * Care should be taken if you are using `hasOwnProperty` on the `data` object.
409
- * Properties from parent objects will return false for `hasOwnProperty`.
410
- */
411
- data?: any;
412
- /**
413
- * Synchronously or asynchronously redirects Transitions to a different state/params
414
- *
415
- * If this property is defined, a Transition directly to this state will be redirected based on the property's value.
416
- *
417
- * - If the value is a `string`, the Transition is redirected to the state named by the string.
418
- *
419
- * - If the property is an object with a `state` and/or `params` property,
420
- * the Transition is redirected to the named `state` and/or `params`.
421
- *
422
- * - If the value is a [[TargetState]] the Transition is redirected to the `TargetState`
423
- *
424
- * - If the property is a function:
425
- * - The function is called with the current [[Transition]]
426
- * - The return value is processed using the previously mentioned rules.
427
- * - If the return value is a promise, the promise is waited for, then the resolved async value is processed using the same rules.
428
- *
429
- * Note: `redirectTo` is processed as an `onStart` hook, before `LAZY` resolves.
430
- * If your redirect function relies on resolve data, get the [[Transition.injector]] and get a
431
- * promise for the resolve data using [[NGInjector.getAsync]].
432
- *
433
- * #### Example:
434
- * ```js
435
- * // a string
436
- * .state('A', {
437
- * redirectTo: 'A.B'
438
- * })
439
- *
440
- * // a {state, params} object
441
- * .state('C', {
442
- * redirectTo: { state: 'C.D', params: { foo: 'index' } }
443
- * })
444
- *
445
- * // a fn
446
- * .state('E', {
447
- * redirectTo: () => "A"
448
- * })
449
- *
450
- * // a fn conditionally returning a {state, params}
451
- * .state('F', {
452
- * redirectTo: (trans) => {
453
- * if (trans.params().foo < 10)
454
- * return { state: 'F', params: { foo: 10 } };
455
- * }
456
- * })
457
- *
458
- * // a fn returning a promise for a redirect
459
- * .state('G', {
460
- * redirectTo: (trans) => {
461
- * let svc = trans.injector().get('SomeAsyncService')
462
- * let promise = svc.getAsyncRedirectTo(trans.params.foo);
463
- * return promise;
464
- * }
465
- * })
466
- *
467
- * // a fn that fetches resolve data
468
- * .state('G', {
469
- * redirectTo: (trans) => {
470
- * // getAsync tells the resolve to load
471
- * let resolvePromise = trans.injector().getAsync('SomeResolve')
472
- * return resolvePromise.then(resolveData => resolveData === 'login' ? 'login' : null);
473
- * }
474
- * })
475
- * ```
476
- */
477
- redirectTo?:
478
- | RedirectToResult
479
- | ((transition: Transition) => RedirectToResult)
480
- | ((transition: Transition) => Promise<RedirectToResult>);
481
- /**
482
- * A Transition Hook called with the state is being entered. See: [[IHookRegistry.onEnter]]
483
- *
484
- * #### Example:
485
- * ```js
486
- * .state({
487
- * name: 'mystate',
488
- * onEnter: function(trans, state) {
489
- * console.log("Entering " + state.name);
490
- * }
491
- * });
492
- * ```
493
- *
494
- * Note: The above `onEnter` on the state declaration is effectively sugar for:
495
- *
496
- * ```js
497
- * transitionService.onEnter({ entering: 'mystate' }, function(trans, state) {
498
- * console.log("Entering " + state.name);
499
- * });
500
- * ```
501
- */
502
- onEnter?: TransitionStateHookFn;
503
- /**
504
- * A [[TransitionStateHookFn]] called with the state is being retained/kept. See: [[IHookRegistry.onRetain]]
505
- *
506
- * #### Example:
507
- * ```js
508
- * .state({
509
- * name: 'mystate',
510
- * onRetain: function(trans, state) {
511
- * console.log(state.name + " is still active!");
512
- * }
513
- * });
514
- * ```
515
- *
516
- * Note: The above `onRetain` on the state declaration is effectively sugar for:
517
- *
518
- * ```js
519
- * transitionService.onRetain({ retained: 'mystate' }, function(trans, state) {
520
- * console.log(state.name + " is still active!");
521
- * });
522
- * ```
523
- */
524
- onRetain?: TransitionStateHookFn;
525
- /**
526
- * A Transition Hook called with the state is being exited. See: [[IHookRegistry.onExit]]
527
- *
528
- * #### Example:
529
- * ```js
530
- * .state({
531
- * name: 'mystate',
532
- * onExit: function(trans, state) {
533
- * console.log("Leaving " + state.name);
534
- * }
535
- * });
536
- * ```
537
- *
538
- * Note: The above `onRetain` on the state declaration is effectively sugar for:
539
- *
540
- * ```js
541
- * transitionService.onExit({ exiting: 'mystate' }, function(trans, state) {
542
- * console.log("Leaving " + state.name);
543
- * });
544
- * ```
545
- */
546
- onExit?: TransitionStateHookFn;
547
- /**
548
- * A function used to lazy load code
549
- *
550
- * The `lazyLoad` function is invoked before the state is activated.
551
- * The transition waits while the code is loading.
552
- *
553
- * The function should load the code that is required to activate the state.
554
- * For example, it may load a component class, or some service code.
555
- * The function must return a promise which resolves when loading is complete.
556
- *
557
- * For example, this code lazy loads a service before the `abc` state is activated:
558
- *
559
- * ```
560
- * .state('abc', {
561
- * lazyLoad: (transition, state) => import('./abcService')
562
- * }
563
- * ```
564
- *
565
- * The `abcService` file is imported and loaded
566
- * (it is assumed that the `abcService` file knows how to register itself as a service).
567
- *
568
- * #### Lifecycle
569
- *
570
- * - The `lazyLoad` function is invoked if a transition is going to enter the state.
571
- * - The function is invoked before the transition starts (using an `onBefore` transition hook).
572
- * - The function is only invoked once; while the `lazyLoad` function is loading code, it will not be invoked again.
573
- * For example, if the user double clicks a ui-sref, `lazyLoad` is only invoked once even though there were two transition attempts.
574
- * Instead, the existing lazy load promise is re-used.
575
- * - When the promise resolves successfully, the `lazyLoad` property is deleted from the state declaration.
576
- * - If the promise resolves to a [[LazyLoadResult]] which has an array of `states`, those states are registered.
577
- * - The original transition is retried (this time without the `lazyLoad` property present).
578
- *
579
- * - If the `lazyLoad` function fails, then the transition also fails.
580
- * The failed transition (and the `lazyLoad` function) could potentially be retried by the user.
581
- *
582
- * ### Lazy loading state definitions (Future States)
583
- *
584
- * State definitions can also be lazy loaded.
585
- * This might be desirable when building large, multi-module applications.
586
- *
587
- * To lazy load state definitions, a Future State should be registered as a placeholder.
588
- * When the state definitions are lazy loaded, the Future State is deregistered.
589
- *
590
- * A future state can act as a placeholder for a single state, or for an entire module of states and substates.
591
- * A future state should have:
592
- *
593
- * - A `name` which ends in `.**`.
594
- * A future state's `name` property acts as a wildcard [[Glob]].
595
- * It matches any state name that starts with the `name` (including child states that are not yet loaded).
596
- * - A `url` prefix.
597
- * A future state's `url` property acts as a wildcard.
598
- * Router matches all paths that begin with the `url`.
599
- * It effectively appends `.*` to the internal regular expression.
600
- * When the prefix matches, the future state will begin loading.
601
- * - A `lazyLoad` function.
602
- * This function should should return a Promise to lazy load the code for one or more [[StateDeclaration]] objects.
603
- * It should return a [[LazyLoadResult]].
604
- * Generally, one of the lazy loaded states should have the same name as the future state.
605
- * The new state will then **replace the future state placeholder** in the registry.
606
- *
607
- * ### Additional resources
608
- *
609
- * For in depth information on lazy loading and Future States, see the [Lazy Loading Guide](https://ui-router.github.io/guides/lazyload).
610
- *
611
- * #### Example: states.js
612
- * ```js
613
- *
614
- * // This child state is a lazy loaded future state
615
- * // The `lazyLoad` function loads the final state definition
616
- * {
617
- * name: 'parent.**',
618
- * url: '/parent',
619
- * lazyLoad: () => import('./lazy.states.js')
620
- * }
621
- * ```
622
- *
623
- * #### Example: lazy.states.js
624
- *
625
- * This file is lazy loaded. It exports an array of states.
626
- *
627
- * ```js
628
- * import {ChildComponent} from "./child.component.js";
629
- * import {ParentComponent} from "./parent.component.js";
630
- *
631
- * // This fully defined state replaces the future state
632
- * let parentState = {
633
- * // the name should match the future state
634
- * name: 'parent',
635
- * url: '/parent/:parentId',
636
- * component: ParentComponent,
637
- * resolve: {
638
- * parentData: ($transition$, ParentService) =>
639
- * ParentService.get($transition$.params().parentId)
640
- * }
641
- * }
642
- *
643
- * let childState = {
644
- * name: 'parent.child',
645
- * url: '/child/:childId',
646
- * params: {
647
- * childId: "default"
648
- * },
649
- * resolve: {
650
- * childData: ($transition$, ChildService) =>
651
- * ChildService.get($transition$.params().childId)
652
- * }
653
- * };
654
- *
655
- * // This array of states will be registered by the lazyLoad hook
656
- * let lazyLoadResults = {
657
- * states: [ parentState, childState ]
658
- * };
659
- *
660
- * export default lazyLoadResults;
661
- * ```
662
- *
663
- * @param transition the [[Transition]] that is activating the future state
664
- * @param state the [[StateDeclaration]] that the `lazyLoad` function is declared on
665
- * @return a Promise to load the states.
666
- * Optionally, if the promise resolves to a [[LazyLoadResult]],
667
- * the states will be registered with the [[StateRegistry]].
668
- */
669
- lazyLoad?: (
670
- transition: Transition,
671
- state: StateDeclaration,
672
- ) => Promise<LazyLoadResult>;
673
- /**
674
- * Marks all the state's parameters as `dynamic`.
675
- *
676
- * All parameters on the state will use this value for `dynamic` as a default.
677
- * Individual parameters may override this default using [[ParamDeclaration.dynamic]] in the [[params]] block.
678
- *
679
- * Note: this value overrides the `dynamic` value on a custom parameter type ([[ParamTypeDefinition.dynamic]]).
680
- */
681
- dynamic?: boolean;
682
- /**
683
- * Marks all query parameters as [[ParamDeclaration.dynamic]]
684
- *
685
- * @deprecated use either [[dynamic]] or [[ParamDeclaration.dynamic]]
686
- */
687
- reloadOnSearch?: boolean;
688
- }
689
- /**
690
- * The return type of a [[StateDeclaration.lazyLoad]] function
691
- *
692
- * If your state has a `lazyLoad` function, it should return a promise.
693
- * If promise resolves to an object matching this interface, then the `states` array
694
- * of [[StateDeclaration]] objects will be automatically registered.
695
- */
696
- export interface LazyLoadResult {
697
- states?: StateDeclaration[];
698
- }
699
- /**
700
- * An options object for [[StateService.href]]
701
- */
702
- export interface HrefOptions {
703
- /**
704
- * Defines what state to be "relative from"
705
- *
706
- * When a relative path is found (e.g `^` or `.bar`), defines which state to be relative from.
707
- */
708
- relative?: StateOrName;
709
- /**
710
- * If true, and if there is no url associated with the state provided in the
711
- * first parameter, then the constructed href url will be built from the first
712
- * ancestor which has a url.
713
- */
714
- lossy?: boolean;
715
- /**
716
- * If `true` will inherit parameters from the current parameter values.
717
- */
718
- inherit?: boolean;
719
- /**
720
- * If true will generate an absolute url, e.g. `http://www.example.com/fullurl`.
721
- */
722
- absolute?: boolean;
723
- }
724
- /**
725
- * Either a [[StateDeclaration]] or an ES6 class that implements [[StateDeclaration]]
726
- * The ES6 class constructor should have no arguments.
727
- */
728
- export declare type _StateDeclaration =
729
- | StateDeclaration
730
- | {
731
- new (): StateDeclaration;
732
- };