@angular-wave/angular.ts 0.0.70 → 0.0.71

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.
@@ -29,11 +29,6 @@ $interpolateMinErr.interr = function (text, err) {
29
29
  };
30
30
 
31
31
  /**
32
- * @ngdoc provider
33
- * @name $interpolateProvider
34
- *
35
- *
36
- * @description
37
32
  *
38
33
  * Used for configuring the interpolation markup. Defaults to `{{` and `}}`.
39
34
  *
@@ -50,9 +45,6 @@ export function $InterpolateProvider() {
50
45
  let endSymbol = "}}";
51
46
 
52
47
  /**
53
- * @ngdoc method
54
- * @name $interpolateProvider#startSymbol
55
- * @description
56
48
  * Symbol to denote start of expression in the interpolated string. Defaults to `{{`.
57
49
  *
58
50
  * @param {string=} value new value to set the starting symbol to.
@@ -67,9 +59,6 @@ export function $InterpolateProvider() {
67
59
  };
68
60
 
69
61
  /**
70
- * @ngdoc method
71
- * @name $interpolateProvider#endSymbol
72
- * @description
73
62
  * Symbol to denote the end of expression in the interpolated string. Defaults to `}}`.
74
63
  *
75
64
  * @param {string=} value new value to set the ending symbol to.
@@ -89,7 +78,7 @@ export function $InterpolateProvider() {
89
78
  "$sce",
90
79
  /**
91
80
  *
92
- * @param {*} $parse
81
+ * @param {import("../parser/parse").ParseService} $parse
93
82
  * @param {import('../exception-handler').ErrorHandler} $exceptionHandler
94
83
  * @param {*} $sce
95
84
  * @returns
@@ -333,6 +333,19 @@ export class Location {
333
333
 
334
334
  return this;
335
335
  }
336
+
337
+ /**
338
+ * @param {string} _url
339
+ * @param {string} _url2
340
+ * @returns {boolean}
341
+ */
342
+ $$parseLinkUrl(_url, _url2) {
343
+ throw new Error(`Method not implemented ${_url} ${_url2}`);
344
+ }
345
+
346
+ $$parse(_url) {
347
+ throw new Error(`Method not implemented ${_url}`);
348
+ }
336
349
  }
337
350
 
338
351
  /**
@@ -379,7 +392,12 @@ export class LocationHtml5Url extends Location {
379
392
  return this.appBaseNoFile + url.substr(1); // first char is always '/'
380
393
  }
381
394
 
382
- $$parseLinkUrl = function (url, relHref) {
395
+ /**
396
+ * @param {string} url
397
+ * @param {string} relHref
398
+ * @returns {boolean}
399
+ */
400
+ $$parseLinkUrl(url, relHref) {
383
401
  if (relHref && relHref[0] === "#") {
384
402
  // special case for links to hash fragments:
385
403
  // keep the old url and only replace the hash fragment
@@ -410,7 +428,7 @@ export class LocationHtml5Url extends Location {
410
428
  this.$$parse(rewrittenUrl);
411
429
  }
412
430
  return !!rewrittenUrl;
413
- };
431
+ }
414
432
  }
415
433
 
416
434
  /**
@@ -513,6 +531,10 @@ export class LocationHashbangUrl extends Location {
513
531
  return this.appBase + (url ? this.hashPrefix + url : "");
514
532
  }
515
533
 
534
+ /**
535
+ * @param {string} url
536
+ * @returns {boolean}
537
+ */
516
538
  $$parseLinkUrl(url) {
517
539
  if (stripHash(this.appBase) === stripHash(url)) {
518
540
  this.$$parse(url);
@@ -602,7 +624,7 @@ export function $LocationProvider() {
602
624
  let $location;
603
625
  let LocationMode;
604
626
  const baseHref = $browser.baseHref(); // if base[href] is undefined, it defaults to ''
605
- const initialUrl = $browser.url();
627
+ const initialUrl = /** @type {string} */ ($browser.url());
606
628
  let appBase;
607
629
 
608
630
  if (html5Mode.enabled) {
@@ -639,7 +661,7 @@ export function $LocationProvider() {
639
661
  $location.$$state = $browser.state();
640
662
  } catch (e) {
641
663
  // Restore old values if pushState fails
642
- $location.url(oldUrl);
664
+ $location.url(/** @type {string} */ (oldUrl));
643
665
  $location.$$state = oldState;
644
666
 
645
667
  throw e;
@@ -7,11 +7,11 @@ import { Parser } from "./parser";
7
7
  * @typedef {Object} CompiledExpressionProps
8
8
  * @property {boolean} literal - Indicates if the expression is a literal.
9
9
  * @property {boolean} constant - Indicates if the expression is constant.
10
- * @property {boolean} isPure
10
+ * @property {boolean} [isPure]
11
11
  * @property {boolean} oneTime
12
- * @property {function(import('../scope/scope').Scope, import('../scope/scope').WatchListener, boolean, CompiledExpression, string | ((scope: import('../scope/scope').Scope) => any)): any} $$watchDelegate
13
- * @property {any[]} inputs
14
- * @property {function(any, any): any} assign - Assigns a value to a context. If value is not provided,
12
+ * @property {function(import('../scope/scope').Scope, import('../scope/scope').WatchListener, boolean, CompiledExpression, string | ((scope: import('../scope/scope').Scope) => any) | CompiledExpression): any} [$$watchDelegate]
13
+ * @property {any[]|Function} inputs
14
+ * @property {function(any, any): any} [assign] - Assigns a value to a context. If value is not provided,
15
15
  */
16
16
 
17
17
  /**
@@ -30,7 +30,7 @@ import { Parser } from "./parser";
30
30
  */
31
31
 
32
32
  /**
33
- * @typedef {function(string|function(import('../scope/scope').Scope):any, function(any, import('../scope/scope').Scope, any):any=, boolean=): CompiledExpression} ParseService
33
+ * @typedef {function(CompiledExpression|string|function(import('../scope/scope').Scope):any, function(any, import('../scope/scope').Scope, any):any=, boolean=): CompiledExpression} ParseService
34
34
  */
35
35
 
36
36
  export function $ParseProvider() {
@@ -219,21 +219,22 @@ function inputsWatchDelegate(
219
219
  objectEquality,
220
220
  parsedExpression,
221
221
  ) {
222
- let inputExpressions = parsedExpression.inputs;
222
+ let inputExpressions = /** @type {Function} */ (parsedExpression.inputs);
223
223
  let lastResult;
224
224
 
225
225
  if (inputExpressions.length === 1) {
226
226
  let oldInputValueOf = expressionInputDirtyCheck; // init to something unique so that equals check fails
227
227
 
228
- inputExpressions = inputExpressions[0];
228
+ let inputExpression = inputExpressions[0];
229
+
229
230
  return scope.$watch(
230
231
  ($scope) => {
231
- const newInputValue = inputExpressions($scope);
232
+ const newInputValue = inputExpression($scope);
232
233
  if (
233
234
  !expressionInputDirtyCheck(
234
235
  newInputValue,
235
236
  oldInputValueOf,
236
- inputExpressions.isPure,
237
+ inputExpression.isPure,
237
238
  )
238
239
  ) {
239
240
  lastResult = parsedExpression($scope, undefined, undefined, [
@@ -246,48 +247,49 @@ function inputsWatchDelegate(
246
247
  listener,
247
248
  objectEquality,
248
249
  );
249
- }
250
-
251
- const oldInputValueOfValues = [];
252
- const oldInputValues = [];
253
- for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
254
- oldInputValueOfValues[i] = expressionInputDirtyCheck; // init to something unique so that equals check fails
255
- oldInputValues[i] = null;
256
- }
257
-
258
- return scope.$watch(
259
- (scope) => {
260
- let changed = false;
250
+ } else {
251
+ const oldInputValueOfValues = [];
252
+ const oldInputValues = [];
253
+ for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
254
+ oldInputValueOfValues[i] = expressionInputDirtyCheck; // init to something unique so that equals check fails
255
+ oldInputValues[i] = null;
256
+ }
261
257
 
262
- for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
263
- const newInputValue = inputExpressions[i](scope);
264
- if (
265
- changed ||
266
- (changed = !expressionInputDirtyCheck(
267
- newInputValue,
268
- oldInputValueOfValues[i],
269
- inputExpressions[i].isPure,
270
- ))
271
- ) {
272
- oldInputValues[i] = newInputValue;
273
- oldInputValueOfValues[i] = newInputValue && getValueOf(newInputValue);
258
+ return scope.$watch(
259
+ (scope) => {
260
+ let changed = false;
261
+
262
+ for (let i = 0, ii = inputExpressions.length; i < ii; i++) {
263
+ const newInputValue = inputExpressions[i](scope);
264
+ if (
265
+ changed ||
266
+ (changed = !expressionInputDirtyCheck(
267
+ newInputValue,
268
+ oldInputValueOfValues[i],
269
+ inputExpressions[i].isPure,
270
+ ))
271
+ ) {
272
+ oldInputValues[i] = newInputValue;
273
+ oldInputValueOfValues[i] =
274
+ newInputValue && getValueOf(newInputValue);
275
+ }
274
276
  }
275
- }
276
277
 
277
- if (changed) {
278
- lastResult = parsedExpression(
279
- scope,
280
- undefined,
281
- undefined,
282
- oldInputValues,
283
- );
284
- }
278
+ if (changed) {
279
+ lastResult = parsedExpression(
280
+ scope,
281
+ undefined,
282
+ undefined,
283
+ oldInputValues,
284
+ );
285
+ }
285
286
 
286
- return lastResult;
287
- },
288
- listener,
289
- objectEquality,
290
- );
287
+ return lastResult;
288
+ },
289
+ listener,
290
+ objectEquality,
291
+ );
292
+ }
291
293
  }
292
294
 
293
295
  function oneTimeWatchDelegate(
@@ -311,6 +313,7 @@ function oneTimeWatchDelegate(
311
313
  oneTimeWatch.literal = parsedExpression.literal;
312
314
  oneTimeWatch.constant = parsedExpression.constant;
313
315
  oneTimeWatch.inputs = parsedExpression.inputs;
316
+ oneTimeWatch.oneTime = undefined;
314
317
 
315
318
  // Allow other delegates to run on this wrapped expression
316
319
  addWatchDelegate(oneTimeWatch);
@@ -386,7 +386,7 @@ export class Scope {
386
386
  *
387
387
  *
388
388
  *
389
- * @param {string | ((scope: Scope) => any)} watchExp Expression that is evaluated on each
389
+ * @param {string | ((scope: Scope) => any) | import("../parser/parse").CompiledExpression} watchExp Expression that is evaluated on each
390
390
  * {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers
391
391
  * a call to the `listener`.
392
392
  *
@@ -1074,12 +1074,8 @@ export class Scope {
1074
1074
  this.$$nextSibling.$$prevSibling = this.$$prevSibling;
1075
1075
 
1076
1076
  // Disable listeners, watchers and apply/digest methods
1077
- this.$destroy =
1078
- this.$digest =
1079
- this.$apply =
1080
- this.$evalAsync =
1081
- this.$applyAsync =
1082
- () => {};
1077
+ this.$destroy = this.$digest = this.$apply = this.$applyAsync = () => {};
1078
+ this.$evalAsync = () => undefined;
1083
1079
  this.$on =
1084
1080
  this.$watch =
1085
1081
  this.$watchGroup =
@@ -1358,6 +1354,7 @@ export class Scope {
1358
1354
  * @param {string} name
1359
1355
  */
1360
1356
  decrementListenerCount(count, name) {
1357
+ /** @type {Scope} */
1361
1358
  let self = this;
1362
1359
  for (; self; self = self.$parent) {
1363
1360
  if (self.$$listenerCount[name] !== undefined) {
@@ -109,6 +109,7 @@ export function FormController(
109
109
  this.$valid = true;
110
110
  this.$invalid = false;
111
111
  this.$submitted = false;
112
+ /** @type {FormController|Object} */
112
113
  this.$$parentForm = nullFormCtrl;
113
114
 
114
115
  this.$$element = $element;
@@ -326,6 +327,7 @@ FormController.prototype = {
326
327
  * parent forms of the form.
327
328
  */
328
329
  $setSubmitted() {
330
+ /** @type {FormController} */
329
331
  let rootForm = this;
330
332
  while (rootForm.$$parentForm && rootForm.$$parentForm !== nullFormCtrl) {
331
333
  rootForm = rootForm.$$parentForm;
@@ -589,7 +591,7 @@ const formDirectiveFactory = function (isNgForm) {
589
591
  };
590
592
 
591
593
  export const formDirective = formDirectiveFactory();
592
- export const ngFormDirective = formDirectiveFactory(true);
594
+ export const ngFormDirective = formDirectiveFactory("ngForm");
593
595
 
594
596
  // helper methods
595
597
  export function setupValidity(instance) {
@@ -11,17 +11,18 @@ export function ngMessagesDirective($animate) {
11
11
  const ctrl = this;
12
12
  let latestKey = 0;
13
13
  let nextAttachId = 0;
14
+ const messages = {};
15
+ let renderLater;
16
+ let cachedCollection;
17
+
14
18
  this.head = undefined;
15
19
  this.default = undefined;
20
+ this.messages = messages;
16
21
 
17
22
  this.getAttachId = function getAttachId() {
18
23
  return nextAttachId++;
19
24
  };
20
25
 
21
- const messages = (this.messages = {});
22
- let renderLater;
23
- let cachedCollection;
24
-
25
26
  this.render = function (collection) {
26
27
  collection = collection || {};
27
28
 
@@ -22,12 +22,10 @@ export class StateObject {
22
22
  * @returns {StateObject} an internal State object
23
23
  */
24
24
  static create(stateDecl) {
25
- const state = StateObject.isStateClass(stateDecl)
26
- ? new stateDecl()
27
- : Object.setPrototypeOf(
28
- Object.assign({}, stateDecl),
29
- StateObject.prototype,
30
- );
25
+ const state = Object.setPrototypeOf(
26
+ Object.assign({}, stateDecl),
27
+ StateObject.prototype,
28
+ );
31
29
  stateDecl.$$state = () => state;
32
30
  state.self = stateDecl;
33
31
  state.__stateObjectCache = {
@@ -110,9 +108,6 @@ export class StateObject {
110
108
  return this.fqn();
111
109
  }
112
110
  }
113
- /** Predicate which returns true if the object is an class with @State() decorator */
114
- StateObject.isStateClass = (stateDecl) =>
115
- isFunction(stateDecl) && stateDecl["__uiRouterState"] === true;
116
111
  /** Predicate which returns true if the object is a [[StateDeclaration]] object */
117
112
  StateObject.isStateDeclaration = (obj) => isFunction(obj["$$state"]);
118
113
  /** Predicate which returns true if the object is an internal [[StateObject]] object */
@@ -406,7 +406,7 @@ export class UrlMatcher {
406
406
  *
407
407
  * @param id
408
408
  * @param opts
409
- * @returns {T|Param|any|boolean|UrlMatcher|null}
409
+ * @returns {Param|any|boolean|UrlMatcher|null}
410
410
  */
411
411
  parameter(id, opts = {}) {
412
412
  const findParam = () => {
@@ -203,7 +203,11 @@ export class BaseUrlRule {
203
203
  this.match = match;
204
204
  this.type = "RAW";
205
205
  this.$id = -1;
206
- this.matchPriority = () => 0 - this.$id;
206
+ this._group = undefined;
207
207
  this.handler = handler || ((x) => x);
208
208
  }
209
+
210
+ matchPriority() {
211
+ return 0 - this.$id;
212
+ }
209
213
  }
@@ -356,7 +356,7 @@ export class UrlService {
356
356
  return;
357
357
  }
358
358
  if (this.url() === this.location) return;
359
- this.url(this.location, true);
359
+ this.url(/** @type {string} */ (this.location), true);
360
360
  }
361
361
 
362
362
  /**
@@ -62,7 +62,7 @@ const BOOLEAN_ELEMENTS = {};
62
62
  * JQLite both a function and an array-like data structure for manipulation of DOM, linking elements to expando cache,
63
63
  * and execution of chain functions.
64
64
  *
65
- * @param {string|Node|JQLite|ArrayLike<Element>|(() => void)|Window} element
65
+ * @param {string|Node|Node[]|NodeList|JQLite|ArrayLike<Element>|(() => void)|Window} element
66
66
  * @returns {JQLite}
67
67
  */
68
68
  export function JQLite(element) {
@@ -116,6 +116,18 @@ JQLite.prototype = {
116
116
  length: 0,
117
117
  };
118
118
 
119
+ /**
120
+ * @returns {Element[]}
121
+ */
122
+ JQLite.prototype.elements = function () {
123
+ /** @type {Element[]} */
124
+ let elements = [];
125
+ for (let index = 0; index < this.length; index++) {
126
+ elements.push(this[index]);
127
+ }
128
+ return elements;
129
+ };
130
+
119
131
  /**
120
132
  * Remove all child nodes of the set of matched elements from the DOM and clears CACHE data, associated with the node.
121
133
  * @returns {JQLite} The current instance of JQLite.
package/src/types.js CHANGED
@@ -217,7 +217,7 @@
217
217
  /**
218
218
 
219
219
  *
220
- * @typedef {function(TScope, CloneAttachFunction, import('./shared/jqlite/jqlite').JQLite=, string=): import('./shared/jqlite/jqlite').JQLite} TranscludeFunction
220
+ * @typedef {function(TScope|Function, CloneAttachFunction=, import('./shared/jqlite/jqlite').JQLite=, string=): import('./shared/jqlite/jqlite').JQLite} TranscludeFunction
221
221
  */
222
222
 
223
223
  /**
@@ -6,12 +6,17 @@ export function packageStyles(options: any): {
6
6
  };
7
7
  export function pendClasses(classes: any, fix: any, isPrefix: any): string;
8
8
  export function removeFromArray(arr: any, val: any): void;
9
- export function stripCommentsFromElement(element: any): JQLite | {
10
- toString(): string;
11
- eq(index: any): JQLite;
12
- length: number;
13
- };
14
- export function extractElementNode(element: any): any;
9
+ /**
10
+ *
11
+ * @param {JQLite|Node} element
12
+ * @returns {JQLite}
13
+ */
14
+ export function stripCommentsFromElement(element: JQLite | Node): JQLite;
15
+ /**
16
+ * @param {JQLite|Node} element
17
+ * @returns {Node}
18
+ */
19
+ export function extractElementNode(element: JQLite | Node): Node;
15
20
  export function applyAnimationClassesFactory(): (element: any, options: any) => void;
16
21
  export function prepareAnimationOptions(options: any): any;
17
22
  export function applyAnimationStyles(element: any, options: any): void;
@@ -0,0 +1,101 @@
1
+ export class Attributes {
2
+ /**
3
+ *
4
+ * @param {import('../scope/scope').Scope} $rootScope
5
+ * @param {*} $animate
6
+ * @param {import("../exception-handler").ExceptionHandlerProvider} $exceptionHandler
7
+ * @param {*} $sce
8
+ * @param {import('../../shared/jqlite/jqlite').JQLite} [element]
9
+ * @param {*} [attributesToCopy]
10
+ */
11
+ constructor($rootScope: import("../scope/scope").Scope, $animate: any, $exceptionHandler: import("../exception-handler").ExceptionHandlerProvider, $sce: any, element?: import("../../shared/jqlite/jqlite").JQLite, attributesToCopy?: any);
12
+ $rootScope: import("../scope/scope").Scope;
13
+ $animate: any;
14
+ $exceptionHandler: any;
15
+ $sce: any;
16
+ $attr: {};
17
+ $$element: import("../../shared/jqlite/jqlite").JQLite;
18
+ /**
19
+ * @ngdoc method
20
+ * @name $compile.directive.Attributes#$normalize
21
+ * @kind function
22
+ *
23
+ * @description
24
+ * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with `x-` or
25
+ * `data-`) to its normalized, camelCase form.
26
+ *
27
+ * Also there is special case for Moz prefix starting with upper case letter.
28
+ *
29
+ * For further information check out the guide on {@link guide/directive#matching-directives Matching Directives}
30
+ *
31
+ * @param {string} name Name to normalize
32
+ */
33
+ $normalize: typeof directiveNormalize;
34
+ /**
35
+ * @ngdoc method
36
+ * @name $compile.directive.Attributes#$addClass
37
+ * @kind function
38
+ *
39
+ * @description
40
+ * Adds the CSS class value specified by the classVal parameter to the element. If animations
41
+ * are enabled then an animation will be triggered for the class addition.
42
+ *
43
+ * @param {string} classVal The className value that will be added to the element
44
+ */
45
+ $addClass(classVal: string): void;
46
+ /**
47
+ * @ngdoc method
48
+ * @name $compile.directive.Attributes#$removeClass
49
+ * @kind function
50
+ *
51
+ * @description
52
+ * Removes the CSS class value specified by the classVal parameter from the element. If
53
+ * animations are enabled then an animation will be triggered for the class removal.
54
+ *
55
+ * @param {string} classVal The className value that will be removed from the element
56
+ */
57
+ $removeClass(classVal: string): void;
58
+ /**
59
+ * @ngdoc method
60
+ * @name $compile.directive.Attributes#$updateClass
61
+ * @kind function
62
+ *
63
+ * @description
64
+ * Adds and removes the appropriate CSS class values to the element based on the difference
65
+ * between the new and old CSS class values (specified as newClasses and oldClasses).
66
+ *
67
+ * @param {string} newClasses The current CSS className value
68
+ * @param {string} oldClasses The former CSS className value
69
+ */
70
+ $updateClass(newClasses: string, oldClasses: string): void;
71
+ /**
72
+ * Set a normalized attribute on the element in a way such that all directives
73
+ * can share the attribute. This function properly handles boolean attributes.
74
+ * @param {string} key Normalized key. (ie ngAttribute)
75
+ * @param {string|boolean} value The value to set. If `null` attribute will be deleted.
76
+ * @param {boolean=} writeAttr If false, does not write the value to DOM element attribute.
77
+ * Defaults to true.
78
+ * @param {string=} attrName Optional none normalized name. Defaults to key.
79
+ */
80
+ $set(key: string, value: string | boolean, writeAttr?: boolean | undefined, attrName?: string | undefined): void;
81
+ /**
82
+ * Observes an interpolated attribute.
83
+ *
84
+ * The observer function will be invoked once during the next `$digest` following
85
+ * compilation. The observer is then invoked whenever the interpolated value
86
+ * changes.
87
+ *
88
+ * @param {string} key Normalized key. (ie ngAttribute) .
89
+ * @param {any} fn Function that will be called whenever
90
+ the interpolated value of the attribute changes.
91
+ * See the {@link guide/interpolation#how-text-and-attribute-bindings-work Interpolation
92
+ * guide} for more info.
93
+ * @returns {function()} Returns a deregistration function for this observer.
94
+ */
95
+ $observe(key: string, fn: any): () => any;
96
+ $$observers: any;
97
+ setSpecialAttr(element: any, attrName: any, value: any): void;
98
+ sanitizeSrcset(value: any, invokeType: any): any;
99
+ srcset: any;
100
+ }
101
+ import { directiveNormalize } from "../../shared/utils";