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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.js","sources":["../../src/runtime/scroll.ts"],"sourcesContent":["/**\n * `motionary/runtime/scroll` (10.2) — scroll-linked scenes, an original\n * implementation: start / end rules, scrubbing (direct or smoothed), pinning,\n * debug markers, enter / leave callbacks and per-edge actions for a runtime\n * tween or timeline.\n *\n * ```ts\n * import { use, timeline } from 'motionary/runtime';\n * import { scroll, scrollScene } from 'motionary/runtime/scroll';\n * use(scroll);\n * const tl = timeline({ paused: true }).to('.card', { to: { x: 200, rotate: 8 } });\n * scrollScene({ trigger: '.section', start: 'top 80%', end: 'bottom 20%', scrub: 120, pin: true, markers: true, animation: tl });\n * ```\n *\n * Rules: `\"<trigger edge> <viewport edge>\"` where an edge is `top | center | bottom`,\n * a percentage or pixels, optionally `+=N` / `-=N` (e.g. `\"top top+=80\"`);\n * `end` may also be `\"+=600\"` (pixels after start). Horizontal scenes use\n * `left | center | right`. Nothing touches `window` until a scene is created.\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { getTicker } from './ticker';\nimport type { Playable } from './tween';\n\nexport type SceneAction = 'play' | 'pause' | 'resume' | 'reverse' | 'restart' | 'reset' | 'complete' | 'none';\n\nexport interface SceneOptions {\n /** Element (or selector) whose position defines the scene. */\n trigger: Element | string;\n /** Default 'top bottom' (trigger top meets viewport bottom). */\n start?: string;\n /** Default 'bottom top'. `'+=600'` = 600 px after start. */\n end?: string;\n /** Link the animation to the scroll position: `true` (direct) or a smoothing time in ms. */\n scrub?: boolean | number;\n /** Runtime tween / timeline (created `paused: true`). */\n animation?: Playable;\n /** Without scrub: actions on enter, leave, enter back, leave back. Default 'play none none reverse'. */\n actions?: string;\n /** Pin the trigger (or another element) while the scene is active. */\n pin?: boolean | Element | string;\n /** Show start / end markers (debugging). */\n markers?: boolean | { color?: string };\n /** Class toggled on the trigger while active. */\n toggleClass?: string;\n /** Kill after the first forward completion. */\n once?: boolean;\n horizontal?: boolean;\n /** Scroll container (default: the window). */\n scroller?: Element | string;\n onEnter?: (s: ScrollScene) => void;\n onLeave?: (s: ScrollScene) => void;\n onEnterBack?: (s: ScrollScene) => void;\n onLeaveBack?: (s: ScrollScene) => void;\n onUpdate?: (s: ScrollScene) => void;\n onToggle?: (s: ScrollScene) => void;\n}\n\nconst KEYWORDS: Record<string, number> = { top: 0, left: 0, center: 0.5, bottom: 1, right: 1 };\n\n/** One side of a rule ('top', '80%', '120px', 'center+=40') → pixels within `size`. */\nexport function parseEdge(spec: string, size: number): number {\n const m = /^([a-z]+|-?[\\d.]+%|-?[\\d.]+(?:px)?)?\\s*(?:([+-])=\\s*(-?[\\d.]+)(px|%)?)?$/.exec(spec.trim());\n if (!m) throw new Error(`[motionary] scroll: bad edge \"${spec}\"`);\n let v = 0;\n const b = m[1] || '0';\n if (b in KEYWORDS) v = KEYWORDS[b] * size;\n else if (b.endsWith('%')) v = (parseFloat(b) / 100) * size;\n else if (/^-?[\\d.]/.test(b)) v = parseFloat(b);\n else throw new Error(`[motionary] scroll: bad edge \"${spec}\"`);\n if (m[2]) {\n const n = m[4] === '%' ? (parseFloat(m[3]) / 100) * size : parseFloat(m[3]);\n v += m[2] === '+' ? n : -n;\n }\n return v;\n}\n\n/** Scroll offset at which `rule` is met: trigger edge (at `triggerStart`, size `triggerSize`) meets viewport edge. */\nexport function resolveRule(rule: string, triggerStart: number, triggerSize: number, viewport: number): number {\n const parts = rule.trim().split(/\\s+(?![+-]=)/);\n const t = parts[0] ?? 'top';\n const s = parts[1] ?? 'bottom';\n return triggerStart + parseEdge(t, triggerSize) - parseEdge(s, viewport);\n}\n\nconst scenes = new Set<ScrollScene>();\nconst q = (x: Element | string): Element => {\n const el = typeof x === 'string' ? document.querySelector(x) : x;\n if (!el) throw new Error(`[motionary] scroll: element \"${x}\" not found`);\n return el;\n};\n\n/** A scroll scene (see `scrollScene()`). */\nexport class ScrollScene {\n readonly trigger: Element;\n readonly options: SceneOptions;\n /** Scroll offsets (px) of the start and end. */\n start = 0;\n end = 0;\n /** 0 → 1 between start and end. */\n progress = 0;\n /** 1 scrolling forward, -1 back. */\n direction = 1;\n isActive = false;\n private shown = 0;\n private last = -1;\n private offs: (() => void)[] = [];\n private pinEl: HTMLElement | null = null;\n private spacer: HTMLElement | null = null;\n private marks: HTMLElement[] = [];\n private scroller: Element | Window;\n private killed = false;\n\n constructor(o: SceneOptions) {\n if (typeof window === 'undefined') throw new Error('[motionary] scroll scenes need a browser window');\n this.options = o;\n this.trigger = q(o.trigger);\n this.scroller = o.scroller ? q(o.scroller) : window;\n if (o.pin) this.setupPin(o.pin === true ? (this.trigger as HTMLElement) : (q(o.pin) as HTMLElement));\n const target: EventTarget = this.scroller;\n const onScroll = () => this.update();\n target.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('resize', this.refreshBound);\n this.offs.push(() => target.removeEventListener('scroll', onScroll), () => window.removeEventListener('resize', this.refreshBound));\n if (o.scrub && typeof o.scrub === 'number') this.offs.push(getTicker().add((_, dt) => this.smooth(dt)));\n scenes.add(this);\n this.refresh();\n }\n private refreshBound = () => this.refresh();\n\n private pos(): number {\n const s = this.scroller as any;\n if (s === window) return this.options.horizontal ? window.scrollX : window.scrollY;\n return this.options.horizontal ? s.scrollLeft : s.scrollTop;\n }\n private viewport(): number {\n const s = this.scroller as any;\n if (s === window) return this.options.horizontal ? window.innerWidth : window.innerHeight;\n return this.options.horizontal ? s.clientWidth : s.clientHeight;\n }\n\n /** Re-measure start / end (after layout changes). */\n refresh(): void {\n if (this.killed) return;\n const h = !!this.options.horizontal;\n const ref = (this.spacer || this.trigger) as Element;\n const r = ref.getBoundingClientRect();\n const sr = this.scroller === window ? { top: 0, left: 0 } : (this.scroller as Element).getBoundingClientRect();\n const tStart = (h ? r.left - sr.left : r.top - sr.top) + this.pos();\n const tSize = (this.pinEl ? (h ? this.pinEl.offsetWidth : this.pinEl.offsetHeight) : h ? r.width : r.height) || 0;\n const vp = this.viewport();\n this.start = resolveRule(this.options.start || (h ? 'left right' : 'top bottom'), tStart, tSize, vp);\n const e = this.options.end || (h ? 'right left' : 'bottom top');\n this.end = /^\\+=/.test(e.trim()) ? this.start + parseFloat(e.trim().slice(2)) : resolveRule(e, tStart, tSize, vp);\n if (this.end <= this.start) this.end = this.start + 1;\n if (this.spacer && this.pinEl) this.spacer.style[h ? 'paddingRight' : 'paddingBottom'] = `${this.end - this.start}px`;\n this.drawMarkers(vp);\n this.last = -1;\n this.update();\n }\n\n /** Read the scroll position and fire callbacks / drive the animation. */\n update(): void {\n if (this.killed) return;\n const y = this.pos();\n const p = Math.min(1, Math.max(0, (y - this.start) / (this.end - this.start)));\n if (y !== this.last && this.last >= 0) this.direction = y > this.last ? 1 : -1;\n const prev = this.progress;\n const was = this.isActive;\n this.progress = p;\n this.isActive = y > this.start && y < this.end;\n this.last = y;\n const o = this.options;\n if (this.isActive !== was || (prev === 0 && p === 1) || (prev === 1 && p === 0)) {\n const toggles: [keyof SceneOptions, number][] = [];\n if (p > 0 && prev === 0) toggles.push(['onEnter', 0]);\n if (p === 1 && prev < 1) toggles.push(['onLeave', 1]);\n if (p < 1 && prev === 1) toggles.push(['onEnterBack', 2]);\n if (p === 0 && prev > 0) toggles.push(['onLeaveBack', 3]);\n for (const [cb, i] of toggles) {\n (o[cb] as ((s: ScrollScene) => void) | undefined)?.(this);\n if (!o.scrub) this.act(i);\n }\n if (o.toggleClass) this.trigger.classList.toggle(o.toggleClass, this.isActive);\n o.onToggle?.(this);\n if (o.once && p === 1) {\n this.applyPin(1);\n this.kill(true);\n return;\n }\n }\n this.applyPin(p);\n if (o.scrub === true && o.animation) o.animation.progress = p;\n o.onUpdate?.(this);\n }\n\n private smooth(dt: number): void {\n const a = this.options.animation;\n if (!a) return;\n const k = 1 - Math.exp(-dt / Math.max(1, this.options.scrub as number));\n this.shown += (this.progress - this.shown) * k;\n if (Math.abs(this.progress - this.shown) < 0.0005) this.shown = this.progress;\n a.progress = this.shown;\n }\n\n private act(i: number): void {\n const a = this.options.animation;\n if (!a) return;\n const act = ((this.options.actions || 'play none none reverse').split(/\\s+/)[i] || 'none') as SceneAction;\n if (act === 'play') a.play();\n else if (act === 'pause') a.pause();\n else if (act === 'resume') a.play();\n else if (act === 'reverse') a.reverse();\n else if (act === 'restart') a.restart();\n else if (act === 'reset') (a.pause(), a.seek(0));\n else if (act === 'complete') (a.pause(), (a.progress = 1));\n }\n\n private setupPin(el: HTMLElement): void {\n this.pinEl = el;\n const sp = document.createElement('div');\n sp.className = 'usa-pin-spacer';\n sp.style.boxSizing = 'content-box';\n el.parentNode?.insertBefore(sp, el);\n sp.appendChild(el);\n this.spacer = sp;\n this.offs.push(() => {\n el.style.position = el.style.top = el.style.left = el.style.width = el.style.transform = '';\n sp.parentNode?.insertBefore(el, sp);\n sp.remove();\n });\n }\n\n private applyPin(p: number): void {\n const el = this.pinEl, sp = this.spacer;\n if (!el || !sp) return;\n const h = !!this.options.horizontal;\n if (p > 0 && p < 1 && this.scroller === window) {\n const r = sp.getBoundingClientRect();\n const offset = this.start - (h ? r.left + window.scrollX : r.top + window.scrollY);\n el.style.position = 'fixed';\n el.style.width = `${r.width}px`;\n el.style.left = h ? `${-offset}px` : `${r.left}px`;\n el.style.top = h ? `${r.top}px` : `${-offset}px`;\n el.style.transform = '';\n } else {\n el.style.position = el.style.top = el.style.left = el.style.width = '';\n // inside a scroll container (or after the end) pinning is done with a transform\n const d = p >= 1 ? this.end - this.start : p > 0 ? this.pos() - this.start : 0;\n el.style.transform = d ? (h ? `translateX(${d}px)` : `translateY(${d}px)`) : '';\n }\n }\n\n private drawMarkers(vp: number): void {\n this.marks.forEach((m) => m.remove());\n this.marks = [];\n const mk = this.options.markers;\n if (!mk) return;\n const color = (typeof mk === 'object' && mk.color) || '#e11d48';\n const h = !!this.options.horizontal;\n const host = this.scroller === window ? document.body : (this.scroller as HTMLElement);\n const line = (label: string, at: number, fixed: boolean, c: string) => {\n const d = document.createElement('div');\n d.className = 'usa-scroll-marker';\n d.textContent = label;\n d.setAttribute('aria-hidden', 'true');\n Object.assign(d.style, { position: fixed ? 'fixed' : 'absolute', [h ? 'left' : 'top']: `${at}px`, [h ? 'top' : 'right']: '0', [h ? 'height' : 'width']: '80px', [h ? 'borderLeft' : 'borderTop']: `2px solid ${c}`, color: c, font: '600 11px/1.2 ui-monospace,monospace', padding: '2px 4px', zIndex: '2147483646', pointerEvents: 'none', background: 'rgba(255,255,255,.7)' });\n (fixed ? document.body : host).appendChild(d);\n this.marks.push(d);\n };\n const rule = (r: string | undefined, d: string) => (r || d).trim().split(/\\s+(?![+-]=)/)[1] ?? 'bottom';\n line(`start ${this.start | 0}`, this.start, false, color);\n line(`end ${this.end | 0}`, this.end, false, color);\n line('scroller-start', parseEdge(rule(this.options.start, 'top bottom'), vp), true, '#16a34a');\n if (!/^\\+=/.test((this.options.end || '').trim())) line('scroller-end', parseEdge(rule(this.options.end, 'bottom top'), vp), true, '#2563eb');\n }\n\n /** Remove listeners, pin spacer and markers (`keepState` keeps the animation where it is). */\n kill(keepState = false): void {\n if (this.killed) return;\n this.killed = true;\n if (!keepState) this.options.animation?.pause();\n this.offs.splice(0).forEach((f) => f());\n this.marks.forEach((m) => m.remove());\n scenes.delete(this);\n }\n}\n\n/** Create a scroll scene. */\nexport function scrollScene(o: SceneOptions): ScrollScene {\n return new ScrollScene(o);\n}\n/** Re-measure every scene (call after layout changes such as images loading). */\nexport function refreshScenes(): void {\n scenes.forEach((s) => s.refresh());\n}\n/** Kill every scene. */\nexport function killScenes(): void {\n Array.from(scenes).forEach((s) => s.kill());\n}\n/** The live scenes. */\nexport const allScenes = (): ScrollScene[] => Array.from(scenes);\n\nexport interface ScrollApi {\n scrollScene: typeof scrollScene;\n refreshScenes: typeof refreshScenes;\n killScenes: typeof killScenes;\n allScenes: typeof allScenes;\n parseEdge: typeof parseEdge;\n resolveRule: typeof resolveRule;\n ScrollScene: typeof ScrollScene;\n}\n\n/** The module object for `use(scroll)`. */\nexport const scroll: RuntimeModule<ScrollApi> = { id: 'scroll', version: RUNTIME_VERSION, requires: ['core'], api: { scrollScene, refreshScenes, killScenes, allScenes, parseEdge, resolveRule, ScrollScene } };\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;AAkBG;AAuCH,MAAM,QAAQ,GAA2B,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AAE9F;AACM,SAAU,SAAS,CAAC,IAAY,EAAE,IAAY,EAAA;IAClD,MAAM,CAAC,GAAG,0EAA0E,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AACtG,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAA,CAAA,CAAG,CAAC;IACjE,IAAI,CAAC,GAAG,CAAC;IACT,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG;IACrB,IAAI,CAAC,IAAI,QAAQ;AAAE,QAAA,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;AACpC,SAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;QAA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,OAAO,EAAE,CAAC;AACpC;AACA;SACgB,UAAU,GAAA;AACxB,IAAA,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7C;AACA;AACO,MAAM,SAAS,GAAG,MAAqB,KAAK,CAAC,IAAI,CAAC,MAAM;AAY/D;AACO,MAAM,MAAM,GAA6B,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE;;;;"}
@@ -0,0 +1,147 @@
1
+ 'use strict';
2
+
3
+ var registry = require('../chunks/registry-CSVil2qJ.cjs');
4
+
5
+ /**
6
+ * `motionary/runtime/text` (10.3) — split text into characters, words and
7
+ * lines for animation, keeping it accessible (original implementation).
8
+ *
9
+ * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):
10
+ * grapheme clusters via `Intl.Segmenter` when available (emoji, combining
11
+ * marks, CJK stay whole), whitespace-aware words.
12
+ * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text
13
+ * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups
14
+ * words into lines by their rendered position, sets `aria-label` on the
15
+ * element with the original text and hides the pieces from assistive tech.
16
+ * `revert()` restores the original markup; `resplit()` re-measures lines
17
+ * (e.g. after a resize).
18
+ */
19
+ /** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */
20
+ function segment(text, by = 'chars') {
21
+ const Seg = Intl.Segmenter;
22
+ if (by === 'chars') {
23
+ if (Seg)
24
+ return Array.from(new Seg(undefined, { granularity: 'grapheme' }).segment(text), (s) => s.segment);
25
+ return Array.from(text);
26
+ }
27
+ return text.split(/(\s+)/).filter((s) => s !== '');
28
+ }
29
+ const types = (t) => new Set((t || 'chars,words').split(/[\s,]+/).filter(Boolean));
30
+ /** Split an element's text (see module docs). Needs a DOM. */
31
+ function splitText(el, o = {}) {
32
+ if (typeof document === 'undefined')
33
+ throw new Error('[motionary] splitText needs a DOM — use segment() on the server');
34
+ const want = types(o.type);
35
+ const pre = o.className || 'usa-split';
36
+ const original = el.innerHTML;
37
+ const hadLabel = el.getAttribute('aria-label');
38
+ const text = (el.textContent || '').replace(/\s+/g, ' ').trim();
39
+ const chars = [], words = [];
40
+ const mk = (cls, txt) => {
41
+ const s = document.createElement('span');
42
+ s.className = cls;
43
+ s.setAttribute('aria-hidden', 'true');
44
+ s.style.display = 'inline-block';
45
+ if (txt !== undefined)
46
+ s.textContent = txt;
47
+ return s;
48
+ };
49
+ const wantWords = want.has('words') || want.has('lines');
50
+ const walk = (node) => {
51
+ for (const child of Array.from(node.childNodes)) {
52
+ if (child.nodeType === 3) {
53
+ const frag = document.createDocumentFragment();
54
+ for (const part of segment(child.textContent || '', 'words')) {
55
+ if (/^\s+$/.test(part)) {
56
+ frag.appendChild(document.createTextNode(' '));
57
+ continue;
58
+ }
59
+ const w = wantWords ? mk(`${pre}-word`) : null;
60
+ if (want.has('chars')) {
61
+ for (const g of segment(part, 'chars')) {
62
+ const c = mk(`${pre}-char`, g);
63
+ chars.push(c);
64
+ (w || frag).appendChild(c);
65
+ }
66
+ }
67
+ else if (w)
68
+ w.textContent = part;
69
+ else
70
+ frag.appendChild(document.createTextNode(part));
71
+ if (w) {
72
+ words.push(w);
73
+ frag.appendChild(w);
74
+ }
75
+ }
76
+ child.replaceWith(frag);
77
+ }
78
+ else if (child.nodeType === 1 && !child.classList.contains(`${pre}-word`))
79
+ walk(child);
80
+ }
81
+ };
82
+ walk(el);
83
+ if (text && hadLabel === null)
84
+ el.setAttribute('aria-label', text);
85
+ el.setAttribute('data-split', Array.from(want).join(' '));
86
+ const lines = [];
87
+ if (want.has('lines') && words.length) {
88
+ // group words by their rendered top; wrap each group in a line span (flat text only)
89
+ let top = NaN, cur = [];
90
+ const groups = [];
91
+ for (const w of words) {
92
+ const t = Math.round(w.offsetTop);
93
+ if (cur.length && Math.abs(t - top) > 2) {
94
+ groups.push(cur);
95
+ cur = [];
96
+ }
97
+ if (!cur.length)
98
+ top = t;
99
+ cur.push(w);
100
+ }
101
+ if (cur.length)
102
+ groups.push(cur);
103
+ const flat = words.every((w) => w.parentElement === el);
104
+ if (flat) {
105
+ el.textContent = '';
106
+ for (const g of groups) {
107
+ const line = mk(`${pre}-line`);
108
+ line.style.display = 'block';
109
+ g.forEach((w, i) => {
110
+ if (i)
111
+ line.appendChild(document.createTextNode(' '));
112
+ line.appendChild(w);
113
+ });
114
+ lines.push(line);
115
+ el.appendChild(line);
116
+ }
117
+ }
118
+ else
119
+ groups.forEach((g, i) => g.forEach((w) => w.setAttribute('data-line', String(i))));
120
+ }
121
+ if (o.indexVar !== false)
122
+ for (const list of [chars, words, lines])
123
+ list.forEach((s, i) => s.style.setProperty('--i', String(i)));
124
+ const result = {
125
+ chars,
126
+ words: want.has('words') ? words : [],
127
+ lines,
128
+ revert() {
129
+ el.innerHTML = original;
130
+ el.removeAttribute('data-split');
131
+ if (hadLabel === null)
132
+ el.removeAttribute('aria-label');
133
+ },
134
+ resplit() {
135
+ result.revert();
136
+ return splitText(el, o);
137
+ },
138
+ };
139
+ return result;
140
+ }
141
+ /** The module object for `use(text)`. */
142
+ const text = { id: 'text', version: registry.RUNTIME_VERSION, requires: ['core'], api: { segment, splitText } };
143
+
144
+ exports.segment = segment;
145
+ exports.splitText = splitText;
146
+ exports.text = text;
147
+ //# sourceMappingURL=text.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.cjs","sources":["../../src/runtime/text.ts"],"sourcesContent":["/**\n * `motionary/runtime/text` (10.3) — split text into characters, words and\n * lines for animation, keeping it accessible (original implementation).\n *\n * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):\n * grapheme clusters via `Intl.Segmenter` when available (emoji, combining\n * marks, CJK stay whole), whitespace-aware words.\n * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text\n * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups\n * words into lines by their rendered position, sets `aria-label` on the\n * element with the original text and hides the pieces from assistive tech.\n * `revert()` restores the original markup; `resplit()` re-measures lines\n * (e.g. after a resize).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\n\nexport type SplitType = 'chars' | 'words' | 'lines';\n\n/** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */\nexport function segment(text: string, by: 'chars' | 'words' = 'chars'): string[] {\n const Seg = (Intl as any).Segmenter;\n if (by === 'chars') {\n if (Seg) return Array.from(new Seg(undefined, { granularity: 'grapheme' }).segment(text), (s: any) => s.segment as string);\n return Array.from(text);\n }\n return text.split(/(\\s+)/).filter((s) => s !== '');\n}\n\nexport interface SplitOptions {\n /** Any of chars, words, lines (comma / space separated). Default 'chars,words'. */\n type?: string;\n /** Class prefix (default 'usa-split'): pieces get `<prefix>-char`, `-word`, `-line`. */\n className?: string;\n /** Set a `--i` custom property (index) on each piece for CSS staggering (default true). */\n indexVar?: boolean;\n}\n\nexport interface SplitResult {\n chars: HTMLElement[];\n words: HTMLElement[];\n lines: HTMLElement[];\n /** Restore the original markup. */\n revert(): void;\n /** Revert and split again (re-measures lines). */\n resplit(): SplitResult;\n}\n\nconst types = (t?: string): Set<SplitType> => new Set((t || 'chars,words').split(/[\\s,]+/).filter(Boolean) as SplitType[]);\n\n/** Split an element's text (see module docs). Needs a DOM. */\nexport function splitText(el: HTMLElement, o: SplitOptions = {}): SplitResult {\n if (typeof document === 'undefined') throw new Error('[motionary] splitText needs a DOM — use segment() on the server');\n const want = types(o.type);\n const pre = o.className || 'usa-split';\n const original = el.innerHTML;\n const hadLabel = el.getAttribute('aria-label');\n const text = (el.textContent || '').replace(/\\s+/g, ' ').trim();\n const chars: HTMLElement[] = [], words: HTMLElement[] = [];\n const mk = (cls: string, txt?: string) => {\n const s = document.createElement('span');\n s.className = cls;\n s.setAttribute('aria-hidden', 'true');\n s.style.display = 'inline-block';\n if (txt !== undefined) s.textContent = txt;\n return s;\n };\n const wantWords = want.has('words') || want.has('lines');\n const walk = (node: Node) => {\n for (const child of Array.from(node.childNodes)) {\n if (child.nodeType === 3) {\n const frag = document.createDocumentFragment();\n for (const part of segment(child.textContent || '', 'words')) {\n if (/^\\s+$/.test(part)) {\n frag.appendChild(document.createTextNode(' '));\n continue;\n }\n const w = wantWords ? mk(`${pre}-word`) : null;\n if (want.has('chars')) {\n for (const g of segment(part, 'chars')) {\n const c = mk(`${pre}-char`, g);\n chars.push(c);\n (w || frag).appendChild(c);\n }\n } else if (w) w.textContent = part;\n else frag.appendChild(document.createTextNode(part));\n if (w) {\n words.push(w);\n frag.appendChild(w);\n }\n }\n child.replaceWith(frag);\n } else if (child.nodeType === 1 && !(child as Element).classList.contains(`${pre}-word`)) walk(child);\n }\n };\n walk(el);\n if (text && hadLabel === null) el.setAttribute('aria-label', text);\n el.setAttribute('data-split', Array.from(want).join(' '));\n const lines: HTMLElement[] = [];\n if (want.has('lines') && words.length) {\n // group words by their rendered top; wrap each group in a line span (flat text only)\n let top = NaN, cur: HTMLElement[] = [];\n const groups: HTMLElement[][] = [];\n for (const w of words) {\n const t = Math.round(w.offsetTop);\n if (cur.length && Math.abs(t - top) > 2) {\n groups.push(cur);\n cur = [];\n }\n if (!cur.length) top = t;\n cur.push(w);\n }\n if (cur.length) groups.push(cur);\n const flat = words.every((w) => w.parentElement === el);\n if (flat) {\n el.textContent = '';\n for (const g of groups) {\n const line = mk(`${pre}-line`);\n line.style.display = 'block';\n g.forEach((w, i) => {\n if (i) line.appendChild(document.createTextNode(' '));\n line.appendChild(w);\n });\n lines.push(line);\n el.appendChild(line);\n }\n } else groups.forEach((g, i) => g.forEach((w) => w.setAttribute('data-line', String(i))));\n }\n if (o.indexVar !== false) for (const list of [chars, words, lines]) list.forEach((s, i) => s.style.setProperty('--i', String(i)));\n const result: SplitResult = {\n chars,\n words: want.has('words') ? words : [],\n lines,\n revert() {\n el.innerHTML = original;\n el.removeAttribute('data-split');\n if (hadLabel === null) el.removeAttribute('aria-label');\n },\n resplit() {\n result.revert();\n return splitText(el, o);\n },\n };\n return result;\n}\n\nexport interface TextApi {\n segment: typeof segment;\n splitText: typeof splitText;\n}\n\n/** The module object for `use(text)`. */\nexport const text: RuntimeModule<TextApi> = { id: 'text', version: RUNTIME_VERSION, requires: ['core'], api: { segment, splitText } };\n"],"names":["RUNTIME_VERSION"],"mappings":";;;;AAAA;;;;;;;;;;;;;AAaG;AAKH;SACgB,OAAO,CAAC,IAAY,EAAE,KAAwB,OAAO,EAAA;AACnE,IAAA,MAAM,GAAG,GAAI,IAAY,CAAC,SAAS;AACnC,IAAA,IAAI,EAAE,KAAK,OAAO,EAAE;AAClB,QAAA,IAAI,GAAG;AAAE,YAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAM,KAAK,CAAC,CAAC,OAAiB,CAAC;AAC1H,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACzB;AACA,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;AACpD;AAqBA,MAAM,KAAK,GAAG,CAAC,CAAU,KAAqB,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAgB,CAAC;AAE1H;SACgB,SAAS,CAAC,EAAe,EAAE,IAAkB,EAAE,EAAA;IAC7D,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC;IACvH,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,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;AACD,IAAA,OAAO,MAAM;AACf;AAOA;AACO,MAAM,IAAI,GAA2B,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAEA,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;;;;;;"}
@@ -0,0 +1,65 @@
1
+ /** A runtime module: `{ id, version, api }`, registered with `use()`. */
2
+ interface RuntimeModule<A = unknown> {
3
+ /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
4
+ id: string;
5
+ version: string;
6
+ /** Other modules this one needs (registered first by `use()` callers). */
7
+ requires?: string[];
8
+ /** The module's public API (what `requireModule(id)` returns). */
9
+ api: A;
10
+ /** Optional one-time setup, called on first registration. */
11
+ setup?(registry: RuntimeRegistry): void;
12
+ }
13
+ interface RuntimeRegistry {
14
+ version: string;
15
+ modules: Map<string, RuntimeModule>;
16
+ /** Shared per-page state slots (the ticker lives here). */
17
+ slots: Record<string, unknown>;
18
+ }
19
+
20
+ /**
21
+ * `motionary/runtime/text` (10.3) — split text into characters, words and
22
+ * lines for animation, keeping it accessible (original implementation).
23
+ *
24
+ * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):
25
+ * grapheme clusters via `Intl.Segmenter` when available (emoji, combining
26
+ * marks, CJK stay whole), whitespace-aware words.
27
+ * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text
28
+ * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups
29
+ * words into lines by their rendered position, sets `aria-label` on the
30
+ * element with the original text and hides the pieces from assistive tech.
31
+ * `revert()` restores the original markup; `resplit()` re-measures lines
32
+ * (e.g. after a resize).
33
+ */
34
+
35
+ type SplitType = 'chars' | 'words' | 'lines';
36
+ /** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */
37
+ declare function segment(text: string, by?: 'chars' | 'words'): string[];
38
+ interface SplitOptions {
39
+ /** Any of chars, words, lines (comma / space separated). Default 'chars,words'. */
40
+ type?: string;
41
+ /** Class prefix (default 'usa-split'): pieces get `<prefix>-char`, `-word`, `-line`. */
42
+ className?: string;
43
+ /** Set a `--i` custom property (index) on each piece for CSS staggering (default true). */
44
+ indexVar?: boolean;
45
+ }
46
+ interface SplitResult {
47
+ chars: HTMLElement[];
48
+ words: HTMLElement[];
49
+ lines: HTMLElement[];
50
+ /** Restore the original markup. */
51
+ revert(): void;
52
+ /** Revert and split again (re-measures lines). */
53
+ resplit(): SplitResult;
54
+ }
55
+ /** Split an element's text (see module docs). Needs a DOM. */
56
+ declare function splitText(el: HTMLElement, o?: SplitOptions): SplitResult;
57
+ interface TextApi {
58
+ segment: typeof segment;
59
+ splitText: typeof splitText;
60
+ }
61
+ /** The module object for `use(text)`. */
62
+ declare const text: RuntimeModule<TextApi>;
63
+
64
+ export { segment, splitText, text };
65
+ export type { SplitOptions, SplitResult, SplitType, TextApi };
@@ -0,0 +1,65 @@
1
+ /** A runtime module: `{ id, version, api }`, registered with `use()`. */
2
+ interface RuntimeModule<A = unknown> {
3
+ /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
4
+ id: string;
5
+ version: string;
6
+ /** Other modules this one needs (registered first by `use()` callers). */
7
+ requires?: string[];
8
+ /** The module's public API (what `requireModule(id)` returns). */
9
+ api: A;
10
+ /** Optional one-time setup, called on first registration. */
11
+ setup?(registry: RuntimeRegistry): void;
12
+ }
13
+ interface RuntimeRegistry {
14
+ version: string;
15
+ modules: Map<string, RuntimeModule>;
16
+ /** Shared per-page state slots (the ticker lives here). */
17
+ slots: Record<string, unknown>;
18
+ }
19
+
20
+ /**
21
+ * `motionary/runtime/text` (10.3) — split text into characters, words and
22
+ * lines for animation, keeping it accessible (original implementation).
23
+ *
24
+ * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):
25
+ * grapheme clusters via `Intl.Segmenter` when available (emoji, combining
26
+ * marks, CJK stay whole), whitespace-aware words.
27
+ * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text
28
+ * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups
29
+ * words into lines by their rendered position, sets `aria-label` on the
30
+ * element with the original text and hides the pieces from assistive tech.
31
+ * `revert()` restores the original markup; `resplit()` re-measures lines
32
+ * (e.g. after a resize).
33
+ */
34
+
35
+ type SplitType = 'chars' | 'words' | 'lines';
36
+ /** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */
37
+ declare function segment(text: string, by?: 'chars' | 'words'): string[];
38
+ interface SplitOptions {
39
+ /** Any of chars, words, lines (comma / space separated). Default 'chars,words'. */
40
+ type?: string;
41
+ /** Class prefix (default 'usa-split'): pieces get `<prefix>-char`, `-word`, `-line`. */
42
+ className?: string;
43
+ /** Set a `--i` custom property (index) on each piece for CSS staggering (default true). */
44
+ indexVar?: boolean;
45
+ }
46
+ interface SplitResult {
47
+ chars: HTMLElement[];
48
+ words: HTMLElement[];
49
+ lines: HTMLElement[];
50
+ /** Restore the original markup. */
51
+ revert(): void;
52
+ /** Revert and split again (re-measures lines). */
53
+ resplit(): SplitResult;
54
+ }
55
+ /** Split an element's text (see module docs). Needs a DOM. */
56
+ declare function splitText(el: HTMLElement, o?: SplitOptions): SplitResult;
57
+ interface TextApi {
58
+ segment: typeof segment;
59
+ splitText: typeof splitText;
60
+ }
61
+ /** The module object for `use(text)`. */
62
+ declare const text: RuntimeModule<TextApi>;
63
+
64
+ export { segment, splitText, text };
65
+ export type { SplitOptions, SplitResult, SplitType, TextApi };
@@ -0,0 +1,2 @@
1
+ !function(e,t){"use strict";function n(e,t="chars"){const n=Intl.Segmenter;return"chars"===t?n?Array.from(new n(void 0,{granularity:"grapheme"}).segment(e),e=>e.segment):Array.from(e):e.split(/(\s+)/).filter(e=>""!==e)}function r(e,t={}){if("undefined"==typeof document)throw new Error("[motionary] splitText needs a DOM — use segment() on the server");const s=(o=t.type,new Set((o||"chars,words").split(/[\s,]+/).filter(Boolean)));var o;const i=t.className||"usa-split",a=e.innerHTML,l=e.getAttribute("aria-label"),c=(e.textContent||"").replace(/\s+/g," ").trim(),d=[],h=[],p=(e,t)=>{const n=document.createElement("span");return n.className=e,n.setAttribute("aria-hidden","true"),n.style.display="inline-block",void 0!==t&&(n.textContent=t),n},u=s.has("words")||s.has("lines"),f=e=>{for(const t of Array.from(e.childNodes))if(3===t.nodeType){const e=document.createDocumentFragment();for(const r of n(t.textContent||"","words")){if(/^\s+$/.test(r)){e.appendChild(document.createTextNode(" "));continue}const t=u?p(`${i}-word`):null;if(s.has("chars"))for(const s of n(r,"chars")){const n=p(`${i}-char`,s);d.push(n),(t||e).appendChild(n)}else t?t.textContent=r:e.appendChild(document.createTextNode(r));t&&(h.push(t),e.appendChild(t))}t.replaceWith(e)}else 1!==t.nodeType||t.classList.contains(`${i}-word`)||f(t)};f(e),c&&null===l&&e.setAttribute("aria-label",c),e.setAttribute("data-split",Array.from(s).join(" "));const m=[];if(s.has("lines")&&h.length){let t=NaN,n=[];const r=[];for(const e of h){const s=Math.round(e.offsetTop);n.length&&Math.abs(s-t)>2&&(r.push(n),n=[]),n.length||(t=s),n.push(e)}n.length&&r.push(n);if(h.every(t=>t.parentElement===e)){e.textContent="";for(const t of r){const n=p(`${i}-line`);n.style.display="block",t.forEach((e,t)=>{t&&n.appendChild(document.createTextNode(" ")),n.appendChild(e)}),m.push(n),e.appendChild(n)}}else r.forEach((e,t)=>e.forEach(e=>e.setAttribute("data-line",String(t))))}if(!1!==t.indexVar)for(const e of[d,h,m])e.forEach((e,t)=>e.style.setProperty("--i",String(t)));const y={chars:d,words:s.has("words")?h:[],lines:m,revert(){e.innerHTML=a,e.removeAttribute("data-split"),null===l&&e.removeAttribute("aria-label")},resplit:()=>(y.revert(),r(e,t))};return y}const s={id:"text",version:t.RUNTIME_VERSION,requires:["core"],api:{segment:n,splitText:r}};t.register(s),e.segment=n,e.splitText=r,e.text=s}(this.MotionaryRuntime=this.MotionaryRuntime||{},MotionaryRuntime);
2
+ //# sourceMappingURL=text.iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.iife.js","sources":["../../src/runtime/text.ts","../../src/runtime/iife/text.ts"],"sourcesContent":["/**\n * `motionary/runtime/text` (10.3) — split text into characters, words and\n * lines for animation, keeping it accessible (original implementation).\n *\n * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):\n * grapheme clusters via `Intl.Segmenter` when available (emoji, combining\n * marks, CJK stay whole), whitespace-aware words.\n * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text\n * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups\n * words into lines by their rendered position, sets `aria-label` on the\n * element with the original text and hides the pieces from assistive tech.\n * `revert()` restores the original markup; `resplit()` re-measures lines\n * (e.g. after a resize).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\n\nexport type SplitType = 'chars' | 'words' | 'lines';\n\n/** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */\nexport function segment(text: string, by: 'chars' | 'words' = 'chars'): string[] {\n const Seg = (Intl as any).Segmenter;\n if (by === 'chars') {\n if (Seg) return Array.from(new Seg(undefined, { granularity: 'grapheme' }).segment(text), (s: any) => s.segment as string);\n return Array.from(text);\n }\n return text.split(/(\\s+)/).filter((s) => s !== '');\n}\n\nexport interface SplitOptions {\n /** Any of chars, words, lines (comma / space separated). Default 'chars,words'. */\n type?: string;\n /** Class prefix (default 'usa-split'): pieces get `<prefix>-char`, `-word`, `-line`. */\n className?: string;\n /** Set a `--i` custom property (index) on each piece for CSS staggering (default true). */\n indexVar?: boolean;\n}\n\nexport interface SplitResult {\n chars: HTMLElement[];\n words: HTMLElement[];\n lines: HTMLElement[];\n /** Restore the original markup. */\n revert(): void;\n /** Revert and split again (re-measures lines). */\n resplit(): SplitResult;\n}\n\nconst types = (t?: string): Set<SplitType> => new Set((t || 'chars,words').split(/[\\s,]+/).filter(Boolean) as SplitType[]);\n\n/** Split an element's text (see module docs). Needs a DOM. */\nexport function splitText(el: HTMLElement, o: SplitOptions = {}): SplitResult {\n if (typeof document === 'undefined') throw new Error('[motionary] splitText needs a DOM — use segment() on the server');\n const want = types(o.type);\n const pre = o.className || 'usa-split';\n const original = el.innerHTML;\n const hadLabel = el.getAttribute('aria-label');\n const text = (el.textContent || '').replace(/\\s+/g, ' ').trim();\n const chars: HTMLElement[] = [], words: HTMLElement[] = [];\n const mk = (cls: string, txt?: string) => {\n const s = document.createElement('span');\n s.className = cls;\n s.setAttribute('aria-hidden', 'true');\n s.style.display = 'inline-block';\n if (txt !== undefined) s.textContent = txt;\n return s;\n };\n const wantWords = want.has('words') || want.has('lines');\n const walk = (node: Node) => {\n for (const child of Array.from(node.childNodes)) {\n if (child.nodeType === 3) {\n const frag = document.createDocumentFragment();\n for (const part of segment(child.textContent || '', 'words')) {\n if (/^\\s+$/.test(part)) {\n frag.appendChild(document.createTextNode(' '));\n continue;\n }\n const w = wantWords ? mk(`${pre}-word`) : null;\n if (want.has('chars')) {\n for (const g of segment(part, 'chars')) {\n const c = mk(`${pre}-char`, g);\n chars.push(c);\n (w || frag).appendChild(c);\n }\n } else if (w) w.textContent = part;\n else frag.appendChild(document.createTextNode(part));\n if (w) {\n words.push(w);\n frag.appendChild(w);\n }\n }\n child.replaceWith(frag);\n } else if (child.nodeType === 1 && !(child as Element).classList.contains(`${pre}-word`)) walk(child);\n }\n };\n walk(el);\n if (text && hadLabel === null) el.setAttribute('aria-label', text);\n el.setAttribute('data-split', Array.from(want).join(' '));\n const lines: HTMLElement[] = [];\n if (want.has('lines') && words.length) {\n // group words by their rendered top; wrap each group in a line span (flat text only)\n let top = NaN, cur: HTMLElement[] = [];\n const groups: HTMLElement[][] = [];\n for (const w of words) {\n const t = Math.round(w.offsetTop);\n if (cur.length && Math.abs(t - top) > 2) {\n groups.push(cur);\n cur = [];\n }\n if (!cur.length) top = t;\n cur.push(w);\n }\n if (cur.length) groups.push(cur);\n const flat = words.every((w) => w.parentElement === el);\n if (flat) {\n el.textContent = '';\n for (const g of groups) {\n const line = mk(`${pre}-line`);\n line.style.display = 'block';\n g.forEach((w, i) => {\n if (i) line.appendChild(document.createTextNode(' '));\n line.appendChild(w);\n });\n lines.push(line);\n el.appendChild(line);\n }\n } else groups.forEach((g, i) => g.forEach((w) => w.setAttribute('data-line', String(i))));\n }\n if (o.indexVar !== false) for (const list of [chars, words, lines]) list.forEach((s, i) => s.style.setProperty('--i', String(i)));\n const result: SplitResult = {\n chars,\n words: want.has('words') ? words : [],\n lines,\n revert() {\n el.innerHTML = original;\n el.removeAttribute('data-split');\n if (hadLabel === null) el.removeAttribute('aria-label');\n },\n resplit() {\n result.revert();\n return splitText(el, o);\n },\n };\n return result;\n}\n\nexport interface TextApi {\n segment: typeof segment;\n splitText: typeof splitText;\n}\n\n/** The module object for `use(text)`. */\nexport const text: RuntimeModule<TextApi> = { id: 'text', version: RUNTIME_VERSION, requires: ['core'], api: { segment, splitText } };\n","// CDN build: load runtime.iife.js first, then this file → registers motionary/runtime/text and adds its API to window.MotionaryRuntime.\nimport { register } from '../registry';\nimport { text } from '../text';\nexport * from '../text';\nregister(text);\n"],"names":["segment","text","by","Seg","Intl","Segmenter","Array","from","undefined","granularity","s","split","filter","splitText","el","o","document","Error","want","t","type","Set","Boolean","pre","className","original","innerHTML","hadLabel","getAttribute","textContent","replace","trim","chars","words","mk","cls","txt","createElement","setAttribute","style","display","wantWords","has","walk","node","child","childNodes","nodeType","frag","createDocumentFragment","part","test","appendChild","createTextNode","w","g","c","push","replaceWith","classList","contains","join","lines","length","top","NaN","cur","groups","Math","round","offsetTop","abs","every","parentElement","line","forEach","i","String","indexVar","list","setProperty","result","revert","removeAttribute","resplit","id","version","RUNTIME_VERSION","requires","api","register"],"mappings":"qCAmBgBA,EAAQC,EAAcC,EAAwB,SAC5D,MAAMC,EAAOC,KAAaC,UAC1B,MAAW,UAAPH,EACEC,EAAYG,MAAMC,KAAK,IAAIJ,OAAIK,EAAW,CAAEC,YAAa,aAAcT,QAAQC,GAAQS,GAAWA,EAAEV,SACjGM,MAAMC,KA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CAACjE,EAAGkE,IAAMlE,EAAE6B,MAAMyC,YAAY,MAAOH,OAAOD,KAC7H,MAAMK,EAAsB,CAC1BjD,QACAC,MAAOf,EAAKwB,IAAI,SAAWT,EAAQ,GACnC6B,QACA,MAAAoB,GACEpE,EAAGY,UAAYD,EACfX,EAAGqE,gBAAgB,cACF,OAAbxD,GAAmBb,EAAGqE,gBAAgB,aAC5C,EACAC,QAAO,KACLH,EAAOC,SACArE,EAAUC,EAAIC,KAGzB,OAAOkE,CACT,CAQO,MAAMhF,EAA+B,CAAEoF,GAAI,OAAQC,QAASC,EAAAA,gBAAiBC,SAAU,CAAC,QAASC,IAAK,CAAEzF,UAASa,cCnJxH6E,EAAAA,SAASzF"}
@@ -0,0 +1,143 @@
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-46AAzyeC.js';
2
+
3
+ /**
4
+ * `motionary/runtime/text` (10.3) — split text into characters, words and
5
+ * lines for animation, keeping it accessible (original implementation).
6
+ *
7
+ * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):
8
+ * grapheme clusters via `Intl.Segmenter` when available (emoji, combining
9
+ * marks, CJK stay whole), whitespace-aware words.
10
+ * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text
11
+ * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups
12
+ * words into lines by their rendered position, sets `aria-label` on the
13
+ * element with the original text and hides the pieces from assistive tech.
14
+ * `revert()` restores the original markup; `resplit()` re-measures lines
15
+ * (e.g. after a resize).
16
+ */
17
+ /** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */
18
+ function segment(text, by = 'chars') {
19
+ const Seg = Intl.Segmenter;
20
+ if (by === 'chars') {
21
+ if (Seg)
22
+ return Array.from(new Seg(undefined, { granularity: 'grapheme' }).segment(text), (s) => s.segment);
23
+ return Array.from(text);
24
+ }
25
+ return text.split(/(\s+)/).filter((s) => s !== '');
26
+ }
27
+ const types = (t) => new Set((t || 'chars,words').split(/[\s,]+/).filter(Boolean));
28
+ /** Split an element's text (see module docs). Needs a DOM. */
29
+ function splitText(el, o = {}) {
30
+ if (typeof document === 'undefined')
31
+ throw new Error('[motionary] splitText needs a DOM — use segment() on the server');
32
+ const want = types(o.type);
33
+ const pre = o.className || 'usa-split';
34
+ const original = el.innerHTML;
35
+ const hadLabel = el.getAttribute('aria-label');
36
+ const text = (el.textContent || '').replace(/\s+/g, ' ').trim();
37
+ const chars = [], words = [];
38
+ const mk = (cls, txt) => {
39
+ const s = document.createElement('span');
40
+ s.className = cls;
41
+ s.setAttribute('aria-hidden', 'true');
42
+ s.style.display = 'inline-block';
43
+ if (txt !== undefined)
44
+ s.textContent = txt;
45
+ return s;
46
+ };
47
+ const wantWords = want.has('words') || want.has('lines');
48
+ const walk = (node) => {
49
+ for (const child of Array.from(node.childNodes)) {
50
+ if (child.nodeType === 3) {
51
+ const frag = document.createDocumentFragment();
52
+ for (const part of segment(child.textContent || '', 'words')) {
53
+ if (/^\s+$/.test(part)) {
54
+ frag.appendChild(document.createTextNode(' '));
55
+ continue;
56
+ }
57
+ const w = wantWords ? mk(`${pre}-word`) : null;
58
+ if (want.has('chars')) {
59
+ for (const g of segment(part, 'chars')) {
60
+ const c = mk(`${pre}-char`, g);
61
+ chars.push(c);
62
+ (w || frag).appendChild(c);
63
+ }
64
+ }
65
+ else if (w)
66
+ w.textContent = part;
67
+ else
68
+ frag.appendChild(document.createTextNode(part));
69
+ if (w) {
70
+ words.push(w);
71
+ frag.appendChild(w);
72
+ }
73
+ }
74
+ child.replaceWith(frag);
75
+ }
76
+ else if (child.nodeType === 1 && !child.classList.contains(`${pre}-word`))
77
+ walk(child);
78
+ }
79
+ };
80
+ walk(el);
81
+ if (text && hadLabel === null)
82
+ el.setAttribute('aria-label', text);
83
+ el.setAttribute('data-split', Array.from(want).join(' '));
84
+ const lines = [];
85
+ if (want.has('lines') && words.length) {
86
+ // group words by their rendered top; wrap each group in a line span (flat text only)
87
+ let top = NaN, cur = [];
88
+ const groups = [];
89
+ for (const w of words) {
90
+ const t = Math.round(w.offsetTop);
91
+ if (cur.length && Math.abs(t - top) > 2) {
92
+ groups.push(cur);
93
+ cur = [];
94
+ }
95
+ if (!cur.length)
96
+ top = t;
97
+ cur.push(w);
98
+ }
99
+ if (cur.length)
100
+ groups.push(cur);
101
+ const flat = words.every((w) => w.parentElement === el);
102
+ if (flat) {
103
+ el.textContent = '';
104
+ for (const g of groups) {
105
+ const line = mk(`${pre}-line`);
106
+ line.style.display = 'block';
107
+ g.forEach((w, i) => {
108
+ if (i)
109
+ line.appendChild(document.createTextNode(' '));
110
+ line.appendChild(w);
111
+ });
112
+ lines.push(line);
113
+ el.appendChild(line);
114
+ }
115
+ }
116
+ else
117
+ groups.forEach((g, i) => g.forEach((w) => w.setAttribute('data-line', String(i))));
118
+ }
119
+ if (o.indexVar !== false)
120
+ for (const list of [chars, words, lines])
121
+ list.forEach((s, i) => s.style.setProperty('--i', String(i)));
122
+ const result = {
123
+ chars,
124
+ words: want.has('words') ? words : [],
125
+ lines,
126
+ revert() {
127
+ el.innerHTML = original;
128
+ el.removeAttribute('data-split');
129
+ if (hadLabel === null)
130
+ el.removeAttribute('aria-label');
131
+ },
132
+ resplit() {
133
+ result.revert();
134
+ return splitText(el, o);
135
+ },
136
+ };
137
+ return result;
138
+ }
139
+ /** The module object for `use(text)`. */
140
+ const text = { id: 'text', version: RUNTIME_VERSION, requires: ['core'], api: { segment, splitText } };
141
+
142
+ export { segment, splitText, text };
143
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sources":["../../src/runtime/text.ts"],"sourcesContent":["/**\n * `motionary/runtime/text` (10.3) — split text into characters, words and\n * lines for animation, keeping it accessible (original implementation).\n *\n * - `segment(text, 'chars' | 'words')` — pure, works anywhere (SSR, workers):\n * grapheme clusters via `Intl.Segmenter` when available (emoji, combining\n * marks, CJK stay whole), whitespace-aware words.\n * - `splitText(el, { type: 'chars,words,lines' })` — wraps the element's text\n * in spans (nested elements such as `<a>`, `<em>` keep their markup), groups\n * words into lines by their rendered position, sets `aria-label` on the\n * element with the original text and hides the pieces from assistive tech.\n * `revert()` restores the original markup; `resplit()` re-measures lines\n * (e.g. after a resize).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\n\nexport type SplitType = 'chars' | 'words' | 'lines';\n\n/** Split a string into graphemes ('chars') or words + whitespace runs ('words'). */\nexport function segment(text: string, by: 'chars' | 'words' = 'chars'): string[] {\n const Seg = (Intl as any).Segmenter;\n if (by === 'chars') {\n if (Seg) return Array.from(new Seg(undefined, { granularity: 'grapheme' }).segment(text), (s: any) => s.segment as string);\n return Array.from(text);\n }\n return text.split(/(\\s+)/).filter((s) => s !== '');\n}\n\nexport interface SplitOptions {\n /** Any of chars, words, lines (comma / space separated). Default 'chars,words'. */\n type?: string;\n /** Class prefix (default 'usa-split'): pieces get `<prefix>-char`, `-word`, `-line`. */\n className?: string;\n /** Set a `--i` custom property (index) on each piece for CSS staggering (default true). */\n indexVar?: boolean;\n}\n\nexport interface SplitResult {\n chars: HTMLElement[];\n words: HTMLElement[];\n lines: HTMLElement[];\n /** Restore the original markup. */\n revert(): void;\n /** Revert and split again (re-measures lines). */\n resplit(): SplitResult;\n}\n\nconst types = (t?: string): Set<SplitType> => new Set((t || 'chars,words').split(/[\\s,]+/).filter(Boolean) as SplitType[]);\n\n/** Split an element's text (see module docs). Needs a DOM. */\nexport function splitText(el: HTMLElement, o: SplitOptions = {}): SplitResult {\n if (typeof document === 'undefined') throw new Error('[motionary] splitText needs a DOM — use segment() on the server');\n const want = types(o.type);\n const pre = o.className || 'usa-split';\n const original = el.innerHTML;\n const hadLabel = el.getAttribute('aria-label');\n const text = (el.textContent || '').replace(/\\s+/g, ' ').trim();\n const chars: HTMLElement[] = [], words: HTMLElement[] = [];\n const mk = (cls: string, txt?: string) => {\n const s = document.createElement('span');\n s.className = cls;\n s.setAttribute('aria-hidden', 'true');\n s.style.display = 'inline-block';\n if (txt !== undefined) s.textContent = txt;\n return s;\n };\n const wantWords = want.has('words') || want.has('lines');\n const walk = (node: Node) => {\n for (const child of Array.from(node.childNodes)) {\n if (child.nodeType === 3) {\n const frag = document.createDocumentFragment();\n for (const part of segment(child.textContent || '', 'words')) {\n if (/^\\s+$/.test(part)) {\n frag.appendChild(document.createTextNode(' '));\n continue;\n }\n const w = wantWords ? mk(`${pre}-word`) : null;\n if (want.has('chars')) {\n for (const g of segment(part, 'chars')) {\n const c = mk(`${pre}-char`, g);\n chars.push(c);\n (w || frag).appendChild(c);\n }\n } else if (w) w.textContent = part;\n else frag.appendChild(document.createTextNode(part));\n if (w) {\n words.push(w);\n frag.appendChild(w);\n }\n }\n child.replaceWith(frag);\n } else if (child.nodeType === 1 && !(child as Element).classList.contains(`${pre}-word`)) walk(child);\n }\n };\n walk(el);\n if (text && hadLabel === null) el.setAttribute('aria-label', text);\n el.setAttribute('data-split', Array.from(want).join(' '));\n const lines: HTMLElement[] = [];\n if (want.has('lines') && words.length) {\n // group words by their rendered top; wrap each group in a line span (flat text only)\n let top = NaN, cur: HTMLElement[] = [];\n const groups: HTMLElement[][] = [];\n for (const w of words) {\n const t = Math.round(w.offsetTop);\n if (cur.length && Math.abs(t - top) > 2) {\n groups.push(cur);\n cur = [];\n }\n if (!cur.length) top = t;\n cur.push(w);\n }\n if (cur.length) groups.push(cur);\n const flat = words.every((w) => w.parentElement === el);\n if (flat) {\n el.textContent = '';\n for (const g of groups) {\n const line = mk(`${pre}-line`);\n line.style.display = 'block';\n g.forEach((w, i) => {\n if (i) line.appendChild(document.createTextNode(' '));\n line.appendChild(w);\n });\n lines.push(line);\n el.appendChild(line);\n }\n } else groups.forEach((g, i) => g.forEach((w) => w.setAttribute('data-line', String(i))));\n }\n if (o.indexVar !== false) for (const list of [chars, words, lines]) list.forEach((s, i) => s.style.setProperty('--i', String(i)));\n const result: SplitResult = {\n chars,\n words: want.has('words') ? words : [],\n lines,\n revert() {\n el.innerHTML = original;\n el.removeAttribute('data-split');\n if (hadLabel === null) el.removeAttribute('aria-label');\n },\n resplit() {\n result.revert();\n return splitText(el, o);\n },\n };\n return result;\n}\n\nexport interface TextApi {\n segment: typeof segment;\n splitText: typeof splitText;\n}\n\n/** The module object for `use(text)`. */\nexport const text: RuntimeModule<TextApi> = { id: 'text', version: RUNTIME_VERSION, requires: ['core'], api: { segment, splitText } };\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;AAaG;AAKH;SACgB,OAAO,CAAC,IAAY,EAAE,KAAwB,OAAO,EAAA;AACnE,IAAA,MAAM,GAAG,GAAI,IAAY,CAAC,SAAS;AACnC,IAAA,IAAI,EAAE,KAAK,OAAO,EAAE;AAClB,QAAA,IAAI,GAAG;AAAE,YAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAM,KAAK,CAAC,CAAC,OAAiB,CAAC;AAC1H,QAAA,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;IACzB;AACA,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;AACpD;AAqBA,MAAM,KAAK,GAAG,CAAC,CAAU,KAAqB,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAgB,CAAC;AAE1H;SACgB,SAAS,CAAC,EAAe,EAAE,IAAkB,EAAE,EAAA;IAC7D,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC;IACvH,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1B,IAAA,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,IAAI,WAAW;AACtC,IAAA,M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E,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;;;;"}
package/dist/runtime.cjs CHANGED
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('./chunks/registry-C0xLNq3-.cjs');
4
- var tween$1 = require('./chunks/tween-JEthWrjo.cjs');
3
+ var registry = require('./chunks/registry-CSVil2qJ.cjs');
4
+ var ticker = require('./chunks/ticker-gHv6pNfx.cjs');
5
+ var tween$1 = require('./chunks/tween-CFN0WcOb.cjs');
5
6
 
6
7
  /**
7
8
  * `motionary/runtime` (10.1) — Motionary's own zero-dependency animation
@@ -27,7 +28,7 @@ var tween$1 = require('./chunks/tween-JEthWrjo.cjs');
27
28
  const core = {
28
29
  id: 'core',
29
30
  version: registry.RUNTIME_VERSION,
30
- api: { version: registry.RUNTIME_VERSION, getTicker: tween$1.getTicker, tween, timeline: tween$1.timeline, Tween: tween$1.Tween, Timeline: tween$1.Timeline, EASES: tween$1.EASES, parseEase: tween$1.parseEase, cubicBezier: tween$1.cubicBezier, steps: tween$1.steps },
31
+ api: { version: registry.RUNTIME_VERSION, getTicker: ticker.getTicker, tween, timeline: tween$1.timeline, Tween: tween$1.Tween, Timeline: tween$1.Timeline, EASES: tween$1.EASES, parseEase: tween$1.parseEase, cubicBezier: tween$1.cubicBezier, steps: tween$1.steps },
31
32
  };
32
33
  /** Tween targets (objects, elements, lists or a CSS selector). See `TweenOptions`. */
33
34
  function tween(target, o) {
@@ -61,12 +62,12 @@ exports.register = registry.register;
61
62
  exports.registeredModules = registry.registeredModules;
62
63
  exports.registry = registry.registry;
63
64
  exports.requireModule = registry.requireModule;
65
+ exports.getTicker = ticker.getTicker;
64
66
  exports.EASES = tween$1.EASES;
65
67
  exports.Playable = tween$1.Playable;
66
68
  exports.Timeline = tween$1.Timeline;
67
69
  exports.Tween = tween$1.Tween;
68
70
  exports.cubicBezier = tween$1.cubicBezier;
69
- exports.getTicker = tween$1.getTicker;
70
71
  exports.parseEase = tween$1.parseEase;
71
72
  exports.parseValue = tween$1.parseValue;
72
73
  exports.steps = tween$1.steps;