@angular-wave/angular.ts 0.0.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.
Files changed (231) hide show
  1. package/.eslintignore +1 -0
  2. package/.eslintrc.cjs +29 -0
  3. package/.github/workflows/playwright.yml +27 -0
  4. package/CHANGELOG.md +17974 -0
  5. package/CODE_OF_CONDUCT.md +3 -0
  6. package/CONTRIBUTING.md +246 -0
  7. package/DEVELOPERS.md +488 -0
  8. package/LICENSE +22 -0
  9. package/Makefile +31 -0
  10. package/README.md +115 -0
  11. package/RELEASE.md +98 -0
  12. package/SECURITY.md +16 -0
  13. package/TRIAGING.md +135 -0
  14. package/css/angular.css +22 -0
  15. package/dist/angular-ts.cjs.js +36843 -0
  16. package/dist/angular-ts.esm.js +36841 -0
  17. package/dist/angular-ts.umd.js +36848 -0
  18. package/dist/build/angular-animate.js +4272 -0
  19. package/dist/build/angular-aria.js +426 -0
  20. package/dist/build/angular-message-format.js +1072 -0
  21. package/dist/build/angular-messages.js +829 -0
  22. package/dist/build/angular-mocks.js +3757 -0
  23. package/dist/build/angular-parse-ext.js +1275 -0
  24. package/dist/build/angular-resource.js +911 -0
  25. package/dist/build/angular-route.js +1266 -0
  26. package/dist/build/angular-sanitize.js +891 -0
  27. package/dist/build/angular-touch.js +368 -0
  28. package/dist/build/angular.js +36600 -0
  29. package/e2e/unit.spec.ts +15 -0
  30. package/images/android-chrome-192x192.png +0 -0
  31. package/images/android-chrome-512x512.png +0 -0
  32. package/images/apple-touch-icon.png +0 -0
  33. package/images/favicon-16x16.png +0 -0
  34. package/images/favicon-32x32.png +0 -0
  35. package/images/favicon.ico +0 -0
  36. package/images/site.webmanifest +1 -0
  37. package/index.html +104 -0
  38. package/package.json +47 -0
  39. package/playwright.config.ts +78 -0
  40. package/public/circle.html +1 -0
  41. package/public/my_child_directive.html +1 -0
  42. package/public/my_directive.html +1 -0
  43. package/public/my_other_directive.html +1 -0
  44. package/public/test.html +1 -0
  45. package/rollup.config.js +31 -0
  46. package/src/animations/animateCache.js +55 -0
  47. package/src/animations/animateChildrenDirective.js +105 -0
  48. package/src/animations/animateCss.js +1139 -0
  49. package/src/animations/animateCssDriver.js +291 -0
  50. package/src/animations/animateJs.js +367 -0
  51. package/src/animations/animateJsDriver.js +67 -0
  52. package/src/animations/animateQueue.js +851 -0
  53. package/src/animations/animation.js +506 -0
  54. package/src/animations/module.js +779 -0
  55. package/src/animations/ngAnimateSwap.js +119 -0
  56. package/src/animations/rafScheduler.js +50 -0
  57. package/src/animations/shared.js +378 -0
  58. package/src/constants.js +20 -0
  59. package/src/core/animate.js +845 -0
  60. package/src/core/animateCss.js +73 -0
  61. package/src/core/animateRunner.js +195 -0
  62. package/src/core/attributes.js +199 -0
  63. package/src/core/cache.js +45 -0
  64. package/src/core/compile.js +4727 -0
  65. package/src/core/controller.js +225 -0
  66. package/src/core/exceptionHandler.js +63 -0
  67. package/src/core/filter.js +146 -0
  68. package/src/core/interpolate.js +442 -0
  69. package/src/core/interval.js +188 -0
  70. package/src/core/intervalFactory.js +57 -0
  71. package/src/core/location.js +1086 -0
  72. package/src/core/parser/parse.js +2562 -0
  73. package/src/core/parser/parse.md +13 -0
  74. package/src/core/q.js +746 -0
  75. package/src/core/rootScope.js +1596 -0
  76. package/src/core/sanitizeUri.js +85 -0
  77. package/src/core/sce.js +1161 -0
  78. package/src/core/taskTrackerFactory.js +125 -0
  79. package/src/core/timeout.js +121 -0
  80. package/src/core/urlUtils.js +187 -0
  81. package/src/core/utils.js +1349 -0
  82. package/src/directive/a.js +37 -0
  83. package/src/directive/attrs.js +283 -0
  84. package/src/directive/bind.js +51 -0
  85. package/src/directive/bind.md +142 -0
  86. package/src/directive/change.js +12 -0
  87. package/src/directive/change.md +25 -0
  88. package/src/directive/cloak.js +12 -0
  89. package/src/directive/cloak.md +24 -0
  90. package/src/directive/events.js +75 -0
  91. package/src/directive/events.md +166 -0
  92. package/src/directive/form.js +725 -0
  93. package/src/directive/init.js +15 -0
  94. package/src/directive/init.md +41 -0
  95. package/src/directive/input.js +1783 -0
  96. package/src/directive/list.js +46 -0
  97. package/src/directive/list.md +22 -0
  98. package/src/directive/ngClass.js +249 -0
  99. package/src/directive/ngController.js +64 -0
  100. package/src/directive/ngCsp.js +82 -0
  101. package/src/directive/ngIf.js +134 -0
  102. package/src/directive/ngInclude.js +217 -0
  103. package/src/directive/ngModel.js +1356 -0
  104. package/src/directive/ngModelOptions.js +509 -0
  105. package/src/directive/ngOptions.js +670 -0
  106. package/src/directive/ngRef.js +90 -0
  107. package/src/directive/ngRepeat.js +650 -0
  108. package/src/directive/ngShowHide.js +255 -0
  109. package/src/directive/ngSwitch.js +178 -0
  110. package/src/directive/ngTransclude.js +98 -0
  111. package/src/directive/non-bindable.js +11 -0
  112. package/src/directive/non-bindable.md +17 -0
  113. package/src/directive/script.js +30 -0
  114. package/src/directive/select.js +624 -0
  115. package/src/directive/style.js +25 -0
  116. package/src/directive/style.md +23 -0
  117. package/src/directive/validators.js +329 -0
  118. package/src/exts/aria.js +544 -0
  119. package/src/exts/messages.js +852 -0
  120. package/src/filters/filter.js +207 -0
  121. package/src/filters/filter.md +69 -0
  122. package/src/filters/filters.js +239 -0
  123. package/src/filters/json.md +16 -0
  124. package/src/filters/limit-to.js +43 -0
  125. package/src/filters/limit-to.md +19 -0
  126. package/src/filters/order-by.js +183 -0
  127. package/src/filters/order-by.md +83 -0
  128. package/src/index.js +13 -0
  129. package/src/injector.js +1034 -0
  130. package/src/jqLite.js +1117 -0
  131. package/src/loader.js +1320 -0
  132. package/src/public.js +215 -0
  133. package/src/routeToRegExp.js +41 -0
  134. package/src/services/anchorScroll.js +135 -0
  135. package/src/services/browser.js +321 -0
  136. package/src/services/cacheFactory.js +398 -0
  137. package/src/services/cookieReader.js +72 -0
  138. package/src/services/document.js +64 -0
  139. package/src/services/http.js +1537 -0
  140. package/src/services/httpBackend.js +206 -0
  141. package/src/services/log.js +160 -0
  142. package/src/services/templateRequest.js +139 -0
  143. package/test/angular.spec.js +2153 -0
  144. package/test/aria/aria.spec.js +1245 -0
  145. package/test/binding.spec.js +504 -0
  146. package/test/build-test.html +14 -0
  147. package/test/injector.spec.js +2327 -0
  148. package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
  149. package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
  150. package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
  151. package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
  152. package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
  153. package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
  154. package/test/jasmine/jasmine-browser.json +17 -0
  155. package/test/jasmine/jasmine.json +9 -0
  156. package/test/jqlite.spec.js +2133 -0
  157. package/test/loader.spec.js +219 -0
  158. package/test/messages/messages.spec.js +1146 -0
  159. package/test/min-err.spec.js +174 -0
  160. package/test/mock-test.html +13 -0
  161. package/test/module-test.html +15 -0
  162. package/test/ng/anomate.spec.js +606 -0
  163. package/test/ng/cache-factor.spec.js +334 -0
  164. package/test/ng/compile.spec.js +17956 -0
  165. package/test/ng/controller-provider.spec.js +227 -0
  166. package/test/ng/cookie-reader.spec.js +98 -0
  167. package/test/ng/directive/a.spec.js +192 -0
  168. package/test/ng/directive/bind.spec.js +334 -0
  169. package/test/ng/directive/boolean.spec.js +136 -0
  170. package/test/ng/directive/change.spec.js +71 -0
  171. package/test/ng/directive/class.spec.js +858 -0
  172. package/test/ng/directive/click.spec.js +38 -0
  173. package/test/ng/directive/cloak.spec.js +44 -0
  174. package/test/ng/directive/constoller.spec.js +194 -0
  175. package/test/ng/directive/element-style.spec.js +92 -0
  176. package/test/ng/directive/event.spec.js +282 -0
  177. package/test/ng/directive/form.spec.js +1518 -0
  178. package/test/ng/directive/href.spec.js +143 -0
  179. package/test/ng/directive/if.spec.js +402 -0
  180. package/test/ng/directive/include.spec.js +828 -0
  181. package/test/ng/directive/init.spec.js +68 -0
  182. package/test/ng/directive/input.spec.js +3810 -0
  183. package/test/ng/directive/list.spec.js +170 -0
  184. package/test/ng/directive/model-options.spec.js +1008 -0
  185. package/test/ng/directive/model.spec.js +1905 -0
  186. package/test/ng/directive/non-bindable.spec.js +55 -0
  187. package/test/ng/directive/options.spec.js +3583 -0
  188. package/test/ng/directive/ref.spec.js +575 -0
  189. package/test/ng/directive/repeat.spec.js +1675 -0
  190. package/test/ng/directive/script.spec.js +52 -0
  191. package/test/ng/directive/scrset.spec.js +67 -0
  192. package/test/ng/directive/select.spec.js +2541 -0
  193. package/test/ng/directive/show-hide.spec.js +253 -0
  194. package/test/ng/directive/src.spec.js +157 -0
  195. package/test/ng/directive/style.spec.js +178 -0
  196. package/test/ng/directive/switch.spec.js +647 -0
  197. package/test/ng/directive/validators.spec.js +717 -0
  198. package/test/ng/document.spec.js +52 -0
  199. package/test/ng/filter/filter.spec.js +714 -0
  200. package/test/ng/filter/filters.spec.js +35 -0
  201. package/test/ng/filter/limit-to.spec.js +251 -0
  202. package/test/ng/filter/order-by.spec.js +891 -0
  203. package/test/ng/filter.spec.js +149 -0
  204. package/test/ng/http-backend.spec.js +398 -0
  205. package/test/ng/http.spec.js +4071 -0
  206. package/test/ng/interpolate.spec.js +642 -0
  207. package/test/ng/interval.spec.js +343 -0
  208. package/test/ng/location.spec.js +3488 -0
  209. package/test/ng/on.spec.js +229 -0
  210. package/test/ng/parse.spec.js +4655 -0
  211. package/test/ng/prop.spec.js +805 -0
  212. package/test/ng/q.spec.js +2904 -0
  213. package/test/ng/root-element.spec.js +16 -0
  214. package/test/ng/sanitize-uri.spec.js +249 -0
  215. package/test/ng/sce.spec.js +660 -0
  216. package/test/ng/scope.spec.js +3442 -0
  217. package/test/ng/template-request.spec.js +236 -0
  218. package/test/ng/timeout.spec.js +351 -0
  219. package/test/ng/url-utils.spec.js +156 -0
  220. package/test/ng/utils.spec.js +144 -0
  221. package/test/original-test.html +21 -0
  222. package/test/public.spec.js +34 -0
  223. package/test/sanitize/bing-html.spec.js +36 -0
  224. package/test/server/express.js +158 -0
  225. package/test/test-utils.js +11 -0
  226. package/tsconfig.json +17 -0
  227. package/types/angular.d.ts +138 -0
  228. package/types/global.d.ts +9 -0
  229. package/types/index.d.ts +2357 -0
  230. package/types/jqlite.d.ts +558 -0
  231. package/vite.config.js +14 -0
@@ -0,0 +1,506 @@
1
+ import { jqLite } from "../jqLite";
2
+ import { forEach, mergeClasses } from "../core/utils";
3
+ import {
4
+ NG_ANIMATE_CLASSNAME,
5
+ PREPARE_CLASS_SUFFIX,
6
+ applyAnimationClassesFactory,
7
+ applyAnimationStyles,
8
+ getDomNode,
9
+ prepareAnimationOptions,
10
+ } from "./shared";
11
+
12
+ export const $$AnimationProvider = [
13
+ "$animateProvider",
14
+ function ($animateProvider) {
15
+ const NG_ANIMATE_REF_ATTR = "ng-animate-ref";
16
+
17
+ const drivers = (this.drivers = []);
18
+
19
+ const RUNNER_STORAGE_KEY = "$$animationRunner";
20
+ const PREPARE_CLASSES_KEY = "$$animatePrepareClasses";
21
+
22
+ function setRunner(element, runner) {
23
+ element.data(RUNNER_STORAGE_KEY, runner);
24
+ }
25
+
26
+ function removeRunner(element) {
27
+ element.removeData(RUNNER_STORAGE_KEY);
28
+ }
29
+
30
+ function getRunner(element) {
31
+ return element.data(RUNNER_STORAGE_KEY);
32
+ }
33
+
34
+ this.$get = [
35
+ "$rootScope",
36
+ "$injector",
37
+ "$$AnimateRunner",
38
+ "$$rAFScheduler",
39
+ "$$animateCache",
40
+ function (
41
+ $rootScope,
42
+ $injector,
43
+ $$AnimateRunner,
44
+ $$rAFScheduler,
45
+ $$animateCache,
46
+ ) {
47
+ const animationQueue = [];
48
+ const applyAnimationClasses = applyAnimationClassesFactory();
49
+
50
+ function sortAnimations(animations) {
51
+ const tree = { children: [] };
52
+ let i;
53
+ const lookup = new Map();
54
+
55
+ // this is done first beforehand so that the map
56
+ // is filled with a list of the elements that will be animated
57
+ // eslint-disable-next-line no-plusplus
58
+ for (i = 0; i < animations.length; i++) {
59
+ const animation = animations[i];
60
+ lookup.set(
61
+ animation.domNode,
62
+ (animations[i] = {
63
+ domNode: animation.domNode,
64
+ element: animation.element,
65
+ fn: animation.fn,
66
+ children: [],
67
+ }),
68
+ );
69
+ }
70
+
71
+ for (i = 0; i < animations.length; i++) {
72
+ processNode(animations[i]);
73
+ }
74
+
75
+ return flatten(tree);
76
+
77
+ function processNode(entry) {
78
+ if (entry.processed) return entry;
79
+ entry.processed = true;
80
+
81
+ const elementNode = entry.domNode;
82
+ let { parentNode } = elementNode;
83
+ lookup.set(elementNode, entry);
84
+
85
+ let parentEntry;
86
+ while (parentNode) {
87
+ parentEntry = lookup.get(parentNode);
88
+ if (parentEntry) {
89
+ if (!parentEntry.processed) {
90
+ parentEntry = processNode(parentEntry);
91
+ }
92
+ break;
93
+ }
94
+ parentNode = parentNode.parentNode;
95
+ }
96
+
97
+ (parentEntry || tree).children.push(entry);
98
+ return entry;
99
+ }
100
+
101
+ function flatten(tree) {
102
+ const result = [];
103
+ const queue = [];
104
+ let i;
105
+
106
+ for (i = 0; i < tree.children.length; i++) {
107
+ queue.push(tree.children[i]);
108
+ }
109
+
110
+ let remainingLevelEntries = queue.length;
111
+ let nextLevelEntries = 0;
112
+ let row = [];
113
+
114
+ for (i = 0; i < queue.length; i++) {
115
+ const entry = queue[i];
116
+ if (remainingLevelEntries <= 0) {
117
+ remainingLevelEntries = nextLevelEntries;
118
+ nextLevelEntries = 0;
119
+ result.push(row);
120
+ row = [];
121
+ }
122
+ row.push(entry);
123
+ entry.children.forEach((childEntry) => {
124
+ nextLevelEntries++;
125
+ queue.push(childEntry);
126
+ });
127
+ remainingLevelEntries--;
128
+ }
129
+
130
+ if (row.length) {
131
+ result.push(row);
132
+ }
133
+
134
+ return result;
135
+ }
136
+ }
137
+
138
+ // TODO(matsko): document the signature in a better way
139
+ return function (element, event, options) {
140
+ options = prepareAnimationOptions(options);
141
+ const isStructural = ["enter", "move", "leave"].indexOf(event) >= 0;
142
+
143
+ // there is no animation at the current moment, however
144
+ // these runner methods will get later updated with the
145
+ // methods leading into the driver's end/cancel methods
146
+ // for now they just stop the animation from starting
147
+ const runner = new $$AnimateRunner({
148
+ end() {
149
+ close();
150
+ },
151
+ cancel() {
152
+ close(true);
153
+ },
154
+ });
155
+
156
+ if (!drivers.length) {
157
+ close();
158
+ return runner;
159
+ }
160
+
161
+ let classes = mergeClasses(
162
+ element.attr("class"),
163
+ mergeClasses(options.addClass, options.removeClass),
164
+ );
165
+ let { tempClasses } = options;
166
+ if (tempClasses) {
167
+ classes += ` ${tempClasses}`;
168
+ options.tempClasses = null;
169
+ }
170
+
171
+ if (isStructural) {
172
+ element.data(
173
+ PREPARE_CLASSES_KEY,
174
+ `ng-${event}${PREPARE_CLASS_SUFFIX}`,
175
+ );
176
+ }
177
+
178
+ setRunner(element, runner);
179
+
180
+ animationQueue.push({
181
+ // this data is used by the postDigest code and passed into
182
+ // the driver step function
183
+ element,
184
+ classes,
185
+ event,
186
+ structural: isStructural,
187
+ options,
188
+ beforeStart,
189
+ close,
190
+ });
191
+
192
+ element.on("$destroy", handleDestroyedElement);
193
+
194
+ // we only want there to be one function called within the post digest
195
+ // block. This way we can group animations for all the animations that
196
+ // were apart of the same postDigest flush call.
197
+ if (animationQueue.length > 1) return runner;
198
+
199
+ $rootScope.$$postDigest(() => {
200
+ const animations = [];
201
+ forEach(animationQueue, (entry) => {
202
+ // the element was destroyed early on which removed the runner
203
+ // form its storage. This means we can't animate this element
204
+ // at all and it already has been closed due to destruction.
205
+ if (getRunner(entry.element)) {
206
+ animations.push(entry);
207
+ } else {
208
+ entry.close();
209
+ }
210
+ });
211
+
212
+ // now any future animations will be in another postDigest
213
+ animationQueue.length = 0;
214
+
215
+ const groupedAnimations = groupAnimations(animations);
216
+ const toBeSortedAnimations = [];
217
+
218
+ forEach(groupedAnimations, (animationEntry) => {
219
+ const element = animationEntry.from
220
+ ? animationEntry.from.element
221
+ : animationEntry.element;
222
+ let extraClasses = options.addClass;
223
+
224
+ extraClasses =
225
+ (extraClasses ? `${extraClasses} ` : "") + NG_ANIMATE_CLASSNAME;
226
+ const cacheKey = $$animateCache.cacheKey(
227
+ element[0],
228
+ animationEntry.event,
229
+ extraClasses,
230
+ options.removeClass,
231
+ );
232
+
233
+ toBeSortedAnimations.push({
234
+ element,
235
+ domNode: getDomNode(element),
236
+ fn: function triggerAnimationStart() {
237
+ let startAnimationFn;
238
+ const closeFn = animationEntry.close;
239
+
240
+ // in the event that we've cached the animation status for this element
241
+ // and it's in fact an invalid animation (something that has duration = 0)
242
+ // then we should skip all the heavy work from here on
243
+ if (
244
+ $$animateCache.containsCachedAnimationWithoutDuration(
245
+ cacheKey,
246
+ )
247
+ ) {
248
+ closeFn();
249
+ return;
250
+ }
251
+
252
+ // it's important that we apply the `ng-animate` CSS class and the
253
+ // temporary classes before we do any driver invoking since these
254
+ // CSS classes may be required for proper CSS detection.
255
+ animationEntry.beforeStart();
256
+
257
+ // in the event that the element was removed before the digest runs or
258
+ // during the RAF sequencing then we should not trigger the animation.
259
+ const targetElement = animationEntry.anchors
260
+ ? animationEntry.from.element || animationEntry.to.element
261
+ : animationEntry.element;
262
+
263
+ if (getRunner(targetElement)) {
264
+ const operation = invokeFirstDriver(animationEntry);
265
+ if (operation) {
266
+ startAnimationFn = operation.start;
267
+ }
268
+ }
269
+
270
+ if (!startAnimationFn) {
271
+ closeFn();
272
+ } else {
273
+ const animationRunner = startAnimationFn();
274
+ animationRunner.done((status) => {
275
+ closeFn(!status);
276
+ });
277
+ updateAnimationRunners(animationEntry, animationRunner);
278
+ }
279
+ },
280
+ });
281
+ });
282
+
283
+ // we need to sort each of the animations in order of parent to child
284
+ // relationships. This ensures that the child classes are applied at the
285
+ // right time.
286
+ const finalAnimations = sortAnimations(toBeSortedAnimations);
287
+ for (let i = 0; i < finalAnimations.length; i++) {
288
+ const innerArray = finalAnimations[i];
289
+ for (let j = 0; j < innerArray.length; j++) {
290
+ const entry = innerArray[j];
291
+ const { element } = entry;
292
+
293
+ // the RAFScheduler code only uses functions
294
+ finalAnimations[i][j] = entry.fn;
295
+
296
+ // the first row of elements shouldn't have a prepare-class added to them
297
+ // since the elements are at the top of the animation hierarchy and they
298
+ // will be applied without a RAF having to pass...
299
+ if (i === 0) {
300
+ element.removeData(PREPARE_CLASSES_KEY);
301
+ continue;
302
+ }
303
+
304
+ const prepareClassName = element.data(PREPARE_CLASSES_KEY);
305
+ if (prepareClassName) {
306
+ element[0].classList.add(prepareClassName);
307
+ }
308
+ }
309
+ }
310
+
311
+ $$rAFScheduler(finalAnimations);
312
+ });
313
+
314
+ return runner;
315
+
316
+ // TODO(matsko): change to reference nodes
317
+ function getAnchorNodes(node) {
318
+ const SELECTOR = `[${NG_ANIMATE_REF_ATTR}]`;
319
+ const items = node.hasAttribute(NG_ANIMATE_REF_ATTR)
320
+ ? [node]
321
+ : node.querySelectorAll(SELECTOR);
322
+ const anchors = [];
323
+ forEach(items, (node) => {
324
+ const attr = node.getAttribute(NG_ANIMATE_REF_ATTR);
325
+ if (attr && attr.length) {
326
+ anchors.push(node);
327
+ }
328
+ });
329
+ return anchors;
330
+ }
331
+
332
+ function groupAnimations(animations) {
333
+ const preparedAnimations = [];
334
+ const refLookup = {};
335
+ forEach(animations, (animation, index) => {
336
+ const { element } = animation;
337
+ const node = getDomNode(element);
338
+ const { event } = animation;
339
+ const enterOrMove = ["enter", "move"].indexOf(event) >= 0;
340
+ const anchorNodes = animation.structural
341
+ ? getAnchorNodes(node)
342
+ : [];
343
+
344
+ if (anchorNodes.length) {
345
+ const direction = enterOrMove ? "to" : "from";
346
+
347
+ forEach(anchorNodes, (anchor) => {
348
+ const key = anchor.getAttribute(NG_ANIMATE_REF_ATTR);
349
+ refLookup[key] = refLookup[key] || {};
350
+ refLookup[key][direction] = {
351
+ animationID: index,
352
+ element: jqLite(anchor),
353
+ };
354
+ });
355
+ } else {
356
+ preparedAnimations.push(animation);
357
+ }
358
+ });
359
+
360
+ const usedIndicesLookup = {};
361
+ const anchorGroups = {};
362
+ Object.values(refLookup).forEach((operations) => {
363
+ const { from } = operations;
364
+ const { to } = operations;
365
+
366
+ if (!from || !to) {
367
+ // only one of these is set therefore we can't have an
368
+ // anchor animation since all three pieces are required
369
+ const index = from ? from.animationID : to.animationID;
370
+ const indexKey = index.toString();
371
+ if (!usedIndicesLookup[indexKey]) {
372
+ usedIndicesLookup[indexKey] = true;
373
+ preparedAnimations.push(animations[index]);
374
+ }
375
+ return;
376
+ }
377
+
378
+ const fromAnimation = animations[from.animationID];
379
+ const toAnimation = animations[to.animationID];
380
+ const lookupKey = from.animationID.toString();
381
+ if (!anchorGroups[lookupKey]) {
382
+ const group = (anchorGroups[lookupKey] = {
383
+ structural: true,
384
+ beforeStart() {
385
+ fromAnimation.beforeStart();
386
+ toAnimation.beforeStart();
387
+ },
388
+ close() {
389
+ fromAnimation.close();
390
+ toAnimation.close();
391
+ },
392
+ classes: cssClassesIntersection(
393
+ fromAnimation.classes,
394
+ toAnimation.classes,
395
+ ),
396
+ from: fromAnimation,
397
+ to: toAnimation,
398
+ anchors: [], // TODO(matsko): change to reference nodes
399
+ });
400
+
401
+ // the anchor animations require that the from and to elements both have at least
402
+ // one shared CSS class which effectively marries the two elements together to use
403
+ // the same animation driver and to properly sequence the anchor animation.
404
+ if (group.classes.length) {
405
+ preparedAnimations.push(group);
406
+ } else {
407
+ preparedAnimations.push(fromAnimation);
408
+ preparedAnimations.push(toAnimation);
409
+ }
410
+ }
411
+
412
+ anchorGroups[lookupKey].anchors.push({
413
+ out: from.element,
414
+ in: to.element,
415
+ });
416
+ });
417
+
418
+ return preparedAnimations;
419
+ }
420
+
421
+ function cssClassesIntersection(a, b) {
422
+ a = a.split(" ");
423
+ b = b.split(" ");
424
+ const matches = [];
425
+
426
+ for (let i = 0; i < a.length; i++) {
427
+ const aa = a[i];
428
+ if (aa.substring(0, 3) === "ng-") continue;
429
+
430
+ for (let j = 0; j < b.length; j++) {
431
+ if (aa === b[j]) {
432
+ matches.push(aa);
433
+ break;
434
+ }
435
+ }
436
+ }
437
+
438
+ return matches.join(" ");
439
+ }
440
+
441
+ function invokeFirstDriver(animationDetails) {
442
+ // we loop in reverse order since the more general drivers (like CSS and JS)
443
+ // may attempt more elements, but custom drivers are more particular
444
+ for (let i = drivers.length - 1; i >= 0; i--) {
445
+ const driverName = drivers[i];
446
+ const factory = $injector.get(driverName);
447
+ const driver = factory(animationDetails);
448
+ if (driver) {
449
+ return driver;
450
+ }
451
+ }
452
+ }
453
+
454
+ function beforeStart() {
455
+ tempClasses =
456
+ (tempClasses ? `${tempClasses} ` : "") + NG_ANIMATE_CLASSNAME;
457
+ element.className += ` ${tempClasses}`;
458
+ let prepareClassName = element.data(PREPARE_CLASSES_KEY);
459
+ if (prepareClassName) {
460
+ element[0].classList.remove(prepareClassName);
461
+ prepareClassName = null;
462
+ }
463
+ }
464
+
465
+ function updateAnimationRunners(animation, newRunner) {
466
+ if (animation.from && animation.to) {
467
+ update(animation.from.element);
468
+ update(animation.to.element);
469
+ } else {
470
+ update(animation.element);
471
+ }
472
+
473
+ function update(element) {
474
+ const runner = getRunner(element);
475
+ if (runner) runner.setHost(newRunner);
476
+ }
477
+ }
478
+
479
+ function handleDestroyedElement() {
480
+ const runner = getRunner(element);
481
+ if (runner && (event !== "leave" || !options.$$domOperationFired)) {
482
+ runner.end();
483
+ }
484
+ }
485
+
486
+ function close(rejected) {
487
+ element.off("$destroy", handleDestroyedElement);
488
+ removeRunner(element);
489
+
490
+ applyAnimationClasses(element, options);
491
+ applyAnimationStyles(element, options);
492
+ options.domOperation();
493
+
494
+ if (tempClasses) {
495
+ tempClasses
496
+ .split(" ")
497
+ .forEach((cls) => element[0].classList.remove(cls));
498
+ }
499
+
500
+ runner.complete(!rejected);
501
+ }
502
+ };
503
+ },
504
+ ];
505
+ },
506
+ ];