use-scroll-animate 10.2.0 → 10.4.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 (403) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +67 -0
  4. package/bin/motionary-mcp.mjs +265 -0
  5. package/dist/chunks/anim-image-DDdb9q3X.js +166 -0
  6. package/dist/chunks/anim-image-DDdb9q3X.js.map +1 -0
  7. package/dist/chunks/anim-image-blQgPFFS.cjs +174 -0
  8. package/dist/chunks/anim-image-blQgPFFS.cjs.map +1 -0
  9. package/dist/chunks/audio-BpU-A1m1.cjs.map +1 -1
  10. package/dist/chunks/{audio-D95jwlOh.js → audio-CWt1xdZB.js} +3 -3
  11. package/dist/chunks/{audio-D95jwlOh.js.map → audio-CWt1xdZB.js.map} +1 -1
  12. package/dist/chunks/{base-BnRyfuyM.js → base-BTev8qxg.js} +2 -2
  13. package/dist/chunks/{base-BnRyfuyM.js.map → base-BTev8qxg.js.map} +1 -1
  14. package/dist/chunks/base-DBheNxJu.cjs.map +1 -1
  15. package/dist/chunks/bind-B_CTL6Qn.js.map +1 -1
  16. package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -1
  17. package/dist/chunks/builtins-CKKZNR95.cjs.map +1 -1
  18. package/dist/chunks/{builtins-CqIq1zBv.js → builtins-CPmS6aDB.js} +3 -3
  19. package/dist/chunks/{builtins-CqIq1zBv.js.map → builtins-CPmS6aDB.js.map} +1 -1
  20. package/dist/chunks/core-B5T0dhFH.cjs.map +1 -1
  21. package/dist/chunks/{core-DsGoL9EY.js → core-BviA7nFa.js} +2 -2
  22. package/dist/chunks/{core-DsGoL9EY.js.map → core-BviA7nFa.js.map} +1 -1
  23. package/dist/chunks/core-D74Fz-dL.cjs.map +1 -1
  24. package/dist/chunks/core-D7cVumUu.js.map +1 -1
  25. package/dist/chunks/{core-XA2yhn1b.js → core-KiM7MXjL.js} +2 -2
  26. package/dist/chunks/{core-XA2yhn1b.js.map → core-KiM7MXjL.js.map} +1 -1
  27. package/dist/chunks/core-MQlXZKUG.cjs.map +1 -1
  28. package/dist/chunks/ease-HwYZnZat.cjs +94 -0
  29. package/dist/chunks/ease-HwYZnZat.cjs.map +1 -0
  30. package/dist/chunks/ease-XN8_0sXu.js +89 -0
  31. package/dist/chunks/ease-XN8_0sXu.js.map +1 -0
  32. package/dist/chunks/fx-B_pbhpDp.cjs.map +1 -1
  33. package/dist/chunks/{fx-CtnrFEg9.js → fx-CgWKqVsn.js} +2 -2
  34. package/dist/chunks/{fx-CtnrFEg9.js.map → fx-CgWKqVsn.js.map} +1 -1
  35. package/dist/chunks/generative-2LhxG5BJ.js.map +1 -1
  36. package/dist/chunks/generative-BHIj-NU0.cjs.map +1 -1
  37. package/dist/chunks/{gpu-CDcXiNA8.js → gpu-BWfgYWMY.js} +2 -2
  38. package/dist/chunks/{gpu-CDcXiNA8.js.map → gpu-BWfgYWMY.js.map} +1 -1
  39. package/dist/chunks/gpu-cUixt7kT.cjs.map +1 -1
  40. package/dist/chunks/index-tags-B-JBecYg.js.map +1 -1
  41. package/dist/chunks/index-tags-hLIF2Clq.cjs.map +1 -1
  42. package/dist/chunks/{keyframes-W-474DMc.js → keyframes-B5PWe5bU.js} +3 -2
  43. package/dist/chunks/keyframes-B5PWe5bU.js.map +1 -0
  44. package/dist/chunks/{keyframes-ZheOkpt0.cjs → keyframes-tC3I7anQ.cjs} +4 -3
  45. package/dist/chunks/keyframes-tC3I7anQ.cjs.map +1 -0
  46. package/dist/chunks/{manifest-D58HXVY-.js → manifest-BHx5yPN6.js} +2 -2
  47. package/dist/chunks/{manifest-D58HXVY-.js.map → manifest-BHx5yPN6.js.map} +1 -1
  48. package/dist/chunks/manifest-PaF9B8Vt.cjs.map +1 -1
  49. package/dist/chunks/{player-48Zy_NBG.js → player-BfHMNtiM.js} +4 -4
  50. package/dist/chunks/{player-48Zy_NBG.js.map → player-BfHMNtiM.js.map} +1 -1
  51. package/dist/chunks/player-C4y4jXSv.cjs.map +1 -1
  52. package/dist/chunks/presets-BYBVJVeP.js.map +1 -1
  53. package/dist/chunks/presets-CUHys3sK.cjs.map +1 -1
  54. package/dist/chunks/{registry-gFJRpPES.js → registry-BKzyg1JV.js} +2 -2
  55. package/dist/chunks/{registry-gFJRpPES.js.map → registry-BKzyg1JV.js.map} +1 -1
  56. package/dist/chunks/{registry-BIEjKngP.js → registry-CT-TT_bx.js} +3 -3
  57. package/dist/chunks/{registry-BIEjKngP.js.map → registry-CT-TT_bx.js.map} +1 -1
  58. package/dist/chunks/{registry-eJgpFAzI.cjs → registry-tzwKkldE.cjs} +2 -2
  59. package/dist/chunks/{registry-eJgpFAzI.cjs.map → registry-tzwKkldE.cjs.map} +1 -1
  60. package/dist/chunks/registry-xQZnSqqV.cjs.map +1 -1
  61. package/dist/chunks/shared-CkKHWrtJ.js.map +1 -1
  62. package/dist/chunks/shared-jkgRH-Hx.cjs.map +1 -1
  63. package/dist/chunks/{spring-CZDNyqWp.js → spring-BHuP55DR.js} +2 -2
  64. package/dist/chunks/{spring-CZDNyqWp.js.map → spring-BHuP55DR.js.map} +1 -1
  65. package/dist/chunks/spring-BlTQD2AV.cjs.map +1 -1
  66. package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -1
  67. package/dist/chunks/stagger-DtMKo2SK.js.map +1 -1
  68. package/dist/chunks/{ticker-CM_56oVy.js → ticker-C8lSGml9.js} +2 -2
  69. package/dist/chunks/{ticker-CM_56oVy.js.map → ticker-C8lSGml9.js.map} +1 -1
  70. package/dist/chunks/{ticker-D4o6enH0.cjs → ticker-Un0bvTWR.cjs} +2 -2
  71. package/dist/chunks/{ticker-D4o6enH0.cjs.map → ticker-Un0bvTWR.cjs.map} +1 -1
  72. package/dist/chunks/{tween-CqX1JBuj.js → tween-BcejKpsx.js} +15 -91
  73. package/dist/chunks/tween-BcejKpsx.js.map +1 -0
  74. package/dist/chunks/{tween-CBuWYpI-.cjs → tween-CwLLC3Ko.cjs} +15 -95
  75. package/dist/chunks/tween-CwLLC3Ko.cjs.map +1 -0
  76. package/dist/chunks/variants-CrDDJoYK.cjs.map +1 -1
  77. package/dist/chunks/{variants-GU3yIL4F.js → variants-CsRGUIyA.js} +2 -2
  78. package/dist/chunks/{variants-GU3yIL4F.js.map → variants-CsRGUIyA.js.map} +1 -1
  79. package/dist/components/a11y.cjs.map +1 -1
  80. package/dist/components/a11y.js +2 -2
  81. package/dist/components/a11y.js.map +1 -1
  82. package/dist/components/angular.cjs.map +1 -1
  83. package/dist/components/angular.js +8 -8
  84. package/dist/components/angular.js.map +1 -1
  85. package/dist/components/background.cjs.map +1 -1
  86. package/dist/components/background.js +2 -2
  87. package/dist/components/background.js.map +1 -1
  88. package/dist/components/bridge.cjs.map +1 -1
  89. package/dist/components/bridge.js +1 -1
  90. package/dist/components/bridge.js.map +1 -1
  91. package/dist/components/cards.cjs.map +1 -1
  92. package/dist/components/cards.js +2 -2
  93. package/dist/components/cards.js.map +1 -1
  94. package/dist/components/click.cjs.map +1 -1
  95. package/dist/components/click.js +3 -3
  96. package/dist/components/click.js.map +1 -1
  97. package/dist/components/core.cjs.map +1 -1
  98. package/dist/components/core.js.map +1 -1
  99. package/dist/components/depth.cjs.map +1 -1
  100. package/dist/components/depth.js +3 -3
  101. package/dist/components/depth.js.map +1 -1
  102. package/dist/components/design.cjs.map +1 -1
  103. package/dist/components/design.js +3 -3
  104. package/dist/components/design.js.map +1 -1
  105. package/dist/components/dsl.cjs.map +1 -1
  106. package/dist/components/dsl.js +2 -2
  107. package/dist/components/dsl.js.map +1 -1
  108. package/dist/components/effects.cjs.map +1 -1
  109. package/dist/components/effects.js +9 -9
  110. package/dist/components/effects.js.map +1 -1
  111. package/dist/components/engine.cjs.map +1 -1
  112. package/dist/components/engine.js +2 -2
  113. package/dist/components/engine.js.map +1 -1
  114. package/dist/components/feedback.cjs.map +1 -1
  115. package/dist/components/feedback.js +1 -1
  116. package/dist/components/feedback.js.map +1 -1
  117. package/dist/components/fx-3d.cjs.map +1 -1
  118. package/dist/components/fx-3d.js +2 -2
  119. package/dist/components/fx-3d.js.map +1 -1
  120. package/dist/components/fx-ai.cjs.map +1 -1
  121. package/dist/components/fx-ai.js +2 -2
  122. package/dist/components/fx-ai.js.map +1 -1
  123. package/dist/components/fx-chart.cjs.map +1 -1
  124. package/dist/components/fx-chart.js +2 -2
  125. package/dist/components/fx-chart.js.map +1 -1
  126. package/dist/components/fx-cinema.cjs.map +1 -1
  127. package/dist/components/fx-cinema.js +2 -2
  128. package/dist/components/fx-cinema.js.map +1 -1
  129. package/dist/components/fx-cyber.cjs.map +1 -1
  130. package/dist/components/fx-cyber.js +2 -2
  131. package/dist/components/fx-cyber.js.map +1 -1
  132. package/dist/components/fx-festival.cjs.map +1 -1
  133. package/dist/components/fx-festival.js +2 -2
  134. package/dist/components/fx-festival.js.map +1 -1
  135. package/dist/components/fx-focus.cjs.map +1 -1
  136. package/dist/components/fx-focus.js +2 -2
  137. package/dist/components/fx-focus.js.map +1 -1
  138. package/dist/components/fx-form.cjs.map +1 -1
  139. package/dist/components/fx-form.js +2 -2
  140. package/dist/components/fx-form.js.map +1 -1
  141. package/dist/components/fx-game.cjs.map +1 -1
  142. package/dist/components/fx-game.js +2 -2
  143. package/dist/components/fx-game.js.map +1 -1
  144. package/dist/components/fx-genart.cjs.map +1 -1
  145. package/dist/components/fx-genart.js +2 -2
  146. package/dist/components/fx-genart.js.map +1 -1
  147. package/dist/components/fx-geo.cjs.map +1 -1
  148. package/dist/components/fx-geo.js +2 -2
  149. package/dist/components/fx-geo.js.map +1 -1
  150. package/dist/components/fx-gesture.cjs.map +1 -1
  151. package/dist/components/fx-gesture.js +2 -2
  152. package/dist/components/fx-gesture.js.map +1 -1
  153. package/dist/components/fx-gpu.js +3 -3
  154. package/dist/components/fx-light.cjs.map +1 -1
  155. package/dist/components/fx-light.js +2 -2
  156. package/dist/components/fx-light.js.map +1 -1
  157. package/dist/components/fx-lottie.cjs.map +1 -1
  158. package/dist/components/fx-lottie.js +2 -2
  159. package/dist/components/fx-lottie.js.map +1 -1
  160. package/dist/components/fx-morph.cjs.map +1 -1
  161. package/dist/components/fx-morph.js +2 -2
  162. package/dist/components/fx-morph.js.map +1 -1
  163. package/dist/components/fx-music.cjs.map +1 -1
  164. package/dist/components/fx-music.js +3 -3
  165. package/dist/components/fx-music.js.map +1 -1
  166. package/dist/components/fx-organic.cjs.map +1 -1
  167. package/dist/components/fx-organic.js +2 -2
  168. package/dist/components/fx-organic.js.map +1 -1
  169. package/dist/components/fx-paper.cjs.map +1 -1
  170. package/dist/components/fx-paper.js +2 -2
  171. package/dist/components/fx-paper.js.map +1 -1
  172. package/dist/components/fx-perf.cjs.map +1 -1
  173. package/dist/components/fx-perf.js +2 -2
  174. package/dist/components/fx-perf.js.map +1 -1
  175. package/dist/components/fx-physics.cjs.map +1 -1
  176. package/dist/components/fx-physics.js +2 -2
  177. package/dist/components/fx-physics.js.map +1 -1
  178. package/dist/components/fx-retro.cjs.map +1 -1
  179. package/dist/components/fx-retro.js +2 -2
  180. package/dist/components/fx-retro.js.map +1 -1
  181. package/dist/components/fx-safe.cjs.map +1 -1
  182. package/dist/components/fx-safe.js +2 -2
  183. package/dist/components/fx-safe.js.map +1 -1
  184. package/dist/components/fx-shop.cjs.map +1 -1
  185. package/dist/components/fx-shop.js +2 -2
  186. package/dist/components/fx-shop.js.map +1 -1
  187. package/dist/components/fx-social.cjs.map +1 -1
  188. package/dist/components/fx-social.js +2 -2
  189. package/dist/components/fx-social.js.map +1 -1
  190. package/dist/components/fx-spatial.cjs.map +1 -1
  191. package/dist/components/fx-spatial.js +2 -2
  192. package/dist/components/fx-spatial.js.map +1 -1
  193. package/dist/components/fx-surface.cjs.map +1 -1
  194. package/dist/components/fx-surface.js +2 -2
  195. package/dist/components/fx-surface.js.map +1 -1
  196. package/dist/components/fx-text.cjs.map +1 -1
  197. package/dist/components/fx-text.js +2 -2
  198. package/dist/components/fx-text.js.map +1 -1
  199. package/dist/components/fx-transitions.cjs.map +1 -1
  200. package/dist/components/fx-transitions.js +3 -3
  201. package/dist/components/fx-transitions.js.map +1 -1
  202. package/dist/components/fx-video.cjs.map +1 -1
  203. package/dist/components/fx-video.js +2 -2
  204. package/dist/components/fx-video.js.map +1 -1
  205. package/dist/components/fx-weather.cjs.map +1 -1
  206. package/dist/components/fx-weather.js +2 -2
  207. package/dist/components/fx-weather.js.map +1 -1
  208. package/dist/components/fx.cjs.map +1 -1
  209. package/dist/components/fx.js +6 -6
  210. package/dist/components/fx.js.map +1 -1
  211. package/dist/components/fx2.cjs.map +1 -1
  212. package/dist/components/fx2.js +6 -6
  213. package/dist/components/fx2.js.map +1 -1
  214. package/dist/components/gesture.cjs.map +1 -1
  215. package/dist/components/gesture.js +4 -4
  216. package/dist/components/gesture.js.map +1 -1
  217. package/dist/components/interaction.cjs.map +1 -1
  218. package/dist/components/interaction.js +1 -1
  219. package/dist/components/interaction.js.map +1 -1
  220. package/dist/components/layout.cjs.map +1 -1
  221. package/dist/components/layout.js +1 -1
  222. package/dist/components/layout.js.map +1 -1
  223. package/dist/components/lazy.cjs.map +1 -1
  224. package/dist/components/lazy.js.map +1 -1
  225. package/dist/components/lite.cjs.map +1 -1
  226. package/dist/components/lite.js.map +1 -1
  227. package/dist/components/marketplace.cjs.map +1 -1
  228. package/dist/components/marketplace.js +4 -4
  229. package/dist/components/marketplace.js.map +1 -1
  230. package/dist/components/native.cjs.map +1 -1
  231. package/dist/components/native.js +3 -3
  232. package/dist/components/native.js.map +1 -1
  233. package/dist/components/packs.cjs.map +1 -1
  234. package/dist/components/packs.js +1 -1
  235. package/dist/components/packs.js.map +1 -1
  236. package/dist/components/page.cjs.map +1 -1
  237. package/dist/components/page.js +3 -3
  238. package/dist/components/page.js.map +1 -1
  239. package/dist/components/perf.cjs.map +1 -1
  240. package/dist/components/perf.js +2 -2
  241. package/dist/components/perf.js.map +1 -1
  242. package/dist/components/physics.cjs.map +1 -1
  243. package/dist/components/physics.js +3 -3
  244. package/dist/components/physics.js.map +1 -1
  245. package/dist/components/plugins.cjs.map +1 -1
  246. package/dist/components/plugins.js +4 -4
  247. package/dist/components/plugins.js.map +1 -1
  248. package/dist/components/react.cjs.map +1 -1
  249. package/dist/components/react.js.map +1 -1
  250. package/dist/components/reveal.cjs.map +1 -1
  251. package/dist/components/reveal.js +1 -1
  252. package/dist/components/reveal.js.map +1 -1
  253. package/dist/components/solid.cjs.map +1 -1
  254. package/dist/components/solid.js +8 -8
  255. package/dist/components/solid.js.map +1 -1
  256. package/dist/components/svelte.cjs.map +1 -1
  257. package/dist/components/svelte.js +8 -8
  258. package/dist/components/svelte.js.map +1 -1
  259. package/dist/components/svg.cjs.map +1 -1
  260. package/dist/components/svg.js +1 -1
  261. package/dist/components/svg.js.map +1 -1
  262. package/dist/components/text.cjs.map +1 -1
  263. package/dist/components/text.js +2 -2
  264. package/dist/components/text.js.map +1 -1
  265. package/dist/components/timeline.cjs.map +1 -1
  266. package/dist/components/timeline.js +3 -3
  267. package/dist/components/timeline.js.map +1 -1
  268. package/dist/components/tokens.cjs.map +1 -1
  269. package/dist/components/tokens.js.map +1 -1
  270. package/dist/components/transitions.cjs.map +1 -1
  271. package/dist/components/transitions.js +1 -1
  272. package/dist/components/transitions.js.map +1 -1
  273. package/dist/components/ui.cjs.map +1 -1
  274. package/dist/components/ui.js +4 -4
  275. package/dist/components/ui.js.map +1 -1
  276. package/dist/components/vue.cjs.map +1 -1
  277. package/dist/components/vue.js +8 -8
  278. package/dist/components/vue.js.map +1 -1
  279. package/dist/components/webgl.cjs.map +1 -1
  280. package/dist/components/webgl.js +1 -1
  281. package/dist/components/webgl.js.map +1 -1
  282. package/dist/components/widgets.cjs +766 -212
  283. package/dist/components/widgets.cjs.map +1 -1
  284. package/dist/components/widgets.d.cts +207 -2
  285. package/dist/components/widgets.d.ts +207 -2
  286. package/dist/components/widgets.js +770 -221
  287. package/dist/components/widgets.js.map +1 -1
  288. package/dist/components.cjs.map +1 -1
  289. package/dist/components.js +10 -10
  290. package/dist/components.js.map +1 -1
  291. package/dist/element.cjs.map +1 -1
  292. package/dist/element.js.map +1 -1
  293. package/dist/index.cjs.map +1 -1
  294. package/dist/index.js +2 -2
  295. package/dist/index.js.map +1 -1
  296. package/dist/llms-full.txt +250 -1
  297. package/dist/llms.txt +13 -2
  298. package/dist/manifest.json +646 -1
  299. package/dist/presets/extended.cjs.map +1 -1
  300. package/dist/presets/extended.js.map +1 -1
  301. package/dist/react.cjs.map +1 -1
  302. package/dist/react.js.map +1 -1
  303. package/dist/runtime/format-apng.cjs +131 -0
  304. package/dist/runtime/format-apng.cjs.map +1 -0
  305. package/dist/runtime/format-apng.d.cts +250 -0
  306. package/dist/runtime/format-apng.d.ts +250 -0
  307. package/dist/runtime/format-apng.iife.js +2 -0
  308. package/dist/runtime/format-apng.iife.js.map +1 -0
  309. package/dist/runtime/format-apng.js +123 -0
  310. package/dist/runtime/format-apng.js.map +1 -0
  311. package/dist/runtime/format-css.cjs +5 -4
  312. package/dist/runtime/format-css.cjs.map +1 -1
  313. package/dist/runtime/format-css.js +5 -4
  314. package/dist/runtime/format-css.js.map +1 -1
  315. package/dist/runtime/format-gif.cjs +206 -0
  316. package/dist/runtime/format-gif.cjs.map +1 -0
  317. package/dist/runtime/format-gif.d.cts +223 -0
  318. package/dist/runtime/format-gif.d.ts +223 -0
  319. package/dist/runtime/format-gif.iife.js +2 -0
  320. package/dist/runtime/format-gif.iife.js.map +1 -0
  321. package/dist/runtime/format-gif.js +199 -0
  322. package/dist/runtime/format-gif.js.map +1 -0
  323. package/dist/runtime/format-motion.cjs +9 -8
  324. package/dist/runtime/format-motion.cjs.map +1 -1
  325. package/dist/runtime/format-motion.js +5 -4
  326. package/dist/runtime/format-motion.js.map +1 -1
  327. package/dist/runtime/format-sprite.cjs +226 -0
  328. package/dist/runtime/format-sprite.cjs.map +1 -0
  329. package/dist/runtime/format-sprite.d.cts +224 -0
  330. package/dist/runtime/format-sprite.d.ts +224 -0
  331. package/dist/runtime/format-sprite.iife.js +2 -0
  332. package/dist/runtime/format-sprite.iife.js.map +1 -0
  333. package/dist/runtime/format-sprite.js +216 -0
  334. package/dist/runtime/format-sprite.js.map +1 -0
  335. package/dist/runtime/format-svg.cjs +5 -4
  336. package/dist/runtime/format-svg.cjs.map +1 -1
  337. package/dist/runtime/format-svg.iife.js.map +1 -1
  338. package/dist/runtime/format-svg.js +4 -3
  339. package/dist/runtime/format-svg.js.map +1 -1
  340. package/dist/runtime/format-webp.cjs +123 -0
  341. package/dist/runtime/format-webp.cjs.map +1 -0
  342. package/dist/runtime/format-webp.d.cts +245 -0
  343. package/dist/runtime/format-webp.d.ts +245 -0
  344. package/dist/runtime/format-webp.iife.js +2 -0
  345. package/dist/runtime/format-webp.iife.js.map +1 -0
  346. package/dist/runtime/format-webp.js +115 -0
  347. package/dist/runtime/format-webp.js.map +1 -0
  348. package/dist/runtime/scroll.cjs +2 -2
  349. package/dist/runtime/scroll.cjs.map +1 -1
  350. package/dist/runtime/scroll.js +2 -2
  351. package/dist/runtime/scroll.js.map +1 -1
  352. package/dist/runtime/smooth.cjs +284 -0
  353. package/dist/runtime/smooth.cjs.map +1 -0
  354. package/dist/runtime/smooth.d.cts +137 -0
  355. package/dist/runtime/smooth.d.ts +137 -0
  356. package/dist/runtime/smooth.iife.js +2 -0
  357. package/dist/runtime/smooth.iife.js.map +1 -0
  358. package/dist/runtime/smooth.js +279 -0
  359. package/dist/runtime/smooth.js.map +1 -0
  360. package/dist/runtime/text.cjs +147 -0
  361. package/dist/runtime/text.cjs.map +1 -0
  362. package/dist/runtime/text.d.cts +65 -0
  363. package/dist/runtime/text.d.ts +65 -0
  364. package/dist/runtime/text.iife.js +2 -0
  365. package/dist/runtime/text.iife.js.map +1 -0
  366. package/dist/runtime/text.js +143 -0
  367. package/dist/runtime/text.js.map +1 -0
  368. package/dist/runtime.cjs +9 -8
  369. package/dist/runtime.cjs.map +1 -1
  370. package/dist/runtime.d.cts +9 -2
  371. package/dist/runtime.d.ts +9 -2
  372. package/dist/runtime.iife.js +1 -1
  373. package/dist/runtime.iife.js.map +1 -1
  374. package/dist/runtime.js +6 -5
  375. package/dist/runtime.js.map +1 -1
  376. package/dist/solid.cjs.map +1 -1
  377. package/dist/solid.js.map +1 -1
  378. package/dist/svelte.cjs.map +1 -1
  379. package/dist/svelte.js.map +1 -1
  380. package/dist/vue.cjs.map +1 -1
  381. package/dist/vue.js.map +1 -1
  382. package/dist/widgets.umd.js +1 -1
  383. package/dist/widgets.umd.js.map +1 -1
  384. package/docs/ROADMAP.md +2 -2
  385. package/docs/components/README.md +12 -7
  386. package/docs/components/usa-parallax-layers.md +38 -0
  387. package/docs/components/usa-route-transition.md +38 -0
  388. package/docs/components/usa-scroll-ring.md +32 -0
  389. package/docs/components/usa-smooth-scroll.md +60 -0
  390. package/docs/components/usa-text-splitter.md +60 -0
  391. package/docs/components.md +94 -0
  392. package/docs/mcp.md +50 -0
  393. package/docs/runtime/format-apng.md +59 -0
  394. package/docs/runtime/format-gif.md +60 -0
  395. package/docs/runtime/format-sprite.md +60 -0
  396. package/docs/runtime/format-webp.md +58 -0
  397. package/docs/runtime/smooth.md +60 -0
  398. package/docs/runtime/text.md +59 -0
  399. package/package.json +64 -2
  400. package/dist/chunks/keyframes-W-474DMc.js.map +0 -1
  401. package/dist/chunks/keyframes-ZheOkpt0.cjs.map +0 -1
  402. package/dist/chunks/tween-CBuWYpI-.cjs.map +0 -1
  403. package/dist/chunks/tween-CqX1JBuj.js.map +0 -1
@@ -0,0 +1,199 @@
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-CT-TT_bx.js';
2
+ import { a as animatedImagePlayer, u as u8, c as composeFrames, d as bytesOf, f as fixDelay } from '../chunks/anim-image-DDdb9q3X.js';
3
+ import '../chunks/tween-BcejKpsx.js';
4
+ import '../chunks/ticker-C8lSGml9.js';
5
+ import '../chunks/ease-XN8_0sXu.js';
6
+
7
+ /**
8
+ * `motionary/runtime/format-gif` (10.4) — a complete GIF decoder written for
9
+ * Motionary (own LZW implementation, no dependencies, no DOM): GIF87a / GIF89a,
10
+ * global and local palettes, transparency, interlaced frames, disposal
11
+ * methods 0–3, per-frame delays and the NETSCAPE2.0 loop count. Frames are
12
+ * composited to full-size RGBA, so they can be drawn, scrubbed or reversed
13
+ * with `animatedImagePlayer()` (a runtime timeline).
14
+ *
15
+ * ```ts
16
+ * import { use } from 'motionary/runtime';
17
+ * import { formatGif, loadGif, animatedImagePlayer } from 'motionary/runtime/format-gif';
18
+ * use(formatGif);
19
+ * const gif = await loadGif('/loader.gif');
20
+ * const player = animatedImagePlayer(canvas, gif); // player.pause(); player.progress = 0.5
21
+ * ```
22
+ */
23
+ /** LZW-decode GIF image data into palette indices (exported for tests / tools). */
24
+ function lzwDecode(minCodeSize, data, pixelCount) {
25
+ const out = new Uint8Array(pixelCount);
26
+ const clear = 1 << minCodeSize, eoi = clear + 1;
27
+ const prefix = new Uint16Array(4096), suffix = new Uint8Array(4096), stack = new Uint8Array(4097);
28
+ let size = minCodeSize + 1, mask = (1 << size) - 1, next = eoi + 1;
29
+ let old = -1, first = 0, bits = 0, acc = 0, op = 0, pos = 0;
30
+ for (let i = 0; i < clear; i++)
31
+ suffix[i] = i;
32
+ while (op < pixelCount) {
33
+ while (bits < size) {
34
+ if (pos >= data.length)
35
+ return out; // truncated data: keep what we have
36
+ acc |= data[pos++] << bits;
37
+ bits += 8;
38
+ }
39
+ const code = acc & mask;
40
+ acc >>>= size;
41
+ bits -= size;
42
+ if (code === clear) {
43
+ size = minCodeSize + 1;
44
+ mask = (1 << size) - 1;
45
+ next = eoi + 1;
46
+ old = -1;
47
+ continue;
48
+ }
49
+ if (code === eoi)
50
+ break;
51
+ if (old === -1) {
52
+ out[op++] = suffix[code];
53
+ old = first = code;
54
+ continue;
55
+ }
56
+ let c = code, sp = 0;
57
+ if (code >= next) {
58
+ stack[sp++] = first;
59
+ c = old;
60
+ }
61
+ while (c >= clear) {
62
+ stack[sp++] = suffix[c];
63
+ c = prefix[c];
64
+ }
65
+ first = suffix[c];
66
+ stack[sp++] = first;
67
+ while (sp && op < pixelCount)
68
+ out[op++] = stack[--sp];
69
+ if (next < 4096) {
70
+ prefix[next] = old;
71
+ suffix[next] = first;
72
+ next++;
73
+ if (next > mask && size < 12) {
74
+ size++;
75
+ mask = (1 << size) - 1;
76
+ }
77
+ }
78
+ old = code;
79
+ }
80
+ return out;
81
+ }
82
+ const DISPOSE = ['none', 'none', 'background', 'previous'];
83
+ /** Decode a GIF (bytes) into composited RGBA frames. Pure: no DOM, works in workers / Node. */
84
+ function decodeGif(input) {
85
+ const b = u8(input);
86
+ const sig = String.fromCharCode(...b.subarray(0, 6));
87
+ if (sig !== 'GIF87a' && sig !== 'GIF89a')
88
+ throw new Error('[motionary] format-gif: not a GIF file');
89
+ const width = b[6] | (b[7] << 8), height = b[8] | (b[9] << 8), flags = b[10];
90
+ let p = 13, gct = null;
91
+ if (flags & 0x80) {
92
+ const n = 3 << ((flags & 7) + 1);
93
+ gct = b.subarray(p, p + n);
94
+ p += n;
95
+ }
96
+ const parts = [];
97
+ let loopCount = null, delay = 0, transparent = -1, disposal = 0;
98
+ const blocks = () => {
99
+ const chunks = [];
100
+ let len = 0;
101
+ while (p < b.length) {
102
+ const n = b[p++];
103
+ if (!n)
104
+ break;
105
+ chunks.push(b.subarray(p, p + n));
106
+ len += n;
107
+ p += n;
108
+ }
109
+ const outB = new Uint8Array(len);
110
+ let o = 0;
111
+ for (const c of chunks) {
112
+ outB.set(c, o);
113
+ o += c.length;
114
+ }
115
+ return outB;
116
+ };
117
+ while (p < b.length) {
118
+ const t = b[p++];
119
+ if (t === 0x3b)
120
+ break; // trailer
121
+ if (t === 0x21) {
122
+ const label = b[p++];
123
+ if (label === 0xf9) {
124
+ const d = blocks();
125
+ disposal = (d[0] >> 2) & 7;
126
+ delay = (d[1] | (d[2] << 8)) * 10;
127
+ transparent = d[0] & 1 ? d[3] : -1;
128
+ }
129
+ else if (label === 0xff) {
130
+ const id = String.fromCharCode(...b.subarray(p + 1, p + 12));
131
+ const d = blocks();
132
+ if ((id === 'NETSCAPE2.0' || id === 'ANIMEXTS1.0') && d.length >= 14 && d[11] === 1)
133
+ loopCount = d[12] | (d[13] << 8);
134
+ }
135
+ else
136
+ blocks();
137
+ continue;
138
+ }
139
+ if (t !== 0x2c)
140
+ break; // unknown block: stop (corrupt tail)
141
+ const x = b[p] | (b[p + 1] << 8), y = b[p + 2] | (b[p + 3] << 8), w = b[p + 4] | (b[p + 5] << 8), h = b[p + 6] | (b[p + 7] << 8), f = b[p + 8];
142
+ p += 9;
143
+ let pal = gct;
144
+ if (f & 0x80) {
145
+ const n = 3 << ((f & 7) + 1);
146
+ pal = b.subarray(p, p + n);
147
+ p += n;
148
+ }
149
+ const minCode = b[p++];
150
+ const idx = lzwDecode(minCode, blocks(), w * h);
151
+ const rows = new Uint32Array(h);
152
+ if (f & 0x40) {
153
+ // interlaced: rows come in 4 passes (every 8th from 0, every 8th from 4, every 4th from 2, every 2nd from 1)
154
+ let r = 0;
155
+ for (const [start, step] of [[0, 8], [4, 8], [2, 4], [1, 2]])
156
+ for (let yy = start; yy < h; yy += step)
157
+ rows[r++] = yy;
158
+ }
159
+ else
160
+ for (let yy = 0; yy < h; yy++)
161
+ rows[yy] = yy;
162
+ const data = new Uint8ClampedArray(w * h * 4);
163
+ for (let r = 0; r < h; r++) {
164
+ const dy = rows[r];
165
+ for (let xx = 0; xx < w; xx++) {
166
+ const ci = idx[r * w + xx], o = (dy * w + xx) * 4;
167
+ if (ci === transparent || !pal || ci * 3 + 2 >= pal.length)
168
+ continue;
169
+ data[o] = pal[ci * 3];
170
+ data[o + 1] = pal[ci * 3 + 1];
171
+ data[o + 2] = pal[ci * 3 + 2];
172
+ data[o + 3] = 255;
173
+ }
174
+ }
175
+ parts.push({ x, y, image: { width: w, height: h, data }, delay: fixDelay(delay), blend: 'over', dispose: DISPOSE[disposal] || 'none' });
176
+ delay = 0;
177
+ transparent = -1;
178
+ disposal = 0;
179
+ }
180
+ // like browsers, "restore to background" clears to transparent
181
+ const frames = composeFrames(width, height, parts);
182
+ return {
183
+ format: 'gif',
184
+ width,
185
+ height,
186
+ plays: loopCount === null ? 1 : loopCount === 0 ? 0 : loopCount + 1,
187
+ frames,
188
+ info: { version: sig.slice(3), width, height, loopCount, frameCount: frames.length },
189
+ };
190
+ }
191
+ /** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode a GIF. */
192
+ async function loadGif(src) {
193
+ return decodeGif(await bytesOf(src));
194
+ }
195
+ /** The module object for `use(formatGif)`. */
196
+ const formatGif = { id: 'format-gif', version: RUNTIME_VERSION, requires: ['core'], api: { decodeGif, loadGif, lzwDecode, animatedImagePlayer } };
197
+
198
+ export { animatedImagePlayer, composeFrames, decodeGif, formatGif, loadGif, lzwDecode };
199
+ //# sourceMappingURL=format-gif.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-gif.js","sources":["../../src/runtime/format-gif.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-gif` (10.4) — a complete GIF decoder written for\n * Motionary (own LZW implementation, no dependencies, no DOM): GIF87a / GIF89a,\n * global and local palettes, transparency, interlaced frames, disposal\n * methods 0–3, per-frame delays and the NETSCAPE2.0 loop count. Frames are\n * composited to full-size RGBA, so they can be drawn, scrubbed or reversed\n * with `animatedImagePlayer()` (a runtime timeline).\n *\n * ```ts\n * import { use } from 'motionary/runtime';\n * import { formatGif, loadGif, animatedImagePlayer } from 'motionary/runtime/format-gif';\n * use(formatGif);\n * const gif = await loadGif('/loader.gif');\n * const player = animatedImagePlayer(canvas, gif); // player.pause(); player.progress = 0.5\n * ```\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { composeFrames, fixDelay, bytesOf, animatedImagePlayer, u8, type AnimatedImage, type FramePart } from './anim-image';\n\nexport type { AnimatedImage, AnimFrame, Rgba, AnimPlayer, AnimPlayerOptions } from './anim-image';\nexport { animatedImagePlayer, composeFrames } from './anim-image';\n\n/** LZW-decode GIF image data into palette indices (exported for tests / tools). */\nexport function lzwDecode(minCodeSize: number, data: Uint8Array, pixelCount: number): Uint8Array {\n const out = new Uint8Array(pixelCount);\n const clear = 1 << minCodeSize, eoi = clear + 1;\n const prefix = new Uint16Array(4096), suffix = new Uint8Array(4096), stack = new Uint8Array(4097);\n let size = minCodeSize + 1, mask = (1 << size) - 1, next = eoi + 1;\n let old = -1, first = 0, bits = 0, acc = 0, op = 0, pos = 0;\n for (let i = 0; i < clear; i++) suffix[i] = i;\n while (op < pixelCount) {\n while (bits < size) {\n if (pos >= data.length) return out; // truncated data: keep what we have\n acc |= data[pos++] << bits;\n bits += 8;\n }\n const code = acc & mask;\n acc >>>= size;\n bits -= size;\n if (code === clear) {\n size = minCodeSize + 1; mask = (1 << size) - 1; next = eoi + 1; old = -1;\n continue;\n }\n if (code === eoi) break;\n if (old === -1) {\n out[op++] = suffix[code];\n old = first = code;\n continue;\n }\n let c = code, sp = 0;\n if (code >= next) {\n stack[sp++] = first;\n c = old;\n }\n while (c >= clear) {\n stack[sp++] = suffix[c];\n c = prefix[c];\n }\n first = suffix[c];\n stack[sp++] = first;\n while (sp && op < pixelCount) out[op++] = stack[--sp];\n if (next < 4096) {\n prefix[next] = old;\n suffix[next] = first;\n next++;\n if (next > mask && size < 12) {\n size++;\n mask = (1 << size) - 1;\n }\n }\n old = code;\n }\n return out;\n}\n\nexport interface GifInfo {\n version: '87a' | '89a';\n width: number;\n height: number;\n /** NETSCAPE2.0 loop count (0 = forever), or null when the file has none (plays once). */\n loopCount: number | null;\n frameCount: number;\n}\n\nconst DISPOSE: FramePart['dispose'][] = ['none', 'none', 'background', 'previous'];\n\n/** Decode a GIF (bytes) into composited RGBA frames. Pure: no DOM, works in workers / Node. */\nexport function decodeGif(input: Uint8Array | ArrayBuffer): AnimatedImage & { info: GifInfo } {\n const b = u8(input);\n const sig = String.fromCharCode(...b.subarray(0, 6));\n if (sig !== 'GIF87a' && sig !== 'GIF89a') throw new Error('[motionary] format-gif: not a GIF file');\n const width = b[6] | (b[7] << 8), height = b[8] | (b[9] << 8), flags = b[10];\n let p = 13, gct: Uint8Array | null = null;\n if (flags & 0x80) {\n const n = 3 << ((flags & 7) + 1);\n gct = b.subarray(p, p + n);\n p += n;\n }\n const parts: FramePart[] = [];\n let loopCount: number | null = null, delay = 0, transparent = -1, disposal = 0;\n const blocks = (): Uint8Array => {\n const chunks: Uint8Array[] = [];\n let len = 0;\n while (p < b.length) {\n const n = b[p++];\n if (!n) break;\n chunks.push(b.subarray(p, p + n));\n len += n;\n p += n;\n }\n const outB = new Uint8Array(len);\n let o = 0;\n for (const c of chunks) {\n outB.set(c, o);\n o += c.length;\n }\n return outB;\n };\n while (p < b.length) {\n const t = b[p++];\n if (t === 0x3b) break; // trailer\n if (t === 0x21) {\n const label = b[p++];\n if (label === 0xf9) {\n const d = blocks();\n disposal = (d[0] >> 2) & 7;\n delay = (d[1] | (d[2] << 8)) * 10;\n transparent = d[0] & 1 ? d[3] : -1;\n } else if (label === 0xff) {\n const id = String.fromCharCode(...b.subarray(p + 1, p + 12));\n const d = blocks();\n if ((id === 'NETSCAPE2.0' || id === 'ANIMEXTS1.0') && d.length >= 14 && d[11] === 1) loopCount = d[12] | (d[13] << 8);\n } else blocks();\n continue;\n }\n if (t !== 0x2c) break; // unknown block: stop (corrupt tail)\n const x = b[p] | (b[p + 1] << 8), y = b[p + 2] | (b[p + 3] << 8), w = b[p + 4] | (b[p + 5] << 8), h = b[p + 6] | (b[p + 7] << 8), f = b[p + 8];\n p += 9;\n let pal = gct;\n if (f & 0x80) {\n const n = 3 << ((f & 7) + 1);\n pal = b.subarray(p, p + n);\n p += n;\n }\n const minCode = b[p++];\n const idx = lzwDecode(minCode, blocks(), w * h);\n const rows = new Uint32Array(h);\n if (f & 0x40) {\n // interlaced: rows come in 4 passes (every 8th from 0, every 8th from 4, every 4th from 2, every 2nd from 1)\n let r = 0;\n for (const [start, step] of [[0, 8], [4, 8], [2, 4], [1, 2]]) for (let yy = start; yy < h; yy += step) rows[r++] = yy;\n } else for (let yy = 0; yy < h; yy++) rows[yy] = yy;\n const data = new Uint8ClampedArray(w * h * 4);\n for (let r = 0; r < h; r++) {\n const dy = rows[r];\n for (let xx = 0; xx < w; xx++) {\n const ci = idx[r * w + xx], o = (dy * w + xx) * 4;\n if (ci === transparent || !pal || ci * 3 + 2 >= pal.length) continue;\n data[o] = pal[ci * 3]; data[o + 1] = pal[ci * 3 + 1]; data[o + 2] = pal[ci * 3 + 2]; data[o + 3] = 255;\n }\n }\n parts.push({ x, y, image: { width: w, height: h, data }, delay: fixDelay(delay), blend: 'over', dispose: DISPOSE[disposal] || 'none' });\n delay = 0; transparent = -1; disposal = 0;\n }\n // like browsers, \"restore to background\" clears to transparent\n const frames = composeFrames(width, height, parts);\n return {\n format: 'gif',\n width,\n height,\n plays: loopCount === null ? 1 : loopCount === 0 ? 0 : loopCount + 1,\n frames,\n info: { version: sig.slice(3) as '87a' | '89a', width, height, loopCount, frameCount: frames.length },\n };\n}\n\n/** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode a GIF. */\nexport async function loadGif(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<AnimatedImage & { info: GifInfo }> {\n return decodeGif(await bytesOf(src));\n}\n\nexport interface FormatGifApi {\n decodeGif: typeof decodeGif;\n loadGif: typeof loadGif;\n lzwDecode: typeof lzwDecode;\n animatedImagePlayer: typeof animatedImagePlayer;\n}\n\n/** The module object for `use(formatGif)`. */\nexport const formatGif: RuntimeModule<FormatGifApi> = { id: 'format-gif', version: RUNTIME_VERSION, requires: ['core'], api: { decodeGif, loadGif, lzwDecode, animatedImagePlayer } };\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAOH;SACgB,SAAS,CAAC,WAAmB,EAAE,IAAgB,EAAE,UAAkB,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,IA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AC,GAAG,CAAC,CAAC;AACtC;AASA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE;;"}
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-eJgpFAzI.cjs');
4
- var tween = require('../chunks/tween-CBuWYpI-.cjs');
5
- var keyframes = require('../chunks/keyframes-ZheOkpt0.cjs');
6
- require('../chunks/ticker-D4o6enH0.cjs');
3
+ var registry = require('../chunks/registry-tzwKkldE.cjs');
4
+ var tween = require('../chunks/tween-CwLLC3Ko.cjs');
5
+ var ease = require('../chunks/ease-HwYZnZat.cjs');
6
+ var keyframes = require('../chunks/keyframes-tC3I7anQ.cjs');
7
+ require('../chunks/ticker-Un0bvTWR.cjs');
7
8
 
8
9
  /**
9
10
  * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
@@ -29,13 +30,13 @@ const NAMES = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', ease
29
30
  /** A Motion ease → runtime ease. */
30
31
  function motionEase(e) {
31
32
  if (Array.isArray(e))
32
- return tween.cubicBezier(e[0], e[1], e[2], e[3]);
33
+ return ease.cubicBezier(e[0], e[1], e[2], e[3]);
33
34
  if (!e)
34
- return tween.EASES['cubic-out'];
35
+ return ease.EASES['cubic-out'];
35
36
  const n = NAMES[e] || e;
36
- if (!tween.EASES[n])
37
+ if (!ease.EASES[n])
37
38
  throw new Error(`[motionary] format-motion: unknown ease "${e}"`);
38
- return tween.EASES[n];
39
+ return ease.EASES[n];
39
40
  }
40
41
  /** Simulate a damped spring (unit step) → [ease, duration ms]. */
41
42
  function springEase(o) {
@@ -1 +1 @@
1
- {"version":3,"file":"format-motion.cjs","sources":["../../src/runtime/format-motion.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n"],"names":["cubicBezier","EASES","Timeline","framesToTimeline","RUNTIME_VERSION"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA2BH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE;AAE9R;AACM,SAAU,UAAU,CAAC,CAAgC,EAAA;AACzD,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAOA,iBAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAOC,WAAK,CAAC,WAAW,CAAC;IACjC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACvB,IAAA,IAAI,CAACA,WAAK,CAAC,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA,CAAA,CAAG,CAAC;AAChF,IAAA,OAAOA,WAAK,CAAC,CAAC,CAAC;AACjB;AAEA;AACM,SAAU,UAAU,CAAC,CAA8F,EAAA;AACvH,IAAA,IAAI,CAAC,GAA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,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,KAAK,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;AACpJ,QAAA,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACvC;IACA,IAAI,CAAC,CAAC,CAAC,MAAM;QAAE,EAAE,CAAC,IAAI,EAAE;AACxB,IAAA,OAAO,EAAE;AACX;AASA;AACO,MAAM,YAAY,GAAmC,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;;;;;;;;"}
1
+ {"version":3,"file":"format-motion.cjs","sources":["../../src/runtime/format-motion.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n"],"names":["cubicBezier","EASES","Timeline","framesToTimeline","RUNTIME_VERSION"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA2BH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,E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,8 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-BIEjKngP.js';
2
- import { c as cubicBezier, E as EASES, T as Timeline } from '../chunks/tween-CqX1JBuj.js';
3
- import { f as framesToTimeline } from '../chunks/keyframes-W-474DMc.js';
4
- import '../chunks/ticker-CM_56oVy.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-CT-TT_bx.js';
2
+ import { T as Timeline } from '../chunks/tween-BcejKpsx.js';
3
+ import { c as cubicBezier, E as EASES } from '../chunks/ease-XN8_0sXu.js';
4
+ import { f as framesToTimeline } from '../chunks/keyframes-B5PWe5bU.js';
5
+ import '../chunks/ticker-C8lSGml9.js';
5
6
 
6
7
  /**
7
8
  * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
@@ -1 +1 @@
1
- {"version":3,"file":"format-motion.js","sources":["../../src/runtime/format-motion.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA2BH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE;AAE9R;AACM,SAAU,UAAU,CAAC,CAAgC,EAAA;AACzD,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO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AAA,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC/E,aAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;AAAE,YAAA,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,IAAqC,CAAC;QAC/H,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,KAAK,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,CAAC;AACxD,QAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,KAAK,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;AACpJ,QAAA,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACvC;IACA,IAAI,CAAC,CAAC,CAAC,MAAM;QAAE,EAAE,CAAC,IAAI,EAAE;AACxB,IAAA,OAAO,EAAE;AACX;AASA;AACO,MAAM,YAAY,GAAmC,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;;;;"}
1
+ {"version":3,"file":"format-motion.js","sources":["../../src/runtime/format-motion.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA2BH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE;AAE9R;AACM,SAAU,UAAU,CAAC,CAAgC,EAAA;AACzD,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,WAAW,CAAC;IACjC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACvB,IAAA,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA,CAAA,CAAG,CAAC;AAChF,IAAA,OAAO,KAAK,CAAC,CAAC,CAAC;AACjB;AAEA;AACM,SAAU,UAAU,CAAC,CAA8F,EAAA;AACvH,IAAA,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,IAAI,EAAE;AAC/C,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC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,CAAC,UAAU,EAAE,CAAC;AACpJ,QAAA,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACvC;IACA,IAAI,CAAC,CAAC,CAAC,MAAM;QAAE,EAAE,CAAC,IAAI,EAAE;AACxB,IAAA,OAAO,EAAE;AACX;AASA;AACO,MAAM,YAAY,GAAmC,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;;"}
@@ -0,0 +1,226 @@
1
+ 'use strict';
2
+
3
+ var registry = require('../chunks/registry-tzwKkldE.cjs');
4
+ var tween = require('../chunks/tween-CwLLC3Ko.cjs');
5
+ require('../chunks/ticker-Un0bvTWR.cjs');
6
+ require('../chunks/ease-HwYZnZat.cjs');
7
+
8
+ /**
9
+ * `motionary/runtime/format-sprite` (10.3) — sprite sheets and image
10
+ * sequences on the runtime timeline (original implementation).
11
+ *
12
+ * - `parseSpriteSheet(json)` — TexturePacker JSON (hash and array), Aseprite
13
+ * JSON (hash and array, per-frame `duration`, `meta.frameTags` with
14
+ * `forward` / `reverse` / `pingpong` directions) and the generic
15
+ * `{ frames: [{ x, y, w, h }] }` shape; trimmed frames (`spriteSourceSize` /
16
+ * `sourceSize`) and rotated frames are supported.
17
+ * - `gridSheet(cols, rows, w, h, n?)` — a plain grid sheet.
18
+ * - `frameOrder(sheet, tag?)` — the playback order of a tag (pingpong without repeating the ends).
19
+ * - `spritePlayer(target, sheet, image, { tag, fps })` — a runtime `Playable`
20
+ * that draws frames onto a `<canvas>` or moves the background of an element.
21
+ * - `imageSequence('frame_{0001}.webp', { start, end })`, `preloadImages(urls)`,
22
+ * `sequencePlayer(canvas, images, { fps })` — numbered image sequences,
23
+ * scrubbable (`player.progress = p`, e.g. from a scroll scene).
24
+ * Parsing works without the DOM (SSR / workers); players need a canvas / element.
25
+ */
26
+ const num = (v, d = 0) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
27
+ /** Parse a sprite-sheet JSON (object or string). */
28
+ function parseSpriteSheet(input) {
29
+ const j = typeof input === 'string' ? JSON.parse(input) : input;
30
+ if (!j || !j.frames)
31
+ throw new Error('[motionary] format-sprite: no "frames" in the sprite sheet JSON');
32
+ const meta = j.meta || {};
33
+ const aseprite = /aseprite/i.test(meta.app || '') || Array.isArray(meta.frameTags);
34
+ const entries = Array.isArray(j.frames) ? j.frames.map((f, i) => [f.filename ?? f.name ?? String(i), f]) : Object.entries(j.frames);
35
+ const frames = entries.map(([name, f]) => {
36
+ const r = f.frame || f;
37
+ const rotated = !!f.rotated;
38
+ const sss = f.spriteSourceSize || { x: 0, y: 0 };
39
+ const ss = f.sourceSize || { w: r.w, h: r.h };
40
+ const out = { name, x: num(r.x), y: num(r.y), w: num(r.w), h: num(r.h), rotated, offsetX: num(sss.x), offsetY: num(sss.y), sourceW: num(ss.w, r.w), sourceH: num(ss.h, r.h) };
41
+ if (typeof f.duration === 'number')
42
+ out.duration = f.duration;
43
+ return out;
44
+ });
45
+ if (!Array.isArray(j.frames) && !aseprite)
46
+ frames.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
47
+ const tags = (meta.frameTags || []).map((t) => ({ name: t.name, from: num(t.from), to: num(t.to), direction: t.direction || 'forward' }));
48
+ return { frames, tags, image: meta.image, size: meta.size, format: aseprite ? 'aseprite' : meta.app || j.meta ? 'texturepacker' : 'generic' };
49
+ }
50
+ /** A grid sheet: `cols × rows` cells of `w × h` (first `n` cells). */
51
+ function gridSheet(cols, rows, w, h, n = cols * rows) {
52
+ const frames = [];
53
+ for (let i = 0; i < n; i++)
54
+ frames.push({ name: String(i), x: (i % cols) * w, y: Math.floor(i / cols) * h, w, h, rotated: false, offsetX: 0, offsetY: 0, sourceW: w, sourceH: h });
55
+ return { frames, tags: [], format: 'generic' };
56
+ }
57
+ /** Frame indices for a tag (or the whole sheet). */
58
+ function frameOrder(sheet, tag) {
59
+ const t = tag ? sheet.tags.find((x) => x.name === tag) : undefined;
60
+ if (tag && !t)
61
+ throw new Error(`[motionary] format-sprite: unknown tag "${tag}" (have: ${sheet.tags.map((x) => x.name).join(', ') || 'none'})`);
62
+ const from = t ? t.from : 0, to = t ? t.to : sheet.frames.length - 1;
63
+ const fwd = Array.from({ length: to - from + 1 }, (_, i) => from + i);
64
+ const dir = t?.direction || 'forward';
65
+ if (dir === 'reverse')
66
+ return fwd.reverse();
67
+ if (dir === 'pingpong')
68
+ return [...fwd, ...fwd.slice(1, -1).reverse()];
69
+ if (dir === 'pingpong_reverse') {
70
+ const r = fwd.reverse();
71
+ return [...r, ...r.slice(1, -1).reverse()];
72
+ }
73
+ return fwd;
74
+ }
75
+ /** Draw one frame onto a 2D context at (dx, dy), honouring trim offsets and rotation. */
76
+ function drawFrame(ctx, image, f, dx = 0, dy = 0, scale = 1) {
77
+ ctx.save();
78
+ ctx.translate(dx + f.offsetX * scale, dy + f.offsetY * scale);
79
+ if (f.rotated) {
80
+ // TexturePacker stores rotated frames 90° clockwise: w/h are the unrotated size
81
+ ctx.rotate(-Math.PI / 2);
82
+ ctx.drawImage(image, f.x, f.y, f.h, f.w, -f.h * scale, 0, f.h * scale, f.w * scale);
83
+ }
84
+ else
85
+ ctx.drawImage(image, f.x, f.y, f.w, f.h, 0, 0, f.w * scale, f.h * scale);
86
+ ctx.restore();
87
+ }
88
+ /** Plays a list of frames (by index) with per-frame durations. */
89
+ class FramePlayable extends tween.Playable {
90
+ constructor() {
91
+ super(...arguments);
92
+ this.times = [0];
93
+ this.order = [];
94
+ this.current = -1;
95
+ }
96
+ setOrder(order, dur) {
97
+ this.order = order;
98
+ this.times = [0];
99
+ for (const i of order)
100
+ this.times.push(this.times[this.times.length - 1] + dur(i));
101
+ }
102
+ get duration() {
103
+ return this.times[this.times.length - 1];
104
+ }
105
+ /** Index into `order` at a local time. */
106
+ indexAt(ms) {
107
+ let lo = 0, hi = this.order.length - 1;
108
+ while (lo < hi) {
109
+ const mid = (lo + hi + 1) >> 1;
110
+ if (this.times[mid] <= ms)
111
+ lo = mid;
112
+ else
113
+ hi = mid - 1;
114
+ }
115
+ return Math.min(lo, this.order.length - 1);
116
+ }
117
+ renderLocal(ms) {
118
+ const k = this.order[this.indexAt(Math.min(ms, this.duration - 0.001))];
119
+ if (k === this.current)
120
+ return;
121
+ this.current = k;
122
+ this.show(k);
123
+ }
124
+ /** The frame index currently shown. */
125
+ get frame() {
126
+ return this.current;
127
+ }
128
+ }
129
+ class SpritePlayer extends FramePlayable {
130
+ constructor(target, sheet, image, o) {
131
+ super({ repeat: o.repeat ?? -1, yoyo: o.yoyo });
132
+ this.target = target;
133
+ this.sheet = sheet;
134
+ this.image = image;
135
+ const fps = o.fps || 12;
136
+ this.setOrder(frameOrder(sheet, o.tag), (i) => sheet.frames[i].duration ?? 1000 / fps);
137
+ this.scale = o.scale;
138
+ if (!o.paused)
139
+ this.play();
140
+ }
141
+ show(i) {
142
+ const f = this.sheet.frames[i];
143
+ const t = this.target;
144
+ if (typeof t.getContext === 'function' && typeof this.image !== 'string') {
145
+ const ctx = t.getContext('2d');
146
+ if (!ctx)
147
+ return;
148
+ const s = this.scale ?? t.width / (f.sourceW || f.w || 1);
149
+ ctx.clearRect(0, 0, t.width, t.height);
150
+ drawFrame(ctx, this.image, f, 0, 0, s);
151
+ }
152
+ else {
153
+ const el = this.target;
154
+ if (typeof this.image === 'string')
155
+ el.style.backgroundImage = `url("${this.image}")`;
156
+ el.style.backgroundPosition = `${-f.x}px ${-f.y}px`;
157
+ el.style.width = `${f.w}px`;
158
+ el.style.height = `${f.h}px`;
159
+ el.style.backgroundRepeat = 'no-repeat';
160
+ }
161
+ }
162
+ }
163
+ /** Play a sprite sheet on a canvas (image = loaded image / bitmap) or an element's background (image = URL). */
164
+ function spritePlayer(target, sheet, image, o = {}) {
165
+ return new SpritePlayer(target, sheet, image, o);
166
+ }
167
+ /** 'frame_{0001}.webp' + { start: 1, end: 3 } → frame_0001.webp, frame_0002.webp, frame_0003.webp ('{1}' = no padding). */
168
+ function imageSequence(pattern, o) {
169
+ const m = /\{(\d+)\}/.exec(pattern);
170
+ if (!m)
171
+ throw new Error('[motionary] format-sprite: the pattern needs a {0001}-style placeholder');
172
+ const pad = m[1].length;
173
+ const out = [];
174
+ for (let i = o.start ?? (+m[1] || 0); i <= o.end; i += o.step || 1)
175
+ out.push(pattern.replace(m[0], String(i).padStart(pad, '0')));
176
+ return out;
177
+ }
178
+ /** Load images (resolves when all are decoded; rejects with the failing URL). */
179
+ function preloadImages(urls) {
180
+ return Promise.all(urls.map((u) => new Promise((ok, bad) => {
181
+ const img = new Image();
182
+ img.decoding = 'async';
183
+ img.onload = () => ok(img);
184
+ img.onerror = () => bad(new Error(`[motionary] format-sprite: could not load ${u}`));
185
+ img.src = u;
186
+ })));
187
+ }
188
+ class SequencePlayer extends FramePlayable {
189
+ constructor(canvas, images, o) {
190
+ super({ repeat: o.repeat ?? 0, yoyo: o.yoyo });
191
+ this.canvas = canvas;
192
+ this.images = images;
193
+ const fps = o.fps || 24;
194
+ this.setOrder(images.map((_, i) => i), () => 1000 / fps);
195
+ if (!o.paused)
196
+ this.play();
197
+ }
198
+ show(i) {
199
+ const ctx = this.canvas.getContext('2d');
200
+ const img = this.images[i];
201
+ if (!ctx || !img)
202
+ return;
203
+ const w = this.canvas.width, h = this.canvas.height;
204
+ const iw = img.naturalWidth || img.width || w, ih = img.naturalHeight || img.height || h;
205
+ const s = Math.max(w / iw, h / ih); // cover
206
+ ctx.clearRect(0, 0, w, h);
207
+ ctx.drawImage(img, (w - iw * s) / 2, (h - ih * s) / 2, iw * s, ih * s);
208
+ }
209
+ }
210
+ /** Play (or scrub, via `progress`) an image sequence on a canvas, `object-fit: cover` style. */
211
+ function sequencePlayer(canvas, images, o = {}) {
212
+ return new SequencePlayer(canvas, images, o);
213
+ }
214
+ /** The module object for `use(formatSprite)`. */
215
+ const formatSprite = { id: 'format-sprite', version: registry.RUNTIME_VERSION, requires: ['core'], api: { parseSpriteSheet, gridSheet, frameOrder, drawFrame, spritePlayer, imageSequence, preloadImages, sequencePlayer } };
216
+
217
+ exports.drawFrame = drawFrame;
218
+ exports.formatSprite = formatSprite;
219
+ exports.frameOrder = frameOrder;
220
+ exports.gridSheet = gridSheet;
221
+ exports.imageSequence = imageSequence;
222
+ exports.parseSpriteSheet = parseSpriteSheet;
223
+ exports.preloadImages = preloadImages;
224
+ exports.sequencePlayer = sequencePlayer;
225
+ exports.spritePlayer = spritePlayer;
226
+ //# sourceMappingURL=format-sprite.cjs.map