@bydiorama/motion 0.0.0-stage → 0.4.1

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 (354) hide show
  1. package/CREDITS.md +53 -0
  2. package/LICENSE +21 -0
  3. package/README.md +137 -2
  4. package/catalog.json +4697 -0
  5. package/dist/npm/brief/brief.d.ts +28 -0
  6. package/dist/npm/brief/brief.js +159 -0
  7. package/dist/npm/brief/types.d.ts +75 -0
  8. package/dist/npm/brief/types.js +2 -0
  9. package/dist/npm/browser/motion.js +1039 -0
  10. package/dist/npm/browser/page.js +4821 -0
  11. package/dist/npm/browser/wizard.js +1511 -0
  12. package/dist/npm/build/design.d.ts +54 -0
  13. package/dist/npm/build/design.js +91 -0
  14. package/dist/npm/build/index.d.ts +39 -0
  15. package/dist/npm/build/index.js +66 -0
  16. package/dist/npm/build/iso.d.ts +41 -0
  17. package/dist/npm/build/iso.js +71 -0
  18. package/dist/npm/catalog.d.ts +24 -0
  19. package/dist/npm/catalog.js +23 -0
  20. package/dist/npm/cli/browser.d.ts +26 -0
  21. package/dist/npm/cli/browser.js +66 -0
  22. package/dist/npm/cli/capture.d.ts +26 -0
  23. package/dist/npm/cli/capture.js +94 -0
  24. package/dist/npm/cli/files.d.ts +14 -0
  25. package/dist/npm/cli/files.js +87 -0
  26. package/dist/npm/cli/frames.d.ts +27 -0
  27. package/dist/npm/cli/frames.js +125 -0
  28. package/dist/npm/cli/guard.d.ts +23 -0
  29. package/dist/npm/cli/guard.js +158 -0
  30. package/dist/npm/cli/library.d.ts +2 -0
  31. package/dist/npm/cli/library.js +55 -0
  32. package/dist/npm/cli/main.d.ts +17 -0
  33. package/dist/npm/cli/main.js +964 -0
  34. package/dist/npm/cli/motion.d.ts +2 -0
  35. package/dist/npm/cli/motion.js +6 -0
  36. package/dist/npm/cli/record.d.ts +36 -0
  37. package/dist/npm/cli/record.js +142 -0
  38. package/dist/npm/cli/review.d.ts +45 -0
  39. package/dist/npm/cli/review.js +139 -0
  40. package/dist/npm/cli/schema.d.ts +852 -0
  41. package/dist/npm/cli/schema.js +120 -0
  42. package/dist/npm/cli/server.d.ts +17 -0
  43. package/dist/npm/cli/server.js +135 -0
  44. package/dist/npm/core/ease.d.ts +39 -0
  45. package/dist/npm/core/ease.js +176 -0
  46. package/dist/npm/core/frame.d.ts +52 -0
  47. package/dist/npm/core/frame.js +60 -0
  48. package/dist/npm/core/shapes.d.ts +8 -0
  49. package/dist/npm/core/shapes.js +88 -0
  50. package/dist/npm/core/stagger.d.ts +19 -0
  51. package/dist/npm/core/stagger.js +77 -0
  52. package/dist/npm/core/tap.d.ts +19 -0
  53. package/dist/npm/core/tap.js +42 -0
  54. package/dist/npm/core/track.d.ts +4 -0
  55. package/dist/npm/core/track.js +23 -0
  56. package/dist/npm/dom/mount.d.ts +127 -0
  57. package/dist/npm/dom/mount.js +950 -0
  58. package/dist/npm/dom/page.d.ts +37 -0
  59. package/dist/npm/dom/page.js +77 -0
  60. package/dist/npm/dom/soundtrack.d.ts +13 -0
  61. package/dist/npm/dom/soundtrack.js +37 -0
  62. package/dist/npm/dom/stage.css.d.ts +1 -0
  63. package/dist/npm/dom/stage.css.js +44 -0
  64. package/dist/npm/dom/tokens.d.ts +10 -0
  65. package/dist/npm/dom/tokens.js +38 -0
  66. package/dist/npm/dom/ui-themes.css.d.ts +8 -0
  67. package/dist/npm/dom/ui-themes.css.js +9 -0
  68. package/dist/npm/film/beats.d.ts +64 -0
  69. package/dist/npm/film/beats.js +282 -0
  70. package/dist/npm/film/pace.d.ts +94 -0
  71. package/dist/npm/film/pace.js +396 -0
  72. package/dist/npm/film/resolve.d.ts +16 -0
  73. package/dist/npm/film/resolve.js +997 -0
  74. package/dist/npm/film/tempo.d.ts +19 -0
  75. package/dist/npm/film/tempo.js +34 -0
  76. package/dist/npm/film/tune.d.ts +17 -0
  77. package/dist/npm/film/tune.js +68 -0
  78. package/dist/npm/film/types.d.ts +416 -0
  79. package/dist/npm/film/types.js +16 -0
  80. package/dist/npm/index.d.ts +18 -0
  81. package/dist/npm/index.js +11 -0
  82. package/dist/npm/primitives/blur.d.ts +14 -0
  83. package/dist/npm/primitives/blur.js +59 -0
  84. package/dist/npm/primitives/canvas.d.ts +5 -0
  85. package/dist/npm/primitives/canvas.js +13 -0
  86. package/dist/npm/primitives/el/box.d.ts +2 -0
  87. package/dist/npm/primitives/el/box.js +24 -0
  88. package/dist/npm/primitives/el/frames.d.ts +15 -0
  89. package/dist/npm/primitives/el/frames.js +71 -0
  90. package/dist/npm/primitives/el/html.d.ts +2 -0
  91. package/dist/npm/primitives/el/html.js +14 -0
  92. package/dist/npm/primitives/el/image.d.ts +2 -0
  93. package/dist/npm/primitives/el/image.js +43 -0
  94. package/dist/npm/primitives/el/slot.d.ts +2 -0
  95. package/dist/npm/primitives/el/slot.js +25 -0
  96. package/dist/npm/primitives/el/text.d.ts +2 -0
  97. package/dist/npm/primitives/el/text.js +13 -0
  98. package/dist/npm/primitives/el/video.d.ts +6 -0
  99. package/dist/npm/primitives/el/video.js +179 -0
  100. package/dist/npm/primitives/fx/counter-roll.d.ts +2 -0
  101. package/dist/npm/primitives/fx/counter-roll.js +32 -0
  102. package/dist/npm/primitives/fx/depth-drift.d.ts +2 -0
  103. package/dist/npm/primitives/fx/depth-drift.js +44 -0
  104. package/dist/npm/primitives/fx/grid-ripple.d.ts +2 -0
  105. package/dist/npm/primitives/fx/grid-ripple.js +59 -0
  106. package/dist/npm/primitives/fx/odometer.d.ts +2 -0
  107. package/dist/npm/primitives/fx/odometer.js +80 -0
  108. package/dist/npm/primitives/fx/pan-across.d.ts +17 -0
  109. package/dist/npm/primitives/fx/pan-across.js +76 -0
  110. package/dist/npm/primitives/fx/path-draw.d.ts +2 -0
  111. package/dist/npm/primitives/fx/path-draw.js +105 -0
  112. package/dist/npm/primitives/fx/pin-drop.d.ts +2 -0
  113. package/dist/npm/primitives/fx/pin-drop.js +92 -0
  114. package/dist/npm/primitives/fx/shape-morph.d.ts +2 -0
  115. package/dist/npm/primitives/fx/shape-morph.js +65 -0
  116. package/dist/npm/primitives/fx/slow-push.d.ts +13 -0
  117. package/dist/npm/primitives/fx/slow-push.js +56 -0
  118. package/dist/npm/primitives/fx/stagger-fill.d.ts +2 -0
  119. package/dist/npm/primitives/fx/stagger-fill.js +33 -0
  120. package/dist/npm/primitives/index.d.ts +4 -0
  121. package/dist/npm/primitives/index.js +78 -0
  122. package/dist/npm/primitives/rig/browser-window.d.ts +2 -0
  123. package/dist/npm/primitives/rig/browser-window.js +142 -0
  124. package/dist/npm/primitives/rig/camera.d.ts +36 -0
  125. package/dist/npm/primitives/rig/camera.js +81 -0
  126. package/dist/npm/primitives/rig/footage-plane.d.ts +27 -0
  127. package/dist/npm/primitives/rig/footage-plane.js +257 -0
  128. package/dist/npm/primitives/rig/layer-stack.d.ts +39 -0
  129. package/dist/npm/primitives/rig/layer-stack.js +276 -0
  130. package/dist/npm/primitives/rig/orbit-ring.d.ts +2 -0
  131. package/dist/npm/primitives/rig/orbit-ring.js +59 -0
  132. package/dist/npm/primitives/rig/tab-stack.d.ts +9 -0
  133. package/dist/npm/primitives/rig/tab-stack.js +143 -0
  134. package/dist/npm/primitives/scene/bar-chart.d.ts +2 -0
  135. package/dist/npm/primitives/scene/bar-chart.js +83 -0
  136. package/dist/npm/primitives/scene/bento-grid.d.ts +49 -0
  137. package/dist/npm/primitives/scene/bento-grid.js +293 -0
  138. package/dist/npm/primitives/scene/grid-wall.d.ts +18 -0
  139. package/dist/npm/primitives/scene/grid-wall.js +110 -0
  140. package/dist/npm/primitives/scene/line-chart.d.ts +2 -0
  141. package/dist/npm/primitives/scene/line-chart.js +121 -0
  142. package/dist/npm/primitives/scene/logo-reveal.d.ts +2 -0
  143. package/dist/npm/primitives/scene/logo-reveal.js +117 -0
  144. package/dist/npm/primitives/scene/marquee-wall.d.ts +2 -0
  145. package/dist/npm/primitives/scene/marquee-wall.js +82 -0
  146. package/dist/npm/primitives/scene/post-carousel.d.ts +16 -0
  147. package/dist/npm/primitives/scene/post-carousel.js +195 -0
  148. package/dist/npm/primitives/scene/strip-cycle.d.ts +49 -0
  149. package/dist/npm/primitives/scene/strip-cycle.js +237 -0
  150. package/dist/npm/primitives/split.d.ts +34 -0
  151. package/dist/npm/primitives/split.js +105 -0
  152. package/dist/npm/primitives/texture/beat-field.d.ts +13 -0
  153. package/dist/npm/primitives/texture/beat-field.js +113 -0
  154. package/dist/npm/primitives/texture/gradient-drift.d.ts +2 -0
  155. package/dist/npm/primitives/texture/gradient-drift.js +56 -0
  156. package/dist/npm/primitives/texture/grain.d.ts +2 -0
  157. package/dist/npm/primitives/texture/grain.js +54 -0
  158. package/dist/npm/primitives/texture/halftone-field.d.ts +2 -0
  159. package/dist/npm/primitives/texture/halftone-field.js +36 -0
  160. package/dist/npm/primitives/texture/signal-field.d.ts +4 -0
  161. package/dist/npm/primitives/texture/signal-field.js +107 -0
  162. package/dist/npm/primitives/texture/vignette.d.ts +2 -0
  163. package/dist/npm/primitives/texture/vignette.js +23 -0
  164. package/dist/npm/primitives/transition/band-sweep.d.ts +22 -0
  165. package/dist/npm/primitives/transition/band-sweep.js +111 -0
  166. package/dist/npm/primitives/transition/beat-cut.d.ts +2 -0
  167. package/dist/npm/primitives/transition/beat-cut.js +10 -0
  168. package/dist/npm/primitives/transition/blur-dissolve.d.ts +2 -0
  169. package/dist/npm/primitives/transition/blur-dissolve.js +28 -0
  170. package/dist/npm/primitives/transition/camera-travel.d.ts +2 -0
  171. package/dist/npm/primitives/transition/camera-travel.js +69 -0
  172. package/dist/npm/primitives/transition/cover-reveal.d.ts +2 -0
  173. package/dist/npm/primitives/transition/cover-reveal.js +52 -0
  174. package/dist/npm/primitives/transition/curtain.d.ts +2 -0
  175. package/dist/npm/primitives/transition/curtain.js +40 -0
  176. package/dist/npm/primitives/transition/dive-in.d.ts +2 -0
  177. package/dist/npm/primitives/transition/dive-in.js +52 -0
  178. package/dist/npm/primitives/transition/fly-past.d.ts +2 -0
  179. package/dist/npm/primitives/transition/fly-past.js +87 -0
  180. package/dist/npm/primitives/transition/iris.d.ts +2 -0
  181. package/dist/npm/primitives/transition/iris.js +38 -0
  182. package/dist/npm/primitives/transition/overlay.d.ts +4 -0
  183. package/dist/npm/primitives/transition/overlay.js +24 -0
  184. package/dist/npm/primitives/transition/push.d.ts +2 -0
  185. package/dist/npm/primitives/transition/push.js +35 -0
  186. package/dist/npm/primitives/transition/signal-wipe.d.ts +2 -0
  187. package/dist/npm/primitives/transition/signal-wipe.js +67 -0
  188. package/dist/npm/primitives/transition/slant-wipe.d.ts +2 -0
  189. package/dist/npm/primitives/transition/slant-wipe.js +30 -0
  190. package/dist/npm/primitives/transition/stack-over.d.ts +2 -0
  191. package/dist/npm/primitives/transition/stack-over.js +38 -0
  192. package/dist/npm/primitives/transition/step-wipe.d.ts +2 -0
  193. package/dist/npm/primitives/transition/step-wipe.js +29 -0
  194. package/dist/npm/primitives/transition/strip-wipe.d.ts +40 -0
  195. package/dist/npm/primitives/transition/strip-wipe.js +121 -0
  196. package/dist/npm/primitives/transition/whip-pan.d.ts +2 -0
  197. package/dist/npm/primitives/transition/whip-pan.js +45 -0
  198. package/dist/npm/primitives/type/block-reveal.d.ts +2 -0
  199. package/dist/npm/primitives/type/block-reveal.js +61 -0
  200. package/dist/npm/primitives/type/char-cascade.d.ts +2 -0
  201. package/dist/npm/primitives/type/char-cascade.js +45 -0
  202. package/dist/npm/primitives/type/echo.d.ts +2 -0
  203. package/dist/npm/primitives/type/echo.js +57 -0
  204. package/dist/npm/primitives/type/fill-text.d.ts +14 -0
  205. package/dist/npm/primitives/type/fill-text.js +82 -0
  206. package/dist/npm/primitives/type/mask-reveal.d.ts +2 -0
  207. package/dist/npm/primitives/type/mask-reveal.js +58 -0
  208. package/dist/npm/primitives/type/scramble.d.ts +2 -0
  209. package/dist/npm/primitives/type/scramble.js +34 -0
  210. package/dist/npm/primitives/type/scribble-highlight.d.ts +2 -0
  211. package/dist/npm/primitives/type/scribble-highlight.js +84 -0
  212. package/dist/npm/primitives/type/shimmer.d.ts +2 -0
  213. package/dist/npm/primitives/type/shimmer.js +35 -0
  214. package/dist/npm/primitives/type/tracking-in.d.ts +2 -0
  215. package/dist/npm/primitives/type/tracking-in.js +37 -0
  216. package/dist/npm/primitives/type/typed-title.d.ts +2 -0
  217. package/dist/npm/primitives/type/typed-title.js +33 -0
  218. package/dist/npm/primitives/type/word-build.d.ts +2 -0
  219. package/dist/npm/primitives/type/word-build.js +44 -0
  220. package/dist/npm/primitives/type/word-roller.d.ts +2 -0
  221. package/dist/npm/primitives/type/word-roller.js +80 -0
  222. package/dist/npm/primitives/types.d.ts +183 -0
  223. package/dist/npm/primitives/types.js +5 -0
  224. package/dist/npm/primitives/ui/cursor-click.d.ts +4 -0
  225. package/dist/npm/primitives/ui/cursor-click.js +68 -0
  226. package/dist/npm/primitives/ui/page-scroll.d.ts +17 -0
  227. package/dist/npm/primitives/ui/page-scroll.js +98 -0
  228. package/dist/npm/review/fft.d.ts +4 -0
  229. package/dist/npm/review/fft.js +71 -0
  230. package/dist/npm/review/measure.d.ts +170 -0
  231. package/dist/npm/review/measure.js +577 -0
  232. package/dist/npm/tokens.d.ts +50 -0
  233. package/dist/npm/tokens.js +49 -0
  234. package/dist/npm/version.d.ts +1 -0
  235. package/dist/npm/version.js +1 -0
  236. package/examples/builder.film.mjs +18 -0
  237. package/films/feature-announcement.film.json +70 -0
  238. package/library/narratives/app-demo.md +64 -0
  239. package/library/narratives/brand-identity.md +78 -0
  240. package/library/narratives/capability-through-type.md +53 -0
  241. package/library/narratives/data-story.md +59 -0
  242. package/library/narratives/explainer.md +64 -0
  243. package/library/narratives/feature-announcement.md +68 -0
  244. package/library/narratives/infinite-loop.md +28 -0
  245. package/library/narratives/platform-launch.md +81 -0
  246. package/library/narratives/social-teaser.md +45 -0
  247. package/library/narratives/title-sequence.md +55 -0
  248. package/library/narratives/website-launch.md +65 -0
  249. package/library/primitives/fx/card-arrangements.md +26 -0
  250. package/library/primitives/fx/counter-roll.md +27 -0
  251. package/library/primitives/fx/depth-drift.md +32 -0
  252. package/library/primitives/fx/grid-ripple.md +58 -0
  253. package/library/primitives/fx/letter-interleave.md +26 -0
  254. package/library/primitives/fx/marquee-highlight.md +27 -0
  255. package/library/primitives/fx/mosaic-fill.md +23 -0
  256. package/library/primitives/fx/odometer.md +44 -0
  257. package/library/primitives/fx/pan-across.md +63 -0
  258. package/library/primitives/fx/path-draw.md +54 -0
  259. package/library/primitives/fx/pin-drop.md +51 -0
  260. package/library/primitives/fx/radial-burst.md +33 -0
  261. package/library/primitives/fx/shape-morph.md +45 -0
  262. package/library/primitives/fx/slow-push.md +63 -0
  263. package/library/primitives/fx/stagger-fill.md +28 -0
  264. package/library/primitives/rig/browser-window.md +113 -0
  265. package/library/primitives/rig/flip-ticker.md +26 -0
  266. package/library/primitives/rig/footage-plane.md +90 -0
  267. package/library/primitives/rig/layer-stack.md +168 -0
  268. package/library/primitives/rig/orbit-ring.md +43 -0
  269. package/library/primitives/rig/rolodex.md +31 -0
  270. package/library/primitives/rig/tab-stack.md +116 -0
  271. package/library/primitives/rig/tumbling-object.md +27 -0
  272. package/library/primitives/scene/bar-chart.md +49 -0
  273. package/library/primitives/scene/bento-grid.md +74 -0
  274. package/library/primitives/scene/end-card.md +28 -0
  275. package/library/primitives/scene/grid-wall.md +61 -0
  276. package/library/primitives/scene/hero-object.md +33 -0
  277. package/library/primitives/scene/kinetic-headline.md +34 -0
  278. package/library/primitives/scene/line-chart.md +47 -0
  279. package/library/primitives/scene/logo-reveal.md +53 -0
  280. package/library/primitives/scene/marquee-wall.md +33 -0
  281. package/library/primitives/scene/mosaic.md +28 -0
  282. package/library/primitives/scene/post-carousel.md +68 -0
  283. package/library/primitives/scene/specimen-grid.md +28 -0
  284. package/library/primitives/scene/stat-with-evidence.md +34 -0
  285. package/library/primitives/scene/strip-cycle.md +122 -0
  286. package/library/primitives/scene/zoomed-ui.md +29 -0
  287. package/library/primitives/texture/ascii.md +22 -0
  288. package/library/primitives/texture/beat-field.md +85 -0
  289. package/library/primitives/texture/depth-fade.md +23 -0
  290. package/library/primitives/texture/dither.md +27 -0
  291. package/library/primitives/texture/gradient-drift.md +50 -0
  292. package/library/primitives/texture/grain.md +39 -0
  293. package/library/primitives/texture/halftone-field.md +26 -0
  294. package/library/primitives/texture/signal-field.md +61 -0
  295. package/library/primitives/texture/vignette.md +53 -0
  296. package/library/primitives/transition/band-sweep.md +63 -0
  297. package/library/primitives/transition/beat-cut.md +27 -0
  298. package/library/primitives/transition/blur-dissolve.md +36 -0
  299. package/library/primitives/transition/camera-travel.md +57 -0
  300. package/library/primitives/transition/collapse-to-anchor.md +27 -0
  301. package/library/primitives/transition/cover-reveal.md +47 -0
  302. package/library/primitives/transition/curtain.md +42 -0
  303. package/library/primitives/transition/dive-in.md +51 -0
  304. package/library/primitives/transition/fly-past.md +51 -0
  305. package/library/primitives/transition/iris.md +49 -0
  306. package/library/primitives/transition/layout-locked-swap.md +28 -0
  307. package/library/primitives/transition/light-dark-flip.md +27 -0
  308. package/library/primitives/transition/push.md +47 -0
  309. package/library/primitives/transition/signal-wipe.md +52 -0
  310. package/library/primitives/transition/slant-wipe.md +44 -0
  311. package/library/primitives/transition/stack-over.md +51 -0
  312. package/library/primitives/transition/step-wipe.md +32 -0
  313. package/library/primitives/transition/strip-wipe.md +80 -0
  314. package/library/primitives/transition/torn-edge.md +26 -0
  315. package/library/primitives/transition/whip-pan.md +47 -0
  316. package/library/primitives/transition/zoom-through-letter.md +27 -0
  317. package/library/primitives/type/accent-number.md +22 -0
  318. package/library/primitives/type/block-reveal.md +41 -0
  319. package/library/primitives/type/char-cascade.md +65 -0
  320. package/library/primitives/type/echo.md +44 -0
  321. package/library/primitives/type/fill-text.md +63 -0
  322. package/library/primitives/type/focus-blur.md +22 -0
  323. package/library/primitives/type/inline-chips.md +27 -0
  324. package/library/primitives/type/mask-reveal.md +65 -0
  325. package/library/primitives/type/parting.md +23 -0
  326. package/library/primitives/type/per-word-restyle.md +28 -0
  327. package/library/primitives/type/scramble.md +26 -0
  328. package/library/primitives/type/scribble-highlight.md +47 -0
  329. package/library/primitives/type/shimmer.md +39 -0
  330. package/library/primitives/type/split-flap.md +26 -0
  331. package/library/primitives/type/style-multiply.md +23 -0
  332. package/library/primitives/type/tracking-in.md +40 -0
  333. package/library/primitives/type/typed-title.md +27 -0
  334. package/library/primitives/type/word-build.md +37 -0
  335. package/library/primitives/type/word-roller.md +52 -0
  336. package/library/primitives/type/writing-ticker.md +27 -0
  337. package/library/primitives/ui/collab-cursors.md +27 -0
  338. package/library/primitives/ui/cursor-click.md +61 -0
  339. package/library/primitives/ui/page-scroll.md +58 -0
  340. package/library/primitives/ui/prompt-typing.md +29 -0
  341. package/library/primitives/ui/streamed-result.md +23 -0
  342. package/library/primitives/ui/tour-hold.md +27 -0
  343. package/library/styles/brand-system.md +49 -0
  344. package/library/styles/clean-explainer.md +42 -0
  345. package/library/styles/dark-showcase.md +48 -0
  346. package/library/styles/editorial-type.md +37 -0
  347. package/library/styles/kinetic-poster.md +54 -0
  348. package/library/styles/product-ui.md +44 -0
  349. package/library/styles/studio-loop.md +41 -0
  350. package/library.json +1467 -0
  351. package/package.json +64 -4
  352. package/schema/film.schema.json +1316 -0
  353. package/showcase/vendor/DIALKIT-LICENSE +21 -0
  354. package/src/studio/theme/fonts/OFL.txt +94 -0
@@ -0,0 +1,61 @@
1
+ // type/block-reveal. See library/primitives/type/block-reveal.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { staggerDelays } from "../../core/stagger.js";
4
+ import { countHardLines, splitText } from "../split.js";
5
+ import { list, num, str } from "../types.js";
6
+ const FILL = { accent: 'var(--m-bg-accent)', inverse: 'var(--m-bg-inverse)', primary: 'var(--m-text-primary)' };
7
+ export const blockReveal = {
8
+ slug: 'type/block-reveal',
9
+ summary: 'A solid block covers each line, then retracts as the line slides out from behind it.',
10
+ props: {
11
+ text: { type: 'string', required: true, label: 'The text. Use \\n to set the line breaks' },
12
+ accent: { type: 'string[]', default: [], label: 'Words set in the accent colour' },
13
+ fill: { type: 'string', default: 'accent', label: 'Block colour: accent, inverse, primary or a CSS colour' },
14
+ },
15
+ params: {
16
+ duration: { type: 'number', default: 0.8, min: 0.5, max: 1.2, step: 0.05, unit: 's', label: 'Time for one block to grow and retract' },
17
+ stagger: { type: 'number', default: 0.08, min: 0.03, max: 0.2, step: 0.01, unit: 's', label: 'Delay between lines' },
18
+ direction: { type: 'choice', default: 'right', options: ['right', 'left'], label: 'Which way the block travels' },
19
+ },
20
+ // Each line: the block grows, then retracts; the text slides out from 0.35 of the way into the retract.
21
+ duration: (props, p) => (countHardLines(str(props.text)) - 1) * num(p.stagger) + num(p.duration) * 2.35,
22
+ build(el, props, p, ctx) {
23
+ const doc = el.ownerDocument;
24
+ const { lines } = splitText(el, str(props.text), { accent: list(props.accent) });
25
+ const right = str(p.direction) !== 'left';
26
+ const fill = FILL[str(props.fill, 'accent')] ?? str(props.fill, 'accent');
27
+ // Each line hugs its words, so the block is exactly the line's own width.
28
+ const units = lines.map((line) => {
29
+ line.style.cssText += ';position:relative;display:block;width:fit-content;margin-inline:auto;text-align:inherit';
30
+ const block = doc.createElement('span');
31
+ block.setAttribute('aria-hidden', 'true');
32
+ block.style.cssText = `position:absolute;inset:0.06em -0.08em;border-radius:0.06em;background:${fill};transform:scaleX(0)`;
33
+ const words = doc.createElement('span');
34
+ words.style.cssText = 'display:inline-block';
35
+ while (line.firstChild)
36
+ words.appendChild(line.firstChild);
37
+ line.append(words, block);
38
+ return { block, words };
39
+ });
40
+ // Lines that wrap share the time the "\n" lines were given.
41
+ const budget = (countHardLines(str(props.text)) - 1) * num(p.stagger);
42
+ const delays = staggerDelays(units.length, units.length > 1 ? Math.min(num(p.stagger), budget / (units.length - 1)) : 0);
43
+ const dur = num(p.duration), grow = ctx.ease('expo.inOut'), land = ctx.ease('snap.out');
44
+ return {
45
+ seek(t) {
46
+ units.forEach(({ block, words }, i) => {
47
+ const g = progress(t, delays[i], dur, grow);
48
+ const r = progress(t, delays[i] + dur, dur, grow);
49
+ // Grows from one side, retracts toward the other.
50
+ block.style.transformOrigin = r > 0 ? (right ? '100% 50%' : '0% 50%') : (right ? '0% 50%' : '100% 50%');
51
+ block.style.transform = `scaleX(${(r > 0 ? 1 - r : g).toFixed(4)})`;
52
+ const k = progress(t, delays[i] + dur * 1.35, dur, land);
53
+ const shown = t >= delays[i] + dur;
54
+ words.style.visibility = shown ? 'inherit' : 'hidden';
55
+ words.style.transform = k >= 1 ? '' : `translateX(${((right ? -1 : 1) * (1 - k) * 0.6).toFixed(4)}em)`;
56
+ words.style.opacity = shown ? Math.min(1, 0.4 + k).toFixed(3) : '0';
57
+ });
58
+ },
59
+ };
60
+ },
61
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const charCascade: Primitive;
@@ -0,0 +1,45 @@
1
+ // type/char-cascade. See library/primitives/type/char-cascade.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { STAGGER_FROM, staggerDelays, staggerSpan } from "../../core/stagger.js";
4
+ import { countChars, splitText } from "../split.js";
5
+ import { list, num, str } from "../types.js";
6
+ export const charCascade = {
7
+ slug: 'type/char-cascade',
8
+ summary: 'Letters arrive one by one: rising, turning, growing or coming into focus.',
9
+ props: {
10
+ text: { type: 'string', required: true, label: 'The text' },
11
+ accent: { type: 'string[]', default: [], label: 'Words set in the accent colour' },
12
+ },
13
+ params: {
14
+ stagger: { type: 'number', default: 0.03, min: 0.015, max: 0.06, step: 0.005, unit: 's', label: 'Delay between letters' },
15
+ char_duration: { type: 'number', default: 0.6, min: 0.3, max: 1, step: 0.05, unit: 's', label: 'Time per letter' },
16
+ from: { type: 'choice', default: 'start', options: STAGGER_FROM, label: 'Which letter goes first' },
17
+ rise: { type: 'number', default: 0.6, min: -1, max: 1.2, step: 0.05, unit: 'em', label: 'Rise (negative drops in)' },
18
+ rotate: { type: 'number', default: 0, min: -90, max: 90, step: 1, unit: 'deg', label: 'Turn that settles' },
19
+ scale: { type: 'number', default: 1, min: 0, max: 1.6, step: 0.05, unit: 'x', label: 'Start scale' },
20
+ blur: { type: 'number', default: 8, min: 0, max: 24, step: 1, unit: 'px', label: 'Start blur' },
21
+ },
22
+ duration: (props, p, ctx) => staggerSpan(countChars(str(props.text)), str(p.from), ctx.seed) * num(p.stagger) + num(p.char_duration),
23
+ build(el, props, p, ctx) {
24
+ const { chars } = splitText(el, str(props.text), { chars: true, accent: list(props.accent) });
25
+ const delays = staggerDelays(chars.length, num(p.stagger), str(p.from), ctx.seed);
26
+ // The token ease, which a lively film may make springy; opacity always leads.
27
+ const ease = ctx.ease(ctx.tokens.ease_enter);
28
+ const dur = num(p.char_duration), rise = num(p.rise), rot = num(p.rotate), s0 = num(p.scale), blur = num(p.blur);
29
+ for (const c of chars)
30
+ c.style.transformOrigin = '50% 70%';
31
+ return {
32
+ seek(t) {
33
+ chars.forEach((c, i) => {
34
+ const k = progress(t, delays[i], dur, ease);
35
+ const fade = Math.min(1, Math.max(0, (t - delays[i]) / (dur * 0.45)));
36
+ const off = 1 - k;
37
+ c.style.opacity = fade >= 1 ? '' : String(fade);
38
+ c.style.transform = off === 0 ? '' : `translateY(${(off * rise).toFixed(4)}em) rotate(${(off * rot).toFixed(3)}deg) scale(${(s0 + (1 - s0) * k).toFixed(4)})`;
39
+ const b = Math.max(0, off) * blur;
40
+ c.style.filter = b > 0.05 ? `blur(${b.toFixed(2)}px)` : '';
41
+ });
42
+ },
43
+ };
44
+ },
45
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const echo: Primitive;
@@ -0,0 +1,57 @@
1
+ // type/echo. See library/primitives/type/echo.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ export const echo = {
5
+ slug: 'type/echo',
6
+ summary: 'Copies of a headline trail behind it.',
7
+ props: { text: { type: 'string', required: true, label: 'The headline' } },
8
+ params: {
9
+ copies: { type: 'number', default: 4, min: 3, max: 6, step: 1, unit: 'copies', label: 'Outlined copies' },
10
+ lag: { type: 'number', default: 0.06, min: 0.03, max: 0.12, step: 0.005, unit: 's', label: 'Delay between copies' },
11
+ distance: { type: 'number', default: 1.2, min: 0.4, max: 3, step: 0.1, unit: 'em', label: 'How far below they start' },
12
+ settle: { type: 'number', default: 0, min: 0, max: 0.6, step: 0.02, unit: 'em', label: 'Gap between copies at rest (0 hides them under the headline)' },
13
+ },
14
+ duration: (_props, p, ctx) => Math.round(num(p.copies)) * num(p.lag) + ctx.tokens.duration.slow + 0.4,
15
+ build(el, props, p, ctx) {
16
+ const doc = el.ownerDocument;
17
+ const n = Math.max(1, Math.round(num(p.copies))), lag = num(p.lag), dist = num(p.distance), settle = num(p.settle);
18
+ const dur = ctx.tokens.duration.slow + 0.4, ease = ctx.ease('expressive.out');
19
+ el.style.display = 'grid';
20
+ const make = (outline) => {
21
+ const s = doc.createElement('span');
22
+ s.textContent = str(props.text);
23
+ s.style.cssText = 'grid-area:1/1;white-space:pre-line';
24
+ if (outline) {
25
+ s.style.color = 'transparent';
26
+ s.style.setProperty('-webkit-text-stroke', '0.018em currentColor');
27
+ s.setAttribute('aria-hidden', 'true');
28
+ }
29
+ return s;
30
+ };
31
+ // Copies are drawn first, so the headline sits on top of them.
32
+ const copies = Array.from({ length: n }, () => make(true)).reverse();
33
+ copies.forEach((c) => el.appendChild(c));
34
+ copies.reverse();
35
+ const head = make(false);
36
+ el.appendChild(head);
37
+ return {
38
+ seek(t) {
39
+ const kh = progress(t, n * lag, dur, ease);
40
+ head.style.transform = kh >= 1 ? '' : `translateY(${((1 - kh) * dist).toFixed(4)}em)`;
41
+ head.style.opacity = String(Math.min(1, Math.max(0, (t - n * lag) / (dur * 0.3))));
42
+ copies.forEach((c, i) => {
43
+ // The copy furthest back leaves first and ends furthest down.
44
+ const order = n - 1 - i;
45
+ const k = progress(t, order * lag, dur, ease);
46
+ const rest = (i + 1) * settle;
47
+ c.style.transform = `translateY(${(rest + (1 - k) * dist).toFixed(4)}em)`;
48
+ const fade = Math.min(1, Math.max(0, (t - order * lag) / (dur * 0.25)));
49
+ const depth = 1 - (i + 1) / (n + 1);
50
+ // With no gap at rest, copies vanish under the headline once it lands.
51
+ const hide = settle === 0 ? 1 - progress(t, n * lag + dur * 0.6, dur * 0.4, (x) => x) : 1;
52
+ c.style.opacity = (fade * depth * hide).toFixed(3);
53
+ });
54
+ },
55
+ };
56
+ },
57
+ };
@@ -0,0 +1,14 @@
1
+ import { type Primitive } from '../types.ts';
2
+ /**
3
+ * Opacity of a word `k` of the way through its fill (0–1): through the dim, mid
4
+ * and full stops, linearly between them. Mid sits a little past halfway, so a
5
+ * word reads as filled before it is quite done.
6
+ */
7
+ export declare function fillLevel(k: number, dim: number): number;
8
+ /**
9
+ * How far each of `n` words is through its fill when the whole fill is `e` of
10
+ * the way through. `soft` is how many words fill at once: 1 fills them strictly
11
+ * one after another, 3 lets each overlap the next two.
12
+ */
13
+ export declare function fillShares(n: number, e: number, soft: number): number[];
14
+ export declare const fillText: Primitive;
@@ -0,0 +1,82 @@
1
+ // type/fill-text. See library/primitives/type/fill-text.md.
2
+ //
3
+ // The whole line is there from the first frame, dim, and fills word by word in
4
+ // reading order: dim, then mid, then full. Nothing moves. The first frame is
5
+ // already a readable thumbnail, and the fill tells the eye where to read.
6
+ //
7
+ // With `dim` at 0 it streams instead: words arrive one after another out of a soft
8
+ // focus, the way a model's answer comes in, but every word has its place from the
9
+ // first frame, so the line never re-wraps or re-centres as it grows. A word in
10
+ // braces, {1}, is a badge (a citation, a count) that pops in on its turn.
11
+ import { clamp } from "../../core/ease.js";
12
+ import { splitText } from "../split.js";
13
+ import { list, num, str } from "../types.js";
14
+ /**
15
+ * Opacity of a word `k` of the way through its fill (0–1): through the dim, mid
16
+ * and full stops, linearly between them. Mid sits a little past halfway, so a
17
+ * word reads as filled before it is quite done.
18
+ */
19
+ export function fillLevel(k, dim) {
20
+ const mid = dim + (1 - dim) * 0.55, x = clamp(k);
21
+ return x < 0.5 ? dim + (mid - dim) * x * 2 : mid + (1 - mid) * (x - 0.5) * 2;
22
+ }
23
+ /**
24
+ * How far each of `n` words is through its fill when the whole fill is `e` of
25
+ * the way through. `soft` is how many words fill at once: 1 fills them strictly
26
+ * one after another, 3 lets each overlap the next two.
27
+ */
28
+ export function fillShares(n, e, soft) {
29
+ const s = Math.max(1, soft), g = clamp(e) * (n - 1 + s);
30
+ return Array.from({ length: n }, (_, i) => clamp((g - i) / s));
31
+ }
32
+ export const fillText = {
33
+ slug: 'type/fill-text',
34
+ summary: 'The whole line is there, dim; each word fills to full in reading order.',
35
+ props: {
36
+ text: { type: 'string', required: true, label: 'The text. Use \\n to set the line breaks yourself.' },
37
+ accent: { type: 'string[]', default: [], label: 'Words that fill to the accent colour' },
38
+ },
39
+ params: {
40
+ duration: { type: 'number', default: 1.7, min: 0.4, max: 4, step: 0.05, unit: 's', label: 'Time for the whole fill' },
41
+ dim: { type: 'number', default: 0.35, min: 0, max: 0.6, step: 0.01, unit: 'opacity', label: 'How dim the words wait (0: unseen, so the text streams in)' },
42
+ blur: { type: 'number', default: 0, min: 0, max: 6, step: 0.1, unit: 'px', label: 'Soft focus a word fills out of' },
43
+ rise: { type: 'number', default: 0, min: 0, max: 12, step: 0.5, unit: 'px', label: 'How far a word rises as it fills' },
44
+ word_ease: { type: 'ease', default: 'linear', label: 'Pace of each word\'s own fill' },
45
+ soft: { type: 'number', default: 1.5, min: 1, max: 8, step: 0.1, unit: 'words', label: 'How many words fill at once' },
46
+ ease: { type: 'ease', default: 'smooth', label: 'Pace of the fill along the line' },
47
+ },
48
+ duration: (_props, p) => num(p.duration),
49
+ build(el, props, p, ctx) {
50
+ const { words } = splitText(el, str(props.text), { accent: list(props.accent) });
51
+ const badge = words.map((w) => {
52
+ const m = /^\{(.+)\}([^\p{L}\p{N}]*)$/u.exec(w.textContent ?? '');
53
+ if (!m)
54
+ return false;
55
+ w.textContent = m[1];
56
+ w.style.cssText += ';padding:0 0.38em;margin:0 0.05em;border-radius:999px;font-size:0.62em;line-height:1.55;vertical-align:0.18em;font-weight:600;' +
57
+ 'color:var(--m-accent);background:color-mix(in srgb, var(--m-accent) 16%, transparent)';
58
+ return true;
59
+ });
60
+ const ease = ctx.ease(p.ease), each = ctx.ease(p.word_ease), pop = ctx.ease('bounce.out');
61
+ const dur = Math.max(0.001, num(p.duration)), dim = num(p.dim), soft = num(p.soft), blur = num(p.blur), rise = num(p.rise);
62
+ return {
63
+ seek(t) {
64
+ const shares = fillShares(words.length, ease(clamp(t / dur)), soft);
65
+ words.forEach((w, i) => {
66
+ const k = each(shares[i]);
67
+ if (badge[i]) {
68
+ // A badge pops on its turn: from half size, past its mark and back.
69
+ const a = clamp(k * 3);
70
+ w.style.opacity = a >= 1 ? '' : a.toFixed(4);
71
+ w.style.transform = k >= 1 ? '' : `scale(${(0.5 + 0.5 * pop(k)).toFixed(4)})`;
72
+ return;
73
+ }
74
+ const a = fillLevel(k, dim);
75
+ w.style.opacity = a >= 1 ? '' : a.toFixed(4);
76
+ w.style.filter = blur > 0 && k < 1 ? `blur(${((1 - k) * blur).toFixed(3)}px)` : '';
77
+ w.style.transform = rise > 0 && k < 1 ? `translateY(${((1 - k) * rise).toFixed(3)}px)` : '';
78
+ });
79
+ },
80
+ };
81
+ },
82
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const maskReveal: Primitive;
@@ -0,0 +1,58 @@
1
+ // type/mask-reveal. See library/primitives/type/mask-reveal.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { STAGGER_FROM, staggerDelays, staggerSpan } from "../../core/stagger.js";
4
+ import { countHardLines, countWords, splitText } from "../split.js";
5
+ import { list, num, str } from "../types.js";
6
+ const span = (props, p, seed) => {
7
+ const text = str(props.text);
8
+ if (p.unit === 'word')
9
+ return staggerSpan(countWords(text), str(p.from), seed);
10
+ // Lines are only known once laid out; "\n" lines are counted, and one more step
11
+ // is kept for a line that wraps.
12
+ return staggerSpan(countHardLines(text), str(p.from), seed) + (countHardLines(text) > 1 || countWords(text) > 3 ? 1 : 0);
13
+ };
14
+ export const maskReveal = {
15
+ slug: 'type/mask-reveal',
16
+ summary: 'Lines or words slide up from under an edge, one after another.',
17
+ props: {
18
+ text: { type: 'string', required: true, label: 'The text. Use \\n to set the line breaks yourself.' },
19
+ accent: { type: 'string[]', default: [], label: 'Words set in the accent colour' },
20
+ },
21
+ params: {
22
+ unit: { type: 'choice', default: 'line', options: ['line', 'word'], label: 'What rises together' },
23
+ stagger: { type: 'number', default: 0.08, min: 0.04, max: 0.16, step: 0.005, unit: 's', label: 'Delay between units' },
24
+ duration: { type: 'number', default: 0.9, min: 0.5, max: 1.4, step: 0.05, unit: 's', label: 'Time per unit' },
25
+ tilt: { type: 'number', default: 0, min: 0, max: 8, step: 0.5, unit: 'deg', label: 'Tilt that settles as it rises' },
26
+ from: { type: 'choice', default: 'start', options: STAGGER_FROM, label: 'Which unit goes first' },
27
+ ease: { type: 'ease', default: 'expressive.out', label: 'Curve of each rise' },
28
+ feather: { type: 'number', default: 0, min: 0, max: 0.4, step: 0.01, unit: 'em', label: 'A soft edge to rise out of, instead of a hard line (0.1–0.12 em reads as soft)' },
29
+ },
30
+ duration: (props, p, ctx) => span(props, p, ctx.seed) * num(p.stagger) + num(p.duration),
31
+ build(el, props, p, ctx) {
32
+ const byWord = p.unit === 'word';
33
+ const split = splitText(el, str(props.text), { mask: byWord ? 'word' : 'line', accent: list(props.accent), feather: num(p.feather) });
34
+ const units = byWord ? split.words : split.lines;
35
+ // Measured lines can outnumber "\n" lines; the stagger shrinks so the reveal
36
+ // still ends when the timeline says it does.
37
+ const steps = staggerSpan(units.length, str(p.from), ctx.seed);
38
+ const budget = span(props, p, ctx.seed);
39
+ const stagger = steps > budget && steps > 0 ? (num(p.stagger) * budget) / steps : num(p.stagger);
40
+ const delays = staggerDelays(units.length, stagger, str(p.from), ctx.seed);
41
+ const ease = ctx.ease(p.ease), dur = num(p.duration), tilt = num(p.tilt);
42
+ // A feathered mask reaches further down, so the unit starts that much lower.
43
+ const feather = num(p.feather);
44
+ for (const u of units) {
45
+ u.style.transformOrigin = '0% 100%';
46
+ u.style.willChange = 'transform';
47
+ }
48
+ return {
49
+ seek(t) {
50
+ units.forEach((u, i) => {
51
+ const k = progress(t, delays[i], dur, ease);
52
+ const off = 1 - k;
53
+ u.style.transform = off === 0 ? '' : `translateY(${feather > 0 ? `calc(${(off * 110).toFixed(3)}% + ${(off * feather).toFixed(4)}em)` : `${(off * 110).toFixed(3)}%`}) rotate(${(off * tilt).toFixed(3)}deg)`;
54
+ });
55
+ },
56
+ };
57
+ },
58
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const scramble: Primitive;
@@ -0,0 +1,34 @@
1
+ // type/scramble. See library/primitives/type/scramble.md.
2
+ import { rng } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ const GLYPHS = 'ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/+';
5
+ const STEP = 1 / 20; // glyphs change 20 times a second, whatever the frame rate
6
+ export const scramble = {
7
+ slug: 'type/scramble',
8
+ summary: 'Characters cycle randomly before settling.',
9
+ props: { text: { type: 'string', required: true, label: 'The text to settle on' } },
10
+ params: {
11
+ duration: { type: 'number', default: 0.8, min: 0.6, max: 1.0, step: 0.05, unit: 's', label: 'Time to settle' },
12
+ },
13
+ duration: (_props, p) => num(p.duration),
14
+ build(el, props, p, ctx) {
15
+ const chars = [...str(props.text)];
16
+ const dur = num(p.duration);
17
+ el.style.whiteSpace = 'pre';
18
+ el.style.fontVariantNumeric = 'tabular-nums';
19
+ return {
20
+ seek(t) {
21
+ const locked = dur <= 0 ? chars.length : Math.floor((Math.max(0, t) / dur) * chars.length + 1e-6);
22
+ const tick = Math.floor(Math.max(0, t) / STEP);
23
+ el.textContent = chars
24
+ .map((c, i) => {
25
+ if (i < locked || c === ' ')
26
+ return c;
27
+ const r = rng(ctx.seed * 7919 + tick * 131 + i);
28
+ return GLYPHS[Math.floor(r() * GLYPHS.length)] ?? c;
29
+ })
30
+ .join('');
31
+ },
32
+ };
33
+ },
34
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const scribbleHighlight: Primitive;
@@ -0,0 +1,84 @@
1
+ // type/scribble-highlight. See library/primitives/type/scribble-highlight.md.
2
+ import { progress, rng } from "../../core/ease.js";
3
+ import { bare, splitText } from "../split.js";
4
+ import { list, num, str } from "../types.js";
5
+ const SVG = 'http://www.w3.org/2000/svg';
6
+ /** A hand-drawn path for a mark over a box w × h, wobbling a little by seed. */
7
+ function markPath(kind, w, h, r) {
8
+ const j = (a) => (r() - 0.5) * a; // jitter
9
+ if (kind === 'circle') {
10
+ // A loop that overshoots its start, as a pen does.
11
+ const cx = w / 2, cy = h / 2, rx = w / 2 + h * 0.35, ry = h * 0.72;
12
+ const pts = [];
13
+ for (let i = 0; i <= 28; i++) {
14
+ const a = -Math.PI * 0.62 + (i / 28) * Math.PI * 2.18;
15
+ const wob = 1 + j(0.06);
16
+ pts.push(`${(cx + Math.cos(a) * rx * wob).toFixed(1)},${(cy + Math.sin(a) * ry * wob + (i / 28) * h * 0.08).toFixed(1)}`);
17
+ }
18
+ return `M${pts.join('L')}`;
19
+ }
20
+ if (kind === 'strike')
21
+ return `M${-h * 0.1},${h * 0.56 + j(4)} C${w * 0.3},${h * 0.5 + j(6)} ${w * 0.7},${h * 0.6 + j(6)} ${w + h * 0.1},${h * 0.5 + j(4)}`;
22
+ if (kind === 'marker') {
23
+ // Two strokes of a broad marker, back and forth.
24
+ const y1 = h * 0.42, y2 = h * 0.7;
25
+ return `M${-h * 0.08},${y1 + j(4)} L${w + h * 0.1},${y1 + j(5)} L${-h * 0.05},${y2 + j(5)} L${w + h * 0.06},${y2 + j(4)}`;
26
+ }
27
+ // underline: a confident stroke that rises a touch at the end
28
+ const y = h * 1.02;
29
+ return `M${-h * 0.05},${y + j(3)} C${w * 0.35},${y + h * 0.06 + j(4)} ${w * 0.65},${y - h * 0.02 + j(4)} ${w + h * 0.12},${y - h * 0.12 + j(3)}`;
30
+ }
31
+ export const scribbleHighlight = {
32
+ slug: 'type/scribble-highlight',
33
+ summary: 'A hand-drawn mark draws under or around a word.',
34
+ props: {
35
+ text: { type: 'string', required: true, label: 'The sentence' },
36
+ mark: { type: 'string[]', required: true, label: 'Words to mark (a run of words gets one mark)' },
37
+ },
38
+ params: {
39
+ duration: { type: 'number', default: 0.5, min: 0.3, max: 0.9, step: 0.05, unit: 's', label: 'Time to draw the mark' },
40
+ kind: { type: 'choice', default: 'underline', options: ['underline', 'circle', 'marker', 'strike'], label: 'Mark' },
41
+ delay: { type: 'number', default: 0.3, min: 0, max: 2, step: 0.05, unit: 's', label: 'Wait before drawing' },
42
+ weight: { type: 'number', default: 0.08, min: 0.03, max: 0.4, step: 0.01, unit: 'em', label: 'Stroke weight (a marker uses about 0.35)' },
43
+ },
44
+ duration: (_props, p) => num(p.delay) + num(p.duration),
45
+ build(el, props, p, ctx) {
46
+ const marked = new Set(list(props.mark).map(bare));
47
+ const { words } = splitText(el, str(props.text));
48
+ el.style.position = 'relative';
49
+ const hit = words.filter((w) => marked.has(bare(w.textContent ?? '')));
50
+ if (!hit.length)
51
+ return { seek() { } };
52
+ // One mark over the run from the first to the last marked word on that line.
53
+ const first = hit[0], last = hit[hit.length - 1];
54
+ const box = el.getBoundingClientRect(), a = first.getBoundingClientRect(), b = last.getBoundingClientRect();
55
+ const scale = el.offsetWidth > 0 ? box.width / el.offsetWidth : 1;
56
+ const x = (a.left - box.left) / scale, y = (a.top - box.top) / scale;
57
+ const w = (b.right - a.left) / scale, h = a.height / scale;
58
+ const kind = str(p.kind), size = parseFloat(getComputedStyle(el).fontSize) || 16;
59
+ const svg = el.ownerDocument.createElementNS(SVG, 'svg');
60
+ svg.setAttribute('width', String(w));
61
+ svg.setAttribute('height', String(h));
62
+ svg.style.cssText = `position:absolute;left:${x}px;top:${y}px;overflow:visible;pointer-events:none;${kind === 'marker' ? 'z-index:-1;mix-blend-mode:multiply' : ''}`;
63
+ const path = el.ownerDocument.createElementNS(SVG, 'path');
64
+ path.setAttribute('d', markPath(kind, w, h, rng(ctx.seed * 31 + w)));
65
+ path.setAttribute('fill', 'none');
66
+ path.setAttribute('stroke', kind === 'marker' ? 'color-mix(in srgb, var(--m-accent) 45%, transparent)' : 'var(--m-accent)');
67
+ path.setAttribute('stroke-width', String(num(p.weight) * size * (kind === 'marker' ? 4.4 : 1)));
68
+ path.setAttribute('stroke-linecap', 'round');
69
+ path.setAttribute('stroke-linejoin', 'round');
70
+ path.setAttribute('pathLength', '1');
71
+ path.setAttribute('stroke-dasharray', '1 1');
72
+ svg.appendChild(path);
73
+ el.style.isolation = 'isolate';
74
+ el.appendChild(svg);
75
+ const ease = ctx.ease('quart.inOut'), delay = num(p.delay), dur = num(p.duration);
76
+ return {
77
+ seek(t) {
78
+ const k = progress(t, delay, dur, ease);
79
+ path.setAttribute('stroke-dashoffset', (1 - k).toFixed(4));
80
+ svg.style.visibility = k <= 0 ? 'hidden' : 'inherit';
81
+ },
82
+ };
83
+ },
84
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const shimmer: Primitive;
@@ -0,0 +1,35 @@
1
+ // type/shimmer. See library/primitives/type/shimmer.md.
2
+ import { num, str } from "../types.js";
3
+ export const shimmer = {
4
+ slug: 'type/shimmer',
5
+ summary: 'A band of light passes across the letters, again and again.',
6
+ props: { text: { type: 'string', required: true, label: 'The text' } },
7
+ params: {
8
+ period: { type: 'number', default: 2.4, min: 1.2, max: 4, step: 0.1, unit: 's', label: 'Time between passes' },
9
+ band: { type: 'number', default: 0.22, min: 0.1, max: 0.5, step: 0.01, unit: 'ratio', label: 'Width of the band' },
10
+ strength: { type: 'number', default: 0.65, min: 0.3, max: 1, step: 0.05, unit: 'ratio', label: 'How dim the text is outside the band' },
11
+ },
12
+ // Ambient: it shines for as long as its scene. A scene a whole number of periods long loops.
13
+ duration: () => 0,
14
+ build(el, props, p, ctx) {
15
+ const inner = el.ownerDocument.createElement('span');
16
+ inner.textContent = str(props.text);
17
+ const band = num(p.band), period = Math.max(0.2, num(p.period)), dim = 100 - Math.round(num(p.strength) * 100);
18
+ const ease = ctx.ease('sine.inOut');
19
+ // The text is the gradient: dimmed colour everywhere, full colour in the band.
20
+ inner.style.cssText = 'display:inline-block;white-space:pre-line;-webkit-background-clip:text;background-clip:text;' +
21
+ `background-image:linear-gradient(100deg, color-mix(in srgb, currentColor ${dim}%, transparent) 0%, color-mix(in srgb, currentColor ${dim}%, transparent) ${50 - band * 50}%, currentColor 50%, color-mix(in srgb, currentColor ${dim}%, transparent) ${50 + band * 50}%, color-mix(in srgb, currentColor ${dim}%, transparent) 100%);` +
22
+ 'background-size:300% 100%;background-repeat:no-repeat';
23
+ // currentColor inside the gradient resolves against the span, so it keeps the layer's colour.
24
+ inner.style.setProperty('-webkit-text-fill-color', 'transparent');
25
+ el.appendChild(inner);
26
+ return {
27
+ seek(t) {
28
+ // Each pass sweeps across, then rests off the text for the remainder of the period.
29
+ const phase = (((t % period) + period) % period) / period;
30
+ const k = ease(Math.min(1, phase / 0.7));
31
+ inner.style.backgroundPosition = `${(100 - k * 100).toFixed(3)}% 0`;
32
+ },
33
+ };
34
+ },
35
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const trackingIn: Primitive;
@@ -0,0 +1,37 @@
1
+ // type/tracking-in. See library/primitives/type/tracking-in.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { num, str } from "../types.js";
4
+ export const trackingIn = {
5
+ slug: 'type/tracking-in',
6
+ summary: 'Wide-spaced letters close up to their set spacing while coming into focus.',
7
+ props: { text: { type: 'string', required: true, label: 'The title' } },
8
+ params: {
9
+ duration: { type: 'number', default: 1.6, min: 0.8, max: 3, step: 0.1, unit: 's', label: 'Time to close up' },
10
+ spread: { type: 'number', default: 0.5, min: 0.1, max: 1.2, step: 0.05, unit: 'em', label: 'Extra spacing at the start' },
11
+ blur: { type: 'number', default: 12, min: 0, max: 30, step: 1, unit: 'px', label: 'Start blur' },
12
+ },
13
+ duration: (_props, p) => num(p.duration),
14
+ build(el, props, p, ctx) {
15
+ const ease = ctx.ease('expressive.out');
16
+ const dur = num(p.duration), spread = num(p.spread), blur = num(p.blur);
17
+ const inner = el.ownerDocument.createElement('span');
18
+ inner.textContent = str(props.text);
19
+ inner.style.cssText = 'display:inline-block;white-space:pre-line';
20
+ el.appendChild(inner);
21
+ // Spacing is added after the last letter too; a matching negative margin keeps the line centred.
22
+ const base = parseFloat(getComputedStyle(el).letterSpacing) || 0;
23
+ const size = parseFloat(getComputedStyle(el).fontSize) || 16;
24
+ return {
25
+ seek(t) {
26
+ const k = progress(t, 0, dur, ease);
27
+ const fade = Math.min(1, t / (dur * 0.5));
28
+ const extra = (1 - k) * spread;
29
+ inner.style.letterSpacing = `${(base / size + extra).toFixed(4)}em`;
30
+ inner.style.marginRight = `${(-extra).toFixed(4)}em`;
31
+ inner.style.opacity = fade >= 1 ? '' : String(Math.max(0, fade));
32
+ const b = (1 - k) * blur;
33
+ inner.style.filter = b > 0.05 ? `blur(${b.toFixed(2)}px)` : '';
34
+ },
35
+ };
36
+ },
37
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const typedTitle: Primitive;
@@ -0,0 +1,33 @@
1
+ // type/typed-title. See library/primitives/type/typed-title.md.
2
+ import { num, str } from "../types.js";
3
+ export const typedTitle = {
4
+ slug: 'type/typed-title',
5
+ summary: 'Characters appear one by one with a caret.',
6
+ props: { text: { type: 'string', required: true, label: 'The text to type' } },
7
+ params: {
8
+ chars_per_s: { type: 'number', default: 20, min: 12, max: 30, step: 1, unit: 'chars/s', label: 'Typing speed' },
9
+ },
10
+ duration: (props, p) => [...str(props.text)].length / Math.max(1, num(p.chars_per_s)),
11
+ build(el, props, p) {
12
+ const chars = [...str(props.text)];
13
+ const cps = Math.max(1, num(p.chars_per_s));
14
+ const typed = document.createElement('span');
15
+ const rest = document.createElement('span');
16
+ const caret = document.createElement('span');
17
+ // The untyped part keeps its space, so the line does not move while it is typed.
18
+ rest.style.visibility = 'hidden';
19
+ caret.style.cssText = 'display:inline-block;width:0.06em;height:1em;margin:0 -0.03em;vertical-align:-0.12em;background:var(--m-accent)';
20
+ el.style.whiteSpace = 'pre-wrap';
21
+ el.append(typed, caret, rest);
22
+ return {
23
+ seek(t) {
24
+ const n = Math.min(chars.length, Math.floor(t * cps + 1e-6));
25
+ typed.textContent = chars.slice(0, n).join('');
26
+ rest.textContent = chars.slice(n).join('');
27
+ // Solid while typing; blinks at 1 Hz once typing has stopped.
28
+ const idle = t - chars.length / cps;
29
+ caret.style.opacity = idle > 0 && idle % 1 >= 0.5 ? '0' : '1';
30
+ },
31
+ };
32
+ },
33
+ };
@@ -0,0 +1,2 @@
1
+ import { type Primitive } from '../types.ts';
2
+ export declare const wordBuild: Primitive;
@@ -0,0 +1,44 @@
1
+ // type/word-build. See library/primitives/type/word-build.md.
2
+ import { progress } from "../../core/ease.js";
3
+ import { list, num, str } from "../types.js";
4
+ const words = (props) => str(props.text).split(/\s+/).filter(Boolean);
5
+ export const wordBuild = {
6
+ slug: 'type/word-build',
7
+ summary: 'Words rise and fade in one by one.',
8
+ props: {
9
+ text: { type: 'string', required: true, label: 'The line to build' },
10
+ accent: { type: 'string[]', default: [], label: 'Words set in the accent colour' },
11
+ },
12
+ params: {
13
+ rise: { type: 'number', default: 16, min: 12, max: 20, step: 1, unit: 'px', label: 'Rise' },
14
+ stagger: { type: 'number', default: 0.1, min: 0.08, max: 0.12, step: 0.005, unit: 's', label: 'Delay between words' },
15
+ word_duration: { type: 'number', default: 0.5, min: 0.3, max: 0.6, step: 0.01, unit: 's', label: 'Time per word' },
16
+ },
17
+ duration: (props, p) => Math.max(0, words(props).length - 1) * num(p.stagger) + num(p.word_duration),
18
+ build(el, props, p, ctx) {
19
+ const ease = ctx.ease(ctx.tokens.ease_enter);
20
+ const accent = new Set(list(props.accent).map((w) => w.toLowerCase()));
21
+ el.style.cssText += ';display:flex;flex-wrap:wrap;justify-content:center;gap:0 0.26em';
22
+ const spans = words(props).map((w) => {
23
+ const s = document.createElement('span');
24
+ s.textContent = w;
25
+ s.style.cssText = 'display:inline-block;will-change:transform,opacity';
26
+ if (accent.has(w.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '')))
27
+ s.style.color = 'var(--m-accent)';
28
+ el.appendChild(s);
29
+ return s;
30
+ });
31
+ // Every word has its place from the first frame: the line is laid out whole, so it
32
+ // never re-wraps or re-centres as words arrive, and nothing around it moves.
33
+ const stagger = num(p.stagger), dur = num(p.word_duration), rise = num(p.rise);
34
+ return {
35
+ seek(t) {
36
+ spans.forEach((s, i) => {
37
+ const k = progress(t, i * stagger, dur, ease);
38
+ s.style.opacity = String(Math.min(1, k * 1.6));
39
+ s.style.transform = `translateY(${(1 - k) * rise}px)`;
40
+ });
41
+ },
42
+ };
43
+ },
44
+ };