@angular-wave/angular.ts 0.0.21 → 0.0.22

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 (122) hide show
  1. package/Makefile +1 -1
  2. package/TODO.md +14 -0
  3. package/dist/angular-ts.esm.js +1 -1
  4. package/dist/angular-ts.umd.js +1 -1
  5. package/index.html +2 -0
  6. package/package.json +1 -1
  7. package/src/animations/animate-css-driver.js +2 -2
  8. package/src/animations/animate-css.js +15 -6
  9. package/src/animations/animate-js.js +1 -1
  10. package/src/animations/animate-queue.js +1 -1
  11. package/src/animations/shared.js +0 -14
  12. package/src/core/compile.js +6 -3
  13. package/src/directive/if.js +0 -79
  14. package/src/directive/if.md +80 -0
  15. package/src/directive/include.js +0 -82
  16. package/src/directive/include.md +86 -0
  17. package/src/directive/repeat.js +0 -1
  18. package/src/loader.js +0 -1
  19. package/src/router/common/trace.js +1 -1
  20. package/src/router/directives/stateDirectives.js +16 -14
  21. package/src/router/directives/viewDirective.js +2 -2
  22. package/src/router/hooks/resolve.js +3 -4
  23. package/src/router/hooks/views.js +3 -2
  24. package/src/router/state/stateService.js +1 -2
  25. package/src/router/transition/interface.js +14 -14
  26. package/src/router/transition/rejectFactory.js +29 -20
  27. package/src/router/transition/transitionHook.js +5 -5
  28. package/src/router/url/urlMatcher.js +1 -2
  29. package/src/router/url/urlRule.js +1 -1
  30. package/src/router/url/urlRules.js +1 -1
  31. package/src/shared/common.js +0 -1
  32. package/test/module-test.html +44 -12
  33. package/test/router/services.spec.js +71 -0
  34. package/test/router/state-directives.spec.js +1208 -0
  35. package/types/angular.d.ts +132 -124
  36. package/types/index.d.ts +2350 -2187
  37. package/types/jqlite.d.ts +463 -418
  38. package/types/router/core/common/common.d.ts +70 -24
  39. package/types/router/core/common/coreservices.d.ts +30 -32
  40. package/types/router/core/common/glob.d.ts +9 -9
  41. package/types/router/core/common/hof.d.ts +12 -4
  42. package/types/router/core/common/index.d.ts +8 -8
  43. package/types/router/core/common/predicates.d.ts +1 -1
  44. package/types/router/core/common/queue.d.ts +13 -13
  45. package/types/router/core/common/safeConsole.d.ts +3 -3
  46. package/types/router/core/common/strings.d.ts +4 -2
  47. package/types/router/core/common/trace.d.ts +94 -82
  48. package/types/router/core/globals.d.ts +37 -37
  49. package/types/router/core/hooks/coreResolvables.d.ts +5 -3
  50. package/types/router/core/hooks/ignoredTransition.d.ts +4 -2
  51. package/types/router/core/hooks/invalidTransition.d.ts +4 -2
  52. package/types/router/core/hooks/lazyLoad.d.ts +10 -5
  53. package/types/router/core/hooks/onEnterExitRetain.d.ts +10 -4
  54. package/types/router/core/hooks/redirectTo.d.ts +4 -2
  55. package/types/router/core/hooks/resolve.d.ts +10 -4
  56. package/types/router/core/hooks/updateGlobals.d.ts +4 -2
  57. package/types/router/core/hooks/url.d.ts +4 -2
  58. package/types/router/core/hooks/views.d.ts +7 -3
  59. package/types/router/core/index.d.ts +11 -12
  60. package/types/router/core/interface.d.ts +83 -81
  61. package/types/router/core/params/index.d.ts +5 -5
  62. package/types/router/core/params/interface.d.ts +439 -439
  63. package/types/router/core/params/param.d.ts +72 -60
  64. package/types/router/core/params/paramType.d.ts +40 -40
  65. package/types/router/core/params/paramTypes.d.ts +169 -165
  66. package/types/router/core/params/stateParams.d.ts +13 -13
  67. package/types/router/core/path/index.d.ts +2 -2
  68. package/types/router/core/path/pathNode.d.ts +49 -49
  69. package/types/router/core/path/pathUtils.d.ts +100 -74
  70. package/types/router/core/resolve/index.d.ts +3 -3
  71. package/types/router/core/resolve/interface.d.ts +137 -137
  72. package/types/router/core/resolve/resolvable.d.ts +60 -54
  73. package/types/router/core/resolve/resolveContext.d.ts +84 -79
  74. package/types/router/core/router.d.ts +95 -86
  75. package/types/router/core/state/index.d.ts +8 -8
  76. package/types/router/core/state/interface.d.ts +667 -643
  77. package/types/router/core/state/stateBuilder.d.ts +41 -38
  78. package/types/router/core/state/stateMatcher.d.ts +11 -9
  79. package/types/router/core/state/stateObject.d.ts +154 -139
  80. package/types/router/core/state/stateQueueManager.d.ts +26 -21
  81. package/types/router/core/state/stateRegistry.d.ts +124 -121
  82. package/types/router/core/state/stateService.d.ts +380 -343
  83. package/types/router/core/state/targetState.d.ts +74 -69
  84. package/types/router/core/transition/hookBuilder.d.ts +34 -30
  85. package/types/router/core/transition/hookRegistry.d.ts +96 -74
  86. package/types/router/core/transition/index.d.ts +8 -8
  87. package/types/router/core/transition/interface.d.ts +652 -609
  88. package/types/router/core/transition/rejectFactory.d.ts +97 -97
  89. package/types/router/core/transition/transition.d.ts +565 -517
  90. package/types/router/core/transition/transitionEventType.d.ts +20 -11
  91. package/types/router/core/transition/transitionHook.d.ts +90 -82
  92. package/types/router/core/transition/transitionService.d.ts +228 -161
  93. package/types/router/core/url/index.d.ts +8 -8
  94. package/types/router/core/url/interface.d.ts +100 -87
  95. package/types/router/core/url/urlConfig.d.ts +130 -126
  96. package/types/router/core/url/urlMatcher.d.ts +132 -127
  97. package/types/router/core/url/urlMatcherFactory.d.ts +46 -42
  98. package/types/router/core/url/urlRouter.d.ts +91 -75
  99. package/types/router/core/url/urlRule.d.ts +123 -100
  100. package/types/router/core/url/urlRules.d.ts +240 -232
  101. package/types/router/core/url/urlService.d.ts +201 -201
  102. package/types/router/core/view/index.d.ts +2 -2
  103. package/types/router/core/view/interface.d.ts +26 -26
  104. package/types/router/core/view/view.d.ts +152 -143
  105. package/types/router/directives/viewDirective.d.ts +12 -11
  106. package/types/router/index.d.ts +11 -12
  107. package/types/router/interface.d.ts +361 -351
  108. package/types/router/legacy/resolveService.d.ts +44 -40
  109. package/types/router/legacy/stateEvents.d.ts +1 -1
  110. package/types/router/locationServices.d.ts +45 -37
  111. package/types/router/services.d.ts +9 -9
  112. package/types/router/stateFilters.d.ts +3 -3
  113. package/types/router/stateProvider.d.ts +240 -235
  114. package/types/router/statebuilders/onEnterExitRetain.d.ts +4 -2
  115. package/types/router/statebuilders/views.d.ts +35 -22
  116. package/types/router/templateFactory.d.ts +99 -79
  117. package/types/router/viewScroll.d.ts +7 -7
  118. package/src/directive/a.js +0 -37
  119. package/types/router/angular.d.ts +0 -1
  120. package/types/router/core/vanilla.d.ts +0 -1
  121. package/types/router/directives/stateDirectives.d.ts +0 -3
  122. package/types/router/injectables.d.ts +0 -1
@@ -1,4 +1,3 @@
1
- import { noop } from "../../shared/common";
2
1
  import { ResolveContext } from "../resolve/resolveContext";
3
2
  import { val } from "../../shared/hof";
4
3
  export const RESOLVE_HOOK_PRIORITY = 1000;
@@ -14,7 +13,7 @@ export const RESOLVE_HOOK_PRIORITY = 1000;
14
13
  const eagerResolvePath = (trans) =>
15
14
  new ResolveContext(trans.treeChanges().to)
16
15
  .resolvePath("EAGER", trans)
17
- .then(noop);
16
+ .then(() => {});
18
17
  export const registerEagerResolvePath = (transitionService) =>
19
18
  transitionService.onStart({}, eagerResolvePath, {
20
19
  priority: RESOLVE_HOOK_PRIORITY,
@@ -32,7 +31,7 @@ const lazyResolveState = (trans, state) =>
32
31
  new ResolveContext(trans.treeChanges().to)
33
32
  .subContext(state.$$state())
34
33
  .resolvePath("LAZY", trans)
35
- .then(noop);
34
+ .then(() => {});
36
35
  export const registerLazyResolveState = (transitionService) =>
37
36
  transitionService.onEnter({ entering: val(true) }, lazyResolveState, {
38
37
  priority: RESOLVE_HOOK_PRIORITY,
@@ -50,7 +49,7 @@ export const registerLazyResolveState = (transitionService) =>
50
49
  const resolveRemaining = (trans) =>
51
50
  new ResolveContext(trans.treeChanges().to)
52
51
  .resolvePath("LAZY", trans)
53
- .then(noop);
52
+ .then(() => {});
54
53
  export const registerResolveRemaining = (transitionService) =>
55
54
  transitionService.onFinish({}, resolveRemaining, {
56
55
  priority: RESOLVE_HOOK_PRIORITY,
@@ -1,4 +1,3 @@
1
- import { noop } from "../../shared/common";
2
1
  import { services } from "../common/coreservices";
3
2
  /**
4
3
  * A [[TransitionHookFn]] which waits for the views to load
@@ -12,7 +11,9 @@ const loadEnteringViews = (transition) => {
12
11
  const $q = services.$q;
13
12
  const enteringViews = transition.views("entering");
14
13
  if (!enteringViews.length) return;
15
- return $q.all(enteringViews.map((view) => $q.when(view.load()))).then(noop);
14
+ return $q
15
+ .all(enteringViews.map((view) => $q.when(view.load())))
16
+ .then(() => {});
16
17
  };
17
18
  export const registerLoadEnteringViews = (transitionService) =>
18
19
  transitionService.onFinish({}, loadEnteringViews);
@@ -2,7 +2,6 @@ import {
2
2
  createProxyFunctions,
3
3
  defaults,
4
4
  inArray,
5
- noop,
6
5
  removeFrom,
7
6
  silenceUncaughtInPromise,
8
7
  silentRejection,
@@ -86,7 +85,7 @@ export class StateService {
86
85
  }
87
86
 
88
87
  dispose() {
89
- this.defaultErrorHandler(noop);
88
+ this.defaultErrorHandler(() => {});
90
89
  this.invalidCallbacks = [];
91
90
  }
92
91
  /**
@@ -1,14 +1,14 @@
1
- var TransitionHookPhase;
2
- (function (TransitionHookPhase) {
3
- TransitionHookPhase[(TransitionHookPhase["CREATE"] = 0)] = "CREATE";
4
- TransitionHookPhase[(TransitionHookPhase["BEFORE"] = 1)] = "BEFORE";
5
- TransitionHookPhase[(TransitionHookPhase["RUN"] = 2)] = "RUN";
6
- TransitionHookPhase[(TransitionHookPhase["SUCCESS"] = 3)] = "SUCCESS";
7
- TransitionHookPhase[(TransitionHookPhase["ERROR"] = 4)] = "ERROR";
8
- })(TransitionHookPhase || (TransitionHookPhase = {}));
9
- var TransitionHookScope;
10
- (function (TransitionHookScope) {
11
- TransitionHookScope[(TransitionHookScope["TRANSITION"] = 0)] = "TRANSITION";
12
- TransitionHookScope[(TransitionHookScope["STATE"] = 1)] = "STATE";
13
- })(TransitionHookScope || (TransitionHookScope = {}));
14
- export { TransitionHookPhase, TransitionHookScope };
1
+ /** An object for Transition Hook Phases */
2
+ export const TransitionHookPhase = {
3
+ CREATE: 0,
4
+ BEFORE: 1,
5
+ RUN: 2,
6
+ SUCCESS: 3,
7
+ ERROR: 4,
8
+ };
9
+
10
+ /** An object for Transition Hook Scopes */
11
+ export const TransitionHookScope = {
12
+ TRANSITION: 0,
13
+ STATE: 1,
14
+ };
@@ -1,47 +1,56 @@
1
1
  import { silentRejection } from "../../shared/common";
2
2
  import { stringify } from "../../shared/strings";
3
3
  import { is } from "../../shared/hof";
4
- /** An enum for Transition Rejection reasons */
5
- var RejectType;
6
- (function (RejectType) {
4
+
5
+ /**
6
+ * An object for Transition Rejection reasons.
7
+ * @enum {number}
8
+ */
9
+ export const RejectType = {
7
10
  /**
8
11
  * A new transition superseded this one.
9
12
  *
10
13
  * While this transition was running, a new transition started.
11
- * This transition is cancelled because it was superseded by new transition.
14
+ * This transition is cancelled because it was superseded by a new transition.
15
+ * @type {number}
12
16
  */
13
- RejectType[(RejectType["SUPERSEDED"] = 2)] = "SUPERSEDED";
17
+ SUPERSEDED: 2,
18
+
14
19
  /**
15
- * The transition was aborted
20
+ * The transition was aborted.
16
21
  *
17
- * The transition was aborted by a hook which returned `false`
22
+ * The transition was aborted by a hook which returned `false`.
23
+ * @type {number}
18
24
  */
19
- RejectType[(RejectType["ABORTED"] = 3)] = "ABORTED";
25
+ ABORTED: 3,
26
+
20
27
  /**
21
- * The transition was invalid
28
+ * The transition was invalid.
22
29
  *
23
- * The transition was never started because it was invalid
30
+ * The transition was never started because it was invalid.
31
+ * @type {number}
24
32
  */
25
- RejectType[(RejectType["INVALID"] = 4)] = "INVALID";
33
+ INVALID: 4,
34
+
26
35
  /**
27
- * The transition was ignored
36
+ * The transition was ignored.
28
37
  *
29
38
  * The transition was ignored because it would have no effect.
30
- *
31
39
  * Either:
32
- *
33
- * - The transition is targeting the current state and parameter values
40
+ * - The transition is targeting the current state and parameter values.
34
41
  * - The transition is targeting the same state and parameter values as the currently running transition.
42
+ * @type {number}
35
43
  */
36
- RejectType[(RejectType["IGNORED"] = 5)] = "IGNORED";
44
+ IGNORED: 5,
45
+
37
46
  /**
38
47
  * The transition errored.
39
48
  *
40
- * This generally means a hook threw an error or returned a rejected promise
49
+ * This generally means a hook threw an error or returned a rejected promise.
50
+ * @type {number}
41
51
  */
42
- RejectType[(RejectType["ERROR"] = 6)] = "ERROR";
43
- })(RejectType || (RejectType = {}));
44
- export { RejectType };
52
+ ERROR: 6,
53
+ };
45
54
 
46
55
  let id = 0;
47
56
  export class Rejection {
@@ -1,5 +1,5 @@
1
1
  import { TransitionHookPhase } from "./interface";
2
- import { defaults, noop, silentRejection } from "../../shared/common";
2
+ import { defaults, silentRejection } from "../../shared/common";
3
3
  import { fnToString, maxLength } from "../../shared/strings";
4
4
  import { isPromise } from "../../shared/predicates";
5
5
  import { is, parse } from "../../shared/hof";
@@ -8,7 +8,7 @@ import { services } from "../common/coreservices";
8
8
  import { Rejection } from "./rejectFactory";
9
9
  import { TargetState } from "../state/targetState";
10
10
  const defaultOptions = {
11
- current: noop,
11
+ current: () => {},
12
12
  transition: null,
13
13
  traceData: {},
14
14
  bind: null,
@@ -127,7 +127,7 @@ export class TransitionHook {
127
127
  // Wait for the promise, then reprocess with the resulting value
128
128
  return result.then((val) => this.handleHookResult(val));
129
129
  }
130
- trace.traceHookResult(result, this.transition, this.options);
130
+ trace.traceHookResult(result, this.transition);
131
131
  // Hook returned false
132
132
  if (result === false) {
133
133
  // Abort this Transition
@@ -193,7 +193,7 @@ TransitionHook.LOG_REJECTED_RESULT = (hook) => (result) => {
193
193
  * Each HookType chooses a GetErrorHandler (See: [[TransitionService._defineCoreEvents]])
194
194
  */
195
195
  TransitionHook.LOG_ERROR = (hook) => (error) => hook.logError(error);
196
- TransitionHook.REJECT_ERROR = (hook) => (error) => silentRejection(error);
197
- TransitionHook.THROW_ERROR = (hook) => (error) => {
196
+ TransitionHook.REJECT_ERROR = () => (error) => silentRejection(error);
197
+ TransitionHook.THROW_ERROR = () => (error) => {
198
198
  throw error;
199
199
  };
@@ -347,11 +347,10 @@ export class UrlMatcher {
347
347
  * @param path The URL path to match, e.g. `$location.path()`.
348
348
  * @param search URL search parameters, e.g. `$location.search()`.
349
349
  * @param hash URL hash e.g. `$location.hash()`.
350
- * @param options
351
350
  *
352
351
  * @returns The captured parameter values.
353
352
  */
354
- exec(path, search = {}, hash, options = {}) {
353
+ exec(path, search = {}, hash) {
355
354
  const match = memoizeTo(this._cache, "pattern", () => {
356
355
  return new RegExp(
357
356
  [
@@ -199,7 +199,7 @@ export class BaseUrlRule {
199
199
  constructor(match, handler) {
200
200
  this.match = match;
201
201
  this.type = "RAW";
202
- this.matchPriority = (match) => 0 - this.$id;
202
+ this.matchPriority = () => 0 - this.$id;
203
203
  this.handler = handler || identity;
204
204
  }
205
205
  }
@@ -73,7 +73,7 @@ export class UrlRules {
73
73
  this.urlRuleFactory = new UrlRuleFactory(router);
74
74
  }
75
75
 
76
- dispose(router) {
76
+ dispose() {
77
77
  this._rules = [];
78
78
  delete this._otherwiseFn;
79
79
  }
@@ -20,7 +20,6 @@ export const equals = _equals;
20
20
  export function identity(x) {
21
21
  return x;
22
22
  }
23
- export function noop() {}
24
23
  /**
25
24
  * Builds proxy functions on the `to` object which pass through to the `from` object.
26
25
  *
@@ -6,21 +6,53 @@
6
6
  <script>
7
7
  document.addEventListener("DOMContentLoaded", () => {
8
8
  var myApp = window.angular.module("test", ["ui.router"]);
9
- myApp.config(function ($stateProvider) {
10
- var helloState = {
11
- name: "hello",
12
- url: "/",
13
- template: "<h3>hello world!</h3>",
14
- };
15
-
16
- $stateProvider.state(helloState);
17
- });
9
+ myApp
10
+ .config(function ($stateProvider) {
11
+ $stateProvider
12
+ .state({ name: "top", url: "" })
13
+ .state({ name: "other", url: "/other/:id", template: "other" })
14
+ .state({
15
+ name: "other.detail",
16
+ url: "/detail",
17
+ template: "detail",
18
+ })
19
+ .state({
20
+ name: "contacts",
21
+ url: "/contacts",
22
+ template:
23
+ '<a ui-sref=".item({ id: 5 })" class="item">Person</a> <ui-view></ui-view>',
24
+ })
25
+ .state({
26
+ name: "contacts.item",
27
+ url: "/{id:int}",
28
+ template:
29
+ '<a ui-sref=".detail" class="item-detail">Detail</a> | <a ui-sref="^" class="item-parent">Parent</a> | <ui-view></ui-view>',
30
+ })
31
+ .state({
32
+ name: "contacts.item.detail",
33
+ url: "/{id}",
34
+ template:
35
+ '<div class="title">Detail</div> | <a ui-sref="^" class="item-parent2">Item</a>',
36
+ });
37
+ })
38
+ .controller(
39
+ "TestController",
40
+ class {
41
+ constructor($q) {
42
+ const defer = $q.defer();
43
+ this.contact = defer.promise;
44
+ this.test = 1;
45
+ defer.resolve({ id: 6 });
46
+ }
47
+ },
48
+ );
18
49
  });
19
50
  </script>
20
51
  </head>
21
52
  <body ng-app="test">
22
- {{ 2 + 2 }}
23
- <a ui-sref="hello" ui-sref-active="active">Hello</a>
24
- <ui-view></ui-view>
53
+ <div ng-controller="TestController as $ctrl">
54
+ {{$ctrl.test}}
55
+ <a ui-sref="contacts.item.detail({ id: contact.id })">Details</a>
56
+ </div>
25
57
  </body>
26
58
  </html>
@@ -0,0 +1,71 @@
1
+ import { Angular } from "../../src/loader";
2
+ import { publishExternalAPI } from "../../src/public";
3
+
4
+ describe("router services", () => {
5
+ let providers;
6
+ let $routerProvider;
7
+ let $injector;
8
+
9
+ beforeEach(() => {
10
+ window.angular = new Angular();
11
+ publishExternalAPI();
12
+ let module = window.angular.module("defaultModule", ["ui.router"]);
13
+ module.config(
14
+ (
15
+ _$routerProvider_,
16
+ $urlMatcherFactoryProvider,
17
+ $stateRegistryProvider,
18
+ $routerGlobalsProvider,
19
+ $transitionsProvider,
20
+ $stateProvider,
21
+ ) => {
22
+ debugger;
23
+ $routerProvider = _$routerProvider_;
24
+ expect($routerProvider["router"]).toBe($routerProvider);
25
+ providers = {
26
+ $routerProvider,
27
+ $urlMatcherFactoryProvider,
28
+ $stateRegistryProvider,
29
+ $routerGlobalsProvider,
30
+ $transitionsProvider,
31
+ $stateProvider,
32
+ };
33
+ },
34
+ );
35
+
36
+ $injector = window.angular.bootstrap(document.getElementById("dummy"), [
37
+ "defaultModule",
38
+ ]);
39
+ });
40
+
41
+ it("Should expose ui-router providers from the UIRouter instance", () => {
42
+ expect(providers.$urlMatcherFactoryProvider).toBe(
43
+ $routerProvider.urlMatcherFactory,
44
+ );
45
+ expect(providers.$urlRouterProvider).toBe(
46
+ $routerProvider.urlRouterProvider,
47
+ );
48
+ expect(providers.$stateRegistryProvider).toBe(
49
+ $routerProvider.stateRegistry,
50
+ );
51
+ expect(providers.$routerGlobalsProvider).toBe($routerProvider.globals);
52
+ expect(providers.$transitionsProvider).toBe(
53
+ $routerProvider.transitionService,
54
+ );
55
+ expect(providers.$stateProvider).toBe($routerProvider.stateProvider);
56
+ });
57
+
58
+ it("Should expose ui-router services from the UIRouter instance", () => {
59
+ let $router = $injector.get("$router");
60
+ expect($router).toBe($routerProvider);
61
+ expect($injector.get("$urlMatcherFactory")).toBe($router.urlMatcherFactory);
62
+ expect($injector.get("$urlService")).toBe($router.urlService);
63
+ expect($injector.get("$stateRegistry")).toBe($router.stateRegistry);
64
+ expect($injector.get("$routerGlobals")).toBe($router.globals);
65
+ expect($injector.get("$transitions")).toBe($router.transitionService);
66
+ expect($injector.get("$state")).toBe($router.stateService);
67
+ expect($injector.get("$stateParams")).toBe($router.globals.params);
68
+ expect($injector.get("$view")).toBe($router.viewService);
69
+ expect($injector.get("$trace")).toBeDefined();
70
+ });
71
+ });