@angular-wave/angular.ts 0.0.70 → 0.0.72

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 (83) 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/animations/animate-children-directive.md +1 -1
  5. package/src/animations/animate-css-driver.js +1 -1
  6. package/src/animations/animate-css.html +2 -2
  7. package/src/animations/animate-js.html +1 -1
  8. package/src/animations/animate-queue.js +4 -4
  9. package/src/animations/animate-swap.md +1 -1
  10. package/src/{core/animate → animations}/animate.html +1 -1
  11. package/src/{core/animate → animations}/animate.js +4 -120
  12. package/src/animations/raf-scheduler.js +7 -3
  13. package/src/animations/raf-scheduler.spec.js +3 -3
  14. package/src/animations/shared.js +16 -7
  15. package/src/binding.spec.js +4 -3
  16. package/src/core/compile/attributes.js +326 -0
  17. package/src/core/compile/compile.js +76 -433
  18. package/src/core/compile/compile.spec.js +45 -28
  19. package/src/core/di/injector.md +1 -1
  20. package/src/core/di/ng-module.js +46 -3
  21. package/src/core/interpolate/interpolate.js +1 -12
  22. package/src/core/location/location.js +26 -4
  23. package/src/core/parser/parse.js +50 -47
  24. package/src/core/prop.spec.js +15 -11
  25. package/src/core/scope/scope.js +4 -7
  26. package/src/directive/bind/bind.spec.js +80 -44
  27. package/src/directive/class/class.js +43 -14
  28. package/src/directive/class/class.spec.js +7 -4
  29. package/src/directive/form/form.js +3 -1
  30. package/src/directive/form/form.spec.js +3 -4
  31. package/src/directive/if/if-animate-css.html +5 -7
  32. package/src/directive/if/if.js +1 -1
  33. package/src/directive/if/if.spec.js +3 -2
  34. package/src/directive/include/include.js +1 -1
  35. package/src/directive/input/input.spec.js +6 -4
  36. package/src/directive/list/list.spec.js +4 -2
  37. package/src/directive/messages/messages.js +5 -4
  38. package/src/directive/messages/messages.spec.js +4 -4
  39. package/src/directive/model/model.spec.js +4 -3
  40. package/src/directive/model-options/model-options.spec.js +3 -1
  41. package/src/directive/repeat/repeat.md +1 -1
  42. package/src/directive/repeat/repeat.spec.js +1 -1
  43. package/src/directive/select/select.spec.js +3 -3
  44. package/src/directive/show-hide/show-hide.js +36 -6
  45. package/src/directive/switch/switch.spec.js +5 -2
  46. package/src/directive/validators/validators.spec.js +6 -4
  47. package/src/loader.js +1 -2
  48. package/src/public.js +22 -10
  49. package/src/router/state/state-object.js +4 -9
  50. package/src/router/url/url-matcher.js +1 -1
  51. package/src/router/url/url-rule.js +5 -1
  52. package/src/router/url/url-service.js +1 -1
  53. package/src/services/anchor-scroll.html +1 -1
  54. package/src/shared/jqlite/jqlite.js +14 -2
  55. package/src/types.js +1 -1
  56. package/types/animations/animate-css-driver.d.ts +1 -1
  57. package/types/animations/animate-queue.d.ts +1 -2
  58. package/types/{core/animate → animations}/animate.d.ts +2 -12
  59. package/types/animations/raf-scheduler.d.ts +7 -2
  60. package/types/animations/shared.d.ts +11 -6
  61. package/types/core/compile/attributes.d.ts +101 -0
  62. package/types/core/compile/compile.d.ts +10 -67
  63. package/types/core/di/ng-module.d.ts +55 -12
  64. package/types/core/interpolate/interpolate.d.ts +1 -12
  65. package/types/core/location/location.d.ts +12 -2
  66. package/types/core/parser/parse.d.ts +10 -10
  67. package/types/core/scope/scope.d.ts +20 -20
  68. package/types/directive/form/form.d.ts +2 -11
  69. package/types/router/state/state-object.d.ts +0 -2
  70. package/types/router/url/url-matcher.d.ts +2 -2
  71. package/types/router/url/url-rule.d.ts +2 -1
  72. package/types/shared/jqlite/jqlite.d.ts +10 -6
  73. package/types/types.d.ts +1 -1
  74. package/src/animations/module.js +0 -25
  75. package/src/core/animate/animate-css.js +0 -88
  76. package/src/core/animate/anomate.md +0 -13
  77. package/types/animations/module.d.ts +0 -1
  78. package/types/core/animate/animate-css.d.ts +0 -19
  79. /package/src/{core/animate → animations}/animate-runner.js +0 -0
  80. /package/src/{core/animate → animations}/animate.spec.js +0 -0
  81. /package/src/{core/animate → animations}/helpers.js +0 -0
  82. /package/types/{core/animate → animations}/animate-runner.d.ts +0 -0
  83. /package/types/{core/animate → animations}/helpers.d.ts +0 -0
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "description": "A modern, optimized and typesafe version of AngularJS",
4
4
  "license": "MIT",
5
- "version": "0.0.70",
5
+ "version": "0.0.72",
6
6
  "type": "module",
7
7
  "main": "dist/angular-ts.esm.js",
8
8
  "browser": "dist/angular-ts.umd.js",
@@ -70,7 +70,7 @@
70
70
 
71
71
  </file>
72
72
  <file name="script.js">
73
- angular.module('ngAnimateChildren', ['ngAnimate'])
73
+ angular.module('ngAnimateChildren', [])
74
74
  .controller('MainController', function MainController() {
75
75
  this.animateChildren = false;
76
76
  this.enterElement = false;
@@ -26,7 +26,7 @@ export function $$AnimateCssDriverProvider($$animationProvider) {
26
26
  /**
27
27
  *
28
28
  * @param {*} $animateCss
29
- * @param {typeof import('../core/animate/animate-runner').AnimateRunner} $$AnimateRunner
29
+ * @param {typeof import('./animate-runner').AnimateRunner} $$AnimateRunner
30
30
  * @param {JQLite} $rootElement
31
31
  * @returns
32
32
  */
@@ -9,12 +9,12 @@
9
9
  <!--
10
10
  <script src="https://cdn.jsdelivr.net/npm/angular@1.8.3/angular.js"></script>
11
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> -->
12
+ <script>window.angular.module("test", [])</script> -->
13
13
 
14
14
  <script type="module" src="/src/index.js"></script>
15
15
  <script>
16
16
  document.addEventListener("DOMContentLoaded", () => {
17
- window.angular.module("test", ["ngAnimate"]);
17
+ window.angular.module("test", []);
18
18
  });
19
19
  </script>
20
20
 
@@ -9,7 +9,7 @@
9
9
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.2/lib/anime.min.js"></script>
10
10
  <script>
11
11
  document.addEventListener("DOMContentLoaded", () => {
12
- window.angular.module("test", ["ngAnimate"]).animation(".colorful", [
12
+ window.angular.module("test", []).animation(".colorful", [
13
13
  function () {
14
14
  return {
15
15
  addClass: function (element, className, doneFn) {
@@ -145,14 +145,14 @@ export function $$AnimateQueueProvider($animateProvider) {
145
145
 
146
146
  this.$get = [
147
147
  "$rootScope",
148
- "$rootElement",
148
+ "$injector",
149
149
  "$$animation",
150
150
  "$$AnimateRunner",
151
151
  "$templateRequest",
152
152
  /**
153
153
  *
154
154
  * @param {*} $rootScope
155
- * @param {JQLite} $rootElement
155
+ * @param {*} $injector
156
156
  * @param {*} $$animation
157
157
  * @param {*} $$AnimateRunner
158
158
  * @param {*} $templateRequest
@@ -160,7 +160,7 @@ export function $$AnimateQueueProvider($animateProvider) {
160
160
  */
161
161
  function (
162
162
  $rootScope,
163
- $rootElement,
163
+ $injector,
164
164
  $$animation,
165
165
  $$AnimateRunner,
166
166
  $templateRequest,
@@ -747,7 +747,7 @@ export function $$AnimateQueueProvider($animateProvider) {
747
747
  */
748
748
  function areAnimationsAllowed(node, parentNode) {
749
749
  const bodyNode = document.body;
750
- const rootNode = getDomNode($rootElement);
750
+ const rootNode = getDomNode($injector.get("$rootElement"));
751
751
 
752
752
  let bodyNodeDetected = node === bodyNode || node.nodeName === "HTML";
753
753
  let rootNodeDetected = node === rootNode;
@@ -32,7 +32,7 @@
32
32
  - </div>
33
33
  - </file>
34
34
  - <file name="script.js">
35
- - angular.module('ngAnimateSwapExample', ['ngAnimate'])
35
+ - angular.module('ngAnimateSwapExample', [])
36
36
  - .controller('AppCtrl', ['$scope', '$interval', function($scope, $interval) {
37
37
  - $scope.number = 0;
38
38
  - $interval(function() {
@@ -10,7 +10,7 @@
10
10
  <script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
11
11
  <script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
12
12
  <script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
13
- <script type="module" src="/src/core/animate/animate.spec.js"></script>
13
+ <script type="module" src="/src/animations/animate.spec.js"></script>
14
14
  </head>
15
15
  <body>
16
16
  <div id="dummy"></div>
@@ -5,10 +5,9 @@ import {
5
5
  isString,
6
6
  minErr,
7
7
  extend,
8
- } from "../../shared/utils";
9
- import { JQLite } from "../../shared/jqlite/jqlite";
10
- import { NG_ANIMATE_CLASSNAME } from "../../animations/shared";
11
- import { addInlineStyles } from "./helpers";
8
+ } from "../shared/utils";
9
+ import { JQLite } from "../shared/jqlite/jqlite";
10
+ import { NG_ANIMATE_CLASSNAME } from "./shared";
12
11
 
13
12
  /** @typedef {"enter"|"leave"|"move"|"addClass"|"setClass"|"removeClass"} AnimationMethod */
14
13
 
@@ -70,121 +69,6 @@ function prepareAnimateOptions(options) {
70
69
  return isObject(options) ? options : {};
71
70
  }
72
71
 
73
- // this is prefixed with Core since it conflicts with
74
- // the animateQueueProvider defined in ngAnimate/animateQueue.js
75
- export function CoreAnimateQueueProvider() {
76
- const postDigestQueue = new Map();
77
- const postDigestElements = [];
78
-
79
- this.$get = [
80
- "$$AnimateRunner",
81
- "$rootScope",
82
- function ($$AnimateRunner, $rootScope) {
83
- return {
84
- enabled: () => {},
85
- on: () => {},
86
- off: () => {},
87
- pin: () => {},
88
-
89
- push(element, event, options, domOperation) {
90
- if (domOperation) {
91
- domOperation();
92
- }
93
-
94
- options = options || {};
95
- if (options.from) {
96
- addInlineStyles(element[0], options.from);
97
- }
98
- if (options.to) {
99
- addInlineStyles(element[0], options.to);
100
- }
101
-
102
- if (options.addClass || options.removeClass) {
103
- addRemoveClassesPostDigest(
104
- element,
105
- options.addClass,
106
- options.removeClass,
107
- );
108
- }
109
-
110
- const runner = new $$AnimateRunner();
111
-
112
- // since there are no animations to run the runner needs to be
113
- // notified that the animation call is complete.
114
- runner.complete();
115
- return runner;
116
- },
117
- };
118
-
119
- function updateData(data, classes, value) {
120
- let changed = false;
121
- if (classes) {
122
- classes = isString(classes)
123
- ? classes.split(" ")
124
- : Array.isArray(classes)
125
- ? classes
126
- : [];
127
- forEach(classes, (className) => {
128
- if (className) {
129
- changed = true;
130
- data[className] = value;
131
- }
132
- });
133
- }
134
- return changed;
135
- }
136
-
137
- function handleCSSClassChanges() {
138
- forEach(postDigestElements, function (element) {
139
- const data = postDigestQueue.get(element);
140
- if (data) {
141
- const existing = splitClasses(element.attr("class"));
142
- let toAdd = "";
143
- let toRemove = "";
144
- forEach(data, function (status, className) {
145
- const hasClass = !!existing[className];
146
- if (status !== hasClass) {
147
- if (status) {
148
- toAdd += (toAdd.length ? " " : "") + className;
149
- } else {
150
- toRemove += (toRemove.length ? " " : "") + className;
151
- }
152
- }
153
- });
154
-
155
- forEach(element, function (elm) {
156
- if (toRemove) {
157
- toRemove.split(" ").forEach((css) => elm.classList.remove(css));
158
- }
159
- if (toAdd) {
160
- toAdd.split(" ").forEach((css) => elm.classList.add(css));
161
- }
162
- });
163
- postDigestQueue.delete(element);
164
- }
165
- });
166
- postDigestElements.length = 0;
167
- }
168
-
169
- function addRemoveClassesPostDigest(element, add, remove) {
170
- const data = postDigestQueue.get(element) || {};
171
-
172
- const classesAdded = updateData(data, add, true);
173
- const classesRemoved = updateData(data, remove, false);
174
-
175
- if (classesAdded || classesRemoved) {
176
- postDigestQueue.set(element, data);
177
- postDigestElements.push(element);
178
-
179
- if (postDigestElements.length === 1) {
180
- $rootScope.$$postDigest(handleCSSClassChanges);
181
- }
182
- }
183
- }
184
- },
185
- ];
186
- }
187
-
188
72
  export function domInsert(element, parentElement, afterElement) {
189
73
  // if for some reason the previous element was removed
190
74
  // from the dom sometime before this code runs then let's
@@ -502,7 +386,7 @@ export function AnimateProvider($provide) {
502
386
  * @example
503
387
  <example module="animationExample" deps="angular-animate.js" animations="true" name="animate-cancel">
504
388
  <file name="app.js">
505
- angular.module('animationExample', ['ngAnimate']).component('cancelExample', {
389
+ angular.module('animationExample', []).component('cancelExample', {
506
390
  templateUrl: 'template.html',
507
391
  controller: function($element, $animate) {
508
392
  this.runner = null;
@@ -7,9 +7,8 @@
7
7
 
8
8
  /**
9
9
  * Creates a requestAnimationFrame scheduler.
10
- * @returns {RafScheduler} The scheduler object.
11
10
  */
12
- export function $$rAFSchedulerFactory() {
11
+ export function RafSchedulerProvider() {
13
12
  /**
14
13
  * @type {Array<Array<Function>>}
15
14
  */
@@ -68,5 +67,10 @@ export function $$rAFSchedulerFactory() {
68
67
  });
69
68
  };
70
69
 
71
- return scheduler;
70
+ /**
71
+ * @returns {RafScheduler} The scheduler object.
72
+ */
73
+ this.$get = function () {
74
+ return scheduler;
75
+ };
72
76
  }
@@ -1,6 +1,6 @@
1
- import { $$rAFSchedulerFactory } from "./raf-scheduler";
1
+ import { RafSchedulerProvider } from "./raf-scheduler";
2
2
 
3
- describe("$$rAFSchedulerFactory", function () {
3
+ describe("RafSchedulerProvider", function () {
4
4
  let scheduler;
5
5
  let rAFCallbacks;
6
6
  let originalRequestAnimationFrame;
@@ -8,7 +8,7 @@ describe("$$rAFSchedulerFactory", function () {
8
8
 
9
9
  beforeEach(function () {
10
10
  rAFCallbacks = [];
11
- scheduler = $$rAFSchedulerFactory();
11
+ scheduler = new RafSchedulerProvider().$get();
12
12
 
13
13
  originalRequestAnimationFrame = window.requestAnimationFrame;
14
14
  originalCancelAnimationFrame = window.cancelAnimationFrame;
@@ -119,18 +119,23 @@ export function removeFromArray(arr, val) {
119
119
  }
120
120
  }
121
121
 
122
+ /**
123
+ *
124
+ * @param {JQLite|Node} element
125
+ * @returns {JQLite}
126
+ */
122
127
  export function stripCommentsFromElement(element) {
123
128
  if (element instanceof JQLite) {
124
129
  switch (element.length) {
125
130
  case 0:
126
- return element;
131
+ return /** @type {JQLite} */ (element);
127
132
 
128
133
  case 1:
129
134
  // there is no point of stripping anything if the element
130
135
  // is the only element within the JQLite wrapper.
131
136
  // (it's important that we retain the element instance.)
132
137
  if (element[0].nodeType === Node.ELEMENT_NODE) {
133
- return element;
138
+ return /** @type {JQLite} */ (element);
134
139
  }
135
140
  break;
136
141
 
@@ -139,14 +144,18 @@ export function stripCommentsFromElement(element) {
139
144
  }
140
145
  }
141
146
 
142
- if (element.nodeType === Node.ELEMENT_NODE) {
147
+ if (/** @type {Node} */ (element).nodeType === Node.ELEMENT_NODE) {
143
148
  return JQLite(element);
144
149
  }
145
150
  }
146
151
 
152
+ /**
153
+ * @param {JQLite|Node} element
154
+ * @returns {Node}
155
+ */
147
156
  export function extractElementNode(element) {
148
- if (!element[0]) return element;
149
- for (let i = 0; i < element.length; i++) {
157
+ if (!element[0]) return /** @type {Node} */ (element);
158
+ for (let i = 0; i < /** @type {JQLite} */ (element).length; i++) {
150
159
  const elm = element[i];
151
160
  if (elm.nodeType === Node.ELEMENT_NODE) {
152
161
  return elm;
@@ -157,11 +166,11 @@ export function extractElementNode(element) {
157
166
  export function applyAnimationClassesFactory() {
158
167
  return function (element, options) {
159
168
  if (options.addClass) {
160
- element[0].classList.add(options.addClass);
169
+ element[0].classList.add(...options.addClass.trim().split(" "));
161
170
  options.addClass = null;
162
171
  }
163
172
  if (options.removeClass) {
164
- element[0].classList.remove(options.removeClass);
173
+ element[0].classList.remove(...options.removeClass.trim().split(" "));
165
174
  options.removeClass = null;
166
175
  }
167
176
  };
@@ -1,6 +1,5 @@
1
1
  import { JQLite, dealoc } from "./shared/jqlite/jqlite";
2
2
  import { Angular } from "./loader";
3
- import { createInjector } from "./core/di/injector";
4
3
  import { browserTrigger } from "./shared/test-utils";
5
4
 
6
5
  describe("binding", () => {
@@ -21,11 +20,13 @@ describe("binding", () => {
21
20
  window.angular = new Angular();
22
21
  myModule = window.angular.module("myModule", ["ng"]);
23
22
  myModule.decorator("$exceptionHandler", function () {
24
- return (exception, cause) => {
23
+ return (exception) => {
25
24
  errors.push(exception.message);
26
25
  };
27
26
  });
28
- $injector = createInjector(["myModule"]);
27
+ $injector = window.angular.bootstrap(document.getElementById("dummy"), [
28
+ "myModule",
29
+ ]);
29
30
  $rootScope = $injector.get("$rootScope");
30
31
  $compile = $injector.get("$compile");
31
32
  $exceptionHandler = $injector.get("$exceptionHandler");