animejs 4.1.2 → 4.2.0-beta.0

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 (191) hide show
  1. package/README.md +18 -8
  2. package/{lib → dist/bundles}/anime.esm.js +6549 -6265
  3. package/dist/bundles/anime.esm.min.js +7 -0
  4. package/dist/bundles/anime.umd.js +8621 -0
  5. package/dist/bundles/anime.umd.min.js +7 -0
  6. package/dist/modules/animatable/animatable.cjs +150 -0
  7. package/dist/modules/animatable/animatable.d.ts +28 -0
  8. package/dist/modules/animatable/animatable.js +147 -0
  9. package/dist/modules/animatable/index.cjs +15 -0
  10. package/dist/modules/animatable/index.d.ts +1 -0
  11. package/dist/modules/animatable/index.js +8 -0
  12. package/dist/modules/animation/additive.cjs +82 -0
  13. package/dist/modules/animation/additive.d.ts +15 -0
  14. package/dist/modules/animation/additive.js +79 -0
  15. package/dist/modules/animation/animation.cjs +660 -0
  16. package/dist/modules/animation/animation.d.ts +47 -0
  17. package/dist/modules/animation/animation.js +657 -0
  18. package/dist/modules/animation/composition.cjs +383 -0
  19. package/dist/modules/animation/composition.d.ts +10 -0
  20. package/dist/modules/animation/composition.js +377 -0
  21. package/dist/modules/animation/index.cjs +15 -0
  22. package/dist/modules/animation/index.d.ts +1 -0
  23. package/dist/modules/animation/index.js +8 -0
  24. package/dist/modules/core/clock.cjs +110 -0
  25. package/dist/modules/core/clock.d.ts +51 -0
  26. package/dist/modules/core/clock.js +108 -0
  27. package/dist/modules/core/colors.cjs +102 -0
  28. package/dist/modules/core/colors.d.ts +2 -0
  29. package/dist/modules/core/colors.js +100 -0
  30. package/dist/modules/core/consts.cjs +154 -0
  31. package/dist/modules/core/consts.d.ts +59 -0
  32. package/dist/modules/core/consts.js +121 -0
  33. package/dist/modules/core/globals.cjs +77 -0
  34. package/dist/modules/core/globals.d.ts +29 -0
  35. package/dist/modules/core/globals.js +72 -0
  36. package/dist/modules/core/helpers.cjs +304 -0
  37. package/dist/modules/core/helpers.d.ts +43 -0
  38. package/dist/modules/core/helpers.js +261 -0
  39. package/dist/modules/core/render.cjs +389 -0
  40. package/dist/modules/core/render.d.ts +4 -0
  41. package/dist/modules/core/render.js +386 -0
  42. package/dist/modules/core/styles.cjs +116 -0
  43. package/dist/modules/core/styles.d.ts +5 -0
  44. package/dist/modules/core/styles.js +113 -0
  45. package/dist/modules/core/targets.cjs +136 -0
  46. package/dist/modules/core/targets.d.ts +118 -0
  47. package/dist/modules/core/targets.js +132 -0
  48. package/dist/modules/core/transforms.cjs +49 -0
  49. package/dist/modules/core/transforms.d.ts +2 -0
  50. package/dist/modules/core/transforms.js +47 -0
  51. package/dist/modules/core/units.cjs +67 -0
  52. package/dist/modules/core/units.d.ts +3 -0
  53. package/dist/modules/core/units.js +65 -0
  54. package/dist/modules/core/values.cjs +215 -0
  55. package/dist/modules/core/values.d.ts +14 -0
  56. package/dist/modules/core/values.js +205 -0
  57. package/dist/modules/draggable/draggable.cjs +1226 -0
  58. package/dist/modules/draggable/draggable.d.ts +272 -0
  59. package/dist/modules/draggable/draggable.js +1223 -0
  60. package/dist/modules/draggable/index.cjs +15 -0
  61. package/dist/modules/draggable/index.d.ts +1 -0
  62. package/dist/modules/draggable/index.js +8 -0
  63. package/dist/modules/easings/cubic-bezier.cjs +64 -0
  64. package/dist/modules/easings/cubic-bezier.d.ts +2 -0
  65. package/dist/modules/easings/cubic-bezier.js +62 -0
  66. package/dist/modules/easings/eases.cjs +149 -0
  67. package/dist/modules/easings/eases.d.ts +111 -0
  68. package/dist/modules/easings/eases.js +146 -0
  69. package/dist/modules/easings/index.cjs +24 -0
  70. package/dist/modules/easings/index.d.ts +6 -0
  71. package/dist/modules/easings/index.js +13 -0
  72. package/dist/modules/easings/irregular.cjs +41 -0
  73. package/dist/modules/easings/irregular.d.ts +2 -0
  74. package/dist/modules/easings/irregular.js +39 -0
  75. package/dist/modules/easings/linear.cjs +59 -0
  76. package/dist/modules/easings/linear.d.ts +2 -0
  77. package/dist/modules/easings/linear.js +57 -0
  78. package/dist/modules/easings/none.cjs +19 -0
  79. package/dist/modules/easings/none.d.ts +8 -0
  80. package/dist/modules/easings/none.js +17 -0
  81. package/dist/modules/easings/parser.cjs +59 -0
  82. package/dist/modules/easings/parser.d.ts +21 -0
  83. package/dist/modules/easings/parser.js +55 -0
  84. package/dist/modules/easings/steps.cjs +30 -0
  85. package/dist/modules/easings/steps.d.ts +2 -0
  86. package/dist/modules/easings/steps.js +28 -0
  87. package/dist/modules/engine/engine.cjs +168 -0
  88. package/dist/modules/engine/engine.d.ts +21 -0
  89. package/dist/modules/engine/engine.js +166 -0
  90. package/dist/modules/engine/index.cjs +14 -0
  91. package/dist/modules/engine/index.d.ts +1 -0
  92. package/dist/modules/engine/index.js +8 -0
  93. package/dist/modules/events/index.cjs +16 -0
  94. package/dist/modules/events/index.d.ts +1 -0
  95. package/dist/modules/events/index.js +8 -0
  96. package/dist/modules/events/scroll.cjs +936 -0
  97. package/dist/modules/events/scroll.d.ts +189 -0
  98. package/dist/modules/events/scroll.js +932 -0
  99. package/dist/modules/index.cjs +103 -0
  100. package/dist/modules/index.d.ts +19 -0
  101. package/dist/modules/index.js +42 -0
  102. package/dist/modules/scope/index.cjs +15 -0
  103. package/dist/modules/scope/index.d.ts +1 -0
  104. package/dist/modules/scope/index.js +8 -0
  105. package/dist/modules/scope/scope.cjs +254 -0
  106. package/dist/modules/scope/scope.d.ts +115 -0
  107. package/dist/modules/scope/scope.js +251 -0
  108. package/dist/modules/spring/index.cjs +15 -0
  109. package/dist/modules/spring/index.d.ts +1 -0
  110. package/dist/modules/spring/index.js +8 -0
  111. package/dist/modules/spring/spring.cjs +133 -0
  112. package/dist/modules/spring/spring.d.ts +37 -0
  113. package/dist/modules/spring/spring.js +130 -0
  114. package/dist/modules/svg/drawable.cjs +119 -0
  115. package/dist/modules/svg/drawable.d.ts +3 -0
  116. package/dist/modules/svg/drawable.js +117 -0
  117. package/dist/modules/svg/helpers.cjs +30 -0
  118. package/dist/modules/svg/helpers.d.ts +2 -0
  119. package/dist/modules/svg/helpers.js +28 -0
  120. package/dist/modules/svg/index.cjs +18 -0
  121. package/dist/modules/svg/index.d.ts +3 -0
  122. package/dist/modules/svg/index.js +10 -0
  123. package/dist/modules/svg/morphto.cjs +58 -0
  124. package/dist/modules/svg/morphto.d.ts +3 -0
  125. package/dist/modules/svg/morphto.js +56 -0
  126. package/dist/modules/svg/motionpath.cjs +79 -0
  127. package/dist/modules/svg/motionpath.d.ts +7 -0
  128. package/dist/modules/svg/motionpath.js +77 -0
  129. package/dist/modules/text/index.cjs +16 -0
  130. package/dist/modules/text/index.d.ts +1 -0
  131. package/dist/modules/text/index.js +8 -0
  132. package/dist/modules/text/split.cjs +488 -0
  133. package/dist/modules/text/split.d.ts +62 -0
  134. package/dist/modules/text/split.js +484 -0
  135. package/dist/modules/timeline/index.cjs +15 -0
  136. package/dist/modules/timeline/index.d.ts +1 -0
  137. package/dist/modules/timeline/index.js +8 -0
  138. package/dist/modules/timeline/position.cjs +72 -0
  139. package/dist/modules/timeline/position.d.ts +3 -0
  140. package/dist/modules/timeline/position.js +70 -0
  141. package/dist/modules/timeline/timeline.cjs +312 -0
  142. package/dist/modules/timeline/timeline.d.ts +163 -0
  143. package/dist/modules/timeline/timeline.js +309 -0
  144. package/dist/modules/timer/index.cjs +15 -0
  145. package/dist/modules/timer/index.d.ts +1 -0
  146. package/dist/modules/timer/index.js +8 -0
  147. package/dist/modules/timer/timer.cjs +491 -0
  148. package/dist/modules/timer/timer.d.ts +141 -0
  149. package/dist/modules/timer/timer.js +488 -0
  150. package/dist/modules/types/index.d.ts +387 -0
  151. package/dist/modules/utils/chainable.cjs +190 -0
  152. package/dist/modules/utils/chainable.d.ts +135 -0
  153. package/dist/modules/utils/chainable.js +177 -0
  154. package/dist/modules/utils/index.cjs +43 -0
  155. package/dist/modules/utils/index.d.ts +5 -0
  156. package/dist/modules/utils/index.js +14 -0
  157. package/dist/modules/utils/number.cjs +97 -0
  158. package/dist/modules/utils/number.d.ts +9 -0
  159. package/dist/modules/utils/number.js +85 -0
  160. package/dist/modules/utils/random.cjs +77 -0
  161. package/dist/modules/utils/random.d.ts +22 -0
  162. package/dist/modules/utils/random.js +72 -0
  163. package/dist/modules/utils/stagger.cjs +122 -0
  164. package/dist/modules/utils/stagger.d.ts +30 -0
  165. package/dist/modules/utils/stagger.js +120 -0
  166. package/dist/modules/utils/target.cjs +130 -0
  167. package/dist/modules/utils/target.d.ts +126 -0
  168. package/dist/modules/utils/target.js +125 -0
  169. package/dist/modules/utils/time.cjs +57 -0
  170. package/dist/modules/utils/time.d.ts +5 -0
  171. package/dist/modules/utils/time.js +54 -0
  172. package/dist/modules/waapi/composition.cjs +89 -0
  173. package/dist/modules/waapi/composition.d.ts +4 -0
  174. package/dist/modules/waapi/composition.js +86 -0
  175. package/dist/modules/waapi/index.cjs +15 -0
  176. package/dist/modules/waapi/index.d.ts +1 -0
  177. package/dist/modules/waapi/index.js +8 -0
  178. package/dist/modules/waapi/waapi.cjs +473 -0
  179. package/dist/modules/waapi/waapi.d.ts +114 -0
  180. package/dist/modules/waapi/waapi.js +470 -0
  181. package/package.json +130 -33
  182. package/lib/anime.cjs +0 -9
  183. package/lib/anime.esm.min.js +0 -9
  184. package/lib/anime.iife.js +0 -9
  185. package/lib/anime.iife.min.js +0 -9
  186. package/lib/anime.min.cjs +0 -9
  187. package/lib/anime.umd.js +0 -9
  188. package/lib/anime.umd.min.js +0 -9
  189. package/lib/gui/index.js +0 -6341
  190. package/types/index.d.ts +0 -1081
  191. package/types/index.js +0 -7407
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Anime.js - core - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { isBrowser, win, noop, maxFps, K, compositionTypes, doc } from './consts.js';
9
+
10
+ /**
11
+ * @import {
12
+ * DefaultsParams,
13
+ * DOMTarget,
14
+ * } from '../types/index.js'
15
+ *
16
+ * @import {
17
+ * Scope,
18
+ * } from '../scope/index.js'
19
+ */
20
+
21
+ /** @type {DefaultsParams} */
22
+ const defaults = {
23
+ id: null,
24
+ keyframes: null,
25
+ playbackEase: null,
26
+ playbackRate: 1,
27
+ frameRate: maxFps,
28
+ loop: 0,
29
+ reversed: false,
30
+ alternate: false,
31
+ autoplay: true,
32
+ duration: K,
33
+ delay: 0,
34
+ loopDelay: 0,
35
+ ease: 'out(2)',
36
+ composition: compositionTypes.replace,
37
+ modifier: v => v,
38
+ onBegin: noop,
39
+ onBeforeUpdate: noop,
40
+ onUpdate: noop,
41
+ onLoop: noop,
42
+ onPause: noop,
43
+ onComplete: noop,
44
+ onRender: noop,
45
+ };
46
+
47
+ const scope = {
48
+ /** @type {Scope} */
49
+ current: null,
50
+ /** @type {Document|DOMTarget} */
51
+ root: doc,
52
+ };
53
+
54
+ const globals = {
55
+ /** @type {DefaultsParams} */
56
+ defaults,
57
+ /** @type {Number} */
58
+ precision: 4,
59
+ /** @type {Number} equals 1 in ms mode, 0.001 in s mode */
60
+ timeScale: 1,
61
+ /** @type {Number} */
62
+ tickThreshold: 200,
63
+ };
64
+
65
+ const globalVersions = { version: '4.2.0', engine: null };
66
+
67
+ if (isBrowser) {
68
+ if (!win.AnimeJS) win.AnimeJS = [];
69
+ win.AnimeJS.push(globalVersions);
70
+ }
71
+
72
+ export { defaults, globalVersions, globals, scope };
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Anime.js - core - CJS
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var consts = require('./consts.cjs');
11
+ var globals = require('./globals.cjs');
12
+
13
+ /**
14
+ * @import {
15
+ * Target,
16
+ * DOMTarget,
17
+ * } from '../types/index.js'
18
+ */
19
+
20
+ // Strings
21
+
22
+ /**
23
+ * @param {String} str
24
+ * @return {String}
25
+ */
26
+ const toLowerCase = str => str.replace(consts.lowerCaseRgx, '$1-$2').toLowerCase();
27
+
28
+ /**
29
+ * Prioritize this method instead of regex when possible
30
+ * @param {String} str
31
+ * @param {String} sub
32
+ * @return {Boolean}
33
+ */
34
+ const stringStartsWith = (str, sub) => str.indexOf(sub) === 0;
35
+
36
+ // Note: Date.now is used instead of performance.now since it is precise enough for timings calculations, performs slightly faster and works in Node.js environement.
37
+ const now = Date.now;
38
+
39
+ // Types checkers
40
+
41
+ const isArr = Array.isArray;
42
+ /**@param {any} a @return {a is Record<String, any>} */
43
+ const isObj = a => a && a.constructor === Object;
44
+ /**@param {any} a @return {a is Number} */
45
+ const isNum = a => typeof a === 'number' && !isNaN(a);
46
+ /**@param {any} a @return {a is String} */
47
+ const isStr = a => typeof a === 'string';
48
+ /**@param {any} a @return {a is Function} */
49
+ const isFnc = a => typeof a === 'function';
50
+ /**@param {any} a @return {a is undefined} */
51
+ const isUnd = a => typeof a === 'undefined';
52
+ /**@param {any} a @return {a is null | undefined} */
53
+ const isNil = a => isUnd(a) || a === null;
54
+ /**@param {any} a @return {a is SVGElement} */
55
+ const isSvg = a => consts.isBrowser && a instanceof SVGElement;
56
+ /**@param {any} a @return {Boolean} */
57
+ const isHex = a => consts.hexTestRgx.test(a);
58
+ /**@param {any} a @return {Boolean} */
59
+ const isRgb = a => stringStartsWith(a, 'rgb');
60
+ /**@param {any} a @return {Boolean} */
61
+ const isHsl = a => stringStartsWith(a, 'hsl');
62
+ /**@param {any} a @return {Boolean} */
63
+ const isCol = a => isHex(a) || isRgb(a) || isHsl(a);
64
+ /**@param {any} a @return {Boolean} */
65
+ const isKey = a => !globals.globals.defaults.hasOwnProperty(a);
66
+
67
+ // SVG
68
+
69
+ // Consider the following as CSS animation
70
+ // CSS opacity animation has better default values (opacity: 1 instead of 0))
71
+ // rotate is more commonly intended to be used as a transform
72
+ const svgCssReservedProperties = ['opacity', 'rotate', 'overflow', 'color'];
73
+
74
+ /**
75
+ * @param {Target} el
76
+ * @param {String} propertyName
77
+ * @return {Boolean}
78
+ */
79
+ const isValidSVGAttribute = (el, propertyName) => {
80
+ if (svgCssReservedProperties.includes(propertyName)) return false;
81
+ if (el.getAttribute(propertyName) || propertyName in el) {
82
+ if (propertyName === 'scale') { // Scale
83
+ const elParentNode = /** @type {SVGGeometryElement} */(/** @type {DOMTarget} */(el).parentNode);
84
+ // Only consider scale as a valid SVG attribute on filter element
85
+ return elParentNode && elParentNode.tagName === 'filter';
86
+ }
87
+ return true;
88
+ }
89
+ };
90
+
91
+ // Number
92
+
93
+ /**
94
+ * @param {Number|String} str
95
+ * @return {Number}
96
+ */
97
+ const parseNumber = str => isStr(str) ?
98
+ parseFloat(/** @type {String} */(str)) :
99
+ /** @type {Number} */(str);
100
+
101
+ // Math
102
+
103
+ const pow = Math.pow;
104
+ const sqrt = Math.sqrt;
105
+ const sin = Math.sin;
106
+ const cos = Math.cos;
107
+ const abs = Math.abs;
108
+ const exp = Math.exp;
109
+ const ceil = Math.ceil;
110
+ const floor = Math.floor;
111
+ const asin = Math.asin;
112
+ const max = Math.max;
113
+ const atan2 = Math.atan2;
114
+ const PI = Math.PI;
115
+ const _round = Math.round;
116
+
117
+ /**
118
+ * Clamps a value between min and max bounds
119
+ *
120
+ * @param {Number} v - Value to clamp
121
+ * @param {Number} min - Minimum boundary
122
+ * @param {Number} max - Maximum boundary
123
+ * @return {Number}
124
+ */
125
+ const clamp = (v, min, max) => v < min ? min : v > max ? max : v;
126
+
127
+ const powCache = {};
128
+
129
+ /**
130
+ * Rounds a number to specified decimal places
131
+ *
132
+ * @param {Number} v - Value to round
133
+ * @param {Number} decimalLength - Number of decimal places
134
+ * @return {Number}
135
+ */
136
+ const round = (v, decimalLength) => {
137
+ if (decimalLength < 0) return v;
138
+ if (!decimalLength) return _round(v);
139
+ let p = powCache[decimalLength];
140
+ if (!p) p = powCache[decimalLength] = 10 ** decimalLength;
141
+ return _round(v * p) / p;
142
+ };
143
+
144
+ /**
145
+ * Snaps a value to nearest increment or array value
146
+ *
147
+ * @param {Number} v - Value to snap
148
+ * @param {Number|Array<Number>} increment - Step size or array of snap points
149
+ * @return {Number}
150
+ */
151
+ const snap = (v, increment) => isArr(increment) ? increment.reduce((closest, cv) => (abs(cv - v) < abs(closest - v) ? cv : closest)) : increment ? _round(v / increment) * increment : v;
152
+
153
+ /**
154
+ * Linear interpolation between two values
155
+ *
156
+ * @param {Number} start - Starting value
157
+ * @param {Number} end - Ending value
158
+ * @param {Number} factor - Interpolation factor in the range [0, 1]
159
+ * @return {Number} The interpolated value
160
+ */
161
+ const lerp = (start, end, factor) => start + (end - start) * factor;
162
+
163
+ /**
164
+ * Replaces infinity with maximum safe value
165
+ *
166
+ * @param {Number} v - Value to check
167
+ * @return {Number}
168
+ */
169
+ const clampInfinity = v => v === Infinity ? consts.maxValue : v === -Infinity ? -consts.maxValue : v;
170
+
171
+ /**
172
+ * Normalizes time value with minimum threshold
173
+ *
174
+ * @param {Number} v - Time value to normalize
175
+ * @return {Number}
176
+ */
177
+ const normalizeTime = v => v <= consts.minValue ? consts.minValue : clampInfinity(round(v, 11));
178
+
179
+ // Arrays
180
+
181
+ /**
182
+ * @template T
183
+ * @param {T[]} a
184
+ * @return {T[]}
185
+ */
186
+ const cloneArray = a => isArr(a) ? [ ...a ] : a;
187
+
188
+ // Objects
189
+
190
+ /**
191
+ * @template T
192
+ * @template U
193
+ * @param {T} o1
194
+ * @param {U} o2
195
+ * @return {T & U}
196
+ */
197
+ const mergeObjects = (o1, o2) => {
198
+ const merged = /** @type {T & U} */({ ...o1 });
199
+ for (let p in o2) {
200
+ const o1p = /** @type {T & U} */(o1)[p];
201
+ merged[p] = isUnd(o1p) ? /** @type {T & U} */(o2)[p] : o1p;
202
+ } return merged;
203
+ };
204
+
205
+ // Linked lists
206
+
207
+ /**
208
+ * @param {Object} parent
209
+ * @param {Function} callback
210
+ * @param {Boolean} [reverse]
211
+ * @param {String} [prevProp]
212
+ * @param {String} [nextProp]
213
+ * @return {void}
214
+ */
215
+ const forEachChildren = (parent, callback, reverse, prevProp = '_prev', nextProp = '_next') => {
216
+ let next = parent._head;
217
+ let adjustedNextProp = nextProp;
218
+ if (reverse) {
219
+ next = parent._tail;
220
+ adjustedNextProp = prevProp;
221
+ }
222
+ while (next) {
223
+ const currentNext = next[adjustedNextProp];
224
+ callback(next);
225
+ next = currentNext;
226
+ }
227
+ };
228
+
229
+ /**
230
+ * @param {Object} parent
231
+ * @param {Object} child
232
+ * @param {String} [prevProp]
233
+ * @param {String} [nextProp]
234
+ * @return {void}
235
+ */
236
+ const removeChild = (parent, child, prevProp = '_prev', nextProp = '_next') => {
237
+ const prev = child[prevProp];
238
+ const next = child[nextProp];
239
+ prev ? prev[nextProp] = next : parent._head = next;
240
+ next ? next[prevProp] = prev : parent._tail = prev;
241
+ child[prevProp] = null;
242
+ child[nextProp] = null;
243
+ };
244
+
245
+ /**
246
+ * @param {Object} parent
247
+ * @param {Object} child
248
+ * @param {Function} [sortMethod]
249
+ * @param {String} prevProp
250
+ * @param {String} nextProp
251
+ * @return {void}
252
+ */
253
+ const addChild = (parent, child, sortMethod, prevProp = '_prev', nextProp = '_next') => {
254
+ let prev = parent._tail;
255
+ while (prev && sortMethod && sortMethod(prev, child)) prev = prev[prevProp];
256
+ const next = prev ? prev[nextProp] : parent._head;
257
+ prev ? prev[nextProp] = child : parent._head = child;
258
+ next ? next[prevProp] = child : parent._tail = child;
259
+ child[prevProp] = prev;
260
+ child[nextProp] = next;
261
+ };
262
+
263
+ exports.PI = PI;
264
+ exports._round = _round;
265
+ exports.abs = abs;
266
+ exports.addChild = addChild;
267
+ exports.asin = asin;
268
+ exports.atan2 = atan2;
269
+ exports.ceil = ceil;
270
+ exports.clamp = clamp;
271
+ exports.clampInfinity = clampInfinity;
272
+ exports.cloneArray = cloneArray;
273
+ exports.cos = cos;
274
+ exports.exp = exp;
275
+ exports.floor = floor;
276
+ exports.forEachChildren = forEachChildren;
277
+ exports.isArr = isArr;
278
+ exports.isCol = isCol;
279
+ exports.isFnc = isFnc;
280
+ exports.isHex = isHex;
281
+ exports.isHsl = isHsl;
282
+ exports.isKey = isKey;
283
+ exports.isNil = isNil;
284
+ exports.isNum = isNum;
285
+ exports.isObj = isObj;
286
+ exports.isRgb = isRgb;
287
+ exports.isStr = isStr;
288
+ exports.isSvg = isSvg;
289
+ exports.isUnd = isUnd;
290
+ exports.isValidSVGAttribute = isValidSVGAttribute;
291
+ exports.lerp = lerp;
292
+ exports.max = max;
293
+ exports.mergeObjects = mergeObjects;
294
+ exports.normalizeTime = normalizeTime;
295
+ exports.now = now;
296
+ exports.parseNumber = parseNumber;
297
+ exports.pow = pow;
298
+ exports.removeChild = removeChild;
299
+ exports.round = round;
300
+ exports.sin = sin;
301
+ exports.snap = snap;
302
+ exports.sqrt = sqrt;
303
+ exports.stringStartsWith = stringStartsWith;
304
+ exports.toLowerCase = toLowerCase;
@@ -0,0 +1,43 @@
1
+ export function toLowerCase(str: string): string;
2
+ export function stringStartsWith(str: string, sub: string): boolean;
3
+ export const now: () => number;
4
+ export const isArr: (arg: any) => arg is any[];
5
+ export function isObj(a: any): a is Record<string, any>;
6
+ export function isNum(a: any): a is number;
7
+ export function isStr(a: any): a is string;
8
+ export function isFnc(a: any): a is Function;
9
+ export function isUnd(a: any): a is undefined;
10
+ export function isNil(a: any): a is null | undefined;
11
+ export function isSvg(a: any): a is SVGElement;
12
+ export function isHex(a: any): boolean;
13
+ export function isRgb(a: any): boolean;
14
+ export function isHsl(a: any): boolean;
15
+ export function isCol(a: any): boolean;
16
+ export function isKey(a: any): boolean;
17
+ export function isValidSVGAttribute(el: Target, propertyName: string): boolean;
18
+ export function parseNumber(str: number | string): number;
19
+ export const pow: (x: number, y: number) => number;
20
+ export const sqrt: (x: number) => number;
21
+ export const sin: (x: number) => number;
22
+ export const cos: (x: number) => number;
23
+ export const abs: (x: number) => number;
24
+ export const exp: (x: number) => number;
25
+ export const ceil: (x: number) => number;
26
+ export const floor: (x: number) => number;
27
+ export const asin: (x: number) => number;
28
+ export const max: (...values: number[]) => number;
29
+ export const atan2: (y: number, x: number) => number;
30
+ export const PI: number;
31
+ export const _round: (x: number) => number;
32
+ export function clamp(v: number, min: number, max: number): number;
33
+ export function round(v: number, decimalLength: number): number;
34
+ export function snap(v: number, increment: number | Array<number>): number;
35
+ export function lerp(start: number, end: number, factor: number): number;
36
+ export function clampInfinity(v: number): number;
37
+ export function normalizeTime(v: number): number;
38
+ export function cloneArray<T>(a: T[]): T[];
39
+ export function mergeObjects<T, U>(o1: T, o2: U): T & U;
40
+ export function forEachChildren(parent: any, callback: Function, reverse?: boolean, prevProp?: string, nextProp?: string): void;
41
+ export function removeChild(parent: any, child: any, prevProp?: string, nextProp?: string): void;
42
+ export function addChild(parent: any, child: any, sortMethod?: Function, prevProp?: string, nextProp?: string): void;
43
+ import type { Target } from '../types/index.js';
@@ -0,0 +1,261 @@
1
+ /**
2
+ * Anime.js - core - ESM
3
+ * @version v4.2.0
4
+ * @license MIT
5
+ * @copyright 2025 - Julian Garnier
6
+ */
7
+
8
+ import { isBrowser, maxValue, minValue, hexTestRgx, lowerCaseRgx } from './consts.js';
9
+ import { globals } from './globals.js';
10
+
11
+ /**
12
+ * @import {
13
+ * Target,
14
+ * DOMTarget,
15
+ * } from '../types/index.js'
16
+ */
17
+
18
+ // Strings
19
+
20
+ /**
21
+ * @param {String} str
22
+ * @return {String}
23
+ */
24
+ const toLowerCase = str => str.replace(lowerCaseRgx, '$1-$2').toLowerCase();
25
+
26
+ /**
27
+ * Prioritize this method instead of regex when possible
28
+ * @param {String} str
29
+ * @param {String} sub
30
+ * @return {Boolean}
31
+ */
32
+ const stringStartsWith = (str, sub) => str.indexOf(sub) === 0;
33
+
34
+ // Note: Date.now is used instead of performance.now since it is precise enough for timings calculations, performs slightly faster and works in Node.js environement.
35
+ const now = Date.now;
36
+
37
+ // Types checkers
38
+
39
+ const isArr = Array.isArray;
40
+ /**@param {any} a @return {a is Record<String, any>} */
41
+ const isObj = a => a && a.constructor === Object;
42
+ /**@param {any} a @return {a is Number} */
43
+ const isNum = a => typeof a === 'number' && !isNaN(a);
44
+ /**@param {any} a @return {a is String} */
45
+ const isStr = a => typeof a === 'string';
46
+ /**@param {any} a @return {a is Function} */
47
+ const isFnc = a => typeof a === 'function';
48
+ /**@param {any} a @return {a is undefined} */
49
+ const isUnd = a => typeof a === 'undefined';
50
+ /**@param {any} a @return {a is null | undefined} */
51
+ const isNil = a => isUnd(a) || a === null;
52
+ /**@param {any} a @return {a is SVGElement} */
53
+ const isSvg = a => isBrowser && a instanceof SVGElement;
54
+ /**@param {any} a @return {Boolean} */
55
+ const isHex = a => hexTestRgx.test(a);
56
+ /**@param {any} a @return {Boolean} */
57
+ const isRgb = a => stringStartsWith(a, 'rgb');
58
+ /**@param {any} a @return {Boolean} */
59
+ const isHsl = a => stringStartsWith(a, 'hsl');
60
+ /**@param {any} a @return {Boolean} */
61
+ const isCol = a => isHex(a) || isRgb(a) || isHsl(a);
62
+ /**@param {any} a @return {Boolean} */
63
+ const isKey = a => !globals.defaults.hasOwnProperty(a);
64
+
65
+ // SVG
66
+
67
+ // Consider the following as CSS animation
68
+ // CSS opacity animation has better default values (opacity: 1 instead of 0))
69
+ // rotate is more commonly intended to be used as a transform
70
+ const svgCssReservedProperties = ['opacity', 'rotate', 'overflow', 'color'];
71
+
72
+ /**
73
+ * @param {Target} el
74
+ * @param {String} propertyName
75
+ * @return {Boolean}
76
+ */
77
+ const isValidSVGAttribute = (el, propertyName) => {
78
+ if (svgCssReservedProperties.includes(propertyName)) return false;
79
+ if (el.getAttribute(propertyName) || propertyName in el) {
80
+ if (propertyName === 'scale') { // Scale
81
+ const elParentNode = /** @type {SVGGeometryElement} */(/** @type {DOMTarget} */(el).parentNode);
82
+ // Only consider scale as a valid SVG attribute on filter element
83
+ return elParentNode && elParentNode.tagName === 'filter';
84
+ }
85
+ return true;
86
+ }
87
+ };
88
+
89
+ // Number
90
+
91
+ /**
92
+ * @param {Number|String} str
93
+ * @return {Number}
94
+ */
95
+ const parseNumber = str => isStr(str) ?
96
+ parseFloat(/** @type {String} */(str)) :
97
+ /** @type {Number} */(str);
98
+
99
+ // Math
100
+
101
+ const pow = Math.pow;
102
+ const sqrt = Math.sqrt;
103
+ const sin = Math.sin;
104
+ const cos = Math.cos;
105
+ const abs = Math.abs;
106
+ const exp = Math.exp;
107
+ const ceil = Math.ceil;
108
+ const floor = Math.floor;
109
+ const asin = Math.asin;
110
+ const max = Math.max;
111
+ const atan2 = Math.atan2;
112
+ const PI = Math.PI;
113
+ const _round = Math.round;
114
+
115
+ /**
116
+ * Clamps a value between min and max bounds
117
+ *
118
+ * @param {Number} v - Value to clamp
119
+ * @param {Number} min - Minimum boundary
120
+ * @param {Number} max - Maximum boundary
121
+ * @return {Number}
122
+ */
123
+ const clamp = (v, min, max) => v < min ? min : v > max ? max : v;
124
+
125
+ const powCache = {};
126
+
127
+ /**
128
+ * Rounds a number to specified decimal places
129
+ *
130
+ * @param {Number} v - Value to round
131
+ * @param {Number} decimalLength - Number of decimal places
132
+ * @return {Number}
133
+ */
134
+ const round = (v, decimalLength) => {
135
+ if (decimalLength < 0) return v;
136
+ if (!decimalLength) return _round(v);
137
+ let p = powCache[decimalLength];
138
+ if (!p) p = powCache[decimalLength] = 10 ** decimalLength;
139
+ return _round(v * p) / p;
140
+ };
141
+
142
+ /**
143
+ * Snaps a value to nearest increment or array value
144
+ *
145
+ * @param {Number} v - Value to snap
146
+ * @param {Number|Array<Number>} increment - Step size or array of snap points
147
+ * @return {Number}
148
+ */
149
+ const snap = (v, increment) => isArr(increment) ? increment.reduce((closest, cv) => (abs(cv - v) < abs(closest - v) ? cv : closest)) : increment ? _round(v / increment) * increment : v;
150
+
151
+ /**
152
+ * Linear interpolation between two values
153
+ *
154
+ * @param {Number} start - Starting value
155
+ * @param {Number} end - Ending value
156
+ * @param {Number} factor - Interpolation factor in the range [0, 1]
157
+ * @return {Number} The interpolated value
158
+ */
159
+ const lerp = (start, end, factor) => start + (end - start) * factor;
160
+
161
+ /**
162
+ * Replaces infinity with maximum safe value
163
+ *
164
+ * @param {Number} v - Value to check
165
+ * @return {Number}
166
+ */
167
+ const clampInfinity = v => v === Infinity ? maxValue : v === -Infinity ? -maxValue : v;
168
+
169
+ /**
170
+ * Normalizes time value with minimum threshold
171
+ *
172
+ * @param {Number} v - Time value to normalize
173
+ * @return {Number}
174
+ */
175
+ const normalizeTime = v => v <= minValue ? minValue : clampInfinity(round(v, 11));
176
+
177
+ // Arrays
178
+
179
+ /**
180
+ * @template T
181
+ * @param {T[]} a
182
+ * @return {T[]}
183
+ */
184
+ const cloneArray = a => isArr(a) ? [ ...a ] : a;
185
+
186
+ // Objects
187
+
188
+ /**
189
+ * @template T
190
+ * @template U
191
+ * @param {T} o1
192
+ * @param {U} o2
193
+ * @return {T & U}
194
+ */
195
+ const mergeObjects = (o1, o2) => {
196
+ const merged = /** @type {T & U} */({ ...o1 });
197
+ for (let p in o2) {
198
+ const o1p = /** @type {T & U} */(o1)[p];
199
+ merged[p] = isUnd(o1p) ? /** @type {T & U} */(o2)[p] : o1p;
200
+ } return merged;
201
+ };
202
+
203
+ // Linked lists
204
+
205
+ /**
206
+ * @param {Object} parent
207
+ * @param {Function} callback
208
+ * @param {Boolean} [reverse]
209
+ * @param {String} [prevProp]
210
+ * @param {String} [nextProp]
211
+ * @return {void}
212
+ */
213
+ const forEachChildren = (parent, callback, reverse, prevProp = '_prev', nextProp = '_next') => {
214
+ let next = parent._head;
215
+ let adjustedNextProp = nextProp;
216
+ if (reverse) {
217
+ next = parent._tail;
218
+ adjustedNextProp = prevProp;
219
+ }
220
+ while (next) {
221
+ const currentNext = next[adjustedNextProp];
222
+ callback(next);
223
+ next = currentNext;
224
+ }
225
+ };
226
+
227
+ /**
228
+ * @param {Object} parent
229
+ * @param {Object} child
230
+ * @param {String} [prevProp]
231
+ * @param {String} [nextProp]
232
+ * @return {void}
233
+ */
234
+ const removeChild = (parent, child, prevProp = '_prev', nextProp = '_next') => {
235
+ const prev = child[prevProp];
236
+ const next = child[nextProp];
237
+ prev ? prev[nextProp] = next : parent._head = next;
238
+ next ? next[prevProp] = prev : parent._tail = prev;
239
+ child[prevProp] = null;
240
+ child[nextProp] = null;
241
+ };
242
+
243
+ /**
244
+ * @param {Object} parent
245
+ * @param {Object} child
246
+ * @param {Function} [sortMethod]
247
+ * @param {String} prevProp
248
+ * @param {String} nextProp
249
+ * @return {void}
250
+ */
251
+ const addChild = (parent, child, sortMethod, prevProp = '_prev', nextProp = '_next') => {
252
+ let prev = parent._tail;
253
+ while (prev && sortMethod && sortMethod(prev, child)) prev = prev[prevProp];
254
+ const next = prev ? prev[nextProp] : parent._head;
255
+ prev ? prev[nextProp] = child : parent._head = child;
256
+ next ? next[prevProp] = child : parent._tail = child;
257
+ child[prevProp] = prev;
258
+ child[nextProp] = next;
259
+ };
260
+
261
+ export { PI, _round, abs, addChild, asin, atan2, ceil, clamp, clampInfinity, cloneArray, cos, exp, floor, forEachChildren, isArr, isCol, isFnc, isHex, isHsl, isKey, isNil, isNum, isObj, isRgb, isStr, isSvg, isUnd, isValidSVGAttribute, lerp, max, mergeObjects, normalizeTime, now, parseNumber, pow, removeChild, round, sin, snap, sqrt, stringStartsWith, toLowerCase };