@angular-wave/angular.ts 0.0.73 → 0.1.1

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.
@@ -9,7 +9,7 @@ import {
9
9
  import { constantWatchDelegate } from "../parser/parse";
10
10
 
11
11
  const $interpolateMinErr = minErr("$interpolate");
12
- $interpolateMinErr.throwNoconcat = function (text) {
12
+ function throwNoconcat(text) {
13
13
  throw $interpolateMinErr(
14
14
  "noconcat",
15
15
  "Error while interpolating: {0}\nStrict Contextual Escaping disallows " +
@@ -17,16 +17,16 @@ $interpolateMinErr.throwNoconcat = function (text) {
17
17
  "required. See http://docs.angularjs.org/api/ng.$sce",
18
18
  text,
19
19
  );
20
- };
20
+ }
21
21
 
22
- $interpolateMinErr.interr = function (text, err) {
22
+ function interr(text, err) {
23
23
  throw $interpolateMinErr(
24
24
  "interr",
25
25
  "Can't interpolate: {0}\n{1}",
26
26
  text,
27
27
  err.toString(),
28
28
  );
29
- };
29
+ }
30
30
 
31
31
  /**
32
32
  *
@@ -48,7 +48,7 @@ export function $InterpolateProvider() {
48
48
  * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
49
49
  *
50
50
  * @param {string=} value new value to set the starting symbol to.
51
- * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
51
+ * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
52
52
  */
53
53
  this.startSymbol = function (value) {
54
54
  if (value) {
@@ -62,7 +62,7 @@ export function $InterpolateProvider() {
62
62
  * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
63
63
  *
64
64
  * @param {string=} value new value to set the ending symbol to.
65
- * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
65
+ * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
66
66
  */
67
67
  this.endSymbol = function (value) {
68
68
  if (value) {
@@ -215,7 +215,7 @@ export function $InterpolateProvider() {
215
215
  * provides Strict Contextual Escaping for details.
216
216
  * @param {boolean=} allOrNothing if `true`, then the returned function returns undefined
217
217
  * unless all embedded expressions evaluate to a value other than `undefined`.
218
- * @returns {function(context)} an interpolation function which is used to compute the
218
+ * @returns {Function} an interpolation function which is used to compute the
219
219
  * interpolated string. The function has these parameters:
220
220
  *
221
221
  * - `context`: evaluation context for all expressions embedded in the interpolated text
@@ -237,6 +237,10 @@ export function $InterpolateProvider() {
237
237
  if (contextAllowsConcatenation) {
238
238
  unescapedText = $sce.getTrusted(trustedContext, unescapedText);
239
239
  }
240
+
241
+ /**
242
+ * @type {any}
243
+ */
240
244
  const constantInterp = valueFn(unescapedText);
241
245
  constantInterp.exp = text;
242
246
  constantInterp.expressions = [];
@@ -322,7 +326,7 @@ export function $InterpolateProvider() {
322
326
  }
323
327
  if (trustedContext && concat.length > 1) {
324
328
  // This context does not allow more than one part, e.g. expr + string or exp + exp.
325
- $interpolateMinErr.throwNoconcat(text);
329
+ throwNoconcat(text);
326
330
  }
327
331
  // In an unprivileged context or only one part: just concatenate and return.
328
332
  return concat.join("");
@@ -341,7 +345,7 @@ export function $InterpolateProvider() {
341
345
 
342
346
  return compute(values);
343
347
  } catch (err) {
344
- $exceptionHandler($interpolateMinErr.interr(text, err));
348
+ interr(text, err);
345
349
  }
346
350
  },
347
351
  {
@@ -380,7 +384,7 @@ export function $InterpolateProvider() {
380
384
  : $sce.valueOf(value);
381
385
  return allOrNothing && !isDefined(value) ? value : stringify(value);
382
386
  } catch (err) {
383
- $exceptionHandler($interpolateMinErr.interr(text, err));
387
+ interr(text, err);
384
388
  }
385
389
  }
386
390
  }
@@ -816,10 +816,6 @@ export class NgModelController {
816
816
  }
817
817
 
818
818
  /**
819
- * @ngdoc method
820
- * @name ngModel.NgModelController#$setViewValue
821
- *
822
- * @description
823
819
  * Update the view value.
824
820
  *
825
821
  * This method should be called when a control wants to change the view value; typically,
@@ -906,11 +902,6 @@ export class NgModelController {
906
902
  }
907
903
 
908
904
  /**
909
- * @ngdoc method
910
- *
911
- * @name ngModel.NgModelController#$overrideModelOptions
912
- *
913
- * @description
914
905
  *
915
906
  * Override the current model options settings programmatically.
916
907
  *
@@ -940,12 +931,6 @@ export class NgModelController {
940
931
  }
941
932
 
942
933
  /**
943
- * @ngdoc method
944
- *
945
- * @name ngModel.NgModelController#$processModelValue
946
-
947
- * @description
948
- *
949
934
  * Runs the model -> view pipeline on the current
950
935
  * {@link ngModel.NgModelController#$modelValue $modelValue}.
951
936
  *
@@ -1132,6 +1117,7 @@ function setupModelWatcher(ctrl) {
1132
1117
  });
1133
1118
  }
1134
1119
 
1120
+ ngModelDirective.$inject = ["$rootScope"];
1135
1121
  export function ngModelDirective($rootScope) {
1136
1122
  return {
1137
1123
  restrict: "A",
@@ -1146,7 +1132,7 @@ export function ngModelDirective($rootScope) {
1146
1132
  element[0].classList.add(PRISTINE_CLASS, UNTOUCHED_CLASS, VALID_CLASS);
1147
1133
 
1148
1134
  return {
1149
- pre: function (scope, element, attr, ctrls) {
1135
+ pre: function (scope, _element, attr, ctrls) {
1150
1136
  const modelCtrl = ctrls[0];
1151
1137
  const formCtrl = ctrls[1] || modelCtrl.$$parentForm;
1152
1138
  const optionsCtrl = ctrls[2];
@@ -1170,7 +1156,7 @@ export function ngModelDirective($rootScope) {
1170
1156
  modelCtrl.$$parentForm.$removeControl(modelCtrl);
1171
1157
  });
1172
1158
  },
1173
- post: function ngModelPostLink(scope, element, attr, ctrls) {
1159
+ post: function (scope, element, _attr, ctrls) {
1174
1160
  const modelCtrl = ctrls[0];
1175
1161
  modelCtrl.$$setUpdateOnEvents();
1176
1162
 
@@ -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
@@ -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.
@@ -13,7 +13,7 @@ export class StateQueueManager {
13
13
  }
14
14
  register(stateDecl) {
15
15
  const queue = this.queue;
16
- const state = StateObject.create(stateDecl);
16
+ const state = new StateObject(stateDecl);
17
17
  const name = state.name;
18
18
  if (!isString(name)) throw new Error("State must have a valid name");
19
19
  if (
@@ -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);
@@ -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
  });
@@ -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
  }
@@ -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
  });
@@ -15,11 +15,14 @@ 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
27
  head.filter((x) => !isString(x)).length ||
25
28
  tail.filter((x) => !isFunction(x)).length
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
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @typedef {Object} AnyStringKeyObject
3
- * @property {Record<string, any>} [key]
2
+ * @typedef {Object} AttributeLike
3
+ * @property {Object} $attr
4
4
  */
5
5
  /**
6
- * @extends {AnyStringKeyObject}
6
+ * @extends {AttributeLike}
7
7
  */
8
8
  export class Attributes {
9
9
  /**
@@ -104,7 +104,7 @@ export class Attributes {
104
104
  sanitizeSrcset(value: any, invokeType: any): any;
105
105
  srcset: any;
106
106
  }
107
- export type AnyStringKeyObject = {
108
- key?: Record<string, any>;
107
+ export type AttributeLike = {
108
+ $attr: any;
109
109
  };
110
110
  import { directiveNormalize } from "../../shared/utils";
@@ -16,18 +16,18 @@ export class $InterpolateProvider {
16
16
  * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
17
17
  *
18
18
  * @param {string=} value new value to set the starting symbol to.
19
- * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
19
+ * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
20
20
  */
21
- startSymbol: (value?: string | undefined) => string | (Window & typeof globalThis);
21
+ startSymbol: (value?: string | undefined) => string | $InterpolateProvider;
22
22
  /**
23
23
  * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
24
24
  *
25
25
  * @param {string=} value new value to set the ending symbol to.
26
- * @returns {string|self} Returns the symbol when used as getter and self if used as setter.
26
+ * @returns {string|$InterpolateProvider} Returns the symbol when used as getter and self if used as setter.
27
27
  */
28
- endSymbol: (value?: string | undefined) => string | (Window & typeof globalThis);
28
+ endSymbol: (value?: string | undefined) => string | $InterpolateProvider;
29
29
  $get: (string | (($parse: import("../parser/parse").ParseService, $exceptionHandler: import("../exception-handler").ErrorHandler, $sce: any) => {
30
- (text: string, mustHaveExpression?: boolean | undefined, trustedContext?: string | undefined, allOrNothing?: boolean | undefined): (arg0: context) => any;
30
+ (text: string, mustHaveExpression?: boolean | undefined, trustedContext?: string | undefined, allOrNothing?: boolean | undefined): Function;
31
31
  /**
32
32
  * @ngdoc method
33
33
  * @name $interpolate#startSymbol
@@ -9,16 +9,18 @@
9
9
  * Each of its own properties (i.e., `hasOwnProperty`) are built using builders from the [[StateBuilder]].
10
10
  */
11
11
  export class StateObject {
12
- /**
13
- * Create a state object to put the private/internal implementation details onto.
14
- * The object's prototype chain looks like:
15
- * (Internal State Object) -> (Copy of State.prototype) -> (State Declaration object) -> (State Declaration's prototype...)
16
- *
17
- * @param stateDecl the user-supplied State Declaration
18
- * @returns {StateObject} an internal State object
19
- */
20
- static create(stateDecl: any): StateObject;
21
12
  constructor(config: any);
13
+ name: any;
14
+ navigable: any;
15
+ /** @type {?StateObject} */
16
+ parent: StateObject | null;
17
+ params: any;
18
+ url: any;
19
+ $$state: () => this;
20
+ self: any;
21
+ __stateObjectCache: {
22
+ nameGlob: Glob;
23
+ };
22
24
  /**
23
25
  * Returns true if the provided parameter is the same state.
24
26
  *
@@ -68,3 +70,4 @@ export namespace StateObject {
68
70
  /** Predicate which returns true if the object is an internal [[StateObject]] object */
69
71
  function isState(obj: any): boolean;
70
72
  }
73
+ import { Glob } from "../common/glob";
@@ -89,9 +89,9 @@ export class StateRegistry {
89
89
  * If the state has children, they are are also removed from the registry.
90
90
  *
91
91
  * @param stateOrName the state's name or object representation
92
- * @returns {StateObject[]} a list of removed states
92
+ * @returns {import('./state-object').StateObject[]} a list of removed states
93
93
  */
94
- deregister(stateOrName: any): StateObject[];
94
+ deregister(stateOrName: any): import("./state-object").StateObject[];
95
95
  get(stateOrName: any, base: any, ...args: any[]): any;
96
96
  /**
97
97
  * Registers a [[BuilderFunction]] for a specific [[StateObject]] property (e.g., `parent`, `url`, or `path`).
@@ -218,7 +218,7 @@ export class Transition {
218
218
  * @param resolvable a [[ResolvableLiteral]] object (or a [[Resolvable]])
219
219
  * @param state the state in the "to path" which should receive the new resolve (otherwise, the root state)
220
220
  */
221
- addResolvable(resolvable: any, state?: string): void;
221
+ addResolvable(resolvable: any, state: any): void;
222
222
  /**
223
223
  * Gets the transition from which this transition was redirected.
224
224
  *
@@ -132,5 +132,10 @@ export class BaseUrlRule {
132
132
  $id: number;
133
133
  _group: any;
134
134
  handler: any;
135
- matchPriority(): number;
135
+ /**
136
+ * This function should be overridden
137
+ * @param {*} [params]
138
+ * @returns {number}
139
+ */
140
+ matchPriority(params?: any): number;
136
141
  }
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * A value is "injectable" if it is a function, or if it is an ng1 array-notation-style array
5
5
  * where all the elements in the array are Strings, except the last one, which is a Function
6
+ * @param {*} val
7
+ * @returns {boolean}
6
8
  */
7
9
  export function isInjectable(val: any): boolean;
8
10
  export function isNull(o: any): boolean;