@bydiorama/motion 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/CREDITS.md +62 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -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,54 @@
1
+ import type { Artboard, Scene } from '../film/types.ts';
2
+ /** One part of the design, its box in the frame's px. */
3
+ export interface DesignLayer {
4
+ name: string;
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ /** An exported picture of the part, relative to the film. */
10
+ src?: string;
11
+ /** A flat colour, for rules and plain shapes. */
12
+ fill?: string;
13
+ /** What it is, when the shape alone does not say: a rule draws across, type rises into its line, a picture arrives last. */
14
+ kind?: DesignKind;
15
+ /** A primitive of its own, with props: used as given, placed and timed like the rest. */
16
+ use?: string;
17
+ props?: Record<string, unknown>;
18
+ }
19
+ export type DesignKind = 'rule' | 'type' | 'picture' | 'shape';
20
+ /** A frame of a design: its size, its background, and its parts from the bottom up, as the design stacks them. */
21
+ export interface Design {
22
+ width: number;
23
+ height: number;
24
+ background?: string;
25
+ layers: DesignLayer[];
26
+ }
27
+ export interface DesignOptions {
28
+ /** Time between one part's arrival and the next: seconds, or beats ("0.5b"). Default 0.3. */
29
+ step?: number | string;
30
+ /** How the frame meets the stage. Default cover, centred. */
31
+ fit?: Artboard['fit'];
32
+ align?: Artboard['align'];
33
+ }
34
+ /**
35
+ * What a part is, from its shape when it does not say: a long thin fill is a rule; a picture
36
+ * covering a sixth of the frame or more is a picture; any other picture is type (exported
37
+ * lettering, a logo); any other fill is a shape.
38
+ */
39
+ export declare function kindOf(l: DesignLayer, frame: {
40
+ width: number;
41
+ height: number;
42
+ }): DesignKind;
43
+ /** Parts in reading order: rows from the top (parts whose tops are within `tolerance` of the frame's height share a row), each row left to right. */
44
+ export declare function readingOrder<T extends {
45
+ x: number;
46
+ y: number;
47
+ }>(parts: T[], frameHeight: number, tolerance?: number): T[];
48
+ /**
49
+ * A scene that builds the design: rules draw across first, two at a time; type and shapes
50
+ * rise into place in reading order, a step apart; pictures arrive last, largest last. Every
51
+ * part keeps its place in the stack. Times use the step's unit, so with a tempo they land
52
+ * on the beat.
53
+ */
54
+ export declare function sceneFromDesign(id: string, design: Design, opts?: DesignOptions): Scene;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * What a part is, from its shape when it does not say: a long thin fill is a rule; a picture
3
+ * covering a sixth of the frame or more is a picture; any other picture is type (exported
4
+ * lettering, a logo); any other fill is a shape.
5
+ */
6
+ export function kindOf(l, frame) {
7
+ if (l.kind)
8
+ return l.kind;
9
+ const long = Math.max(l.width, l.height), thin = Math.min(l.width, l.height);
10
+ if (!l.src && thin > 0 && long / thin >= 20 && thin <= Math.max(frame.width, frame.height) * 0.01)
11
+ return 'rule';
12
+ if (l.src && (l.width * l.height) / (frame.width * frame.height) >= 1 / 6)
13
+ return 'picture';
14
+ return l.src ? 'type' : 'shape';
15
+ }
16
+ /** Parts in reading order: rows from the top (parts whose tops are within `tolerance` of the frame's height share a row), each row left to right. */
17
+ export function readingOrder(parts, frameHeight, tolerance = 0.04) {
18
+ const sorted = [...parts].sort((a, b) => a.y - b.y);
19
+ const rows = [];
20
+ for (const p of sorted) {
21
+ const row = rows[rows.length - 1];
22
+ if (row && p.y - row[0].y <= tolerance * frameHeight)
23
+ row.push(p);
24
+ else
25
+ rows.push([p]);
26
+ }
27
+ return rows.flatMap((r) => r.sort((a, b) => a.x - b.x));
28
+ }
29
+ const slug = (name) => name.toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'part';
30
+ /** `k` steps of `step`, in the step's own unit. */
31
+ function times(step, k) {
32
+ if (typeof step === 'number')
33
+ return Number((step * k).toFixed(4));
34
+ const m = /^\s*(\d+(?:\.\d+)?)\s*(b|beats?|bars?)\s*$/.exec(step);
35
+ if (!m)
36
+ throw new Error(`step is seconds or beats ("0.5b"), not "${step}".`);
37
+ const v = Number((Number(m[1]) * k).toFixed(4)), unit = m[2].startsWith('bar') ? 'bar' : 'b';
38
+ return `${v}${unit}`;
39
+ }
40
+ /**
41
+ * A scene that builds the design: rules draw across first, two at a time; type and shapes
42
+ * rise into place in reading order, a step apart; pictures arrive last, largest last. Every
43
+ * part keeps its place in the stack. Times use the step's unit, so with a tempo they land
44
+ * on the beat.
45
+ */
46
+ export function sceneFromDesign(id, design, opts = {}) {
47
+ const step = opts.step ?? 0.3, frame = { width: design.width, height: design.height };
48
+ const used = new Set();
49
+ const parts = design.layers.map((l) => {
50
+ let lid = slug(l.name), n = 2;
51
+ while (used.has(lid))
52
+ lid = `${slug(l.name)}-${n++}`;
53
+ used.add(lid);
54
+ return { ...l, id: lid, kind: kindOf(l, frame) };
55
+ });
56
+ // When each part arrives, in steps.
57
+ const at = new Map();
58
+ const rules = readingOrder(parts.filter((p) => p.kind === 'rule'), design.height);
59
+ rules.forEach((p, i) => at.set(p.id, Math.floor(i / 2)));
60
+ let k = rules.length ? 1 : 0;
61
+ for (const p of readingOrder(parts.filter((q) => q.kind === 'type' || q.kind === 'shape'), design.height))
62
+ at.set(p.id, k++);
63
+ for (const p of parts.filter((q) => q.kind === 'picture').sort((a, b) => a.width * a.height - b.width * b.height))
64
+ at.set(p.id, k++);
65
+ const enter = (p) => {
66
+ if (p.kind === 'rule')
67
+ return { move: 'wipe', angle: p.width >= p.height ? 0 : 90, duration: times(step, 3), ease: 'expo.out' };
68
+ if (p.kind === 'picture')
69
+ return { move: 'slot-up', duration: times(step, 2) };
70
+ if (p.kind === 'type')
71
+ return { move: 'mask-up', duration: times(step, 2) };
72
+ return { move: 'fade', duration: times(step, 2) };
73
+ };
74
+ const layers = parts.map((p) => {
75
+ const place = { x: p.x, y: p.y, anchor: 'top-left', unit: 'px' };
76
+ const base = p.use
77
+ ? { use: p.use, props: p.props ?? {} }
78
+ : p.src
79
+ ? { use: 'el/image', props: { src: p.src, alt: '' }, params: { width: p.width, radius: 0 } }
80
+ : { use: 'el/box', props: { fill: p.fill ?? '#000000' }, params: { width: p.width, height: p.height, radius: 0 } };
81
+ const when = at.get(p.id) ?? 0;
82
+ return { id: p.id, ...base, place, ...(when ? { at: times(step, when) } : {}), enter: enter(p) };
83
+ });
84
+ return {
85
+ id,
86
+ ...(design.background ? { background: design.background } : {}),
87
+ layout: { padding: 0 },
88
+ artboard: { width: design.width, height: design.height, ...(opts.fit ? { fit: opts.fit } : {}), ...(opts.align ? { align: opts.align } : {}) },
89
+ layers,
90
+ };
91
+ }
@@ -0,0 +1,39 @@
1
+ import type { Film, Layer, Place, Scene } from '../film/types.ts';
2
+ export { iso, type IsoFace, type Vec3 } from './iso.ts';
3
+ export { sceneFromDesign, kindOf, readingOrder, type Design, type DesignLayer, type DesignKind, type DesignOptions } from './design.ts';
4
+ type Without<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
5
+ /** A film, with the library version filled in. */
6
+ export declare const film: (spec: Without<Film, "motion">) => Film;
7
+ /** A scene. Layers may be nested lists, as `repeat` returns; they are flattened. */
8
+ export declare const scene: (id: string, layers: (Layer | Layer[])[], more?: Omit<Partial<Scene>, "id" | "layers">) => Scene;
9
+ /** A layer: a primitive slug with its props, params, timing and placement. */
10
+ export declare const layer: (id: string, use: string, more?: Omit<Partial<Layer>, "id" | "use">) => Layer;
11
+ /** `n` of something: `fn(i)` for i from 0, flattened when it returns several. */
12
+ export declare function repeat<T>(n: number, fn: (i: number) => T | T[]): T[];
13
+ /**
14
+ * Places for `count` items in rows of `columns`, centred in an area of the stage
15
+ * given in %: `{ x: [left, right], y: [top, bottom] }`, the whole stage less a
16
+ * margin by default.
17
+ */
18
+ export declare function grid(count: number, columns: number, area?: {
19
+ x?: [number, number];
20
+ y?: [number, number];
21
+ }): Place[];
22
+ /**
23
+ * Times placed layers so the nearest to `focus` (in % of the stage) start first,
24
+ * `step` seconds apart, from `start`. Layers at the same distance start together.
25
+ * Layers without `place` keep their own `at`. For layers placed in px on an artboard,
26
+ * pass the `artboard`: positions and `focus` are then read as % of it.
27
+ */
28
+ export declare function staggerFrom<T extends Layer>(layers: T[], opts: {
29
+ focus: [number, number];
30
+ step: number;
31
+ start?: number;
32
+ aspect?: number;
33
+ artboard?: {
34
+ width: number;
35
+ height: number;
36
+ };
37
+ }): T[];
38
+ /** Times layers one after another: each starts `gap` seconds after the previous one ends. */
39
+ export declare function sequence<T extends Layer>(layers: T[], gap?: number, start?: number | string): T[];
@@ -0,0 +1,66 @@
1
+ // Building films in code. A film is JSON, and for a short film writing it by
2
+ // hand is the clearest route. When a film repeats itself (a card per photo, a
3
+ // frame per year, a pin per stop) write a script instead: it returns the film,
4
+ // and `motion make script.mjs` checks it and writes the .film.json.
5
+ //
6
+ // import { film, scene, layer, repeat, grid, staggerFrom } from '@bydiorama/motion/build';
7
+ // export default film({ size: [1920, 1080], scenes: [
8
+ // scene('wall', staggerFrom(repeat(12, (i) => layer(`card-${i}`, 'el/image', {
9
+ // props: { src: `photos/${i}.jpg` }, place: grid(12, 4)[i],
10
+ // })), { focus: [50, 40], step: 0.05 })),
11
+ // ] });
12
+ //
13
+ // Everything here returns plain film JSON; nothing is hidden from `motion inspect`.
14
+ import { staggerByDistance } from "../core/stagger.js";
15
+ import { VERSION } from "../version.js";
16
+ export { iso } from "./iso.js";
17
+ export { sceneFromDesign, kindOf, readingOrder } from "./design.js";
18
+ /** A film, with the library version filled in. */
19
+ export const film = (spec) => ({ motion: VERSION, ...spec });
20
+ /** A scene. Layers may be nested lists, as `repeat` returns; they are flattened. */
21
+ export const scene = (id, layers, more = {}) => ({ id, ...more, layers: layers.flat() });
22
+ /** A layer: a primitive slug with its props, params, timing and placement. */
23
+ export const layer = (id, use, more = {}) => ({ id, use, ...more });
24
+ /** `n` of something: `fn(i)` for i from 0, flattened when it returns several. */
25
+ export function repeat(n, fn) {
26
+ return Array.from({ length: Math.max(0, Math.floor(n)) }, (_, i) => fn(i)).flat();
27
+ }
28
+ /**
29
+ * Places for `count` items in rows of `columns`, centred in an area of the stage
30
+ * given in %: `{ x: [left, right], y: [top, bottom] }`, the whole stage less a
31
+ * margin by default.
32
+ */
33
+ export function grid(count, columns, area = {}) {
34
+ const [x0, x1] = area.x ?? [10, 90], [y0, y1] = area.y ?? [12, 88];
35
+ const cols = Math.max(1, Math.round(columns)), rows = Math.max(1, Math.ceil(count / cols));
36
+ const cell = (a, b, n, i) => a + ((b - a) * (i + 0.5)) / n;
37
+ return repeat(count, (i) => ({ x: round(cell(x0, x1, cols, i % cols)), y: round(cell(y0, y1, rows, Math.floor(i / cols))) }));
38
+ }
39
+ /**
40
+ * Times placed layers so the nearest to `focus` (in % of the stage) start first,
41
+ * `step` seconds apart, from `start`. Layers at the same distance start together.
42
+ * Layers without `place` keep their own `at`. For layers placed in px on an artboard,
43
+ * pass the `artboard`: positions and `focus` are then read as % of it.
44
+ */
45
+ export function staggerFrom(layers, opts) {
46
+ // Distances are measured on the frame, so % across counts for more on a wide one.
47
+ const ab = opts.artboard;
48
+ const aspect = opts.aspect ?? (ab ? ab.width / ab.height : 16 / 9);
49
+ const placed = layers.filter((l) => l.place);
50
+ const pos = (l) => {
51
+ const p = l.place;
52
+ if (p.unit !== 'px')
53
+ return [p.x, p.y];
54
+ if (!ab)
55
+ throw new Error(`staggerFrom: layer "${l.id}" is placed in px; pass the scene's artboard.`);
56
+ return [(p.x / ab.width) * 100, (p.y / ab.height) * 100];
57
+ };
58
+ const steps = staggerByDistance(placed.map((l) => { const [x, y] = pos(l); return [x * aspect, y]; }), [opts.focus[0] * aspect, opts.focus[1]], 0.01);
59
+ const at = new Map(placed.map((l, i) => [l, round((opts.start ?? 0) + steps[i] * opts.step, 4)]));
60
+ return layers.map((l) => (at.has(l) ? { ...l, at: at.get(l) } : l));
61
+ }
62
+ /** Times layers one after another: each starts `gap` seconds after the previous one ends. */
63
+ export function sequence(layers, gap = 0, start = 0) {
64
+ return layers.map((l, i) => ({ ...l, at: i === 0 ? start : `${layers[i - 1].id}.end${gap ? ` ${gap < 0 ? '-' : '+'} ${Math.abs(gap)}` : ''}` }));
65
+ }
66
+ const round = (n, d = 3) => Number(n.toFixed(d));
@@ -0,0 +1,41 @@
1
+ export type Vec3 = readonly [number, number, number];
2
+ /**
3
+ * A face a flat drawing can lie on. Its u runs right in the drawing and v down.
4
+ * floor: u along x, v along y (any height).
5
+ * front-right: an upright face looking to the front right; u along x, v down.
6
+ * front-left: an upright face looking to the front left; u along y, v down.
7
+ */
8
+ export type IsoFace = 'floor' | 'front-right' | 'front-left';
9
+ /** Where a world point is seen, in px from the world's origin on stage. */
10
+ declare function point(x: number, y: number, z?: number): [number, number];
11
+ /** The world point on the floor at height z that is seen at stage offset [sx, sy]. */
12
+ declare function unproject(sx: number, sy: number, z?: number): [number, number];
13
+ /**
14
+ * An SVG transform that lays a flat drawing onto a face, its top-left corner at
15
+ * the world point `at`. `origin` is where the world's origin is in the SVG.
16
+ */
17
+ declare function matrix(face: IsoFace, at: Vec3, origin?: readonly [number, number]): string;
18
+ /** SVG path data through world points, in stage px from `origin`. */
19
+ declare function path(points: readonly Vec3[], close?: boolean, origin?: readonly [number, number]): string;
20
+ /** The corners of a rectangle on a face, from its top-left corner `at`, `w` along u and `h` along v. */
21
+ declare function quad(face: IsoFace, at: Vec3, w: number, h: number): Vec3[];
22
+ /**
23
+ * Dots on every crossing of an isometric floor grid of `cell` px, as an SVG of
24
+ * `w` × `h` with the world's origin at `origin` on a dot.
25
+ */
26
+ declare function lattice(w: number, h: number, cell: number, origin: readonly [number, number], dot?: {
27
+ r?: number;
28
+ color?: string;
29
+ }): string;
30
+ export declare const iso: {
31
+ readonly point: typeof point;
32
+ readonly unproject: typeof unproject;
33
+ readonly matrix: typeof matrix;
34
+ readonly path: typeof path;
35
+ readonly quad: typeof quad;
36
+ readonly lattice: typeof lattice;
37
+ readonly C: number;
38
+ readonly S: number;
39
+ readonly V: number;
40
+ };
41
+ export {};
@@ -0,0 +1,71 @@
1
+ // Isometric drawing for film scripts.
2
+ //
3
+ // A parallel isometric view is affine: a point in the world lands on stage by a
4
+ // fixed linear map, and a move in the world is the same move on stage wherever it
5
+ // happens. So an isometric scene can be drawn once as flat SVG and animated with
6
+ // ordinary x and y tracks, and a flat drawing can be laid onto any face of it
7
+ // with one SVG matrix. The view is the one rig/layer-stack draws with `lay` at
8
+ // ISOMETRIC_LAY, `turn` -45 and `lens` 0, so pieces drawn here line up with it.
9
+ //
10
+ // import { iso } from '@bydiorama/motion/build';
11
+ // const [x, y] = iso.point(120, 0, 40); // px from the world's origin on stage
12
+ // `<g transform="${iso.matrix('floor', [-60, -60, 0])}">…</g>` // a drawing lying on the floor
13
+ //
14
+ // World axes: x runs to the back right, y to the front right, z up. Units are
15
+ // stage px measured along the axis before the view foreshortens them.
16
+ const LAY = (54.7356 * Math.PI) / 180;
17
+ const C = Math.SQRT1_2, S = Math.SQRT1_2 * Math.cos(LAY), V = Math.sin(LAY);
18
+ const AXES = {
19
+ floor: [[C, -S], [C, S]],
20
+ 'front-right': [[C, -S], [0, V]],
21
+ 'front-left': [[C, S], [0, V]],
22
+ };
23
+ const f = (n) => Number(n.toFixed(3));
24
+ /** Where a world point is seen, in px from the world's origin on stage. */
25
+ function point(x, y, z = 0) {
26
+ return [(x + y) * C, (y - x) * S - z * V];
27
+ }
28
+ /** The world point on the floor at height z that is seen at stage offset [sx, sy]. */
29
+ function unproject(sx, sy, z = 0) {
30
+ const sum = sx / C, diff = (sy + z * V) / S;
31
+ return [(sum - diff) / 2, (sum + diff) / 2];
32
+ }
33
+ /**
34
+ * An SVG transform that lays a flat drawing onto a face, its top-left corner at
35
+ * the world point `at`. `origin` is where the world's origin is in the SVG.
36
+ */
37
+ function matrix(face, at, origin = [0, 0]) {
38
+ const [[a, b], [c, d]] = AXES[face];
39
+ const [e, g] = point(...at);
40
+ const k = (n) => Number(n.toFixed(6));
41
+ return `matrix(${k(a)} ${k(b)} ${k(c)} ${k(d)} ${f(e + origin[0])} ${f(g + origin[1])})`;
42
+ }
43
+ /** SVG path data through world points, in stage px from `origin`. */
44
+ function path(points, close = false, origin = [0, 0]) {
45
+ return points.map((p, i) => {
46
+ const [x, y] = point(...p);
47
+ return `${i ? 'L' : 'M'}${f(x + origin[0])} ${f(y + origin[1])}`;
48
+ }).join('') + (close ? 'Z' : '');
49
+ }
50
+ /** The corners of a rectangle on a face, from its top-left corner `at`, `w` along u and `h` along v. */
51
+ function quad(face, at, w, h) {
52
+ const [x, y, z] = at;
53
+ if (face === 'floor')
54
+ return [[x, y, z], [x + w, y, z], [x + w, y + h, z], [x, y + h, z]];
55
+ if (face === 'front-right')
56
+ return [[x, y, z], [x + w, y, z], [x + w, y, z - h], [x, y, z - h]];
57
+ return [[x, y, z], [x, y + w, z], [x, y + w, z - h], [x, y, z - h]];
58
+ }
59
+ /**
60
+ * Dots on every crossing of an isometric floor grid of `cell` px, as an SVG of
61
+ * `w` × `h` with the world's origin at `origin` on a dot.
62
+ */
63
+ function lattice(w, h, cell, origin, dot = {}) {
64
+ const pw = 2 * cell * C, ph = 2 * cell * S, r = dot.r ?? 1.6, color = dot.color ?? 'currentColor';
65
+ const ox = ((origin[0] % pw) + pw) % pw, oy = ((origin[1] % ph) + ph) % ph;
66
+ return `<svg width="${w}" height="${h}" viewBox="0 0 ${w} ${h}" style="display:block"><defs>`
67
+ + `<pattern id="iso-lattice" patternUnits="userSpaceOnUse" width="${f(pw)}" height="${f(ph)}" x="${f(ox)}" y="${f(oy)}">`
68
+ + [[0, 0], [pw, 0], [0, ph], [pw, ph], [pw / 2, ph / 2]].map(([x, y]) => `<circle cx="${f(x)}" cy="${f(y)}" r="${r}" fill="${color}"/>`).join('')
69
+ + `</pattern></defs><rect width="${w}" height="${h}" fill="url(#iso-lattice)"/></svg>`;
70
+ }
71
+ export const iso = { point, unproject, matrix, path, quad, lattice, C, S, V };
@@ -0,0 +1,24 @@
1
+ export declare function buildCatalog(): {
2
+ motion: string;
3
+ tokens: import("./tokens.ts").Tokens;
4
+ eases: readonly string[];
5
+ moves: readonly import("./index.ts").MoveName[];
6
+ tracks: readonly import("./index.ts").TrackProp[];
7
+ sizes: readonly import("./index.ts").TextSize[];
8
+ colors: readonly import("./index.ts").Tone[];
9
+ surfaces: readonly import("./index.ts").Surface[];
10
+ anchors: readonly ["center", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right"];
11
+ primitives: {
12
+ slug: string;
13
+ summary: string;
14
+ props: Record<string, import("./index.ts").PropSpec>;
15
+ params: Record<string, import("./index.ts").ParamSpec>;
16
+ }[];
17
+ transitions: {
18
+ calm?: Record<string, string | number | boolean>;
19
+ slug: string;
20
+ summary: string;
21
+ params: Record<string, import("./index.ts").ParamSpec>;
22
+ }[];
23
+ };
24
+ export type Catalog = ReturnType<typeof buildCatalog>;
@@ -0,0 +1,23 @@
1
+ // The catalog: everything a film may use, as data. An agent reads this instead
2
+ // of the source; the studio builds its dials from it; tools/validate.py checks
3
+ // it against the library entries.
4
+ import { EASE_NAMES } from "./core/ease.js";
5
+ import { ANCHORS, MOVE_NAMES, SURFACES, TEXT_SIZES, TONES, TRACK_PROPS } from "./film/types.js";
6
+ import { PRIMITIVES, TRANSITIONS } from "./primitives/index.js";
7
+ import { DEFAULT_TOKENS } from "./tokens.js";
8
+ import { VERSION } from "./version.js";
9
+ export function buildCatalog() {
10
+ return {
11
+ motion: VERSION,
12
+ tokens: DEFAULT_TOKENS,
13
+ eases: EASE_NAMES,
14
+ moves: MOVE_NAMES,
15
+ tracks: TRACK_PROPS,
16
+ sizes: TEXT_SIZES,
17
+ colors: TONES,
18
+ surfaces: SURFACES,
19
+ anchors: ANCHORS,
20
+ primitives: Object.values(PRIMITIVES).map(({ slug, summary, props, params }) => ({ slug, summary, props, params })),
21
+ transitions: Object.values(TRANSITIONS).map(({ slug, summary, params, calm }) => ({ slug, summary, params, ...(calm ? { calm } : {}) })),
22
+ };
23
+ }
@@ -0,0 +1,26 @@
1
+ import type { Browser, Page } from 'playwright';
2
+ import type { LayerBox } from '../dom/mount.ts';
3
+ import type { Timeline } from '../film/types.ts';
4
+ export interface Session {
5
+ page: Page;
6
+ duration: number;
7
+ fps: number;
8
+ frames: number;
9
+ size: [number, number];
10
+ /** Errors the page raised: script errors, failed requests, fonts that did not load. */
11
+ errors: string[];
12
+ seek(t: number): Promise<void>;
13
+ audit(t: number): Promise<LayerBox[]>;
14
+ close(): Promise<void>;
15
+ }
16
+ /** The browser to draw with: --browser, then MOTION_CHROMIUM, then Playwright's own. */
17
+ export declare const browserPath: (flag?: unknown) => string | undefined;
18
+ export declare function launch(executable?: string): Promise<Browser>;
19
+ export declare function open(film: string, opts: {
20
+ css?: string[];
21
+ scale?: number;
22
+ size: [number, number];
23
+ timeline?: Timeline;
24
+ browser?: string;
25
+ noTune?: boolean;
26
+ }): Promise<Session>;
@@ -0,0 +1,66 @@
1
+ import { prepareFrames } from "./frames.js";
2
+ import { serve } from "./server.js";
3
+ /** The browser to draw with: --browser, then MOTION_CHROMIUM, then Playwright's own. */
4
+ export const browserPath = (flag) => (typeof flag === 'string' && flag ? flag : undefined) ?? (process.env.MOTION_CHROMIUM || undefined);
5
+ export async function launch(executable) {
6
+ let chromium;
7
+ try {
8
+ ({ chromium } = await import('playwright'));
9
+ }
10
+ catch {
11
+ throw new Error('This command draws frames in a browser and needs Playwright. Run: pnpm install && pnpm exec playwright install chromium');
12
+ }
13
+ try {
14
+ return await chromium.launch(executable ? { executablePath: executable } : {});
15
+ }
16
+ catch (e) {
17
+ const hint = executable
18
+ ? `Could not start the browser at ${executable}.`
19
+ : 'Playwright\'s Chromium is not installed. Run: pnpm exec playwright install chromium, or point at an installed Chromium-based browser (Chrome, Brave, Edge) with --browser <path> or MOTION_CHROMIUM.';
20
+ throw new Error(`${hint}\n${e.message.split('\n')[0]}`);
21
+ }
22
+ }
23
+ export async function open(film, opts) {
24
+ // Footage is pulled before the page opens, so every frame of it is exact.
25
+ const frames = opts.timeline ? await prepareFrames(film, opts.timeline, opts.scale ?? 1, (m) => process.stderr.write(`${m}\n`)) : {};
26
+ const preview = await serve({ film, frames, ...(opts.css ? { css: opts.css } : {}), ...(opts.noTune ? { noTune: true } : {}) });
27
+ let browser;
28
+ try {
29
+ // --browser or MOTION_CHROMIUM point at a Chromium binary when Playwright's own download is not there.
30
+ browser = await launch(browserPath(opts.browser));
31
+ const context = await browser.newContext({ viewport: { width: opts.size[0], height: opts.size[1] }, deviceScaleFactor: opts.scale ?? 1 });
32
+ const page = await context.newPage();
33
+ const errors = [];
34
+ page.on('pageerror', (e) => errors.push(e.message));
35
+ // A load the page itself cancelled (a footage frame replaced by the next one) is not a failure.
36
+ page.on('requestfailed', (r) => { if (r.failure()?.errorText !== 'net::ERR_ABORTED')
37
+ errors.push(`Request failed: ${r.url()}`); });
38
+ page.on('console', (m) => { if (m.type() === 'error')
39
+ errors.push(m.text()); });
40
+ await page.goto(`${preview.url}#render`);
41
+ try {
42
+ await page.evaluate(() => window.ready);
43
+ }
44
+ catch (e) {
45
+ throw new Error(`The film did not load.\n${errors.join('\n') || e.message}`);
46
+ }
47
+ const info = await page.evaluate(() => ({
48
+ duration: window.duration, fps: window.fps,
49
+ fonts: [...document.fonts].filter((f) => f.status === 'error').map((f) => f.family),
50
+ }));
51
+ for (const f of info.fonts)
52
+ errors.push(`Font did not load: ${f}`);
53
+ const b = browser;
54
+ return {
55
+ page, errors, duration: info.duration, fps: info.fps, frames: Math.round(info.duration * info.fps), size: opts.size,
56
+ seek: (t) => page.evaluate((x) => window.seek(x), t),
57
+ audit: (t) => page.evaluate((x) => window.audit(x), t),
58
+ close: async () => { await b.close(); await preview.close(); },
59
+ };
60
+ }
61
+ catch (e) {
62
+ await browser?.close();
63
+ await preview.close();
64
+ throw e;
65
+ }
66
+ }
@@ -0,0 +1,26 @@
1
+ export interface CaptureOptions {
2
+ url: string;
3
+ out: string;
4
+ sections: boolean;
5
+ /** CSS selector for the sections. Default: `section`, then the children of `main`. */
6
+ selector?: string;
7
+ width: number;
8
+ scale: number;
9
+ /** Extra selectors to hide. */
10
+ hide: string[];
11
+ keepBanners: boolean;
12
+ keepHeader: boolean;
13
+ browser?: string;
14
+ }
15
+ export interface Captured {
16
+ file: string;
17
+ name: string;
18
+ selector: string;
19
+ x: number;
20
+ y: number;
21
+ width: number;
22
+ height: number;
23
+ }
24
+ /** Consent and cookie banners from common providers, and the usual hand-made ones. */
25
+ export declare const BANNERS: string[];
26
+ export declare function capture(o: CaptureOptions): Promise<Captured[]>;
@@ -0,0 +1,94 @@
1
+ // Screenshots of a web page for a film: the whole page, or each section on its
2
+ // own (--sections), at 2× by default, with cookie banners and fixed headers
3
+ // hidden so every picture is clean.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { browserPath, launch } from "./browser.js";
7
+ /** Consent and cookie banners from common providers, and the usual hand-made ones. */
8
+ export const BANNERS = [
9
+ '#onetrust-consent-sdk', '#onetrust-banner-sdk', '#CybotCookiebotDialog', '#CybotCookiebotDialogBodyUnderlay', '#usercentrics-root',
10
+ '#cookiescript_injected', '.cc-window', '.cc-banner', '#cmpbox', '#cmpbox2', '.qc-cmp2-container', '#didomi-host', '#truste-consent-track',
11
+ '#hs-eu-cookie-confirmation', '.osano-cm-window', '#axeptio_overlay', '#tarteaucitronRoot', '.fc-consent-root', '#sp_message_container',
12
+ '[id*="cookie-banner" i]', '[class*="cookie-banner" i]', '[id*="cookie-consent" i]', '[class*="cookie-consent" i]', '[id*="cookie-notice" i]',
13
+ '[class*="cookie-notice" i]', '[aria-label*="cookie" i][role="dialog"]', '[aria-label*="consent" i][role="dialog"]',
14
+ ];
15
+ const slug = (s) => s.toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 40);
16
+ export async function capture(o) {
17
+ const browser = await launch(browserPath(o.browser));
18
+ try {
19
+ const page = await browser.newPage({ viewport: { width: o.width, height: 900 }, deviceScaleFactor: o.scale });
20
+ try {
21
+ await page.goto(o.url, { waitUntil: 'networkidle', timeout: 45_000 });
22
+ }
23
+ catch {
24
+ await page.goto(o.url, { waitUntil: 'load', timeout: 60_000 });
25
+ }
26
+ const hide = [...(o.keepBanners ? [] : BANNERS), ...o.hide];
27
+ if (hide.length)
28
+ await page.addStyleTag({ content: `${hide.join(',\n')} { display: none !important; }\nhtml, body { overflow: visible !important; }` });
29
+ // Scroll through once so lazy pictures load and scroll-triggered reveals finish.
30
+ await page.evaluate(async () => {
31
+ const step = Math.max(200, Math.round(innerHeight * 0.8));
32
+ for (let y = 0; y < document.documentElement.scrollHeight; y += step) {
33
+ scrollTo(0, y);
34
+ await new Promise((r) => setTimeout(r, 120));
35
+ }
36
+ scrollTo(0, 0);
37
+ await Promise.all([...document.images].filter((i) => !i.complete).map((i) => new Promise((r) => { i.addEventListener('load', r, { once: true }); i.addEventListener('error', r, { once: true }); setTimeout(r, 5000); })));
38
+ });
39
+ if (!o.keepHeader) {
40
+ // Headers and bars that stay put would sit on top of every section.
41
+ await page.evaluate(() => {
42
+ for (const el of document.querySelectorAll('body *')) {
43
+ const pos = getComputedStyle(el).position;
44
+ if (pos === 'fixed')
45
+ el.style.setProperty('display', 'none', 'important');
46
+ else if (pos === 'sticky')
47
+ el.style.setProperty('position', 'relative', 'important');
48
+ }
49
+ });
50
+ }
51
+ await page.waitForTimeout(300);
52
+ fs.mkdirSync(o.out, { recursive: true });
53
+ if (!o.sections) {
54
+ const file = path.join(o.out, 'page.png');
55
+ await page.screenshot({ path: file, fullPage: true, animations: 'disabled' });
56
+ const size = await page.evaluate(() => [document.documentElement.scrollWidth, document.documentElement.scrollHeight]);
57
+ return [{ file, name: 'page', selector: 'html', x: 0, y: 0, width: size[0], height: size[1] }];
58
+ }
59
+ const found = await page.evaluate((sel) => {
60
+ const pick = (s) => [...document.querySelectorAll(s)];
61
+ let els = sel ? pick(sel) : pick('section');
62
+ let used = sel || 'section';
63
+ if (!sel && els.length < 2) {
64
+ els = pick('main > *');
65
+ used = 'main > *';
66
+ }
67
+ if (!sel && els.length < 2) {
68
+ els = pick('body > *');
69
+ used = 'body > *';
70
+ }
71
+ // Outermost matches only, and only what has a size.
72
+ els = els.filter((e) => !els.some((o) => o !== e && o.contains(e)));
73
+ return els.map((e, i) => {
74
+ const r = e.getBoundingClientRect();
75
+ e.setAttribute('data-motion-capture', String(i));
76
+ const heading = e.querySelector('h1, h2, h3')?.textContent?.trim() ?? '';
77
+ return { i, used, id: e.id, label: e.getAttribute('aria-label') ?? '', heading, x: r.left + scrollX, y: r.top + scrollY, width: r.width, height: r.height };
78
+ }).filter((e) => e.width >= 50 && e.height >= 50);
79
+ }, o.selector ?? '');
80
+ if (!found.length)
81
+ throw new Error(`No sections found${o.selector ? ` for "${o.selector}"` : ''}. Name them with --selector, e.g. --selector "main > div".`);
82
+ const shots = [];
83
+ for (const [n, s] of found.entries()) {
84
+ const name = `${String(n + 1).padStart(2, '0')}${slug(s.id || s.label || s.heading) ? `-${slug(s.id || s.label || s.heading)}` : ''}`;
85
+ const file = path.join(o.out, `${name}.png`);
86
+ await page.locator(`[data-motion-capture="${s.i}"]`).screenshot({ path: file, animations: 'disabled' });
87
+ shots.push({ file, name, selector: s.used, x: Math.round(s.x), y: Math.round(s.y), width: Math.round(s.width), height: Math.round(s.height) });
88
+ }
89
+ return shots;
90
+ }
91
+ finally {
92
+ await browser.close();
93
+ }
94
+ }
@@ -0,0 +1,14 @@
1
+ import type { Film, Tune } from '../film/types.ts';
2
+ export declare const ROOT: string;
3
+ export declare const tunePath: (filmPath: string) => string;
4
+ export declare const filmName: (filmPath: string) => string;
5
+ export declare function readJson<T>(file: string): T;
6
+ export declare const readFilm: (file: string) => Film;
7
+ export declare const readTune: (filmPath: string) => Tune;
8
+ export declare const writeJson: (file: string, data: unknown) => void;
9
+ export declare function bundle(output?: string): Promise<string>;
10
+ export declare function wizardScript(): Promise<string>;
11
+ /** The wizard as one page, with the catalog and the library inlined. */
12
+ export declare function wizardPage(data: unknown): Promise<string>;
13
+ /** A stylesheet with its relative url() files inlined, so a built film is one file. */
14
+ export declare function inlineCss(file: string): string;