@angular-wave/angular.ts 0.0.53 → 0.0.55

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 (52) hide show
  1. package/dist/angular-ts.esm.js +2 -2
  2. package/dist/angular-ts.umd.js +2 -2
  3. package/package.json +1 -1
  4. package/src/angular.spec.js +0 -8
  5. package/src/animations/animate-cache.js +48 -23
  6. package/src/animations/animate-children-directive.js +5 -0
  7. package/src/animations/animate-css-driver.js +28 -27
  8. package/src/animations/animate-css.html +40 -0
  9. package/src/animations/animate-css.js +14 -20
  10. package/src/animations/animate-queue.js +2 -4
  11. package/src/animations/animate.md +933 -0
  12. package/src/animations/animation.js +3 -3
  13. package/src/animations/module.js +0 -754
  14. package/src/animations/shared.js +5 -0
  15. package/src/binding.spec.js +0 -2
  16. package/src/core/animate/animate-runner.js +1 -1
  17. package/src/core/animate/animate.spec.js +0 -1
  18. package/src/core/compile/compile.spec.js +3 -5
  19. package/src/core/location/location.spec.js +7 -7
  20. package/src/core/url-utils/url-utils.spec.js +1 -3
  21. package/src/directive/options/options.js +2 -3
  22. package/src/directive/repeat/repeat.spec.js +1 -1
  23. package/src/exts/messages/messages.js +1 -2
  24. package/src/loader.js +0 -1
  25. package/src/public.js +0 -7
  26. package/src/router/params/param-type.js +0 -1
  27. package/src/router/params/param-types.js +1 -1
  28. package/src/router/params/param.js +6 -3
  29. package/src/router/resolve/resolve-context.js +0 -1
  30. package/src/router/state/state.spec.js +0 -3
  31. package/src/router/transition/transition-event-type.js +0 -1
  32. package/src/router/transition/transition.js +0 -1
  33. package/src/router/url/url-matcher.js +0 -2
  34. package/src/services/cookie-reader.js +2 -6
  35. package/src/services/http-backend/http-backend.js +0 -1
  36. package/src/shared/common.js +1 -12
  37. package/src/shared/hof.js +0 -1
  38. package/src/shared/utils.js +1 -89
  39. package/types/animations/animate-cache.d.ts +38 -5
  40. package/types/animations/animate-children-directive.d.ts +5 -3
  41. package/types/animations/animate-css-driver.d.ts +1 -1
  42. package/types/animations/animate-queue.d.ts +1 -1
  43. package/types/animations/module.d.ts +0 -749
  44. package/types/animations/shared.d.ts +6 -1
  45. package/types/core/animate/animate-runner.d.ts +1 -2
  46. package/types/directive/options/options.d.ts +1 -1
  47. package/types/services/cookie-reader.d.ts +1 -6
  48. package/types/services/http-backend/http-backend.d.ts +0 -1
  49. package/types/shared/common.d.ts +0 -1
  50. package/types/shared/utils.d.ts +1 -89
  51. package/src/services/document.js +0 -67
  52. package/types/services/document.d.ts +0 -41
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.53",
4
+ "version": "0.0.55",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
@@ -2049,14 +2049,6 @@ describe("angular", () => {
2049
2049
  expect(toJson({ $few: "v" }, false)).toEqual('{"$few":"v"}');
2050
2050
  });
2051
2051
 
2052
- it("should not serialize $window object", () => {
2053
- expect(toJson(window)).toEqual('"$WINDOW"');
2054
- });
2055
-
2056
- it("should not serialize $document object", () => {
2057
- expect(toJson(document)).toEqual('"$DOCUMENT"');
2058
- });
2059
-
2060
2052
  it("should not serialize scope instances", () => {
2061
2053
  expect(toJson({ key: $rootScope })).toEqual('{"key":"$SCOPE"}');
2062
2054
  });
@@ -1,50 +1,75 @@
1
- const KEY = "$$ngAnimateParentKey";
1
+ const KEY = "$animId";
2
2
  let parentCounter = 0;
3
- let cache = Object.create(null);
3
+ const cache = new Map();
4
4
 
5
5
  export function animateCache() {
6
6
  return {
7
+ /**
8
+ * Generates a unique cache key based on the node's parent and other parameters.
9
+ * @param {HTMLElement} node - The DOM node to generate the cache key for.
10
+ * @param {string} method - The animation method being applied.
11
+ * @param {string} [addClass] - Class to add during the animation.
12
+ * @param {string} [removeClass] - Class to remove during the animation.
13
+ * @returns {string} - The generated cache key.
14
+ */
7
15
  cacheKey(node, method, addClass, removeClass) {
8
16
  const { parentNode } = node;
9
- const parentID = parentNode[KEY] || (parentNode[KEY] = ++parentCounter);
17
+ const parentID = parentNode[KEY] ?? (parentNode[KEY] = ++parentCounter);
10
18
  const parts = [parentID, method, node.getAttribute("class")];
11
- if (addClass) {
12
- parts.push(addClass);
13
- }
14
- if (removeClass) {
15
- parts.push(removeClass);
16
- }
19
+ if (addClass) parts.push(addClass);
20
+ if (removeClass) parts.push(removeClass);
17
21
  return parts.join(" ");
18
22
  },
19
23
 
24
+ /**
25
+ * Checks if a cached animation without a duration exists.
26
+ * @param {string} key - The cache key to check.
27
+ * @returns {boolean} - True if an invalid animation is cached, false otherwise.
28
+ */
20
29
  containsCachedAnimationWithoutDuration(key) {
21
- const entry = cache[key];
22
-
23
- // nothing cached, so go ahead and animate
24
- // otherwise it should be a valid animation
25
- return (entry && !entry.isValid) || false;
30
+ const entry = cache.get(key);
31
+ return entry ? !entry.isValid : false;
26
32
  },
27
33
 
34
+ /**
35
+ * Clears the cache.
36
+ * @returns {void}
37
+ */
28
38
  flush() {
29
- cache = Object.create(null);
39
+ cache.clear();
30
40
  },
31
41
 
42
+ /**
43
+ * Gets the count of a specific cache entry.
44
+ * @param {string} key - The cache key to count.
45
+ * @returns {number} - The count of the cache entry.
46
+ */
32
47
  count(key) {
33
- const entry = cache[key];
34
- return entry ? entry.total : 0;
48
+ return cache.get(key)?.total ?? 0;
35
49
  },
36
50
 
51
+ /**
52
+ * Retrieves a value associated with a specific cache key.
53
+ * @param {string} key - The cache key to retrieve.
54
+ * @returns {any} - The value associated with the cache key.
55
+ */
37
56
  get(key) {
38
- const entry = cache[key];
39
- return entry && entry.value;
57
+ return cache.get(key)?.value;
40
58
  },
41
59
 
60
+ /**
61
+ * Adds or updates a cache entry.
62
+ * @param {string} key - The cache key to add or update.
63
+ * @param {any} value - The value to store.
64
+ * @param {boolean} isValid - Whether the cache entry is valid.
65
+ */
42
66
  put(key, value, isValid) {
43
- if (!cache[key]) {
44
- cache[key] = { total: 1, value, isValid };
67
+ const entry = cache.get(key);
68
+ if (entry) {
69
+ entry.total++;
70
+ entry.value = value;
45
71
  } else {
46
- cache[key].total++;
47
- cache[key].value = value;
72
+ cache.set(key, { total: 1, value, isValid });
48
73
  }
49
74
  },
50
75
  };
@@ -2,6 +2,11 @@ import { isString } from "../shared/utils";
2
2
  import { NG_ANIMATE_CHILDREN_DATA } from "./shared";
3
3
 
4
4
  $$AnimateChildrenDirective.$inject = ["$interpolate"];
5
+
6
+ /**
7
+ * @param {*} $interpolate
8
+ * @returns {import("../types").Directive}
9
+ */
5
10
  export function $$AnimateChildrenDirective($interpolate) {
6
11
  return {
7
12
  link(scope, element, attrs) {
@@ -23,10 +23,16 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
23
23
  "$animateCss",
24
24
  "$$AnimateRunner",
25
25
  "$rootElement",
26
- "$document",
27
- function ($animateCss, $$AnimateRunner, $rootElement, $document) {
28
- const bodyNode = $document[0].body;
29
- const rootNode = getDomNode($rootElement);
26
+ /**
27
+ *
28
+ * @param {*} $animateCss
29
+ * @param {typeof import('../core/animate/animate-runner').AnimateRunner} $$AnimateRunner
30
+ * @param {*} $rootElement
31
+ * @returns
32
+ */
33
+ function ($animateCss, $$AnimateRunner, $rootElement) {
34
+ const bodyNode = document.body;
35
+ const rootNode = $rootElement[0];
30
36
 
31
37
  const rootBodyElement = JQLite(
32
38
  // this is to avoid using something that exists outside of the body
@@ -42,24 +48,12 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
42
48
  ? prepareFromToAnchorAnimation(
43
49
  animationDetails.from,
44
50
  animationDetails.to,
45
- animationDetails.classes,
46
51
  animationDetails.anchors,
47
52
  )
48
53
  : prepareRegularAnimation(animationDetails);
49
54
  };
50
55
 
51
- function filterCssClasses(classes) {
52
- // remove all the `ng-` stuff
53
- return classes.replace(/\bng-\S+\b/g, "");
54
- }
55
-
56
- function getUniqueValues(a, b) {
57
- if (isString(a)) a = a.split(" ");
58
- if (isString(b)) b = b.split(" ");
59
- return a.filter((val) => b.indexOf(val) === -1).join(" ");
60
- }
61
-
62
- function prepareAnchoredAnimation(classes, outAnchor, inAnchor) {
56
+ function prepareAnchoredAnimation(outAnchor, inAnchor) {
63
57
  const clone = JQLite(getDomNode(outAnchor).cloneNode(true));
64
58
  const startingClasses = filterCssClasses(getClassVal(clone));
65
59
 
@@ -187,19 +181,15 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
187
181
  }
188
182
  }
189
183
 
190
- function prepareFromToAnchorAnimation(from, to, classes, anchors) {
184
+ function prepareFromToAnchorAnimation(from, to, anchors) {
191
185
  const fromAnimation = prepareRegularAnimation(from);
192
186
  const toAnimation = prepareRegularAnimation(to);
193
187
 
194
188
  const anchorAnimations = [];
195
- forEach(anchors, (anchor) => {
189
+ anchors.forEach((anchor) => {
196
190
  const outElement = anchor.out;
197
191
  const inElement = anchor.in;
198
- const animator = prepareAnchoredAnimation(
199
- classes,
200
- outElement,
201
- inElement,
202
- );
192
+ const animator = prepareAnchoredAnimation(outElement, inElement);
203
193
  if (animator) {
204
194
  anchorAnimations.push(animator);
205
195
  }
@@ -237,7 +227,7 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
237
227
  return runner;
238
228
 
239
229
  function endFn() {
240
- forEach(animationRunners, (runner) => {
230
+ animationRunners.forEach((runner) => {
241
231
  runner.end();
242
232
  });
243
233
  }
@@ -246,7 +236,6 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
246
236
  }
247
237
 
248
238
  function prepareRegularAnimation(animationDetails) {
249
- const { element } = animationDetails;
250
239
  const options = animationDetails.options || {};
251
240
 
252
241
  if (animationDetails.structural) {
@@ -272,14 +261,26 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
272
261
  );
273
262
  }
274
263
 
275
- const animator = $animateCss(element, options);
264
+ const animator = $animateCss(animationDetails.element, options);
276
265
 
277
266
  // the driver lookup code inside of $$animation attempts to spawn a
278
267
  // driver one by one until a driver returns a.$$willAnimate animator object.
279
268
  // $animateCss will always return an object, however, it will pass in
280
269
  // a flag as a hint as to whether an animation was detected or not
270
+
281
271
  return animator.$$willAnimate ? animator : null;
282
272
  }
283
273
  },
284
274
  ];
285
275
  }
276
+
277
+ function filterCssClasses(classes) {
278
+ // remove all the `ng-` stuff
279
+ return classes.replace(/\bng-\S+\b/g, "");
280
+ }
281
+
282
+ function getUniqueValues(a, b) {
283
+ if (isString(a)) a = a.split(" ");
284
+ if (isString(b)) b = b.split(" ");
285
+ return a.filter((val) => b.indexOf(val) === -1).join(" ");
286
+ }
@@ -0,0 +1,40 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>AngularTS Test Runner</title>
6
+
7
+ <link rel="shortcut icon" type="image/png" href="/images/favicon.ico" />
8
+
9
+ <!--
10
+ <script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.js"></script>
11
+ <script src="https://cdn.jsdelivr.net/npm/angular-animate@1.8.3/angular-animate.js"></script>
12
+ <script>window.angular.module("test", ["ngAnimate"])</script> -->
13
+
14
+ <script type="module" src="/src/index.js"></script>
15
+ <script>
16
+ document.addEventListener("DOMContentLoaded", () => {
17
+ window.angular.module("test", ["ngAnimate"]);
18
+ });
19
+ </script>
20
+
21
+ <style>
22
+ /* The starting CSS styles for the enter animation */
23
+ .fade.ng-enter {
24
+ transition: 0.5s linear all;
25
+ opacity: 0;
26
+ }
27
+
28
+ /* The finishing CSS styles for the enter animation */
29
+ .fade.ng-enter.ng-enter-active {
30
+ opacity: 1;
31
+ background-color: red;
32
+ }
33
+ </style>
34
+ </head>
35
+ <body ng-app="test">
36
+ <div ng-if="bool" class="fade">Fade me in out</div>
37
+ <button ng-click="bool=true">Fade In!</button>
38
+ <button ng-click="bool=false">Fade Out!</button>
39
+ </body>
40
+ </html>
@@ -155,7 +155,6 @@ export function $AnimateCssProvider() {
155
155
 
156
156
  function computeCachedCssStyles(
157
157
  node,
158
- className,
159
158
  cacheKey,
160
159
  allowNoDuration,
161
160
  properties,
@@ -247,10 +246,9 @@ export function $AnimateCssProvider() {
247
246
  });
248
247
  }
249
248
 
250
- function computeTimings(node, className, cacheKey, allowNoDuration) {
249
+ function computeTimings(node, cacheKey, allowNoDuration) {
251
250
  const timings = computeCachedCssStyles(
252
251
  node,
253
- className,
254
252
  cacheKey,
255
253
  allowNoDuration,
256
254
  DETECT_CSS_PROPERTIES,
@@ -343,7 +341,6 @@ export function $AnimateCssProvider() {
343
341
  let preparationClasses = [structuralClassName, addRemoveClassName]
344
342
  .join(" ")
345
343
  .trim();
346
- let fullClassName = `${classes} ${preparationClasses}`;
347
344
  const hasToStyles = styles.to && Object.keys(styles.to).length > 0;
348
345
  const containsKeyframeAnimation =
349
346
  (options.keyframeStyle || "").length > 0;
@@ -405,6 +402,7 @@ export function $AnimateCssProvider() {
405
402
 
406
403
  // we set the duration so that it will be picked up by getComputedStyle later
407
404
  applyInlineStyle(node, durationStyle);
405
+
408
406
  temporaryStyles.push(durationStyle);
409
407
  }
410
408
 
@@ -432,12 +430,7 @@ export function $AnimateCssProvider() {
432
430
  blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
433
431
  }
434
432
 
435
- let timings = computeTimings(
436
- node,
437
- fullClassName,
438
- cacheKey,
439
- !isStructural,
440
- );
433
+ let timings = computeTimings(node, cacheKey, !isStructural);
441
434
  let relativeDelay = timings.maxDelay;
442
435
  maxDelay = Math.max(relativeDelay, 0);
443
436
  maxDuration = timings.maxDuration;
@@ -485,7 +478,7 @@ export function $AnimateCssProvider() {
485
478
  return closeAndReturnNoopAnimator();
486
479
  }
487
480
 
488
- const activeClasses = pendClasses(
481
+ var activeClasses = pendClasses(
489
482
  preparationClasses,
490
483
  ACTIVE_CLASS_SUFFIX,
491
484
  );
@@ -585,15 +578,15 @@ export function $AnimateCssProvider() {
585
578
  animationPaused = false;
586
579
 
587
580
  if (preparationClasses && !options.$$skipPreparationClasses) {
588
- preparationClasses
589
- .split(" ")
590
- .forEach((cls) => element.classList.remove(cls));
581
+ preparationClasses.split(" ").forEach(function (cls) {
582
+ element[0].classList.remove(cls);
583
+ });
591
584
  }
592
-
585
+ activeClasses = pendClasses(preparationClasses, ACTIVE_CLASS_SUFFIX);
593
586
  if (activeClasses) {
594
- activeClasses
595
- .split(" ")
596
- .forEach((cls) => element.classList.remove(cls));
587
+ activeClasses.split(" ").forEach(function (cls) {
588
+ element[0].classList.remove(cls);
589
+ });
597
590
  }
598
591
 
599
592
  blockKeyframeAnimations(node, false);
@@ -782,7 +775,8 @@ export function $AnimateCssProvider() {
782
775
  });
783
776
 
784
777
  applyAnimationClasses(element, options);
785
- element.className += ` ${activeClasses}`;
778
+
779
+ element[0].classList.add(activeClasses);
786
780
  if (flags.recalculateTimingStyles) {
787
781
  fullClassName = `${node.getAttribute("class")} ${preparationClasses}`;
788
782
  cacheKey = $$animateCache.cacheKey(
@@ -792,7 +786,7 @@ export function $AnimateCssProvider() {
792
786
  options.removeClass,
793
787
  );
794
788
 
795
- timings = computeTimings(node, fullClassName, cacheKey, false);
789
+ timings = computeTimings(node, cacheKey, false);
796
790
  relativeDelay = timings.maxDelay;
797
791
  maxDelay = Math.max(relativeDelay, 0);
798
792
  maxDuration = timings.maxDuration;
@@ -146,14 +146,12 @@ export function $$AnimateQueueProvider($animateProvider) {
146
146
  this.$get = [
147
147
  "$rootScope",
148
148
  "$rootElement",
149
- "$document",
150
149
  "$$animation",
151
150
  "$$AnimateRunner",
152
151
  "$templateRequest",
153
152
  function (
154
153
  $rootScope,
155
154
  $rootElement,
156
- $document,
157
155
  $$animation,
158
156
  $$AnimateRunner,
159
157
  $templateRequest,
@@ -393,7 +391,7 @@ export function $$AnimateQueueProvider($animateProvider) {
393
391
  // we always make a copy of the options since
394
392
  // there should never be any side effects on
395
393
  // the input data when running `$animateCss`.
396
- let options = structuredClone(initialOptions);
394
+ let options = initialOptions;
397
395
 
398
396
  let element = stripCommentsFromElement(originalElement);
399
397
  const node = getDomNode(element);
@@ -739,7 +737,7 @@ export function $$AnimateQueueProvider($animateProvider) {
739
737
  * d) the element is not a child of the $rootElement
740
738
  */
741
739
  function areAnimationsAllowed(node, parentNode) {
742
- const bodyNode = $document[0].body;
740
+ const bodyNode = document.body;
743
741
  const rootNode = getDomNode($rootElement);
744
742
 
745
743
  let bodyNodeDetected = node === bodyNode || node.nodeName === "HTML";