motionary 10.1.0 → 10.3.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 (290) hide show
  1. package/AGENTS.md +61 -0
  2. package/CHANGELOG.md +36 -0
  3. package/README.md +69 -0
  4. package/dist/chunks/{keyframes-CyH_abhI.js → keyframes-DVAC5sQI.js} +2 -2
  5. package/dist/chunks/{keyframes-CyH_abhI.js.map → keyframes-DVAC5sQI.js.map} +1 -1
  6. package/dist/chunks/{keyframes-cUdsXSXQ.cjs → keyframes-Dw9zwVQa.cjs} +2 -2
  7. package/dist/chunks/{keyframes-cUdsXSXQ.cjs.map → keyframes-Dw9zwVQa.cjs.map} +1 -1
  8. package/dist/chunks/{registry-jF8VIA_9.js → registry-46AAzyeC.js} +2 -2
  9. package/dist/chunks/{registry-jF8VIA_9.js.map → registry-46AAzyeC.js.map} +1 -1
  10. package/dist/chunks/{registry-C0xLNq3-.cjs → registry-CSVil2qJ.cjs} +2 -2
  11. package/dist/chunks/{registry-C0xLNq3-.cjs.map → registry-CSVil2qJ.cjs.map} +1 -1
  12. package/dist/chunks/ticker-COOYAyQy.js +70 -0
  13. package/dist/chunks/ticker-COOYAyQy.js.map +1 -0
  14. package/dist/chunks/ticker-gHv6pNfx.cjs +72 -0
  15. package/dist/chunks/ticker-gHv6pNfx.cjs.map +1 -0
  16. package/dist/chunks/{tween-JEthWrjo.cjs → tween-CFN0WcOb.cjs} +16 -73
  17. package/dist/chunks/tween-CFN0WcOb.cjs.map +1 -0
  18. package/dist/chunks/{tween-DDObu9iA.js → tween-CGyolmzB.js} +16 -72
  19. package/dist/chunks/tween-CGyolmzB.js.map +1 -0
  20. package/dist/components/core.cjs +106 -0
  21. package/dist/components/core.cjs.map +1 -1
  22. package/dist/components/core.d.cts +44 -2
  23. package/dist/components/core.d.ts +44 -2
  24. package/dist/components/core.js +105 -1
  25. package/dist/components/core.js.map +1 -1
  26. package/dist/components/widgets.cjs +602 -198
  27. package/dist/components/widgets.cjs.map +1 -1
  28. package/dist/components/widgets.d.cts +186 -2
  29. package/dist/components/widgets.d.ts +186 -2
  30. package/dist/components/widgets.js +598 -199
  31. package/dist/components/widgets.js.map +1 -1
  32. package/dist/llms-full.txt +194 -1
  33. package/dist/llms.txt +10 -2
  34. package/dist/manifest.json +492 -1
  35. package/dist/runtime/format-css.cjs +4 -3
  36. package/dist/runtime/format-css.cjs.map +1 -1
  37. package/dist/runtime/format-css.js +4 -3
  38. package/dist/runtime/format-css.js.map +1 -1
  39. package/dist/runtime/format-motion.cjs +4 -3
  40. package/dist/runtime/format-motion.cjs.map +1 -1
  41. package/dist/runtime/format-motion.js +4 -3
  42. package/dist/runtime/format-motion.js.map +1 -1
  43. package/dist/runtime/format-sprite.cjs +225 -0
  44. package/dist/runtime/format-sprite.cjs.map +1 -0
  45. package/dist/runtime/format-sprite.d.cts +224 -0
  46. package/dist/runtime/format-sprite.d.ts +224 -0
  47. package/dist/runtime/format-sprite.iife.js +2 -0
  48. package/dist/runtime/format-sprite.iife.js.map +1 -0
  49. package/dist/runtime/format-sprite.js +215 -0
  50. package/dist/runtime/format-sprite.js.map +1 -0
  51. package/dist/runtime/format-svg.cjs +457 -0
  52. package/dist/runtime/format-svg.cjs.map +1 -0
  53. package/dist/runtime/format-svg.d.cts +214 -0
  54. package/dist/runtime/format-svg.d.ts +214 -0
  55. package/dist/runtime/format-svg.iife.js +2 -0
  56. package/dist/runtime/format-svg.iife.js.map +1 -0
  57. package/dist/runtime/format-svg.js +446 -0
  58. package/dist/runtime/format-svg.js.map +1 -0
  59. package/dist/runtime/scroll.cjs +301 -0
  60. package/dist/runtime/scroll.cjs.map +1 -0
  61. package/dist/runtime/scroll.d.cts +236 -0
  62. package/dist/runtime/scroll.d.ts +236 -0
  63. package/dist/runtime/scroll.iife.js +2 -0
  64. package/dist/runtime/scroll.iife.js.map +1 -0
  65. package/dist/runtime/scroll.js +292 -0
  66. package/dist/runtime/scroll.js.map +1 -0
  67. package/dist/runtime/text.cjs +147 -0
  68. package/dist/runtime/text.cjs.map +1 -0
  69. package/dist/runtime/text.d.cts +65 -0
  70. package/dist/runtime/text.d.ts +65 -0
  71. package/dist/runtime/text.iife.js +2 -0
  72. package/dist/runtime/text.iife.js.map +1 -0
  73. package/dist/runtime/text.js +143 -0
  74. package/dist/runtime/text.js.map +1 -0
  75. package/dist/runtime.cjs +5 -4
  76. package/dist/runtime.cjs.map +1 -1
  77. package/dist/runtime.d.cts +9 -2
  78. package/dist/runtime.d.ts +9 -2
  79. package/dist/runtime.iife.js +1 -1
  80. package/dist/runtime.iife.js.map +1 -1
  81. package/dist/runtime.js +5 -4
  82. package/dist/runtime.js.map +1 -1
  83. package/dist/widgets.umd.js +1 -1
  84. package/dist/widgets.umd.js.map +1 -1
  85. package/docs/ROADMAP.md +2 -2
  86. package/docs/ai-prompt-guide.md +54 -0
  87. package/docs/components/README.md +255 -0
  88. package/docs/components/usa-accordion.md +38 -0
  89. package/docs/components/usa-acrylic.md +38 -0
  90. package/docs/components/usa-add-to-cart.md +40 -0
  91. package/docs/components/usa-ambient.md +32 -0
  92. package/docs/components/usa-anim-icon.md +34 -0
  93. package/docs/components/usa-audio.md +38 -0
  94. package/docs/components/usa-aurora.md +36 -0
  95. package/docs/components/usa-auto-animate.md +44 -0
  96. package/docs/components/usa-auto-skeleton.md +38 -0
  97. package/docs/components/usa-avatar-stack.md +38 -0
  98. package/docs/components/usa-back-to-top.md +32 -0
  99. package/docs/components/usa-badge-wall.md +39 -0
  100. package/docs/components/usa-badge.md +36 -0
  101. package/docs/components/usa-bar-chart.md +33 -0
  102. package/docs/components/usa-bg-generator.md +32 -0
  103. package/docs/components/usa-blobs.md +32 -0
  104. package/docs/components/usa-bottom-sheet.md +32 -0
  105. package/docs/components/usa-button.md +78 -0
  106. package/docs/components/usa-card-stack.md +40 -0
  107. package/docs/components/usa-card.md +94 -0
  108. package/docs/components/usa-carousel-3d.md +40 -0
  109. package/docs/components/usa-carousel.md +40 -0
  110. package/docs/components/usa-cart-drawer.md +33 -0
  111. package/docs/components/usa-chapter-nav.md +40 -0
  112. package/docs/components/usa-chat-composer.md +33 -0
  113. package/docs/components/usa-check.md +32 -0
  114. package/docs/components/usa-checkbox.md +32 -0
  115. package/docs/components/usa-click.md +36 -0
  116. package/docs/components/usa-clock-control.md +37 -0
  117. package/docs/components/usa-code-export.md +36 -0
  118. package/docs/components/usa-color-picker.md +32 -0
  119. package/docs/components/usa-command-palette.md +39 -0
  120. package/docs/components/usa-compare.md +38 -0
  121. package/docs/components/usa-countdown.md +32 -0
  122. package/docs/components/usa-counter.md +32 -0
  123. package/docs/components/usa-cube-gallery.md +40 -0
  124. package/docs/components/usa-cube.md +36 -0
  125. package/docs/components/usa-cursor.md +32 -0
  126. package/docs/components/usa-date-picker.md +32 -0
  127. package/docs/components/usa-depth.md +44 -0
  128. package/docs/components/usa-dialog.md +40 -0
  129. package/docs/components/usa-disclosure.md +38 -0
  130. package/docs/components/usa-distort.md +36 -0
  131. package/docs/components/usa-dock.md +40 -0
  132. package/docs/components/usa-dot-network.md +32 -0
  133. package/docs/components/usa-double-tap.md +36 -0
  134. package/docs/components/usa-draggable.md +38 -0
  135. package/docs/components/usa-draw.md +36 -0
  136. package/docs/components/usa-drawer.md +34 -0
  137. package/docs/components/usa-equalizer.md +33 -0
  138. package/docs/components/usa-fab.md +40 -0
  139. package/docs/components/usa-festival-banner.md +32 -0
  140. package/docs/components/usa-field.md +34 -0
  141. package/docs/components/usa-file-drop.md +35 -0
  142. package/docs/components/usa-fullpage.md +38 -0
  143. package/docs/components/usa-fx.md +851 -0
  144. package/docs/components/usa-gauge.md +32 -0
  145. package/docs/components/usa-gen-art.md +32 -0
  146. package/docs/components/usa-gesture-fx.md +36 -0
  147. package/docs/components/usa-gesture-sticker.md +36 -0
  148. package/docs/components/usa-glitch.md +32 -0
  149. package/docs/components/usa-globe.md +33 -0
  150. package/docs/components/usa-gradient-text.md +32 -0
  151. package/docs/components/usa-grain.md +36 -0
  152. package/docs/components/usa-grid-glow.md +36 -0
  153. package/docs/components/usa-gyro-card.md +38 -0
  154. package/docs/components/usa-handwriting.md +32 -0
  155. package/docs/components/usa-hero-video.md +38 -0
  156. package/docs/components/usa-hold.md +32 -0
  157. package/docs/components/usa-hud-panel.md +38 -0
  158. package/docs/components/usa-hydrate.md +42 -0
  159. package/docs/components/usa-icon-morph.md +34 -0
  160. package/docs/components/usa-install-button.md +32 -0
  161. package/docs/components/usa-kanban.md +46 -0
  162. package/docs/components/usa-keyframe-editor.md +37 -0
  163. package/docs/components/usa-kpi.md +32 -0
  164. package/docs/components/usa-leaderboard.md +41 -0
  165. package/docs/components/usa-like.md +32 -0
  166. package/docs/components/usa-liquid-nav.md +36 -0
  167. package/docs/components/usa-liquid.md +36 -0
  168. package/docs/components/usa-loading-bar.md +35 -0
  169. package/docs/components/usa-location-card.md +34 -0
  170. package/docs/components/usa-lottie-icon.md +34 -0
  171. package/docs/components/usa-lottie.md +32 -0
  172. package/docs/components/usa-lyrics.md +38 -0
  173. package/docs/components/usa-magnetic.md +32 -0
  174. package/docs/components/usa-marquee.md +38 -0
  175. package/docs/components/usa-mask-reveal.md +36 -0
  176. package/docs/components/usa-masonry-flow.md +42 -0
  177. package/docs/components/usa-masonry.md +38 -0
  178. package/docs/components/usa-menu-toggle.md +34 -0
  179. package/docs/components/usa-menu.md +44 -0
  180. package/docs/components/usa-message-list.md +39 -0
  181. package/docs/components/usa-milestones.md +40 -0
  182. package/docs/components/usa-modal.md +42 -0
  183. package/docs/components/usa-morph.md +34 -0
  184. package/docs/components/usa-motion-inspector.md +32 -0
  185. package/docs/components/usa-motion-prefs.md +32 -0
  186. package/docs/components/usa-motion-spec.md +32 -0
  187. package/docs/components/usa-motion-switch.md +34 -0
  188. package/docs/components/usa-motion-theme.md +40 -0
  189. package/docs/components/usa-motion.md +42 -0
  190. package/docs/components/usa-music-player.md +36 -0
  191. package/docs/components/usa-native-preview.md +36 -0
  192. package/docs/components/usa-nav-morph.md +40 -0
  193. package/docs/components/usa-navbar.md +36 -0
  194. package/docs/components/usa-notification-bell.md +37 -0
  195. package/docs/components/usa-odometer.md +34 -0
  196. package/docs/components/usa-organic-card.md +36 -0
  197. package/docs/components/usa-otp.md +33 -0
  198. package/docs/components/usa-overscroll.md +36 -0
  199. package/docs/components/usa-pack.md +111 -0
  200. package/docs/components/usa-pagination.md +32 -0
  201. package/docs/components/usa-panorama.md +32 -0
  202. package/docs/components/usa-particles.md +32 -0
  203. package/docs/components/usa-pause-all.md +32 -0
  204. package/docs/components/usa-perf-monitor.md +32 -0
  205. package/docs/components/usa-pinch-zoom.md +36 -0
  206. package/docs/components/usa-player.md +38 -0
  207. package/docs/components/usa-plugin-card.md +61 -0
  208. package/docs/components/usa-plugin-store.md +36 -0
  209. package/docs/components/usa-popover.md +38 -0
  210. package/docs/components/usa-post-fx.md +36 -0
  211. package/docs/components/usa-presence.md +36 -0
  212. package/docs/components/usa-press.md +32 -0
  213. package/docs/components/usa-prize-wheel.md +32 -0
  214. package/docs/components/usa-product-gallery.md +40 -0
  215. package/docs/components/usa-progress-ring.md +38 -0
  216. package/docs/components/usa-progress.md +34 -0
  217. package/docs/components/usa-prop-panel.md +34 -0
  218. package/docs/components/usa-pull-cord.md +32 -0
  219. package/docs/components/usa-pull-refresh.md +37 -0
  220. package/docs/components/usa-radar.md +32 -0
  221. package/docs/components/usa-reactions.md +32 -0
  222. package/docs/components/usa-red-envelope.md +32 -0
  223. package/docs/components/usa-retro-button.md +34 -0
  224. package/docs/components/usa-reveal.md +36 -0
  225. package/docs/components/usa-ripple.md +32 -0
  226. package/docs/components/usa-route-transition.md +38 -0
  227. package/docs/components/usa-scene.md +38 -0
  228. package/docs/components/usa-scramble.md +32 -0
  229. package/docs/components/usa-scroll-highlight.md +34 -0
  230. package/docs/components/usa-scroll-progress.md +36 -0
  231. package/docs/components/usa-scroll-scene.md +66 -0
  232. package/docs/components/usa-scrolly.md +40 -0
  233. package/docs/components/usa-segmented.md +40 -0
  234. package/docs/components/usa-shader.md +74 -0
  235. package/docs/components/usa-sheet.md +42 -0
  236. package/docs/components/usa-shimmer-text.md +32 -0
  237. package/docs/components/usa-shortcut.md +34 -0
  238. package/docs/components/usa-skeleton-reveal.md +42 -0
  239. package/docs/components/usa-skeleton.md +36 -0
  240. package/docs/components/usa-sketch-chart.md +32 -0
  241. package/docs/components/usa-slider.md +32 -0
  242. package/docs/components/usa-sparkline.md +32 -0
  243. package/docs/components/usa-spatial-card.md +40 -0
  244. package/docs/components/usa-spinner.md +34 -0
  245. package/docs/components/usa-splash.md +36 -0
  246. package/docs/components/usa-split-text.md +32 -0
  247. package/docs/components/usa-spotlight.md +40 -0
  248. package/docs/components/usa-spring.md +42 -0
  249. package/docs/components/usa-stagger.md +40 -0
  250. package/docs/components/usa-star-rating.md +34 -0
  251. package/docs/components/usa-stepper.md +42 -0
  252. package/docs/components/usa-sticky-stack.md +40 -0
  253. package/docs/components/usa-sticky-wall.md +40 -0
  254. package/docs/components/usa-stories.md +38 -0
  255. package/docs/components/usa-story.md +80 -0
  256. package/docs/components/usa-suggestion-chips.md +32 -0
  257. package/docs/components/usa-swipe-deck.md +40 -0
  258. package/docs/components/usa-swipeable.md +36 -0
  259. package/docs/components/usa-switch.md +32 -0
  260. package/docs/components/usa-tab-bar.md +46 -0
  261. package/docs/components/usa-tabs.md +40 -0
  262. package/docs/components/usa-terminal.md +38 -0
  263. package/docs/components/usa-text-rotate.md +32 -0
  264. package/docs/components/usa-text-splitter.md +60 -0
  265. package/docs/components/usa-theme-surface.md +36 -0
  266. package/docs/components/usa-theme-switcher.md +32 -0
  267. package/docs/components/usa-tilt.md +36 -0
  268. package/docs/components/usa-timeline.md +40 -0
  269. package/docs/components/usa-tip.md +44 -0
  270. package/docs/components/usa-toast-stack.md +36 -0
  271. package/docs/components/usa-toaster.md +36 -0
  272. package/docs/components/usa-typewriter.md +32 -0
  273. package/docs/components/usa-upload-progress.md +33 -0
  274. package/docs/components/usa-video-card.md +40 -0
  275. package/docs/components/usa-view-switch.md +38 -0
  276. package/docs/components/usa-voice-button.md +33 -0
  277. package/docs/components/usa-volume-knob.md +32 -0
  278. package/docs/components/usa-water-ripple.md +36 -0
  279. package/docs/components/usa-wave-text.md +32 -0
  280. package/docs/components/usa-weather-card.md +32 -0
  281. package/docs/components/usa-worker-canvas.md +32 -0
  282. package/docs/components/usa-xp-bar.md +33 -0
  283. package/docs/components.md +95 -0
  284. package/docs/runtime/format-sprite.md +60 -0
  285. package/docs/runtime/format-svg.md +62 -0
  286. package/docs/runtime/scroll.md +61 -0
  287. package/docs/runtime/text.md +59 -0
  288. package/package.json +45 -3
  289. package/dist/chunks/tween-DDObu9iA.js.map +0 -1
  290. package/dist/chunks/tween-JEthWrjo.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"format-css.js","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;aACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI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AO,EAAE,aAAa,EAAE;;;;"}
1
+ {"version":3,"file":"format-css.js","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;aACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClF;AACA,IAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAC5E;AAEA,SAAS,KAAK,CAAC,IAAY,EAAA;IACzB,MAAM,KAAK,GAA2B,EAAE;AACxC,IAAA,IAAI,MAA0B;;AAE9B,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE;IACvB,MAAM,KAAK,GAAa,EAAE;AAC1B,IAAA,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE;QACrB,IAAI,EAAE,K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AAE;AAC/E,IAAA,CAAC,CAAC;AACJ;AAEA;AACM,SAAU,OAAO,CAAC,MAAe,EAAA;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAe;AACvH;AAEA;AACM,SAAU,aAAa,CAAC,MAAc,EAAE,MAA8B,EAAE,IAA0B,EAAE,EAAA;AACxG,IAAA,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;AACtH;AAUA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;;;"}
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('../chunks/registry-C0xLNq3-.cjs');
4
- var tween = require('../chunks/tween-JEthWrjo.cjs');
5
- var keyframes = require('../chunks/keyframes-cUdsXSXQ.cjs');
3
+ var registry = require('../chunks/registry-CSVil2qJ.cjs');
4
+ var tween = require('../chunks/tween-CFN0WcOb.cjs');
5
+ var keyframes = require('../chunks/keyframes-Dw9zwVQa.cjs');
6
+ require('../chunks/ticker-gHv6pNfx.cjs');
6
7
 
7
8
  /**
8
9
  * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
@@ -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,E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M,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,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,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AU,EAAE;;;;;;;;"}
@@ -1,6 +1,7 @@
1
- import { R as RUNTIME_VERSION } from '../chunks/registry-jF8VIA_9.js';
2
- import { c as cubicBezier, E as EASES, T as Timeline } from '../chunks/tween-DDObu9iA.js';
3
- import { f as framesToTimeline } from '../chunks/keyframes-CyH_abhI.js';
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-46AAzyeC.js';
2
+ import { c as cubicBezier, E as EASES, T as Timeline } from '../chunks/tween-CGyolmzB.js';
3
+ import { f as framesToTimeline } from '../chunks/keyframes-DVAC5sQI.js';
4
+ import '../chunks/ticker-COOYAyQy.js';
4
5
 
5
6
  /**
6
7
  * `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,WAAW,CAAC,CAAC,CAAC,CAAC,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AC,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;AACrB,IAAA,IAAI,CAAC,CAAC,M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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,225 @@
1
+ 'use strict';
2
+
3
+ var registry = require('../chunks/registry-CSVil2qJ.cjs');
4
+ var tween = require('../chunks/tween-CFN0WcOb.cjs');
5
+ require('../chunks/ticker-gHv6pNfx.cjs');
6
+
7
+ /**
8
+ * `motionary/runtime/format-sprite` (10.3) — sprite sheets and image
9
+ * sequences on the runtime timeline (original implementation).
10
+ *
11
+ * - `parseSpriteSheet(json)` — TexturePacker JSON (hash and array), Aseprite
12
+ * JSON (hash and array, per-frame `duration`, `meta.frameTags` with
13
+ * `forward` / `reverse` / `pingpong` directions) and the generic
14
+ * `{ frames: [{ x, y, w, h }] }` shape; trimmed frames (`spriteSourceSize` /
15
+ * `sourceSize`) and rotated frames are supported.
16
+ * - `gridSheet(cols, rows, w, h, n?)` — a plain grid sheet.
17
+ * - `frameOrder(sheet, tag?)` — the playback order of a tag (pingpong without repeating the ends).
18
+ * - `spritePlayer(target, sheet, image, { tag, fps })` — a runtime `Playable`
19
+ * that draws frames onto a `<canvas>` or moves the background of an element.
20
+ * - `imageSequence('frame_{0001}.webp', { start, end })`, `preloadImages(urls)`,
21
+ * `sequencePlayer(canvas, images, { fps })` — numbered image sequences,
22
+ * scrubbable (`player.progress = p`, e.g. from a scroll scene).
23
+ * Parsing works without the DOM (SSR / workers); players need a canvas / element.
24
+ */
25
+ const num = (v, d = 0) => (typeof v === 'number' && Number.isFinite(v) ? v : d);
26
+ /** Parse a sprite-sheet JSON (object or string). */
27
+ function parseSpriteSheet(input) {
28
+ const j = typeof input === 'string' ? JSON.parse(input) : input;
29
+ if (!j || !j.frames)
30
+ throw new Error('[motionary] format-sprite: no "frames" in the sprite sheet JSON');
31
+ const meta = j.meta || {};
32
+ const aseprite = /aseprite/i.test(meta.app || '') || Array.isArray(meta.frameTags);
33
+ const entries = Array.isArray(j.frames) ? j.frames.map((f, i) => [f.filename ?? f.name ?? String(i), f]) : Object.entries(j.frames);
34
+ const frames = entries.map(([name, f]) => {
35
+ const r = f.frame || f;
36
+ const rotated = !!f.rotated;
37
+ const sss = f.spriteSourceSize || { x: 0, y: 0 };
38
+ const ss = f.sourceSize || { w: r.w, h: r.h };
39
+ 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) };
40
+ if (typeof f.duration === 'number')
41
+ out.duration = f.duration;
42
+ return out;
43
+ });
44
+ if (!Array.isArray(j.frames) && !aseprite)
45
+ frames.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
46
+ const tags = (meta.frameTags || []).map((t) => ({ name: t.name, from: num(t.from), to: num(t.to), direction: t.direction || 'forward' }));
47
+ return { frames, tags, image: meta.image, size: meta.size, format: aseprite ? 'aseprite' : meta.app || j.meta ? 'texturepacker' : 'generic' };
48
+ }
49
+ /** A grid sheet: `cols × rows` cells of `w × h` (first `n` cells). */
50
+ function gridSheet(cols, rows, w, h, n = cols * rows) {
51
+ const frames = [];
52
+ for (let i = 0; i < n; i++)
53
+ 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 });
54
+ return { frames, tags: [], format: 'generic' };
55
+ }
56
+ /** Frame indices for a tag (or the whole sheet). */
57
+ function frameOrder(sheet, tag) {
58
+ const t = tag ? sheet.tags.find((x) => x.name === tag) : undefined;
59
+ if (tag && !t)
60
+ throw new Error(`[motionary] format-sprite: unknown tag "${tag}" (have: ${sheet.tags.map((x) => x.name).join(', ') || 'none'})`);
61
+ const from = t ? t.from : 0, to = t ? t.to : sheet.frames.length - 1;
62
+ const fwd = Array.from({ length: to - from + 1 }, (_, i) => from + i);
63
+ const dir = t?.direction || 'forward';
64
+ if (dir === 'reverse')
65
+ return fwd.reverse();
66
+ if (dir === 'pingpong')
67
+ return [...fwd, ...fwd.slice(1, -1).reverse()];
68
+ if (dir === 'pingpong_reverse') {
69
+ const r = fwd.reverse();
70
+ return [...r, ...r.slice(1, -1).reverse()];
71
+ }
72
+ return fwd;
73
+ }
74
+ /** Draw one frame onto a 2D context at (dx, dy), honouring trim offsets and rotation. */
75
+ function drawFrame(ctx, image, f, dx = 0, dy = 0, scale = 1) {
76
+ ctx.save();
77
+ ctx.translate(dx + f.offsetX * scale, dy + f.offsetY * scale);
78
+ if (f.rotated) {
79
+ // TexturePacker stores rotated frames 90° clockwise: w/h are the unrotated size
80
+ ctx.rotate(-Math.PI / 2);
81
+ ctx.drawImage(image, f.x, f.y, f.h, f.w, -f.h * scale, 0, f.h * scale, f.w * scale);
82
+ }
83
+ else
84
+ ctx.drawImage(image, f.x, f.y, f.w, f.h, 0, 0, f.w * scale, f.h * scale);
85
+ ctx.restore();
86
+ }
87
+ /** Plays a list of frames (by index) with per-frame durations. */
88
+ class FramePlayable extends tween.Playable {
89
+ constructor() {
90
+ super(...arguments);
91
+ this.times = [0];
92
+ this.order = [];
93
+ this.current = -1;
94
+ }
95
+ setOrder(order, dur) {
96
+ this.order = order;
97
+ this.times = [0];
98
+ for (const i of order)
99
+ this.times.push(this.times[this.times.length - 1] + dur(i));
100
+ }
101
+ get duration() {
102
+ return this.times[this.times.length - 1];
103
+ }
104
+ /** Index into `order` at a local time. */
105
+ indexAt(ms) {
106
+ let lo = 0, hi = this.order.length - 1;
107
+ while (lo < hi) {
108
+ const mid = (lo + hi + 1) >> 1;
109
+ if (this.times[mid] <= ms)
110
+ lo = mid;
111
+ else
112
+ hi = mid - 1;
113
+ }
114
+ return Math.min(lo, this.order.length - 1);
115
+ }
116
+ renderLocal(ms) {
117
+ const k = this.order[this.indexAt(Math.min(ms, this.duration - 0.001))];
118
+ if (k === this.current)
119
+ return;
120
+ this.current = k;
121
+ this.show(k);
122
+ }
123
+ /** The frame index currently shown. */
124
+ get frame() {
125
+ return this.current;
126
+ }
127
+ }
128
+ class SpritePlayer extends FramePlayable {
129
+ constructor(target, sheet, image, o) {
130
+ super({ repeat: o.repeat ?? -1, yoyo: o.yoyo });
131
+ this.target = target;
132
+ this.sheet = sheet;
133
+ this.image = image;
134
+ const fps = o.fps || 12;
135
+ this.setOrder(frameOrder(sheet, o.tag), (i) => sheet.frames[i].duration ?? 1000 / fps);
136
+ this.scale = o.scale;
137
+ if (!o.paused)
138
+ this.play();
139
+ }
140
+ show(i) {
141
+ const f = this.sheet.frames[i];
142
+ const t = this.target;
143
+ if (typeof t.getContext === 'function' && typeof this.image !== 'string') {
144
+ const ctx = t.getContext('2d');
145
+ if (!ctx)
146
+ return;
147
+ const s = this.scale ?? t.width / (f.sourceW || f.w || 1);
148
+ ctx.clearRect(0, 0, t.width, t.height);
149
+ drawFrame(ctx, this.image, f, 0, 0, s);
150
+ }
151
+ else {
152
+ const el = this.target;
153
+ if (typeof this.image === 'string')
154
+ el.style.backgroundImage = `url("${this.image}")`;
155
+ el.style.backgroundPosition = `${-f.x}px ${-f.y}px`;
156
+ el.style.width = `${f.w}px`;
157
+ el.style.height = `${f.h}px`;
158
+ el.style.backgroundRepeat = 'no-repeat';
159
+ }
160
+ }
161
+ }
162
+ /** Play a sprite sheet on a canvas (image = loaded image / bitmap) or an element's background (image = URL). */
163
+ function spritePlayer(target, sheet, image, o = {}) {
164
+ return new SpritePlayer(target, sheet, image, o);
165
+ }
166
+ /** 'frame_{0001}.webp' + { start: 1, end: 3 } → frame_0001.webp, frame_0002.webp, frame_0003.webp ('{1}' = no padding). */
167
+ function imageSequence(pattern, o) {
168
+ const m = /\{(\d+)\}/.exec(pattern);
169
+ if (!m)
170
+ throw new Error('[motionary] format-sprite: the pattern needs a {0001}-style placeholder');
171
+ const pad = m[1].length;
172
+ const out = [];
173
+ for (let i = o.start ?? (+m[1] || 0); i <= o.end; i += o.step || 1)
174
+ out.push(pattern.replace(m[0], String(i).padStart(pad, '0')));
175
+ return out;
176
+ }
177
+ /** Load images (resolves when all are decoded; rejects with the failing URL). */
178
+ function preloadImages(urls) {
179
+ return Promise.all(urls.map((u) => new Promise((ok, bad) => {
180
+ const img = new Image();
181
+ img.decoding = 'async';
182
+ img.onload = () => ok(img);
183
+ img.onerror = () => bad(new Error(`[motionary] format-sprite: could not load ${u}`));
184
+ img.src = u;
185
+ })));
186
+ }
187
+ class SequencePlayer extends FramePlayable {
188
+ constructor(canvas, images, o) {
189
+ super({ repeat: o.repeat ?? 0, yoyo: o.yoyo });
190
+ this.canvas = canvas;
191
+ this.images = images;
192
+ const fps = o.fps || 24;
193
+ this.setOrder(images.map((_, i) => i), () => 1000 / fps);
194
+ if (!o.paused)
195
+ this.play();
196
+ }
197
+ show(i) {
198
+ const ctx = this.canvas.getContext('2d');
199
+ const img = this.images[i];
200
+ if (!ctx || !img)
201
+ return;
202
+ const w = this.canvas.width, h = this.canvas.height;
203
+ const iw = img.naturalWidth || img.width || w, ih = img.naturalHeight || img.height || h;
204
+ const s = Math.max(w / iw, h / ih); // cover
205
+ ctx.clearRect(0, 0, w, h);
206
+ ctx.drawImage(img, (w - iw * s) / 2, (h - ih * s) / 2, iw * s, ih * s);
207
+ }
208
+ }
209
+ /** Play (or scrub, via `progress`) an image sequence on a canvas, `object-fit: cover` style. */
210
+ function sequencePlayer(canvas, images, o = {}) {
211
+ return new SequencePlayer(canvas, images, o);
212
+ }
213
+ /** The module object for `use(formatSprite)`. */
214
+ const formatSprite = { id: 'format-sprite', version: registry.RUNTIME_VERSION, requires: ['core'], api: { parseSpriteSheet, gridSheet, frameOrder, drawFrame, spritePlayer, imageSequence, preloadImages, sequencePlayer } };
215
+
216
+ exports.drawFrame = drawFrame;
217
+ exports.formatSprite = formatSprite;
218
+ exports.frameOrder = frameOrder;
219
+ exports.gridSheet = gridSheet;
220
+ exports.imageSequence = imageSequence;
221
+ exports.parseSpriteSheet = parseSpriteSheet;
222
+ exports.preloadImages = preloadImages;
223
+ exports.sequencePlayer = sequencePlayer;
224
+ exports.spritePlayer = spritePlayer;
225
+ //# sourceMappingURL=format-sprite.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-sprite.cjs","sources":["../../src/runtime/format-sprite.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-sprite` (10.3) — sprite sheets and image\n * sequences on the runtime timeline (original implementation).\n *\n * - `parseSpriteSheet(json)` — TexturePacker JSON (hash and array), Aseprite\n * JSON (hash and array, per-frame `duration`, `meta.frameTags` with\n * `forward` / `reverse` / `pingpong` directions) and the generic\n * `{ frames: [{ x, y, w, h }] }` shape; trimmed frames (`spriteSourceSize` /\n * `sourceSize`) and rotated frames are supported.\n * - `gridSheet(cols, rows, w, h, n?)` — a plain grid sheet.\n * - `frameOrder(sheet, tag?)` — the playback order of a tag (pingpong without repeating the ends).\n * - `spritePlayer(target, sheet, image, { tag, fps })` — a runtime `Playable`\n * that draws frames onto a `<canvas>` or moves the background of an element.\n * - `imageSequence('frame_{0001}.webp', { start, end })`, `preloadImages(urls)`,\n * `sequencePlayer(canvas, images, { fps })` — numbered image sequences,\n * scrubbable (`player.progress = p`, e.g. from a scroll scene).\n * Parsing works without the DOM (SSR / workers); players need a canvas / element.\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Playable } from './tween';\n\nexport interface SpriteFrame {\n name: string;\n x: number;\n y: number;\n w: number;\n h: number;\n rotated: boolean;\n /** Offset of the trimmed frame inside the original (untrimmed) size. */\n offsetX: number;\n offsetY: number;\n sourceW: number;\n sourceH: number;\n /** ms (Aseprite), or undefined (use the player's fps). */\n duration?: number;\n}\nexport interface SpriteTag {\n name: string;\n from: number;\n to: number;\n direction: 'forward' | 'reverse' | 'pingpong' | 'pingpong_reverse';\n}\nexport interface SpriteSheet {\n frames: SpriteFrame[];\n tags: SpriteTag[];\n image?: string;\n size?: { w: number; h: number };\n format: 'texturepacker' | 'aseprite' | 'generic';\n}\n\nconst num = (v: unknown, d = 0) => (typeof v === 'number' && Number.isFinite(v) ? v : d);\n\n/** Parse a sprite-sheet JSON (object or string). */\nexport function parseSpriteSheet(input: string | Record<string, any>): SpriteSheet {\n const j = typeof input === 'string' ? JSON.parse(input) : input;\n if (!j || !j.frames) throw new Error('[motionary] format-sprite: no \"frames\" in the sprite sheet JSON');\n const meta = j.meta || {};\n const aseprite = /aseprite/i.test(meta.app || '') || Array.isArray(meta.frameTags);\n const entries: [string, any][] = Array.isArray(j.frames) ? j.frames.map((f: any, i: number) => [f.filename ?? f.name ?? String(i), f]) : Object.entries(j.frames);\n const frames = entries.map(([name, f]) => {\n const r = f.frame || f;\n const rotated = !!f.rotated;\n const sss = f.spriteSourceSize || { x: 0, y: 0 };\n const ss = f.sourceSize || { w: r.w, h: r.h };\n const out: SpriteFrame = { 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) };\n if (typeof f.duration === 'number') out.duration = f.duration;\n return out;\n });\n if (!Array.isArray(j.frames) && !aseprite) frames.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));\n const tags: SpriteTag[] = (meta.frameTags || []).map((t: any) => ({ name: t.name, from: num(t.from), to: num(t.to), direction: t.direction || 'forward' }));\n return { frames, tags, image: meta.image, size: meta.size, format: aseprite ? 'aseprite' : meta.app || j.meta ? 'texturepacker' : 'generic' };\n}\n\n/** A grid sheet: `cols × rows` cells of `w × h` (first `n` cells). */\nexport function gridSheet(cols: number, rows: number, w: number, h: number, n = cols * rows): SpriteSheet {\n const frames: SpriteFrame[] = [];\n for (let i = 0; i < n; i++) 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 });\n return { frames, tags: [], format: 'generic' };\n}\n\n/** Frame indices for a tag (or the whole sheet). */\nexport function frameOrder(sheet: SpriteSheet, tag?: string): number[] {\n const t = tag ? sheet.tags.find((x) => x.name === tag) : undefined;\n if (tag && !t) throw new Error(`[motionary] format-sprite: unknown tag \"${tag}\" (have: ${sheet.tags.map((x) => x.name).join(', ') || 'none'})`);\n const from = t ? t.from : 0, to = t ? t.to : sheet.frames.length - 1;\n const fwd = Array.from({ length: to - from + 1 }, (_, i) => from + i);\n const dir = t?.direction || 'forward';\n if (dir === 'reverse') return fwd.reverse();\n if (dir === 'pingpong') return [...fwd, ...fwd.slice(1, -1).reverse()];\n if (dir === 'pingpong_reverse') { const r = fwd.reverse(); return [...r, ...r.slice(1, -1).reverse()]; }\n return fwd;\n}\n\n/** Draw one frame onto a 2D context at (dx, dy), honouring trim offsets and rotation. */\nexport function drawFrame(ctx: CanvasRenderingContext2D, image: CanvasImageSource, f: SpriteFrame, dx = 0, dy = 0, scale = 1): void {\n ctx.save();\n ctx.translate(dx + f.offsetX * scale, dy + f.offsetY * scale);\n if (f.rotated) {\n // TexturePacker stores rotated frames 90° clockwise: w/h are the unrotated size\n ctx.rotate(-Math.PI / 2);\n ctx.drawImage(image, f.x, f.y, f.h, f.w, -f.h * scale, 0, f.h * scale, f.w * scale);\n } else ctx.drawImage(image, f.x, f.y, f.w, f.h, 0, 0, f.w * scale, f.h * scale);\n ctx.restore();\n}\n\n/** Plays a list of frames (by index) with per-frame durations. */\nabstract class FramePlayable extends Playable {\n protected times: number[] = [0];\n protected order: number[] = [];\n protected current = -1;\n protected setOrder(order: number[], dur: (i: number) => number): void {\n this.order = order;\n this.times = [0];\n for (const i of order) this.times.push(this.times[this.times.length - 1] + dur(i));\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n /** Index into `order` at a local time. */\n protected indexAt(ms: number): number {\n let lo = 0, hi = this.order.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= ms) lo = mid;\n else hi = mid - 1;\n }\n return Math.min(lo, this.order.length - 1);\n }\n protected renderLocal(ms: number): void {\n const k = this.order[this.indexAt(Math.min(ms, this.duration - 0.001))];\n if (k === this.current) return;\n this.current = k;\n this.show(k);\n }\n /** The frame index currently shown. */\n get frame(): number {\n return this.current;\n }\n protected abstract show(index: number): void;\n}\n\nexport interface SpritePlayerOptions {\n tag?: string;\n /** Frames per second for frames without their own duration (default 12). */\n fps?: number;\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Canvas only: draw scale (default: fit the canvas width). */\n scale?: number;\n}\n\nclass SpritePlayer extends FramePlayable {\n constructor(private target: HTMLCanvasElement | HTMLElement, private sheet: SpriteSheet, private image: CanvasImageSource | string, o: SpritePlayerOptions) {\n super({ repeat: o.repeat ?? -1, yoyo: o.yoyo });\n const fps = o.fps || 12;\n this.setOrder(frameOrder(sheet, o.tag), (i) => sheet.frames[i].duration ?? 1000 / fps);\n this.scale = o.scale;\n if (!o.paused) this.play();\n }\n private scale?: number;\n protected show(i: number): void {\n const f = this.sheet.frames[i];\n const t = this.target as HTMLCanvasElement;\n if (typeof t.getContext === 'function' && typeof this.image !== 'string') {\n const ctx = t.getContext('2d');\n if (!ctx) return;\n const s = this.scale ?? t.width / (f.sourceW || f.w || 1);\n ctx.clearRect(0, 0, t.width, t.height);\n drawFrame(ctx, this.image, f, 0, 0, s);\n } else {\n const el = this.target as HTMLElement;\n if (typeof this.image === 'string') el.style.backgroundImage = `url(\"${this.image}\")`;\n el.style.backgroundPosition = `${-f.x}px ${-f.y}px`;\n el.style.width = `${f.w}px`;\n el.style.height = `${f.h}px`;\n el.style.backgroundRepeat = 'no-repeat';\n }\n }\n}\n\n/** Play a sprite sheet on a canvas (image = loaded image / bitmap) or an element's background (image = URL). */\nexport function spritePlayer(target: HTMLCanvasElement | HTMLElement, sheet: SpriteSheet, image: CanvasImageSource | string, o: SpritePlayerOptions = {}): Playable & { readonly frame: number } {\n return new SpritePlayer(target, sheet, image, o);\n}\n\n/** 'frame_{0001}.webp' + { start: 1, end: 3 } → frame_0001.webp, frame_0002.webp, frame_0003.webp ('{1}' = no padding). */\nexport function imageSequence(pattern: string, o: { start?: number; end: number; step?: number }): string[] {\n const m = /\\{(\\d+)\\}/.exec(pattern);\n if (!m) throw new Error('[motionary] format-sprite: the pattern needs a {0001}-style placeholder');\n const pad = m[1].length;\n const out: string[] = [];\n for (let i = o.start ?? (+m[1] || 0); i <= o.end; i += o.step || 1) out.push(pattern.replace(m[0], String(i).padStart(pad, '0')));\n return out;\n}\n\n/** Load images (resolves when all are decoded; rejects with the failing URL). */\nexport function preloadImages(urls: string[]): Promise<HTMLImageElement[]> {\n return Promise.all(urls.map((u) => new Promise<HTMLImageElement>((ok, bad) => {\n const img = new Image();\n img.decoding = 'async';\n img.onload = () => ok(img);\n img.onerror = () => bad(new Error(`[motionary] format-sprite: could not load ${u}`));\n img.src = u;\n })));\n}\n\nclass SequencePlayer extends FramePlayable {\n constructor(private canvas: HTMLCanvasElement, private images: CanvasImageSource[], o: { fps?: number; repeat?: number; yoyo?: boolean; paused?: boolean }) {\n super({ repeat: o.repeat ?? 0, yoyo: o.yoyo });\n const fps = o.fps || 24;\n this.setOrder(images.map((_, i) => i), () => 1000 / fps);\n if (!o.paused) this.play();\n }\n protected show(i: number): void {\n const ctx = this.canvas.getContext('2d');\n const img = this.images[i] as any;\n if (!ctx || !img) return;\n const w = this.canvas.width, h = this.canvas.height;\n const iw = img.naturalWidth || img.width || w, ih = img.naturalHeight || img.height || h;\n const s = Math.max(w / iw, h / ih); // cover\n ctx.clearRect(0, 0, w, h);\n ctx.drawImage(img, (w - iw * s) / 2, (h - ih * s) / 2, iw * s, ih * s);\n }\n}\n\n/** Play (or scrub, via `progress`) an image sequence on a canvas, `object-fit: cover` style. */\nexport function sequencePlayer(canvas: HTMLCanvasElement, images: CanvasImageSource[], o: { fps?: number; repeat?: number; yoyo?: boolean; paused?: boolean } = {}): Playable & { readonly frame: number } {\n return new SequencePlayer(canvas, images, o);\n}\n\nexport interface FormatSpriteApi {\n parseSpriteSheet: typeof parseSpriteSheet;\n gridSheet: typeof gridSheet;\n frameOrder: typeof frameOrder;\n drawFrame: typeof drawFrame;\n spritePlayer: typeof spritePlayer;\n imageSequence: typeof imageSequence;\n preloadImages: typeof preloadImages;\n sequencePlayer: typeof sequencePlayer;\n}\n\n/** The module object for `use(formatSprite)`. */\nexport const formatSprite: RuntimeModule<FormatSpriteApi> = { id: 'format-sprite', version: RUNTIME_VERSION, requires: ['core'], api: { parseSpriteSheet, gridSheet, frameOrder, drawFrame, spritePlayer, imageSequence, preloadImages, sequencePlayer } };\n"],"names":["Playable","RUNTIME_VERSION"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;AAiBG;AAiCH,MAAM,GAAG,GAAG,CAAC,CAAU,EAAE,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExF;AACM,SAAU,gBAAgB,CAAC,KAAmC,EAAA;AAClE,IAAA,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK;AAC/D,IAAA,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC;AACvG,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,EAAE;IACzB,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,IAAI,KAAK,CAAC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