@angular-wave/angular.ts 0.0.72 → 0.1.0

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 (58) hide show
  1. package/.github/workflows/types.yml +19 -0
  2. package/dist/angular-ts.esm.js +2 -2
  3. package/dist/angular-ts.umd.js +2 -2
  4. package/package.json +1 -1
  5. package/src/animations/animate-js.html +5 -2
  6. package/src/animations/animate-queue.js +1 -1
  7. package/src/animations/animate.js +1 -26
  8. package/src/core/compile/attributes.js +8 -1
  9. package/src/core/compile/compile.js +432 -368
  10. package/src/core/compile/compile.spec.js +0 -1
  11. package/src/core/controller/controller.js +9 -3
  12. package/src/core/interpolate/interpolate.js +14 -10
  13. package/src/core/q/q.js +2 -1
  14. package/src/directive/change/change.js +3 -1
  15. package/src/directive/form/form.js +4 -3
  16. package/src/directive/list/list.js +3 -3
  17. package/src/directive/messages/messages.js +177 -172
  18. package/src/directive/model/model.js +261 -471
  19. package/src/directive/switch/switch.js +4 -4
  20. package/src/router/directives/state-directives.js +2 -9
  21. package/src/router/hooks/core-resolvables.js +5 -3
  22. package/src/router/path/path-utils.js +1 -2
  23. package/src/router/resolve/resolve-context.js +15 -29
  24. package/src/router/state/state-builder.js +38 -13
  25. package/src/router/state/state-object.js +12 -22
  26. package/src/router/state/state-queue-manager.js +2 -3
  27. package/src/router/state/state-registry.js +2 -1
  28. package/src/router/state/state-service.js +2 -3
  29. package/src/router/transition/transition.js +5 -3
  30. package/src/router/url/url-rule.js +14 -2
  31. package/src/router/view/view.js +2 -8
  32. package/src/router/view/view.spec.js +1 -1
  33. package/src/shared/common.js +3 -8
  34. package/src/shared/common.spec.js +1 -19
  35. package/src/shared/hof.js +1 -8
  36. package/src/shared/jqlite/jqlite.js +1 -1
  37. package/src/shared/predicates.js +6 -2
  38. package/src/types.js +2 -3
  39. package/tsconfig.json +1 -1
  40. package/types/animations/animate-queue.d.ts +1 -1
  41. package/types/core/compile/attributes.d.ts +10 -1
  42. package/types/core/interpolate/interpolate.d.ts +5 -5
  43. package/types/core/q/q.d.ts +4 -2
  44. package/types/directive/form/form.d.ts +3 -1
  45. package/types/directive/messages/messages.d.ts +76 -0
  46. package/types/directive/model/model.d.ts +101 -239
  47. package/types/router/resolve/resolve-context.d.ts +0 -2
  48. package/types/router/state/state-object.d.ts +12 -9
  49. package/types/router/state/state-registry.d.ts +2 -2
  50. package/types/router/transition/transition.d.ts +1 -2
  51. package/types/router/url/url-rule.d.ts +6 -1
  52. package/types/shared/common.d.ts +0 -3
  53. package/types/shared/hof.d.ts +0 -1
  54. package/types/shared/jqlite/jqlite.d.ts +2 -2
  55. package/types/shared/predicates.d.ts +2 -0
  56. package/types/types.d.ts +4 -2
  57. package/src/router/injectables.js +0 -263
  58. package/types/router/injectables.d.ts +0 -1
@@ -90,8 +90,8 @@ export function ngSwitchWhenDirective() {
90
90
  );
91
91
 
92
92
  cases.forEach((whenCase) => {
93
- ctrl.cases[`!${whenCase}`] = ctrl.cases[`!${whenCase}`] || [];
94
- ctrl.cases[`!${whenCase}`].push({
93
+ ctrl["cases"][`!${whenCase}`] = ctrl["cases"][`!${whenCase}`] || [];
94
+ ctrl["cases"][`!${whenCase}`].push({
95
95
  transclude: $transclude,
96
96
  element,
97
97
  });
@@ -111,8 +111,8 @@ export function ngSwitchDefaultDirective() {
111
111
  require: "^ngSwitch",
112
112
  multiElement: true,
113
113
  link(_scope, element, _attr, ctrl, $transclude) {
114
- ctrl.cases["?"] = ctrl.cases["?"] || [];
115
- ctrl.cases["?"].push({ transclude: $transclude, element });
114
+ ctrl["cases"]["?"] = ctrl["cases"]["?"] || [];
115
+ ctrl["cases"]["?"].push({ transclude: $transclude, element });
116
116
  },
117
117
  };
118
118
  }
@@ -1,11 +1,4 @@
1
- import {
2
- forEach,
3
- tail,
4
- unnestR,
5
- uniqR,
6
- inArray,
7
- removeFrom,
8
- } from "../../shared/common";
1
+ import { forEach, tail, unnestR, uniqR, removeFrom } from "../../shared/common";
9
2
  import { isString, isObject } from "../../shared/utils";
10
3
 
11
4
  import { parse } from "../../shared/hof";
@@ -362,7 +355,7 @@ export function $StateRefActiveDirective(
362
355
  : [];
363
356
  const addClasses = fuzzyClasses.concat(exactClasses).reduce(uniqR, []);
364
357
  const removeClasses = allClasses.filter(
365
- (cls) => !inArray(addClasses, cls),
358
+ (cls) => !addClasses.includes(cls),
366
359
  );
367
360
  $scope.$evalAsync(() => {
368
361
  addClasses.forEach((className) =>
@@ -1,6 +1,6 @@
1
1
  import { Transition } from "../transition/transition";
2
2
  import { Resolvable } from "../resolve/resolvable";
3
- import { inArray, uniqR, unnestR } from "../../shared/common";
3
+ import { uniqR, unnestR } from "../../shared/common";
4
4
 
5
5
  export function registerAddCoreResolvables(transitionService) {
6
6
  transitionService.onCreate({}, function addCoreResolvables(trans) {
@@ -17,7 +17,7 @@ export function registerAddCoreResolvables(transitionService) {
17
17
  }
18
18
 
19
19
  const TRANSITION_TOKENS = ["$transition$", Transition];
20
- const isTransition = inArray(TRANSITION_TOKENS);
20
+
21
21
  // References to Transition in the treeChanges pathnodes makes all
22
22
  // previous Transitions reachable in memory, causing a memory leak
23
23
  // This function removes resolves for '$transition$' and `Transition` from the treeChanges.
@@ -28,7 +28,9 @@ export function treeChangesCleanup(trans) {
28
28
  .reduce(uniqR, []);
29
29
  // If the resolvable is a Transition, return a new resolvable with null data
30
30
  const replaceTransitionWithNull = (r) => {
31
- return isTransition(r.token) ? Resolvable.fromData(r.token, null) : r;
31
+ return TRANSITION_TOKENS.includes(r.token)
32
+ ? Resolvable.fromData(r.token, null)
33
+ : r;
32
34
  };
33
35
  nodes.forEach((node) => {
34
36
  node.resolvables = node.resolvables.map(replaceTransitionWithNull);
@@ -5,7 +5,6 @@ import {
5
5
  tail,
6
6
  mergeR,
7
7
  unnestR,
8
- inArray,
9
8
  arrayTuples,
10
9
  } from "../../shared/common";
11
10
  import { prop, propEq } from "../../shared/hof";
@@ -51,7 +50,7 @@ export class PathUtils {
51
50
  static applyViewConfigs($view, path, states) {
52
51
  // Only apply the viewConfigs to the nodes for the given states
53
52
  path
54
- .filter((node) => inArray(states, node.state))
53
+ .filter((node) => states.includes(node.state))
55
54
  .forEach((node) => {
56
55
  const viewDecls = Object.values(node.state.views || {});
57
56
  const subPath = PathUtils.subPath(path, (n) => n === node);
@@ -1,5 +1,5 @@
1
- import { find, tail, uniqR, unnestR, inArray } from "../../shared/common";
2
- import { propEq, not } from "../../shared/hof";
1
+ import { find, tail, uniqR, unnestR } from "../../shared/common";
2
+ import { propEq } from "../../shared/hof";
3
3
  import { trace } from "../common/trace";
4
4
  import { services } from "../common/coreservices";
5
5
  import { Resolvable } from "./resolvable";
@@ -61,7 +61,7 @@ export class ResolveContext {
61
61
  /** Returns the [[ResolvePolicy]] for the given [[Resolvable]] */
62
62
  getPolicy(resolvable) {
63
63
  const node = this.findNode(resolvable);
64
- return resolvable.getPolicy(node.state);
64
+ return resolvable.getPolicy(node);
65
65
  }
66
66
  /**
67
67
  * Returns a ResolveContext that includes a portion of this one
@@ -107,6 +107,7 @@ export class ResolveContext {
107
107
  * @param state Used to find the node to put the resolvable on
108
108
  */
109
109
  addResolvables(newResolvables, state) {
110
+ /** @type {import('../path/path-node').PathNode} */
110
111
  const node = find(this._path, propEq("state", state));
111
112
  const keys = newResolvables.map((r) => r.token);
112
113
  node.resolvables = node.resolvables
@@ -122,7 +123,7 @@ export class ResolveContext {
122
123
  */
123
124
  resolvePath(when = "LAZY", trans) {
124
125
  // This option determines which 'when' policy Resolvables we are about to fetch.
125
- const whenOption = inArray(ALL_WHENS, when) ? when : "LAZY";
126
+ const whenOption = ALL_WHENS.includes(when) ? when : "LAZY";
126
127
  // If the caller specified EAGER, only the EAGER Resolvables are fetched.
127
128
  // if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
128
129
  const matchedWhens =
@@ -130,7 +131,7 @@ export class ResolveContext {
130
131
  // get the subpath to the state argument, if provided
131
132
  trace.traceResolvePath(this._path, when, trans);
132
133
  const matchesPolicy = (acceptedVals, whenOrAsync) => (resolvable) =>
133
- inArray(acceptedVals, this.getPolicy(resolvable)[whenOrAsync]);
134
+ acceptedVals.includes(this.getPolicy(resolvable)[whenOrAsync]);
134
135
  // Trigger all the (matching) Resolvables in the path
135
136
  // Reduce all the "WAIT" Resolvables into an array
136
137
  const promises = this._path.reduce((acc, node) => {
@@ -139,7 +140,7 @@ export class ResolveContext {
139
140
  );
140
141
  const nowait = nodeResolvables.filter(matchesPolicy(["NOWAIT"], "async"));
141
142
  const wait = nodeResolvables.filter(
142
- not(matchesPolicy(["NOWAIT"], "async")),
143
+ (x) => !matchesPolicy(["NOWAIT"], "async")(x),
143
144
  );
144
145
  // For the matching Resolvables, start their async fetch process.
145
146
  const subContext = this.subContext(node.state);
@@ -155,10 +156,10 @@ export class ResolveContext {
155
156
  return services.$q.all(promises);
156
157
  }
157
158
  injector() {
158
- return this._injector || (this._injector = new UIInjectorImpl(this));
159
+ return this._injector || (this._injector = new UIInjectorImpl());
159
160
  }
160
161
  findNode(resolvable) {
161
- return find(this._path, (node) => inArray(node.resolvables, resolvable));
162
+ return find(this._path, (node) => node.resolvables.includes(resolvable));
162
163
  }
163
164
  /**
164
165
  * Gets the async dependencies of a Resolvable
@@ -177,7 +178,7 @@ export class ResolveContext {
177
178
  const getDependency = (token) => {
178
179
  const matching = availableResolvables.filter((r) => r.token === token);
179
180
  if (matching.length) return tail(matching);
180
- const fromInjector = this.injector().getNative(token);
181
+ const fromInjector = services.$injector.get(token);
181
182
  if (isUndefined(fromInjector)) {
182
183
  throw new Error(
183
184
  "Could not find Dependency Injection token: " + stringify(token),
@@ -190,31 +191,16 @@ export class ResolveContext {
190
191
  }
191
192
 
192
193
  class UIInjectorImpl {
193
- constructor(context) {
194
- this.context = context;
195
- this.native = this.get(NATIVE_INJECTOR_TOKEN) || services.$injector;
194
+ constructor() {
195
+ this.native = services.$injector;
196
196
  }
197
197
  get(token) {
198
- const resolvable = this.context.getResolvable(token);
199
- if (resolvable) {
200
- if (this.context.getPolicy(resolvable).async === "NOWAIT") {
201
- return resolvable.get(this.context);
202
- }
203
- if (!resolvable.resolved) {
204
- throw new Error(
205
- "Resolvable async .get() not complete:" + stringify(resolvable.token),
206
- );
207
- }
208
- return resolvable.data;
209
- }
210
- return this.getNative(token);
198
+ return services.$injector.get(token);
211
199
  }
212
200
  getAsync(token) {
213
- const resolvable = this.context.getResolvable(token);
214
- if (resolvable) return resolvable.get(this.context);
215
- return services.$q.when(this.native.get(token));
201
+ return services.$q.when(services.$injector.get(token));
216
202
  }
217
203
  getNative(token) {
218
- return this.native && this.native.get(token);
204
+ return services.$injector.get(token);
219
205
  }
220
206
  }
@@ -172,7 +172,7 @@ export function resolvablesBuilder(state) {
172
172
  );
173
173
  /** extracts the token from a Provider or provide literal */
174
174
  const getToken = (p) => p.provide || p.token;
175
- // prettier-ignore: Given a literal resolve or provider object, returns a Resolvable
175
+ // Given a literal resolve or provider object, returns a Resolvable
176
176
  const literal2Resolvable = pattern([
177
177
  [
178
178
  prop("resolveFn"),
@@ -202,20 +202,45 @@ export function resolvablesBuilder(state) {
202
202
  (p) => new Resolvable(getToken(p), (x) => x, [p.useExisting], p.policy),
203
203
  ],
204
204
  ]);
205
- // prettier-ignore
206
205
  const tuple2Resolvable = pattern([
207
- [pipe(prop('val'), isString), (tuple) => new Resolvable(tuple.token, ((x) => x), [tuple.val], tuple.policy)],
208
- [pipe(prop('val'), Array.isArray), (tuple) => new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy)],
209
- [pipe(prop('val'), isFunction), (tuple) => new Resolvable(tuple.token, tuple.val, annotateFn(tuple.val), tuple.policy)],
210
- ]);
211
- // prettier-ignore
206
+ [
207
+ pipe(prop("val"), isString),
208
+ (tuple) =>
209
+ new Resolvable(tuple.token, (x) => x, [tuple.val], tuple.policy),
210
+ ],
211
+ [
212
+ pipe(prop("val"), Array.isArray),
213
+ (tuple) =>
214
+ new Resolvable(
215
+ tuple.token,
216
+ tail(tuple.val),
217
+ tuple.val.slice(0, -1),
218
+ tuple.policy,
219
+ ),
220
+ ],
221
+ [
222
+ pipe(prop("val"), isFunction),
223
+ (tuple) =>
224
+ new Resolvable(
225
+ tuple.token,
226
+ tuple.val,
227
+ annotateFn(tuple.val),
228
+ tuple.policy,
229
+ ),
230
+ ],
231
+ ]);
212
232
  const item2Resolvable = pattern([
213
- [is(Resolvable), (r) => r],
214
- [isResolveLiteral, literal2Resolvable],
215
- [isLikeNg2Provider, literal2Resolvable],
216
- [isTupleFromObj, tuple2Resolvable],
217
- [val(true), (obj) => { throw new Error('Invalid resolve value: ' + stringify(obj)); },],
218
- ]);
233
+ [is(Resolvable), (r) => r],
234
+ [isResolveLiteral, literal2Resolvable],
235
+ [isLikeNg2Provider, literal2Resolvable],
236
+ [isTupleFromObj, tuple2Resolvable],
237
+ [
238
+ val(true),
239
+ (obj) => {
240
+ throw new Error("Invalid resolve value: " + stringify(obj));
241
+ },
242
+ ],
243
+ ]);
219
244
  // If resolveBlock is already an array, use it as-is.
220
245
  // Otherwise, assume it's an object and convert to an Array of tuples
221
246
  const decl = state.resolve;
@@ -13,29 +13,19 @@ import { isFunction, isObject } from "../../shared/utils";
13
13
  * Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
14
14
  */
15
15
  export class StateObject {
16
- /**
17
- * Create a state object to put the private/internal implementation details onto.
18
- * The object's prototype chain looks like:
19
- * (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)
20
- *
21
- * @param stateDecl the user-supplied State Declaration
22
- * @returns {StateObject} an internal State object
23
- */
24
- static create(stateDecl) {
25
- const state = Object.setPrototypeOf(
26
- Object.assign({}, stateDecl),
27
- StateObject.prototype,
28
- );
29
- stateDecl.$$state = () => state;
30
- state.self = stateDecl;
31
- state.__stateObjectCache = {
32
- nameGlob: Glob.fromString(state.name), // might return null
33
- };
34
- return state;
35
- }
36
- // /** @deprecated use State.create() */
16
+ name = undefined;
17
+ navigable = undefined;
18
+ /** @type {?StateObject} */
19
+ parent = undefined;
20
+ params = undefined;
21
+ url = undefined;
22
+
37
23
  constructor(config) {
38
- return StateObject.create(config || {});
24
+ Object.assign(this, config);
25
+ this.$$state = () => this;
26
+ this.self = config;
27
+ const nameGlob = this.name ? Glob.fromString(this.name) : null;
28
+ this.__stateObjectCache = { nameGlob };
39
29
  }
40
30
  /**
41
31
  * Returns true if the provided parameter is the same state.
@@ -1,4 +1,3 @@
1
- import { inArray } from "../../shared/common";
2
1
  import { prop } from "../../shared/hof";
3
2
  import { isString } from "../../shared/utils";
4
3
  import { StateObject } from "./state-object";
@@ -14,12 +13,12 @@ export class StateQueueManager {
14
13
  }
15
14
  register(stateDecl) {
16
15
  const queue = this.queue;
17
- const state = StateObject.create(stateDecl);
16
+ const state = new StateObject(stateDecl);
18
17
  const name = state.name;
19
18
  if (!isString(name)) throw new Error("State must have a valid name");
20
19
  if (
21
20
  Object.prototype.hasOwnProperty.call(this.states, name) ||
22
- inArray(queue.map(prop("name")), name)
21
+ queue.map(prop("name")).includes(name)
23
22
  )
24
23
  throw new Error(`State '${name}' is already defined`);
25
24
  queue.push(state);
@@ -6,6 +6,7 @@ import { propEq } from "../../shared/hof";
6
6
  import { ResolveContext } from "../resolve/resolve-context";
7
7
  import { ng1ViewsBuilder } from "./views";
8
8
  import { isString } from "../../shared/utils";
9
+
9
10
  /**
10
11
  * A registry for all of the application's [[StateDeclaration]]s
11
12
  *
@@ -196,7 +197,7 @@ export class StateRegistry {
196
197
  * If the state has children, they are are also removed from the registry.
197
198
  *
198
199
  * @param stateOrName the state's name or object representation
199
- * @returns {StateObject[]} a list of removed states
200
+ * @returns {import('./state-object').StateObject[]} a list of removed states
200
201
  */
201
202
  deregister(stateOrName) {
202
203
  const _state = this.get(stateOrName);
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  createProxyFunctions,
3
3
  defaults,
4
- inArray,
5
4
  removeFrom,
6
5
  silenceUncaughtInPromise,
7
6
  silentRejection,
@@ -18,7 +17,7 @@ import { Param } from "../params/param";
18
17
  import { Glob } from "../common/glob";
19
18
  import { ResolveContext } from "../resolve/resolve-context";
20
19
  import { lazyLoadState } from "../hooks/lazy-load";
21
- import { not, val } from "../../shared/hof";
20
+ import { val } from "../../shared/hof";
22
21
  import { EventBus } from "../../core/pubsub/pubsub";
23
22
 
24
23
  const err = minErr("$stateProvider");
@@ -75,7 +74,7 @@ export class StateService {
75
74
  };
76
75
  const getters = ["current", "$current", "params", "transition"];
77
76
  const boundFns = Object.keys(StateService.prototype).filter(
78
- not(inArray(getters)),
77
+ (x) => !getters.includes(x),
79
78
  );
80
79
  createProxyFunctions(
81
80
  val(StateService.prototype),
@@ -14,7 +14,7 @@ import {
14
14
  uniqR,
15
15
  } from "../../shared/common";
16
16
  import { isUndefined, isObject } from "../../shared/utils";
17
- import { prop, propEq, val, not, is } from "../../shared/hof";
17
+ import { prop, propEq, val, is } from "../../shared/hof";
18
18
  import { TransitionHookPhase } from "./interface"; // has or is using
19
19
  import { TransitionHook } from "./transition-hook";
20
20
  import { matchState, makeEvent } from "./hook-registry";
@@ -323,12 +323,14 @@ export class Transition {
323
323
  * @param resolvable a [[ResolvableLiteral]] object (or a [[Resolvable]])
324
324
  * @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
325
325
  */
326
- addResolvable(resolvable, state = "") {
326
+ addResolvable(resolvable, state) {
327
327
  resolvable = is(Resolvable)(resolvable)
328
328
  ? resolvable
329
329
  : new Resolvable(resolvable);
330
+
330
331
  const stateName = typeof state === "string" ? state : state.name;
331
332
  const topath = this._treeChanges.to;
333
+ /** @type {import('../path/path-node').PathNode} */
332
334
  const targetNode = find(topath, (node) => {
333
335
  return node.state.name === stateName;
334
336
  });
@@ -500,7 +502,7 @@ export class Transition {
500
502
  redirectEnteringNodes,
501
503
  originalEnteringNodes,
502
504
  PathUtils.nonDynamicParams,
503
- ).filter(not(nodeIsReloading(targetState.options().reloadState)));
505
+ ).filter((x) => !nodeIsReloading(targetState.options().reloadState)(x));
504
506
  // Use the existing (possibly pre-resolved) resolvables for the matching entering nodes.
505
507
  matchingEnteringNodes.forEach((node, idx) => {
506
508
  node.resolvables = originalEnteringNodes[idx].resolvables;
@@ -1,5 +1,11 @@
1
1
  import { UrlMatcher } from "./url-matcher";
2
- import { isString, isFunction, isDefined } from "../../shared/utils";
2
+ import {
3
+ isString,
4
+ isFunction,
5
+ isDefined,
6
+ isUndefined,
7
+ assert,
8
+ } from "../../shared/utils";
3
9
  import { is, or, pattern } from "../../shared/hof";
4
10
  import { StateObject } from "../state/state-object";
5
11
  /**
@@ -207,7 +213,13 @@ export class BaseUrlRule {
207
213
  this.handler = handler || ((x) => x);
208
214
  }
209
215
 
210
- matchPriority() {
216
+ /**
217
+ * This function should be overridden
218
+ * @param {*} [params]
219
+ * @returns {number}
220
+ */
221
+ matchPriority(params) {
222
+ assert(isUndefined(params));
211
223
  return 0 - this.$id;
212
224
  }
213
225
  }
@@ -1,10 +1,4 @@
1
- import {
2
- equals,
3
- applyPairs,
4
- removeFrom,
5
- inArray,
6
- find,
7
- } from "../../shared/common";
1
+ import { equals, applyPairs, removeFrom, find } from "../../shared/common";
8
2
  import { curry, prop } from "../../shared/hof";
9
3
  import { trace } from "../common/trace";
10
4
  import { getNg1ViewConfigFactory } from "../state/views";
@@ -133,7 +127,7 @@ export class ViewService {
133
127
  .map(matchingConfigPair);
134
128
  const matchedViewConfigs = ngViewTuples.map((tuple) => tuple.viewConfig);
135
129
  const unmatchedConfigTuples = this._viewConfigs
136
- .filter((config) => !inArray(matchedViewConfigs, config))
130
+ .filter((config) => !matchedViewConfigs.includes(config))
137
131
  .map((viewConfig) => ({ ngView: undefined, viewConfig }));
138
132
  ngViewTuples.forEach(configureUIView);
139
133
  const allTuples = ngViewTuples.concat(unmatchedConfigTuples);
@@ -61,7 +61,7 @@ describe("view", () => {
61
61
 
62
62
  let register;
63
63
  const registerState = curry(function (_states, stateBuilder, config) {
64
- const state = StateObject.create(config);
64
+ const state = new StateObject(config);
65
65
  const built = stateBuilder.build(state);
66
66
  return (_states[built.name] = built);
67
67
  });
@@ -1,5 +1,5 @@
1
1
  import { isDate, isFunction, isRegExp, isString } from "./utils";
2
- import { all, any, prop, curry, not } from "./hof";
2
+ import { all, any, prop, curry } from "./hof";
3
3
  import { services } from "../router/common/coreservices";
4
4
  export const fromJson = JSON.parse.bind(JSON);
5
5
  export const toJson = JSON.stringify.bind(JSON);
@@ -101,11 +101,6 @@ export function inherit(parent, extra) {
101
101
  return newObj;
102
102
  }
103
103
 
104
- /** Given an array, returns true if the object is found in the array, (using includes) */
105
- export const inArray = curry(_inArray);
106
- export function _inArray(array, obj) {
107
- return array.includes(obj);
108
- }
109
104
  /**
110
105
  * Given an array, and an item, if the item is found in the array, it removes it (in-place).
111
106
  * The same array is returned
@@ -188,7 +183,7 @@ export function pick(obj, propNames) {
188
183
  */
189
184
  export function omit(obj, propNames) {
190
185
  return Object.keys(obj)
191
- .filter(not(inArray(propNames)))
186
+ .filter((x) => !propNames.includes(x))
192
187
  .reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
193
188
  }
194
189
  /**
@@ -287,7 +282,7 @@ export function pushR(arr, obj) {
287
282
  }
288
283
  /** Reduce function that filters out duplicates */
289
284
  export const uniqR = (acc, token) =>
290
- inArray(acc, token) ? acc : pushR(acc, token);
285
+ acc.includes(token) ? acc : pushR(acc, token);
291
286
  /**
292
287
  * Return a new array with a single level of arrays unnested.
293
288
  *
@@ -1,5 +1,5 @@
1
1
  import { defaults, filter, map, mapObj, pick } from "./common";
2
- import { is, eq, not, pattern, val } from "./hof";
2
+ import { is, eq, pattern, val } from "./hof";
3
3
  import { isInjectable } from "./predicates";
4
4
  import { Queue } from "../router/common/queue";
5
5
 
@@ -58,24 +58,6 @@ describe("common", function () {
58
58
  });
59
59
  });
60
60
 
61
- describe("not", function () {
62
- it("should allow double-negatives", function () {
63
- function T() {
64
- return true;
65
- }
66
- function F() {
67
- return false;
68
- }
69
- function empty() {
70
- return "";
71
- }
72
-
73
- expect(not(not(T))()).toBe(true);
74
- expect(not(not(F))()).toBe(false);
75
- expect(not(not(empty))()).toBe(false);
76
- });
77
- });
78
-
79
61
  describe("val", function () {
80
62
  it("should return identity", function () {
81
63
  const f = function () {},
package/src/shared/hof.js CHANGED
@@ -104,14 +104,7 @@ export const propEq = curry((name, _val, obj) => obj && obj[name] === _val);
104
104
  * propNotFound(obj) === undefined
105
105
  */
106
106
  export const parse = (name) => pipe.apply(null, name.split(".").map(prop));
107
- /**
108
- * Given a function that returns a truthy or falsey value, returns a
109
- * function that returns the opposite (falsey or truthy) value given the same inputs
110
- */
111
- export const not =
112
- (fn) =>
113
- (...args) =>
114
- !fn.apply(null, args);
107
+
115
108
  /**
116
109
  * Given two functions that return truthy or falsey values, returns a function that returns truthy
117
110
  * if both functions return truthy for the given arguments
@@ -1123,7 +1123,7 @@ function specialMouseHandlerWrapper(target, event, handler) {
1123
1123
  }
1124
1124
 
1125
1125
  /**
1126
- * @param {string} elementStr
1126
+ * @param {string|JQLite} elementStr
1127
1127
  * @returns {string} Returns the string representation of the element.
1128
1128
  */
1129
1129
  export function startingTag(elementStr) {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @packageDocumentation
8
8
  */
9
- import { and, not, pipe, prop, or } from "./hof";
9
+ import { and, pipe, prop, or } from "./hof";
10
10
  import { isFunction, isObject, isString, isUndefined } from "./utils";
11
11
  export const isNull = (o) => o === null;
12
12
  export const isNullOrUndefined = or(isNull, isUndefined);
@@ -15,13 +15,17 @@ export const isNullOrUndefined = or(isNull, isUndefined);
15
15
  *
16
16
  * A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
17
17
  * where all the elements in the array are Strings, except the last one, which is a Function
18
+ * @param {*} val
19
+ * @returns {boolean}
18
20
  */
19
21
  export function isInjectable(val) {
20
22
  if (Array.isArray(val) && val.length) {
21
23
  const head = val.slice(0, -1),
22
24
  tail = val.slice(-1);
25
+
23
26
  return !(
24
- head.filter(not(isString)).length || tail.filter(not(isFunction)).length
27
+ head.filter((x) => !isString(x)).length ||
28
+ tail.filter((x) => !isFunction(x)).length
25
29
  );
26
30
  }
27
31
  return isFunction(val);
package/src/types.js CHANGED
@@ -68,9 +68,8 @@
68
68
 
69
69
  /**
70
70
  * @typedef {Object} Controller
71
+ * @property {string} name
71
72
  * @description Interface representing the lifecycle hooks for AngularJS directive controllers.
72
- * @see {@link https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks}
73
- * @see {@link https://docs.angularjs.org/guide/component}
74
73
  *
75
74
  * @property {function(): void} [$onInit]
76
75
  * Called on each controller after all the controllers on an element have been constructed and had their bindings
@@ -147,7 +146,7 @@
147
146
  */
148
147
 
149
148
  /**
150
- * @typedef {DirectiveController} TController
149
+ * @typedef {DirectiveController|NgModelController} TController
151
150
  */
152
151
 
153
152
  /**
package/tsconfig.json CHANGED
@@ -13,5 +13,5 @@
13
13
  "typeRoots": ["node_modules/@types"]
14
14
  },
15
15
  "include": ["./src/*.js", "./**/*.ts"],
16
- "exclude": ["./types-back/**", "./types/**", "**/*.test.js", "**/*.spec.js"]
16
+ "exclude": ["./node_modules/**", "./types/**", "**/*.test.js", "**/*.spec.js"]
17
17
  }
@@ -6,7 +6,7 @@ export class $$AnimateQueueProvider {
6
6
  cancel: any[];
7
7
  join: any[];
8
8
  };
9
- $get: (string | (($rootScope: any, $injector: any, $$animation: any, $$AnimateRunner: any, $templateRequest: any) => {
9
+ $get: (string | (($rootScope: import("../core/scope/scope").Scope, $injector: any, $$animation: any, $$AnimateRunner: any, $templateRequest: any) => {
10
10
  on(event: any, container: any, callback: any): void;
11
11
  off(event: any, container: any, callback: any, ...args: any[]): void;
12
12
  pin(element: any, parentElement: any): void;
@@ -1,6 +1,12 @@
1
+ /**
2
+ * @typedef {Object} AttributeLike
3
+ * @property {Object} $attr
4
+ */
5
+ /**
6
+ * @extends {AttributeLike}
7
+ */
1
8
  export class Attributes {
2
9
  /**
3
- *
4
10
  * @param {import('../scope/scope').Scope} $rootScope
5
11
  * @param {*} $animate
6
12
  * @param {import("../exception-handler").ExceptionHandlerProvider} $exceptionHandler
@@ -98,4 +104,7 @@ export class Attributes {
98
104
  sanitizeSrcset(value: any, invokeType: any): any;
99
105
  srcset: any;
100
106
  }
107
+ export type AttributeLike = {
108
+ $attr: any;
109
+ };
101
110
  import { directiveNormalize } from "../../shared/utils";