motion-start 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (751) hide show
  1. package/README.md +42 -9
  2. package/{src → dist}/animation/UseAnimatedState.svelte +27 -25
  3. package/dist/animation/UseAnimatedState.svelte.d.ts +36 -0
  4. package/dist/animation/UseAnimatedState.svelte.d.ts.map +1 -0
  5. package/dist/animation/UseAnimation.svelte.d.ts +29 -0
  6. package/dist/animation/UseAnimation.svelte.d.ts.map +1 -0
  7. package/{src/animation/animate.ts → dist/animation/animate.d.ts} +59 -78
  8. package/dist/animation/animate.d.ts.map +1 -0
  9. package/dist/animation/animate.js +46 -0
  10. package/dist/animation/animation-controls.d.ts +12 -0
  11. package/dist/animation/animation-controls.d.ts.map +1 -0
  12. package/{src/animation/animation-controls.ts → dist/animation/animation-controls.js} +89 -101
  13. package/{src/animation/types.ts → dist/animation/types.d.ts} +84 -83
  14. package/dist/animation/types.d.ts.map +1 -0
  15. package/dist/animation/types.js +1 -0
  16. package/dist/animation/use-animated-state.d.ts +2 -0
  17. package/dist/animation/use-animated-state.d.ts.map +1 -0
  18. package/dist/animation/use-animated-state.js +1 -0
  19. package/dist/animation/use-animation.d.ts +62 -0
  20. package/dist/animation/use-animation.d.ts.map +1 -0
  21. package/{src/animation/use-animation.ts → dist/animation/use-animation.js} +66 -74
  22. package/dist/animation/utils/default-transitions.d.ts +27 -0
  23. package/dist/animation/utils/default-transitions.d.ts.map +1 -0
  24. package/{src/animation/utils/default-transitions.ts → dist/animation/utils/default-transitions.js} +57 -70
  25. package/dist/animation/utils/easing.d.ts +9 -0
  26. package/dist/animation/utils/easing.d.ts.map +1 -0
  27. package/{src/animation/utils/easing.ts → dist/animation/utils/easing.js} +42 -55
  28. package/dist/animation/utils/is-animatable.d.ts +17 -0
  29. package/dist/animation/utils/is-animatable.d.ts.map +1 -0
  30. package/{src/animation/utils/is-animatable.ts → dist/animation/utils/is-animatable.js} +33 -42
  31. package/{src/animation/utils/is-animation-controls.ts → dist/animation/utils/is-animation-controls.d.ts} +12 -17
  32. package/dist/animation/utils/is-animation-controls.d.ts.map +1 -0
  33. package/dist/animation/utils/is-animation-controls.js +8 -0
  34. package/{src/animation/utils/is-keyframes-target.ts → dist/animation/utils/is-keyframes-target.d.ts} +12 -17
  35. package/dist/animation/utils/is-keyframes-target.d.ts.map +1 -0
  36. package/dist/animation/utils/is-keyframes-target.js +8 -0
  37. package/dist/animation/utils/transitions.d.ts +35 -0
  38. package/dist/animation/utils/transitions.d.ts.map +1 -0
  39. package/{src/animation/utils/transitions.ts → dist/animation/utils/transitions.js} +211 -218
  40. package/{src/animation/utils/variant-resolvers.ts → dist/animation/utils/variant-resolvers.d.ts} +17 -15
  41. package/dist/animation/utils/variant-resolvers.d.ts.map +1 -0
  42. package/dist/animation/utils/variant-resolvers.js +1 -0
  43. package/{src → dist}/components/AnimatePresence/AnimatePresence.svelte +16 -8
  44. package/dist/components/AnimatePresence/AnimatePresence.svelte.d.ts +39 -0
  45. package/dist/components/AnimatePresence/AnimatePresence.svelte.d.ts.map +1 -0
  46. package/{src → dist}/components/AnimatePresence/PresenceChild/PresenceChild.svelte +14 -14
  47. package/dist/components/AnimatePresence/PresenceChild/PresenceChild.svelte.d.ts +29 -0
  48. package/dist/components/AnimatePresence/PresenceChild/PresenceChild.svelte.d.ts.map +1 -0
  49. package/{src/components/AnimatePresence/PresenceChild/index.ts → dist/components/AnimatePresence/PresenceChild/index.d.ts} +7 -7
  50. package/dist/components/AnimatePresence/PresenceChild/index.d.ts.map +1 -0
  51. package/dist/components/AnimatePresence/PresenceChild/index.js +5 -0
  52. package/{src/components/AnimatePresence/PresenceChild/types.ts → dist/components/AnimatePresence/PresenceChild/types.d.ts} +10 -10
  53. package/dist/components/AnimatePresence/PresenceChild/types.d.ts.map +1 -0
  54. package/dist/components/AnimatePresence/PresenceChild/types.js +1 -0
  55. package/{src/components/AnimatePresence/index.ts → dist/components/AnimatePresence/index.d.ts} +51 -46
  56. package/dist/components/AnimatePresence/index.d.ts.map +1 -0
  57. package/dist/components/AnimatePresence/index.js +2 -0
  58. package/dist/components/AnimatePresence/type.spec-d.d.ts +2 -0
  59. package/dist/components/AnimatePresence/type.spec-d.d.ts.map +1 -0
  60. package/dist/components/AnimatePresence/type.spec-d.js +6 -0
  61. package/{src/components/AnimatePresence/types.ts → dist/components/AnimatePresence/types.d.ts} +82 -79
  62. package/dist/components/AnimatePresence/types.d.ts.map +1 -0
  63. package/dist/components/AnimatePresence/types.js +1 -0
  64. package/dist/components/AnimatePresence/use-presence.d.ts +56 -0
  65. package/dist/components/AnimatePresence/use-presence.d.ts.map +1 -0
  66. package/{src/components/AnimatePresence/use-presence.ts → dist/components/AnimatePresence/use-presence.js} +69 -90
  67. package/{src → dist}/components/AnimateSharedLayout/AnimateSharedLayout.svelte +22 -15
  68. package/dist/components/AnimateSharedLayout/AnimateSharedLayout.svelte.d.ts +29 -0
  69. package/dist/components/AnimateSharedLayout/AnimateSharedLayout.svelte.d.ts.map +1 -0
  70. package/dist/components/AnimateSharedLayout/index.d.ts +11 -0
  71. package/dist/components/AnimateSharedLayout/index.d.ts.map +1 -0
  72. package/{src/components/AnimateSharedLayout/index.ts → dist/components/AnimateSharedLayout/index.js} +10 -11
  73. package/dist/components/AnimateSharedLayout/type.spec-d.d.ts +2 -0
  74. package/dist/components/AnimateSharedLayout/type.spec-d.d.ts.map +1 -0
  75. package/dist/components/AnimateSharedLayout/type.spec-d.js +6 -0
  76. package/{src/components/AnimateSharedLayout/types.ts → dist/components/AnimateSharedLayout/types.d.ts} +91 -111
  77. package/dist/components/AnimateSharedLayout/types.d.ts.map +1 -0
  78. package/dist/components/AnimateSharedLayout/types.js +39 -0
  79. package/dist/components/AnimateSharedLayout/utils/batcher.d.ts +11 -0
  80. package/dist/components/AnimateSharedLayout/utils/batcher.d.ts.map +1 -0
  81. package/{src/components/AnimateSharedLayout/utils/batcher.ts → dist/components/AnimateSharedLayout/utils/batcher.js} +86 -96
  82. package/dist/components/AnimateSharedLayout/utils/crossfader.d.ts +27 -0
  83. package/dist/components/AnimateSharedLayout/utils/crossfader.d.ts.map +1 -0
  84. package/{src/components/AnimateSharedLayout/utils/crossfader.ts → dist/components/AnimateSharedLayout/utils/crossfader.js} +228 -260
  85. package/dist/components/AnimateSharedLayout/utils/rotate.d.ts +8 -0
  86. package/dist/components/AnimateSharedLayout/utils/rotate.d.ts.map +1 -0
  87. package/{src/components/AnimateSharedLayout/utils/rotate.ts → dist/components/AnimateSharedLayout/utils/rotate.js} +39 -48
  88. package/dist/components/AnimateSharedLayout/utils/stack.d.ts +18 -0
  89. package/dist/components/AnimateSharedLayout/utils/stack.d.ts.map +1 -0
  90. package/{src/components/AnimateSharedLayout/utils/stack.ts → dist/components/AnimateSharedLayout/utils/stack.js} +138 -160
  91. package/{src → dist}/components/LazyMotion/LazyMotion.svelte +9 -3
  92. package/dist/components/LazyMotion/LazyMotion.svelte.d.ts +29 -0
  93. package/dist/components/LazyMotion/LazyMotion.svelte.d.ts.map +1 -0
  94. package/{src/components/LazyMotion/index.ts → dist/components/LazyMotion/index.d.ts} +42 -42
  95. package/dist/components/LazyMotion/index.d.ts.map +1 -0
  96. package/dist/components/LazyMotion/index.js +36 -0
  97. package/{src/components/LazyMotion/types.ts → dist/components/LazyMotion/types.d.ts} +57 -58
  98. package/dist/components/LazyMotion/types.d.ts.map +1 -0
  99. package/dist/components/LazyMotion/types.js +1 -0
  100. package/{src → dist}/components/MotionConfig/MotionConfig.svelte +4 -2
  101. package/dist/components/MotionConfig/MotionConfig.svelte.d.ts +29 -0
  102. package/dist/components/MotionConfig/MotionConfig.svelte.d.ts.map +1 -0
  103. package/dist/components/MotionConfig/MotionConfigScaleCorrection.d.ts +4 -0
  104. package/dist/components/MotionConfig/MotionConfigScaleCorrection.d.ts.map +1 -0
  105. package/dist/components/MotionConfig/MotionConfigScaleCorrection.js +32 -0
  106. package/{src/components/MotionConfig/index.ts → dist/components/MotionConfig/index.d.ts} +21 -20
  107. package/dist/components/MotionConfig/index.d.ts.map +1 -0
  108. package/dist/components/MotionConfig/index.js +14 -0
  109. package/dist/components/MotionConfig/type.spec-d.d.ts +2 -0
  110. package/dist/components/MotionConfig/type.spec-d.d.ts.map +1 -0
  111. package/dist/components/MotionConfig/type.spec-d.js +6 -0
  112. package/dist/components/MotionDiv.svelte.d.ts +31 -0
  113. package/dist/components/MotionDiv.svelte.d.ts.map +1 -0
  114. package/dist/context/DOMcontext.d.ts +6 -0
  115. package/dist/context/DOMcontext.d.ts.map +1 -0
  116. package/dist/context/DOMcontext.js +20 -0
  117. package/dist/context/LayoutGroupContext.d.ts +10 -0
  118. package/dist/context/LayoutGroupContext.d.ts.map +1 -0
  119. package/dist/context/LayoutGroupContext.js +7 -0
  120. package/dist/context/LazyContext.d.ts +13 -0
  121. package/dist/context/LazyContext.d.ts.map +1 -0
  122. package/dist/context/LazyContext.js +5 -0
  123. package/{src/context/MotionConfigContext.ts → dist/context/MotionConfigContext.d.ts} +35 -48
  124. package/dist/context/MotionConfigContext.d.ts.map +1 -0
  125. package/dist/context/MotionConfigContext.js +15 -0
  126. package/dist/context/MotionContext/MotionContext.svelte +13 -0
  127. package/dist/context/MotionContext/MotionContext.svelte.d.ts +5 -0
  128. package/dist/context/MotionContext/MotionContext.svelte.d.ts.map +1 -0
  129. package/dist/context/MotionContext/MotionContextProvider.svelte.d.ts +31 -0
  130. package/dist/context/MotionContext/MotionContextProvider.svelte.d.ts.map +1 -0
  131. package/dist/context/MotionContext/UseCreateMotionContext.svelte +39 -0
  132. package/dist/context/MotionContext/UseCreateMotionContext.svelte.d.ts +42 -0
  133. package/dist/context/MotionContext/UseCreateMotionContext.svelte.d.ts.map +1 -0
  134. package/dist/context/MotionContext/create.d.ts +2 -0
  135. package/dist/context/MotionContext/create.d.ts.map +1 -0
  136. package/{src/context/MotionContext/create.ts → dist/context/MotionContext/create.js} +1 -1
  137. package/dist/context/MotionContext/index.d.ts +15 -0
  138. package/dist/context/MotionContext/index.d.ts.map +1 -0
  139. package/dist/context/MotionContext/index.js +8 -0
  140. package/dist/context/MotionContext/utils.d.ts +9 -0
  141. package/dist/context/MotionContext/utils.d.ts.map +1 -0
  142. package/{src/context/MotionContext/utils.ts → dist/context/MotionContext/utils.js} +18 -29
  143. package/{src/context/PresenceContext.ts → dist/context/PresenceContext.d.ts} +22 -26
  144. package/dist/context/PresenceContext.d.ts.map +1 -0
  145. package/dist/context/PresenceContext.js +7 -0
  146. package/{src → dist}/context/ScaleCorrectionProvider.svelte +2 -3
  147. package/dist/context/ScaleCorrectionProvider.svelte.d.ts +33 -0
  148. package/dist/context/ScaleCorrectionProvider.svelte.d.ts.map +1 -0
  149. package/dist/context/SharedLayoutContext.d.ts +14 -0
  150. package/dist/context/SharedLayoutContext.d.ts.map +1 -0
  151. package/dist/context/SharedLayoutContext.js +18 -0
  152. package/dist/events/UseDomEvent-type.spec-d.d.ts +2 -0
  153. package/dist/events/UseDomEvent-type.spec-d.d.ts.map +1 -0
  154. package/dist/events/UseDomEvent-type.spec-d.js +6 -0
  155. package/{src → dist}/events/UseDomEvent.svelte +2 -17
  156. package/dist/events/UseDomEvent.svelte.d.ts +29 -0
  157. package/dist/events/UseDomEvent.svelte.d.ts.map +1 -0
  158. package/dist/events/UsePointerEvent.svelte +22 -0
  159. package/dist/events/UsePointerEvent.svelte.d.ts +29 -0
  160. package/dist/events/UsePointerEvent.svelte.d.ts.map +1 -0
  161. package/dist/events/event-info.d.ts +11 -0
  162. package/dist/events/event-info.d.ts.map +1 -0
  163. package/{src/events/event-info.ts → dist/events/event-info.js} +65 -69
  164. package/{src/events/types.ts → dist/events/types.d.ts} +16 -15
  165. package/dist/events/types.d.ts.map +1 -0
  166. package/dist/events/types.js +1 -0
  167. package/{src/events/use-dom-event.ts → dist/events/use-dom-event.d.ts} +51 -48
  168. package/dist/events/use-dom-event.d.ts.map +1 -0
  169. package/dist/events/use-dom-event.js +30 -0
  170. package/dist/events/use-pointer-event.d.ts +32 -0
  171. package/dist/events/use-pointer-event.d.ts.map +1 -0
  172. package/dist/events/use-pointer-event.js +35 -0
  173. package/dist/events/utils.d.ts +9 -0
  174. package/dist/events/utils.d.ts.map +1 -0
  175. package/{src/events/utils.ts → dist/events/utils.js} +20 -25
  176. package/dist/gestures/PanSession.d.ts +142 -0
  177. package/dist/gestures/PanSession.d.ts.map +1 -0
  178. package/dist/gestures/PanSession.js +232 -0
  179. package/dist/gestures/UseFocusGesture.svelte.d.ts +31 -0
  180. package/dist/gestures/UseFocusGesture.svelte.d.ts.map +1 -0
  181. package/dist/gestures/UseGestures.svelte.d.ts +31 -0
  182. package/dist/gestures/UseGestures.svelte.d.ts.map +1 -0
  183. package/{src → dist}/gestures/UseHoverGesture.svelte +6 -3
  184. package/dist/gestures/UseHoverGesture.svelte.d.ts +31 -0
  185. package/dist/gestures/UseHoverGesture.svelte.d.ts.map +1 -0
  186. package/{src → dist}/gestures/UsePanGesture.svelte +6 -5
  187. package/dist/gestures/UsePanGesture.svelte.d.ts +32 -0
  188. package/dist/gestures/UsePanGesture.svelte.d.ts.map +1 -0
  189. package/{src → dist}/gestures/UseTapGesture.svelte +6 -5
  190. package/dist/gestures/UseTapGesture.svelte.d.ts +31 -0
  191. package/dist/gestures/UseTapGesture.svelte.d.ts.map +1 -0
  192. package/{src → dist}/gestures/drag/UseDrag.svelte +5 -4
  193. package/dist/gestures/drag/UseDrag.svelte.d.ts +32 -0
  194. package/dist/gestures/drag/UseDrag.svelte.d.ts.map +1 -0
  195. package/dist/gestures/drag/UseDragControls.svelte +59 -0
  196. package/dist/gestures/drag/UseDragControls.svelte.d.ts +24 -0
  197. package/dist/gestures/drag/UseDragControls.svelte.d.ts.map +1 -0
  198. package/dist/gestures/drag/VisualElementDragControls.d.ts +116 -0
  199. package/dist/gestures/drag/VisualElementDragControls.d.ts.map +1 -0
  200. package/dist/gestures/drag/VisualElementDragControls.js +754 -0
  201. package/{src/gestures/drag/types.ts → dist/gestures/drag/types.d.ts} +309 -307
  202. package/dist/gestures/drag/types.d.ts.map +1 -0
  203. package/dist/gestures/drag/types.js +1 -0
  204. package/dist/gestures/drag/use-drag-controls.d.ts +130 -0
  205. package/dist/gestures/drag/use-drag-controls.d.ts.map +1 -0
  206. package/dist/gestures/drag/use-drag-controls.js +157 -0
  207. package/{src/gestures/drag/use-drag.ts → dist/gestures/drag/use-drag.d.ts} +13 -15
  208. package/dist/gestures/drag/use-drag.d.ts.map +1 -0
  209. package/dist/gestures/drag/use-drag.js +1 -0
  210. package/dist/gestures/drag/utils/constraints.d.ts +78 -0
  211. package/dist/gestures/drag/utils/constraints.d.ts.map +1 -0
  212. package/{src/gestures/drag/utils/constraints.ts → dist/gestures/drag/utils/constraints.js} +134 -157
  213. package/dist/gestures/drag/utils/lock.d.ts +14 -0
  214. package/dist/gestures/drag/utils/lock.d.ts.map +1 -0
  215. package/{src/gestures/drag/utils/lock.ts → dist/gestures/drag/utils/lock.js} +56 -69
  216. package/{src/gestures/types.ts → dist/gestures/types.d.ts} +258 -257
  217. package/dist/gestures/types.d.ts.map +1 -0
  218. package/dist/gestures/types.js +1 -0
  219. package/{src/gestures/use-focus-gesture.ts → dist/gestures/use-focus-gesture.d.ts} +14 -16
  220. package/dist/gestures/use-focus-gesture.d.ts.map +1 -0
  221. package/dist/gestures/use-focus-gesture.js +1 -0
  222. package/dist/gestures/use-gestures.d.ts +2 -0
  223. package/dist/gestures/use-gestures.d.ts.map +1 -0
  224. package/{src/gestures/use-gestures.ts → dist/gestures/use-gestures.js} +1 -2
  225. package/{src/gestures/use-hover-gesture.ts → dist/gestures/use-hover-gesture.d.ts} +8 -10
  226. package/dist/gestures/use-hover-gesture.d.ts.map +1 -0
  227. package/dist/gestures/use-hover-gesture.js +1 -0
  228. package/{src/gestures/use-pan-gesture.ts → dist/gestures/use-pan-gesture.d.ts} +20 -22
  229. package/dist/gestures/use-pan-gesture.d.ts.map +1 -0
  230. package/dist/gestures/use-pan-gesture.js +1 -0
  231. package/{src/gestures/use-tap-gesture.ts → dist/gestures/use-tap-gesture.d.ts} +12 -14
  232. package/dist/gestures/use-tap-gesture.d.ts.map +1 -0
  233. package/dist/gestures/use-tap-gesture.js +1 -0
  234. package/dist/gestures/utils/event-type.d.ts +12 -0
  235. package/dist/gestures/utils/event-type.d.ts.map +1 -0
  236. package/{src/gestures/utils/event-type.ts → dist/gestures/utils/event-type.js} +20 -24
  237. package/dist/gestures/utils/is-node-or-child.d.ts +18 -0
  238. package/dist/gestures/utils/is-node-or-child.d.ts.map +1 -0
  239. package/{src/gestures/utils/is-node-or-child.ts → dist/gestures/utils/is-node-or-child.js} +28 -31
  240. package/dist/index.d.ts +95 -0
  241. package/dist/index.d.ts.map +1 -0
  242. package/dist/index.js +77 -0
  243. package/{src → dist}/motion/Motion.svelte +83 -74
  244. package/dist/motion/Motion.svelte.d.ts +41 -0
  245. package/dist/motion/Motion.svelte.d.ts.map +1 -0
  246. package/{src → dist}/motion/MotionSSR.svelte +77 -56
  247. package/dist/motion/MotionSSR.svelte.d.ts +41 -0
  248. package/dist/motion/MotionSSR.svelte.d.ts.map +1 -0
  249. package/dist/motion/features/AnimationState.svelte.d.ts +22 -0
  250. package/dist/motion/features/AnimationState.svelte.d.ts.map +1 -0
  251. package/{src → dist}/motion/features/Exit.svelte +15 -5
  252. package/dist/motion/features/Exit.svelte.d.ts +32 -0
  253. package/dist/motion/features/Exit.svelte.d.ts.map +1 -0
  254. package/{src → dist}/motion/features/UseFeatures.svelte +2 -2
  255. package/dist/motion/features/UseFeatures.svelte.d.ts +45 -0
  256. package/dist/motion/features/UseFeatures.svelte.d.ts.map +1 -0
  257. package/dist/motion/features/animations.d.ts +11 -0
  258. package/dist/motion/features/animations.d.ts.map +1 -0
  259. package/{src/motion/features/animations.ts → dist/motion/features/animations.js} +14 -22
  260. package/dist/motion/features/definitions.d.ts +37 -0
  261. package/dist/motion/features/definitions.d.ts.map +1 -0
  262. package/{src/motion/features/definitions.ts → dist/motion/features/definitions.js} +42 -49
  263. package/dist/motion/features/drag.d.ts +11 -0
  264. package/dist/motion/features/drag.d.ts.map +1 -0
  265. package/{src/motion/features/drag.ts → dist/motion/features/drag.js} +14 -24
  266. package/dist/motion/features/gestures.d.ts +11 -0
  267. package/dist/motion/features/gestures.d.ts.map +1 -0
  268. package/{src/motion/features/gestures.ts → dist/motion/features/gestures.js} +16 -24
  269. package/dist/motion/features/layout/Animate.d.ts +2 -0
  270. package/dist/motion/features/layout/Animate.d.ts.map +1 -0
  271. package/dist/motion/features/layout/Animate.js +2 -0
  272. package/{src → dist}/motion/features/layout/Animate.svelte +25 -24
  273. package/dist/motion/features/layout/Animate.svelte.d.ts +23 -0
  274. package/dist/motion/features/layout/Animate.svelte.d.ts.map +1 -0
  275. package/dist/motion/features/layout/AnimateLayoutContextProvider.svelte.d.ts +23 -0
  276. package/dist/motion/features/layout/AnimateLayoutContextProvider.svelte.d.ts.map +1 -0
  277. package/dist/motion/features/layout/Measure.d.ts +2 -0
  278. package/dist/motion/features/layout/Measure.d.ts.map +1 -0
  279. package/dist/motion/features/layout/Measure.js +2 -0
  280. package/{src → dist}/motion/features/layout/Measure.svelte +8 -6
  281. package/dist/motion/features/layout/Measure.svelte.d.ts +24 -0
  282. package/dist/motion/features/layout/Measure.svelte.d.ts.map +1 -0
  283. package/{src → dist}/motion/features/layout/MeasureContextProvider.svelte +7 -4
  284. package/dist/motion/features/layout/MeasureContextProvider.svelte.d.ts +23 -0
  285. package/dist/motion/features/layout/MeasureContextProvider.svelte.d.ts.map +1 -0
  286. package/dist/motion/features/layout/index.d.ts +8 -0
  287. package/dist/motion/features/layout/index.d.ts.map +1 -0
  288. package/{src/motion/features/layout/index.ts → dist/motion/features/layout/index.js} +11 -20
  289. package/{src/motion/features/layout/types.ts → dist/motion/features/layout/types.d.ts} +72 -71
  290. package/dist/motion/features/layout/types.d.ts.map +1 -0
  291. package/dist/motion/features/layout/types.js +1 -0
  292. package/dist/motion/features/layout/utils.d.ts +26 -0
  293. package/dist/motion/features/layout/utils.d.ts.map +1 -0
  294. package/{src/motion/features/layout/utils.ts → dist/motion/features/layout/utils.js} +28 -40
  295. package/{src/motion/features/types.ts → dist/motion/features/types.d.ts} +55 -53
  296. package/dist/motion/features/types.d.ts.map +1 -0
  297. package/dist/motion/features/types.js +1 -0
  298. package/{src/motion/features/use-features.ts → dist/motion/features/use-features.d.ts} +12 -16
  299. package/dist/motion/features/use-features.d.ts.map +1 -0
  300. package/dist/motion/features/use-features.js +5 -0
  301. package/dist/motion/index.d.ts +30 -0
  302. package/dist/motion/index.d.ts.map +1 -0
  303. package/dist/motion/index.js +35 -0
  304. package/{src/motion/types.ts → dist/motion/types.d.ts} +281 -278
  305. package/dist/motion/types.d.ts.map +1 -0
  306. package/dist/motion/types.js +1 -0
  307. package/{src → dist}/motion/utils/UseLayoutId.svelte +3 -2
  308. package/dist/motion/utils/UseLayoutId.svelte.d.ts +35 -0
  309. package/dist/motion/utils/UseLayoutId.svelte.d.ts.map +1 -0
  310. package/{src → dist}/motion/utils/UseVisualElement.svelte +22 -13
  311. package/dist/motion/utils/UseVisualElement.svelte.d.ts +40 -0
  312. package/dist/motion/utils/UseVisualElement.svelte.d.ts.map +1 -0
  313. package/{src → dist}/motion/utils/UseVisualState.svelte +27 -27
  314. package/dist/motion/utils/UseVisualState.svelte.d.ts +37 -0
  315. package/dist/motion/utils/UseVisualState.svelte.d.ts.map +1 -0
  316. package/dist/motion/utils/is-forced-motion-value.d.ts +11 -0
  317. package/dist/motion/utils/is-forced-motion-value.d.ts.map +1 -0
  318. package/{src/motion/utils/is-forced-motion-value.ts → dist/motion/utils/is-forced-motion-value.js} +13 -23
  319. package/{src/motion/utils/make-renderless-component.ts → dist/motion/utils/make-renderless-component.d.ts} +12 -17
  320. package/dist/motion/utils/make-renderless-component.d.ts.map +1 -0
  321. package/dist/motion/utils/make-renderless-component.js +11 -0
  322. package/{src/motion/utils/should-inhert-variant.ts → dist/motion/utils/should-inhert-variant.d.ts} +7 -6
  323. package/dist/motion/utils/should-inhert-variant.d.ts.map +1 -0
  324. package/dist/motion/utils/should-inhert-variant.js +1 -0
  325. package/dist/motion/utils/use-motion-ref.d.ts +14 -0
  326. package/dist/motion/utils/use-motion-ref.d.ts.map +1 -0
  327. package/dist/motion/utils/use-motion-ref.js +27 -0
  328. package/dist/motion/utils/use-visual-element.d.ts +11 -0
  329. package/dist/motion/utils/use-visual-element.d.ts.map +1 -0
  330. package/dist/motion/utils/use-visual-element.js +1 -0
  331. package/{src/motion/utils/use-visual-state.ts → dist/motion/utils/use-visual-state.d.ts} +21 -24
  332. package/dist/motion/utils/use-visual-state.d.ts.map +1 -0
  333. package/dist/motion/utils/use-visual-state.js +2 -0
  334. package/dist/motion/utils/valid-prop.d.ts +15 -0
  335. package/dist/motion/utils/valid-prop.d.ts.map +1 -0
  336. package/{src/motion/utils/valid-prop.ts → dist/motion/utils/valid-prop.js} +77 -80
  337. package/dist/render/dom/M-type.spec-d.d.ts +2 -0
  338. package/dist/render/dom/M-type.spec-d.d.ts.map +1 -0
  339. package/dist/render/dom/M-type.spec-d.js +6 -0
  340. package/{src/render/dom/M.svelte → dist/render/dom/Motion-Proxy.svelte} +8 -1
  341. package/dist/render/dom/Motion-Proxy.svelte.d.ts +33 -0
  342. package/dist/render/dom/Motion-Proxy.svelte.d.ts.map +1 -0
  343. package/dist/render/dom/Motion-type.spec-d.d.ts +2 -0
  344. package/dist/render/dom/Motion-type.spec-d.d.ts.map +1 -0
  345. package/dist/render/dom/Motion-type.spec-d.js +6 -0
  346. package/{src → dist}/render/dom/UseRender.svelte +2 -2
  347. package/dist/render/dom/UseRender.svelte.d.ts +42 -0
  348. package/dist/render/dom/UseRender.svelte.d.ts.map +1 -0
  349. package/dist/render/dom/create-visual-element.d.ts +8 -0
  350. package/dist/render/dom/create-visual-element.d.ts.map +1 -0
  351. package/{src/render/dom/create-visual-element.ts → dist/render/dom/create-visual-element.js} +12 -22
  352. package/dist/render/dom/featureBundle.d.ts +24 -0
  353. package/dist/render/dom/featureBundle.d.ts.map +1 -0
  354. package/{src/render/dom/featureBundle.ts → dist/render/dom/featureBundle.js} +20 -22
  355. package/dist/render/dom/motion-minimal.d.ts +942 -0
  356. package/dist/render/dom/motion-minimal.d.ts.map +1 -0
  357. package/dist/render/dom/motion-minimal.js +22 -0
  358. package/dist/render/dom/motion-proxy.d.ts +63 -0
  359. package/dist/render/dom/motion-proxy.d.ts.map +1 -0
  360. package/dist/render/dom/motion-proxy.js +57 -0
  361. package/dist/render/dom/motion.d.ts +966 -0
  362. package/dist/render/dom/motion.d.ts.map +1 -0
  363. package/{src/render/dom/motion.ts → dist/render/dom/motion.js} +46 -62
  364. package/dist/render/dom/projection/convert-to-relative.d.ts +12 -0
  365. package/dist/render/dom/projection/convert-to-relative.d.ts.map +1 -0
  366. package/{src/render/dom/projection/convert-to-relative.ts → dist/render/dom/projection/convert-to-relative.js} +32 -40
  367. package/dist/render/dom/projection/default-scale-correctors.d.ts +40 -0
  368. package/dist/render/dom/projection/default-scale-correctors.d.ts.map +1 -0
  369. package/{src/render/dom/projection/default-scale-correctors.ts → dist/render/dom/projection/default-scale-correctors.js} +108 -138
  370. package/dist/render/dom/projection/measure.d.ts +17 -0
  371. package/dist/render/dom/projection/measure.d.ts.map +1 -0
  372. package/{src/render/dom/projection/measure.ts → dist/render/dom/projection/measure.js} +19 -28
  373. package/dist/render/dom/projection/relative-set.d.ts +8 -0
  374. package/dist/render/dom/projection/relative-set.d.ts.map +1 -0
  375. package/{src/render/dom/projection/relative-set.ts → dist/render/dom/projection/relative-set.js} +18 -27
  376. package/dist/render/dom/projection/scale-correction.d.ts +16 -0
  377. package/dist/render/dom/projection/scale-correction.d.ts.map +1 -0
  378. package/dist/render/dom/projection/scale-correction.js +15 -0
  379. package/{src/render/dom/projection/types.ts → dist/render/dom/projection/types.d.ts} +14 -13
  380. package/dist/render/dom/projection/types.d.ts.map +1 -0
  381. package/dist/render/dom/projection/types.js +1 -0
  382. package/dist/render/dom/projection/utils.d.ts +18 -0
  383. package/dist/render/dom/projection/utils.d.ts.map +1 -0
  384. package/{src/render/dom/projection/utils.ts → dist/render/dom/projection/utils.js} +62 -69
  385. package/dist/render/dom/svg-visual-element.d.ts +3 -0
  386. package/dist/render/dom/svg-visual-element.d.ts.map +1 -0
  387. package/{src/render/dom/svg-visual-element.ts → dist/render/dom/svg-visual-element.js} +91 -114
  388. package/{src/render/dom/types.ts → dist/render/dom/types.d.ts} +33 -32
  389. package/dist/render/dom/types.d.ts.map +1 -0
  390. package/dist/render/dom/types.js +1 -0
  391. package/dist/render/dom/use-render.d.ts +6 -0
  392. package/dist/render/dom/use-render.d.ts.map +1 -0
  393. package/dist/render/dom/use-render.js +5 -0
  394. package/{src → dist}/render/dom/utils/UseInitialMotionProps.svelte +14 -3
  395. package/dist/render/dom/utils/UseInitialMotionProps.svelte.d.ts +36 -0
  396. package/dist/render/dom/utils/UseInitialMotionProps.svelte.d.ts.map +1 -0
  397. package/dist/render/dom/utils/batch-layout.d.ts +14 -0
  398. package/dist/render/dom/utils/batch-layout.d.ts.map +1 -0
  399. package/{src/render/dom/utils/batch-layout.ts → dist/render/dom/utils/batch-layout.js} +67 -77
  400. package/dist/render/dom/utils/camel-to-dash.d.ts +10 -0
  401. package/dist/render/dom/utils/camel-to-dash.d.ts.map +1 -0
  402. package/{src/render/dom/utils/camel-to-dash.ts → dist/render/dom/utils/camel-to-dash.js} +17 -20
  403. package/dist/render/dom/utils/create-config.d.ts +7 -0
  404. package/dist/render/dom/utils/create-config.d.ts.map +1 -0
  405. package/dist/render/dom/utils/create-config.js +18 -0
  406. package/dist/render/dom/utils/css-variables-conversion.d.ts +28 -0
  407. package/dist/render/dom/utils/css-variables-conversion.d.ts.map +1 -0
  408. package/{src/render/dom/utils/css-variables-conversion.ts → dist/render/dom/utils/css-variables-conversion.js} +111 -121
  409. package/dist/render/dom/utils/filter-props.d.ts +8 -0
  410. package/dist/render/dom/utils/filter-props.d.ts.map +1 -0
  411. package/{src/render/dom/utils/filter-props.ts → dist/render/dom/utils/filter-props.js} +47 -55
  412. package/dist/render/dom/utils/is-css-variable.d.ts +14 -0
  413. package/dist/render/dom/utils/is-css-variable.d.ts.map +1 -0
  414. package/{src/render/dom/utils/is-css-variable.ts → dist/render/dom/utils/is-css-variable.js} +15 -18
  415. package/dist/render/dom/utils/is-svg-component.d.ts +8 -0
  416. package/dist/render/dom/utils/is-svg-component.d.ts.map +1 -0
  417. package/{src/render/dom/utils/is-svg-component.ts → dist/render/dom/utils/is-svg-component.js} +36 -41
  418. package/dist/render/dom/utils/parse-dom-variant.d.ts +12 -0
  419. package/dist/render/dom/utils/parse-dom-variant.d.ts.map +1 -0
  420. package/{src/render/dom/utils/parse-dom-variant.ts → dist/render/dom/utils/parse-dom-variant.js} +17 -26
  421. package/dist/render/dom/utils/unit-conversion.d.ts +27 -0
  422. package/dist/render/dom/utils/unit-conversion.d.ts.map +1 -0
  423. package/{src/render/dom/utils/unit-conversion.ts → dist/render/dom/utils/unit-conversion.js} +236 -258
  424. package/dist/render/dom/utils/use-html-props.d.ts +2 -0
  425. package/dist/render/dom/utils/use-html-props.d.ts.map +1 -0
  426. package/{src/render/dom/utils/use-html-props.ts → dist/render/dom/utils/use-html-props.js} +2 -2
  427. package/dist/render/dom/utils/use-svg-props.d.ts +2 -0
  428. package/dist/render/dom/utils/use-svg-props.d.ts.map +1 -0
  429. package/dist/render/dom/utils/use-svg-props.js +1 -0
  430. package/dist/render/dom/value-types/animatable-none.d.ts +7 -0
  431. package/dist/render/dom/value-types/animatable-none.d.ts.map +1 -0
  432. package/{src/render/dom/value-types/animatable-none.ts → dist/render/dom/value-types/animatable-none.js} +20 -24
  433. package/dist/render/dom/value-types/defaults.d.ts +15 -0
  434. package/dist/render/dom/value-types/defaults.d.ts.map +1 -0
  435. package/dist/render/dom/value-types/defaults.js +31 -0
  436. package/dist/render/dom/value-types/dimensions.d.ts +15 -0
  437. package/dist/render/dom/value-types/dimensions.d.ts.map +1 -0
  438. package/{src/render/dom/value-types/dimensions.ts → dist/render/dom/value-types/dimensions.js} +23 -27
  439. package/dist/render/dom/value-types/find.d.ts +15 -0
  440. package/dist/render/dom/value-types/find.d.ts.map +1 -0
  441. package/dist/render/dom/value-types/find.js +21 -0
  442. package/{src/render/dom/value-types/get-as-type.ts → dist/render/dom/value-types/get-as-type.d.ts} +15 -21
  443. package/dist/render/dom/value-types/get-as-type.d.ts.map +1 -0
  444. package/dist/render/dom/value-types/get-as-type.js +13 -0
  445. package/dist/render/dom/value-types/number.d.ts +8 -0
  446. package/dist/render/dom/value-types/number.d.ts.map +1 -0
  447. package/{src/render/dom/value-types/number.ts → dist/render/dom/value-types/number.js} +74 -83
  448. package/{src/render/dom/value-types/test.ts → dist/render/dom/value-types/test.d.ts} +15 -17
  449. package/dist/render/dom/value-types/test.d.ts.map +1 -0
  450. package/dist/render/dom/value-types/test.js +9 -0
  451. package/{src/render/dom/value-types/type-auto.ts → dist/render/dom/value-types/type-auto.d.ts} +15 -21
  452. package/dist/render/dom/value-types/type-auto.d.ts.map +1 -0
  453. package/dist/render/dom/value-types/type-auto.js +12 -0
  454. package/{src/render/dom/value-types/type-int.ts → dist/render/dom/value-types/type-int.d.ts} +14 -23
  455. package/dist/render/dom/value-types/type-int.d.ts.map +1 -0
  456. package/dist/render/dom/value-types/type-int.js +12 -0
  457. package/{src/render/dom/value-types/types.ts → dist/render/dom/value-types/types.d.ts} +9 -8
  458. package/dist/render/dom/value-types/types.d.ts.map +1 -0
  459. package/dist/render/dom/value-types/types.js +1 -0
  460. package/{src → dist}/render/html/UseHTMLProps.svelte +19 -2
  461. package/{src → dist}/render/html/UseInitialMotionValues.svelte +1 -1
  462. package/dist/render/html/UseInitialMotionValues.svelte.d.ts +36 -0
  463. package/dist/render/html/UseInitialMotionValues.svelte.d.ts.map +1 -0
  464. package/dist/render/html/UseStyle.svelte +32 -0
  465. package/dist/render/html/UseStyle.svelte.d.ts +36 -0
  466. package/dist/render/html/UseStyle.svelte.d.ts.map +1 -0
  467. package/dist/render/html/config-motion.d.ts +13 -0
  468. package/dist/render/html/config-motion.d.ts.map +1 -0
  469. package/dist/render/html/config-motion.js +13 -0
  470. package/dist/render/html/supported-elements.d.ts +12 -0
  471. package/dist/render/html/supported-elements.d.ts.map +1 -0
  472. package/{src/render/html/supported-elements.ts → dist/render/html/supported-elements.js} +4 -10
  473. package/{src/render/html/types.ts → dist/render/html/types.d.ts} +54 -64
  474. package/dist/render/html/types.d.ts.map +1 -0
  475. package/dist/render/html/types.js +1 -0
  476. package/dist/render/html/use-props.d.ts +11 -0
  477. package/dist/render/html/use-props.d.ts.map +1 -0
  478. package/dist/render/html/use-props.js +15 -0
  479. package/dist/render/html/utils/build-projection-transform.d.ts +21 -0
  480. package/dist/render/html/utils/build-projection-transform.d.ts.map +1 -0
  481. package/{src/render/html/utils/build-projection-transform.ts → dist/render/html/utils/build-projection-transform.js} +39 -53
  482. package/dist/render/html/utils/build-styles.d.ts +13 -0
  483. package/dist/render/html/utils/build-styles.d.ts.map +1 -0
  484. package/{src/render/html/utils/build-styles.ts → dist/render/html/utils/build-styles.js} +108 -121
  485. package/dist/render/html/utils/build-transform.d.ts +21 -0
  486. package/dist/render/html/utils/build-transform.d.ts.map +1 -0
  487. package/{src/render/html/utils/build-transform.ts → dist/render/html/utils/build-transform.js} +70 -79
  488. package/dist/render/html/utils/create-render-state.d.ts +17 -0
  489. package/dist/render/html/utils/create-render-state.d.ts.map +1 -0
  490. package/dist/render/html/utils/create-render-state.js +18 -0
  491. package/dist/render/html/utils/render.d.ts +12 -0
  492. package/dist/render/html/utils/render.d.ts.map +1 -0
  493. package/{src/render/html/utils/render.ts → dist/render/html/utils/render.js} +15 -22
  494. package/dist/render/html/utils/scrape-motion-values.d.ts +8 -0
  495. package/dist/render/html/utils/scrape-motion-values.d.ts.map +1 -0
  496. package/{src/render/html/utils/scrape-motion-values.ts → dist/render/html/utils/scrape-motion-values.js} +19 -26
  497. package/dist/render/html/utils/transform.d.ts +25 -0
  498. package/dist/render/html/utils/transform.d.ts.map +1 -0
  499. package/{src/render/html/utils/transform.ts → dist/render/html/utils/transform.js} +48 -51
  500. package/dist/render/html/visual-element.d.ts +2312 -0
  501. package/dist/render/html/visual-element.d.ts.map +1 -0
  502. package/{src/render/html/visual-element.ts → dist/render/html/visual-element.js} +111 -129
  503. package/dist/render/index.d.ts +8 -0
  504. package/dist/render/index.d.ts.map +1 -0
  505. package/{src/render/index.ts → dist/render/index.js} +771 -703
  506. package/{src → dist}/render/svg/UseSVGProps.svelte +2 -2
  507. package/dist/render/svg/UseSVGProps.svelte.d.ts +39 -0
  508. package/dist/render/svg/UseSVGProps.svelte.d.ts.map +1 -0
  509. package/dist/render/svg/config-motion.d.ts +24 -0
  510. package/dist/render/svg/config-motion.d.ts.map +1 -0
  511. package/dist/render/svg/config-motion.js +44 -0
  512. package/dist/render/svg/lowercase-elements.d.ts +10 -0
  513. package/dist/render/svg/lowercase-elements.d.ts.map +1 -0
  514. package/{src/render/svg/lowercase-elements.ts → dist/render/svg/lowercase-elements.js} +35 -35
  515. package/dist/render/svg/supported-elements.d.ts +12 -0
  516. package/dist/render/svg/supported-elements.d.ts.map +1 -0
  517. package/{src/render/svg/supported-elements.ts → dist/render/svg/supported-elements.js} +4 -10
  518. package/dist/render/svg/types.d.ts +39 -0
  519. package/dist/render/svg/types.d.ts.map +1 -0
  520. package/dist/render/svg/types.js +1 -0
  521. package/{src/render/svg/use-props.ts → dist/render/svg/use-props.d.ts} +13 -14
  522. package/dist/render/svg/use-props.d.ts.map +1 -0
  523. package/dist/render/svg/use-props.js +1 -0
  524. package/dist/render/svg/utils/build-attrs.d.ts +16 -0
  525. package/dist/render/svg/utils/build-attrs.d.ts.map +1 -0
  526. package/dist/render/svg/utils/build-attrs.js +40 -0
  527. package/dist/render/svg/utils/camel-case-attrs.d.ts +9 -0
  528. package/dist/render/svg/utils/camel-case-attrs.d.ts.map +1 -0
  529. package/{src/render/svg/utils/camel-case-attrs.ts → dist/render/svg/utils/camel-case-attrs.js} +27 -27
  530. package/dist/render/svg/utils/create-render-state.d.ts +11 -0
  531. package/dist/render/svg/utils/create-render-state.d.ts.map +1 -0
  532. package/dist/render/svg/utils/create-render-state.js +7 -0
  533. package/dist/render/svg/utils/path.d.ts +15 -0
  534. package/dist/render/svg/utils/path.d.ts.map +1 -0
  535. package/{src/render/svg/utils/path.ts → dist/render/svg/utils/path.js} +46 -49
  536. package/dist/render/svg/utils/render.d.ts +8 -0
  537. package/dist/render/svg/utils/render.d.ts.map +1 -0
  538. package/{src/render/svg/utils/render.ts → dist/render/svg/utils/render.js} +14 -22
  539. package/dist/render/svg/utils/scrape-motion-values.d.ts +8 -0
  540. package/dist/render/svg/utils/scrape-motion-values.d.ts.map +1 -0
  541. package/{src/render/svg/utils/scrape-motion-values.ts → dist/render/svg/utils/scrape-motion-values.js} +19 -26
  542. package/dist/render/svg/utils/transform-origin.d.ts +12 -0
  543. package/dist/render/svg/utils/transform-origin.d.ts.map +1 -0
  544. package/{src/render/svg/utils/transform-origin.ts → dist/render/svg/utils/transform-origin.js} +21 -30
  545. package/dist/render/svg/visual-element.d.ts +7 -0
  546. package/dist/render/svg/visual-element.d.ts.map +1 -0
  547. package/{src/render/svg/visual-element.ts → dist/render/svg/visual-element.js} +38 -44
  548. package/{src/render/types.ts → dist/render/types.d.ts} +149 -148
  549. package/dist/render/types.d.ts.map +1 -0
  550. package/dist/render/types.js +1 -0
  551. package/dist/render/utils/animation-state.d.ts +43 -0
  552. package/dist/render/utils/animation-state.d.ts.map +1 -0
  553. package/{src/render/utils/animation-state.ts → dist/render/utils/animation-state.js} +338 -375
  554. package/dist/render/utils/animation.d.ts +27 -0
  555. package/dist/render/utils/animation.d.ts.map +1 -0
  556. package/{src/render/utils/animation.ts → dist/render/utils/animation.js} +145 -167
  557. package/{src/render/utils/compare-by-depth.ts → dist/render/utils/compare-by-depth.d.ts} +15 -18
  558. package/dist/render/utils/compare-by-depth.d.ts.map +1 -0
  559. package/dist/render/utils/compare-by-depth.js +8 -0
  560. package/dist/render/utils/flat-tree.d.ts +14 -0
  561. package/dist/render/utils/flat-tree.d.ts.map +1 -0
  562. package/dist/render/utils/flat-tree.js +53 -0
  563. package/{src/render/utils/is-draggable.ts → dist/render/utils/is-draggable.d.ts} +12 -17
  564. package/dist/render/utils/is-draggable.d.ts.map +1 -0
  565. package/dist/render/utils/is-draggable.js +9 -0
  566. package/{src/render/utils/lifecycles.ts → dist/render/utils/lifecycles.d.ts} +122 -172
  567. package/dist/render/utils/lifecycles.d.ts.map +1 -0
  568. package/dist/render/utils/lifecycles.js +44 -0
  569. package/dist/render/utils/motion-values.d.ts +9 -0
  570. package/dist/render/utils/motion-values.d.ts.map +1 -0
  571. package/{src/render/utils/motion-values.ts → dist/render/utils/motion-values.js} +50 -59
  572. package/dist/render/utils/projection.d.ts +9 -0
  573. package/dist/render/utils/projection.d.ts.map +1 -0
  574. package/{src/render/utils/projection.ts → dist/render/utils/projection.js} +29 -38
  575. package/dist/render/utils/setters.d.ts +794 -0
  576. package/dist/render/utils/setters.d.ts.map +1 -0
  577. package/dist/render/utils/setters.js +128 -0
  578. package/{src/render/utils/state.ts → dist/render/utils/state.d.ts} +90 -113
  579. package/dist/render/utils/state.d.ts.map +1 -0
  580. package/dist/render/utils/state.js +26 -0
  581. package/{src/render/utils/types.ts → dist/render/utils/types.d.ts} +13 -12
  582. package/dist/render/utils/types.d.ts.map +1 -0
  583. package/dist/render/utils/types.js +13 -0
  584. package/dist/render/utils/variants.d.ts +27 -0
  585. package/dist/render/utils/variants.d.ts.map +1 -0
  586. package/{src/render/utils/variants.ts → dist/render/utils/variants.js} +66 -76
  587. package/{src/types/geometry.ts → dist/types/geometry.d.ts} +93 -91
  588. package/dist/types/geometry.d.ts.map +1 -0
  589. package/dist/types/geometry.js +1 -0
  590. package/{src/types.ts → dist/types.d.ts} +1091 -1088
  591. package/dist/types.d.ts.map +1 -0
  592. package/dist/types.js +1 -0
  593. package/dist/utils/UseUnmountEffect.svelte.d.ts +30 -0
  594. package/dist/utils/UseUnmountEffect.svelte.d.ts.map +1 -0
  595. package/dist/utils/array.d.ts +12 -0
  596. package/dist/utils/array.d.ts.map +1 -0
  597. package/{src/utils/array.ts → dist/utils/array.js} +16 -18
  598. package/dist/utils/each-axis.d.ts +11 -0
  599. package/dist/utils/each-axis.d.ts.map +1 -0
  600. package/{src/utils/each-axis.ts → dist/utils/each-axis.js} +13 -15
  601. package/dist/utils/errors.d.ts +5 -0
  602. package/dist/utils/errors.d.ts.map +1 -0
  603. package/dist/utils/errors.js +16 -0
  604. package/dist/utils/fix-process-env.d.ts +2 -0
  605. package/dist/utils/fix-process-env.d.ts.map +1 -0
  606. package/dist/utils/fix-process-env.js +19 -0
  607. package/dist/utils/geometry/delta-apply.d.ts +71 -0
  608. package/dist/utils/geometry/delta-apply.d.ts.map +1 -0
  609. package/{src/utils/geometry/delta-apply.ts → dist/utils/geometry/delta-apply.js} +162 -162
  610. package/dist/utils/geometry/delta-calc.d.ts +34 -0
  611. package/dist/utils/geometry/delta-calc.d.ts.map +1 -0
  612. package/{src/utils/geometry/delta-calc.ts → dist/utils/geometry/delta-calc.js} +84 -89
  613. package/dist/utils/geometry/index.d.ts +30 -0
  614. package/dist/utils/geometry/index.d.ts.map +1 -0
  615. package/{src/utils/geometry/index.ts → dist/utils/geometry/index.js} +70 -83
  616. package/dist/utils/is-browser.d.ts +11 -0
  617. package/dist/utils/is-browser.d.ts.map +1 -0
  618. package/{src/utils/is-browser.ts → dist/utils/is-browser.js} +10 -12
  619. package/dist/utils/is-numerical-string.d.ts +14 -0
  620. package/dist/utils/is-numerical-string.d.ts.map +1 -0
  621. package/{src/utils/is-numerical-string.ts → dist/utils/is-numerical-string.js} +13 -15
  622. package/dist/utils/is-ref-object.d.ts +13 -0
  623. package/dist/utils/is-ref-object.d.ts.map +1 -0
  624. package/dist/utils/is-ref-object.js +12 -0
  625. package/dist/utils/noop.d.ts +11 -0
  626. package/dist/utils/noop.d.ts.map +1 -0
  627. package/{src/utils/noop.ts → dist/utils/noop.js} +13 -15
  628. package/dist/utils/resolve-value.d.ts +9 -0
  629. package/dist/utils/resolve-value.d.ts.map +1 -0
  630. package/{src/utils/resolve-value.ts → dist/utils/resolve-value.js} +15 -23
  631. package/dist/utils/shallow-compare.d.ts +11 -0
  632. package/dist/utils/shallow-compare.d.ts.map +1 -0
  633. package/{src/utils/shallow-compare.ts → dist/utils/shallow-compare.js} +21 -23
  634. package/dist/utils/subscription-manager.d.ts +14 -0
  635. package/dist/utils/subscription-manager.d.ts.map +1 -0
  636. package/dist/utils/subscription-manager.js +69 -0
  637. package/dist/utils/time-conversion.d.ts +17 -0
  638. package/dist/utils/time-conversion.d.ts.map +1 -0
  639. package/{src/utils/time-conversion.ts → dist/utils/time-conversion.js} +16 -18
  640. package/{src/utils/transform.ts → dist/utils/transform.d.ts} +93 -120
  641. package/dist/utils/transform.d.ts.map +1 -0
  642. package/dist/utils/transform.js +23 -0
  643. package/dist/utils/use-cycle.d.ts +2 -0
  644. package/dist/utils/use-cycle.d.ts.map +1 -0
  645. package/{src/utils/use-cycle.ts → dist/utils/use-cycle.js} +65 -78
  646. package/dist/utils/use-force-update.d.ts +6 -0
  647. package/dist/utils/use-force-update.d.ts.map +1 -0
  648. package/dist/utils/use-force-update.js +2 -0
  649. package/dist/utils/use-reduced-motion.d.ts +33 -0
  650. package/dist/utils/use-reduced-motion.d.ts.map +1 -0
  651. package/{src/utils/use-reduced-motion.ts → dist/utils/use-reduced-motion.js} +52 -70
  652. package/{src/utils/use-unmount-effect.ts → dist/utils/use-unmount-effect.d.ts} +7 -8
  653. package/dist/utils/use-unmount-effect.d.ts.map +1 -0
  654. package/dist/utils/use-unmount-effect.js +1 -0
  655. package/{src/value/index.ts → dist/value/index.d.ts} +273 -409
  656. package/dist/value/index.d.ts.map +1 -0
  657. package/dist/value/index.js +546 -0
  658. package/dist/value/scroll/use-element-scroll.d.ts +9 -0
  659. package/dist/value/scroll/use-element-scroll.d.ts.map +1 -0
  660. package/dist/value/scroll/use-element-scroll.js +39 -0
  661. package/dist/value/scroll/use-viewport-scroll.d.ts +29 -0
  662. package/dist/value/scroll/use-viewport-scroll.d.ts.map +1 -0
  663. package/{src/value/scroll/use-viewport-scroll.ts → dist/value/scroll/use-viewport-scroll.js} +59 -81
  664. package/dist/value/scroll/utils.d.ts +25 -0
  665. package/dist/value/scroll/utils.d.ts.map +1 -0
  666. package/dist/value/scroll/utils.js +48 -0
  667. package/dist/value/use-combine-values.d.ts +9 -0
  668. package/dist/value/use-combine-values.d.ts.map +1 -0
  669. package/dist/value/use-combine-values.js +41 -0
  670. package/dist/value/use-motion-template.d.ts +31 -0
  671. package/dist/value/use-motion-template.d.ts.map +1 -0
  672. package/{src/value/use-motion-template.ts → dist/value/use-motion-template.js} +51 -57
  673. package/dist/value/use-motion-value.d.ts +27 -0
  674. package/dist/value/use-motion-value.d.ts.map +1 -0
  675. package/{src/value/use-motion-value.ts → dist/value/use-motion-value.js} +27 -27
  676. package/dist/value/use-spring.d.ts +29 -0
  677. package/dist/value/use-spring.d.ts.map +1 -0
  678. package/{src/value/use-spring.ts → dist/value/use-spring.js} +64 -84
  679. package/dist/value/use-transform.d.ts +87 -0
  680. package/dist/value/use-transform.d.ts.map +1 -0
  681. package/dist/value/use-transform.js +78 -0
  682. package/dist/value/use-velocity.d.ts +20 -0
  683. package/dist/value/use-velocity.d.ts.map +1 -0
  684. package/{src/value/use-velocity.ts → dist/value/use-velocity.js} +34 -44
  685. package/dist/value/utils/is-motion-value.d.ts +12 -0
  686. package/dist/value/utils/is-motion-value.d.ts.map +1 -0
  687. package/dist/value/utils/is-motion-value.js +8 -0
  688. package/dist/value/utils/resolve-motion-value.d.ts +16 -0
  689. package/dist/value/utils/resolve-motion-value.d.ts.map +1 -0
  690. package/{src/value/utils/resolve-motion-value.ts → dist/value/utils/resolve-motion-value.js} +25 -29
  691. package/package.json +58 -27
  692. package/src/animation/use-animated-state.ts +0 -1
  693. package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +0 -47
  694. package/src/context/DOMcontext.ts +0 -21
  695. package/src/context/LayoutGroupContext.ts +0 -13
  696. package/src/context/LazyContext.ts +0 -18
  697. package/src/context/MotionContext/MotionContext.svelte +0 -27
  698. package/src/context/MotionContext/UseCreateMotionContext.svelte +0 -34
  699. package/src/context/MotionContext/index.ts +0 -14
  700. package/src/context/SharedLayoutContext.ts +0 -29
  701. package/src/events/UsePointerEvent.svelte +0 -76
  702. package/src/events/use-pointer-event.ts +0 -29
  703. package/src/gestures/PanSession.ts +0 -298
  704. package/src/gestures/drag/UseDragControls.svelte +0 -145
  705. package/src/gestures/drag/VisualElementDragControls.ts +0 -632
  706. package/src/gestures/drag/use-drag-controls.ts +0 -148
  707. package/src/index.ts +0 -104
  708. package/src/motion/features/layout/Animate.ts +0 -9
  709. package/src/motion/features/layout/Measure.ts +0 -9
  710. package/src/motion/index.ts +0 -64
  711. package/src/motion/utils/use-motion-ref.ts +0 -41
  712. package/src/motion/utils/use-visual-element.ts +0 -13
  713. package/src/render/dom/create-motion-class.ts +0 -12
  714. package/src/render/dom/motion-minimal.ts +0 -22
  715. package/src/render/dom/motion-proxy.ts +0 -107
  716. package/src/render/dom/projection/scale-correction.ts +0 -22
  717. package/src/render/dom/use-render.ts +0 -11
  718. package/src/render/dom/utils/create-config.ts +0 -33
  719. package/src/render/dom/utils/use-svg-props.ts +0 -1
  720. package/src/render/dom/value-types/defaults.ts +0 -30
  721. package/src/render/dom/value-types/find.ts +0 -31
  722. package/src/render/html/UseStyle.svelte +0 -47
  723. package/src/render/html/config-motion.ts +0 -23
  724. package/src/render/html/use-props.ts +0 -14
  725. package/src/render/html/utils/create-render-state.ts +0 -18
  726. package/src/render/svg/config-motion.ts +0 -51
  727. package/src/render/svg/types.ts +0 -51
  728. package/src/render/svg/utils/build-attrs.ts +0 -58
  729. package/src/render/svg/utils/create-render-state.ts +0 -17
  730. package/src/render/utils/flat-tree.ts +0 -35
  731. package/src/render/utils/setters.ts +0 -910
  732. package/src/utils/errors.ts +0 -22
  733. package/src/utils/fix-process-env.ts +0 -22
  734. package/src/utils/is-ref-object.ts +0 -16
  735. package/src/utils/subscription-manager.ts +0 -49
  736. package/src/utils/use-constant.ts +0 -23
  737. package/src/utils/use-force-update.ts +0 -7
  738. package/src/utils/use-isomorphic-effect.ts +0 -8
  739. package/src/value/scroll/use-element-scroll.ts +0 -73
  740. package/src/value/scroll/utils.ts +0 -76
  741. package/src/value/use-combine-values.ts +0 -53
  742. package/src/value/use-transform.ts +0 -216
  743. package/src/value/utils/is-motion-value.ts +0 -15
  744. /package/{src → dist}/animation/UseAnimation.svelte +0 -0
  745. /package/{src → dist}/components/MotionDiv.svelte +0 -0
  746. /package/{src → dist}/context/MotionContext/MotionContextProvider.svelte +0 -0
  747. /package/{src → dist}/gestures/UseFocusGesture.svelte +0 -0
  748. /package/{src → dist}/gestures/UseGestures.svelte +0 -0
  749. /package/{src → dist}/motion/features/AnimationState.svelte +0 -0
  750. /package/{src → dist}/motion/features/layout/AnimateLayoutContextProvider.svelte +0 -0
  751. /package/{src → dist}/utils/UseUnmountEffect.svelte +0 -0
@@ -1,703 +1,771 @@
1
- /**
2
- based on framer-motion@4.1.17,
3
- Copyright (c) 2018 Framer B.V.
4
- */
5
- import type { VisualElement, VisualElementConfig, VisualElementOptions } from "./types";
6
-
7
- /**
8
- based on framer-motion@4.1.1,
9
- Copyright (c) 2018 Framer B.V.
10
- */
11
- import sync, { cancelSync } from 'framesync';
12
- import { pipe } from 'popmotion';
13
- import { __assign, __read, __spreadArray } from 'tslib';
14
- import { Presence } from '../components/AnimateSharedLayout/types.js';
15
- import { eachAxis } from '../utils/each-axis.js';
16
- import { applyBoxTransforms, removeBoxTransforms } from '../utils/geometry/delta-apply.js';
17
- import { calcRelativeBox, updateBoxDelta } from '../utils/geometry/delta-calc.js';
18
- import { axisBox } from '../utils/geometry/index.js';
19
- import { motionValue } from '../value/index.js';
20
- import { isMotionValue } from '../value/utils/is-motion-value.js';
21
- import { setCurrentViewportBox } from './dom/projection/relative-set.js';
22
- import { buildLayoutProjectionTransform } from './html/utils/build-projection-transform.js';
23
- import { variantPriorityOrder } from './utils/animation-state.js';
24
- import { FlatTree } from './utils/flat-tree.js';
25
- import { isDraggable } from './utils/is-draggable.js';
26
- import { createLifecycles } from './utils/lifecycles.js';
27
- import { updateMotionValuesFromProps } from './utils/motion-values.js';
28
- import { updateLayoutDeltas } from './utils/projection.js';
29
- import { createLayoutState, createProjectionState } from './utils/state.js';
30
- import { checkIfControllingVariants, checkIfVariantNode, isVariantLabel } from './utils/variants.js';
31
-
32
- // TODO: make abstract class - future plans to match latest FramerMotion
33
- var visualElement = function <Instance = any, MutableState = any, Options extends {} = {}>({ treeType, build, getBaseTarget, makeTargetAnimatable, measureViewportBox, render: renderInstance, readValueFromInstance, resetTransform, restoreTransform, removeValueFromRenderState, sortNodePosition, scrapeMotionValuesFromProps, }: VisualElementConfig<Instance, MutableState, Options>) {
34
- return function ({ parent, props, presenceId, blockInitialAnimation, visualState, }: VisualElementOptions<Instance, any>, options?: Options) {
35
- if (options === void 0) { options = <Options>{}; }
36
- var latestValues = visualState.latestValues, renderState = visualState.renderState;
37
- /**
38
- * The instance of the render-specific node that will be hydrated by the
39
- * exposed React ref. So for example, this visual element can host a
40
- * HTMLElement, plain object, or Three.js object. The functions provided
41
- * in VisualElementConfig allow us to interface with this instance.
42
- */
43
- var instance;
44
- /**
45
- * Manages the subscriptions for a visual element's lifecycle, for instance
46
- * onRender and onViewportBoxUpdate.
47
- */
48
- var lifecycles = createLifecycles();
49
- /**
50
- *
51
- */
52
- var projection = createProjectionState();
53
- /**
54
- * A reference to the nearest projecting parent. This is either
55
- * undefined if we haven't looked for the nearest projecting parent,
56
- * false if there is no parent performing layout projection, or a reference
57
- * to the projecting parent.
58
- */
59
- var projectionParent;
60
- /**
61
- * This is a reference to the visual state of the "lead" visual element.
62
- * Usually, this will be this visual element. But if it shares a layoutId
63
- * with other visual elements, only one of them will be designated lead by
64
- * AnimateSharedLayout. All the other visual elements will take on the visual
65
- * appearance of the lead while they crossfade to it.
66
- */
67
- var leadProjection = projection;
68
- var leadLatestValues = latestValues;
69
- var unsubscribeFromLeadVisualElement;
70
- /**
71
- * The latest layout measurements and calculated projections. This
72
- * is seperate from the target projection data in visualState as
73
- * many visual elements might point to the same piece of visualState as
74
- * a target, whereas they might each have different layouts and thus
75
- * projection calculations needed to project into the same viewport box.
76
- */
77
- var layoutState = createLayoutState();
78
- /**
79
- *
80
- */
81
- var crossfader;
82
- /**
83
- * Keep track of whether the viewport box has been updated since the
84
- * last time the layout projection was re-calculated.
85
- */
86
- var hasViewportBoxUpdated = false;
87
- /**
88
- * A map of all motion values attached to this visual element. Motion
89
- * values are source of truth for any given animated value. A motion
90
- * value might be provided externally by the component via props.
91
- */
92
- var values = new Map();
93
- /**
94
- * A map of every subscription that binds the provided or generated
95
- * motion values onChange listeners to this visual element.
96
- */
97
- var valueSubscriptions = new Map();
98
- /**
99
- * A reference to the previously-provided motion values as returned
100
- * from scrapeMotionValuesFromProps. We use the keys in here to determine
101
- * if any motion values need to be removed after props are updated.
102
- */
103
- var prevMotionValues = {};
104
- /**
105
- * x/y motion values that track the progress of initiated layout
106
- * animations.
107
- *
108
- * TODO: Target for removal
109
- */
110
- var projectionTargetProgress;
111
- /**
112
- * When values are removed from all animation props we need to search
113
- * for a fallback value to animate to. These values are tracked in baseTarget.
114
- */
115
- var baseTarget = __assign({}, latestValues);
116
- // Internal methods ========================
117
- /**
118
- * On mount, this will be hydrated with a callback to disconnect
119
- * this visual element from its parent on unmount.
120
- */
121
- var removeFromVariantTree;
122
- /**
123
- *
124
- */
125
- function render() {
126
- if (!instance)
127
- return;
128
- if (element.isProjectionReady()) {
129
- /**
130
- * Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
131
- * This is the final box that we will then project into by calculating a transform delta and
132
- * applying it to the corrected box.
133
- */
134
- applyBoxTransforms(leadProjection.targetFinal, leadProjection.target, leadLatestValues);
135
- /**
136
- * Update the delta between the corrected box and the final target box, after
137
- * user-set transforms are applied to it. This will be used by the renderer to
138
- * create a transform style that will reproject the element from its actual layout
139
- * into the desired bounding box.
140
- */
141
- updateBoxDelta(layoutState.deltaFinal, layoutState.layoutCorrected, leadProjection.targetFinal, latestValues);
142
- }
143
- triggerBuild();
144
- renderInstance(instance, renderState);
145
- }
146
- function triggerBuild() {
147
- var valuesToRender = latestValues;
148
- if (crossfader && crossfader.isActive()) {
149
- var crossfadedValues = crossfader.getCrossfadeState(element);
150
- if (crossfadedValues)
151
- valuesToRender = crossfadedValues;
152
- }
153
- build(element, renderState, valuesToRender, leadProjection, layoutState, options, props);
154
- }
155
- function update() {
156
- lifecycles.notifyUpdate(latestValues);
157
- }
158
- function updateLayoutProjection() {
159
- if (!element.isProjectionReady())
160
- return;
161
- var delta = layoutState.delta, treeScale = layoutState.treeScale;
162
- var prevTreeScaleX = treeScale.x;
163
- var prevTreeScaleY = treeScale.y;
164
- var prevDeltaTransform = layoutState.deltaTransform;
165
- updateLayoutDeltas(layoutState, leadProjection, element.path, latestValues);
166
- hasViewportBoxUpdated &&
167
- element.notifyViewportBoxUpdate(leadProjection.target, delta);
168
- hasViewportBoxUpdated = false;
169
- var deltaTransform = buildLayoutProjectionTransform(delta, treeScale);
170
- if (deltaTransform !== prevDeltaTransform ||
171
- // Also compare calculated treeScale, for values that rely on this only for scale correction
172
- prevTreeScaleX !== treeScale.x ||
173
- prevTreeScaleY !== treeScale.y) {
174
- element.scheduleRender();
175
- }
176
- layoutState.deltaTransform = deltaTransform;
177
- }
178
- function updateTreeLayoutProjection() {
179
- element.layoutTree.forEach(fireUpdateLayoutProjection);
180
- }
181
- /**
182
- *
183
- */
184
- function bindToMotionValue(key, value) {
185
- var removeOnChange = value.onChange(function (latestValue) {
186
- latestValues[key] = latestValue;
187
- props.onUpdate && sync.update(update, false, true);
188
- });
189
- var removeOnRenderRequest = value.onRenderRequest(element.scheduleRender);
190
- valueSubscriptions.set(key, function () {
191
- removeOnChange();
192
- removeOnRenderRequest();
193
- });
194
- }
195
- /**
196
- * Any motion values that are provided to the element when created
197
- * aren't yet bound to the element, as this would technically be impure.
198
- * However, we iterate through the motion values and set them to the
199
- * initial values for this component.
200
- *
201
- * TODO: This is impure and we should look at changing this to run on mount.
202
- * Doing so will break some tests but this isn't neccessarily a breaking change,
203
- * more a reflection of the test.
204
- */
205
- var initialMotionValues = scrapeMotionValuesFromProps(props);
206
- for (var key in initialMotionValues) {
207
- var value = initialMotionValues[key];
208
- if (latestValues[key] !== undefined && isMotionValue(value)) {
209
- value.set(latestValues[key], false);
210
- }
211
- }
212
- /**
213
- * Determine what role this visual element should take in the variant tree.
214
- */
215
- var isControllingVariants = checkIfControllingVariants(props);
216
- var isVariantNode = checkIfVariantNode(props);
217
- var element: VisualElement<Instance, any> = __assign(__assign({ treeType: treeType,
218
- /**
219
- * This is a mirror of the internal instance prop, which keeps
220
- * VisualElement type-compatible with React's RefObject.
221
- */
222
- current: null,
223
- /**
224
- * The depth of this visual element within the visual element tree.
225
- */
226
- depth: parent ? parent.depth + 1 : 0, parent: parent, children: new Set(),
227
- /**
228
- * An ancestor path back to the root visual element. This is used
229
- * by layout projection to quickly recurse back up the tree.
230
- */
231
- path: parent ? __spreadArray(__spreadArray([], __read(parent.path)), [parent]) : [], layoutTree: parent ? parent.layoutTree : new FlatTree(),
232
- /**
233
- *
234
- */
235
- presenceId: presenceId,
236
- projection: projection,
237
- /**
238
- * If this component is part of the variant tree, it should track
239
- * any children that are also part of the tree. This is essentially
240
- * a shadow tree to simplify logic around how to stagger over children.
241
- */
242
- variantChildren: isVariantNode ? new Set() : undefined,
243
- /**
244
- * Whether this instance is visible. This can be changed imperatively
245
- * by AnimateSharedLayout, is analogous to CSS's visibility in that
246
- * hidden elements should take up layout, and needs enacting by the configured
247
- * render function.
248
- */
249
- isVisible: undefined,
250
- /**
251
- * Normally, if a component is controlled by a parent's variants, it can
252
- * rely on that ancestor to trigger animations further down the tree.
253
- * However, if a component is created after its parent is mounted, the parent
254
- * won't trigger that mount animation so the child needs to.
255
- *
256
- * TODO: This might be better replaced with a method isParentMounted
257
- */
258
- manuallyAnimateOnMount: Boolean(parent === null || parent === void 0 ? void 0 : parent.isMounted()),
259
- /**
260
- * This can be set by AnimatePresence to force components that mount
261
- * at the same time as it to mount as if they have initial={false} set.
262
- */
263
- blockInitialAnimation: blockInitialAnimation,
264
- /**
265
- * Determine whether this component has mounted yet. This is mostly used
266
- * by variant children to determine whether they need to trigger their
267
- * own animations on mount.
268
- */
269
- isMounted: function () { return Boolean(instance); }, mount: function (newInstance) {
270
- instance = element.current = newInstance;
271
- element.pointTo(element);
272
- if (isVariantNode && parent && !isControllingVariants) {
273
- removeFromVariantTree = parent === null || parent === void 0 ? void 0 : parent.addVariantChild(element);
274
- }
275
- parent === null || parent === void 0 ? void 0 : parent.children.add(element);
276
- },
277
- /**
278
- *
279
- */
280
- unmount: function () {
281
- cancelSync.update(update);
282
- cancelSync.render(render);
283
- cancelSync.preRender(element.updateLayoutProjection);
284
- valueSubscriptions.forEach(function (remove) { return remove(); });
285
- element.stopLayoutAnimation();
286
- element.layoutTree.remove(element);
287
- removeFromVariantTree === null || removeFromVariantTree === void 0 ? void 0 : removeFromVariantTree();
288
- parent === null || parent === void 0 ? void 0 : parent.children.delete(element);
289
- unsubscribeFromLeadVisualElement === null || unsubscribeFromLeadVisualElement === void 0 ? void 0 : unsubscribeFromLeadVisualElement();
290
- lifecycles.clearAllListeners();
291
- },
292
- /**
293
- * Add a child visual element to our set of children.
294
- */
295
- addVariantChild: function (child) {
296
- var _a;
297
- var closestVariantNode = element.getClosestVariantNode();
298
- if (closestVariantNode) {
299
- (_a = closestVariantNode.variantChildren) === null || _a === void 0 ? void 0 : _a.add(child);
300
- return function () { return closestVariantNode.variantChildren.delete(child); };
301
- }
302
- },
303
- sortNodePosition: function (other) {
304
- /**
305
- * If these nodes aren't even of the same type we can't compare their depth.
306
- */
307
- if (!sortNodePosition || treeType !== other.treeType)
308
- return 0;
309
- return sortNodePosition(element.getInstance(), other.getInstance());
310
- },
311
- /**
312
- * Returns the closest variant node in the tree starting from
313
- * this visual element.
314
- */
315
- getClosestVariantNode: function () {
316
- return isVariantNode ? element : parent === null || parent === void 0 ? void 0 : parent.getClosestVariantNode();
317
- },
318
- /**
319
- * A method that schedules an update to layout projections throughout
320
- * the tree. We inherit from the parent so there's only ever one
321
- * job scheduled on the next frame - that of the root visual element.
322
- */
323
- scheduleUpdateLayoutProjection: parent
324
- ? parent.scheduleUpdateLayoutProjection
325
- : function () {
326
- return sync.preRender(element.updateTreeLayoutProjection, false, true);
327
- },
328
- /**
329
- * Expose the latest layoutId prop.
330
- */
331
- getLayoutId: function () { return props.layoutId; },
332
- /**
333
- * Returns the current instance.
334
- */
335
- getInstance: function () { return instance; },
336
- /**
337
- * Get/set the latest static values.
338
- */
339
- getStaticValue: function (key) { return latestValues[key]; }, setStaticValue: function (key, value) { return (latestValues[key] = value); },
340
- /**
341
- * Returns the latest motion value state. Currently only used to take
342
- * a snapshot of the visual element - perhaps this can return the whole
343
- * visual state
344
- */
345
- getLatestValues: function () { return latestValues; },
346
- /**
347
- * Set the visiblity of the visual element. If it's changed, schedule
348
- * a render to reflect these changes.
349
- */
350
- setVisibility: function (visibility) {
351
- if (element.isVisible === visibility)
352
- return;
353
- element.isVisible = visibility;
354
- element.scheduleRender();
355
- },
356
- /**
357
- * Make a target animatable by Popmotion. For instance, if we're
358
- * trying to animate width from 100px to 100vw we need to measure 100vw
359
- * in pixels to determine what we really need to animate to. This is also
360
- * pluggable to support Framer's custom value types like Color,
361
- * and CSS variables.
362
- */
363
- makeTargetAnimatable: function (target, canMutate) {
364
- if (canMutate === void 0) { canMutate = true; }
365
- return makeTargetAnimatable(element, target, props, canMutate);
366
- },
367
- // Motion values ========================
368
- /**
369
- * Add a motion value and bind it to this visual element.
370
- */
371
- addValue: function (key, value) {
372
- // Remove existing value if it exists
373
- if (element.hasValue(key))
374
- element.removeValue(key);
375
- values.set(key, value);
376
- latestValues[key] = value.get();
377
- bindToMotionValue(key, value);
378
- },
379
- /**
380
- * Remove a motion value and unbind any active subscriptions.
381
- */
382
- removeValue: function (key) {
383
- var _a;
384
- values.delete(key);
385
- (_a = valueSubscriptions.get(key)) === null || _a === void 0 ? void 0 : _a();
386
- valueSubscriptions.delete(key);
387
- delete latestValues[key];
388
- removeValueFromRenderState(key, renderState);
389
- },
390
- /**
391
- * Check whether we have a motion value for this key
392
- */
393
- hasValue: function (key) { return values.has(key); },
394
- /**
395
- * Get a motion value for this key. If called with a default
396
- * value, we'll create one if none exists.
397
- */
398
- getValue: function (key, defaultValue) {
399
- var value = values.get(key);
400
- if (value === undefined && defaultValue !== undefined) {
401
- value = motionValue(defaultValue);
402
- element.addValue(key, value);
403
- }
404
- return value;
405
- },
406
- /**
407
- * Iterate over our motion values.
408
- */
409
- forEachValue: function (callback) { return values.forEach(callback); },
410
- /**
411
- * If we're trying to animate to a previously unencountered value,
412
- * we need to check for it in our state and as a last resort read it
413
- * directly from the instance (which might have performance implications).
414
- */
415
- readValue: function (key) { var _a; return (_a = latestValues[key]) !== null && _a !== void 0 ? _a : readValueFromInstance(instance, key, options); },
416
- /**
417
- * Set the base target to later animate back to. This is currently
418
- * only hydrated on creation and when we first read a value.
419
- */
420
- setBaseTarget: function (key, value) {
421
- baseTarget[key] = value;
422
- },
423
- /**
424
- * Find the base target for a value thats been removed from all animation
425
- * props.
426
- */
427
- getBaseTarget: function (key) {
428
- if (getBaseTarget) {
429
- var target = getBaseTarget(props, key);
430
- if (target !== undefined && !isMotionValue(target))
431
- return target;
432
- }
433
- return baseTarget[key];
434
- } }, lifecycles), {
435
- /**
436
- * Build the renderer state based on the latest visual state.
437
- */
438
- build: function () {
439
- triggerBuild();
440
- return renderState;
441
- },
442
- /**
443
- * Schedule a render on the next animation frame.
444
- */
445
- scheduleRender: function () {
446
- sync.render(render, false, true);
447
- },
448
- /**
449
- * Synchronously fire render. It's prefered that we batch renders but
450
- * in many circumstances, like layout measurement, we need to run this
451
- * synchronously. However in those instances other measures should be taken
452
- * to batch reads/writes.
453
- */
454
- syncRender: render,
455
- /**
456
- * Update the provided props. Ensure any newly-added motion values are
457
- * added to our map, old ones removed, and listeners updated.
458
- */
459
- setProps: function (newProps) {
460
- props = newProps;
461
- lifecycles.updatePropListeners(newProps);
462
- prevMotionValues = updateMotionValuesFromProps(element, scrapeMotionValuesFromProps(props), prevMotionValues);
463
- }, getProps: function () { return props; },
464
- // Variants ==============================
465
- /**
466
- * Returns the variant definition with a given name.
467
- */
468
- getVariant: function (name) { var _a; return (_a = props.variants) === null || _a === void 0 ? void 0 : _a[name]; },
469
- /**
470
- * Returns the defined default transition on this component.
471
- */
472
- getDefaultTransition: function () { return props.transition; },
473
- /**
474
- * Used by child variant nodes to get the closest ancestor variant props.
475
- */
476
- getVariantContext: function (startAtParent) {
477
- if (startAtParent === void 0) { startAtParent = false; }
478
- if (startAtParent)
479
- return parent === null || parent === void 0 ? void 0 : parent.getVariantContext();
480
- if (!isControllingVariants) {
481
- var context_1 = (parent === null || parent === void 0 ? void 0 : parent.getVariantContext()) || {};
482
- if (props.initial !== undefined) {
483
- context_1.initial = props.initial;
484
- }
485
- return context_1;
486
- }
487
- var context = {};
488
- for (var i = 0; i < numVariantProps; i++) {
489
- var name_1 = variantProps[i];
490
- var prop = props[name_1];
491
- if (isVariantLabel(prop) || prop === false) {
492
- context[name_1] = prop;
493
- }
494
- }
495
- return context;
496
- },
497
- // Layout projection ==============================
498
- /**
499
- * Enable layout projection for this visual element. Won't actually
500
- * occur until we also have hydrated layout measurements.
501
- */
502
- enableLayoutProjection: function () {
503
- projection.isEnabled = true;
504
- element.layoutTree.add(element);
505
- },
506
- /**
507
- * Lock the projection target, for instance when dragging, so
508
- * nothing else can try and animate it.
509
- */
510
- lockProjectionTarget: function () {
511
- projection.isTargetLocked = true;
512
- },
513
- unlockProjectionTarget: function () {
514
- element.stopLayoutAnimation();
515
- projection.isTargetLocked = false;
516
- }, getLayoutState: function () { return layoutState; }, setCrossfader: function (newCrossfader) {
517
- crossfader = newCrossfader;
518
- }, isProjectionReady: function () {
519
- return projection.isEnabled &&
520
- projection.isHydrated &&
521
- layoutState.isHydrated;
522
- },
523
- /**
524
- * Start a layout animation on a given axis.
525
- */
526
- startLayoutAnimation: function (axis, transition, isRelative) {
527
- if (isRelative === void 0) { isRelative = false; }
528
- var progress = element.getProjectionAnimationProgress()[axis];
529
- var _a = isRelative
530
- ? projection.relativeTarget[axis]
531
- : projection.target[axis], min = _a.min, max = _a.max;
532
- var length = max - min;
533
- progress.clearListeners();
534
- progress.set(min);
535
- progress.set(min); // Set twice to hard-reset velocity
536
- progress.onChange(function (v) {
537
- element.setProjectionTargetAxis(axis, v, v + length, isRelative);
538
- });
539
- return element.animateMotionValue(axis, progress, 0, transition);
540
- },
541
- /**
542
- * Stop layout animations.
543
- */
544
- stopLayoutAnimation: function () {
545
- eachAxis(function (axis) {
546
- return element.getProjectionAnimationProgress()[axis].stop();
547
- });
548
- },
549
- /**
550
- * Measure the current viewport box with or without transforms.
551
- * Only measures axis-aligned boxes, rotate and skew must be manually
552
- * removed with a re-render to work.
553
- */
554
- measureViewportBox: function (withTransform) {
555
- if (withTransform === void 0) { withTransform = true; }
556
- var viewportBox = measureViewportBox(instance, options);
557
- if (!withTransform)
558
- removeBoxTransforms(viewportBox, latestValues);
559
- return viewportBox;
560
- },
561
- /**
562
- * Get the motion values tracking the layout animations on each
563
- * axis. Lazy init if not already created.
564
- */
565
- getProjectionAnimationProgress: function () {
566
- projectionTargetProgress || (projectionTargetProgress = {
567
- x: motionValue(0),
568
- y: motionValue(0),
569
- });
570
- return projectionTargetProgress;
571
- },
572
- /**
573
- * Update the projection of a single axis. Schedule an update to
574
- * the tree layout projection.
575
- */
576
- setProjectionTargetAxis: function (axis, min, max, isRelative) {
577
- if (isRelative === void 0) { isRelative = false; }
578
- var target;
579
- if (isRelative) {
580
- if (!projection.relativeTarget) {
581
- projection.relativeTarget = axisBox();
582
- }
583
- target = projection.relativeTarget[axis];
584
- }
585
- else {
586
- projection.relativeTarget = undefined;
587
- target = projection.target[axis];
588
- }
589
- projection.isHydrated = true;
590
- target.min = min;
591
- target.max = max;
592
- // Flag that we want to fire the onViewportBoxUpdate event handler
593
- hasViewportBoxUpdated = true;
594
- lifecycles.notifySetAxisTarget();
595
- },
596
- /**
597
- * Rebase the projection target on top of the provided viewport box
598
- * or the measured layout. This ensures that non-animating elements
599
- * don't fall out of sync differences in measurements vs projections
600
- * after a page scroll or other relayout.
601
- */
602
- rebaseProjectionTarget: function (force, box) {
603
- if (box === void 0) { box = layoutState.layout; }
604
- var _a = element.getProjectionAnimationProgress(), x = _a.x, y = _a.y;
605
- var shouldRebase = !projection.relativeTarget &&
606
- !projection.isTargetLocked &&
607
- !x.isAnimating() &&
608
- !y.isAnimating();
609
- if (force || shouldRebase) {
610
- eachAxis(function (axis) {
611
- var _a = box[axis], min = _a.min, max = _a.max;
612
- element.setProjectionTargetAxis(axis, min, max);
613
- });
614
- }
615
- },
616
- /**
617
- * Notify the visual element that its layout is up-to-date.
618
- * Currently Animate.tsx uses this to check whether a layout animation
619
- * needs to be performed.
620
- */
621
- notifyLayoutReady: function (config) {
622
- setCurrentViewportBox(element);
623
- element.notifyLayoutUpdate(layoutState.layout, element.prevViewportBox || layoutState.layout, config);
624
- },
625
- /**
626
- * Temporarily reset the transform of the instance.
627
- */
628
- resetTransform: function () { return resetTransform(element, instance, props); }, restoreTransform: function () { return restoreTransform(instance, renderState); }, updateLayoutProjection: updateLayoutProjection,
629
- updateTreeLayoutProjection: function () {
630
- element.layoutTree.forEach(fireResolveRelativeTargetBox);
631
- /**
632
- * Schedule the projection updates at the end of the current preRender
633
- * step. This will ensure that all layout trees will first resolve
634
- * relative projection boxes into viewport boxes, and *then*
635
- * update projections.
636
- */
637
- sync.preRender(updateTreeLayoutProjection, false, true);
638
- // sync.postRender(() => element.scheduleUpdateLayoutProjection())
639
- },
640
- getProjectionParent: function () {
641
- if (projectionParent === undefined) {
642
- var foundParent = false;
643
- // Search backwards through the tree path
644
- for (var i = element.path.length - 1; i >= 0; i--) {
645
- var ancestor = element.path[i];
646
- if (ancestor.projection.isEnabled) {
647
- foundParent = ancestor;
648
- break;
649
- }
650
- }
651
- projectionParent = foundParent;
652
- }
653
- return projectionParent;
654
- },
655
- resolveRelativeTargetBox: function () {
656
- var relativeParent = element.getProjectionParent();
657
- if (!projection.relativeTarget || !relativeParent)
658
- return;
659
- calcRelativeBox(projection, relativeParent.projection);
660
- if (isDraggable(relativeParent)) {
661
- var target = projection.target;
662
- applyBoxTransforms(target, target, relativeParent.getLatestValues());
663
- }
664
- },
665
- shouldResetTransform: function () {
666
- return Boolean(props._layoutResetTransform);
667
- },
668
- /**
669
- *
670
- */
671
- pointTo: function (newLead) {
672
- leadProjection = newLead.projection;
673
- leadLatestValues = newLead.getLatestValues();
674
- /**
675
- * Subscribe to lead component's layout animations
676
- */
677
- unsubscribeFromLeadVisualElement === null || unsubscribeFromLeadVisualElement === void 0 ? void 0 : unsubscribeFromLeadVisualElement();
678
- unsubscribeFromLeadVisualElement = pipe(newLead.onSetAxisTarget(element.scheduleUpdateLayoutProjection), newLead.onLayoutAnimationComplete(function () {
679
- var _a;
680
- if (element.isPresent) {
681
- element.presence = Presence.Present;
682
- }
683
- else {
684
- (_a = element.layoutSafeToRemove) === null || _a === void 0 ? void 0 : _a.call(element);
685
- }
686
- }));
687
- },
688
- // TODO: Clean this up
689
- isPresent: true, presence: Presence.Entering });
690
- return element;
691
- };
692
- };
693
- function fireResolveRelativeTargetBox(child) {
694
- child.resolveRelativeTargetBox();
695
- }
696
- function fireUpdateLayoutProjection(child) {
697
- child.updateLayoutProjection();
698
- }
699
- var variantProps = __spreadArray(["initial"], __read(variantPriorityOrder));
700
- var numVariantProps = variantProps.length;
701
-
702
- export { visualElement };
703
-
1
+ /**
2
+ based on framer-motion@4.1.1,
3
+ Copyright (c) 2018 Framer B.V.
4
+ */
5
+ import sync, { cancelSync } from 'framesync';
6
+ import { pipe } from 'popmotion';
7
+ import { Presence } from '../components/AnimateSharedLayout/types.js';
8
+ import { eachAxis } from '../utils/each-axis.js';
9
+ import { applyBoxTransforms, removeBoxTransforms } from '../utils/geometry/delta-apply.js';
10
+ import { calcRelativeBox, updateBoxDelta } from '../utils/geometry/delta-calc.js';
11
+ import { axisBox } from '../utils/geometry/index.js';
12
+ import { motionValue } from '../value/index.js';
13
+ import { isMotionValue } from '../value/utils/is-motion-value.js';
14
+ import { setCurrentViewportBox } from './dom/projection/relative-set.js';
15
+ import { buildLayoutProjectionTransform } from './html/utils/build-projection-transform.js';
16
+ import { variantPriorityOrder } from './utils/animation-state.js';
17
+ import { FlatTree } from './utils/flat-tree.js';
18
+ import { isDraggable } from './utils/is-draggable.js';
19
+ import { createLifecycles } from './utils/lifecycles.js';
20
+ import { updateMotionValuesFromProps } from './utils/motion-values.js';
21
+ import { updateLayoutDeltas } from './utils/projection.js';
22
+ import { createLayoutState, createProjectionState } from './utils/state.js';
23
+ import { checkIfControllingVariants, checkIfVariantNode, isVariantLabel } from './utils/variants.js';
24
+ // TODO: make abstract class - future plans to match latest FramerMotion
25
+ var visualElement = function ({ treeType, build, getBaseTarget, makeTargetAnimatable, measureViewportBox, render: renderInstance, readValueFromInstance, resetTransform, restoreTransform, removeValueFromRenderState, sortNodePosition, scrapeMotionValuesFromProps, }) {
26
+ return function ({ parent, props, presenceId, blockInitialAnimation, visualState }, options) {
27
+ if (options === void 0) {
28
+ options = {};
29
+ }
30
+ var latestValues = visualState.latestValues, renderState = visualState.renderState;
31
+ /**
32
+ * The instance of the render-specific node that will be hydrated by the
33
+ * exposed React ref. So for example, this visual element can host a
34
+ * HTMLElement, plain object, or Three.js object. The functions provided
35
+ * in VisualElementConfig allow us to interface with this instance.
36
+ */
37
+ var instance;
38
+ /**
39
+ * Manages the subscriptions for a visual element's lifecycle, for instance
40
+ * onRender and onViewportBoxUpdate.
41
+ */
42
+ var lifecycles = createLifecycles();
43
+ /**
44
+ *
45
+ */
46
+ var projection = createProjectionState();
47
+ /**
48
+ * A reference to the nearest projecting parent. This is either
49
+ * undefined if we haven't looked for the nearest projecting parent,
50
+ * false if there is no parent performing layout projection, or a reference
51
+ * to the projecting parent.
52
+ */
53
+ var projectionParent;
54
+ /**
55
+ * This is a reference to the visual state of the "lead" visual element.
56
+ * Usually, this will be this visual element. But if it shares a layoutId
57
+ * with other visual elements, only one of them will be designated lead by
58
+ * AnimateSharedLayout. All the other visual elements will take on the visual
59
+ * appearance of the lead while they crossfade to it.
60
+ */
61
+ var leadProjection = projection;
62
+ var leadLatestValues = latestValues;
63
+ var unsubscribeFromLeadVisualElement;
64
+ /**
65
+ * The latest layout measurements and calculated projections. This
66
+ * is seperate from the target projection data in visualState as
67
+ * many visual elements might point to the same piece of visualState as
68
+ * a target, whereas they might each have different layouts and thus
69
+ * projection calculations needed to project into the same viewport box.
70
+ */
71
+ var layoutState = createLayoutState();
72
+ /**
73
+ *
74
+ */
75
+ var crossfader;
76
+ /**
77
+ * Keep track of whether the viewport box has been updated since the
78
+ * last time the layout projection was re-calculated.
79
+ */
80
+ var hasViewportBoxUpdated = false;
81
+ /**
82
+ * A map of all motion values attached to this visual element. Motion
83
+ * values are source of truth for any given animated value. A motion
84
+ * value might be provided externally by the component via props.
85
+ */
86
+ var values = new Map();
87
+ /**
88
+ * A map of every subscription that binds the provided or generated
89
+ * motion values onChange listeners to this visual element.
90
+ */
91
+ var valueSubscriptions = new Map();
92
+ /**
93
+ * A reference to the previously-provided motion values as returned
94
+ * from scrapeMotionValuesFromProps. We use the keys in here to determine
95
+ * if any motion values need to be removed after props are updated.
96
+ */
97
+ var prevMotionValues = {};
98
+ /**
99
+ * x/y motion values that track the progress of initiated layout
100
+ * animations.
101
+ *
102
+ * TODO: Target for removal
103
+ */
104
+ var projectionTargetProgress;
105
+ /**
106
+ * When values are removed from all animation props we need to search
107
+ * for a fallback value to animate to. These values are tracked in baseTarget.
108
+ */
109
+ var baseTarget = Object.assign({}, latestValues);
110
+ // Internal methods ========================
111
+ /**
112
+ * On mount, this will be hydrated with a callback to disconnect
113
+ * this visual element from its parent on unmount.
114
+ */
115
+ var removeFromVariantTree;
116
+ /**
117
+ *
118
+ */
119
+ function render() {
120
+ if (!instance)
121
+ return;
122
+ if (element.isProjectionReady()) {
123
+ /**
124
+ * Apply the latest user-set transforms to the targetBox to produce the targetBoxFinal.
125
+ * This is the final box that we will then project into by calculating a transform delta and
126
+ * applying it to the corrected box.
127
+ */
128
+ applyBoxTransforms(leadProjection.targetFinal, leadProjection.target, leadLatestValues);
129
+ /**
130
+ * Update the delta between the corrected box and the final target box, after
131
+ * user-set transforms are applied to it. This will be used by the renderer to
132
+ * create a transform style that will reproject the element from its actual layout
133
+ * into the desired bounding box.
134
+ */
135
+ updateBoxDelta(layoutState.deltaFinal, layoutState.layoutCorrected, leadProjection.targetFinal, latestValues);
136
+ }
137
+ triggerBuild();
138
+ renderInstance(instance, renderState);
139
+ }
140
+ function triggerBuild() {
141
+ var valuesToRender = latestValues;
142
+ if (crossfader && crossfader.isActive()) {
143
+ var crossfadedValues = crossfader.getCrossfadeState(element);
144
+ if (crossfadedValues)
145
+ valuesToRender = crossfadedValues;
146
+ }
147
+ build(element, renderState, valuesToRender, leadProjection, layoutState, options, props);
148
+ }
149
+ function update() {
150
+ lifecycles.notifyUpdate(latestValues);
151
+ }
152
+ function updateLayoutProjection() {
153
+ if (!element.isProjectionReady())
154
+ return;
155
+ var delta = layoutState.delta, treeScale = layoutState.treeScale;
156
+ var prevTreeScaleX = treeScale.x;
157
+ var prevTreeScaleY = treeScale.y;
158
+ var prevDeltaTransform = layoutState.deltaTransform;
159
+ updateLayoutDeltas(layoutState, leadProjection, element.path, latestValues);
160
+ hasViewportBoxUpdated && element.notifyViewportBoxUpdate(leadProjection.target, delta);
161
+ hasViewportBoxUpdated = false;
162
+ var deltaTransform = buildLayoutProjectionTransform(delta, treeScale);
163
+ if (deltaTransform !== prevDeltaTransform ||
164
+ // Also compare calculated treeScale, for values that rely on this only for scale correction
165
+ prevTreeScaleX !== treeScale.x ||
166
+ prevTreeScaleY !== treeScale.y) {
167
+ element.scheduleRender();
168
+ }
169
+ layoutState.deltaTransform = deltaTransform;
170
+ }
171
+ function updateTreeLayoutProjection() {
172
+ //@ts-ignore
173
+ element.layoutTree.forEach(fireUpdateLayoutProjection);
174
+ }
175
+ /**
176
+ *
177
+ */
178
+ function bindToMotionValue(key, value) {
179
+ var removeOnChange = value.onChange(function (latestValue) {
180
+ latestValues[key] = latestValue;
181
+ props.onUpdate && sync.update(update, false, true);
182
+ });
183
+ var removeOnRenderRequest = value.onRenderRequest(element.scheduleRender);
184
+ valueSubscriptions.set(key, function () {
185
+ removeOnChange();
186
+ removeOnRenderRequest();
187
+ });
188
+ }
189
+ /**
190
+ * Any motion values that are provided to the element when created
191
+ * aren't yet bound to the element, as this would technically be impure.
192
+ * However, we iterate through the motion values and set them to the
193
+ * initial values for this component.
194
+ *
195
+ * TODO: This is impure and we should look at changing this to run on mount.
196
+ * Doing so will break some tests but this isn't neccessarily a breaking change,
197
+ * more a reflection of the test.
198
+ */
199
+ var initialMotionValues = scrapeMotionValuesFromProps(props);
200
+ for (var key in initialMotionValues) {
201
+ var value = initialMotionValues[key];
202
+ if (latestValues[key] !== undefined && isMotionValue(value)) {
203
+ value.set(latestValues[key], false);
204
+ }
205
+ }
206
+ /**
207
+ * Determine what role this visual element should take in the variant tree.
208
+ */
209
+ var isControllingVariants = checkIfControllingVariants(props);
210
+ var isVariantNode = checkIfVariantNode(props);
211
+ var element = Object.assign(Object.assign({
212
+ treeType: treeType,
213
+ /**
214
+ * This is a mirror of the internal instance prop, which keeps
215
+ * VisualElement type-compatible with React's RefObject.
216
+ */
217
+ current: null,
218
+ /**
219
+ * The depth of this visual element within the visual element tree.
220
+ */
221
+ depth: parent ? parent.depth + 1 : 0,
222
+ parent: parent,
223
+ children: new Set(),
224
+ /**
225
+ * An ancestor path back to the root visual element. This is used
226
+ * by layout projection to quickly recurse back up the tree.
227
+ */
228
+ path: parent ? [...parent.path, ...[parent]] : [],
229
+ layoutTree: parent ? parent.layoutTree : new FlatTree(),
230
+ /**
231
+ *
232
+ */
233
+ presenceId: presenceId,
234
+ projection: projection,
235
+ /**
236
+ * If this component is part of the variant tree, it should track
237
+ * any children that are also part of the tree. This is essentially
238
+ * a shadow tree to simplify logic around how to stagger over children.
239
+ */
240
+ variantChildren: isVariantNode ? new Set() : undefined,
241
+ /**
242
+ * Whether this instance is visible. This can be changed imperatively
243
+ * by AnimateSharedLayout, is analogous to CSS's visibility in that
244
+ * hidden elements should take up layout, and needs enacting by the configured
245
+ * render function.
246
+ */
247
+ isVisible: undefined,
248
+ /**
249
+ * Normally, if a component is controlled by a parent's variants, it can
250
+ * rely on that ancestor to trigger animations further down the tree.
251
+ * However, if a component is created after its parent is mounted, the parent
252
+ * won't trigger that mount animation so the child needs to.
253
+ *
254
+ * TODO: This might be better replaced with a method isParentMounted
255
+ */
256
+ manuallyAnimateOnMount: Boolean(parent === null || parent === void 0 ? void 0 : parent.isMounted()),
257
+ /**
258
+ * This can be set by AnimatePresence to force components that mount
259
+ * at the same time as it to mount as if they have initial={false} set.
260
+ */
261
+ blockInitialAnimation: blockInitialAnimation,
262
+ /**
263
+ * Determine whether this component has mounted yet. This is mostly used
264
+ * by variant children to determine whether they need to trigger their
265
+ * own animations on mount.
266
+ */
267
+ isMounted: function () {
268
+ return Boolean(instance);
269
+ },
270
+ mount: function (newInstance) {
271
+ instance = element.current = newInstance;
272
+ element.pointTo(element);
273
+ if (isVariantNode && parent && !isControllingVariants) {
274
+ removeFromVariantTree = parent === null || parent === void 0 ? void 0 : parent.addVariantChild(element);
275
+ }
276
+ parent === null || parent === void 0 ? void 0 : parent.children.add(element);
277
+ },
278
+ /**
279
+ *
280
+ */
281
+ unmount: function () {
282
+ cancelSync.update(update);
283
+ cancelSync.render(render);
284
+ cancelSync.preRender(element.updateLayoutProjection);
285
+ valueSubscriptions.forEach(function (remove) {
286
+ return remove();
287
+ });
288
+ element.stopLayoutAnimation();
289
+ element.layoutTree.remove(element);
290
+ removeFromVariantTree === null || removeFromVariantTree === void 0 ? void 0 : removeFromVariantTree();
291
+ parent === null || parent === void 0 ? void 0 : parent.children.delete(element);
292
+ unsubscribeFromLeadVisualElement === null || unsubscribeFromLeadVisualElement === void 0
293
+ ? void 0
294
+ : unsubscribeFromLeadVisualElement();
295
+ lifecycles.clearAllListeners();
296
+ },
297
+ /**
298
+ * Add a child visual element to our set of children.
299
+ */
300
+ addVariantChild: function (child) {
301
+ var _a;
302
+ var closestVariantNode = element.getClosestVariantNode();
303
+ if (closestVariantNode) {
304
+ (_a = closestVariantNode.variantChildren) === null || _a === void 0 ? void 0 : _a.add(child);
305
+ return function () {
306
+ return closestVariantNode?.variantChildren?.delete(child);
307
+ };
308
+ }
309
+ },
310
+ sortNodePosition: function (other) {
311
+ /**
312
+ * If these nodes aren't even of the same type we can't compare their depth.
313
+ */
314
+ if (!sortNodePosition || treeType !== other.treeType)
315
+ return 0;
316
+ return sortNodePosition(element.getInstance(), other.getInstance());
317
+ },
318
+ /**
319
+ * Returns the closest variant node in the tree starting from
320
+ * this visual element.
321
+ */
322
+ getClosestVariantNode: function () {
323
+ return isVariantNode
324
+ ? element
325
+ : parent === null || parent === void 0
326
+ ? void 0
327
+ : parent.getClosestVariantNode();
328
+ },
329
+ /**
330
+ * A method that schedules an update to layout projections throughout
331
+ * the tree. We inherit from the parent so there's only ever one
332
+ * job scheduled on the next frame - that of the root visual element.
333
+ */
334
+ scheduleUpdateLayoutProjection: parent
335
+ ? parent.scheduleUpdateLayoutProjection
336
+ : function () {
337
+ return sync.preRender(element.updateTreeLayoutProjection, false, true);
338
+ },
339
+ /**
340
+ * Expose the latest layoutId prop.
341
+ */
342
+ getLayoutId: function () {
343
+ return props.layoutId;
344
+ },
345
+ /**
346
+ * Returns the current instance.
347
+ */
348
+ getInstance: function () {
349
+ return instance;
350
+ },
351
+ /**
352
+ * Get/set the latest static values.
353
+ */
354
+ getStaticValue: function (key) {
355
+ return latestValues[key];
356
+ },
357
+ setStaticValue: function (key, value) {
358
+ return (latestValues[key] = value);
359
+ },
360
+ /**
361
+ * Returns the latest motion value state. Currently only used to take
362
+ * a snapshot of the visual element - perhaps this can return the whole
363
+ * visual state
364
+ */
365
+ getLatestValues: function () {
366
+ return latestValues;
367
+ },
368
+ /**
369
+ * Set the visiblity of the visual element. If it's changed, schedule
370
+ * a render to reflect these changes.
371
+ */
372
+ setVisibility: function (visibility) {
373
+ if (element.isVisible === visibility)
374
+ return;
375
+ element.isVisible = visibility;
376
+ element.scheduleRender();
377
+ },
378
+ /**
379
+ * Make a target animatable by Popmotion. For instance, if we're
380
+ * trying to animate width from 100px to 100vw we need to measure 100vw
381
+ * in pixels to determine what we really need to animate to. This is also
382
+ * pluggable to support Framer's custom value types like Color,
383
+ * and CSS variables.
384
+ */
385
+ makeTargetAnimatable: function (target, canMutate) {
386
+ if (canMutate === void 0) {
387
+ canMutate = true;
388
+ }
389
+ return makeTargetAnimatable(element, target, props, canMutate);
390
+ },
391
+ // Motion values ========================
392
+ /**
393
+ * Add a motion value and bind it to this visual element.
394
+ */
395
+ addValue: function (key, value) {
396
+ // Remove existing value if it exists
397
+ if (element.hasValue(key))
398
+ element.removeValue(key);
399
+ values.set(key, value);
400
+ latestValues[key] = value.get();
401
+ bindToMotionValue(key, value);
402
+ },
403
+ /**
404
+ * Remove a motion value and unbind any active subscriptions.
405
+ */
406
+ removeValue: function (key) {
407
+ var _a;
408
+ values.delete(key);
409
+ (_a = valueSubscriptions.get(key)) === null || _a === void 0 ? void 0 : _a();
410
+ valueSubscriptions.delete(key);
411
+ delete latestValues[key];
412
+ removeValueFromRenderState(key, renderState);
413
+ },
414
+ /**
415
+ * Check whether we have a motion value for this key
416
+ */
417
+ hasValue: function (key) {
418
+ return values.has(key);
419
+ },
420
+ /**
421
+ * Get a motion value for this key. If called with a default
422
+ * value, we'll create one if none exists.
423
+ */
424
+ getValue: function (key, defaultValue) {
425
+ var value = values.get(key);
426
+ if (value === undefined && defaultValue !== undefined) {
427
+ value = motionValue(defaultValue);
428
+ element.addValue(key, value);
429
+ }
430
+ return value;
431
+ },
432
+ /**
433
+ * Iterate over our motion values.
434
+ */
435
+ forEachValue: function (callback) {
436
+ return values.forEach(callback);
437
+ },
438
+ /**
439
+ * If we're trying to animate to a previously unencountered value,
440
+ * we need to check for it in our state and as a last resort read it
441
+ * directly from the instance (which might have performance implications).
442
+ */
443
+ readValue: function (key) {
444
+ var _a;
445
+ return (_a = latestValues[key]) !== null && _a !== void 0
446
+ ? _a
447
+ : readValueFromInstance(instance, key, options);
448
+ },
449
+ /**
450
+ * Set the base target to later animate back to. This is currently
451
+ * only hydrated on creation and when we first read a value.
452
+ */
453
+ setBaseTarget: function (key, value) {
454
+ baseTarget[key] = value;
455
+ },
456
+ /**
457
+ * Find the base target for a value thats been removed from all animation
458
+ * props.
459
+ */
460
+ getBaseTarget: function (key) {
461
+ if (getBaseTarget) {
462
+ var target = getBaseTarget(props, key);
463
+ if (target !== undefined && !isMotionValue(target))
464
+ return target;
465
+ }
466
+ return baseTarget[key];
467
+ },
468
+ }, lifecycles), {
469
+ /**
470
+ * Build the renderer state based on the latest visual state.
471
+ */
472
+ build: function () {
473
+ triggerBuild();
474
+ return renderState;
475
+ },
476
+ /**
477
+ * Schedule a render on the next animation frame.
478
+ */
479
+ scheduleRender: function () {
480
+ sync.render(render, false, true);
481
+ },
482
+ /**
483
+ * Synchronously fire render. It's prefered that we batch renders but
484
+ * in many circumstances, like layout measurement, we need to run this
485
+ * synchronously. However in those instances other measures should be taken
486
+ * to batch reads/writes.
487
+ */
488
+ syncRender: render,
489
+ /**
490
+ * Update the provided props. Ensure any newly-added motion values are
491
+ * added to our map, old ones removed, and listeners updated.
492
+ */
493
+ setProps: function (newProps) {
494
+ props = newProps;
495
+ lifecycles.updatePropListeners(newProps);
496
+ prevMotionValues = updateMotionValuesFromProps(element, scrapeMotionValuesFromProps(props), prevMotionValues);
497
+ },
498
+ getProps: function () {
499
+ return props;
500
+ },
501
+ // Variants ==============================
502
+ /**
503
+ * Returns the variant definition with a given name.
504
+ */
505
+ getVariant: function (name) {
506
+ var _a;
507
+ return (_a = props.variants) === null || _a === void 0 ? void 0 : _a[name];
508
+ },
509
+ /**
510
+ * Returns the defined default transition on this component.
511
+ */
512
+ getDefaultTransition: function () {
513
+ return props.transition;
514
+ },
515
+ /**
516
+ * Used by child variant nodes to get the closest ancestor variant props.
517
+ */
518
+ getVariantContext: function (startAtParent) {
519
+ if (startAtParent === void 0) {
520
+ startAtParent = false;
521
+ }
522
+ if (startAtParent)
523
+ return parent === null || parent === void 0 ? void 0 : parent.getVariantContext();
524
+ if (!isControllingVariants) {
525
+ var context_1 = (parent === null || parent === void 0 ? void 0 : parent.getVariantContext()) || {};
526
+ if (props.initial !== undefined) {
527
+ //@ts-ignore
528
+ context_1.initial = props.initial;
529
+ }
530
+ return context_1;
531
+ }
532
+ var context = {};
533
+ for (var i = 0; i < numVariantProps; i++) {
534
+ var name_1 = variantProps[i];
535
+ //@ts-ignore
536
+ var prop = props[name_1];
537
+ if (isVariantLabel(prop) || prop === false) {
538
+ //@ts-ignore
539
+ context[name_1] = prop;
540
+ }
541
+ }
542
+ return context;
543
+ },
544
+ // Layout projection ==============================
545
+ /**
546
+ * Enable layout projection for this visual element. Won't actually
547
+ * occur until we also have hydrated layout measurements.
548
+ */
549
+ enableLayoutProjection: function () {
550
+ projection.isEnabled = true;
551
+ element.layoutTree.add(element);
552
+ },
553
+ /**
554
+ * Lock the projection target, for instance when dragging, so
555
+ * nothing else can try and animate it.
556
+ */
557
+ lockProjectionTarget: function () {
558
+ projection.isTargetLocked = true;
559
+ },
560
+ unlockProjectionTarget: function () {
561
+ element.stopLayoutAnimation();
562
+ projection.isTargetLocked = false;
563
+ },
564
+ getLayoutState: function () {
565
+ return layoutState;
566
+ },
567
+ setCrossfader: function (newCrossfader) {
568
+ crossfader = newCrossfader;
569
+ },
570
+ isProjectionReady: function () {
571
+ return projection.isEnabled && projection.isHydrated && layoutState.isHydrated;
572
+ },
573
+ /**
574
+ * Start a layout animation on a given axis.
575
+ */
576
+ startLayoutAnimation: function (axis, transition, isRelative) {
577
+ if (isRelative === void 0) {
578
+ isRelative = false;
579
+ }
580
+ var progress = element.getProjectionAnimationProgress()[axis];
581
+ var _a = isRelative ? projection.relativeTarget[axis] : projection.target[axis], min = _a.min, max = _a.max;
582
+ var length = max - min;
583
+ progress.clearListeners();
584
+ progress.set(min);
585
+ progress.set(min); // Set twice to hard-reset velocity
586
+ progress.onChange(function (v) {
587
+ element.setProjectionTargetAxis(axis, v, v + length, isRelative);
588
+ });
589
+ return element.animateMotionValue(axis, progress, 0, transition);
590
+ },
591
+ /**
592
+ * Stop layout animations.
593
+ */
594
+ stopLayoutAnimation: function () {
595
+ eachAxis(function (axis) {
596
+ return element.getProjectionAnimationProgress()[axis].stop();
597
+ });
598
+ },
599
+ /**
600
+ * Measure the current viewport box with or without transforms.
601
+ * Only measures axis-aligned boxes, rotate and skew must be manually
602
+ * removed with a re-render to work.
603
+ */
604
+ measureViewportBox: function (withTransform) {
605
+ if (withTransform === void 0) {
606
+ withTransform = true;
607
+ }
608
+ var viewportBox = measureViewportBox(instance, options);
609
+ if (!withTransform)
610
+ removeBoxTransforms(viewportBox, latestValues);
611
+ return viewportBox;
612
+ },
613
+ /**
614
+ * Get the motion values tracking the layout animations on each
615
+ * axis. Lazy init if not already created.
616
+ */
617
+ getProjectionAnimationProgress: function () {
618
+ projectionTargetProgress ||
619
+ (projectionTargetProgress = {
620
+ x: motionValue(0),
621
+ y: motionValue(0),
622
+ });
623
+ return projectionTargetProgress;
624
+ },
625
+ /**
626
+ * Update the projection of a single axis. Schedule an update to
627
+ * the tree layout projection.
628
+ */
629
+ setProjectionTargetAxis: function (axis, min, max, isRelative) {
630
+ if (isRelative === void 0) {
631
+ isRelative = false;
632
+ }
633
+ var target; /*: {
634
+ min : number,
635
+ max : number,
636
+ projection: TargetProjection
637
+ };*/
638
+ if (isRelative) {
639
+ if (!projection.relativeTarget) {
640
+ projection.relativeTarget = axisBox();
641
+ }
642
+ target = projection.relativeTarget[axis];
643
+ }
644
+ else {
645
+ projection.relativeTarget = undefined;
646
+ target = projection.target[axis];
647
+ }
648
+ projection.isHydrated = true;
649
+ target.min = min;
650
+ target.max = max;
651
+ // Flag that we want to fire the onViewportBoxUpdate event handler
652
+ hasViewportBoxUpdated = true;
653
+ lifecycles.notifySetAxisTarget();
654
+ },
655
+ /**
656
+ * Rebase the projection target on top of the provided viewport box
657
+ * or the measured layout. This ensures that non-animating elements
658
+ * don't fall out of sync differences in measurements vs projections
659
+ * after a page scroll or other relayout.
660
+ */
661
+ rebaseProjectionTarget: function (force, box) {
662
+ if (box === void 0) {
663
+ box = layoutState.layout;
664
+ }
665
+ var _a = element.getProjectionAnimationProgress(), x = _a.x, y = _a.y;
666
+ var shouldRebase = !projection.relativeTarget && !projection.isTargetLocked && !x.isAnimating() && !y.isAnimating();
667
+ if (force || shouldRebase) {
668
+ eachAxis(function (axis) {
669
+ var _a = box[axis], min = _a.min, max = _a.max;
670
+ element.setProjectionTargetAxis(axis, min, max);
671
+ });
672
+ }
673
+ },
674
+ /**
675
+ * Notify the visual element that its layout is up-to-date.
676
+ * Currently Animate.tsx uses this to check whether a layout animation
677
+ * needs to be performed.
678
+ */
679
+ notifyLayoutReady: function (config) {
680
+ setCurrentViewportBox(element);
681
+ element.notifyLayoutUpdate(layoutState.layout, element.prevViewportBox || layoutState.layout, config);
682
+ },
683
+ /**
684
+ * Temporarily reset the transform of the instance.
685
+ */
686
+ resetTransform: function () {
687
+ return resetTransform(element, instance, props);
688
+ },
689
+ restoreTransform: function () {
690
+ return restoreTransform(instance, renderState);
691
+ },
692
+ updateLayoutProjection: updateLayoutProjection,
693
+ updateTreeLayoutProjection: function () {
694
+ //@ts-ignore
695
+ element.layoutTree.forEach(fireResolveRelativeTargetBox);
696
+ /**
697
+ * Schedule the projection updates at the end of the current preRender
698
+ * step. This will ensure that all layout trees will first resolve
699
+ * relative projection boxes into viewport boxes, and *then*
700
+ * update projections.
701
+ */
702
+ sync.preRender(updateTreeLayoutProjection, false, true);
703
+ // sync.postRender(() => element.scheduleUpdateLayoutProjection())
704
+ },
705
+ getProjectionParent: function () {
706
+ if (projectionParent === undefined) {
707
+ var foundParent = false;
708
+ // Search backwards through the tree path
709
+ for (var i = element.path.length - 1; i >= 0; i--) {
710
+ var ancestor = element.path[i];
711
+ if (ancestor.projection.isEnabled) {
712
+ //@ts-ignore
713
+ foundParent = ancestor;
714
+ break;
715
+ }
716
+ }
717
+ projectionParent = foundParent;
718
+ }
719
+ return projectionParent;
720
+ },
721
+ resolveRelativeTargetBox: function () {
722
+ var relativeParent = element.getProjectionParent();
723
+ if (!projection.relativeTarget || !relativeParent)
724
+ return;
725
+ calcRelativeBox(projection, relativeParent.projection);
726
+ if (isDraggable(relativeParent)) {
727
+ var target = projection.target;
728
+ applyBoxTransforms(target, target, relativeParent.getLatestValues());
729
+ }
730
+ },
731
+ shouldResetTransform: function () {
732
+ return Boolean(props._layoutResetTransform);
733
+ },
734
+ /**
735
+ *
736
+ */
737
+ pointTo: function (newLead) {
738
+ leadProjection = newLead.projection;
739
+ leadLatestValues = newLead.getLatestValues();
740
+ /**
741
+ * Subscribe to lead component's layout animations
742
+ */
743
+ unsubscribeFromLeadVisualElement === null || unsubscribeFromLeadVisualElement === void 0
744
+ ? void 0
745
+ : unsubscribeFromLeadVisualElement();
746
+ unsubscribeFromLeadVisualElement = pipe(newLead.onSetAxisTarget(element.scheduleUpdateLayoutProjection), newLead.onLayoutAnimationComplete(function () {
747
+ var _a;
748
+ if (element.isPresent) {
749
+ element.presence = Presence.Present;
750
+ }
751
+ else {
752
+ (_a = element.layoutSafeToRemove) === null || _a === void 0 ? void 0 : _a.call(element);
753
+ }
754
+ }));
755
+ },
756
+ // TODO: Clean this up
757
+ isPresent: true,
758
+ presence: Presence.Entering,
759
+ });
760
+ return element;
761
+ };
762
+ };
763
+ function fireResolveRelativeTargetBox(child) {
764
+ child.resolveRelativeTargetBox();
765
+ }
766
+ function fireUpdateLayoutProjection(child) {
767
+ child.updateLayoutProjection();
768
+ }
769
+ var variantProps = [...['initial'], ...variantPriorityOrder];
770
+ var numVariantProps = variantProps.length;
771
+ export { visualElement };