motion 10.17.1 → 11.11.12

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 (320) hide show
  1. package/.turbo/turbo-build.log +29 -0
  2. package/{LICENSE → LICENSE.md} +2 -2
  3. package/README.md +99 -7
  4. package/dist/cjs/index.js +6117 -0
  5. package/dist/cjs/react-client.js +10003 -0
  6. package/dist/cjs/react-m.js +1852 -0
  7. package/dist/es/framer-motion/dist/es/animation/GroupPlaybackControls.mjs +78 -0
  8. package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +34 -0
  9. package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +19 -0
  10. package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +14 -0
  11. package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +11 -0
  12. package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +52 -0
  13. package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +318 -0
  14. package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +112 -0
  15. package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +380 -0
  16. package/dist/es/framer-motion/dist/es/animation/animators/drivers/driver-frameloop.mjs +17 -0
  17. package/dist/es/framer-motion/dist/es/animation/animators/utils/accelerated-values.mjs +14 -0
  18. package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +42 -0
  19. package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +169 -0
  20. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +36 -0
  21. package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +12 -0
  22. package/dist/es/framer-motion/dist/es/animation/animators/waapi/easing.mjs +44 -0
  23. package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +23 -0
  24. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/attach-timeline.mjs +6 -0
  25. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +12 -0
  26. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/linear.mjs +15 -0
  27. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs +9 -0
  28. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/style.mjs +8 -0
  29. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs +9 -0
  30. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs +15 -0
  31. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +13 -0
  32. package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +5 -0
  33. package/dist/es/framer-motion/dist/es/animation/generators/inertia.mjs +87 -0
  34. package/dist/es/framer-motion/dist/es/animation/generators/keyframes.mjs +51 -0
  35. package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +89 -0
  36. package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +129 -0
  37. package/dist/es/framer-motion/dist/es/animation/generators/utils/calc-duration.mjs +17 -0
  38. package/dist/es/framer-motion/dist/es/animation/generators/utils/is-generator.mjs +5 -0
  39. package/dist/es/framer-motion/dist/es/animation/generators/utils/velocity.mjs +9 -0
  40. package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +105 -0
  41. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +75 -0
  42. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +66 -0
  43. package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element.mjs +26 -0
  44. package/dist/es/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +6 -0
  45. package/dist/es/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +7 -0
  46. package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +230 -0
  47. package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +21 -0
  48. package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +31 -0
  49. package/dist/es/framer-motion/dist/es/animation/sequence/utils/sort.mjs +14 -0
  50. package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +44 -0
  51. package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +40 -0
  52. package/dist/es/framer-motion/dist/es/animation/utils/get-value-transition.mjs +9 -0
  53. package/dist/es/framer-motion/dist/es/animation/utils/is-animatable.mjs +30 -0
  54. package/dist/es/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +7 -0
  55. package/dist/es/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +5 -0
  56. package/dist/es/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +5 -0
  57. package/dist/es/framer-motion/dist/es/animation/utils/is-none.mjs +15 -0
  58. package/dist/es/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +10 -0
  59. package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +26 -0
  60. package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +40 -0
  61. package/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs +6 -0
  62. package/dist/es/framer-motion/dist/es/context/LazyContext.mjs +6 -0
  63. package/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs +13 -0
  64. package/dist/es/framer-motion/dist/es/context/MotionContext/create.mjs +13 -0
  65. package/dist/es/framer-motion/dist/es/context/MotionContext/index.mjs +6 -0
  66. package/dist/es/framer-motion/dist/es/context/MotionContext/utils.mjs +17 -0
  67. package/dist/es/framer-motion/dist/es/context/PresenceContext.mjs +9 -0
  68. package/dist/es/framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs +9 -0
  69. package/dist/es/framer-motion/dist/es/easing/anticipate.mjs +5 -0
  70. package/dist/es/framer-motion/dist/es/easing/back.mjs +9 -0
  71. package/dist/es/framer-motion/dist/es/easing/circ.mjs +8 -0
  72. package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +51 -0
  73. package/dist/es/framer-motion/dist/es/easing/ease.mjs +7 -0
  74. package/dist/es/framer-motion/dist/es/easing/modifiers/mirror.mjs +5 -0
  75. package/dist/es/framer-motion/dist/es/easing/modifiers/reverse.mjs +5 -0
  76. package/dist/es/framer-motion/dist/es/easing/steps.mjs +15 -0
  77. package/dist/es/framer-motion/dist/es/easing/utils/create-generator-easing.mjs +17 -0
  78. package/dist/es/framer-motion/dist/es/easing/utils/get-easing-for-segment.mjs +8 -0
  79. package/dist/es/framer-motion/dist/es/easing/utils/is-bezier-definition.mjs +3 -0
  80. package/dist/es/framer-motion/dist/es/easing/utils/is-easing-array.mjs +5 -0
  81. package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +38 -0
  82. package/dist/es/framer-motion/dist/es/events/add-dom-event.mjs +6 -0
  83. package/dist/es/framer-motion/dist/es/events/add-pointer-event.mjs +8 -0
  84. package/dist/es/framer-motion/dist/es/events/event-info.mjs +15 -0
  85. package/dist/es/framer-motion/dist/es/events/utils/is-primary-pointer.mjs +18 -0
  86. package/dist/es/framer-motion/dist/es/frameloop/batcher.mjs +71 -0
  87. package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +6 -0
  88. package/dist/es/framer-motion/dist/es/frameloop/index-legacy.mjs +20 -0
  89. package/dist/es/framer-motion/dist/es/frameloop/microtask.mjs +5 -0
  90. package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +80 -0
  91. package/dist/es/framer-motion/dist/es/frameloop/sync-time.mjs +31 -0
  92. package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +487 -0
  93. package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +27 -0
  94. package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +129 -0
  95. package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +53 -0
  96. package/dist/es/framer-motion/dist/es/gestures/focus.mjs +41 -0
  97. package/dist/es/framer-motion/dist/es/gestures/hover.mjs +33 -0
  98. package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +156 -0
  99. package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +50 -0
  100. package/dist/es/framer-motion/dist/es/gestures/press.mjs +130 -0
  101. package/dist/es/framer-motion/dist/es/gestures/utils/is-node-or-child.mjs +20 -0
  102. package/dist/es/framer-motion/dist/es/motion/features/Feature.mjs +9 -0
  103. package/dist/es/framer-motion/dist/es/motion/features/animation/exit.mjs +31 -0
  104. package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +41 -0
  105. package/dist/es/framer-motion/dist/es/motion/features/animations.mjs +13 -0
  106. package/dist/es/framer-motion/dist/es/motion/features/definitions.mjs +28 -0
  107. package/dist/es/framer-motion/dist/es/motion/features/drag.mjs +17 -0
  108. package/dist/es/framer-motion/dist/es/motion/features/gestures.mjs +21 -0
  109. package/dist/es/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs +134 -0
  110. package/dist/es/framer-motion/dist/es/motion/features/layout.mjs +11 -0
  111. package/dist/es/framer-motion/dist/es/motion/features/load-features.mjs +12 -0
  112. package/dist/es/framer-motion/dist/es/motion/features/viewport/index.mjs +72 -0
  113. package/dist/es/framer-motion/dist/es/motion/features/viewport/observers.mjs +49 -0
  114. package/dist/es/framer-motion/dist/es/motion/index.mjs +98 -0
  115. package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +11 -0
  116. package/dist/es/framer-motion/dist/es/motion/utils/symbol.mjs +3 -0
  117. package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +36 -0
  118. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +134 -0
  119. package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +82 -0
  120. package/dist/es/framer-motion/dist/es/motion/utils/valid-prop.mjs +57 -0
  121. package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +93 -0
  122. package/dist/es/framer-motion/dist/es/projection/geometry/conversion.mjs +33 -0
  123. package/dist/es/framer-motion/dist/es/projection/geometry/copy.mjs +31 -0
  124. package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +119 -0
  125. package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +52 -0
  126. package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +54 -0
  127. package/dist/es/framer-motion/dist/es/projection/geometry/models.mjs +17 -0
  128. package/dist/es/framer-motion/dist/es/projection/geometry/utils.mjs +31 -0
  129. package/dist/es/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +13 -0
  130. package/dist/es/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +27 -0
  131. package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +1583 -0
  132. package/dist/es/framer-motion/dist/es/projection/node/state.mjs +19 -0
  133. package/dist/es/framer-motion/dist/es/projection/shared/stack.mjs +112 -0
  134. package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +41 -0
  135. package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +35 -0
  136. package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +6 -0
  137. package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +49 -0
  138. package/dist/es/framer-motion/dist/es/projection/utils/each-axis.mjs +5 -0
  139. package/dist/es/framer-motion/dist/es/projection/utils/has-transform.mjs +26 -0
  140. package/dist/es/framer-motion/dist/es/projection/utils/measure.mjs +17 -0
  141. package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +477 -0
  142. package/dist/es/framer-motion/dist/es/render/components/create-factory.mjs +23 -0
  143. package/dist/es/framer-motion/dist/es/render/components/m/create.mjs +6 -0
  144. package/dist/es/framer-motion/dist/es/render/components/m/elements.mjs +227 -0
  145. package/dist/es/framer-motion/dist/es/render/components/motion/create.mjs +15 -0
  146. package/dist/es/framer-motion/dist/es/render/components/motion/elements.mjs +194 -0
  147. package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +130 -0
  148. package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +28 -0
  149. package/dist/es/framer-motion/dist/es/render/dom/create-visual-element.mjs +14 -0
  150. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +64 -0
  151. package/dist/es/framer-motion/dist/es/render/dom/resize/handle-window.mjs +30 -0
  152. package/dist/es/framer-motion/dist/es/render/dom/resize/index.mjs +8 -0
  153. package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +80 -0
  154. package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +56 -0
  155. package/dist/es/framer-motion/dist/es/render/dom/scroll/observe.mjs +18 -0
  156. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +45 -0
  157. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +59 -0
  158. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +45 -0
  159. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +35 -0
  160. package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +20 -0
  161. package/dist/es/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +48 -0
  162. package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +5 -0
  163. package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +84 -0
  164. package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +33 -0
  165. package/dist/es/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +6 -0
  166. package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +42 -0
  167. package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +59 -0
  168. package/dist/es/framer-motion/dist/es/render/dom/utils/is-css-variable.mjs +15 -0
  169. package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-component.mjs +30 -0
  170. package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-element.mjs +5 -0
  171. package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +28 -0
  172. package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +65 -0
  173. package/dist/es/framer-motion/dist/es/render/dom/value-types/animatable-none.mjs +15 -0
  174. package/dist/es/framer-motion/dist/es/render/dom/value-types/defaults.mjs +30 -0
  175. package/dist/es/framer-motion/dist/es/render/dom/value-types/dimensions.mjs +15 -0
  176. package/dist/es/framer-motion/dist/es/render/dom/value-types/find.mjs +15 -0
  177. package/dist/es/framer-motion/dist/es/render/dom/value-types/get-as-type.mjs +10 -0
  178. package/dist/es/framer-motion/dist/es/render/dom/value-types/number-browser.mjs +41 -0
  179. package/dist/es/framer-motion/dist/es/render/dom/value-types/number.mjs +18 -0
  180. package/dist/es/framer-motion/dist/es/render/dom/value-types/test.mjs +6 -0
  181. package/dist/es/framer-motion/dist/es/render/dom/value-types/transform.mjs +31 -0
  182. package/dist/es/framer-motion/dist/es/render/dom/value-types/type-auto.mjs +9 -0
  183. package/dist/es/framer-motion/dist/es/render/dom/value-types/type-int.mjs +8 -0
  184. package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +43 -0
  185. package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +57 -0
  186. package/dist/es/framer-motion/dist/es/render/html/config-motion.mjs +12 -0
  187. package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +57 -0
  188. package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +65 -0
  189. package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +62 -0
  190. package/dist/es/framer-motion/dist/es/render/html/utils/create-render-state.mjs +8 -0
  191. package/dist/es/framer-motion/dist/es/render/html/utils/make-none-animatable.mjs +30 -0
  192. package/dist/es/framer-motion/dist/es/render/html/utils/render.mjs +9 -0
  193. package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +20 -0
  194. package/dist/es/framer-motion/dist/es/render/html/utils/transform.mjs +28 -0
  195. package/dist/es/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +41 -0
  196. package/dist/es/framer-motion/dist/es/render/store.mjs +3 -0
  197. package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +45 -0
  198. package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +40 -0
  199. package/dist/es/framer-motion/dist/es/render/svg/lowercase-elements.mjs +33 -0
  200. package/dist/es/framer-motion/dist/es/render/svg/use-props.mjs +24 -0
  201. package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +52 -0
  202. package/dist/es/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +30 -0
  203. package/dist/es/framer-motion/dist/es/render/svg/utils/create-render-state.mjs +8 -0
  204. package/dist/es/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +3 -0
  205. package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +32 -0
  206. package/dist/es/framer-motion/dist/es/render/svg/utils/render.mjs +12 -0
  207. package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +19 -0
  208. package/dist/es/framer-motion/dist/es/render/svg/utils/transform-origin.mjs +18 -0
  209. package/dist/es/framer-motion/dist/es/render/utils/KeyframesResolver.mjs +164 -0
  210. package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +332 -0
  211. package/dist/es/framer-motion/dist/es/render/utils/compare-by-depth.mjs +3 -0
  212. package/dist/es/framer-motion/dist/es/render/utils/flat-tree.mjs +24 -0
  213. package/dist/es/framer-motion/dist/es/render/utils/get-variant-context.mjs +28 -0
  214. package/dist/es/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +13 -0
  215. package/dist/es/framer-motion/dist/es/render/utils/is-variant-label.mjs +8 -0
  216. package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +59 -0
  217. package/dist/es/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +8 -0
  218. package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +36 -0
  219. package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +27 -0
  220. package/dist/es/framer-motion/dist/es/render/utils/variant-props.mjs +12 -0
  221. package/dist/es/framer-motion/dist/es/utils/GlobalConfig.mjs +6 -0
  222. package/dist/es/framer-motion/dist/es/utils/array.mjs +11 -0
  223. package/dist/es/framer-motion/dist/es/utils/clamp.mjs +9 -0
  224. package/dist/es/framer-motion/dist/es/utils/delay.mjs +24 -0
  225. package/dist/es/framer-motion/dist/es/utils/distance.mjs +9 -0
  226. package/dist/es/framer-motion/dist/es/utils/errors.mjs +18 -0
  227. package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +6 -0
  228. package/dist/es/framer-motion/dist/es/utils/hsla-to-rgba.mjs +42 -0
  229. package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +75 -0
  230. package/dist/es/framer-motion/dist/es/utils/is-browser.mjs +3 -0
  231. package/dist/es/framer-motion/dist/es/utils/is-numerical-string.mjs +6 -0
  232. package/dist/es/framer-motion/dist/es/utils/is-ref-object.mjs +7 -0
  233. package/dist/es/framer-motion/dist/es/utils/is-zero-value-string.mjs +6 -0
  234. package/dist/es/framer-motion/dist/es/utils/memo.mjs +10 -0
  235. package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +47 -0
  236. package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +94 -0
  237. package/dist/es/framer-motion/dist/es/utils/mix/immediate.mjs +5 -0
  238. package/dist/es/framer-motion/dist/es/utils/mix/index.mjs +14 -0
  239. package/dist/es/framer-motion/dist/es/utils/mix/number.mjs +26 -0
  240. package/dist/es/framer-motion/dist/es/utils/mix/visibility.mjs +16 -0
  241. package/dist/es/framer-motion/dist/es/utils/noop.mjs +3 -0
  242. package/dist/es/framer-motion/dist/es/utils/offsets/default.mjs +9 -0
  243. package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +12 -0
  244. package/dist/es/framer-motion/dist/es/utils/offsets/time.mjs +5 -0
  245. package/dist/es/framer-motion/dist/es/utils/pipe.mjs +11 -0
  246. package/dist/es/framer-motion/dist/es/utils/progress.mjs +18 -0
  247. package/dist/es/framer-motion/dist/es/utils/reduced-motion/index.mjs +19 -0
  248. package/dist/es/framer-motion/dist/es/utils/reduced-motion/state.mjs +5 -0
  249. package/dist/es/framer-motion/dist/es/utils/resolve-value.mjs +11 -0
  250. package/dist/es/framer-motion/dist/es/utils/shallow-compare.mjs +14 -0
  251. package/dist/es/framer-motion/dist/es/utils/subscription-manager.mjs +40 -0
  252. package/dist/es/framer-motion/dist/es/utils/time-conversion.mjs +10 -0
  253. package/dist/es/framer-motion/dist/es/utils/transform.mjs +21 -0
  254. package/dist/es/framer-motion/dist/es/utils/use-constant.mjs +18 -0
  255. package/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs +6 -0
  256. package/dist/es/framer-motion/dist/es/utils/velocity-per-second.mjs +11 -0
  257. package/dist/es/framer-motion/dist/es/utils/warn-once.mjs +11 -0
  258. package/dist/es/framer-motion/dist/es/utils/wrap.mjs +6 -0
  259. package/dist/es/framer-motion/dist/es/value/index.mjs +313 -0
  260. package/dist/es/framer-motion/dist/es/value/types/color/hex.mjs +40 -0
  261. package/dist/es/framer-motion/dist/es/value/types/color/hsla.mjs +22 -0
  262. package/dist/es/framer-motion/dist/es/value/types/color/index.mjs +27 -0
  263. package/dist/es/framer-motion/dist/es/value/types/color/rgba.mjs +25 -0
  264. package/dist/es/framer-motion/dist/es/value/types/color/utils.mjs +29 -0
  265. package/dist/es/framer-motion/dist/es/value/types/complex/filter.mjs +30 -0
  266. package/dist/es/framer-motion/dist/es/value/types/complex/index.mjs +92 -0
  267. package/dist/es/framer-motion/dist/es/value/types/numbers/index.mjs +17 -0
  268. package/dist/es/framer-motion/dist/es/value/types/numbers/units.mjs +17 -0
  269. package/dist/es/framer-motion/dist/es/value/types/utils/color-regex.mjs +3 -0
  270. package/dist/es/framer-motion/dist/es/value/types/utils/float-regex.mjs +3 -0
  271. package/dist/es/framer-motion/dist/es/value/types/utils/is-nullish.mjs +5 -0
  272. package/dist/es/framer-motion/dist/es/value/types/utils/sanitize.mjs +5 -0
  273. package/dist/es/framer-motion/dist/es/value/types/utils/single-color-regex.mjs +3 -0
  274. package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +14 -0
  275. package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +7 -0
  276. package/dist/es/framer-motion/dist/es/value/utils/is-motion-value.mjs +3 -0
  277. package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +16 -0
  278. package/dist/es/motion/lib/index.mjs +30 -0
  279. package/dist/es/motion/lib/react-client.mjs +3 -0
  280. package/dist/es/motion/lib/react-m.mjs +3 -0
  281. package/dist/index.d.ts +1 -0
  282. package/dist/motion.dev.js +6121 -0
  283. package/dist/motion.js +1 -0
  284. package/dist/react-client.d.ts +1 -0
  285. package/dist/react-m.d.ts +1 -0
  286. package/lib/index.js +1 -3
  287. package/lib/index.js.map +1 -1
  288. package/lib/react-client.js +3 -0
  289. package/lib/react-client.js.map +1 -0
  290. package/lib/react-m.js +3 -0
  291. package/lib/react-m.js.map +1 -0
  292. package/lib/react.js +3 -0
  293. package/lib/react.js.map +1 -0
  294. package/package.json +79 -29
  295. package/react/package.json +6 -0
  296. package/react-client/package.json +6 -0
  297. package/react-m/package.json +6 -0
  298. package/rollup.config.mjs +174 -0
  299. package/src/index.ts +1 -0
  300. package/src/react-client.ts +3 -0
  301. package/src/react-m.ts +3 -0
  302. package/src/react.ts +3 -0
  303. package/tsconfig.json +25 -0
  304. package/types/index.d.ts +1 -4
  305. package/types/react-client.d.ts +1 -0
  306. package/types/react-m.d.ts +1 -0
  307. package/types/react.d.ts +1 -0
  308. package/CHANGELOG.md +0 -372
  309. package/dist/animate.cjs.js +0 -22
  310. package/dist/animate.es.js +0 -19
  311. package/dist/main.cjs.js +0 -21
  312. package/dist/main.es.js +0 -3
  313. package/dist/motion.min.js +0 -1
  314. package/dist/motion.umd.js +0 -2359
  315. package/dist/size-index.js +0 -1
  316. package/lib/animate.js +0 -17
  317. package/lib/animate.js.map +0 -1
  318. package/types/animate.d.ts +0 -6
  319. package/types/animate.d.ts.map +0 -1
  320. package/types/index.d.ts.map +0 -1
@@ -0,0 +1,26 @@
1
+ import { easingDefinitionToFunction } from '../../easing/utils/map.mjs';
2
+
3
+ function getOriginIndex(from, total) {
4
+ if (from === "first") {
5
+ return 0;
6
+ }
7
+ else {
8
+ const lastIndex = total - 1;
9
+ return from === "last" ? lastIndex : lastIndex / 2;
10
+ }
11
+ }
12
+ function stagger(duration = 0.1, { startDelay = 0, from = 0, ease } = {}) {
13
+ return (i, total) => {
14
+ const fromIndex = typeof from === "number" ? from : getOriginIndex(from, total);
15
+ const distance = Math.abs(fromIndex - i);
16
+ let delay = duration * distance;
17
+ if (ease) {
18
+ const maxDelay = total * duration;
19
+ const easingFunction = easingDefinitionToFunction(ease);
20
+ delay = easingFunction(delay / maxDelay) * maxDelay;
21
+ }
22
+ return startDelay + delay;
23
+ };
24
+ }
25
+
26
+ export { getOriginIndex, stagger };
@@ -0,0 +1,40 @@
1
+ import { useContext, useId, useEffect, useCallback } from 'react';
2
+ import { PresenceContext } from '../../context/PresenceContext.mjs';
3
+
4
+ /**
5
+ * When a component is the child of `AnimatePresence`, it can use `usePresence`
6
+ * to access information about whether it's still present in the React tree.
7
+ *
8
+ * ```jsx
9
+ * import { usePresence } from "framer-motion"
10
+ *
11
+ * export const Component = () => {
12
+ * const [isPresent, safeToRemove] = usePresence()
13
+ *
14
+ * useEffect(() => {
15
+ * !isPresent && setTimeout(safeToRemove, 1000)
16
+ * }, [isPresent])
17
+ *
18
+ * return <div />
19
+ * }
20
+ * ```
21
+ *
22
+ * If `isPresent` is `false`, it means that a component has been removed the tree, but
23
+ * `AnimatePresence` won't really remove it until `safeToRemove` has been called.
24
+ *
25
+ * @public
26
+ */
27
+ function usePresence() {
28
+ const context = useContext(PresenceContext);
29
+ if (context === null)
30
+ return [true, null];
31
+ const { isPresent, onExitComplete, register } = context;
32
+ // It's safe to call the following hooks conditionally (after an early return) because the context will always
33
+ // either be null or non-null for the lifespan of the component.
34
+ const id = useId();
35
+ useEffect(() => register(id), []);
36
+ const safeToRemove = useCallback(() => onExitComplete && onExitComplete(id), [id, onExitComplete]);
37
+ return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
38
+ }
39
+
40
+ export { usePresence };
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ const LayoutGroupContext = createContext({});
5
+
6
+ export { LayoutGroupContext };
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ const LazyContext = createContext({ strict: false });
5
+
6
+ export { LazyContext };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ /**
5
+ * @public
6
+ */
7
+ const MotionConfigContext = createContext({
8
+ transformPagePoint: (p) => p,
9
+ isStatic: false,
10
+ reducedMotion: "never",
11
+ });
12
+
13
+ export { MotionConfigContext };
@@ -0,0 +1,13 @@
1
+ import { useContext, useMemo } from 'react';
2
+ import { MotionContext } from './index.mjs';
3
+ import { getCurrentTreeVariants } from './utils.mjs';
4
+
5
+ function useCreateMotionContext(props) {
6
+ const { initial, animate } = getCurrentTreeVariants(props, useContext(MotionContext));
7
+ return useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8
+ }
9
+ function variantLabelsAsDependency(prop) {
10
+ return Array.isArray(prop) ? prop.join(" ") : prop;
11
+ }
12
+
13
+ export { useCreateMotionContext };
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ const MotionContext = createContext({});
5
+
6
+ export { MotionContext };
@@ -0,0 +1,17 @@
1
+ import { isVariantLabel } from '../../render/utils/is-variant-label.mjs';
2
+ import { isControllingVariants } from '../../render/utils/is-controlling-variants.mjs';
3
+
4
+ function getCurrentTreeVariants(props, context) {
5
+ if (isControllingVariants(props)) {
6
+ const { initial, animate } = props;
7
+ return {
8
+ initial: initial === false || isVariantLabel(initial)
9
+ ? initial
10
+ : undefined,
11
+ animate: isVariantLabel(animate) ? animate : undefined,
12
+ };
13
+ }
14
+ return props.inherit !== false ? context : {};
15
+ }
16
+
17
+ export { getCurrentTreeVariants };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ /**
5
+ * @public
6
+ */
7
+ const PresenceContext = createContext(null);
8
+
9
+ export { PresenceContext };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { createContext } from 'react';
3
+
4
+ /**
5
+ * Internal, exported only for usage in Framer
6
+ */
7
+ const SwitchLayoutGroupContext = createContext({});
8
+
9
+ export { SwitchLayoutGroupContext };
@@ -0,0 +1,5 @@
1
+ import { backIn } from './back.mjs';
2
+
3
+ const anticipate = (p) => (p *= 2) < 1 ? 0.5 * backIn(p) : 0.5 * (2 - Math.pow(2, -10 * (p - 1)));
4
+
5
+ export { anticipate };
@@ -0,0 +1,9 @@
1
+ import { cubicBezier } from './cubic-bezier.mjs';
2
+ import { mirrorEasing } from './modifiers/mirror.mjs';
3
+ import { reverseEasing } from './modifiers/reverse.mjs';
4
+
5
+ const backOut = /*@__PURE__*/ cubicBezier(0.33, 1.53, 0.69, 0.99);
6
+ const backIn = /*@__PURE__*/ reverseEasing(backOut);
7
+ const backInOut = /*@__PURE__*/ mirrorEasing(backIn);
8
+
9
+ export { backIn, backInOut, backOut };
@@ -0,0 +1,8 @@
1
+ import { mirrorEasing } from './modifiers/mirror.mjs';
2
+ import { reverseEasing } from './modifiers/reverse.mjs';
3
+
4
+ const circIn = (p) => 1 - Math.sin(Math.acos(p));
5
+ const circOut = reverseEasing(circIn);
6
+ const circInOut = mirrorEasing(circIn);
7
+
8
+ export { circIn, circInOut, circOut };
@@ -0,0 +1,51 @@
1
+ import { noop } from '../utils/noop.mjs';
2
+
3
+ /*
4
+ Bezier function generator
5
+ This has been modified from Gaëtan Renaudeau's BezierEasing
6
+ https://github.com/gre/bezier-easing/blob/master/src/index.js
7
+ https://github.com/gre/bezier-easing/blob/master/LICENSE
8
+
9
+ I've removed the newtonRaphsonIterate algo because in benchmarking it
10
+ wasn't noticiably faster than binarySubdivision, indeed removing it
11
+ usually improved times, depending on the curve.
12
+ I also removed the lookup table, as for the added bundle size and loop we're
13
+ only cutting ~4 or so subdivision iterations. I bumped the max iterations up
14
+ to 12 to compensate and this still tended to be faster for no perceivable
15
+ loss in accuracy.
16
+ Usage
17
+ const easeOut = cubicBezier(.17,.67,.83,.67);
18
+ const x = easeOut(0.5); // returns 0.627...
19
+ */
20
+ // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
21
+ const calcBezier = (t, a1, a2) => (((1.0 - 3.0 * a2 + 3.0 * a1) * t + (3.0 * a2 - 6.0 * a1)) * t + 3.0 * a1) *
22
+ t;
23
+ const subdivisionPrecision = 0.0000001;
24
+ const subdivisionMaxIterations = 12;
25
+ function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
26
+ let currentX;
27
+ let currentT;
28
+ let i = 0;
29
+ do {
30
+ currentT = lowerBound + (upperBound - lowerBound) / 2.0;
31
+ currentX = calcBezier(currentT, mX1, mX2) - x;
32
+ if (currentX > 0.0) {
33
+ upperBound = currentT;
34
+ }
35
+ else {
36
+ lowerBound = currentT;
37
+ }
38
+ } while (Math.abs(currentX) > subdivisionPrecision &&
39
+ ++i < subdivisionMaxIterations);
40
+ return currentT;
41
+ }
42
+ function cubicBezier(mX1, mY1, mX2, mY2) {
43
+ // If this is a linear gradient, return linear easing
44
+ if (mX1 === mY1 && mX2 === mY2)
45
+ return noop;
46
+ const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
47
+ // If animation is at start/end, return t without easing
48
+ return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
49
+ }
50
+
51
+ export { cubicBezier };
@@ -0,0 +1,7 @@
1
+ import { cubicBezier } from './cubic-bezier.mjs';
2
+
3
+ const easeIn = /*@__PURE__*/ cubicBezier(0.42, 0, 1, 1);
4
+ const easeOut = /*@__PURE__*/ cubicBezier(0, 0, 0.58, 1);
5
+ const easeInOut = /*@__PURE__*/ cubicBezier(0.42, 0, 0.58, 1);
6
+
7
+ export { easeIn, easeInOut, easeOut };
@@ -0,0 +1,5 @@
1
+ // Accepts an easing function and returns a new one that outputs mirrored values for
2
+ // the second half of the animation. Turns easeIn into easeInOut.
3
+ const mirrorEasing = (easing) => (p) => p <= 0.5 ? easing(2 * p) / 2 : (2 - easing(2 * (1 - p))) / 2;
4
+
5
+ export { mirrorEasing };
@@ -0,0 +1,5 @@
1
+ // Accepts an easing function and returns a new one that outputs reversed values.
2
+ // Turns easeIn into easeOut.
3
+ const reverseEasing = (easing) => (p) => 1 - easing(1 - p);
4
+
5
+ export { reverseEasing };
@@ -0,0 +1,15 @@
1
+ import { clamp } from '../utils/clamp.mjs';
2
+
3
+ function steps(numSteps, direction = "end") {
4
+ return (progress) => {
5
+ progress =
6
+ direction === "end"
7
+ ? Math.min(progress, 0.999)
8
+ : Math.max(progress, 0.001);
9
+ const expanded = progress * numSteps;
10
+ const rounded = direction === "end" ? Math.floor(expanded) : Math.ceil(expanded);
11
+ return clamp(0, 1, rounded / numSteps);
12
+ };
13
+ }
14
+
15
+ export { steps };
@@ -0,0 +1,17 @@
1
+ import { calcGeneratorDuration, maxGeneratorDuration } from '../../animation/generators/utils/calc-duration.mjs';
2
+ import { millisecondsToSeconds } from '../../utils/time-conversion.mjs';
3
+
4
+ /**
5
+ * Create a progress => progress easing function from a generator.
6
+ */
7
+ function createGeneratorEasing(options, scale = 100, createGenerator) {
8
+ const generator = createGenerator({ ...options, keyframes: [0, scale] });
9
+ const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
10
+ return {
11
+ type: "keyframes",
12
+ ease: (progress) => generator.next(duration * progress).value / scale,
13
+ duration: millisecondsToSeconds(duration),
14
+ };
15
+ }
16
+
17
+ export { createGeneratorEasing };
@@ -0,0 +1,8 @@
1
+ import { wrap } from '../../utils/wrap.mjs';
2
+ import { isEasingArray } from './is-easing-array.mjs';
3
+
4
+ function getEasingForSegment(easing, i) {
5
+ return isEasingArray(easing) ? easing[wrap(0, easing.length, i)] : easing;
6
+ }
7
+
8
+ export { getEasingForSegment };
@@ -0,0 +1,3 @@
1
+ const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
2
+
3
+ export { isBezierDefinition };
@@ -0,0 +1,5 @@
1
+ const isEasingArray = (ease) => {
2
+ return Array.isArray(ease) && typeof ease[0] !== "number";
3
+ };
4
+
5
+ export { isEasingArray };
@@ -0,0 +1,38 @@
1
+ import { invariant } from '../../utils/errors.mjs';
2
+ import { cubicBezier } from '../cubic-bezier.mjs';
3
+ import { noop } from '../../utils/noop.mjs';
4
+ import { easeIn, easeInOut, easeOut } from '../ease.mjs';
5
+ import { circIn, circInOut, circOut } from '../circ.mjs';
6
+ import { backIn, backInOut, backOut } from '../back.mjs';
7
+ import { anticipate } from '../anticipate.mjs';
8
+ import { isBezierDefinition } from './is-bezier-definition.mjs';
9
+
10
+ const easingLookup = {
11
+ linear: noop,
12
+ easeIn,
13
+ easeInOut,
14
+ easeOut,
15
+ circIn,
16
+ circInOut,
17
+ circOut,
18
+ backIn,
19
+ backInOut,
20
+ backOut,
21
+ anticipate,
22
+ };
23
+ const easingDefinitionToFunction = (definition) => {
24
+ if (isBezierDefinition(definition)) {
25
+ // If cubic bezier definition, create bezier curve
26
+ invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
27
+ const [x1, y1, x2, y2] = definition;
28
+ return cubicBezier(x1, y1, x2, y2);
29
+ }
30
+ else if (typeof definition === "string") {
31
+ // Else lookup from table
32
+ invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
33
+ return easingLookup[definition];
34
+ }
35
+ return definition;
36
+ };
37
+
38
+ export { easingDefinitionToFunction };
@@ -0,0 +1,6 @@
1
+ function addDomEvent(target, eventName, handler, options = { passive: true }) {
2
+ target.addEventListener(eventName, handler, options);
3
+ return () => target.removeEventListener(eventName, handler);
4
+ }
5
+
6
+ export { addDomEvent };
@@ -0,0 +1,8 @@
1
+ import { addDomEvent } from './add-dom-event.mjs';
2
+ import { addPointerInfo } from './event-info.mjs';
3
+
4
+ function addPointerEvent(target, eventName, handler, options) {
5
+ return addDomEvent(target, eventName, addPointerInfo(handler), options);
6
+ }
7
+
8
+ export { addPointerEvent };
@@ -0,0 +1,15 @@
1
+ import { isPrimaryPointer } from './utils/is-primary-pointer.mjs';
2
+
3
+ function extractEventInfo(event, pointType = "page") {
4
+ return {
5
+ point: {
6
+ x: event[`${pointType}X`],
7
+ y: event[`${pointType}Y`],
8
+ },
9
+ };
10
+ }
11
+ const addPointerInfo = (handler) => {
12
+ return (event) => isPrimaryPointer(event) && handler(event, extractEventInfo(event));
13
+ };
14
+
15
+ export { addPointerInfo, extractEventInfo };
@@ -0,0 +1,18 @@
1
+ const isPrimaryPointer = (event) => {
2
+ if (event.pointerType === "mouse") {
3
+ return typeof event.button !== "number" || event.button <= 0;
4
+ }
5
+ else {
6
+ /**
7
+ * isPrimary is true for all mice buttons, whereas every touch point
8
+ * is regarded as its own input. So subsequent concurrent touch points
9
+ * will be false.
10
+ *
11
+ * Specifically match against false here as incomplete versions of
12
+ * PointerEvents in very old browser might have it set as undefined.
13
+ */
14
+ return event.isPrimary !== false;
15
+ }
16
+ };
17
+
18
+ export { isPrimaryPointer };
@@ -0,0 +1,71 @@
1
+ import { createRenderStep } from './render-step.mjs';
2
+
3
+ const stepsOrder = [
4
+ "read", // Read
5
+ "resolveKeyframes", // Write/Read/Write/Read
6
+ "update", // Compute
7
+ "preRender", // Compute
8
+ "render", // Write
9
+ "postRender", // Compute
10
+ ];
11
+ const maxElapsed = 40;
12
+ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
13
+ let runNextFrame = false;
14
+ let useDefaultElapsed = true;
15
+ const state = {
16
+ delta: 0.0,
17
+ timestamp: 0.0,
18
+ isProcessing: false,
19
+ };
20
+ const flagRunNextFrame = () => (runNextFrame = true);
21
+ const steps = stepsOrder.reduce((acc, key) => {
22
+ acc[key] = createRenderStep(flagRunNextFrame);
23
+ return acc;
24
+ }, {});
25
+ const { read, resolveKeyframes, update, preRender, render, postRender } = steps;
26
+ const processBatch = () => {
27
+ const timestamp = performance.now();
28
+ runNextFrame = false;
29
+ state.delta = useDefaultElapsed
30
+ ? 1000 / 60
31
+ : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);
32
+ state.timestamp = timestamp;
33
+ state.isProcessing = true;
34
+ // Unrolled render loop for better per-frame performance
35
+ read.process(state);
36
+ resolveKeyframes.process(state);
37
+ update.process(state);
38
+ preRender.process(state);
39
+ render.process(state);
40
+ postRender.process(state);
41
+ state.isProcessing = false;
42
+ if (runNextFrame && allowKeepAlive) {
43
+ useDefaultElapsed = false;
44
+ scheduleNextBatch(processBatch);
45
+ }
46
+ };
47
+ const wake = () => {
48
+ runNextFrame = true;
49
+ useDefaultElapsed = true;
50
+ if (!state.isProcessing) {
51
+ scheduleNextBatch(processBatch);
52
+ }
53
+ };
54
+ const schedule = stepsOrder.reduce((acc, key) => {
55
+ const step = steps[key];
56
+ acc[key] = (process, keepAlive = false, immediate = false) => {
57
+ if (!runNextFrame)
58
+ wake();
59
+ return step.schedule(process, keepAlive, immediate);
60
+ };
61
+ return acc;
62
+ }, {});
63
+ const cancel = (process) => {
64
+ for (let i = 0; i < stepsOrder.length; i++) {
65
+ steps[stepsOrder[i]].cancel(process);
66
+ }
67
+ };
68
+ return { schedule, cancel, state, steps };
69
+ }
70
+
71
+ export { createRenderBatcher, stepsOrder };
@@ -0,0 +1,6 @@
1
+ import { noop } from '../utils/noop.mjs';
2
+ import { createRenderBatcher } from './batcher.mjs';
3
+
4
+ const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
5
+
6
+ export { cancelFrame, frame, frameData, frameSteps };
@@ -0,0 +1,20 @@
1
+ import { stepsOrder } from './batcher.mjs';
2
+ import { frame, cancelFrame } from './frame.mjs';
3
+
4
+ /**
5
+ * @deprecated
6
+ *
7
+ * Import as `frame` instead.
8
+ */
9
+ const sync = frame;
10
+ /**
11
+ * @deprecated
12
+ *
13
+ * Use cancelFrame(callback) instead.
14
+ */
15
+ const cancelSync = stepsOrder.reduce((acc, key) => {
16
+ acc[key] = (process) => cancelFrame(process);
17
+ return acc;
18
+ }, {});
19
+
20
+ export { cancelSync, sync };
@@ -0,0 +1,5 @@
1
+ import { createRenderBatcher } from './batcher.mjs';
2
+
3
+ const { schedule: microtask, cancel: cancelMicrotask } = createRenderBatcher(queueMicrotask, false);
4
+
5
+ export { cancelMicrotask, microtask };
@@ -0,0 +1,80 @@
1
+ function createRenderStep(runNextFrame) {
2
+ /**
3
+ * We create and reuse two queues, one to queue jobs for the current frame
4
+ * and one for the next. We reuse to avoid triggering GC after x frames.
5
+ */
6
+ let thisFrame = new Set();
7
+ let nextFrame = new Set();
8
+ /**
9
+ * Track whether we're currently processing jobs in this step. This way
10
+ * we can decide whether to schedule new jobs for this frame or next.
11
+ */
12
+ let isProcessing = false;
13
+ let flushNextFrame = false;
14
+ /**
15
+ * A set of processes which were marked keepAlive when scheduled.
16
+ */
17
+ const toKeepAlive = new WeakSet();
18
+ let latestFrameData = {
19
+ delta: 0.0,
20
+ timestamp: 0.0,
21
+ isProcessing: false,
22
+ };
23
+ function triggerCallback(callback) {
24
+ if (toKeepAlive.has(callback)) {
25
+ step.schedule(callback);
26
+ runNextFrame();
27
+ }
28
+ callback(latestFrameData);
29
+ }
30
+ const step = {
31
+ /**
32
+ * Schedule a process to run on the next frame.
33
+ */
34
+ schedule: (callback, keepAlive = false, immediate = false) => {
35
+ const addToCurrentFrame = immediate && isProcessing;
36
+ const queue = addToCurrentFrame ? thisFrame : nextFrame;
37
+ if (keepAlive)
38
+ toKeepAlive.add(callback);
39
+ if (!queue.has(callback))
40
+ queue.add(callback);
41
+ return callback;
42
+ },
43
+ /**
44
+ * Cancel the provided callback from running on the next frame.
45
+ */
46
+ cancel: (callback) => {
47
+ nextFrame.delete(callback);
48
+ toKeepAlive.delete(callback);
49
+ },
50
+ /**
51
+ * Execute all schedule callbacks.
52
+ */
53
+ process: (frameData) => {
54
+ latestFrameData = frameData;
55
+ /**
56
+ * If we're already processing we've probably been triggered by a flushSync
57
+ * inside an existing process. Instead of executing, mark flushNextFrame
58
+ * as true and ensure we flush the following frame at the end of this one.
59
+ */
60
+ if (isProcessing) {
61
+ flushNextFrame = true;
62
+ return;
63
+ }
64
+ isProcessing = true;
65
+ [thisFrame, nextFrame] = [nextFrame, thisFrame];
66
+ // Clear the next frame queue
67
+ nextFrame.clear();
68
+ // Execute this frame
69
+ thisFrame.forEach(triggerCallback);
70
+ isProcessing = false;
71
+ if (flushNextFrame) {
72
+ flushNextFrame = false;
73
+ step.process(frameData);
74
+ }
75
+ },
76
+ };
77
+ return step;
78
+ }
79
+
80
+ export { createRenderStep };
@@ -0,0 +1,31 @@
1
+ import { MotionGlobalConfig } from '../utils/GlobalConfig.mjs';
2
+ import { frameData } from './frame.mjs';
3
+
4
+ let now;
5
+ function clearTime() {
6
+ now = undefined;
7
+ }
8
+ /**
9
+ * An eventloop-synchronous alternative to performance.now().
10
+ *
11
+ * Ensures that time measurements remain consistent within a synchronous context.
12
+ * Usually calling performance.now() twice within the same synchronous context
13
+ * will return different values which isn't useful for animations when we're usually
14
+ * trying to sync animations to the same frame.
15
+ */
16
+ const time = {
17
+ now: () => {
18
+ if (now === undefined) {
19
+ time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming
20
+ ? frameData.timestamp
21
+ : performance.now());
22
+ }
23
+ return now;
24
+ },
25
+ set: (newTime) => {
26
+ now = newTime;
27
+ queueMicrotask(clearTime);
28
+ },
29
+ };
30
+
31
+ export { time };