motion 10.3.1 → 10.5.0-alpha.2

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 (210) hide show
  1. package/README.md +0 -19
  2. package/dist/main.cjs.js +11 -13
  3. package/dist/main.es.js +7 -6
  4. package/dist/motion.min.js +1 -1
  5. package/dist/motion.umd.js +236 -19
  6. package/dist/react.cjs.js +7 -2
  7. package/dist/react.es.js +1 -1
  8. package/dist/size-index.js +1 -0
  9. package/lib/index.js +5 -0
  10. package/lib/index.js.map +1 -0
  11. package/lib/react.js +2 -0
  12. package/lib/react.js.map +1 -0
  13. package/lib/vue.js +2 -0
  14. package/lib/vue.js.map +1 -0
  15. package/package.json +8 -136
  16. package/react/package.json +1 -1
  17. package/types/index.d.ts +3 -7
  18. package/types/index.d.ts.map +1 -0
  19. package/types/react.d.ts +2 -0
  20. package/types/react.d.ts.map +1 -0
  21. package/types/vue.d.ts +2 -0
  22. package/types/vue.d.ts.map +1 -0
  23. package/CHANGELOG.md +0 -91
  24. package/dist/size-animate-dom.js +0 -1
  25. package/dist/size-animate-style.js +0 -1
  26. package/dist/size-react.js +0 -1
  27. package/dist/size-spring.js +0 -1
  28. package/dist/size-timeline-dom.js +0 -1
  29. package/dist/size-webpack-animate.js +0 -1
  30. package/dist/targets/dom/animate-style.cjs.js +0 -182
  31. package/dist/targets/dom/animate-style.es.js +0 -178
  32. package/dist/targets/dom/animate.cjs.js +0 -42
  33. package/dist/targets/dom/animate.es.js +0 -38
  34. package/dist/targets/dom/data.cjs.js +0 -18
  35. package/dist/targets/dom/data.es.js +0 -14
  36. package/dist/targets/dom/style.cjs.js +0 -22
  37. package/dist/targets/dom/style.es.js +0 -18
  38. package/dist/targets/dom/timeline/index.cjs.js +0 -174
  39. package/dist/targets/dom/timeline/index.es.js +0 -169
  40. package/dist/targets/dom/timeline/utils/calc-time.cjs.js +0 -23
  41. package/dist/targets/dom/timeline/utils/calc-time.es.js +0 -19
  42. package/dist/targets/dom/timeline/utils/edit.cjs.js +0 -36
  43. package/dist/targets/dom/timeline/utils/edit.es.js +0 -31
  44. package/dist/targets/dom/timeline/utils/sort.cjs.js +0 -14
  45. package/dist/targets/dom/timeline/utils/sort.es.js +0 -10
  46. package/dist/targets/dom/utils/apply.cjs.js +0 -9
  47. package/dist/targets/dom/utils/apply.es.js +0 -4
  48. package/dist/targets/dom/utils/controls.cjs.js +0 -59
  49. package/dist/targets/dom/utils/controls.es.js +0 -54
  50. package/dist/targets/dom/utils/css-var.cjs.js +0 -29
  51. package/dist/targets/dom/utils/css-var.es.js +0 -23
  52. package/dist/targets/dom/utils/defaults.cjs.js +0 -13
  53. package/dist/targets/dom/utils/defaults.es.js +0 -9
  54. package/dist/targets/dom/utils/easing.cjs.js +0 -18
  55. package/dist/targets/dom/utils/easing.es.js +0 -10
  56. package/dist/targets/dom/utils/feature-detection.cjs.js +0 -31
  57. package/dist/targets/dom/utils/feature-detection.es.js +0 -27
  58. package/dist/targets/dom/utils/get-style-name.cjs.js +0 -13
  59. package/dist/targets/dom/utils/get-style-name.es.js +0 -9
  60. package/dist/targets/dom/utils/keyframes.cjs.js +0 -16
  61. package/dist/targets/dom/utils/keyframes.es.js +0 -11
  62. package/dist/targets/dom/utils/options.cjs.js +0 -13
  63. package/dist/targets/dom/utils/options.es.js +0 -9
  64. package/dist/targets/dom/utils/resolve-elements.cjs.js +0 -22
  65. package/dist/targets/dom/utils/resolve-elements.es.js +0 -18
  66. package/dist/targets/dom/utils/stop-animation.cjs.js +0 -19
  67. package/dist/targets/dom/utils/stop-animation.es.js +0 -15
  68. package/dist/targets/dom/utils/time.cjs.js +0 -7
  69. package/dist/targets/dom/utils/time.es.js +0 -3
  70. package/dist/targets/dom/utils/transforms.cjs.js +0 -85
  71. package/dist/targets/dom/utils/transforms.es.js +0 -74
  72. package/dist/targets/js/NumberAnimation.cjs.js +0 -144
  73. package/dist/targets/js/NumberAnimation.es.js +0 -140
  74. package/dist/targets/js/easing/cubic-bezier.cjs.js +0 -57
  75. package/dist/targets/js/easing/cubic-bezier.es.js +0 -53
  76. package/dist/targets/js/easing/glide/generator.cjs.js +0 -99
  77. package/dist/targets/js/easing/glide/generator.es.js +0 -95
  78. package/dist/targets/js/easing/glide/index.cjs.js +0 -10
  79. package/dist/targets/js/easing/glide/index.es.js +0 -6
  80. package/dist/targets/js/easing/spring/generator.cjs.js +0 -64
  81. package/dist/targets/js/easing/spring/generator.es.js +0 -57
  82. package/dist/targets/js/easing/spring/index.cjs.js +0 -10
  83. package/dist/targets/js/easing/spring/index.es.js +0 -6
  84. package/dist/targets/js/easing/steps.cjs.js +0 -15
  85. package/dist/targets/js/easing/steps.es.js +0 -11
  86. package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +0 -71
  87. package/dist/targets/js/easing/utils/create-generator-easing.es.js +0 -67
  88. package/dist/targets/js/easing/utils/get-function.cjs.js +0 -37
  89. package/dist/targets/js/easing/utils/get-function.es.js +0 -33
  90. package/dist/targets/js/easing/utils/has-reached-target.cjs.js +0 -10
  91. package/dist/targets/js/easing/utils/has-reached-target.es.js +0 -6
  92. package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +0 -34
  93. package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +0 -30
  94. package/dist/targets/js/utils/get-easing.cjs.js +0 -14
  95. package/dist/targets/js/utils/get-easing.es.js +0 -10
  96. package/dist/targets/js/utils/interpolate.cjs.js +0 -35
  97. package/dist/targets/js/utils/interpolate.es.js +0 -31
  98. package/dist/targets/js/utils/offset.cjs.js +0 -22
  99. package/dist/targets/js/utils/offset.es.js +0 -17
  100. package/dist/targets/react/animated.cjs.js +0 -126
  101. package/dist/targets/react/animated.es.js +0 -101
  102. package/dist/targets/react/context.cjs.js +0 -9
  103. package/dist/targets/react/context.es.js +0 -5
  104. package/dist/targets/react/hooks/use-animation.cjs.js +0 -47
  105. package/dist/targets/react/hooks/use-animation.es.js +0 -43
  106. package/dist/targets/react/hooks/use-exit.cjs.js +0 -27
  107. package/dist/targets/react/hooks/use-exit.es.js +0 -23
  108. package/dist/targets/react/hooks/use-gesture-state.cjs.js +0 -17
  109. package/dist/targets/react/hooks/use-gesture-state.es.js +0 -13
  110. package/dist/targets/react/hooks/use-hover.cjs.js +0 -24
  111. package/dist/targets/react/hooks/use-hover.es.js +0 -20
  112. package/dist/targets/react/hooks/use-press.cjs.js +0 -25
  113. package/dist/targets/react/hooks/use-press.es.js +0 -21
  114. package/dist/targets/react/hooks/use-viewport.cjs.js +0 -37
  115. package/dist/targets/react/hooks/use-viewport.es.js +0 -33
  116. package/dist/targets/react/index.cjs.js +0 -17
  117. package/dist/targets/react/index.es.js +0 -13
  118. package/dist/targets/react/utils/has-changed.cjs.js +0 -24
  119. package/dist/targets/react/utils/has-changed.es.js +0 -19
  120. package/dist/targets/react/utils/keyframes.cjs.js +0 -38
  121. package/dist/targets/react/utils/keyframes.es.js +0 -34
  122. package/dist/targets/react/utils/poses.cjs.js +0 -14
  123. package/dist/targets/react/utils/poses.es.js +0 -10
  124. package/dist/targets/react/utils/update-target.cjs.js +0 -20
  125. package/dist/targets/react/utils/update-target.es.js +0 -16
  126. package/dist/utils/array.cjs.js +0 -14
  127. package/dist/utils/array.es.js +0 -9
  128. package/dist/utils/clamp.cjs.js +0 -7
  129. package/dist/utils/clamp.es.js +0 -3
  130. package/dist/utils/is-number.cjs.js +0 -7
  131. package/dist/utils/is-number.es.js +0 -3
  132. package/dist/utils/mix.cjs.js +0 -28
  133. package/dist/utils/mix.es.js +0 -24
  134. package/dist/utils/noop.cjs.js +0 -9
  135. package/dist/utils/noop.es.js +0 -4
  136. package/dist/utils/progress.cjs.js +0 -20
  137. package/dist/utils/progress.es.js +0 -16
  138. package/dist/utils/stagger.cjs.js +0 -38
  139. package/dist/utils/stagger.es.js +0 -32
  140. package/dist/utils/velocity-per-second.cjs.js +0 -15
  141. package/dist/utils/velocity-per-second.es.js +0 -11
  142. package/dist/utils/wrap.cjs.js +0 -10
  143. package/dist/utils/wrap.es.js +0 -6
  144. package/types/react-entry.d.ts +0 -2
  145. package/types/targets/dom/animate-style.d.ts +0 -2
  146. package/types/targets/dom/animate.d.ts +0 -2
  147. package/types/targets/dom/data.d.ts +0 -2
  148. package/types/targets/dom/style.d.ts +0 -3
  149. package/types/targets/dom/timeline/index.d.ts +0 -15
  150. package/types/targets/dom/timeline/types.d.ts +0 -13
  151. package/types/targets/dom/timeline/utils/calc-time.d.ts +0 -2
  152. package/types/targets/dom/timeline/utils/edit.d.ts +0 -4
  153. package/types/targets/dom/timeline/utils/sort.d.ts +0 -2
  154. package/types/targets/dom/types.d.ts +0 -114
  155. package/types/targets/dom/utils/apply.d.ts +0 -3
  156. package/types/targets/dom/utils/controls.d.ts +0 -12
  157. package/types/targets/dom/utils/css-var.d.ts +0 -3
  158. package/types/targets/dom/utils/defaults.d.ts +0 -8
  159. package/types/targets/dom/utils/easing.d.ts +0 -6
  160. package/types/targets/dom/utils/feature-detection.d.ts +0 -8
  161. package/types/targets/dom/utils/get-style-name.d.ts +0 -1
  162. package/types/targets/dom/utils/keyframes.d.ts +0 -3
  163. package/types/targets/dom/utils/options.d.ts +0 -2
  164. package/types/targets/dom/utils/resolve-elements.d.ts +0 -4
  165. package/types/targets/dom/utils/stop-animation.d.ts +0 -6
  166. package/types/targets/dom/utils/time.d.ts +0 -1
  167. package/types/targets/dom/utils/transforms.d.ts +0 -20
  168. package/types/targets/js/NumberAnimation.d.ts +0 -24
  169. package/types/targets/js/easing/cubic-bezier.d.ts +0 -1
  170. package/types/targets/js/easing/glide/generator.d.ts +0 -5
  171. package/types/targets/js/easing/glide/index.d.ts +0 -2
  172. package/types/targets/js/easing/glide/types.d.ts +0 -14
  173. package/types/targets/js/easing/spring/generator.d.ts +0 -6
  174. package/types/targets/js/easing/spring/index.d.ts +0 -2
  175. package/types/targets/js/easing/spring/types.d.ts +0 -10
  176. package/types/targets/js/easing/steps.d.ts +0 -3
  177. package/types/targets/js/easing/utils/create-generator-easing.d.ts +0 -3
  178. package/types/targets/js/easing/utils/get-function.d.ts +0 -3
  179. package/types/targets/js/easing/utils/has-reached-target.d.ts +0 -1
  180. package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +0 -7
  181. package/types/targets/js/types.d.ts +0 -12
  182. package/types/targets/js/utils/get-easing.d.ts +0 -1
  183. package/types/targets/js/utils/interpolate.d.ts +0 -2
  184. package/types/targets/js/utils/offset.d.ts +0 -2
  185. package/types/targets/react/animated.d.ts +0 -3
  186. package/types/targets/react/context.d.ts +0 -3
  187. package/types/targets/react/hooks/use-animation.d.ts +0 -4
  188. package/types/targets/react/hooks/use-exit.d.ts +0 -3
  189. package/types/targets/react/hooks/use-gesture-state.d.ts +0 -4
  190. package/types/targets/react/hooks/use-hover.d.ts +0 -4
  191. package/types/targets/react/hooks/use-press.d.ts +0 -4
  192. package/types/targets/react/hooks/use-viewport.d.ts +0 -4
  193. package/types/targets/react/index.d.ts +0 -2
  194. package/types/targets/react/types.d.ts +0 -108
  195. package/types/targets/react/utils/has-changed.d.ts +0 -2
  196. package/types/targets/react/utils/keyframes.d.ts +0 -3
  197. package/types/targets/react/utils/poses.d.ts +0 -2
  198. package/types/targets/react/utils/supported-elements.d.ts +0 -8
  199. package/types/targets/react/utils/update-target.d.ts +0 -3
  200. package/types/utils/array.d.ts +0 -2
  201. package/types/utils/clamp.d.ts +0 -1
  202. package/types/utils/interpolate.d.ts +0 -0
  203. package/types/utils/is-number.d.ts +0 -1
  204. package/types/utils/mix.d.ts +0 -1
  205. package/types/utils/noop.d.ts +0 -2
  206. package/types/utils/progress.d.ts +0 -1
  207. package/types/utils/stagger.d.ts +0 -12
  208. package/types/utils/value-types.d.ts +0 -0
  209. package/types/utils/velocity-per-second.d.ts +0 -1
  210. package/types/utils/wrap.d.ts +0 -1
package/README.md CHANGED
@@ -1,19 +0,0 @@
1
- # Motion One
2
-
3
- A new animation library, built on the Web Animations API for the smallest filesize and the fastest performance.
4
-
5
- ## 📚 Documentation
6
-
7
- Full docs are available at [motion.dev](https://motion.dev).
8
-
9
- ## 🙌 Sponsors
10
-
11
- A huge thank you to all sponsors of this project, with a special shoutout to:
12
-
13
- - [Alex Frazer](https://github.com/AlexFrazer)
14
- - [Derek Reynolds](https://github.com/derekr)
15
- - [Martin Pitt](https://github.com/Martin-Pitt)
16
- - [Ryan Yogan](https://github.com/ryanyogan)
17
- - [Mihael Konjević](https://github.com/retro)
18
-
19
- [Become a sponsor](https://github.com/sponsors/mattgperry) and get access to the private Motion One repo. File issues, read the changelog and source code, and join discussions that help shape the future of the API.
package/dist/main.cjs.js CHANGED
@@ -2,18 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var animate = require('./targets/dom/animate.cjs.js');
6
- var animateStyle = require('./targets/dom/animate-style.cjs.js');
7
- var index = require('./targets/dom/timeline/index.cjs.js');
8
- var stagger = require('./utils/stagger.cjs.js');
9
- var index$1 = require('./targets/js/easing/spring/index.cjs.js');
10
- var index$2 = require('./targets/js/easing/glide/index.cjs.js');
5
+ var dom = require('@motionone/dom');
11
6
 
7
+ function test() {
8
+ console.log("test");
9
+ }
12
10
 
13
-
14
- exports.animate = animate.animate;
15
- exports.animateStyle = animateStyle.animateStyle;
16
- exports.timeline = index.timeline;
17
- exports.stagger = stagger.stagger;
18
- exports.spring = index$1.spring;
19
- exports.glide = index$2.glide;
11
+ exports.test = test;
12
+ Object.keys(dom).forEach(function (k) {
13
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
14
+ enumerable: true,
15
+ get: function () { return dom[k]; }
16
+ });
17
+ });
package/dist/main.es.js CHANGED
@@ -1,6 +1,7 @@
1
- export { animate } from './targets/dom/animate.es.js';
2
- export { animateStyle } from './targets/dom/animate-style.es.js';
3
- export { timeline } from './targets/dom/timeline/index.es.js';
4
- export { stagger } from './utils/stagger.es.js';
5
- export { spring } from './targets/js/easing/spring/index.es.js';
6
- export { glide } from './targets/js/easing/glide/index.es.js';
1
+ export * from '@motionone/dom';
2
+
3
+ function test() {
4
+ console.log("test");
5
+ }
6
+
7
+ export { test };
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],animations:{},generators:{},prevGeneratorState:{}}),e.get(t)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i=()=>{},s=t=>t,r=["","X","Y","Z"],o={x:"translateX",y:"translateY",z:"translateZ"},l={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},c={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:l,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:s},skew:l},u=new Map,h=t=>`--motion-${t}`,f=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{r.forEach((e=>{f.push(t+e),u.set(h(t+e),c[t])}))}));const d=(t,e)=>f.indexOf(t)-f.indexOf(e),p=new Set(f),y=t=>p.has(t),m=t=>t.sort(d).reduce(g,"").trim(),g=(t,e)=>`${t} ${e}(var(${h(e)}))`,v=t=>t.startsWith("--"),b=new Set;const M=t=>1e3*t,x=t=>"number"==typeof t,S=t=>Array.isArray(t)&&!x(t[0]),T=t=>"object"==typeof t&&Boolean(t.createAnimation),O=t=>(t=>Array.isArray(t)&&x(t[0]))(t)?w(t):t,w=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,j=t=>document.createElement("div").animate(t,{duration:.001}),D={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{j({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(j({opacity:[0,1]}).finished)},k={},A={};for(const t in D)A[t]=()=>(void 0===k[t]&&(k[t]=D[t]()),k[t]);const P={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},R=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function $(t,e,n,a){if(t===e&&n===a)return s;const i=e=>function(t,e,n,a,i){let s,r,o=0;do{r=e+(n-e)/2,s=R(r,a,i)-t,s>0?n=r:e=r}while(Math.abs(s)>1e-7&&++o<12);return r}(e,0,1,t,n);return t=>0===t||1===t?t:R(i(t),e,a)}const E=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return s=0,r=1,o=i/t,Math.min(Math.max(o,s),r);var s,r,o},V={ease:$(.25,.1,.25,1),"ease-in":$(.42,0,1,1),"ease-in-out":$(.42,0,.58,1),"ease-out":$(0,0,.58,1)},q=/\((.*?)\)/;function W(t){if("function"==typeof t)return t;if(Array.isArray(t))return $(...t);if(V[t])return V[t];if(t.startsWith("steps")){const e=q.exec(t);if(e){const t=e[1].split(",");return E(parseFloat(t[0]),t[1].trim())}}return s}const F=(t,e,n)=>-n*t+n*e+t,U=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function B(t,e){return S(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function C(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=U(0,e,a);t.push(F(n,1,i))}}function z(t){const e=[0];return C(e,t-1),e}function G(t,e=z(t.length),n=s){const a=t.length,i=a-e.length;return i>0&&C(e,i),i=>{let s=0;for(;s<a-2&&!(i<e[s+1]);s++);let r=(o=U(e[s],e[s+1],i),Math.min(1,Math.max(o,0)));var o;return r=B(n,s)(r),F(t[s],t[s+1],r)}}class K{constructor(t,e=[0,1],{easing:n=P.easing,duration:a=P.duration,delay:i=P.delay,endDelay:s=P.endDelay,repeat:r=P.repeat,offset:o,direction:l="normal"}={}){this.startTime=0,this.rate=1,this.t=0,this.cancelT=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e}));const c=a*(r+1);T(n)&&(n="ease");const u=G(e,o,S(n)?n.map(W):W(n));this.tick=e=>{this.pauseTime&&(e=this.pauseTime);let n=(e-this.startTime)*this.rate;this.t=n,n/=1e3,n=Math.max(n-i,0),"finished"===this.playState&&(n=c);const r=n/a;let o=Math.floor(r),h=r%1;!h&&r>=1&&(h=1),1===h&&o--;const f=o%2;("reverse"===l||"alternate"===l&&f||"alternate-reverse"===l&&!f)&&(h=1-h);const d=u(n>=c?1:Math.min(h,1));t(d);"finished"===this.playState||n>=c+s?(this.playState="finished",this.resolve(d)):"idle"!==this.playState&&requestAnimationFrame(this.tick)},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime?this.startTime=t-(this.pauseTime-this.startTime):this.startTime||(this.startTime=t),this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}cancel(){this.playState="idle",this.tick(this.cancelT),this.reject(!1)}reverse(){this.rate*=-1}commitStyles(){this.cancelT=this.t}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const X=t=>Array.isArray(t)?t:[t],Y=(t,e)=>{let n=v(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=u.get(e);t&&(n=t.initialValue)}return n};function Z(t){if(t)try{"finished"!==t.playState&&t.commitStyles(),t.cancel()}catch(t){}}function _(t,e,a,s={}){let r,{duration:l=P.duration,delay:c=P.delay,endDelay:f=P.endDelay,repeat:d=P.repeat,easing:p=P.easing,direction:g,offset:w,allowWebkitAcceleration:j=!1}=s;const D=n(t);let k=A.waapi(),R=i;const $=y(e);$&&((t,e)=>{o[e]&&(e=o[e]);const{transforms:a}=n(t);var i,s;s=e,-1===(i=a).indexOf(s)&&i.push(s),t.style.transform=m(a)})(t,e);const E=function(t){return o[t]&&(t=o[t]),y(t)?h(t):t}(e),V=u.get(E);return Z(D.animations[E]),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=Y(t,E))&&void 0!==e?e:null==V?void 0:V.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(a),e);if(T(p)){const t=p.createAnimation(n,e,$,E,D);p=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(l=t.duration)}if(v(E)?(R=((t,e)=>n=>t.style.setProperty(e,n))(t,E),A.cssRegisterProperty()?function(t){if(!b.has(t)){b.add(t);try{const{syntax:e,initialValue:n}=u.has(t)?u.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(E):k=!1):R=((t,e)=>n=>t.style[e]=n)(t,E),k){V&&(n=n.map((t=>x(t)?V.toDefaultUnit(t):t))),A.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:M(c),duration:M(l),endDelay:M(f),easing:S(p)?void 0:O(p),direction:g,iterations:d+1,fill:"both"};r=t.animate({[E]:n,offset:w,easing:S(p)?p.map(O):void 0},a),r.finished||(r.finished=new Promise(((t,e)=>{r.onfinish=t,r.oncancel=e})));const s=n[n.length-1];r.finished.then((()=>{R(s),r.cancel()})).catch(i),j||(r.playbackRate=1.000001)}else if($&&n.every(x)){if(1===n.length&&n.unshift(parseFloat(e())),V){const t=R;R=e=>t(V.toDefaultUnit(e))}r=new K(R,n,Object.assign(Object.assign({},s),{duration:l,easing:p}))}else{const t=n[n.length-1];R(V&&x(t)?V.toDefaultUnit(t):t)}return D.animations[E]=r,null==r||r.finished.then((()=>{D.animations[E]=void 0,D.generators[E]=void 0,D.prevGeneratorState[E]=void 0})).catch(i),r}}const I=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function H(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const J=t=>t(),L=(t,e)=>new Proxy({animations:t.map(J).filter(Boolean),duration:e},Q),N=t=>t.animations[0],Q={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let s=(null===(n=N(t))||void 0===n?void 0:n[e])||0;return s?s/1e3:0;case"playbackRate":return null===(a=N(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(tt)).catch(i)),t.finished;case"stop":return()=>t.animations.forEach(Z);default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=M(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},tt=t=>t.finished;function et(t,e,n){return"function"==typeof t?t(e,n):t}function nt(t,e,n,a){var i;return x(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function at(t,e,n,i,s,r){!function(t,e,n){for(let i=0;i<t.length;i++){const s=t[i];s.at>e&&s.at<n&&(a(t,s),i--)}}(t,s,r);for(let a=0;a<e.length;a++)t.push({value:e[a],at:F(s,r,i[a]),easing:B(n,a)})}function it(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function st(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function rt(t,e){return e[t]||(e[t]=[]),e[t]}const ot=({stiffness:t=100,damping:e=10,mass:n=1,from:a=0,to:i=1,velocity:s=0,restSpeed:r=2,restDistance:o=.5}={})=>{const l={done:!1,value:a,target:i,velocity:s=s?s/1e3:0,hasReachedTarget:!1},c=((t=100,e=10,n=1)=>e/(2*Math.sqrt(t*n)))(t,e,n),u=i-a,h=Math.sqrt(t/n)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(h,c);let d;return d=c<1?t=>i-Math.exp(-c*h*t)*((c*h*u-s)/f*Math.sin(f*t)+u*Math.cos(f*t)):t=>i-Math.exp(-h*t)*(u+(s+h*u)*t),{next:t=>{l.value=d(t),l.velocity=0===t?s:lt(d,t,l.value);const e=Math.abs(l.velocity)<=r,n=Math.abs(i-l.value)<=o;var c,u,h;return l.done=e&&n,l.hasReachedTarget=(c=a,u=i,h=l.value,c<u&&h>=u||c>u&&h<=u),l}}};function lt(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(s=5)?i*(1e3/s):0;var i,s}function ct(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,s=0,r=!1)=>{const o=`${e}-${i}-${s}-${r}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:s,restSpeed:r?.05:2,restDistance:r?.01:.5},n))),a.get(o)},s=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t.next(0);const i=[a.value];for(;!a.done&&n<1e4;)a=t.next(n),i.push(a.done?a.target:a.value),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const s=n-10;return 1===i.length&&i.push(a.value),{keyframes:i,duration:s/1e3,overshootDuration:(null!=e?e:s)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,r)=>{let o,l;const c=t.length;if(n&&c<=2&&t.every(ut)){const n=a&&r&&r.prevGeneratorState[a],u=n&&(1===c||2===c&&null===t[0])?n.velocity:0,h=t[c-1],f=1===c?null:t[0],d=null===f?n?n.value:parseFloat(e()):f;l=i(d,h,u,null==a?void 0:a.includes("scale"));const p=s(l);o=Object.assign(Object.assign({},p),{easing:"linear"})}else{l=i(0,100);o={easing:"ease",duration:s(l).overshootDuration}}return l&&r&&a&&(r.generators[a]=l),o}}}}const ut=t=>"string"!=typeof t,ht=ct(ot),ft=ct((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:s,changeTarget:r,min:o,max:l,restDistance:c=.5,restSpeed:u})=>{a=M(a);const h={value:t,target:t,velocity:e,hasReachedTarget:!1,done:!1},f=t=>void 0===o?l:void 0===l||Math.abs(o-t)<Math.abs(l-t)?o:l;let d=n*e;const p=t+d,y=void 0===r?p:r(p);h.target=y,y!==p&&(d=y-t);const m=t=>-d*Math.exp(-t/a),g=t=>y+m(t),v=t=>{const n=m(t),a=g(t);h.done=Math.abs(n)<=c,h.value=h.done?y:a,h.velocity=0===t?e:lt(g,t,h.value)};let b,x;const S=t=>{var e;(e=h.value,void 0!==o&&e<o||void 0!==l&&e>l)&&(b=t,x=ot({from:h.value,to:f(h.value),velocity:h.velocity,damping:i,stiffness:s,restDistance:c,restSpeed:u}))};return S(0),{next:t=>{let e=!1;return x||void 0!==b||(e=!0,v(t),S(t)),void 0!==b&&t>b?(h.hasReachedTarget=!0,x.next(t-b)):(h.hasReachedTarget=!1,!e&&v(t),h)}}}));t.animate=function(t,e,n={}){var a;const i=(t=H(t)).length,s=[];for(let a=0;a<i;a++){const r=t[a];for(const t in e){const o=I(n,t);o.delay=et(o.delay,a,i);const l=_(r,t,e[t],o);s.push(l)}}return L(s,null!==(a=n.duration)&&void 0!==a?a:P.duration)},t.animateStyle=_,t.glide=ft,t.spring=ht,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const r=x(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),o=Math.abs(r-i);let l=t*o;if(a){const t=s*i;l=W(a)(l/t)*t}return e+l}},t.timeline=function(t,e={}){var n,a;const i=function(t,e={}){var{defaultOptions:n={}}=e,a=function(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}(e,["defaultOptions"]);const i=[],s=new Map,r={},o=new Map;let l=0,c=0,u=0;for(let e=0;e<t.length;e++){const[a,i,h={}]=t[e];void 0!==h.at&&(c=nt(c,h.at,l,o));let f=0;const d=H(a,r),p=d.length;for(let t=0;t<p;t++){const e=st(d[t],s);for(const a in i){const s=rt(a,e),r=X(i[a]),o=I(h,a);let{duration:l=n.duration||P.duration,easing:d=n.easing||P.easing}=o;const y=et(h.delay,t,p)||0,m=c+y,g=m+l;let{offset:v=z(r.length)}=o;1===v.length&&0===v[0]&&(v[1]=1);const b=length-r.length;b>0&&C(v,b),1===r.length&&r.unshift(null),at(s,r,d,v,m,g),f=Math.max(y+l,f),u=Math.max(g,u)}}l=c,c+=f}return s.forEach(((t,e)=>{for(const s in t){const r=t[s];r.sort(it);const o=[],l=[],c=[];for(let t=0;t<r.length;t++){const{at:e,value:n,easing:a}=r[t];o.push(n),l.push(U(0,u,e)),c.push(a||P.easing)}0!==l[0]&&(l.unshift(0),o.unshift(o[0]),c.unshift("linear")),1!==l[l.length-1]&&(l.push(1),o.push(null)),i.push([e,s,o,Object.assign(Object.assign(Object.assign({},n),{duration:u,easing:c,offset:l}),a)])}})),i}(t,e),s=i.map((t=>_(...t))).filter(Boolean);return L(s,null!==(a=null===(n=i[0])||void 0===n?void 0:n[3].duration)&&void 0!==a?a:P.duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Motion={})}(this,(function(t){"use strict";const e=new WeakMap;function n(t){return e.has(t)||e.set(t,{transforms:[],animations:{},generators:{},prevGeneratorState:{}}),e.get(t)}function a(t,e){-1===t.indexOf(e)&&t.push(e)}function i(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const s=()=>{},r=t=>t,o=["","X","Y","Z"],l={x:"translateX",y:"translateY",z:"translateZ"},c={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},u={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:c,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:r},skew:c},f=new Map,h=t=>`--motion-${t}`,d=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{o.forEach((e=>{d.push(t+e),f.set(h(t+e),u[t])}))}));const p=(t,e)=>d.indexOf(t)-d.indexOf(e),m=new Set(d),y=t=>m.has(t),g=t=>t.sort(p).reduce(v,"").trim(),v=(t,e)=>`${t} ${e}(var(${h(e)}))`,b=t=>t.startsWith("--"),x=new Set;const M=t=>1e3*t,S=t=>"number"==typeof t,O=t=>Array.isArray(t)&&!S(t[0]),T=t=>"object"==typeof t&&Boolean(t.createAnimation),w=t=>(t=>Array.isArray(t)&&S(t[0]))(t)?A(t):t,A=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,j=t=>document.createElement("div").animate(t,{duration:.001}),D={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{j({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(j({opacity:[0,1]}).finished)},k={},P={};for(const t in D)P[t]=()=>(void 0===k[t]&&(k[t]=D[t]()),k[t]);const $={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},R=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function E(t,e,n,a){if(t===e&&n===a)return r;const i=e=>function(t,e,n,a,i){let s,r,o=0;do{r=e+(n-e)/2,s=R(r,a,i)-t,s>0?n=r:e=r}while(Math.abs(s)>1e-7&&++o<12);return r}(e,0,1,t,n);return t=>0===t||1===t?t:R(i(t),e,a)}const U=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return s=0,r=1,o=i/t,Math.min(Math.max(o,s),r);var s,r,o},q={ease:E(.25,.1,.25,1),"ease-in":E(.42,0,1,1),"ease-in-out":E(.42,0,.58,1),"ease-out":E(0,0,.58,1)},C=/\((.*?)\)/;function V(t){if("function"==typeof t)return t;if(Array.isArray(t))return E(...t);if(q[t])return q[t];if(t.startsWith("steps")){const e=C.exec(t);if(e){const t=e[1].split(",");return U(parseFloat(t[0]),t[1].trim())}}return r}const W=(t,e,n)=>-n*t+n*e+t,F=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function B(t,e){return O(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function z(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=F(0,e,a);t.push(W(n,1,i))}}function G(t){const e=[0];return z(e,t-1),e}function Z(t,e=G(t.length),n=r){const a=t.length,i=a-e.length;return i>0&&z(e,i),i=>{let s=0;for(;s<a-2&&!(i<e[s+1]);s++);let r=(o=F(e[s],e[s+1],i),Math.min(1,Math.max(o,0)));var o;return r=B(n,s)(r),W(t[s],t[s+1],r)}}class K{constructor(t,e=[0,1],{easing:n=$.easing,duration:a=$.duration,delay:i=$.delay,endDelay:s=$.endDelay,repeat:r=$.repeat,offset:o,direction:l="normal"}={}){this.startTime=0,this.rate=1,this.t=0,this.cancelTimestamp=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e}));const c=a*(r+1);T(n)&&(n="ease");const u=Z(e,o,O(n)?n.map(V):V(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let r=(e-this.startTime)*this.rate;this.t=r,r/=1e3,r=Math.max(r-i,0),"finished"===this.playState&&(r=c);const o=r/a;let f=Math.floor(o),h=o%1;!h&&o>=1&&(h=1),1===h&&f--;const d=f%2;("reverse"===l||"alternate"===l&&d||"alternate-reverse"===l&&!d)&&(h=1-h);const p=u(r>=c?1:Math.min(h,1));t(p);"finished"===this.playState||r>=c+s?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,p)):"idle"!==this.playState&&requestAnimationFrame(this.tick)},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime?this.startTime=t-(this.pauseTime-this.startTime):this.startTime||(this.startTime=t),this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}cancel(){var t;this.playState="idle",this.tick(this.cancelTimestamp),null===(t=this.reject)||void 0===t||t.call(this,!1)}reverse(){this.rate*=-1}commitStyles(){this.cancelTimestamp=performance.now()}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const X=t=>Array.isArray(t)?t:[t];function Y(t){return l[t]&&(t=l[t]),y(t)?h(t):t}const _=(t,e)=>{e=Y(e);let n=b(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=f.get(e);t&&(n=t.initialValue)}return n};function I(t){if(t)try{"finished"!==t.playState&&t.commitStyles(),t.cancel()}catch(t){}}function L(t,e,i,r={}){let o,{duration:c=$.duration,delay:u=$.delay,endDelay:h=$.endDelay,repeat:d=$.repeat,easing:p=$.easing,direction:m,offset:v,allowWebkitAcceleration:A=!1}=r;const j=n(t);let D=P.waapi(),k=s;const R=y(e);R&&((t,e)=>{l[e]&&(e=l[e]);const{transforms:i}=n(t);a(i,e),t.style.transform=g(i)})(t,e);const E=Y(e),U=f.get(E);return I(j.animations[E]),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=_(t,E))&&void 0!==e?e:null==U?void 0:U.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(X(i),e);if(T(p)){const t=p.createAnimation(n,e,R,E,j);p=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(c=t.duration)}if(b(E)?(k=((t,e)=>n=>t.style.setProperty(e,n))(t,E),P.cssRegisterProperty()?function(t){if(!x.has(t)){x.add(t);try{const{syntax:e,initialValue:n}=f.has(t)?f.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(E):D=!1):k=((t,e)=>n=>t.style[e]=n)(t,E),D){U&&(n=n.map((t=>S(t)?U.toDefaultUnit(t):t))),P.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:M(u),duration:M(c),endDelay:M(h),easing:O(p)?void 0:w(p),direction:m,iterations:d+1,fill:"both"};o=t.animate({[E]:n,offset:v,easing:O(p)?p.map(w):void 0},a),o.finished||(o.finished=new Promise(((t,e)=>{o.onfinish=t,o.oncancel=e})));const i=n[n.length-1];o.finished.then((()=>{k(i),o.cancel()})).catch(s),A||(o.playbackRate=1.000001)}else if(R&&n.every(S)){if(1===n.length&&n.unshift(parseFloat(e())),U){const t=k;k=e=>t(U.toDefaultUnit(e))}o=new K(k,n,Object.assign(Object.assign({},r),{duration:c,easing:p}))}else{const t=n[n.length-1];k(U&&S(t)?U.toDefaultUnit(t):t)}return j.animations[E]=o,null==o||o.finished.then((()=>{j.animations[E]=void 0,j.generators[E]=void 0,j.prevGeneratorState[E]=void 0})).catch(s),o}}const H=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function J(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const N=t=>t(),Q=(t,e)=>new Proxy({animations:t.map(N).filter(Boolean),duration:e},et),tt=t=>t.animations[0],et={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let i=(null===(n=tt(t))||void 0===n?void 0:n[e])||0;return i?i/1e3:0;case"playbackRate":return null===(a=tt(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(nt)).catch(s)),t.finished;case"stop":return()=>t.animations.forEach(I);default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=M(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},nt=t=>t.finished;function at(t,e,n){return"function"==typeof t?t(e,n):t}function it(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}function st(t,e,n,a){var i;return S(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function rt(t,e,n,a,s,r){!function(t,e,n){for(let a=0;a<t.length;a++){const s=t[a];s.at>e&&s.at<n&&(i(t,s),a--)}}(t,s,r);for(let i=0;i<e.length;i++)t.push({value:e[i],at:W(s,r,a[i]),easing:B(n,i)})}function ot(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function lt(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ct(t,e){return e[t]||(e[t]=[]),e[t]}const ut=({stiffness:t=100,damping:e=10,mass:n=1,from:a=0,to:i=1,velocity:s=0,restSpeed:r=2,restDistance:o=.5}={})=>{const l={done:!1,value:a,target:i,velocity:s=s?s/1e3:0,hasReachedTarget:!1},c=((t=100,e=10,n=1)=>e/(2*Math.sqrt(t*n)))(t,e,n),u=i-a,f=Math.sqrt(t/n)/1e3,h=((t,e)=>t*Math.sqrt(1-e*e))(f,c);let d;return d=c<1?t=>i-Math.exp(-c*f*t)*((c*f*u-s)/h*Math.sin(h*t)+u*Math.cos(h*t)):t=>i-Math.exp(-f*t)*(u+(s+f*u)*t),{next:t=>{l.value=d(t),l.velocity=0===t?s:ft(d,t,l.value);const e=Math.abs(l.velocity)<=r,n=Math.abs(i-l.value)<=o;var c,u,f;return l.done=e&&n,l.hasReachedTarget=(c=a,u=i,f=l.value,c<u&&f>=u||c>u&&f<=u),l}}};function ft(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(s=5)?i*(1e3/s):0;var i,s}function ht(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,s=0,r=!1)=>{const o=`${e}-${i}-${s}-${r}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:s,restSpeed:r?.05:2,restDistance:r?.01:.5},n))),a.get(o)},s=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t.next(0);const i=[a.value];for(;!a.done&&n<1e4;)a=t.next(n),i.push(a.done?a.target:a.value),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const s=n-10;return 1===i.length&&i.push(a.value),{keyframes:i,duration:s/1e3,overshootDuration:(null!=e?e:s)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,r)=>{let o,l;const c=t.length;if(n&&c<=2&&t.every(dt)){const n=a&&r&&r.prevGeneratorState[a],u=n&&(1===c||2===c&&null===t[0])?n.velocity:0,f=t[c-1],h=1===c?null:t[0],d=null===h?n?n.value:parseFloat(e()):h;l=i(d,f,u,null==a?void 0:a.includes("scale"));const p=s(l);o=Object.assign(Object.assign({},p),{easing:"linear"})}else{l=i(0,100);o={easing:"ease",duration:s(l).overshootDuration}}return l&&r&&a&&(r.generators[a]=l),o}}}}const dt=t=>"string"!=typeof t,pt=ht(ut),mt=ht((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:s,changeTarget:r,min:o,max:l,restDistance:c=.5,restSpeed:u})=>{a=M(a);const f={value:t,target:t,velocity:e,hasReachedTarget:!1,done:!1},h=t=>void 0===o?l:void 0===l||Math.abs(o-t)<Math.abs(l-t)?o:l;let d=n*e;const p=t+d,m=void 0===r?p:r(p);f.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),g=t=>m+y(t),v=t=>{const n=y(t),a=g(t);f.done=Math.abs(n)<=c,f.value=f.done?m:a,f.velocity=0===t?e:ft(g,t,f.value)};let b,x;const S=t=>{var e;(e=f.value,void 0!==o&&e<o||void 0!==l&&e>l)&&(b=t,x=ut({from:f.value,to:h(f.value),velocity:f.velocity,damping:i,stiffness:s,restDistance:c,restSpeed:u}))};return S(0),{next:t=>{let e=!1;return x||void 0!==b||(e=!0,v(t),S(t)),void 0!==b&&t>b?(f.hasReachedTarget=!0,x.next(t-b)):(f.hasReachedTarget=!1,!e&&v(t),f)}}}));function yt(t,e){return function(t){return"object"==typeof t}(t)?t:t&&e?e[t]:void 0}let gt;function vt(){if(!gt)return;const t=gt.sort(bt).map(xt);t.forEach(Mt),t.forEach(Mt),gt=void 0}const bt=(t,e)=>t.getDepth()-e.getDepth(),xt=t=>t.animateUpdates(),Mt=t=>t.next(),St=["initial","animate"];function Ot(t){const e={},n=[];for(let a in t){const i=t[a];y(a)&&(l[a]&&(a=l[a]),n.push(a),a=h(a));let s=Array.isArray(i)?i[0]:i;const r=f.get(a);r&&(s=S(i)?r.toDefaultUnit(i):i),e[a]=s}return n.length&&(e.transform=g(n)),e}const Tt=t=>`-${t.toLowerCase()}`;t.animate=function(t,e,n={}){var a;const i=(t=J(t)).length,s=[];for(let a=0;a<i;a++){const r=t[a];for(const t in e){const o=H(n,t);o.delay=at(o.delay,a,i);const l=L(r,t,e[t],o);s.push(l)}}return Q(s,null!==(a=n.duration)&&void 0!==a?a:$.duration)},t.animateStyle=L,t.createMotionState=function(t={},e){var n;let r,o=e?e.getDepth()+1:0;const l={};for(const n of St)l[n]="string"==typeof t[n]?t[n]:null==e?void 0:e.getContext()[n];let c=it(yt(null!==(n=t.initial)&&void 0!==n?n:l.initial,t.variants)||{},["transition"]);const u=Object.assign({},c),f={update:e=>{r&&(t=e,function(t){gt?a(gt,t):(gt=[t],requestAnimationFrame(vt))}(f))},animateUpdates:function*(){var e,n;const a=c;c={};const i={};for(const a of St){const s=yt(t[a]);if(s)for(const a in s)"transition"!==a&&(c[a]=s[a],i[a]=H(null!==(n=null!==(e=s.transition)&&void 0!==e?e:t.transition)&&void 0!==n?n:{},a))}const o=new Set([...Object.keys(c),...Object.keys(a)]),l=[];o.forEach((t=>{var e,n,s;void 0===c[t]&&(c[t]=u[t]),n=a[t],s=c[t],typeof n==typeof s&&(Array.isArray(n)&&Array.isArray(s)?function(t,e){const n=e.length;if(n!==t.length)return!1;for(let a=0;a<n;a++)if(e[a]!==t[a])return!1;return!0}(n,s):n===s)||(null!==(e=u[t])&&void 0!==e||(u[t]=_(r,t)),l.push(L(r,t,c[t],i[t])))})),yield;const f=l.map((t=>t())).filter(Boolean);if(!f.length)return;const h=c;Promise.all(f.map((t=>t.finished))).then((()=>{var e;null===(e=t.onAnimationComplete)||void 0===e||e.call(t,h)})).catch(s)},getDepth:()=>o,getTarget:()=>c,getOptions:()=>t,getContext:()=>l,mount:t=>(r=t,()=>{!function(t){gt&&i(gt,t)}(f)})};return f},t.createStyleString=function(t={}){const e=Ot(t);let n="";for(const t in e)n+=t.startsWith("--")?t:t.replace(/[A-Z]/g,Tt),n+=`: ${e[t]}; `;return n},t.createStyles=Ot,t.glide=mt,t.spring=pt,t.stagger=function(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,s)=>{const r=S(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,s),o=Math.abs(r-i);let l=t*o;if(a){const t=s*i;l=V(a)(l/t)*t}return e+l}},t.test=function(){console.log("test")},t.timeline=function(t,e={}){var n,a;const i=function(t,e={}){var{defaultOptions:n={}}=e,a=it(e,["defaultOptions"]);const i=[],s=new Map,r={},o=new Map;let l=0,c=0,u=0;for(let e=0;e<t.length;e++){const[a,i,f={}]=t[e];void 0!==f.at&&(c=st(c,f.at,l,o));let h=0;const d=J(a,r),p=d.length;for(let t=0;t<p;t++){const e=lt(d[t],s);for(const a in i){const s=ct(a,e);let r=X(i[a]);const o=H(f,a);let{duration:l=n.duration||$.duration,easing:d=n.easing||$.easing}=o;if(T(d)){const t=y(a);r.length;const e=d.createAnimation(r,(()=>"0"),t);d=e.easing,void 0!==e.keyframes&&(r=e.keyframes),void 0!==e.duration&&(l=e.duration)}const m=at(f.delay,t,p)||0,g=c+m,v=g+l;let{offset:b=G(r.length)}=o;1===b.length&&0===b[0]&&(b[1]=1);const x=length-r.length;x>0&&z(b,x),1===r.length&&r.unshift(null),rt(s,r,d,b,g,v),h=Math.max(m+l,h),u=Math.max(v,u)}}l=c,c+=h}return s.forEach(((t,e)=>{for(const s in t){const r=t[s];r.sort(ot);const o=[],l=[],c=[];for(let t=0;t<r.length;t++){const{at:e,value:n,easing:a}=r[t];o.push(n),l.push(F(0,u,e)),c.push(a||$.easing)}0!==l[0]&&(l.unshift(0),o.unshift(o[0]),c.unshift("linear")),1!==l[l.length-1]&&(l.push(1),o.push(null)),i.push([e,s,o,Object.assign(Object.assign(Object.assign({},n),{duration:u,easing:c,offset:l}),a)])}})),i}(t,e),s=i.map((t=>L(...t))).filter(Boolean);return Q(s,null!==(a=null===(n=i[0])||void 0===n?void 0:n[3].duration)&&void 0!==a?a:$.duration)},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Motion = {}));
5
- }(this, (function (exports) { 'use strict';
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  const data = new WeakMap();
8
8
  function getAnimationData(element) {
@@ -344,7 +344,7 @@
344
344
  this.startTime = 0;
345
345
  this.rate = 1;
346
346
  this.t = 0;
347
- this.cancelT = 0;
347
+ this.cancelTimestamp = 0;
348
348
  this.playState = "idle";
349
349
  this.finished = new Promise((resolve, reject) => {
350
350
  this.resolve = resolve;
@@ -362,6 +362,7 @@
362
362
  ? easing.map(getEasingFunction)
363
363
  : getEasingFunction(easing));
364
364
  this.tick = (timestamp) => {
365
+ var _a;
365
366
  if (this.pauseTime)
366
367
  timestamp = this.pauseTime;
367
368
  let t = (timestamp - this.startTime) * this.rate;
@@ -415,7 +416,7 @@
415
416
  const isAnimationFinished = this.playState === "finished" || t >= totalDuration + endDelay;
416
417
  if (isAnimationFinished) {
417
418
  this.playState = "finished";
418
- this.resolve(latest);
419
+ (_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, latest);
419
420
  }
420
421
  else if (this.playState !== "idle") {
421
422
  requestAnimationFrame(this.tick);
@@ -444,15 +445,16 @@
444
445
  this.tick(0);
445
446
  }
446
447
  cancel() {
448
+ var _a;
447
449
  this.playState = "idle";
448
- this.tick(this.cancelT);
449
- this.reject(false);
450
+ this.tick(this.cancelTimestamp);
451
+ (_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, false);
450
452
  }
451
453
  reverse() {
452
454
  this.rate *= -1;
453
455
  }
454
456
  commitStyles() {
455
- this.cancelT = this.t;
457
+ this.cancelTimestamp = performance.now();
456
458
  }
457
459
  get currentTime() {
458
460
  return this.t;
@@ -483,8 +485,15 @@
483
485
  }
484
486
  const keyframesList = (keyframes) => Array.isArray(keyframes) ? keyframes : [keyframes];
485
487
 
488
+ function getStyleName(key) {
489
+ if (transformAlias[key])
490
+ key = transformAlias[key];
491
+ return isTransform(key) ? asTransformCssVar(key) : key;
492
+ }
493
+
486
494
  const style = {
487
495
  get: (element, name) => {
496
+ name = getStyleName(name);
488
497
  let value = isCssVar(name)
489
498
  ? element.style.getPropertyValue(name)
490
499
  : getComputedStyle(element)[name];
@@ -497,12 +506,6 @@
497
506
  },
498
507
  };
499
508
 
500
- function getStyleName(key) {
501
- if (transformAlias[key])
502
- key = transformAlias[key];
503
- return isTransform(key) ? asTransformCssVar(key) : key;
504
- }
505
-
506
509
  function stopAnimation(animation) {
507
510
  if (!animation)
508
511
  return;
@@ -837,6 +840,15 @@
837
840
  return t;
838
841
  }
839
842
 
843
+ var invariant = function () { };
844
+ {
845
+ invariant = function (check, message) {
846
+ if (!check) {
847
+ throw new Error(message);
848
+ }
849
+ };
850
+ }
851
+
840
852
  function calcNextTime(current, next, prev, labels) {
841
853
  var _a;
842
854
  if (isNumber(next)) {
@@ -940,9 +952,22 @@
940
952
  const elementSequence = getElementSequence(element, elementSequences);
941
953
  for (const key in keyframes) {
942
954
  const valueSequence = getValueSequence(key, elementSequence);
943
- const valueKeyframes = keyframesList(keyframes[key]);
955
+ let valueKeyframes = keyframesList(keyframes[key]);
944
956
  const valueOptions = getOptions(options, key);
945
957
  let { duration = defaultOptions.duration || defaults.duration, easing = defaultOptions.easing || defaults.easing, } = valueOptions;
958
+ if (isCustomEasing(easing)) {
959
+ const valueIsTransform = isTransform(key);
960
+ invariant(valueKeyframes.length === 2 || !valueIsTransform, "spring must be provided 2 keyframes within timeline");
961
+ const custom = easing.createAnimation(valueKeyframes,
962
+ // TODO We currently only support explicit keyframes
963
+ // so this doesn't currently read from the DOM
964
+ () => "0", valueIsTransform);
965
+ easing = custom.easing;
966
+ if (custom.keyframes !== undefined)
967
+ valueKeyframes = custom.keyframes;
968
+ if (custom.duration !== undefined)
969
+ duration = custom.duration;
970
+ }
946
971
  const delay = resolveOption(options.delay, elementIndex, numElements) || 0;
947
972
  const startTime = currentTime + delay;
948
973
  const targetTime = startTime + duration;
@@ -1167,17 +1192,17 @@
1167
1192
  numKeyframes <= 2 &&
1168
1193
  keyframes.every(isNumberOrNull);
1169
1194
  if (shouldUseGenerator) {
1170
- const prevAnimationState = name && data && data.prevGeneratorState[name];
1171
- const velocity = prevAnimationState &&
1195
+ const prevMotionState = name && data && data.prevGeneratorState[name];
1196
+ const velocity = prevMotionState &&
1172
1197
  (numKeyframes === 1 ||
1173
1198
  (numKeyframes === 2 && keyframes[0] === null))
1174
- ? prevAnimationState.velocity
1199
+ ? prevMotionState.velocity
1175
1200
  : 0;
1176
1201
  const target = keyframes[numKeyframes - 1];
1177
1202
  const unresolvedOrigin = numKeyframes === 1 ? null : keyframes[0];
1178
1203
  const origin = unresolvedOrigin === null
1179
- ? prevAnimationState
1180
- ? prevAnimationState.value
1204
+ ? prevMotionState
1205
+ ? prevMotionState.value
1181
1206
  : parseFloat(getOrigin())
1182
1207
  : unresolvedOrigin;
1183
1208
  generator = getGenerator(origin, target, velocity, name === null || name === void 0 ? void 0 : name.includes("scale"));
@@ -1298,13 +1323,205 @@
1298
1323
 
1299
1324
  const glide = createGeneratorEasing(createGlideGenerator);
1300
1325
 
1326
+ function hasChanged(a, b) {
1327
+ if (typeof a !== typeof b)
1328
+ return true;
1329
+ if (Array.isArray(a) && Array.isArray(b))
1330
+ return !shallowCompare(a, b);
1331
+ return a !== b;
1332
+ }
1333
+ function shallowCompare(next, prev) {
1334
+ const prevLength = prev.length;
1335
+ if (prevLength !== next.length)
1336
+ return false;
1337
+ for (let i = 0; i < prevLength; i++) {
1338
+ if (prev[i] !== next[i])
1339
+ return false;
1340
+ }
1341
+ return true;
1342
+ }
1343
+
1344
+ function isVariant(definition) {
1345
+ return typeof definition === "object";
1346
+ }
1347
+
1348
+ function resolveVariant(definition, variants) {
1349
+ if (isVariant(definition)) {
1350
+ return definition;
1351
+ }
1352
+ else if (definition && variants) {
1353
+ return variants[definition];
1354
+ }
1355
+ }
1356
+
1357
+ let scheduled = undefined;
1358
+ function processScheduledAnimations() {
1359
+ if (!scheduled)
1360
+ return;
1361
+ const generators = scheduled.sort(compareByDepth).map(fireAnimateUpdates);
1362
+ generators.forEach(fireNext);
1363
+ generators.forEach(fireNext);
1364
+ scheduled = undefined;
1365
+ }
1366
+ function scheduleAnimation(state) {
1367
+ if (!scheduled) {
1368
+ scheduled = [state];
1369
+ requestAnimationFrame(processScheduledAnimations);
1370
+ }
1371
+ else {
1372
+ addUniqueItem(scheduled, state);
1373
+ }
1374
+ }
1375
+ function unscheduleAnimation(state) {
1376
+ scheduled && removeItem(scheduled, state);
1377
+ }
1378
+ const compareByDepth = (a, b) => a.getDepth() - b.getDepth();
1379
+ const fireAnimateUpdates = (state) => state.animateUpdates();
1380
+ const fireNext = (iterator) => iterator.next();
1381
+
1382
+ const stateNames = ["initial", "animate"];
1383
+ function createMotionState(options = {}, parent) {
1384
+ var _a;
1385
+ //@ts-ignore
1386
+ let element;
1387
+ let depth = parent ? parent.getDepth() + 1 : 0;
1388
+ // const activeStates = stateNames.map((key) => key === "initial")
1389
+ const context = {};
1390
+ for (const name of stateNames) {
1391
+ context[name] =
1392
+ typeof options[name] === "string"
1393
+ ? options[name]
1394
+ : parent === null || parent === void 0 ? void 0 : parent.getContext()[name];
1395
+ }
1396
+ let _b = resolveVariant((_a = options.initial) !== null && _a !== void 0 ? _a : context.initial, options.variants) || {}, target = __rest(_b, ["transition"]);
1397
+ const baseTarget = Object.assign({}, target);
1398
+ function* animateUpdates() {
1399
+ var _a, _b;
1400
+ const prevTarget = target;
1401
+ target = {};
1402
+ const animationOptions = {};
1403
+ for (const name of stateNames) {
1404
+ const variant = resolveVariant(options[name]);
1405
+ if (!variant)
1406
+ continue;
1407
+ for (const key in variant) {
1408
+ if (key === "transition")
1409
+ continue;
1410
+ target[key] = variant[key];
1411
+ animationOptions[key] = getOptions((_b = (_a = variant.transition) !== null && _a !== void 0 ? _a : options.transition) !== null && _b !== void 0 ? _b : {}, key);
1412
+ }
1413
+ }
1414
+ const allTargetKeys = new Set([
1415
+ ...Object.keys(target),
1416
+ ...Object.keys(prevTarget),
1417
+ ]);
1418
+ const animationFactories = [];
1419
+ allTargetKeys.forEach((key) => {
1420
+ var _a;
1421
+ if (target[key] === undefined) {
1422
+ target[key] = baseTarget[key];
1423
+ }
1424
+ if (hasChanged(prevTarget[key], target[key])) {
1425
+ (_a = baseTarget[key]) !== null && _a !== void 0 ? _a : (baseTarget[key] = style.get(element, key));
1426
+ animationFactories.push(animateStyle(element, key, target[key], animationOptions[key]));
1427
+ }
1428
+ });
1429
+ yield;
1430
+ const animations = animationFactories
1431
+ .map((factory) => factory())
1432
+ .filter(Boolean);
1433
+ if (!animations.length)
1434
+ return;
1435
+ const animationTarget = target;
1436
+ Promise.all(animations.map((animation) => animation.finished))
1437
+ .then(() => {
1438
+ var _a;
1439
+ (_a = options.onAnimationComplete) === null || _a === void 0 ? void 0 : _a.call(options, animationTarget);
1440
+ })
1441
+ .catch(noop);
1442
+ }
1443
+ const state = {
1444
+ update: (newOptions) => {
1445
+ if (!element)
1446
+ return;
1447
+ options = newOptions;
1448
+ scheduleAnimation(state);
1449
+ },
1450
+ animateUpdates,
1451
+ getDepth: () => depth,
1452
+ getTarget: () => target,
1453
+ getOptions: () => options,
1454
+ getContext: () => context,
1455
+ mount: (newElement) => {
1456
+ invariant(Boolean(newElement), "Animation state must be mounted with valid Element");
1457
+ element = newElement;
1458
+ return () => {
1459
+ unscheduleAnimation(state);
1460
+ // Stop all animations
1461
+ // Remove all gesture subscriptions
1462
+ };
1463
+ },
1464
+ };
1465
+ return state;
1466
+ }
1467
+
1468
+ function createStyles(keyframes) {
1469
+ const initialKeyframes = {};
1470
+ const transformKeys = [];
1471
+ for (let key in keyframes) {
1472
+ const value = keyframes[key];
1473
+ if (isTransform(key)) {
1474
+ if (transformAlias[key])
1475
+ key = transformAlias[key];
1476
+ transformKeys.push(key);
1477
+ key = asTransformCssVar(key);
1478
+ }
1479
+ let initialKeyframe = Array.isArray(value) ? value[0] : value;
1480
+ /**
1481
+ * If this is a number and we have a default value type, convert the number
1482
+ * to this type.
1483
+ */
1484
+ const definition = transformDefinitions.get(key);
1485
+ if (definition) {
1486
+ initialKeyframe = isNumber(value)
1487
+ ? definition.toDefaultUnit(value)
1488
+ : value;
1489
+ }
1490
+ initialKeyframes[key] = initialKeyframe;
1491
+ }
1492
+ if (transformKeys.length) {
1493
+ initialKeyframes.transform = buildTransformTemplate(transformKeys);
1494
+ }
1495
+ return initialKeyframes;
1496
+ }
1497
+
1498
+ const camelLetterToPipeLetter = (letter) => `-${letter.toLowerCase()}`;
1499
+ const camelToPipeCase = (str) => str.replace(/[A-Z]/g, camelLetterToPipeLetter);
1500
+ function createStyleString(target = {}) {
1501
+ const styles = createStyles(target);
1502
+ let style = "";
1503
+ for (const key in styles) {
1504
+ style += key.startsWith("--") ? key : camelToPipeCase(key);
1505
+ style += `: ${styles[key]}; `;
1506
+ }
1507
+ return style;
1508
+ }
1509
+
1510
+ function test() {
1511
+ console.log("test");
1512
+ }
1513
+
1301
1514
  exports.animate = animate;
1302
1515
  exports.animateStyle = animateStyle;
1516
+ exports.createMotionState = createMotionState;
1517
+ exports.createStyleString = createStyleString;
1518
+ exports.createStyles = createStyles;
1303
1519
  exports.glide = glide;
1304
1520
  exports.spring = spring;
1305
1521
  exports.stagger = stagger;
1522
+ exports.test = test;
1306
1523
  exports.timeline = timeline;
1307
1524
 
1308
1525
  Object.defineProperty(exports, '__esModule', { value: true });
1309
1526
 
1310
- })));
1527
+ }));
package/dist/react.cjs.js CHANGED
@@ -2,8 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./targets/react/index.cjs.js');
5
+ var react = require('@motionone/react');
6
6
 
7
7
 
8
8
 
9
- exports.animated = index.animated;
9
+ Object.keys(react).forEach(function (k) {
10
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () { return react[k]; }
13
+ });
14
+ });
package/dist/react.es.js CHANGED
@@ -1 +1 @@
1
- export { animated } from './targets/react/index.es.js';
1
+ export * from '@motionone/react';
@@ -0,0 +1 @@
1
+ const t=new WeakMap;function e(e){return t.has(e)||t.set(e,{transforms:[],animations:{},generators:{},prevGeneratorState:{}}),t.get(e)}function n(t,e){-1===t.indexOf(e)&&t.push(e)}function a(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const i=()=>{},r=t=>t,s=["","X","Y","Z"],o={x:"translateX",y:"translateY",z:"translateZ"},l={syntax:"<angle>",initialValue:"0deg",toDefaultUnit:t=>t+"deg"},c={translate:{syntax:"<length-percentage>",initialValue:"0px",toDefaultUnit:t=>t+"px"},rotate:l,scale:{syntax:"<number>",initialValue:1,toDefaultUnit:r},skew:l},u=new Map,h=t=>`--motion-${t}`,f=["x","y","z"];["translate","scale","rotate","skew"].forEach((t=>{s.forEach((e=>{f.push(t+e),u.set(h(t+e),c[t])}))}));const d=(t,e)=>f.indexOf(t)-f.indexOf(e),p=new Set(f),m=t=>p.has(t),y=t=>t.sort(d).reduce(g,"").trim(),g=(t,e)=>`${t} ${e}(var(${h(e)}))`,v=t=>t.startsWith("--"),b=new Set;const x=t=>1e3*t,w=t=>"number"==typeof t,M=t=>Array.isArray(t)&&!w(t[0]),O=t=>"object"==typeof t&&Boolean(t.createAnimation),S=t=>(t=>Array.isArray(t)&&w(t[0]))(t)?T(t):t,T=([t,e,n,a])=>`cubic-bezier(${t}, ${e}, ${n}, ${a})`,A=t=>document.createElement("div").animate(t,{duration:.001}),D={cssRegisterProperty:()=>"undefined"!=typeof CSS&&Object.hasOwnProperty.call(CSS,"registerProperty"),waapi:()=>Object.hasOwnProperty.call(Element.prototype,"animate"),partialKeyframes:()=>{try{A({opacity:[1]})}catch(t){return!1}return!0},finished:()=>Boolean(A({opacity:[0,1]}).finished)},j={},k={};for(const t in D)k[t]=()=>(void 0===j[t]&&(j[t]=D[t]()),j[t]);const E={duration:.3,delay:0,endDelay:0,repeat:0,easing:"ease"},P=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t;function $(t,e,n,a){if(t===e&&n===a)return r;const i=e=>function(t,e,n,a,i){let r,s,o=0;do{s=e+(n-e)/2,r=P(s,a,i)-t,r>0?n=s:e=s}while(Math.abs(r)>1e-7&&++o<12);return s}(e,0,1,t,n);return t=>0===t||1===t?t:P(i(t),e,a)}const R=(t,e="end")=>n=>{const a=(n="end"===e?Math.min(n,.999):Math.max(n,.001))*t,i="end"===e?Math.floor(a):Math.ceil(a);return r=0,s=1,o=i/t,Math.min(Math.max(o,r),s);var r,s,o},U={ease:$(.25,.1,.25,1),"ease-in":$(.42,0,1,1),"ease-in-out":$(.42,0,.58,1),"ease-out":$(0,0,.58,1)},V=/\((.*?)\)/;function q(t){if("function"==typeof t)return t;if(Array.isArray(t))return $(...t);if(U[t])return U[t];if(t.startsWith("steps")){const e=V.exec(t);if(e){const t=e[1].split(",");return R(parseFloat(t[0]),t[1].trim())}}return r}const C=(t,e,n)=>-n*t+n*e+t,W=(t,e,n)=>e-t==0?1:(n-t)/(e-t);function F(t,e){return M(t)?t[((t,e,n)=>{const a=e-t;return((n-t)%a+a)%a+t})(0,t.length,e)]:t}function B(t,e){const n=t[t.length-1];for(let a=1;a<=e;a++){const i=W(0,e,a);t.push(C(n,1,i))}}function z(t){const e=[0];return B(e,t-1),e}function G(t,e=z(t.length),n=r){const a=t.length,i=a-e.length;return i>0&&B(e,i),i=>{let r=0;for(;r<a-2&&!(i<e[r+1]);r++);let s=(o=W(e[r],e[r+1],i),Math.min(1,Math.max(o,0)));var o;return s=F(n,r)(s),C(t[r],t[r+1],s)}}class Z{constructor(t,e=[0,1],{easing:n=E.easing,duration:a=E.duration,delay:i=E.delay,endDelay:r=E.endDelay,repeat:s=E.repeat,offset:o,direction:l="normal"}={}){this.startTime=0,this.rate=1,this.t=0,this.cancelTimestamp=0,this.playState="idle",this.finished=new Promise(((t,e)=>{this.resolve=t,this.reject=e}));const c=a*(s+1);O(n)&&(n="ease");const u=G(e,o,M(n)?n.map(q):q(n));this.tick=e=>{var n;this.pauseTime&&(e=this.pauseTime);let s=(e-this.startTime)*this.rate;this.t=s,s/=1e3,s=Math.max(s-i,0),"finished"===this.playState&&(s=c);const o=s/a;let h=Math.floor(o),f=o%1;!f&&o>=1&&(f=1),1===f&&h--;const d=h%2;("reverse"===l||"alternate"===l&&d||"alternate-reverse"===l&&!d)&&(f=1-f);const p=u(s>=c?1:Math.min(f,1));t(p);"finished"===this.playState||s>=c+r?(this.playState="finished",null===(n=this.resolve)||void 0===n||n.call(this,p)):"idle"!==this.playState&&requestAnimationFrame(this.tick)},this.play()}play(){const t=performance.now();this.playState="running",this.pauseTime?this.startTime=t-(this.pauseTime-this.startTime):this.startTime||(this.startTime=t),this.pauseTime=void 0,requestAnimationFrame(this.tick)}pause(){this.playState="paused",this.pauseTime=performance.now()}finish(){this.playState="finished",this.tick(0)}cancel(){var t;this.playState="idle",this.tick(this.cancelTimestamp),null===(t=this.reject)||void 0===t||t.call(this,!1)}reverse(){this.rate*=-1}commitStyles(){this.cancelTimestamp=performance.now()}get currentTime(){return this.t}set currentTime(t){this.pauseTime||0===this.rate?this.pauseTime=t:this.startTime=performance.now()-t/this.rate}get playbackRate(){return this.rate}set playbackRate(t){this.rate=t}}const K=t=>Array.isArray(t)?t:[t];function N(t){return o[t]&&(t=o[t]),m(t)?h(t):t}const X=(t,e)=>{e=N(e);let n=v(e)?t.style.getPropertyValue(e):getComputedStyle(t)[e];if(!n&&0!==n){const t=u.get(e);t&&(n=t.initialValue)}return n};function Y(t){if(t)try{"finished"!==t.playState&&t.commitStyles(),t.cancel()}catch(t){}}function I(t,a,r,s={}){let l,{duration:c=E.duration,delay:h=E.delay,endDelay:f=E.endDelay,repeat:d=E.repeat,easing:p=E.easing,direction:g,offset:T,allowWebkitAcceleration:A=!1}=s;const D=e(t);let j=k.waapi(),P=i;const $=m(a);$&&((t,a)=>{o[a]&&(a=o[a]);const{transforms:i}=e(t);n(i,a),t.style.transform=y(i)})(t,a);const R=N(a),U=u.get(R);return Y(D.animations[R]),()=>{const e=()=>{var e,n;return null!==(n=null!==(e=X(t,R))&&void 0!==e?e:null==U?void 0:U.initialValue)&&void 0!==n?n:0};let n=function(t,e){for(let n=0;n<t.length;n++)null===t[n]&&(t[n]=n?t[n-1]:e());return t}(K(r),e);if(O(p)){const t=p.createAnimation(n,e,$,R,D);p=t.easing,void 0!==t.keyframes&&(n=t.keyframes),void 0!==t.duration&&(c=t.duration)}if(v(R)?(P=((t,e)=>n=>t.style.setProperty(e,n))(t,R),k.cssRegisterProperty()?function(t){if(!b.has(t)){b.add(t);try{const{syntax:e,initialValue:n}=u.has(t)?u.get(t):{};CSS.registerProperty({name:t,inherits:!1,syntax:e,initialValue:n})}catch(t){}}}(R):j=!1):P=((t,e)=>n=>t.style[e]=n)(t,R),j){U&&(n=n.map((t=>w(t)?U.toDefaultUnit(t):t))),k.partialKeyframes()||1!==n.length||n.unshift(e());const a={delay:x(h),duration:x(c),endDelay:x(f),easing:M(p)?void 0:S(p),direction:g,iterations:d+1,fill:"both"};l=t.animate({[R]:n,offset:T,easing:M(p)?p.map(S):void 0},a),l.finished||(l.finished=new Promise(((t,e)=>{l.onfinish=t,l.oncancel=e})));const r=n[n.length-1];l.finished.then((()=>{P(r),l.cancel()})).catch(i),A||(l.playbackRate=1.000001)}else if($&&n.every(w)){if(1===n.length&&n.unshift(parseFloat(e())),U){const t=P;P=e=>t(U.toDefaultUnit(e))}l=new Z(P,n,Object.assign(Object.assign({},s),{duration:c,easing:p}))}else{const t=n[n.length-1];P(U&&w(t)?U.toDefaultUnit(t):t)}return D.animations[R]=l,null==l||l.finished.then((()=>{D.animations[R]=void 0,D.generators[R]=void 0,D.prevGeneratorState[R]=void 0})).catch(i),l}}const L=(t,e)=>t[e]?Object.assign(Object.assign({},t),t[e]):Object.assign({},t);function _(t,e){var n;return"string"==typeof t?e?(null!==(n=e[t])&&void 0!==n||(e[t]=document.querySelectorAll(t)),t=e[t]):t=document.querySelectorAll(t):t instanceof Element&&(t=[t]),Array.from(t)}const H=t=>t(),J=(t,e)=>new Proxy({animations:t.map(H).filter(Boolean),duration:e},tt),Q=t=>t.animations[0],tt={get:(t,e)=>{var n,a;switch(e){case"duration":return t.duration;case"currentTime":let r=(null===(n=Q(t))||void 0===n?void 0:n[e])||0;return r?r/1e3:0;case"playbackRate":return null===(a=Q(t))||void 0===a?void 0:a[e];case"finished":return t.finished||(t.finished=Promise.all(t.animations.map(et)).catch(i)),t.finished;case"stop":return()=>t.animations.forEach(Y);default:return()=>t.animations.forEach((t=>t[e]()))}},set:(t,e,n)=>{switch(e){case"currentTime":n=x(n);case"currentTime":case"playbackRate":for(let a=0;a<t.animations.length;a++)t.animations[a][e]=n;return!0}return!1}},et=t=>t.finished;function nt(t=.1,{start:e=0,from:n=0,easing:a}={}){return(i,r)=>{const s=w(n)?n:function(t,e){if("first"===t)return 0;{const n=e-1;return"last"===t?n:n/2}}(n,r),o=Math.abs(s-i);let l=t*o;if(a){const t=r*i;l=q(a)(l/t)*t}return e+l}}function at(t,e,n){return"function"==typeof t?t(e,n):t}function it(t,e,n={}){var a;const i=(t=_(t)).length,r=[];for(let a=0;a<i;a++){const s=t[a];for(const t in e){const o=L(n,t);o.delay=at(o.delay,a,i);const l=I(s,t,e[t],o);r.push(l)}}return J(r,null!==(a=n.duration)&&void 0!==a?a:E.duration)}function rt(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(t);i<a.length;i++)e.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(t,a[i])&&(n[a[i]]=t[a[i]])}return n}var st=function(){};function ot(t,e,n,a){var i;return w(e)?e:e.startsWith("-")||e.startsWith("+")?Math.max(0,t+parseFloat(e)):"<"===e?n:null!==(i=a.get(e))&&void 0!==i?i:t}function lt(t,e,n,i,r,s){!function(t,e,n){for(let i=0;i<t.length;i++){const r=t[i];r.at>e&&r.at<n&&(a(t,r),i--)}}(t,r,s);for(let a=0;a<e.length;a++)t.push({value:e[a],at:C(r,s,i[a]),easing:F(n,a)})}function ct(t,e){return t.at===e.at?null===t.value?1:-1:t.at-e.at}function ut(t,e={}){var n,a;const i=function(t,e={}){var{defaultOptions:n={}}=e,a=rt(e,["defaultOptions"]);const i=[],r=new Map,s={},o=new Map;let l=0,c=0,u=0;for(let e=0;e<t.length;e++){const[a,i,h={}]=t[e];void 0!==h.at&&(c=ot(c,h.at,l,o));let f=0;const d=_(a,s),p=d.length;for(let t=0;t<p;t++){const e=ht(d[t],r);for(const a in i){const r=ft(a,e);let s=K(i[a]);const o=L(h,a);let{duration:l=n.duration||E.duration,easing:d=n.easing||E.easing}=o;if(O(d)){const t=m(a);st(2===s.length||!t,"spring must be provided 2 keyframes within timeline");const e=d.createAnimation(s,(()=>"0"),t);d=e.easing,void 0!==e.keyframes&&(s=e.keyframes),void 0!==e.duration&&(l=e.duration)}const y=at(h.delay,t,p)||0,g=c+y,v=g+l;let{offset:b=z(s.length)}=o;1===b.length&&0===b[0]&&(b[1]=1);const x=length-s.length;x>0&&B(b,x),1===s.length&&s.unshift(null),lt(r,s,d,b,g,v),f=Math.max(y+l,f),u=Math.max(v,u)}}l=c,c+=f}return r.forEach(((t,e)=>{for(const r in t){const s=t[r];s.sort(ct);const o=[],l=[],c=[];for(let t=0;t<s.length;t++){const{at:e,value:n,easing:a}=s[t];o.push(n),l.push(W(0,u,e)),c.push(a||E.easing)}0!==l[0]&&(l.unshift(0),o.unshift(o[0]),c.unshift("linear")),1!==l[l.length-1]&&(l.push(1),o.push(null)),i.push([e,r,o,Object.assign(Object.assign(Object.assign({},n),{duration:u,easing:c,offset:l}),a)])}})),i}(t,e),r=i.map((t=>I(...t))).filter(Boolean);return J(r,null!==(a=null===(n=i[0])||void 0===n?void 0:n[3].duration)&&void 0!==a?a:E.duration)}function ht(t,e){return!e.has(t)&&e.set(t,{}),e.get(t)}function ft(t,e){return e[t]||(e[t]=[]),e[t]}"production"!==process.env.NODE_ENV&&(st=function(t,e){if(!t)throw new Error(e)});const dt=({stiffness:t=100,damping:e=10,mass:n=1,from:a=0,to:i=1,velocity:r=0,restSpeed:s=2,restDistance:o=.5}={})=>{const l={done:!1,value:a,target:i,velocity:r=r?r/1e3:0,hasReachedTarget:!1},c=((t=100,e=10,n=1)=>e/(2*Math.sqrt(t*n)))(t,e,n),u=i-a,h=Math.sqrt(t/n)/1e3,f=((t,e)=>t*Math.sqrt(1-e*e))(h,c);let d;return d=c<1?t=>i-Math.exp(-c*h*t)*((c*h*u-r)/f*Math.sin(f*t)+u*Math.cos(f*t)):t=>i-Math.exp(-h*t)*(u+(r+h*u)*t),{next:t=>{l.value=d(t),l.velocity=0===t?r:pt(d,t,l.value);const e=Math.abs(l.velocity)<=s,n=Math.abs(i-l.value)<=o;var c,u,h;return l.done=e&&n,l.hasReachedTarget=(c=a,u=i,h=l.value,c<u&&h>=u||c>u&&h<=u),l}}};function pt(t,e,n){const a=Math.max(e-5,0);return i=n-t(a),(r=5)?i*(1e3/r):0;var i,r}function mt(t){const e=new WeakMap;return(n={})=>{const a=new Map,i=(e=0,i=100,r=0,s=!1)=>{const o=`${e}-${i}-${r}-${s}`;return a.has(o)||a.set(o,t(Object.assign({from:e,to:i,velocity:r,restSpeed:s?.05:2,restDistance:s?.01:.5},n))),a.get(o)},r=t=>(e.has(t)||e.set(t,function(t){let e,n=10,a=t.next(0);const i=[a.value];for(;!a.done&&n<1e4;)a=t.next(n),i.push(a.done?a.target:a.value),void 0===e&&a.hasReachedTarget&&(e=n),n+=10;const r=n-10;return 1===i.length&&i.push(a.value),{keyframes:i,duration:r/1e3,overshootDuration:(null!=e?e:r)/1e3}}(t)),e.get(t));return{createAnimation:(t,e,n,a,s)=>{let o,l;const c=t.length;if(n&&c<=2&&t.every(yt)){const n=a&&s&&s.prevGeneratorState[a],u=n&&(1===c||2===c&&null===t[0])?n.velocity:0,h=t[c-1],f=1===c?null:t[0],d=null===f?n?n.value:parseFloat(e()):f;l=i(d,h,u,null==a?void 0:a.includes("scale"));const p=r(l);o=Object.assign(Object.assign({},p),{easing:"linear"})}else{l=i(0,100);o={easing:"ease",duration:r(l).overshootDuration}}return l&&s&&a&&(s.generators[a]=l),o}}}}const yt=t=>"string"!=typeof t,gt=mt(dt),vt=mt((({from:t=0,velocity:e=0,power:n=.8,decay:a=.325,bounceDamping:i,bounceStiffness:r,changeTarget:s,min:o,max:l,restDistance:c=.5,restSpeed:u})=>{a=x(a);const h={value:t,target:t,velocity:e,hasReachedTarget:!1,done:!1},f=t=>void 0===o?l:void 0===l||Math.abs(o-t)<Math.abs(l-t)?o:l;let d=n*e;const p=t+d,m=void 0===s?p:s(p);h.target=m,m!==p&&(d=m-t);const y=t=>-d*Math.exp(-t/a),g=t=>m+y(t),v=t=>{const n=y(t),a=g(t);h.done=Math.abs(n)<=c,h.value=h.done?m:a,h.velocity=0===t?e:pt(g,t,h.value)};let b,w;const M=t=>{var e;(e=h.value,void 0!==o&&e<o||void 0!==l&&e>l)&&(b=t,w=dt({from:h.value,to:f(h.value),velocity:h.velocity,damping:i,stiffness:r,restDistance:c,restSpeed:u}))};return M(0),{next:t=>{let e=!1;return w||void 0!==b||(e=!0,v(t),M(t)),void 0!==b&&t>b?(h.hasReachedTarget=!0,w.next(t-b)):(h.hasReachedTarget=!1,!e&&v(t),h)}}}));function bt(t,e){return function(t){return"object"==typeof t}(t)?t:t&&e?e[t]:void 0}let xt;function wt(){if(!xt)return;const t=xt.sort(Mt).map(Ot);t.forEach(St),t.forEach(St),xt=void 0}const Mt=(t,e)=>t.getDepth()-e.getDepth(),Ot=t=>t.animateUpdates(),St=t=>t.next(),Tt=["initial","animate"];function At(t={},e){var r;let s,o=e?e.getDepth()+1:0;const l={};for(const n of Tt)l[n]="string"==typeof t[n]?t[n]:null==e?void 0:e.getContext()[n];let c=rt(bt(null!==(r=t.initial)&&void 0!==r?r:l.initial,t.variants)||{},["transition"]);const u=Object.assign({},c);const h={update:e=>{s&&(t=e,function(t){xt?n(xt,t):(xt=[t],requestAnimationFrame(wt))}(h))},animateUpdates:function*(){var e,n;const a=c;c={};const r={};for(const a of Tt){const i=bt(t[a]);if(i)for(const a in i)"transition"!==a&&(c[a]=i[a],r[a]=L(null!==(n=null!==(e=i.transition)&&void 0!==e?e:t.transition)&&void 0!==n?n:{},a))}const o=new Set([...Object.keys(c),...Object.keys(a)]),l=[];o.forEach((t=>{var e,n,i;void 0===c[t]&&(c[t]=u[t]),n=a[t],i=c[t],typeof n==typeof i&&(Array.isArray(n)&&Array.isArray(i)?function(t,e){const n=e.length;if(n!==t.length)return!1;for(let a=0;a<n;a++)if(e[a]!==t[a])return!1;return!0}(n,i):n===i)||(null!==(e=u[t])&&void 0!==e||(u[t]=X(s,t)),l.push(I(s,t,c[t],r[t])))})),yield;const h=l.map((t=>t())).filter(Boolean);if(!h.length)return;const f=c;Promise.all(h.map((t=>t.finished))).then((()=>{var e;null===(e=t.onAnimationComplete)||void 0===e||e.call(t,f)})).catch(i)},getDepth:()=>o,getTarget:()=>c,getOptions:()=>t,getContext:()=>l,mount:t=>(st(Boolean(t),"Animation state must be mounted with valid Element"),s=t,()=>{!function(t){xt&&a(xt,t)}(h)})};return h}function Dt(t){const e={},n=[];for(let a in t){const i=t[a];m(a)&&(o[a]&&(a=o[a]),n.push(a),a=h(a));let r=Array.isArray(i)?i[0]:i;const s=u.get(a);s&&(r=w(i)?s.toDefaultUnit(i):i),e[a]=r}return n.length&&(e.transform=y(n)),e}const jt=t=>`-${t.toLowerCase()}`;function kt(t={}){const e=Dt(t);let n="";for(const t in e)n+=t.startsWith("--")?t:t.replace(/[A-Z]/g,jt),n+=`: ${e[t]}; `;return n}function Et(){console.log("test")}export{it as animate,I as animateStyle,At as createMotionState,kt as createStyleString,Dt as createStyles,vt as glide,gt as spring,nt as stagger,Et as test,ut as timeline};
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "@motionone/dom";
2
+ export function test() {
3
+ console.log("test");
4
+ }
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAE9B,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC"}
package/lib/react.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@motionone/react";
2
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
package/lib/vue.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "@motionone/vue";
2
+ //# sourceMappingURL=vue.js.map
package/lib/vue.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vue.js","sourceRoot":"","sources":["../src/vue.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}