@angular-wave/angular.ts 0.0.15 → 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 (294) 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/src/animations/animate-children-directive.js +1 -1
  7. package/src/animations/animate-css-driver.js +1 -1
  8. package/src/animations/animate-css.js +2 -2
  9. package/src/animations/animate-js-driver.js +1 -1
  10. package/src/animations/animate-js.js +2 -2
  11. package/src/animations/animate-queue.js +3 -4
  12. package/src/animations/animation.js +1 -1
  13. package/src/animations/shared.js +4 -4
  14. package/src/core/animate-runner.js +1 -1
  15. package/src/core/animate.js +4 -5
  16. package/src/core/compile.js +5 -6
  17. package/src/core/controller.js +4 -3
  18. package/src/core/filter.js +1 -1
  19. package/src/core/interpolate.js +1 -1
  20. package/src/core/interval-factory.js +1 -1
  21. package/src/core/interval.js +1 -1
  22. package/src/core/location.js +1 -1
  23. package/src/core/parser/parse.js +1 -1
  24. package/src/core/q.js +2 -3
  25. package/src/core/root-scope.js +1 -1
  26. package/src/core/sanitize-uri.js +1 -1
  27. package/src/core/sce.js +1 -1
  28. package/src/core/task-tracker-factory.js +1 -1
  29. package/src/core/timeout.js +1 -1
  30. package/src/core/urlUtils.js +1 -1
  31. package/src/directive/attrs.js +1 -1
  32. package/src/directive/bind.js +1 -1
  33. package/src/directive/class.js +2 -2
  34. package/src/directive/events.js +1 -1
  35. package/src/directive/form.js +1 -1
  36. package/src/directive/include.js +1 -1
  37. package/src/directive/input.js +1 -1
  38. package/src/directive/list.js +2 -2
  39. package/src/directive/model-options.js +1 -1
  40. package/src/directive/model.js +1 -1
  41. package/src/directive/options.js +2 -3
  42. package/src/directive/ref.js +1 -1
  43. package/src/directive/repeat.js +1 -1
  44. package/src/directive/select.js +1 -1
  45. package/src/directive/switch.js +1 -1
  46. package/src/directive/transclude.js +1 -1
  47. package/src/directive/validators.js +1 -1
  48. package/src/exts/aria.js +1 -1
  49. package/src/exts/messages.js +3 -3
  50. package/src/exts/messages.md +28 -31
  51. package/src/filters/filter.js +2 -3
  52. package/src/filters/filters.js +1 -1
  53. package/src/filters/limit-to.js +1 -1
  54. package/src/filters/order-by.js +2 -3
  55. package/src/injector.js +8 -9
  56. package/src/jqLite.js +3 -4
  57. package/src/loader.js +1 -3
  58. package/src/public.js +1 -1
  59. package/src/router/common/coreservices.js +5 -0
  60. package/src/router/{core/common → common}/queue.js +1 -1
  61. package/src/router/{core/common → common}/trace.js +21 -19
  62. package/src/router/{adapter/directives → directives}/stateDirectives.js +24 -28
  63. package/src/router/{adapter/directives → directives}/viewDirective.js +9 -9
  64. package/src/router/{core/globals.js → globals.js} +13 -3
  65. package/src/router/{core/hooks → hooks}/coreResolvables.js +6 -4
  66. package/src/router/{core/hooks → hooks}/lazyLoad.js +5 -2
  67. package/src/router/{core/hooks → hooks}/redirectTo.js +1 -1
  68. package/src/router/{core/hooks → hooks}/resolve.js +2 -2
  69. package/src/router/{core/hooks → hooks}/updateGlobals.js +1 -1
  70. package/src/router/{core/hooks → hooks}/views.js +1 -1
  71. package/src/router/index.js +60 -0
  72. package/src/router/{adapter/injectables.js → injectables.js} +9 -9
  73. package/src/router/{adapter/locationServices.js → locationServices.js} +19 -12
  74. package/src/router/{core/params → params}/param.js +5 -10
  75. package/src/router/{core/params → params}/paramType.js +4 -4
  76. package/src/router/{core/params → params}/paramTypes.js +4 -3
  77. package/src/router/{core/params → params}/stateParams.js +1 -1
  78. package/src/router/{core/path → path}/pathNode.js +2 -2
  79. package/src/router/{core/path → path}/pathUtils.js +13 -7
  80. package/src/router/{core/resolve → resolve}/resolvable.js +5 -5
  81. package/src/router/{core/resolve → resolve}/resolveContext.js +16 -6
  82. package/src/router/router.js +172 -72
  83. package/src/router/{adapter/services.js → services.js} +47 -27
  84. package/src/router/{core/state → state}/stateBuilder.js +14 -10
  85. package/src/router/{core/state → state}/stateMatcher.js +2 -3
  86. package/src/router/{core/state → state}/stateObject.js +8 -6
  87. package/src/router/{core/state → state}/stateQueueManager.js +3 -3
  88. package/src/router/{core/state → state}/stateRegistry.js +6 -7
  89. package/src/router/{core/state → state}/stateService.js +12 -15
  90. package/src/router/{core/state → state}/targetState.js +2 -2
  91. package/src/router/{adapter/statebuilders → state}/views.js +17 -15
  92. package/src/router/{adapter/stateProvider.js → stateProvider.js} +52 -9
  93. package/src/router/{adapter/templateFactory.js → templateFactory.js} +10 -19
  94. package/src/router/{core/transition → transition}/hookBuilder.js +4 -3
  95. package/src/router/{core/transition → transition}/hookRegistry.js +3 -6
  96. package/src/router/{core/transition → transition}/rejectFactory.js +4 -5
  97. package/src/router/{core/transition → transition}/transition.js +10 -12
  98. package/src/router/{core/transition → transition}/transitionHook.js +4 -4
  99. package/src/router/{core/transition → transition}/transitionService.js +13 -13
  100. package/src/router/{core/url → url}/urlConfig.js +28 -19
  101. package/src/router/{core/url → url}/urlMatcher.js +14 -16
  102. package/src/router/{core/url → url}/urlMatcherFactory.js +7 -6
  103. package/src/router/{core/url → url}/urlRouter.js +6 -30
  104. package/src/router/{core/url → url}/urlRule.js +3 -3
  105. package/src/router/{core/url → url}/urlRules.js +10 -11
  106. package/src/router/{core/url → url}/urlService.js +12 -6
  107. package/src/router/{core/view → view}/view.js +32 -27
  108. package/src/router/{adapter/viewScroll.js → viewScroll.js} +3 -0
  109. package/src/services/anchor-scroll.js +1 -1
  110. package/src/services/browser.js +1 -1
  111. package/src/services/cache-factory.js +7 -1
  112. package/src/services/cookie-reader.js +1 -1
  113. package/src/services/http-backend.js +6 -1
  114. package/src/services/http.js +4 -5
  115. package/src/services/log.js +1 -1
  116. package/src/services/template-request.js +2 -2
  117. package/src/{router/core/common → shared}/common.js +35 -16
  118. package/src/{router/core/common → shared}/predicates.js +2 -12
  119. package/src/{router/core/common → shared}/strings.js +5 -13
  120. package/src/{core → shared}/utils.js +13 -29
  121. package/test/angular.spec.js +1 -31
  122. package/test/{ng → core}/animate.spec.js +1 -1
  123. package/test/{ng → core}/compile.spec.js +2 -3
  124. package/test/{ng → core}/http.spec.js +2 -2
  125. package/test/{ng → core}/on.spec.js +1 -1
  126. package/test/{ng → core}/parse.spec.js +1 -1
  127. package/test/{ng → core}/prop.spec.js +1 -1
  128. package/test/{ng → core}/scope.spec.js +1 -1
  129. package/test/{ng/directive → directive}/a.spec.js +4 -4
  130. package/test/{ng/directive → directive}/bind.spec.js +3 -3
  131. package/test/{ng/directive → directive}/boolean.spec.js +2 -2
  132. package/test/{ng/directive → directive}/change.spec.js +3 -3
  133. package/test/{ng/directive → directive}/class.spec.js +4 -4
  134. package/test/{ng/directive → directive}/click.spec.js +3 -3
  135. package/test/{ng/directive → directive}/cloak.spec.js +4 -4
  136. package/test/{ng/directive → directive}/constoller.spec.js +5 -5
  137. package/test/{ng/directive → directive}/element-style.spec.js +3 -3
  138. package/test/{ng/directive → directive}/event.spec.js +4 -4
  139. package/test/{ng/directive → directive}/form.spec.js +5 -5
  140. package/test/{ng/directive → directive}/href.spec.js +4 -4
  141. package/test/{ng/directive → directive}/if.spec.js +5 -5
  142. package/test/{ng/directive → directive}/include.spec.js +5 -5
  143. package/test/{ng/directive → directive}/init.spec.js +4 -4
  144. package/test/{ng/directive → directive}/input.spec.js +5 -5
  145. package/test/{ng/directive → directive}/list.spec.js +3 -3
  146. package/test/{ng/directive → directive}/model-options.spec.js +6 -6
  147. package/test/{ng/directive → directive}/model.spec.js +8 -8
  148. package/test/{ng/directive → directive}/non-bindable.spec.js +3 -3
  149. package/test/{ng/directive → directive}/options.spec.js +5 -5
  150. package/test/{ng/directive → directive}/ref.spec.js +2 -2
  151. package/test/{ng/directive → directive}/repeat.spec.js +5 -5
  152. package/test/{ng/directive → directive}/script.spec.js +3 -3
  153. package/test/{ng/directive → directive}/scrset.spec.js +3 -3
  154. package/test/{ng/directive → directive}/select.spec.js +5 -5
  155. package/test/{ng/directive → directive}/show-hide.spec.js +3 -3
  156. package/test/{ng/directive → directive}/src.spec.js +3 -3
  157. package/test/{ng/directive → directive}/style.spec.js +3 -3
  158. package/test/{ng/directive → directive}/switch.spec.js +3 -3
  159. package/test/{ng/directive → directive}/validators.spec.js +3 -3
  160. package/test/{ng/filter → filter}/filter.spec.js +4 -4
  161. package/test/{ng/filter → filter}/filters.spec.js +3 -3
  162. package/test/{ng/filter → filter}/limit-to.spec.js +3 -3
  163. package/test/{ng/filter → filter}/order-by.spec.js +2 -2
  164. package/test/injector.spec.js +1 -1
  165. package/test/jqlite.spec.js +1 -1
  166. package/test/messages/messages.spec.js +1 -1
  167. package/test/min-err.spec.js +1 -1
  168. package/test/original-test.html +4 -4
  169. package/test/router/glob.spec.js +78 -0
  170. package/test/router/state.spec.js +931 -0
  171. package/test/sanitize/bing-html.spec.js +1 -1
  172. package/test/shared/common.spec.js +283 -0
  173. package/test/shared/hof.spec.js +60 -0
  174. package/test/shared/strings.spec.js +40 -0
  175. package/test/{ng → shared}/utils.spec.js +1 -1
  176. package/types/router/angular.d.ts +1 -0
  177. package/types/router/core/common/common.d.ts +370 -0
  178. package/types/router/core/common/coreservices.d.ts +80 -0
  179. package/types/router/core/common/glob.d.ts +60 -0
  180. package/types/router/core/common/hof.d.ts +160 -0
  181. package/types/router/core/common/index.d.ts +8 -0
  182. package/types/router/core/common/predicates.d.ts +25 -0
  183. package/types/router/core/common/queue.d.ts +15 -0
  184. package/types/router/core/common/safeConsole.d.ts +5 -0
  185. package/types/router/core/common/strings.d.ts +64 -0
  186. package/types/router/core/common/trace.d.ts +114 -0
  187. package/types/router/core/globals.d.ts +45 -0
  188. package/types/router/core/hooks/coreResolvables.d.ts +4 -0
  189. package/types/router/core/hooks/ignoredTransition.d.ts +2 -0
  190. package/types/router/core/hooks/invalidTransition.d.ts +2 -0
  191. package/types/router/core/hooks/lazyLoad.d.ts +12 -0
  192. package/types/router/core/hooks/onEnterExitRetain.d.ts +4 -0
  193. package/types/router/core/hooks/redirectTo.d.ts +2 -0
  194. package/types/router/core/hooks/resolve.d.ts +5 -0
  195. package/types/router/core/hooks/updateGlobals.d.ts +2 -0
  196. package/types/router/core/hooks/url.d.ts +2 -0
  197. package/types/router/core/hooks/views.d.ts +3 -0
  198. package/types/router/core/index.d.ts +12 -0
  199. package/types/router/core/interface.d.ts +102 -0
  200. package/types/router/core/params/index.d.ts +12 -0
  201. package/types/router/core/params/interface.d.ts +606 -0
  202. package/types/router/core/params/param.d.ts +65 -0
  203. package/types/router/core/params/paramType.d.ts +65 -0
  204. package/types/router/core/params/paramTypes.d.ts +190 -0
  205. package/types/router/core/params/stateParams.d.ts +15 -0
  206. package/types/router/core/path/index.d.ts +2 -0
  207. package/types/router/core/path/pathNode.d.ts +60 -0
  208. package/types/router/core/path/pathUtils.d.ts +79 -0
  209. package/types/router/core/resolve/index.d.ts +3 -0
  210. package/types/router/core/resolve/interface.d.ts +210 -0
  211. package/types/router/core/resolve/resolvable.d.ts +69 -0
  212. package/types/router/core/resolve/resolveContext.d.ts +92 -0
  213. package/types/router/core/router.d.ts +95 -0
  214. package/types/router/core/state/index.d.ts +28 -0
  215. package/types/router/core/state/interface.d.ts +708 -0
  216. package/types/router/core/state/stateBuilder.d.ts +104 -0
  217. package/types/router/core/state/stateMatcher.d.ts +11 -0
  218. package/types/router/core/state/stateObject.d.ts +155 -0
  219. package/types/router/core/state/stateQueueManager.d.ts +24 -0
  220. package/types/router/core/state/stateRegistry.d.ts +136 -0
  221. package/types/router/core/state/stateService.d.ts +350 -0
  222. package/types/router/core/state/targetState.d.ts +100 -0
  223. package/types/router/core/transition/hookBuilder.d.ts +45 -0
  224. package/types/router/core/transition/hookRegistry.d.ts +93 -0
  225. package/types/router/core/transition/index.d.ts +20 -0
  226. package/types/router/core/transition/interface.d.ts +819 -0
  227. package/types/router/core/transition/rejectFactory.d.ts +103 -0
  228. package/types/router/core/transition/transition.d.ts +527 -0
  229. package/types/router/core/transition/transitionEventType.d.ts +17 -0
  230. package/types/router/core/transition/transitionHook.d.ts +88 -0
  231. package/types/router/core/transition/transitionService.d.ts +187 -0
  232. package/types/router/core/url/index.d.ts +8 -0
  233. package/types/router/core/url/interface.d.ts +156 -0
  234. package/types/router/core/url/urlConfig.d.ts +141 -0
  235. package/types/router/core/url/urlMatcher.d.ts +180 -0
  236. package/types/router/core/url/urlMatcherFactory.d.ts +52 -0
  237. package/types/router/core/url/urlRouter.d.ts +85 -0
  238. package/types/router/core/url/urlRule.d.ts +120 -0
  239. package/types/router/core/url/urlRules.d.ts +244 -0
  240. package/types/router/core/url/urlService.d.ts +206 -0
  241. package/types/router/core/vanilla.d.ts +1 -0
  242. package/types/router/core/view/index.d.ts +2 -0
  243. package/types/router/core/view/interface.d.ts +46 -0
  244. package/types/router/core/view/view.d.ts +167 -0
  245. package/types/router/directives/stateDirectives.d.ts +3 -0
  246. package/types/router/directives/viewDirective.d.ts +143 -0
  247. package/types/router/index.d.ts +19 -0
  248. package/types/router/interface.d.ts +491 -0
  249. package/types/router/legacy/resolveService.d.ts +44 -0
  250. package/types/router/legacy/stateEvents.d.ts +123 -0
  251. package/types/router/locationServices.d.ts +43 -0
  252. package/types/router/services.d.ts +15 -0
  253. package/types/router/stateFilters.d.ts +11 -0
  254. package/types/router/stateProvider.d.ts +254 -0
  255. package/types/router/statebuilders/onEnterExitRetain.d.ts +12 -0
  256. package/types/router/statebuilders/views.d.ts +41 -0
  257. package/types/router/templateFactory.d.ts +84 -0
  258. package/types/router/viewScroll.d.ts +9 -0
  259. package/src/router/adapter/statebuilders/onEnterExitRetain.js +0 -29
  260. package/src/router/core/common/coreservices.js +0 -15
  261. package/src/router/core/common/safeConsole.js +0 -38
  262. package/src/router/core/interface.js +0 -3
  263. package/src/router/core/resolve/interface.js +0 -10
  264. package/src/router/core/router.js +0 -203
  265. package/src/router/core/url/interface.js +0 -1
  266. package/src/router/core/view/interface.js +0 -1
  267. /package/src/router/{core/common → common}/glob.js +0 -0
  268. /package/src/router/{core/hooks → hooks}/ignoredTransition.js +0 -0
  269. /package/src/router/{core/hooks → hooks}/invalidTransition.js +0 -0
  270. /package/src/router/{core/hooks → hooks}/onEnterExitRetain.js +0 -0
  271. /package/src/router/{core/hooks → hooks}/url.js +0 -0
  272. /package/src/router/{core/params → params}/README.md +0 -0
  273. /package/src/router/{core/state → state}/README.md +0 -0
  274. /package/src/router/{adapter/stateFilters.js → stateFilters.js} +0 -0
  275. /package/src/router/{core/transition → transition}/interface.js +0 -0
  276. /package/src/router/{core/transition → transition}/transitionEventType.js +0 -0
  277. /package/src/{router/core/common → shared}/hof.js +0 -0
  278. /package/test/{ng → core}/cache-factor.spec.js +0 -0
  279. /package/test/{ng → core}/controller-provider.spec.js +0 -0
  280. /package/test/{ng → core}/cookie-reader.spec.js +0 -0
  281. /package/test/{ng → core}/document.spec.js +0 -0
  282. /package/test/{ng → core}/filter.spec.js +0 -0
  283. /package/test/{ng → core}/http-backend.spec.js +0 -0
  284. /package/test/{ng → core}/interpolate.spec.js +0 -0
  285. /package/test/{ng → core}/interval.spec.js +0 -0
  286. /package/test/{ng → core}/location.spec.js +0 -0
  287. /package/test/{ng → core}/q.spec.js +0 -0
  288. /package/test/{ng → core}/root-element.spec.js +0 -0
  289. /package/test/{ng → core}/sanitize-uri.spec.js +0 -0
  290. /package/test/{ng → core}/sce.spec.js +0 -0
  291. /package/test/{ng → core}/template-request.spec.js +0 -0
  292. /package/test/{ng → core}/timeout.spec.js +0 -0
  293. /package/test/{ng → core}/url-utils.spec.js +0 -0
  294. /package/{src/router/adapter/interface.js → types/router/injectables.d.ts} +0 -0
@@ -1,76 +1,176 @@
1
- import {
2
- $uiRouterProvider,
3
- getProviderFor,
4
- getStateProvider,
5
- router,
6
- runBlock,
7
- watchDigests,
8
- } from "./adapter/services";
9
- import { TemplateFactory } from "./adapter/templateFactory";
10
- import { trace } from "./core/common/trace";
11
- import { $ViewScrollProvider } from "./adapter/viewScroll";
12
- import { $IsStateFilter, $IncludedByStateFilter } from "./adapter/stateFilters";
13
- import {
14
- uiSrefActiveDirective,
15
- uiStateDirective,
16
- uiSrefDirective,
17
- } from "./adapter/directives/stateDirectives";
18
- import { uiView, $ViewDirectiveFill } from "./adapter/directives/viewDirective";
1
+ import { UrlMatcherFactory } from "./url/urlMatcherFactory";
2
+ import { UrlRouter } from "./url/urlRouter";
3
+ import { TransitionService } from "./transition/transitionService";
4
+ import { ViewService } from "./view/view";
5
+ import { StateRegistry } from "./state/stateRegistry";
6
+ import { StateService } from "./state/stateService";
7
+ import { UIRouterGlobals } from "./globals";
8
+ import { removeFrom } from "../shared/common";
9
+ import { isFunction } from "../shared/utils";
10
+ import { UrlService } from "./url/urlService";
11
+ import { trace } from "./common/trace";
19
12
 
20
- export function initRouter() {
21
- window.angular.module("ui.router.angular1", []);
22
- const mod_init = window.angular.module("ui.router.init", ["ng"]);
23
- const mod_util = window.angular.module("ui.router.util", ["ui.router.init"]);
24
- const mod_state = window.angular.module("ui.router.state", [
25
- "ui.router.util",
26
- "ui.router.angular1",
27
- ]);
13
+ /**
14
+ * Router id tracker
15
+ * @type {number}
16
+ */
17
+ let routerId = 0;
28
18
 
29
- const mod_main = window.angular.module("ui.router", [
30
- "ui.router.init",
31
- "ui.router.state",
32
- "ui.router.angular1",
33
- ]);
19
+ /**
20
+ * An instance of UI-Router.
21
+ * @class
22
+ *
23
+ * This object contains references to service APIs which define your application's routing behavior.
24
+ */
25
+ export class UIRouter {
26
+ /**
27
+ * Creates a new `UIRouter` object
28
+ *
29
+ * @param {import('./locationServices').Ng1LocationServices} locationService
30
+ */
31
+ constructor(locationService) {
32
+ /**
33
+ * @type {import('./locationServices').Ng1LocationServices}
34
+ */
35
+ this.locationService = locationService;
36
+ /** @type {number} */ this.$id = routerId++;
37
+ /** @type {boolean} */ this._disposed = false;
38
+ this._disposables = [];
39
+ /** Enable/disable tracing to the javascript console */
40
+ this.trace = trace;
41
+ /** Provides services related to ui-view synchronization */
42
+ this.viewService = new ViewService(this);
43
+ /** @type {UIRouterGlobals} An object that contains global router state, such as the current state and params */
44
+ this.globals = new UIRouterGlobals();
45
+ /** @type {TransitionService} A service that exposes global Transition Hooks */
46
+ this.transitionService = new TransitionService(this);
47
+ /**
48
+ * Deprecated for public use. Use [[urlService]] instead.
49
+ * @deprecated Use [[urlService]] instead
50
+ */
51
+ this.urlMatcherFactory = new UrlMatcherFactory(this);
52
+ /**
53
+ * Deprecated for public use. Use [[urlService]] instead.
54
+ * @deprecated Use [[urlService]] instead
55
+ */
56
+ this.urlRouter = new UrlRouter(this);
57
+ /** Provides services related to the URL */
58
+ this.urlService = new UrlService(this);
59
+ /** Provides a registry for states, and related registration services */
60
+ this.stateRegistry = new StateRegistry(this);
61
+ /** Provides services related to states */
62
+ this.stateService = new StateService(this);
63
+ /** @internal plugin instances are registered here */
64
+ this._plugins = {};
65
+ this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());
66
+ this.globals.$current = this.stateRegistry.root();
67
+ this.globals.current = this.globals.$current.self;
68
+ this.disposable(this.globals);
69
+ this.disposable(this.stateService);
70
+ this.disposable(this.stateRegistry);
71
+ this.disposable(this.transitionService);
72
+ this.disposable(this.urlService);
73
+ this.disposable(locationService);
74
+ }
34
75
 
35
- mod_init.provider("$uiRouter", $uiRouterProvider);
36
- mod_util.provider("$urlService", getProviderFor("urlService"));
37
- mod_util.provider("$urlMatcherFactory", [
38
- "$uiRouterProvider",
39
- function RouterProvide() {
40
- return router.urlMatcherFactory;
41
- },
42
- ]);
43
- mod_util.provider("$templateFactory", function () {
44
- return new TemplateFactory();
45
- });
46
- mod_state
47
- .provider("$stateRegistry", getProviderFor("stateRegistry"))
48
- .provider("$uiRouterGlobals", getProviderFor("globals"))
49
- .provider("$transitions", getProviderFor("transitionService"))
50
- .provider("$state", ["$uiRouterProvider", getStateProvider])
51
- .provider("$uiViewScroll", $ViewScrollProvider)
52
- .factory("$stateParams", [
53
- "$uiRouter",
54
- function StateParamse($uiRouter) {
55
- return $uiRouter.globals.params;
56
- },
57
- ])
58
- .filter("isState", $IsStateFilter)
59
- .filter("includedByState", $IncludedByStateFilter)
60
- .directive("uiSref", uiSrefDirective)
61
- .directive("uiSrefActive", uiSrefActiveDirective)
62
- .directive("uiSrefActiveEq", uiSrefActiveDirective)
63
- .directive("uiState", uiStateDirective)
64
- .directive("uiView", uiView)
65
- .directive("uiView", $ViewDirectiveFill);
66
- mod_main.factory("$view", function View() {
67
- return router.viewService;
68
- });
69
- mod_main.service("$trace", function Trace() {
70
- return trace;
71
- });
72
- mod_main.run(watchDigests);
73
- mod_util.run(["$urlMatcherFactory", function MatcherFac() {}]);
74
- mod_state.run(["$state", function State() {}]);
75
- mod_init.run(runBlock);
76
+ /**
77
+ * Registers an object to be notified when the router is disposed
78
+ * @param {Disposable} disposable
79
+ * @returns {void}
80
+ */
81
+ disposable(disposable) {
82
+ this._disposables.push(disposable);
83
+ }
84
+ /**
85
+ * Disposes this router instance
86
+ *
87
+ * When called, clears resources retained by the router by calling `dispose(this)` on all
88
+ * registered [[disposable]] objects.
89
+ *
90
+ * Or, if a `disposable` object is provided, calls `dispose(this)` on that object only.
91
+ *
92
+ * @internal
93
+ * @param disposable (optional) the disposable to dispose
94
+ */
95
+ dispose(disposable) {
96
+ if (disposable && isFunction(disposable.dispose)) {
97
+ disposable.dispose(this);
98
+ return undefined;
99
+ }
100
+ this._disposed = true;
101
+ this._disposables.slice().forEach((d) => {
102
+ try {
103
+ typeof d.dispose === "function" && d.dispose(this);
104
+ removeFrom(this._disposables, d);
105
+ } catch (ignored) {}
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Adds a plugin to UI-Router
111
+ *
112
+ * This method adds a UI-Router Plugin.
113
+ * A plugin can enhance or change UI-Router behavior using any public API.
114
+ *
115
+ * #### Example:
116
+ * ```js
117
+ * import { MyCoolPlugin } from "ui-router-cool-plugin";
118
+ *
119
+ * var plugin = router.addPlugin(MyCoolPlugin);
120
+ * ```
121
+ *
122
+ * ### Plugin authoring
123
+ *
124
+ * A plugin is simply a class (or constructor function) which accepts a [[UIRouter]] instance and (optionally) an options object.
125
+ *
126
+ * The plugin can implement its functionality using any of the public APIs of [[UIRouter]].
127
+ * For example, it may configure router options or add a Transition Hook.
128
+ *
129
+ * The plugin can then be published as a separate module.
130
+ *
131
+ * #### Example:
132
+ * ```js
133
+ * export class MyAuthPlugin implements UIRouterPlugin {
134
+ * constructor(router: UIRouter, options: any) {
135
+ * this.name = "MyAuthPlugin";
136
+ * let $transitions = router.transitionService;
137
+ * let $state = router.stateService;
138
+ *
139
+ * let authCriteria = {
140
+ * to: (state) => state.data && state.data.requiresAuth
141
+ * };
142
+ *
143
+ * function authHook(transition: Transition) {
144
+ * let authService = transition.injector().get('AuthService');
145
+ * if (!authService.isAuthenticated()) {
146
+ * return $state.target('login');
147
+ * }
148
+ * }
149
+ *
150
+ * $transitions.onStart(authCriteria, authHook);
151
+ * }
152
+ * }
153
+ * ```
154
+ *
155
+ * @param plugin one of:
156
+ * - a plugin class which implements [[UIRouterPlugin]]
157
+ * - a constructor function for a [[UIRouterPlugin]] which accepts a [[UIRouter]] instance
158
+ * - a factory function which accepts a [[UIRouter]] instance and returns a [[UIRouterPlugin]] instance
159
+ * @param options options to pass to the plugin class/factory
160
+ * @returns the registered plugin instance
161
+ */
162
+ plugin(plugin, options = {}) {
163
+ const pluginInstance = new plugin(this, options);
164
+ if (!pluginInstance.name)
165
+ throw new Error(
166
+ "Required property `name` missing on plugin: " + pluginInstance,
167
+ );
168
+ this._disposables.push(pluginInstance);
169
+ return (this._plugins[pluginInstance.name] = pluginInstance);
170
+ }
171
+ getPlugin(pluginName) {
172
+ return pluginName
173
+ ? this._plugins[pluginName]
174
+ : Object.values(this._plugins);
175
+ }
76
176
  }
@@ -8,26 +8,24 @@
8
8
  *
9
9
  * @preferred @publicapi @module ng1
10
10
  */
11
- import { services } from "../core/common/coreservices";
12
- import { applyPairs, unnestR } from "../core/common/common";
13
- import { isString } from "../../core/utils";
14
- import { trace } from "../core/common/trace";
15
- import { UIRouter } from "../core/router";
16
- import {
17
- ng1ViewsBuilder,
18
- getNg1ViewConfigFactory,
19
- } from "./statebuilders/views";
11
+ import { services } from "./common/coreservices";
12
+ import { applyPairs, unnestR } from "../shared/common";
13
+ import { isString } from "../shared/utils";
14
+ import { trace } from "./common/trace";
15
+ import { UIRouter } from "./router";
16
+ import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "./state/views";
20
17
 
21
18
  import { StateProvider } from "./stateProvider";
22
- import { getStateHookBuilder } from "./statebuilders/onEnterExitRetain";
23
19
  import { Ng1LocationServices } from "./locationServices";
20
+ import { ResolveContext } from "./resolve/resolveContext";
24
21
 
25
22
  export let router = null;
26
- $uiRouterProvider.$inject = ["$locationProvider"];
23
+ $routerProvider.$inject = ["$locationProvider"];
27
24
  /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
28
- export function $uiRouterProvider($locationProvider) {
29
- // Create a new instance of the Router when the $uiRouterProvider is initialized
30
- router = this.router = new UIRouter();
25
+ export function $routerProvider($locationProvider) {
26
+ const ng1LocationService = new Ng1LocationServices($locationProvider);
27
+ // Create a new instance of the Router when the $routerProvider is initialized
28
+ router = this.router = new UIRouter(ng1LocationService);
31
29
  router.stateProvider = new StateProvider(
32
30
  router.stateRegistry,
33
31
  router.stateService,
@@ -43,47 +41,42 @@ export function $uiRouterProvider($locationProvider) {
43
41
  );
44
42
  // Disable decoding of params by UrlMatcherFactory because $location already handles this
45
43
  router.urlService.config._decodeParams = false;
46
- const ng1LocationService =
47
- (router.locationService =
48
- router.locationConfig =
49
- new Ng1LocationServices($locationProvider));
44
+
50
45
  Ng1LocationServices.monkeyPatchPathParameterType(router);
51
- // backwards compat: also expose router instance as $uiRouterProvider.router
46
+ // backwards compat: also expose router instance as $routerProvider.router
52
47
  router["router"] = router;
53
48
  router["$get"] = $get;
54
49
  $get.$inject = ["$location", "$browser", "$rootScope"];
55
50
  function $get($location, $browser, $rootScope) {
56
51
  ng1LocationService._runtimeServices($rootScope, $location, $browser);
57
- delete router["router"];
58
- delete router["$get"];
59
52
  return router;
60
53
  }
61
54
  return router;
62
55
  }
63
56
  export const getProviderFor = (serviceName) => [
64
- "$uiRouterProvider",
57
+ "$routerProvider",
65
58
  function UrlServiceProvider($urp) {
66
59
  const service = $urp.router[serviceName];
67
60
  service["$get"] = () => service;
68
61
  return service;
69
62
  },
70
63
  ];
71
- // This effectively calls $get() on `$uiRouterProvider` to trigger init (when ng enters runtime)
72
- runBlock.$inject = ["$injector", "$q", "$uiRouter"];
73
- export function runBlock($injector, $q, $uiRouter) {
64
+ // This effectively calls $get() on `$routerProvider` to trigger init (when ng enters runtime)
65
+ runBlock.$inject = ["$injector", "$q", "$router"];
66
+ export function runBlock($injector, $q, $router) {
74
67
  services.$injector = $injector;
75
68
  services.$q = $q;
76
69
  // https://github.com/angular-ui/ui-router/issues/3678
77
70
  if (!Object.prototype.hasOwnProperty.call($injector, "strictDi")) {
78
71
  try {
79
- $injector.invoke(function (checkStrictDi) {});
72
+ $injector.invoke(() => {});
80
73
  } catch (error) {
81
74
  $injector.strictDi = !!/strict mode/.exec(error && error.toString());
82
75
  }
83
76
  }
84
77
  // The $injector is now available.
85
78
  // Find any resolvables that had dependency annotation deferred
86
- $uiRouter.stateRegistry
79
+ $router.stateRegistry
87
80
  .get()
88
81
  .map((x) => x.$$state().resolvables)
89
82
  .reduce(unnestR, [])
@@ -95,6 +88,8 @@ export function runBlock($injector, $q, $uiRouter) {
95
88
  $injector.strictDi,
96
89
  )),
97
90
  );
91
+ // TODO: Is this the best place for this?
92
+ $router.urlService.listen();
98
93
  }
99
94
 
100
95
  // $state service and $stateProvider
@@ -125,3 +120,28 @@ export const getLocals = (ctx) => {
125
120
  });
126
121
  return tuples.reduce(applyPairs, {});
127
122
  };
123
+
124
+ /**
125
+ * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
126
+ * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
127
+ *
128
+ * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder
129
+ * ensures that those hooks are injectable for @uirouter/angularjs (ng1).
130
+ *
131
+ * @internalapi
132
+ */
133
+ const getStateHookBuilder = (hookName) =>
134
+ function stateHookBuilder(stateObject) {
135
+ const hook = stateObject[hookName];
136
+ const pathname = hookName === "onExit" ? "from" : "to";
137
+ function decoratedNg1Hook(trans, state) {
138
+ const resolveContext = new ResolveContext(trans.treeChanges(pathname));
139
+ const subContext = resolveContext.subContext(state.$$state());
140
+ const locals = Object.assign(getLocals(subContext), {
141
+ $state$: state,
142
+ $transition$: trans,
143
+ });
144
+ return services.$injector.invoke(hook, this, locals);
145
+ }
146
+ return hook ? decoratedNg1Hook : undefined;
147
+ };
@@ -3,14 +3,13 @@ import {
3
3
  identity,
4
4
  inherit,
5
5
  mapObj,
6
- noop,
7
6
  omit,
8
7
  tail,
9
8
  copy,
10
- } from "../common/common";
11
- import { isArray, isDefined, isFunction, isString } from "../common/predicates";
12
- import { stringify } from "../common/strings";
13
- import { is, pattern, pipe, prop, val } from "../common/hof";
9
+ } from "../../shared/common";
10
+ import { isDefined, isFunction, isString } from "../../shared/utils";
11
+ import { stringify } from "../../shared/strings";
12
+ import { is, pattern, pipe, prop, val } from "../../shared/hof";
14
13
  import { Resolvable } from "../resolve/resolvable";
15
14
  import { services } from "../common/coreservices";
16
15
  const parseUrl = (url) => {
@@ -85,7 +84,11 @@ const getParamsBuilder = (paramFactory) =>
85
84
  .reduce(applyPairs, {});
86
85
  };
87
86
  function pathBuilder(state) {
88
- return state.parent ? state.parent.path.concat(state) : /*root*/ [state];
87
+ if (state.parent && !state.abstract) {
88
+ return state.parent.path.concat(state);
89
+ } else {
90
+ return [state];
91
+ }
89
92
  }
90
93
  function includesBuilder(state) {
91
94
  const includes = state.parent ? Object.assign({}, state.parent.includes) : {};
@@ -167,7 +170,7 @@ export function resolvablesBuilder(state) {
167
170
  !!(
168
171
  obj &&
169
172
  obj.val &&
170
- (isString(obj.val) || isArray(obj.val) || isFunction(obj.val))
173
+ (isString(obj.val) || Array.isArray(obj.val) || isFunction(obj.val))
171
174
  );
172
175
  /** extracts the token from a Provider or provide literal */
173
176
  const getToken = (p) => p.provide || p.token;
@@ -204,7 +207,7 @@ export function resolvablesBuilder(state) {
204
207
  // prettier-ignore
205
208
  const tuple2Resolvable = pattern([
206
209
  [pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, identity, [tuple.val], tuple.policy)],
207
- [pipe(prop('val'), isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
210
+ [pipe(prop('val'), Array.isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
208
211
  [pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy)],
209
212
  ]);
210
213
  // prettier-ignore
@@ -218,7 +221,7 @@ export function resolvablesBuilder(state) {
218
221
  // If resolveBlock is already an array, use it as-is.
219
222
  // Otherwise, assume it's an object and convert to an Array of tuples
220
223
  const decl = state.resolve;
221
- const items = isArray(decl)
224
+ const items = Array.isArray(decl)
222
225
  ? decl
223
226
  : objects2Tuples(decl, state.resolvePolicy || {});
224
227
  return items.map(item2Resolvable);
@@ -293,12 +296,13 @@ export class StateBuilder {
293
296
  if (!Object.prototype.hasOwnProperty.call(builders, key)) continue;
294
297
  const chain = builders[key].reduce(
295
298
  (parentFn, step) => (_state) => step(_state, parentFn),
296
- noop,
299
+ () => {},
297
300
  );
298
301
  state[key] = chain(state);
299
302
  }
300
303
  return state;
301
304
  }
305
+
302
306
  parentName(state) {
303
307
  // name = 'foo.bar.baz.**'
304
308
  const name = state.name || "";
@@ -1,5 +1,4 @@
1
- import { isString } from "../common/predicates";
2
- import { safeConsole } from "../common/safeConsole";
1
+ import { isString } from "../../shared/utils";
3
2
  export class StateMatcher {
4
3
  constructor(_states) {
5
4
  this._states = _states;
@@ -28,7 +27,7 @@ export class StateMatcher {
28
27
  _state.__stateObjectCache.nameGlob.matches(name),
29
28
  );
30
29
  if (matches.length > 1) {
31
- safeConsole.error(
30
+ console.error(
32
31
  `stateMatcher.find: Found multiple matches for ${name} using glob: `,
33
32
  matches.map((match) => match.name),
34
33
  );
@@ -1,7 +1,7 @@
1
- import { defaults, find } from "../common/common";
2
- import { propEq } from "../common/hof";
1
+ import { defaults, find } from "../../shared/common";
2
+ import { propEq } from "../../shared/hof";
3
3
  import { Glob } from "../common/glob";
4
- import { isObject, isFunction } from "../common/predicates";
4
+ import { isFunction, isObject } from "../../shared/utils";
5
5
  /**
6
6
  * Internal representation of a UI-Router state.
7
7
  *
@@ -22,10 +22,12 @@ export class StateObject {
22
22
  * @returns {StateObject} an internal State object
23
23
  */
24
24
  static create(stateDecl) {
25
- stateDecl = StateObject.isStateClass(stateDecl)
25
+ const state = StateObject.isStateClass(stateDecl)
26
26
  ? new stateDecl()
27
- : stateDecl;
28
- const state = Object.setPrototypeOf(stateDecl, StateObject.prototype);
27
+ : Object.setPrototypeOf(
28
+ Object.assign({}, stateDecl),
29
+ StateObject.prototype,
30
+ );
29
31
  stateDecl.$$state = () => state;
30
32
  state.self = stateDecl;
31
33
  state.__stateObjectCache = {
@@ -1,6 +1,6 @@
1
- import { inArray } from "../common/common";
2
- import { prop } from "../common/hof";
3
- import { isString } from "../common/predicates";
1
+ import { inArray } from "../../shared/common";
2
+ import { prop } from "../../shared/hof";
3
+ import { isString } from "../../shared/utils";
4
4
  import { StateObject } from "./stateObject";
5
5
  export class StateQueueManager {
6
6
  constructor(router, states, builder, listeners) {
@@ -1,19 +1,18 @@
1
1
  import { StateMatcher } from "./stateMatcher";
2
2
  import { StateBuilder } from "./stateBuilder";
3
3
  import { StateQueueManager } from "./stateQueueManager";
4
- import { removeFrom } from "../common/common";
5
- import { propEq } from "../common/hof";
4
+ import { removeFrom } from "../../shared/common";
5
+ import { propEq } from "../../shared/hof";
6
6
  /**
7
7
  * A registry for all of the application's [[StateDeclaration]]s
8
8
  *
9
9
  * This API is found at `router.stateRegistry` ([[UIRouter.stateRegistry]])
10
10
  */
11
11
  export class StateRegistry {
12
- /** @internal */
13
12
  constructor(router) {
14
13
  this.router = router;
15
14
  this.states = {};
16
- /** @internal */
15
+
17
16
  this.listeners = [];
18
17
  this.matcher = new StateMatcher(this.states);
19
18
  this.builder = new StateBuilder(this.matcher, router.urlMatcherFactory);
@@ -25,7 +24,7 @@ export class StateRegistry {
25
24
  );
26
25
  this._registerRoot();
27
26
  }
28
- /** @internal */
27
+
29
28
  _registerRoot() {
30
29
  const rootStateDef = {
31
30
  name: "",
@@ -39,7 +38,7 @@ export class StateRegistry {
39
38
  const _root = (this._root = this.stateQueue.register(rootStateDef));
40
39
  _root.navigable = null;
41
40
  }
42
- /** @internal */
41
+
43
42
  dispose() {
44
43
  this.stateQueue.dispose();
45
44
  this.listeners = [];
@@ -108,7 +107,7 @@ export class StateRegistry {
108
107
  register(stateDefinition) {
109
108
  return this.stateQueue.register(stateDefinition);
110
109
  }
111
- /** @internal */
110
+
112
111
  _deregisterTree(state) {
113
112
  const all = this.get().map((s) => s.$$state());
114
113
  const getChildren = (states) => {
@@ -6,8 +6,8 @@ import {
6
6
  removeFrom,
7
7
  silenceUncaughtInPromise,
8
8
  silentRejection,
9
- } from "../common/common";
10
- import { isDefined, isObject, isString } from "../common/predicates";
9
+ } from "../../shared/common";
10
+ import { isDefined, isObject, isString } from "../../shared/utils";
11
11
  import { Queue } from "../common/queue";
12
12
  import { services } from "../common/coreservices";
13
13
  import { PathUtils } from "../path/pathUtils";
@@ -19,7 +19,7 @@ import { Param } from "../params/param";
19
19
  import { Glob } from "../common/glob";
20
20
  import { ResolveContext } from "../resolve/resolveContext";
21
21
  import { lazyLoadState } from "../hooks/lazyLoad";
22
- import { not, val } from "../common/hof";
22
+ import { not, val } from "../../shared/hof";
23
23
  /**
24
24
  * Provides services related to ui-router states.
25
25
  *
@@ -58,22 +58,19 @@ export class StateService {
58
58
  get $current() {
59
59
  return this.router.globals.$current;
60
60
  }
61
- /** @internal */
62
- constructor(/** @internal */ router) {
61
+
62
+ constructor(router) {
63
63
  this.router = router;
64
- /** @internal */
64
+
65
65
  this.invalidCallbacks = [];
66
- /** @internal */
66
+
67
67
  this._defaultErrorHandler = function $defaultErrorHandler($error$) {
68
68
  if ($error$ instanceof Error && $error$.stack) {
69
- console.error($error$);
70
- console.error($error$.stack);
69
+ throw $error$;
71
70
  } else if ($error$ instanceof Rejection) {
72
- console.error($error$.toString());
73
- if ($error$.detail && $error$.detail.stack)
74
- console.error($error$.detail.stack);
71
+ throw new Error($error$.toString());
75
72
  } else {
76
- console.error($error$);
73
+ throw new Error($error$);
77
74
  }
78
75
  };
79
76
  const getters = ["current", "$current", "params", "transition"];
@@ -87,7 +84,7 @@ export class StateService {
87
84
  boundFns,
88
85
  );
89
86
  }
90
- /** @internal */
87
+
91
88
  dispose() {
92
89
  this.defaultErrorHandler(noop);
93
90
  this.invalidCallbacks = [];
@@ -302,7 +299,7 @@ export class StateService {
302
299
  options,
303
300
  );
304
301
  }
305
- /** @internal */
302
+
306
303
  getCurrentPath() {
307
304
  const globals = this.router.globals;
308
305
  const latestSuccess = globals.successfulTransitions.peekTail();
@@ -1,5 +1,5 @@
1
- import { isObject, isString } from "../common/predicates";
2
- import { stringify } from "../common/strings";
1
+ import { isObject, isString } from "../../shared/utils";
2
+ import { stringify } from "../../shared/strings";
3
3
  /**
4
4
  * Encapsulate the target (destination) state/params/options of a [[Transition]].
5
5
  *