@angular-wave/angular.ts 0.0.23 → 0.0.24

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 (60) hide show
  1. package/dist/angular-ts.esm.js +1 -1
  2. package/dist/angular-ts.umd.js +1 -1
  3. package/package.json +1 -1
  4. package/src/core/compile.js +2 -3
  5. package/src/core/parser/parse.js +2 -3
  6. package/src/router/directives/{stateDirectives.js → state-directives.js} +1 -2
  7. package/src/router/directives/{viewDirective.js → view-directive.js} +1 -1
  8. package/src/router/globals.js +1 -1
  9. package/src/router/hooks/{ignoredTransition.js → ignored-transition.js} +1 -1
  10. package/src/router/hooks/{redirectTo.js → redirect-to.js} +1 -1
  11. package/src/router/hooks/resolve.js +1 -1
  12. package/src/router/index.js +6 -8
  13. package/src/router/params/{paramTypes.js → param-types.js} +3 -4
  14. package/src/router/params/param.js +1 -1
  15. package/src/router/path/{pathUtils.js → path-utils.js} +2 -2
  16. package/src/router/resolve/resolvable.js +2 -2
  17. package/src/router/resolve/{resolveContext.js → resolve-context.js} +1 -1
  18. package/src/router/router.js +8 -8
  19. package/src/router/services.js +3 -3
  20. package/src/router/state/{stateBuilder.js → state-builder.js} +2 -3
  21. package/src/router/state/{stateQueueManager.js → state-queue-manager.js} +2 -1
  22. package/src/router/state/{stateRegistry.js → state-registry.js} +3 -3
  23. package/src/router/state/{stateService.js → state-service.js} +7 -7
  24. package/src/router/state/views.js +1 -1
  25. package/src/router/{templateFactory.js → template-factory.js} +84 -48
  26. package/src/router/transition/{hookBuilder.js → hook-builder.js} +3 -3
  27. package/src/router/transition/{transitionEventType.js → transition-event-type.js} +1 -1
  28. package/src/router/transition/{transitionHook.js → transition-hook.js} +2 -2
  29. package/src/router/transition/{transitionService.js → transition-service.js} +10 -10
  30. package/src/router/transition/transition.js +7 -8
  31. package/src/router/url/{urlConfig.js → url-config.js} +1 -1
  32. package/src/router/url/{urlMatcherFactory.js → url-matcher-factory.js} +1 -1
  33. package/src/router/url/{urlMatcher.js → url-matcher.js} +0 -2
  34. package/src/router/url/{urlRouter.js → url-router.js} +1 -1
  35. package/src/router/url/{urlRule.js → url-rule.js} +4 -4
  36. package/src/router/url/{urlRules.js → url-rules.js} +3 -3
  37. package/src/router/url/{urlService.js → url-service.js} +6 -6
  38. package/src/shared/strings.js +2 -2
  39. package/test/router/view.spec.js +5 -5
  40. package/test/test-utils.js +9 -0
  41. package/types/router/legacy/resolveService.d.ts +1 -1
  42. package/types/router/statebuilders/onEnterExitRetain.d.ts +1 -1
  43. package/types/router/statebuilders/views.d.ts +1 -2
  44. /package/src/router/hooks/{coreResolvables.js → core-resolvables.js} +0 -0
  45. /package/src/router/hooks/{invalidTransition.js → invalid-transition.js} +0 -0
  46. /package/src/router/hooks/{lazyLoad.js → lazy-load.js} +0 -0
  47. /package/src/router/hooks/{onEnterExitRetain.js → on-enter-exit-retain.js} +0 -0
  48. /package/src/router/hooks/{updateGlobals.js → update-globals.js} +0 -0
  49. /package/src/router/{locationServices.js → location-services.js} +0 -0
  50. /package/src/router/params/{paramType.js → param-type.js} +0 -0
  51. /package/src/router/params/{stateParams.js → state-params.js} +0 -0
  52. /package/src/router/path/{pathNode.js → path-node.js} +0 -0
  53. /package/src/router/state/{stateMatcher.js → state-matcher.js} +0 -0
  54. /package/src/router/state/{stateObject.js → state-object.js} +0 -0
  55. /package/src/router/state/{targetState.js → target-state.js} +0 -0
  56. /package/src/router/{stateFilters.js → state-filters.js} +0 -0
  57. /package/src/router/{stateProvider.js → state-provider.js} +0 -0
  58. /package/src/router/transition/{hookRegistry.js → hook-registry.js} +0 -0
  59. /package/src/router/transition/{rejectFactory.js → reject-factory.js} +0 -0
  60. /package/src/router/{viewScroll.js → view-scroll.js} +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "license": "MIT",
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
@@ -6,7 +6,6 @@ import {
6
6
  assertNotHasOwnProperty,
7
7
  createMap,
8
8
  forEach,
9
- identity,
10
9
  isDefined,
11
10
  isFunction,
12
11
  isObject,
@@ -969,7 +968,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
969
968
  const endSymbol = $interpolate.endSymbol();
970
969
  const denormalizeTemplate =
971
970
  startSymbol === "{{" && endSymbol === "}}"
972
- ? identity
971
+ ? (x) => x
973
972
  : function denormalizeTemplate(template) {
974
973
  return template
975
974
  .replace(/\{\{/g, startSymbol)
@@ -2902,7 +2901,7 @@ export function $CompileProvider($provide, $$sanitizeUriProvider) {
2902
2901
  const nodeName = nodeName_(node);
2903
2902
  const trustedContext = getTrustedPropContext(nodeName, propName);
2904
2903
 
2905
- let sanitizer = identity;
2904
+ let sanitizer = (x) => x;
2906
2905
  // Sanitize img[srcset] + source[srcset] values.
2907
2906
  if (
2908
2907
  propName === "srcset" &&
@@ -2,7 +2,6 @@ import {
2
2
  createMap,
3
3
  csp,
4
4
  forEach,
5
- identity,
6
5
  isDefined,
7
6
  isFunction,
8
7
  minErr,
@@ -2213,7 +2212,7 @@ export function $ParseProvider() {
2213
2212
  var unwatch, lastValue;
2214
2213
 
2215
2214
  var exp = parsedExpression.$$intercepted || parsedExpression;
2216
- var post = parsedExpression.$$interceptor || identity;
2215
+ var post = parsedExpression.$$interceptor || ((x) => x);
2217
2216
 
2218
2217
  var useInputs = parsedExpression.inputs && !exp.inputs;
2219
2218
 
@@ -2476,7 +2475,7 @@ export function oneTimeWatchDelegate(
2476
2475
  let lastValue;
2477
2476
 
2478
2477
  const exp = parsedExpression.$$intercepted || parsedExpression;
2479
- const post = parsedExpression.$$interceptor || identity;
2478
+ const post = parsedExpression.$$interceptor || ((x) => x);
2480
2479
 
2481
2480
  const useInputs = parsedExpression.inputs && !exp.inputs;
2482
2481
 
@@ -9,7 +9,6 @@ import {
9
9
  forEach,
10
10
  tail,
11
11
  unnestR,
12
- identity,
13
12
  uniqR,
14
13
  inArray,
15
14
  removeFrom,
@@ -642,7 +641,7 @@ export let uiSrefActiveDirective = [
642
641
  }
643
642
  // Update route state
644
643
  function update() {
645
- const splitClasses = (str) => str.split(/\s/).filter(identity);
644
+ const splitClasses = (str) => str.split(/\s/).filter(Boolean);
646
645
  const getClasses = (stateList) =>
647
646
  stateList
648
647
  .map((x) => x.activeClass)
@@ -3,7 +3,7 @@ import { isDefined, isFunction, isString } from "../../shared/utils";
3
3
  import { kebobString } from "../../shared/strings";
4
4
 
5
5
  import { parse } from "../../shared/hof";
6
- import { ResolveContext } from "../resolve/resolveContext";
6
+ import { ResolveContext } from "../resolve/resolve-context";
7
7
  import { trace } from "../common/trace";
8
8
  import { getLocals } from "../services";
9
9
  import { Ng1ViewConfig } from "../state/views";
@@ -1,4 +1,4 @@
1
- import { StateParams } from "./params/stateParams";
1
+ import { StateParams } from "./params/state-params";
2
2
  import { Queue } from "./common/queue";
3
3
  /**
4
4
  * Global router state
@@ -1,5 +1,5 @@
1
1
  import { trace } from "../common/trace";
2
- import { Rejection } from "../transition/rejectFactory";
2
+ import { Rejection } from "../transition/reject-factory";
3
3
  /**
4
4
  * A [[TransitionHookFn]] that skips a transition if it should be ignored
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import { isString, isFunction } from "../../shared/utils";
2
2
  import { services } from "../common/coreservices";
3
- import { TargetState } from "../state/targetState";
3
+ import { TargetState } from "../state/target-state";
4
4
  /**
5
5
  * A [[TransitionHookFn]] that redirects to a different state or params
6
6
  *
@@ -1,4 +1,4 @@
1
- import { ResolveContext } from "../resolve/resolveContext";
1
+ import { ResolveContext } from "../resolve/resolve-context";
2
2
  import { val } from "../../shared/hof";
3
3
  export const RESOLVE_HOOK_PRIORITY = 1000;
4
4
  /**
@@ -6,16 +6,16 @@ import {
6
6
  runBlock,
7
7
  watchDigests,
8
8
  } from "./services";
9
- import { TemplateFactory } from "./templateFactory";
9
+ import { TemplateFactory } from "./template-factory";
10
10
  import { trace } from "./common/trace";
11
- import { $ViewScrollProvider } from "./viewScroll";
12
- import { $IsStateFilter, $IncludedByStateFilter } from "./stateFilters";
11
+ import { $ViewScrollProvider } from "./view-scroll";
12
+ import { $IsStateFilter, $IncludedByStateFilter } from "./state-filters";
13
13
  import {
14
14
  uiSrefActiveDirective,
15
15
  uiStateDirective,
16
16
  uiSrefDirective,
17
- } from "./directives/stateDirectives";
18
- import { uiView, $ViewDirectiveFill } from "./directives/viewDirective";
17
+ } from "./directives/state-directives";
18
+ import { uiView, $ViewDirectiveFill } from "./directives/view-directive";
19
19
 
20
20
  export function initRouter() {
21
21
  window.angular
@@ -28,9 +28,7 @@ export function initRouter() {
28
28
  return router.urlMatcherFactory;
29
29
  },
30
30
  ])
31
- .provider("$templateFactory", function () {
32
- return new TemplateFactory();
33
- })
31
+ .provider("$templateFactory", TemplateFactory)
34
32
  .provider("$stateRegistry", getProviderFor("stateRegistry"))
35
33
  .provider("$routerGlobals", getProviderFor("globals"))
36
34
  .provider("$transitions", getProviderFor("transitionService"))
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  fromJson,
3
3
  toJson,
4
- identity,
5
4
  equals,
6
5
  inherit,
7
6
  map,
@@ -11,7 +10,7 @@ import { isNullOrUndefined } from "../../shared/predicates";
11
10
  import { isDefined } from "../../shared/utils";
12
11
  import { is } from "../../shared/hof";
13
12
  import { services } from "../common/coreservices";
14
- import { ParamType } from "./paramType";
13
+ import { ParamType } from "./param-type";
15
14
  /**
16
15
  * A registry for parameter types.
17
16
  *
@@ -153,8 +152,8 @@ function initDefaultTypes() {
153
152
  }),
154
153
  // does not encode/decode
155
154
  any: makeDefaultType({
156
- encode: identity,
157
- decode: identity,
155
+ encode: (x) => x,
156
+ decode: (x) => x,
158
157
  is: () => true,
159
158
  equals: equals,
160
159
  }),
@@ -3,7 +3,7 @@ import { prop } from "../../shared/hof";
3
3
  import { isInjectable } from "../../shared/predicates";
4
4
  import { isDefined, isUndefined, isString } from "../../shared/utils";
5
5
  import { services } from "../common/coreservices";
6
- import { ParamType } from "./paramType";
6
+ import { ParamType } from "./param-type";
7
7
  const hasOwn = Object.prototype.hasOwnProperty;
8
8
  const isShorthand = (cfg) =>
9
9
  ["value", "type", "squash", "array", "dynamic"].filter(hasOwn.bind(cfg || {}))
@@ -9,8 +9,8 @@ import {
9
9
  arrayTuples,
10
10
  } from "../../shared/common";
11
11
  import { prop, propEq } from "../../shared/hof";
12
- import { TargetState } from "../state/targetState";
13
- import { PathNode } from "./pathNode";
12
+ import { TargetState } from "../state/target-state";
13
+ import { PathNode } from "./path-node";
14
14
  /**
15
15
  * This class contains functions which convert TargetStates, Nodes and paths from one type to another.
16
16
  */
@@ -1,4 +1,4 @@
1
- import { identity, isFunction, isObject } from "../../shared/utils";
1
+ import { isFunction, isObject } from "../../shared/utils";
2
2
  import { services } from "../common/coreservices";
3
3
  import { trace } from "../common/trace";
4
4
  import { stringify } from "../../shared/strings";
@@ -87,7 +87,7 @@ export class Resolvable {
87
87
  const node = resolveContext.findNode(this);
88
88
  const state = node && node.state;
89
89
  const asyncPolicy = this.getPolicy(state).async;
90
- const customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy : identity;
90
+ const customAsyncPolicy = isFunction(asyncPolicy) ? asyncPolicy : (x) => x;
91
91
  // After the final value has been resolved, update the state of the Resolvable
92
92
  const applyResolvedValue = (resolvedValue) => {
93
93
  this.data = resolvedValue;
@@ -3,7 +3,7 @@ import { propEq, not } from "../../shared/hof";
3
3
  import { trace } from "../common/trace";
4
4
  import { services } from "../common/coreservices";
5
5
  import { Resolvable } from "./resolvable";
6
- import { PathUtils } from "../path/pathUtils";
6
+ import { PathUtils } from "../path/path-utils";
7
7
  import { stringify } from "../../shared/strings";
8
8
  import { isUndefined } from "../../shared/utils";
9
9
 
@@ -1,13 +1,13 @@
1
- import { UrlMatcherFactory } from "./url/urlMatcherFactory";
2
- import { UrlRouter } from "./url/urlRouter";
3
- import { TransitionService } from "./transition/transitionService";
1
+ import { UrlMatcherFactory } from "./url/url-matcher-factory";
2
+ import { UrlRouter } from "./url/url-router";
3
+ import { TransitionService } from "./transition/transition-service";
4
4
  import { ViewService } from "./view/view";
5
- import { StateRegistry } from "./state/stateRegistry";
6
- import { StateService } from "./state/stateService";
5
+ import { StateRegistry } from "./state/state-registry";
6
+ import { StateService } from "./state/state-service";
7
7
  import { UIRouterGlobals } from "./globals";
8
8
  import { removeFrom } from "../shared/common";
9
9
  import { isFunction } from "../shared/utils";
10
- import { UrlService } from "./url/urlService";
10
+ import { UrlService } from "./url/url-service";
11
11
  import { trace } from "./common/trace";
12
12
 
13
13
  /**
@@ -26,11 +26,11 @@ export class UIRouter {
26
26
  /**
27
27
  * Creates a new `UIRouter` object
28
28
  *
29
- * @param {import('./locationServices').Ng1LocationServices} locationService
29
+ * @param {import('./location-services').Ng1LocationServices} locationService
30
30
  */
31
31
  constructor(locationService) {
32
32
  /**
33
- * @type {import('./locationServices').Ng1LocationServices}
33
+ * @type {import('./location-services').Ng1LocationServices}
34
34
  */
35
35
  this.locationService = locationService;
36
36
  /** @type {number} */ this.$id = routerId++;
@@ -15,9 +15,9 @@ import { trace } from "./common/trace";
15
15
  import { UIRouter } from "./router";
16
16
  import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "./state/views";
17
17
 
18
- import { StateProvider } from "./stateProvider";
19
- import { Ng1LocationServices } from "./locationServices";
20
- import { ResolveContext } from "./resolve/resolveContext";
18
+ import { StateProvider } from "./state-provider";
19
+ import { Ng1LocationServices } from "./location-services";
20
+ import { ResolveContext } from "./resolve/resolve-context";
21
21
 
22
22
  export let router = null;
23
23
  $routerProvider.$inject = ["$locationProvider"];
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  applyPairs,
3
- identity,
4
3
  inherit,
5
4
  mapObj,
6
5
  omit,
@@ -201,12 +200,12 @@ export function resolvablesBuilder(state) {
201
200
  ],
202
201
  [
203
202
  prop("useExisting"),
204
- (p) => new Resolvable(getToken(p), identity, [p.useExisting], p.policy),
203
+ (p) => new Resolvable(getToken(p), (x) => x, [p.useExisting], p.policy),
205
204
  ],
206
205
  ]);
207
206
  // prettier-ignore
208
207
  const tuple2Resolvable = pattern([
209
- [pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, identity, [tuple.val], tuple.policy)],
208
+ [pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, ((x) => x), [tuple.val], tuple.policy)],
210
209
  [pipe(prop('val'), Array.isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
211
210
  [pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy)],
212
211
  ]);
@@ -1,7 +1,8 @@
1
1
  import { inArray } from "../../shared/common";
2
2
  import { prop } from "../../shared/hof";
3
3
  import { isString } from "../../shared/utils";
4
- import { StateObject } from "./stateObject";
4
+ import { StateObject } from "./state-object";
5
+
5
6
  export class StateQueueManager {
6
7
  constructor(router, states, builder, listeners) {
7
8
  this.router = router;
@@ -1,6 +1,6 @@
1
- import { StateMatcher } from "./stateMatcher";
2
- import { StateBuilder } from "./stateBuilder";
3
- import { StateQueueManager } from "./stateQueueManager";
1
+ import { StateMatcher } from "./state-matcher";
2
+ import { StateBuilder } from "./state-builder";
3
+ import { StateQueueManager } from "./state-queue-manager";
4
4
  import { removeFrom } from "../../shared/common";
5
5
  import { propEq } from "../../shared/hof";
6
6
  /**
@@ -9,15 +9,15 @@ import {
9
9
  import { isDefined, isObject, isString } from "../../shared/utils";
10
10
  import { Queue } from "../common/queue";
11
11
  import { services } from "../common/coreservices";
12
- import { PathUtils } from "../path/pathUtils";
13
- import { PathNode } from "../path/pathNode";
14
- import { defaultTransOpts } from "../transition/transitionService";
15
- import { Rejection, RejectType } from "../transition/rejectFactory";
16
- import { TargetState } from "./targetState";
12
+ import { PathUtils } from "../path/path-utils";
13
+ import { PathNode } from "../path/path-node";
14
+ import { defaultTransOpts } from "../transition/transition-service";
15
+ import { Rejection, RejectType } from "../transition/reject-factory";
16
+ import { TargetState } from "./target-state";
17
17
  import { Param } from "../params/param";
18
18
  import { Glob } from "../common/glob";
19
- import { ResolveContext } from "../resolve/resolveContext";
20
- import { lazyLoadState } from "../hooks/lazyLoad";
19
+ import { ResolveContext } from "../resolve/resolve-context";
20
+ import { lazyLoadState } from "../hooks/lazy-load";
21
21
  import { not, val } from "../../shared/hof";
22
22
  /**
23
23
  * Provides services related to ui-router states.
@@ -4,7 +4,7 @@ import { isInjectable } from "../../shared/predicates";
4
4
  import { services } from "../common/coreservices";
5
5
  import { trace } from "../common/trace";
6
6
  import { ViewService } from "../view/view";
7
- import { ResolveContext } from "../resolve/resolveContext";
7
+ import { ResolveContext } from "../resolve/resolve-context";
8
8
  import { Resolvable } from "../resolve/resolvable";
9
9
 
10
10
  export function getNg1ViewConfigFactory() {
@@ -1,29 +1,48 @@
1
- /** @publicapi @module view */ /** */
2
1
  import { isDefined, isFunction, isObject } from "../shared/utils";
3
2
  import { services } from "./common/coreservices";
4
3
  import { tail, unnestR } from "../shared/common";
5
4
  import { Resolvable } from "./resolve/resolvable";
6
5
  import { kebobString } from "../shared/strings";
7
6
 
7
+ /**
8
+ * @typedef BindingTuple
9
+ * @property {string} name
10
+ * @property {string} type
11
+ */
12
+
8
13
  /**
9
14
  * Service which manages loading of templates from a ViewConfig.
10
15
  */
11
16
  export class TemplateFactory {
12
17
  constructor() {
18
+ /** @type {boolean} */
13
19
  this._useHttp = false;
14
- this.$get = [
15
- "$http",
16
- "$templateCache",
17
- "$templateRequest",
18
- ($http, $templateCache, $templateRequest) => {
19
- this.$templateRequest = $templateRequest;
20
- this.$http = $http;
21
- this.$templateCache = $templateCache;
22
- return this;
23
- },
24
- ];
25
20
  }
26
21
 
22
+ $get = [
23
+ "$http",
24
+ "$templateCache",
25
+ "$templateRequest",
26
+ "$q",
27
+ "$injector",
28
+ /**
29
+ * @param {angular.IHttpService} $http
30
+ * @param {angular.ITemplateCacheService} $templateCache
31
+ * @param {angular.ITemplateRequestService} $templateRequest
32
+ * @param {angular.IQService} $q
33
+ * @param {angular.auto.IInjectorService} $injector
34
+ * @returns
35
+ */
36
+ ($http, $templateCache, $templateRequest, $q, $injector) => {
37
+ this.$templateRequest = $templateRequest;
38
+ this.$http = $http;
39
+ this.$templateCache = $templateCache;
40
+ this.$q = $q;
41
+ this.$injector = $injector;
42
+ return this;
43
+ },
44
+ ];
45
+
27
46
  /**
28
47
  * Forces the provider to use $http service directly
29
48
  * @param {boolean} value
@@ -39,8 +58,9 @@ export class TemplateFactory {
39
58
  * The following properties are search in the specified order, and the first one
40
59
  * that is defined is used to create the template:
41
60
  *
42
- * @param params Parameters to pass to the template function.
43
- * @param context The resolve context associated with the template's view
61
+ * @param {angular.Ng1ViewDeclaration} config
62
+ * @param {any} params Parameters to pass to the template function.
63
+ * @param {angular.ResolveContext} context The resolve context associated with the template's view
44
64
  *
45
65
  * @return {string|object} The template html as a string, or a promise for
46
66
  * that string,or `null` if no template is configured.
@@ -48,34 +68,43 @@ export class TemplateFactory {
48
68
  fromConfig(config, params, context) {
49
69
  const defaultTemplate = "<ui-view></ui-view>";
50
70
  const asTemplate = (result) =>
51
- services.$q.when(result).then((str) => ({ template: str }));
71
+ this.$q.when(result).then((str) => ({ template: str }));
52
72
  const asComponent = (result) =>
53
- services.$q.when(result).then((str) => ({ component: str }));
54
- return isDefined(config.template)
55
- ? asTemplate(this.fromString(config.template, params))
56
- : isDefined(config.templateUrl)
57
- ? asTemplate(this.fromUrl(config.templateUrl, params))
58
- : isDefined(config.templateProvider)
59
- ? asTemplate(
60
- this.fromProvider(config.templateProvider, params, context),
61
- )
62
- : isDefined(config.component)
63
- ? asComponent(config.component)
64
- : isDefined(config.componentProvider)
65
- ? asComponent(
66
- this.fromComponentProvider(
67
- config.componentProvider,
68
- params,
69
- context,
70
- ),
71
- )
72
- : asTemplate(defaultTemplate);
73
+ this.$q.when(result).then((str) => ({ component: str }));
74
+
75
+ const getConfigType = (config) => {
76
+ if (isDefined(config.template)) return "template";
77
+ if (isDefined(config.templateUrl)) return "templateUrl";
78
+ if (isDefined(config.templateProvider)) return "templateProvider";
79
+ if (isDefined(config.component)) return "component";
80
+ if (isDefined(config.componentProvider)) return "componentProvider";
81
+ return "default";
82
+ };
83
+
84
+ switch (getConfigType(config)) {
85
+ case "template":
86
+ return asTemplate(this.fromString(config.template, params));
87
+ case "templateUrl":
88
+ return asTemplate(this.fromUrl(config.templateUrl, params));
89
+ case "templateProvider":
90
+ return asTemplate(
91
+ this.fromProvider(config.templateProvider, params, context),
92
+ );
93
+ case "component":
94
+ return asComponent(config.component);
95
+ case "componentProvider":
96
+ return asComponent(
97
+ this.fromComponentProvider(config.componentProvider, params, context),
98
+ );
99
+ default:
100
+ return asTemplate(defaultTemplate);
101
+ }
73
102
  }
74
103
  /**
75
104
  * Creates a template from a string or a function returning a string.
76
105
  *
77
- * @param template html template as a string or function that returns an html template as a string.
78
- * @param params Parameters to pass to the template function.
106
+ * @param {string | Function} template html template as a string or function that returns an html template as a string.
107
+ * @param {angular.RawParams} [params] Parameters to pass to the template function.
79
108
  *
80
109
  * @return {string|object} The template html as a string, or a promise for that
81
110
  * string.
@@ -110,13 +139,14 @@ export class TemplateFactory {
110
139
  /**
111
140
  * Creates a template by invoking an injectable provider function.
112
141
  *
113
- * @param provider Function to invoke via `locals`
142
+ * @param {angular.IInjectable} provider Function to invoke via `locals`
114
143
  * @param {Function} injectFn a function used to invoke the template provider
144
+ * @param {angular.ResolveContext} context
115
145
  * @return {string|Promise.<string>} The template html as a string, or a promise
116
146
  * for that string.
117
147
  */
118
148
  fromProvider(provider, params, context) {
119
- const deps = services.$injector.annotate(provider);
149
+ const deps = this.$injector.annotate(provider);
120
150
  const providerFn = Array.isArray(provider) ? tail(provider) : provider;
121
151
  const resolvable = new Resolvable("", providerFn, deps);
122
152
  return resolvable.get(context);
@@ -124,12 +154,12 @@ export class TemplateFactory {
124
154
  /**
125
155
  * Creates a component's template by invoking an injectable provider function.
126
156
  *
127
- * @param provider Function to invoke via `locals`
157
+ * @param {angular.IInjectable} provider Function to invoke via `locals`
128
158
  * @param {Function} injectFn a function used to invoke the template provider
129
159
  * @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
130
160
  */
131
161
  fromComponentProvider(provider, params, context) {
132
- const deps = services.$injector.annotate(provider);
162
+ const deps = this.$injector.annotate(provider);
133
163
  const providerFn = Array.isArray(provider) ? tail(provider) : provider;
134
164
  const resolvable = new Resolvable("", providerFn, deps);
135
165
  return resolvable.get(context);
@@ -142,10 +172,10 @@ export class TemplateFactory {
142
172
  * It analyses the component's bindings, then constructs a template that instantiates the component.
143
173
  * The template wires input and output bindings to resolves or from the parent component.
144
174
  *
145
- * @param uiView {object} The parent ui-view (for binding outputs to callbacks)
146
- * @param context The ResolveContext (for binding outputs to callbacks returned from resolves)
147
- * @param component {string} Component's name in camel case.
148
- * @param bindings An object defining the component's bindings: {foo: '<'}
175
+ * @param {angular.IAugmentedJQuery} uiView {object} The parent ui-view (for binding outputs to callbacks)
176
+ * @param {angular.ResolveContext} context The ResolveContext (for binding outputs to callbacks returned from resolves)
177
+ * @param {string} component {string} Component's name in camel case.
178
+ * @param {any} [bindings] An object defining the component's bindings: {foo: '<'}
149
179
  * @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
150
180
  */
151
181
  makeComponentTemplate(uiView, context, component, bindings) {
@@ -157,7 +187,8 @@ export class TemplateFactory {
157
187
  const kebobed = kebobString(camelCase);
158
188
  return /^(x|data)-/.exec(kebobed) ? `x-${kebobed}` : kebobed;
159
189
  };
160
- const attributeTpl = (input) => {
190
+
191
+ const attributeTpl = /** @param {BindingTuple} input*/ (input) => {
161
192
  const { name, type } = input;
162
193
  const attrName = kebob(name);
163
194
  // If the ui-view has an attribute which matches a binding on the routed component
@@ -176,7 +207,7 @@ export class TemplateFactory {
176
207
  if (type === "&") {
177
208
  const res = context.getResolvable(resolveName);
178
209
  const fn = res && res.data;
179
- const args = (fn && services.$injector.annotate(fn)) || [];
210
+ const args = (fn && this.$injector.annotate(fn)) || [];
180
211
  // account for array style injection, i.e., ['foo', function(foo) {}]
181
212
  const arrayIdxStr = Array.isArray(fn) ? `[${fn.length - 1}]` : "";
182
213
  return `${attrName}='$resolve.${resolveName}${arrayIdxStr}(${args.join(",")})'`;
@@ -189,7 +220,12 @@ export class TemplateFactory {
189
220
  return `<${kebobName} ${attrs}></${kebobName}>`;
190
221
  }
191
222
  }
192
- // Gets all the directive(s)' inputs ('@', '=', and '<') and outputs ('&')
223
+
224
+ /**
225
+ * Gets all the directive(s)' inputs ('@', '=', and '<') and outputs ('&')
226
+ * @param {string} name
227
+ * @returns
228
+ */
193
229
  function getComponentBindings(name) {
194
230
  const cmpDefs = services.$injector.get(name + "Directive"); // could be multiple
195
231
  if (!cmpDefs || !cmpDefs.length)
@@ -1,6 +1,6 @@
1
- import { assertPredicate, unnestR, identity } from "../../shared/common";
1
+ import { assertPredicate, unnestR } from "../../shared/common";
2
2
  import { TransitionHookPhase, TransitionHookScope } from "./interface";
3
- import { TransitionHook } from "./transitionHook";
3
+ import { TransitionHook } from "./transition-hook";
4
4
  /**
5
5
  * This class returns applicable TransitionHooks for a specific Transition instance.
6
6
  *
@@ -24,7 +24,7 @@ export class HookBuilder {
24
24
  ._getEvents(phase)
25
25
  .map((type) => this.buildHooks(type))
26
26
  .reduce(unnestR, [])
27
- .filter(identity);
27
+ .filter(Boolean);
28
28
  }
29
29
  /**
30
30
  * Returns an array of newly built TransitionHook objects.
@@ -1,4 +1,4 @@
1
- import { TransitionHook } from "./transitionHook";
1
+ import { TransitionHook } from "./transition-hook";
2
2
  /**
3
3
  * This class defines a type of hook, such as `onBefore` or `onEnter`.
4
4
  * Plugins can define custom hook types, such as sticky states does for `onInactive`.
@@ -5,8 +5,8 @@ import { isPromise } from "../../shared/predicates";
5
5
  import { is, parse } from "../../shared/hof";
6
6
  import { trace } from "../common/trace";
7
7
  import { services } from "../common/coreservices";
8
- import { Rejection } from "./rejectFactory";
9
- import { TargetState } from "../state/targetState";
8
+ import { Rejection } from "./reject-factory";
9
+ import { TargetState } from "../state/target-state";
10
10
  const defaultOptions = {
11
11
  current: () => {},
12
12
  transition: null,