@angular-wave/angular.ts 0.0.16 → 0.0.17

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 (298) hide show
  1. package/README.md +5 -3
  2. package/dist/angular-ts.esm.js +1 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/index.html +66 -57
  5. package/package.json +1 -1
  6. package/rollup.config.js +2 -6
  7. package/src/animations/animate-children-directive.js +1 -1
  8. package/src/animations/animate-css-driver.js +1 -1
  9. package/src/animations/animate-css.js +220 -15
  10. package/src/animations/animate-js-driver.js +1 -1
  11. package/src/animations/animate-js.js +2 -2
  12. package/src/animations/animate-queue.js +3 -4
  13. package/src/animations/animation.js +1 -1
  14. package/src/animations/module.js +750 -0
  15. package/src/animations/shared.js +15 -4
  16. package/src/core/animate-runner.js +1 -1
  17. package/src/core/animate.js +4 -5
  18. package/src/core/compile.js +6 -7
  19. package/src/core/controller.js +4 -3
  20. package/src/core/filter.js +1 -1
  21. package/src/core/interpolate.js +1 -1
  22. package/src/core/interval-factory.js +1 -1
  23. package/src/core/interval.js +1 -1
  24. package/src/core/location.js +1 -1
  25. package/src/core/parser/parse.js +1 -1
  26. package/src/core/q.js +2 -3
  27. package/src/core/root-scope.js +1 -1
  28. package/src/core/sanitize-uri.js +1 -1
  29. package/src/core/sce.js +1 -1
  30. package/src/core/task-tracker-factory.js +1 -1
  31. package/src/core/timeout.js +1 -1
  32. package/src/core/urlUtils.js +1 -1
  33. package/src/directive/attrs.js +1 -1
  34. package/src/directive/bind.js +1 -1
  35. package/src/directive/class.js +2 -2
  36. package/src/directive/events.js +1 -1
  37. package/src/directive/form.js +1 -1
  38. package/src/directive/include.js +1 -1
  39. package/src/directive/input.js +1 -1
  40. package/src/directive/list.js +2 -2
  41. package/src/directive/model-options.js +1 -1
  42. package/src/directive/model.js +1 -1
  43. package/src/directive/options.js +2 -3
  44. package/src/directive/ref.js +1 -1
  45. package/src/directive/repeat.js +1 -1
  46. package/src/directive/select.js +1 -1
  47. package/src/directive/switch.js +1 -1
  48. package/src/directive/transclude.js +1 -1
  49. package/src/directive/validators.js +1 -1
  50. package/src/exts/aria.js +1 -1
  51. package/src/exts/messages.js +3 -3
  52. package/src/exts/messages.md +28 -31
  53. package/src/filters/filter.js +2 -3
  54. package/src/filters/filters.js +1 -1
  55. package/src/filters/limit-to.js +1 -1
  56. package/src/filters/order-by.js +2 -3
  57. package/src/injector.js +8 -9
  58. package/src/jqLite.js +3 -4
  59. package/src/loader.js +1 -3
  60. package/src/public.js +1 -1
  61. package/src/router/common/coreservices.js +5 -0
  62. package/src/router/{core/common → common}/queue.js +1 -1
  63. package/src/router/{core/common → common}/trace.js +21 -19
  64. package/src/router/{adapter/directives → directives}/stateDirectives.js +24 -28
  65. package/src/router/{adapter/directives → directives}/viewDirective.js +10 -9
  66. package/src/router/{core/globals.js → globals.js} +13 -3
  67. package/src/router/{core/hooks → hooks}/coreResolvables.js +6 -4
  68. package/src/router/{core/hooks → hooks}/lazyLoad.js +5 -2
  69. package/src/router/{core/hooks → hooks}/redirectTo.js +1 -1
  70. package/src/router/{core/hooks → hooks}/resolve.js +5 -4
  71. package/src/router/{core/hooks → hooks}/updateGlobals.js +1 -1
  72. package/src/router/{core/hooks → hooks}/views.js +2 -3
  73. package/src/router/index.js +60 -0
  74. package/src/router/{adapter/injectables.js → injectables.js} +9 -9
  75. package/src/router/{adapter/locationServices.js → locationServices.js} +19 -12
  76. package/src/router/{core/params → params}/param.js +5 -10
  77. package/src/router/{core/params → params}/paramType.js +4 -4
  78. package/src/router/{core/params → params}/paramTypes.js +4 -3
  79. package/src/router/{core/params → params}/stateParams.js +1 -1
  80. package/src/router/{core/path → path}/pathNode.js +2 -2
  81. package/src/router/{core/path → path}/pathUtils.js +13 -7
  82. package/src/router/{core/resolve → resolve}/resolvable.js +5 -5
  83. package/src/router/{core/resolve → resolve}/resolveContext.js +16 -6
  84. package/src/router/router.js +171 -72
  85. package/src/router/{adapter/services.js → services.js} +47 -27
  86. package/src/router/{core/state → state}/stateBuilder.js +14 -10
  87. package/src/router/{core/state → state}/stateMatcher.js +2 -3
  88. package/src/router/{core/state → state}/stateObject.js +8 -6
  89. package/src/router/{core/state → state}/stateQueueManager.js +3 -3
  90. package/src/router/{core/state → state}/stateRegistry.js +6 -7
  91. package/src/router/{core/state → state}/stateService.js +12 -15
  92. package/src/router/{core/state → state}/targetState.js +2 -2
  93. package/src/router/{adapter/statebuilders → state}/views.js +17 -15
  94. package/src/router/{adapter/stateProvider.js → stateProvider.js} +52 -9
  95. package/src/router/{adapter/templateFactory.js → templateFactory.js} +10 -19
  96. package/src/router/{core/transition → transition}/hookBuilder.js +4 -3
  97. package/src/router/{core/transition → transition}/hookRegistry.js +3 -6
  98. package/src/router/{core/transition → transition}/rejectFactory.js +4 -5
  99. package/src/router/{core/transition → transition}/transition.js +10 -12
  100. package/src/router/{core/transition → transition}/transitionHook.js +4 -4
  101. package/src/router/{core/transition → transition}/transitionService.js +13 -13
  102. package/src/router/{core/url → url}/urlConfig.js +28 -19
  103. package/src/router/{core/url → url}/urlMatcher.js +14 -16
  104. package/src/router/{core/url → url}/urlMatcherFactory.js +7 -6
  105. package/src/router/{core/url → url}/urlRouter.js +6 -30
  106. package/src/router/{core/url → url}/urlRule.js +3 -3
  107. package/src/router/{core/url → url}/urlRules.js +10 -11
  108. package/src/router/{core/url → url}/urlService.js +12 -6
  109. package/src/router/{core/view → view}/view.js +32 -27
  110. package/src/router/{adapter/viewScroll.js → viewScroll.js} +3 -0
  111. package/src/services/anchor-scroll.js +1 -1
  112. package/src/services/browser.js +1 -1
  113. package/src/services/cache-factory.js +7 -1
  114. package/src/services/cookie-reader.js +1 -1
  115. package/src/services/http-backend.js +6 -1
  116. package/src/services/http.js +4 -5
  117. package/src/services/log.js +1 -1
  118. package/src/services/template-request.js +2 -2
  119. package/src/{router/core/common → shared}/common.js +35 -16
  120. package/src/{router/core/common → shared}/predicates.js +2 -12
  121. package/src/{router/core/common → shared}/strings.js +5 -13
  122. package/src/{core → shared}/utils.js +13 -29
  123. package/test/angular.spec.js +1 -31
  124. package/test/{ng → core}/animate.spec.js +1 -1
  125. package/test/{ng → core}/compile.spec.js +2 -3
  126. package/test/{ng → core}/http.spec.js +2 -2
  127. package/test/{ng → core}/on.spec.js +1 -1
  128. package/test/{ng → core}/parse.spec.js +1 -1
  129. package/test/{ng → core}/prop.spec.js +1 -1
  130. package/test/{ng → core}/scope.spec.js +1 -1
  131. package/test/{ng/directive → directive}/a.spec.js +4 -4
  132. package/test/{ng/directive → directive}/bind.spec.js +3 -3
  133. package/test/{ng/directive → directive}/boolean.spec.js +2 -2
  134. package/test/{ng/directive → directive}/change.spec.js +3 -3
  135. package/test/{ng/directive → directive}/class.spec.js +4 -4
  136. package/test/{ng/directive → directive}/click.spec.js +3 -3
  137. package/test/{ng/directive → directive}/cloak.spec.js +4 -4
  138. package/test/{ng/directive → directive}/constoller.spec.js +5 -5
  139. package/test/{ng/directive → directive}/element-style.spec.js +3 -3
  140. package/test/{ng/directive → directive}/event.spec.js +4 -4
  141. package/test/{ng/directive → directive}/form.spec.js +5 -5
  142. package/test/{ng/directive → directive}/href.spec.js +4 -4
  143. package/test/{ng/directive → directive}/if.spec.js +5 -5
  144. package/test/{ng/directive → directive}/include.spec.js +5 -5
  145. package/test/{ng/directive → directive}/init.spec.js +4 -4
  146. package/test/{ng/directive → directive}/input.spec.js +5 -5
  147. package/test/{ng/directive → directive}/list.spec.js +3 -3
  148. package/test/{ng/directive → directive}/model-options.spec.js +6 -6
  149. package/test/{ng/directive → directive}/model.spec.js +8 -8
  150. package/test/{ng/directive → directive}/non-bindable.spec.js +3 -3
  151. package/test/{ng/directive → directive}/options.spec.js +5 -5
  152. package/test/{ng/directive → directive}/ref.spec.js +2 -2
  153. package/test/{ng/directive → directive}/repeat.spec.js +5 -5
  154. package/test/{ng/directive → directive}/script.spec.js +3 -3
  155. package/test/{ng/directive → directive}/scrset.spec.js +3 -3
  156. package/test/{ng/directive → directive}/select.spec.js +5 -5
  157. package/test/{ng/directive → directive}/show-hide.spec.js +3 -3
  158. package/test/{ng/directive → directive}/src.spec.js +3 -3
  159. package/test/{ng/directive → directive}/style.spec.js +3 -3
  160. package/test/{ng/directive → directive}/switch.spec.js +3 -3
  161. package/test/{ng/directive → directive}/validators.spec.js +3 -3
  162. package/test/{ng/filter → filter}/filter.spec.js +4 -4
  163. package/test/{ng/filter → filter}/filters.spec.js +3 -3
  164. package/test/{ng/filter → filter}/limit-to.spec.js +3 -3
  165. package/test/{ng/filter → filter}/order-by.spec.js +2 -2
  166. package/test/injector.spec.js +1 -1
  167. package/test/jqlite.spec.js +1 -1
  168. package/test/messages/messages.spec.js +1 -1
  169. package/test/min-err.spec.js +1 -1
  170. package/test/original-test.html +4 -4
  171. package/test/router/glob.spec.js +78 -0
  172. package/test/router/state.spec.js +931 -0
  173. package/test/sanitize/bing-html.spec.js +1 -1
  174. package/test/shared/common.spec.js +283 -0
  175. package/test/shared/hof.spec.js +60 -0
  176. package/test/shared/strings.spec.js +40 -0
  177. package/test/{ng → shared}/utils.spec.js +1 -1
  178. package/types/router/angular.d.ts +1 -0
  179. package/types/router/core/common/common.d.ts +370 -0
  180. package/types/router/core/common/coreservices.d.ts +80 -0
  181. package/types/router/core/common/glob.d.ts +60 -0
  182. package/types/router/core/common/hof.d.ts +160 -0
  183. package/types/router/core/common/index.d.ts +8 -0
  184. package/types/router/core/common/predicates.d.ts +25 -0
  185. package/types/router/core/common/queue.d.ts +15 -0
  186. package/types/router/core/common/safeConsole.d.ts +5 -0
  187. package/types/router/core/common/strings.d.ts +64 -0
  188. package/types/router/core/common/trace.d.ts +114 -0
  189. package/types/router/core/globals.d.ts +45 -0
  190. package/types/router/core/hooks/coreResolvables.d.ts +4 -0
  191. package/types/router/core/hooks/ignoredTransition.d.ts +2 -0
  192. package/types/router/core/hooks/invalidTransition.d.ts +2 -0
  193. package/types/router/core/hooks/lazyLoad.d.ts +12 -0
  194. package/types/router/core/hooks/onEnterExitRetain.d.ts +4 -0
  195. package/types/router/core/hooks/redirectTo.d.ts +2 -0
  196. package/types/router/core/hooks/resolve.d.ts +5 -0
  197. package/types/router/core/hooks/updateGlobals.d.ts +2 -0
  198. package/types/router/core/hooks/url.d.ts +2 -0
  199. package/types/router/core/hooks/views.d.ts +3 -0
  200. package/types/router/core/index.d.ts +12 -0
  201. package/types/router/core/interface.d.ts +102 -0
  202. package/types/router/core/params/index.d.ts +12 -0
  203. package/types/router/core/params/interface.d.ts +606 -0
  204. package/types/router/core/params/param.d.ts +65 -0
  205. package/types/router/core/params/paramType.d.ts +65 -0
  206. package/types/router/core/params/paramTypes.d.ts +190 -0
  207. package/types/router/core/params/stateParams.d.ts +15 -0
  208. package/types/router/core/path/index.d.ts +2 -0
  209. package/types/router/core/path/pathNode.d.ts +60 -0
  210. package/types/router/core/path/pathUtils.d.ts +79 -0
  211. package/types/router/core/resolve/index.d.ts +3 -0
  212. package/types/router/core/resolve/interface.d.ts +210 -0
  213. package/types/router/core/resolve/resolvable.d.ts +69 -0
  214. package/types/router/core/resolve/resolveContext.d.ts +92 -0
  215. package/types/router/core/router.d.ts +95 -0
  216. package/types/router/core/state/index.d.ts +28 -0
  217. package/types/router/core/state/interface.d.ts +708 -0
  218. package/types/router/core/state/stateBuilder.d.ts +104 -0
  219. package/types/router/core/state/stateMatcher.d.ts +11 -0
  220. package/types/router/core/state/stateObject.d.ts +155 -0
  221. package/types/router/core/state/stateQueueManager.d.ts +24 -0
  222. package/types/router/core/state/stateRegistry.d.ts +136 -0
  223. package/types/router/core/state/stateService.d.ts +350 -0
  224. package/types/router/core/state/targetState.d.ts +100 -0
  225. package/types/router/core/transition/hookBuilder.d.ts +45 -0
  226. package/types/router/core/transition/hookRegistry.d.ts +93 -0
  227. package/types/router/core/transition/index.d.ts +20 -0
  228. package/types/router/core/transition/interface.d.ts +819 -0
  229. package/types/router/core/transition/rejectFactory.d.ts +103 -0
  230. package/types/router/core/transition/transition.d.ts +527 -0
  231. package/types/router/core/transition/transitionEventType.d.ts +17 -0
  232. package/types/router/core/transition/transitionHook.d.ts +88 -0
  233. package/types/router/core/transition/transitionService.d.ts +187 -0
  234. package/types/router/core/url/index.d.ts +8 -0
  235. package/types/router/core/url/interface.d.ts +156 -0
  236. package/types/router/core/url/urlConfig.d.ts +141 -0
  237. package/types/router/core/url/urlMatcher.d.ts +180 -0
  238. package/types/router/core/url/urlMatcherFactory.d.ts +52 -0
  239. package/types/router/core/url/urlRouter.d.ts +85 -0
  240. package/types/router/core/url/urlRule.d.ts +120 -0
  241. package/types/router/core/url/urlRules.d.ts +244 -0
  242. package/types/router/core/url/urlService.d.ts +206 -0
  243. package/types/router/core/vanilla.d.ts +1 -0
  244. package/types/router/core/view/index.d.ts +2 -0
  245. package/types/router/core/view/interface.d.ts +46 -0
  246. package/types/router/core/view/view.d.ts +167 -0
  247. package/types/router/directives/stateDirectives.d.ts +3 -0
  248. package/types/router/directives/viewDirective.d.ts +143 -0
  249. package/types/router/index.d.ts +19 -0
  250. package/types/router/interface.d.ts +491 -0
  251. package/types/router/legacy/resolveService.d.ts +44 -0
  252. package/types/router/legacy/stateEvents.d.ts +123 -0
  253. package/types/router/locationServices.d.ts +43 -0
  254. package/types/router/services.d.ts +15 -0
  255. package/types/router/stateFilters.d.ts +11 -0
  256. package/types/router/stateProvider.d.ts +254 -0
  257. package/types/router/statebuilders/onEnterExitRetain.d.ts +12 -0
  258. package/types/router/statebuilders/views.d.ts +41 -0
  259. package/types/router/templateFactory.d.ts +84 -0
  260. package/types/router/viewScroll.d.ts +9 -0
  261. package/src/animations/animate.css.md +0 -263
  262. package/src/animations/animate.md +0 -933
  263. package/src/router/adapter/statebuilders/onEnterExitRetain.js +0 -29
  264. package/src/router/core/common/coreservices.js +0 -15
  265. package/src/router/core/common/safeConsole.js +0 -37
  266. package/src/router/core/interface.js +0 -3
  267. package/src/router/core/resolve/interface.js +0 -10
  268. package/src/router/core/router.js +0 -203
  269. package/src/router/core/url/interface.js +0 -1
  270. package/src/router/core/view/interface.js +0 -1
  271. /package/src/router/{core/common → common}/glob.js +0 -0
  272. /package/src/router/{core/hooks → hooks}/ignoredTransition.js +0 -0
  273. /package/src/router/{core/hooks → hooks}/invalidTransition.js +0 -0
  274. /package/src/router/{core/hooks → hooks}/onEnterExitRetain.js +0 -0
  275. /package/src/router/{core/hooks → hooks}/url.js +0 -0
  276. /package/src/router/{core/params → params}/README.md +0 -0
  277. /package/src/router/{core/state → state}/README.md +0 -0
  278. /package/src/router/{adapter/stateFilters.js → stateFilters.js} +0 -0
  279. /package/src/router/{core/transition → transition}/interface.js +0 -0
  280. /package/src/router/{core/transition → transition}/transitionEventType.js +0 -0
  281. /package/src/{router/core/common → shared}/hof.js +0 -0
  282. /package/test/{ng → core}/cache-factor.spec.js +0 -0
  283. /package/test/{ng → core}/controller-provider.spec.js +0 -0
  284. /package/test/{ng → core}/cookie-reader.spec.js +0 -0
  285. /package/test/{ng → core}/document.spec.js +0 -0
  286. /package/test/{ng → core}/filter.spec.js +0 -0
  287. /package/test/{ng → core}/http-backend.spec.js +0 -0
  288. /package/test/{ng → core}/interpolate.spec.js +0 -0
  289. /package/test/{ng → core}/interval.spec.js +0 -0
  290. /package/test/{ng → core}/location.spec.js +0 -0
  291. /package/test/{ng → core}/q.spec.js +0 -0
  292. /package/test/{ng → core}/root-element.spec.js +0 -0
  293. /package/test/{ng → core}/sanitize-uri.spec.js +0 -0
  294. /package/test/{ng → core}/sce.spec.js +0 -0
  295. /package/test/{ng → core}/template-request.spec.js +0 -0
  296. /package/test/{ng → core}/timeout.spec.js +0 -0
  297. /package/test/{ng → core}/url-utils.spec.js +0 -0
  298. /package/{src/router/adapter/interface.js → types/router/injectables.d.ts} +0 -0
@@ -0,0 +1,350 @@
1
+ import { HookResult, TransitionOptions } from '../transition/interface';
2
+ import { Transition } from '../transition/transition';
3
+ import { HrefOptions, LazyLoadResult, StateDeclaration, StateOrName, TransitionPromise } from './interface';
4
+ import { StateObject } from './stateObject';
5
+ import { TargetState } from './targetState';
6
+ import { RawParams } from '../params/interface';
7
+ import { UIRouter } from '../router';
8
+ import { UIInjector } from '../interface';
9
+ import { StateParams } from '../params/stateParams';
10
+ export declare type OnInvalidCallback = (toState?: TargetState, fromState?: TargetState, injector?: UIInjector) => HookResult;
11
+ /**
12
+ * Provides services related to ui-router states.
13
+ *
14
+ * This API is located at `router.stateService` ([[UIRouter.stateService]])
15
+ */
16
+ export declare class StateService {
17
+ private router;
18
+ /** @internal */
19
+ invalidCallbacks: OnInvalidCallback[];
20
+ /**
21
+ * The [[Transition]] currently in progress (or null)
22
+ *
23
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.transition]]
24
+ */
25
+ transition: Transition;
26
+ /**
27
+ * The latest successful state parameters
28
+ *
29
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.params]]
30
+ */
31
+ params: StateParams;
32
+ /**
33
+ * The current [[StateDeclaration]]
34
+ *
35
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.current]]
36
+ */
37
+ current: StateDeclaration;
38
+ /**
39
+ * The current [[StateObject]] (an internal API)
40
+ *
41
+ * @deprecated This is a passthrough through to [[UIRouterGlobals.$current]]
42
+ */
43
+ $current: StateObject;
44
+ /** @internal */
45
+ constructor(/** @internal */ router: UIRouter);
46
+ /** @internal */
47
+ dispose(): void;
48
+ /**
49
+ * Handler for when [[transitionTo]] is called with an invalid state.
50
+ *
51
+ * Invokes the [[onInvalid]] callbacks, in natural order.
52
+ * Each callback's return value is checked in sequence until one of them returns an instance of TargetState.
53
+ * The results of the callbacks are wrapped in $q.when(), so the callbacks may return promises.
54
+ *
55
+ * If a callback returns an TargetState, then it is used as arguments to $state.transitionTo() and the result returned.
56
+ *
57
+ * @internal
58
+ */
59
+ private _handleInvalidTargetState;
60
+ /**
61
+ * Registers an Invalid State handler
62
+ *
63
+ * Registers a [[OnInvalidCallback]] function to be invoked when [[StateService.transitionTo]]
64
+ * has been called with an invalid state reference parameter
65
+ *
66
+ * Example:
67
+ * ```js
68
+ * stateService.onInvalid(function(to, from, injector) {
69
+ * if (to.name() === 'foo') {
70
+ * let lazyLoader = injector.get('LazyLoadService');
71
+ * return lazyLoader.load('foo')
72
+ * .then(() => stateService.target('foo'));
73
+ * }
74
+ * });
75
+ * ```
76
+ *
77
+ * @param {function} callback invoked when the toState is invalid
78
+ * This function receives the (invalid) toState, the fromState, and an injector.
79
+ * The function may optionally return a [[TargetState]] or a Promise for a TargetState.
80
+ * If one is returned, it is treated as a redirect.
81
+ *
82
+ * @returns a function which deregisters the callback
83
+ */
84
+ onInvalid(callback: OnInvalidCallback): Function;
85
+ /**
86
+ * Reloads the current state
87
+ *
88
+ * A method that force reloads the current state, or a partial state hierarchy.
89
+ * All resolves are re-resolved, and components reinstantiated.
90
+ *
91
+ * #### Example:
92
+ * ```js
93
+ * let app angular.module('app', ['ui.router']);
94
+ *
95
+ * app.controller('ctrl', function ($scope, $state) {
96
+ * $scope.reload = function(){
97
+ * $state.reload();
98
+ * }
99
+ * });
100
+ * ```
101
+ *
102
+ * Note: `reload()` is just an alias for:
103
+ *
104
+ * ```js
105
+ * $state.transitionTo($state.current, $state.params, {
106
+ * reload: true, inherit: false
107
+ * });
108
+ * ```
109
+ *
110
+ * @param reloadState A state name or a state object.
111
+ * If present, this state and all its children will be reloaded, but ancestors will not reload.
112
+ *
113
+ * #### Example:
114
+ * ```js
115
+ * //assuming app application consists of 3 states: 'contacts', 'contacts.detail', 'contacts.detail.item'
116
+ * //and current state is 'contacts.detail.item'
117
+ * let app angular.module('app', ['ui.router']);
118
+ *
119
+ * app.controller('ctrl', function ($scope, $state) {
120
+ * $scope.reload = function(){
121
+ * //will reload 'contact.detail' and nested 'contact.detail.item' states
122
+ * $state.reload('contact.detail');
123
+ * }
124
+ * });
125
+ * ```
126
+ *
127
+ * @returns A promise representing the state of the new transition. See [[StateService.go]]
128
+ */
129
+ reload(reloadState?: StateOrName): Promise<StateObject>;
130
+ /**
131
+ * Transition to a different state and/or parameters
132
+ *
133
+ * Convenience method for transitioning to a new state.
134
+ *
135
+ * `$state.go` calls `$state.transitionTo` internally but automatically sets options to
136
+ * `{ location: true, inherit: true, relative: router.globals.$current, notify: true }`.
137
+ * This allows you to use either an absolute or relative `to` argument (because of `relative: router.globals.$current`).
138
+ * It also allows you to specify * only the parameters you'd like to update, while letting unspecified parameters
139
+ * inherit from the current parameter values (because of `inherit: true`).
140
+ *
141
+ * #### Example:
142
+ * ```js
143
+ * let app = angular.module('app', ['ui.router']);
144
+ *
145
+ * app.controller('ctrl', function ($scope, $state) {
146
+ * $scope.changeState = function () {
147
+ * $state.go('contact.detail');
148
+ * };
149
+ * });
150
+ * ```
151
+ *
152
+ * @param to Absolute state name, state object, or relative state path (relative to current state).
153
+ *
154
+ * Some examples:
155
+ *
156
+ * - `$state.go('contact.detail')` - will go to the `contact.detail` state
157
+ * - `$state.go('^')` - will go to the parent state
158
+ * - `$state.go('^.sibling')` - if current state is `home.child`, will go to the `home.sibling` state
159
+ * - `$state.go('.child.grandchild')` - if current state is home, will go to the `home.child.grandchild` state
160
+ *
161
+ * @param params A map of the parameters that will be sent to the state, will populate $stateParams.
162
+ *
163
+ * Any parameters that are not specified will be inherited from current parameter values (because of `inherit: true`).
164
+ * This allows, for example, going to a sibling state that shares parameters defined by a parent state.
165
+ *
166
+ * @param options Transition options
167
+ *
168
+ * @returns {promise} A promise representing the state of the new transition.
169
+ */
170
+ go(to: StateOrName, params?: RawParams, options?: TransitionOptions): TransitionPromise;
171
+ /**
172
+ * Creates a [[TargetState]]
173
+ *
174
+ * This is a factory method for creating a TargetState
175
+ *
176
+ * This may be returned from a Transition Hook to redirect a transition, for example.
177
+ */
178
+ target(identifier: StateOrName, params?: RawParams, options?: TransitionOptions): TargetState;
179
+ /** @internal */
180
+ private getCurrentPath;
181
+ /**
182
+ * Low-level method for transitioning to a new state.
183
+ *
184
+ * The [[go]] method (which uses `transitionTo` internally) is recommended in most situations.
185
+ *
186
+ * #### Example:
187
+ * ```js
188
+ * let app = angular.module('app', ['ui.router']);
189
+ *
190
+ * app.controller('ctrl', function ($scope, $state) {
191
+ * $scope.changeState = function () {
192
+ * $state.transitionTo('contact.detail');
193
+ * };
194
+ * });
195
+ * ```
196
+ *
197
+ * @param to State name or state object.
198
+ * @param toParams A map of the parameters that will be sent to the state,
199
+ * will populate $stateParams.
200
+ * @param options Transition options
201
+ *
202
+ * @returns A promise representing the state of the new transition. See [[go]]
203
+ */
204
+ transitionTo(to: StateOrName, toParams?: RawParams, options?: TransitionOptions): TransitionPromise;
205
+ /**
206
+ * Checks if the current state *is* the provided state
207
+ *
208
+ * Similar to [[includes]] but only checks for the full state name.
209
+ * If params is supplied then it will be tested for strict equality against the current
210
+ * active params object, so all params must match with none missing and no extras.
211
+ *
212
+ * #### Example:
213
+ * ```js
214
+ * $state.$current.name = 'contacts.details.item';
215
+ *
216
+ * // absolute name
217
+ * $state.is('contact.details.item'); // returns true
218
+ * $state.is(contactDetailItemStateObject); // returns true
219
+ * ```
220
+ *
221
+ * // relative name (. and ^), typically from a template
222
+ * // E.g. from the 'contacts.details' template
223
+ * ```html
224
+ * <div ng-class="{highlighted: $state.is('.item')}">Item</div>
225
+ * ```
226
+ *
227
+ * @param stateOrName The state name (absolute or relative) or state object you'd like to check.
228
+ * @param params A param object, e.g. `{sectionId: section.id}`, that you'd like
229
+ * to test against the current active state.
230
+ * @param options An options object. The options are:
231
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
232
+ * test relative to `options.relative` state (or name).
233
+ *
234
+ * @returns Returns true if it is the state.
235
+ */
236
+ is(stateOrName: StateOrName, params?: RawParams, options?: {
237
+ relative?: StateOrName;
238
+ }): boolean;
239
+ /**
240
+ * Checks if the current state *includes* the provided state
241
+ *
242
+ * A method to determine if the current active state is equal to or is the child of the
243
+ * state stateName. If any params are passed then they will be tested for a match as well.
244
+ * Not all the parameters need to be passed, just the ones you'd like to test for equality.
245
+ *
246
+ * #### Example when `$state.$current.name === 'contacts.details.item'`
247
+ * ```js
248
+ * // Using partial names
249
+ * $state.includes("contacts"); // returns true
250
+ * $state.includes("contacts.details"); // returns true
251
+ * $state.includes("contacts.details.item"); // returns true
252
+ * $state.includes("contacts.list"); // returns false
253
+ * $state.includes("about"); // returns false
254
+ * ```
255
+ *
256
+ * #### Glob Examples when `* $state.$current.name === 'contacts.details.item.url'`:
257
+ * ```js
258
+ * $state.includes("*.details.*.*"); // returns true
259
+ * $state.includes("*.details.**"); // returns true
260
+ * $state.includes("**.item.**"); // returns true
261
+ * $state.includes("*.details.item.url"); // returns true
262
+ * $state.includes("*.details.*.url"); // returns true
263
+ * $state.includes("*.details.*"); // returns false
264
+ * $state.includes("item.**"); // returns false
265
+ * ```
266
+ *
267
+ * @param stateOrName A partial name, relative name, glob pattern,
268
+ * or state object to be searched for within the current state name.
269
+ * @param params A param object, e.g. `{sectionId: section.id}`,
270
+ * that you'd like to test against the current active state.
271
+ * @param options An options object. The options are:
272
+ * - `relative`: If `stateOrName` is a relative state name and `options.relative` is set, .is will
273
+ * test relative to `options.relative` state (or name).
274
+ *
275
+ * @returns {boolean} Returns true if it does include the state
276
+ */
277
+ includes(stateOrName: StateOrName, params?: RawParams, options?: TransitionOptions): boolean;
278
+ /**
279
+ * Generates a URL for a state and parameters
280
+ *
281
+ * Returns the url for the given state populated with the given params.
282
+ *
283
+ * #### Example:
284
+ * ```js
285
+ * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
286
+ * ```
287
+ *
288
+ * @param stateOrName The state name or state object you'd like to generate a url from.
289
+ * @param params An object of parameter values to fill the state's required parameters.
290
+ * @param options Options object. The options are:
291
+ *
292
+ * @returns {string} compiled state url
293
+ */
294
+ href(stateOrName: StateOrName, params?: RawParams, options?: HrefOptions): string;
295
+ /** @internal */
296
+ private _defaultErrorHandler;
297
+ /**
298
+ * Sets or gets the default [[transitionTo]] error handler.
299
+ *
300
+ * The error handler is called when a [[Transition]] is rejected or when any error occurred during the Transition.
301
+ * This includes errors caused by resolves and transition hooks.
302
+ *
303
+ * Note:
304
+ * This handler does not receive certain Transition rejections.
305
+ * Redirected and Ignored Transitions are not considered to be errors by [[StateService.transitionTo]].
306
+ *
307
+ * The built-in default error handler logs the error to the console.
308
+ *
309
+ * You can provide your own custom handler.
310
+ *
311
+ * #### Example:
312
+ * ```js
313
+ * stateService.defaultErrorHandler(function() {
314
+ * // Do not log transitionTo errors
315
+ * });
316
+ * ```
317
+ *
318
+ * @param handler a global error handler function
319
+ * @returns the current global error handler
320
+ */
321
+ defaultErrorHandler(handler?: (error: any) => void): (error: any) => void;
322
+ /**
323
+ * Gets a registered [[StateDeclaration]] object
324
+ *
325
+ * Returns the state declaration object for any specific state, or for all registered states.
326
+ *
327
+ * @param stateOrName (absolute or relative) If provided, will only get the declaration object for the requested state.
328
+ * If not provided, returns an array of ALL states.
329
+ * @param base When `stateOrName` is a relative state reference (such as `.bar.baz`), the state will be retrieved relative to this state.
330
+ *
331
+ * @returns a [[StateDeclaration]] object (or array of all registered [[StateDeclaration]] objects.)
332
+ * @deprecated use [[StateRegistry.get]]
333
+ */
334
+ get(stateOrName: StateOrName, base: StateOrName): StateDeclaration;
335
+ get(stateOrName: StateOrName): StateDeclaration;
336
+ get(): StateDeclaration[];
337
+ /**
338
+ * Lazy loads a state
339
+ *
340
+ * Explicitly runs a state's [[StateDeclaration.lazyLoad]] function.
341
+ *
342
+ * @param stateOrName the state that should be lazy loaded
343
+ * @param transition the optional Transition context to use (if the lazyLoad function requires an injector, etc)
344
+ * Note: If no transition is provided, a noop transition is created using the from the current state to the current state.
345
+ * This noop transition is not actually run.
346
+ *
347
+ * @returns a promise to lazy load
348
+ */
349
+ lazyLoad(stateOrName: StateOrName, transition?: Transition): Promise<LazyLoadResult>;
350
+ }
@@ -0,0 +1,100 @@
1
+ import { StateDeclaration, StateOrName, TargetStateDef } from './interface';
2
+ import { TransitionOptions } from '../transition/interface';
3
+ import { StateObject } from './stateObject';
4
+ import { StateRegistry } from './stateRegistry';
5
+ import { RawParams } from '../params';
6
+ /**
7
+ * Encapsulate the target (destination) state/params/options of a [[Transition]].
8
+ *
9
+ * This class is frequently used to redirect a transition to a new destination.
10
+ *
11
+ * See:
12
+ *
13
+ * - [[HookResult]]
14
+ * - [[TransitionHookFn]]
15
+ * - [[TransitionService.onStart]]
16
+ *
17
+ * To create a `TargetState`, use [[StateService.target]].
18
+ *
19
+ * ---
20
+ *
21
+ * This class wraps:
22
+ *
23
+ * 1) an identifier for a state
24
+ * 2) a set of parameters
25
+ * 3) and transition options
26
+ * 4) the registered state object (the [[StateDeclaration]])
27
+ *
28
+ * Many UI-Router APIs such as [[StateService.go]] take a [[StateOrName]] argument which can
29
+ * either be a *state object* (a [[StateDeclaration]] or [[StateObject]]) or a *state name* (a string).
30
+ * The `TargetState` class normalizes those options.
31
+ *
32
+ * A `TargetState` may be valid (the state being targeted exists in the registry)
33
+ * or invalid (the state being targeted is not registered).
34
+ */
35
+ export declare class TargetState {
36
+ private _stateRegistry;
37
+ private _identifier;
38
+ private _definition;
39
+ private _params;
40
+ private _options;
41
+ /** Returns true if the object has a state property that might be a state or state name */
42
+ static isDef: (obj: any) => obj is TargetStateDef;
43
+ /**
44
+ * The TargetState constructor
45
+ *
46
+ * Note: Do not construct a `TargetState` manually.
47
+ * To create a `TargetState`, use the [[StateService.target]] factory method.
48
+ *
49
+ * @param _stateRegistry The StateRegistry to use to look up the _definition
50
+ * @param _identifier An identifier for a state.
51
+ * Either a fully-qualified state name, or the object used to define the state.
52
+ * @param _params Parameters for the target state
53
+ * @param _options Transition options.
54
+ *
55
+ * @internal
56
+ */
57
+ constructor(_stateRegistry: StateRegistry, _identifier: StateOrName, _params?: RawParams, _options?: TransitionOptions);
58
+ /** The name of the state this object targets */
59
+ name(): string;
60
+ /** The identifier used when creating this TargetState */
61
+ identifier(): StateOrName;
62
+ /** The target parameter values */
63
+ params(): RawParams;
64
+ /** The internal state object (if it was found) */
65
+ $state(): StateObject;
66
+ /** The internal state declaration (if it was found) */
67
+ state(): StateDeclaration;
68
+ /** The target options */
69
+ options(): TransitionOptions;
70
+ /** True if the target state was found */
71
+ exists(): boolean;
72
+ /** True if the object is valid */
73
+ valid(): boolean;
74
+ /** If the object is invalid, returns the reason why */
75
+ error(): string;
76
+ toString(): string;
77
+ /**
78
+ * Returns a copy of this TargetState which targets a different state.
79
+ * The new TargetState has the same parameter values and transition options.
80
+ *
81
+ * @param state The new state that should be targeted
82
+ */
83
+ withState(state: StateOrName): TargetState;
84
+ /**
85
+ * Returns a copy of this TargetState, using the specified parameter values.
86
+ *
87
+ * @param params the new parameter values to use
88
+ * @param replace When false (default) the new parameter values will be merged with the current values.
89
+ * When true the parameter values will be used instead of the current values.
90
+ */
91
+ withParams(params: RawParams, replace?: boolean): TargetState;
92
+ /**
93
+ * Returns a copy of this TargetState, using the specified Transition Options.
94
+ *
95
+ * @param options the new options to use
96
+ * @param replace When false (default) the new options will be merged with the current options.
97
+ * When true the options will be used instead of the current options.
98
+ */
99
+ withOptions(options: TransitionOptions, replace?: boolean): TargetState;
100
+ }
@@ -0,0 +1,45 @@
1
+ import { TreeChanges, TransitionHookPhase } from './interface';
2
+ import { Transition } from './transition';
3
+ import { TransitionHook } from './transitionHook';
4
+ import { TransitionEventType } from './transitionEventType';
5
+ import { RegisteredHook } from './hookRegistry';
6
+ /**
7
+ * This class returns applicable TransitionHooks for a specific Transition instance.
8
+ *
9
+ * Hooks ([[RegisteredHook]]) may be registered globally, e.g., $transitions.onEnter(...), or locally, e.g.
10
+ * myTransition.onEnter(...). The HookBuilder finds matching RegisteredHooks (where the match criteria is
11
+ * determined by the type of hook)
12
+ *
13
+ * The HookBuilder also converts RegisteredHooks objects to TransitionHook objects, which are used to run a Transition.
14
+ *
15
+ * The HookBuilder constructor is given the $transitions service and a Transition instance. Thus, a HookBuilder
16
+ * instance may only be used for one specific Transition object. (side note: the _treeChanges accessor is private
17
+ * in the Transition class, so we must also provide the Transition's _treeChanges)
18
+ */
19
+ export declare class HookBuilder {
20
+ private transition;
21
+ constructor(transition: Transition);
22
+ buildHooksForPhase(phase: TransitionHookPhase): TransitionHook[];
23
+ /**
24
+ * Returns an array of newly built TransitionHook objects.
25
+ *
26
+ * - Finds all RegisteredHooks registered for the given `hookType` which matched the transition's [[TreeChanges]].
27
+ * - Finds [[PathNode]] (or `PathNode[]`) to use as the TransitionHook context(s)
28
+ * - For each of the [[PathNode]]s, creates a TransitionHook
29
+ *
30
+ * @param hookType the type of the hook registration function, e.g., 'onEnter', 'onFinish'.
31
+ */
32
+ buildHooks(hookType: TransitionEventType): TransitionHook[];
33
+ /**
34
+ * Finds all RegisteredHooks from:
35
+ * - The Transition object instance hook registry
36
+ * - The TransitionService ($transitions) global hook registry
37
+ *
38
+ * which matched:
39
+ * - the eventType
40
+ * - the matchCriteria (to, from, exiting, retained, entering)
41
+ *
42
+ * @returns an array of matched [[RegisteredHook]]s
43
+ */
44
+ getMatchingHooks(hookType: TransitionEventType, treeChanges: TreeChanges, transition: Transition): RegisteredHook[];
45
+ }
@@ -0,0 +1,93 @@
1
+ import { IHookRegistry } from './interface';
2
+ import { HookRegOptions, HookMatchCriteria, TreeChanges, HookMatchCriterion, IMatchingNodes, HookFn } from './interface';
3
+ import { Transition } from './transition';
4
+ import { StateObject } from '../state/stateObject';
5
+ import { TransitionEventType } from './transitionEventType';
6
+ import { TransitionService } from './transitionService';
7
+ /**
8
+ * Determines if the given state matches the matchCriteria
9
+ *
10
+ * @internal
11
+ *
12
+ * @param state a State Object to test against
13
+ * @param criterion
14
+ * - If a string, matchState uses the string as a glob-matcher against the state name
15
+ * - If an array (of strings), matchState uses each string in the array as a glob-matchers against the state name
16
+ * and returns a positive match if any of the globs match.
17
+ * - If a function, matchState calls the function with the state and returns true if the function's result is truthy.
18
+ * @returns {boolean}
19
+ */
20
+ export declare function matchState(state: StateObject, criterion: HookMatchCriterion, transition: Transition): boolean;
21
+ /**
22
+ * The registration data for a registered transition hook
23
+ */
24
+ export declare class RegisteredHook {
25
+ tranSvc: TransitionService;
26
+ eventType: TransitionEventType;
27
+ callback: HookFn;
28
+ matchCriteria: HookMatchCriteria;
29
+ removeHookFromRegistry: (hook: RegisteredHook) => void;
30
+ priority: number;
31
+ bind: any;
32
+ invokeCount: number;
33
+ invokeLimit: number;
34
+ _deregistered: boolean;
35
+ constructor(tranSvc: TransitionService, eventType: TransitionEventType, callback: HookFn, matchCriteria: HookMatchCriteria, removeHookFromRegistry: (hook: RegisteredHook) => void, options?: HookRegOptions);
36
+ /**
37
+ * Gets the matching [[PathNode]]s
38
+ *
39
+ * Given an array of [[PathNode]]s, and a [[HookMatchCriterion]], returns an array containing
40
+ * the [[PathNode]]s that the criteria matches, or `null` if there were no matching nodes.
41
+ *
42
+ * Returning `null` is significant to distinguish between the default
43
+ * "match-all criterion value" of `true` compared to a `() => true` function,
44
+ * when the nodes is an empty array.
45
+ *
46
+ * This is useful to allow a transition match criteria of `entering: true`
47
+ * to still match a transition, even when `entering === []`. Contrast that
48
+ * with `entering: (state) => true` which only matches when a state is actually
49
+ * being entered.
50
+ */
51
+ private _matchingNodes;
52
+ /**
53
+ * Gets the default match criteria (all `true`)
54
+ *
55
+ * Returns an object which has all the criteria match paths as keys and `true` as values, i.e.:
56
+ *
57
+ * ```js
58
+ * {
59
+ * to: true,
60
+ * from: true,
61
+ * entering: true,
62
+ * exiting: true,
63
+ * retained: true,
64
+ * }
65
+ */
66
+ private _getDefaultMatchCriteria;
67
+ /**
68
+ * Gets matching nodes as [[IMatchingNodes]]
69
+ *
70
+ * Create a IMatchingNodes object from the TransitionHookTypes that is roughly equivalent to:
71
+ *
72
+ * ```js
73
+ * let matches: IMatchingNodes = {
74
+ * to: _matchingNodes([tail(treeChanges.to)], mc.to),
75
+ * from: _matchingNodes([tail(treeChanges.from)], mc.from),
76
+ * exiting: _matchingNodes(treeChanges.exiting, mc.exiting),
77
+ * retained: _matchingNodes(treeChanges.retained, mc.retained),
78
+ * entering: _matchingNodes(treeChanges.entering, mc.entering),
79
+ * };
80
+ * ```
81
+ */
82
+ private _getMatchingNodes;
83
+ /**
84
+ * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]]
85
+ *
86
+ * @returns an IMatchingNodes object, or null. If an IMatchingNodes object is returned, its values
87
+ * are the matching [[PathNode]]s for each [[HookMatchCriterion]] (to, from, exiting, retained, entering)
88
+ */
89
+ matches(treeChanges: TreeChanges, transition: Transition): IMatchingNodes;
90
+ deregister(): void;
91
+ }
92
+ /** Return a registration function of the requested type. */
93
+ export declare function makeEvent(registry: IHookRegistry, transitionService: TransitionService, eventType: TransitionEventType): (matchObject: any, callback: any, options?: {}) => any;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * # Transition subsystem
3
+ *
4
+ * This module contains APIs related to a Transition.
5
+ *
6
+ * See:
7
+ * - [[TransitionService]]
8
+ * - [[Transition]]
9
+ * - [[HookFn]], [[TransitionHookFn]], [[TransitionStateHookFn]], [[HookMatchCriteria]], [[HookResult]]
10
+ *
11
+ * @packageDocumentation @preferred
12
+ */
13
+ export * from './interface';
14
+ export * from './hookBuilder';
15
+ export * from './hookRegistry';
16
+ export * from './rejectFactory';
17
+ export * from './transition';
18
+ export * from './transitionHook';
19
+ export * from './transitionEventType';
20
+ export * from './transitionService';