@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,87 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const source = import.meta.url.endsWith('.ts');
5
+ const cliDir = path.dirname(fileURLToPath(import.meta.url));
6
+ export const ROOT = path.resolve(cliDir, source ? '../..' : '../../..');
7
+ const assets = path.resolve(cliDir, '../browser');
8
+ export const tunePath = (filmPath) => filmPath.replace(/(\.film)?\.json$/, '.tune.json');
9
+ export const filmName = (filmPath) => path.basename(filmPath).replace(/(\.film)?\.json$/, '');
10
+ export function readJson(file) {
11
+ let text;
12
+ try {
13
+ text = fs.readFileSync(file, 'utf8');
14
+ }
15
+ catch {
16
+ throw new Error(`Cannot read ${file}`);
17
+ }
18
+ try {
19
+ return JSON.parse(text);
20
+ }
21
+ catch (e) {
22
+ throw new Error(`${file} is not valid JSON: ${e.message}`);
23
+ }
24
+ }
25
+ export const readFilm = (file) => readJson(file);
26
+ export const readTune = (filmPath) => (fs.existsSync(tunePath(filmPath)) ? readJson(tunePath(filmPath)) : { set: {}, notes: [] });
27
+ export const writeJson = (file, data) => {
28
+ fs.mkdirSync(path.dirname(file), { recursive: true });
29
+ fs.writeFileSync(file, `${JSON.stringify(data, null, 2)}\n`);
30
+ };
31
+ export async function bundle(output) {
32
+ if (!source) {
33
+ if (!output)
34
+ return path.join(assets, 'page.js');
35
+ fs.mkdirSync(output, { recursive: true });
36
+ for (const name of ['page.js', 'motion.js'])
37
+ fs.copyFileSync(path.join(assets, name), path.join(output, name));
38
+ return path.join(output, 'page.js');
39
+ }
40
+ const { build } = await import('esbuild');
41
+ const out = output ?? path.join(ROOT, 'dist');
42
+ const common = { bundle: true, format: 'esm', target: 'es2022', minify: true, legalComments: 'none', logLevel: 'warning', loader: { '.css': 'text', '.woff2': 'dataurl' } };
43
+ await build({ ...common, entryPoints: [path.join(ROOT, 'src/studio/entry.ts')], outfile: path.join(out, 'page.js') });
44
+ await build({ ...common, entryPoints: [path.join(ROOT, 'src/index.ts')], outfile: path.join(out, 'motion.js') });
45
+ return path.join(out, 'page.js');
46
+ }
47
+ export async function wizardScript() {
48
+ const { build } = await import('esbuild');
49
+ const result = await build({
50
+ entryPoints: [path.join(ROOT, 'src/wizard/entry.ts')], bundle: true, format: 'esm', target: 'es2022', minify: true, write: false,
51
+ legalComments: 'none', logLevel: 'warning', loader: { '.css': 'text', '.woff2': 'dataurl' },
52
+ });
53
+ return result.outputFiles[0].text;
54
+ }
55
+ /** The wizard as one page, with the catalog and the library inlined. */
56
+ export async function wizardPage(data) {
57
+ const js = (source ? await wizardScript() : fs.readFileSync(path.join(assets, 'wizard.js'), 'utf8'))
58
+ .replace(/<\/script/g, '<\\/script');
59
+ const json = JSON.stringify(data).replace(/</g, '\\u003c');
60
+ return `<!doctype html>
61
+ <html lang="en">
62
+ <head>
63
+ <meta charset="utf-8">
64
+ <meta name="viewport" content="width=device-width, initial-scale=1">
65
+ <title>Motion brief</title>
66
+ <meta name="color-scheme" content="light dark">
67
+ </head>
68
+ <body>
69
+ <div id="app"></div>
70
+ <script type="application/json" id="wizard-data">${json}</script>
71
+ <script type="module">${js}</script>
72
+ </body>
73
+ </html>
74
+ `;
75
+ }
76
+ /** A stylesheet with its relative url() files inlined, so a built film is one file. */
77
+ export function inlineCss(file) {
78
+ const dir = path.dirname(file);
79
+ const MIME = { '.woff2': 'font/woff2', '.woff': 'font/woff', '.ttf': 'font/ttf', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml' };
80
+ return fs.readFileSync(file, 'utf8').replace(/url\(\s*(['"]?)(?!data:|https?:|\/\/)([^'")]+)\1\s*\)/g, (whole, _q, ref) => {
81
+ const target = path.resolve(dir, ref.split(/[?#]/)[0]);
82
+ const mime = MIME[path.extname(target).toLowerCase()];
83
+ if (!mime || !fs.existsSync(target))
84
+ return whole;
85
+ return `url(data:${mime};base64,${fs.readFileSync(target).toString('base64')})`;
86
+ });
87
+ }
@@ -0,0 +1,27 @@
1
+ import type { Timeline } from '../film/types.ts';
2
+ import type { FrameSequence } from '../primitives/types.ts';
3
+ /** What one layer needs pulled: a stretch of source, at a rate, at a width. */
4
+ export interface FootageNeed {
5
+ key: string;
6
+ src: string;
7
+ /** Source seconds of the first frame, and how long a stretch. */
8
+ start: number;
9
+ length: number;
10
+ /** Frames per source second. */
11
+ rate: number;
12
+ /** Width of the pulled frames in px; the height follows the shot. */
13
+ width: number;
14
+ /** A footage plane's marks file (`motion record --marks`), to send with the frames. */
15
+ marks?: string;
16
+ /** The width the deepest zoom needs: less than this from the source is undersampled. */
17
+ wants?: number;
18
+ }
19
+ /** The footage every el/video layer shows, worked out from the timeline alone. */
20
+ export declare function footageNeeds(t: Timeline, filmDir: string, scale?: number): FootageNeed[];
21
+ /** Width and height of a JPEG, read from its frame header. */
22
+ export declare function jpegSize(buf: Buffer): [number, number] | undefined;
23
+ /**
24
+ * Pulls the frames for every el/video layer, reusing what is cached, and
25
+ * returns them by "<scene>/<layer>" with URLs the preview server answers.
26
+ */
27
+ export declare function prepareFrames(filmFile: string, t: Timeline, scale?: number, log?: (s: string) => void): Promise<Record<string, FrameSequence>>;
@@ -0,0 +1,125 @@
1
+ // Footage for renders. Every el/video layer gets the frames it shows pulled
2
+ // out with ffmpeg into numbered JPEGs, once per film frame of source time, so a
3
+ // render, a check or a still is frame-exact and never waits on a video decoder.
4
+ // The frames are cached in out/<film>/frames/ and reused while nothing changes.
5
+ import { spawn } from 'node:child_process';
6
+ import { createHash } from 'node:crypto';
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ import { cropOf, sourceTime } from "../primitives/el/video.js";
10
+ import { isPicture } from "../primitives/rig/footage-plane.js";
11
+ import { filmName } from "./files.js";
12
+ /** Layers that show footage, pulled frame by frame. */
13
+ const FOOTAGE = new Set(['el/video', 'rig/footage-plane']);
14
+ const isUrl = (s) => /^[a-z][a-z0-9+.-]*:\/\//i.test(s);
15
+ /** The footage every el/video layer shows, worked out from the timeline alone. */
16
+ export function footageNeeds(t, filmDir, scale = 1) {
17
+ const needs = [];
18
+ const frame = 1 / t.fps;
19
+ for (const s of t.scenes) {
20
+ for (const l of s.layers) {
21
+ if (!FOOTAGE.has(l.use))
22
+ continue;
23
+ const src = String(l.props.src);
24
+ if (l.use === 'rig/footage-plane' && isPicture(src))
25
+ continue;
26
+ const rate = typeof l.params.rate === 'number' ? l.params.rate : 1;
27
+ const from = typeof l.props.from === 'number' ? l.props.from : 0, to = typeof l.props.to === 'number' ? l.props.to : 0;
28
+ // On screen from its start to its exit's end, or to the scene's last frame.
29
+ const visible = Math.min(s.length, l.exit ? l.exit.start + l.exit.duration : s.length) - l.start;
30
+ const looped = l.params.loop === true && to > from;
31
+ const end = looped ? to : sourceTime(Math.max(0, visible - frame), l.props, l.params) + frame * rate;
32
+ const [, , cw] = cropOf(l.props.crop);
33
+ const base = { src: isUrl(src) ? src : path.resolve(filmDir, src), start: from, length: Math.max(frame * rate, end - from), rate: t.fps * rate };
34
+ if (l.use === 'rig/footage-plane') {
35
+ // A plane is seen as close as the scene's camera goes: pull enough for its deepest zoom,
36
+ // then halve it until it is small enough for the widest view, so every size is drawn
37
+ // from a copy near it (mips) and nothing shimmers as the camera pulls out.
38
+ const shown = (typeof l.params.width === 'number' ? l.params.width : 1080) * scale;
39
+ const zooms = s.camera?.map((k) => k.zoom * (1 + Math.max(0, k.drift) * s.length)) ?? [1];
40
+ const deep = Math.max(1, ...zooms), wide = Math.min(1, ...zooms);
41
+ const top = Math.ceil((shown * deep) / 2) * 2;
42
+ const marks = typeof l.props.marks === 'string' && l.props.marks ? (isUrl(l.props.marks) ? l.props.marks : path.resolve(filmDir, l.props.marks)) : undefined;
43
+ needs.push({ key: `${s.id}/${l.id}`, ...base, width: top, wants: top, ...(marks ? { marks } : {}) });
44
+ for (let k = 1, w = top / 2; w >= (shown * wide) / 2 && k <= 4; k++, w /= 2)
45
+ needs.push({ key: `${s.id}/${l.id}@${k}`, ...base, width: Math.max(16, Math.ceil(w / 2) * 2) });
46
+ continue;
47
+ }
48
+ const width = Math.max(16, Math.ceil(((typeof l.params.width === 'number' ? l.params.width : 1280) * scale * 100) / cw / 2) * 2);
49
+ needs.push({ key: `${s.id}/${l.id}`, ...base, width });
50
+ }
51
+ }
52
+ return needs;
53
+ }
54
+ /** Width and height of a JPEG, read from its frame header. */
55
+ export function jpegSize(buf) {
56
+ let i = 2;
57
+ while (i + 9 < buf.length) {
58
+ if (buf[i] !== 0xff) {
59
+ i++;
60
+ continue;
61
+ }
62
+ const marker = buf[i + 1];
63
+ if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
64
+ return [buf.readUInt16BE(i + 7), buf.readUInt16BE(i + 5)];
65
+ }
66
+ i += 2 + buf.readUInt16BE(i + 2);
67
+ }
68
+ return undefined;
69
+ }
70
+ function run(args) {
71
+ return new Promise((resolve, reject) => {
72
+ let err = '';
73
+ const p = spawn('ffmpeg', args);
74
+ p.stderr.on('data', (d) => { err += d.toString(); });
75
+ p.on('error', (e) => reject(new Error(`el/video needs ffmpeg to draw footage frame by frame (${e.message}). Install it, e.g. brew install ffmpeg or apt install ffmpeg.`)));
76
+ p.on('close', (code) => (code === 0 ? resolve() : reject(new Error(`ffmpeg could not read the footage:\n${err.trim()}`))));
77
+ });
78
+ }
79
+ /**
80
+ * Pulls the frames for every el/video layer, reusing what is cached, and
81
+ * returns them by "<scene>/<layer>" with URLs the preview server answers.
82
+ */
83
+ export async function prepareFrames(filmFile, t, scale = 1, log = () => { }) {
84
+ const filmDir = path.dirname(path.resolve(filmFile));
85
+ const needs = footageNeeds(t, filmDir, scale);
86
+ const out = {};
87
+ for (const n of needs) {
88
+ let stamp = n.src;
89
+ if (!isUrl(n.src)) {
90
+ if (!fs.existsSync(n.src))
91
+ throw new Error(`Video not found: ${path.relative(process.cwd(), n.src)} (layer ${n.key}).`);
92
+ const st = fs.statSync(n.src);
93
+ stamp += `:${st.size}:${st.mtimeMs}`;
94
+ }
95
+ const hash = createHash('sha1').update(JSON.stringify([stamp, n.start, n.length, n.rate, n.width])).digest('hex').slice(0, 16);
96
+ const dir = path.join(filmDir, 'out', filmName(filmFile), 'frames', hash);
97
+ const marker = path.join(dir, 'frames.json');
98
+ if (!fs.existsSync(marker)) {
99
+ log(`Pulling ${n.key}: ${n.length.toFixed(2)} s of ${path.basename(n.src)} from ${n.start.toFixed(2)} s`);
100
+ fs.rmSync(dir, { recursive: true, force: true });
101
+ fs.mkdirSync(dir, { recursive: true });
102
+ await run(['-v', 'error', '-y', '-ss', n.start.toFixed(6), '-i', n.src, '-t', n.length.toFixed(6), '-an',
103
+ '-vf', `fps=${n.rate},scale=w='min(${n.width},iw)':h=-2:flags=lanczos`, '-q:v', '2', path.join(dir, '%05d.jpg')]);
104
+ const files = fs.readdirSync(dir).filter((f) => f.endsWith('.jpg')).sort();
105
+ if (!files.length)
106
+ throw new Error(`No frames came out of ${path.basename(n.src)} between ${n.start} s and ${n.start + n.length} s (layer ${n.key}). Is "from" past the end of the footage?`);
107
+ const size = jpegSize(fs.readFileSync(path.join(dir, files[0]))) ?? [16, 9];
108
+ fs.writeFileSync(marker, JSON.stringify({ count: files.length, width: size[0], height: size[1] }));
109
+ }
110
+ const info = JSON.parse(fs.readFileSync(marker, 'utf8'));
111
+ out[n.key] = {
112
+ base: `/${path.relative(filmDir, dir).split(path.sep).map(encodeURIComponent).join('/')}/`, ext: 'jpg',
113
+ count: info.count, start: n.start, rate: n.rate, width: info.width, height: info.height,
114
+ };
115
+ if (n.wants && info.width < n.wants * 0.98) {
116
+ log(`warn undersampled: ${n.key} is seen as close as ${n.wants} px across, but ${path.basename(n.src)} is ${info.width} px: the deepest zoom is drawn soft. Record the footage at --scale ${Math.ceil((n.wants / info.width) * 10) / 10} or more, or zoom in less.`);
117
+ }
118
+ if (n.marks) {
119
+ if (!fs.existsSync(n.marks))
120
+ throw new Error(`Marks not found: ${path.relative(process.cwd(), n.marks)} (layer ${n.key}). Record them with motion record --marks.`);
121
+ out[n.key].marks = JSON.parse(fs.readFileSync(n.marks, 'utf8'));
122
+ }
123
+ }
124
+ return out;
125
+ }
@@ -0,0 +1,23 @@
1
+ /** Runs in the page before anything else. `__motionGuard()` returns what changed since the last call. */
2
+ export declare const GUARD = "(() => {\n const w = window;\n const ids = new WeakMap(); let nextId = 1;\n const id = (el) => { let i = ids.get(el); if (!i) { i = nextId++; ids.set(el, i); } return i; };\n const who = (el) => {\n if (!el || !el.tagName) return 'text';\n const cls = typeof el.className === 'string' && el.className.trim() ? '.' + el.className.trim().split(/\\s+/)[0] : '';\n const txt = (el.textContent || '').trim().replace(/\\s+/g, ' ').slice(0, 28);\n return el.tagName.toLowerCase() + (el.id ? '#' + el.id : '') + cls + (txt ? ' \"' + txt + '\"' : '');\n };\n let shifts = [];\n try {\n const po = new PerformanceObserver((list) => { for (const e of list.getEntries()) shifts.push(e); });\n po.observe({ type: 'layout-shift', buffered: true });\n w.__motionShifts = () => { for (const e of po.takeRecords()) shifts.push(e); const s = shifts; shifts = []; return s; };\n } catch { w.__motionShifts = () => []; }\n const BLOCKS = 'p,h1,h2,h3,h4,h5,h6,li,blockquote,figcaption,label,button,[data-motion-text],[style*=\"top\"],[style*=\"left\"],[style*=\"margin\"],[style*=\"height\"],[style*=\"width\"]';\n // Where layout puts an element on the page: offsets ignore transforms, so only layout moves show.\n const place = (el) => { let x = 0, y = 0, e = el; while (e) { x += e.offsetLeft; y += e.offsetTop; e = e.offsetParent; } return [x, y]; };\n w.__motionGuard = () => {\n const out = { shifts: [], sizes: [], zooms: [], scaled: 0 };\n for (const e of w.__motionShifts()) for (const s of e.sources || []) {\n if (!s.node) continue;\n const a = s.previousRect, b = s.currentRect;\n out.shifts.push([who(s.node), Math.round((b.x - a.x) * 10) / 10, Math.round((b.y - a.y) * 10) / 10, Math.round(a.width), Math.round(a.height), Math.round(b.width), Math.round(b.height)]);\n }\n const blocks = document.querySelectorAll(BLOCKS);\n for (let i = 0; i < blocks.length && i < 400; i++) {\n const el = blocks[i];\n if (!el.offsetParent && getComputedStyle(el).position !== 'fixed') continue;\n const [x, y] = place(el);\n out.sizes.push([id(el), who(el), el.offsetWidth, el.offsetHeight, x, y]);\n }\n for (const el of [document.documentElement, document.body, ...document.querySelectorAll('[style*=\"zoom\"]')]) {\n if (!el) continue;\n const z = parseFloat(getComputedStyle(el).zoom || '1') || 1;\n out.zooms.push([who(el).slice(0, 60), z]);\n }\n // The largest scale a transform puts on the page's content, a few levels down.\n const walk = (el, depth) => {\n if (depth > 4) return;\n for (const c of el.children) {\n const t = getComputedStyle(c).transform;\n if (t && t !== 'none') { const m = new DOMMatrixReadOnly(t); out.scaled = Math.max(out.scaled, Math.hypot(m.a, m.b)); }\n walk(c, depth + 1);\n }\n };\n walk(document.body, 0);\n return out;\n };\n})()";
3
+ export interface GuardSample {
4
+ /** Layout shifts this frame: who, dx, dy, and the box before and after (w, h). */
5
+ shifts: [string, number, number, number, number, number, number][];
6
+ /** Text blocks and elements with inline layout styles: id, who, width, height, and where layout puts them (x, y). */
7
+ sizes: [number, string, number, number, number, number][];
8
+ /** CSS zoom on the root, the body and anything that sets it inline. */
9
+ zooms: [string, number][];
10
+ /** The largest scale a transform puts on the page's content. */
11
+ scaled: number;
12
+ }
13
+ /** What the guard saw, as lines for the recorder's report, each starting `guard:`. */
14
+ export declare function guardFindings(frames: readonly GuardSample[], fps: number): string[];
15
+ /** Runs in the page: where each selector's first element sits, without its own transform, in device px. */
16
+ export declare const MARKS = "((selectors, scale) => {\n const out = {};\n for (const sel of selectors) {\n const el = document.querySelector(sel);\n if (!el) { out[sel] = null; continue; }\n const st = el.style, was = [st.transform, st.translate, st.scale, st.rotate, st.transition];\n st.transition = 'none'; st.transform = 'none'; st.translate = 'none'; st.scale = 'none'; st.rotate = 'none';\n const r = el.getBoundingClientRect();\n [st.transform, st.translate, st.scale, st.rotate, st.transition] = was;\n out[sel] = r.width || r.height ? [r.left * scale, r.top * scale, r.width * scale, r.height * scale].map((v) => Math.round(v * 10) / 10) : null;\n }\n return out;\n})";
17
+ /** A recording's marks: per selector, its box in footage px on every frame (null where it is not on the page). */
18
+ export interface Marks {
19
+ fps: number;
20
+ /** The footage's size in px. */
21
+ size: [number, number];
22
+ marks: Record<string, ([number, number, number, number] | null)[]>;
23
+ }
@@ -0,0 +1,158 @@
1
+ // The recorder's guard: what a page does between frames that makes footage judder,
2
+ // wiggle or flicker however exactly it is recorded. A camera or a glide that works
3
+ // by re-laying out the page (moving with top or left, growing with height, zooming
4
+ // with CSS zoom) moves text to whole pixels and can re-wrap a line, so it steps and
5
+ // wiggles; the Layout Instability API names every element that moved in layout. A
6
+ // block whose size flips back and forth is a line re-wrapping. And content in a
7
+ // stage scaled up with a transform snaps to whole CSS px unless it has its own layer.
8
+ /** Runs in the page before anything else. `__motionGuard()` returns what changed since the last call. */
9
+ export const GUARD = `(() => {
10
+ const w = window;
11
+ const ids = new WeakMap(); let nextId = 1;
12
+ const id = (el) => { let i = ids.get(el); if (!i) { i = nextId++; ids.set(el, i); } return i; };
13
+ const who = (el) => {
14
+ if (!el || !el.tagName) return 'text';
15
+ const cls = typeof el.className === 'string' && el.className.trim() ? '.' + el.className.trim().split(/\\s+/)[0] : '';
16
+ const txt = (el.textContent || '').trim().replace(/\\s+/g, ' ').slice(0, 28);
17
+ return el.tagName.toLowerCase() + (el.id ? '#' + el.id : '') + cls + (txt ? ' "' + txt + '"' : '');
18
+ };
19
+ let shifts = [];
20
+ try {
21
+ const po = new PerformanceObserver((list) => { for (const e of list.getEntries()) shifts.push(e); });
22
+ po.observe({ type: 'layout-shift', buffered: true });
23
+ w.__motionShifts = () => { for (const e of po.takeRecords()) shifts.push(e); const s = shifts; shifts = []; return s; };
24
+ } catch { w.__motionShifts = () => []; }
25
+ const BLOCKS = 'p,h1,h2,h3,h4,h5,h6,li,blockquote,figcaption,label,button,[data-motion-text],[style*="top"],[style*="left"],[style*="margin"],[style*="height"],[style*="width"]';
26
+ // Where layout puts an element on the page: offsets ignore transforms, so only layout moves show.
27
+ const place = (el) => { let x = 0, y = 0, e = el; while (e) { x += e.offsetLeft; y += e.offsetTop; e = e.offsetParent; } return [x, y]; };
28
+ w.__motionGuard = () => {
29
+ const out = { shifts: [], sizes: [], zooms: [], scaled: 0 };
30
+ for (const e of w.__motionShifts()) for (const s of e.sources || []) {
31
+ if (!s.node) continue;
32
+ const a = s.previousRect, b = s.currentRect;
33
+ out.shifts.push([who(s.node), Math.round((b.x - a.x) * 10) / 10, Math.round((b.y - a.y) * 10) / 10, Math.round(a.width), Math.round(a.height), Math.round(b.width), Math.round(b.height)]);
34
+ }
35
+ const blocks = document.querySelectorAll(BLOCKS);
36
+ for (let i = 0; i < blocks.length && i < 400; i++) {
37
+ const el = blocks[i];
38
+ if (!el.offsetParent && getComputedStyle(el).position !== 'fixed') continue;
39
+ const [x, y] = place(el);
40
+ out.sizes.push([id(el), who(el), el.offsetWidth, el.offsetHeight, x, y]);
41
+ }
42
+ for (const el of [document.documentElement, document.body, ...document.querySelectorAll('[style*="zoom"]')]) {
43
+ if (!el) continue;
44
+ const z = parseFloat(getComputedStyle(el).zoom || '1') || 1;
45
+ out.zooms.push([who(el).slice(0, 60), z]);
46
+ }
47
+ // The largest scale a transform puts on the page's content, a few levels down.
48
+ const walk = (el, depth) => {
49
+ if (depth > 4) return;
50
+ for (const c of el.children) {
51
+ const t = getComputedStyle(c).transform;
52
+ if (t && t !== 'none') { const m = new DOMMatrixReadOnly(t); out.scaled = Math.max(out.scaled, Math.hypot(m.a, m.b)); }
53
+ walk(c, depth + 1);
54
+ }
55
+ };
56
+ walk(document.body, 0);
57
+ return out;
58
+ };
59
+ })()`;
60
+ const at = (f, fps) => `${(f / fps).toFixed(2)} s`;
61
+ const span = (a, b, fps) => (a === b ? `at ${at(a, fps)}` : `from ${at(a, fps)} to ${at(b, fps)}`);
62
+ /** What the guard saw, as lines for the recorder's report, each starting `guard:`. */
63
+ export function guardFindings(frames, fps) {
64
+ const out = [];
65
+ // Layout shifts, one line per element, with the frames and the largest step.
66
+ const moved = new Map();
67
+ frames.forEach((f, i) => {
68
+ if (i === 0)
69
+ return; // The first frame is the page arriving.
70
+ for (const [who, dx, dy] of f.shifts) {
71
+ const m = moved.get(who) ?? { first: i, last: i, n: 0, step: 0 };
72
+ m.last = i;
73
+ m.n++;
74
+ m.step = Math.max(m.step, Math.hypot(dx, dy));
75
+ moved.set(who, m);
76
+ }
77
+ });
78
+ // Layout positions that change between frames: a move by top, left, margin or a growing
79
+ // neighbour. The API above ignores moves under 3 px, which is exactly a slow glide.
80
+ const last = new Map();
81
+ frames.forEach((f, i) => {
82
+ const zoomChanged = i > 0 && f.zooms.some(([who, z]) => frames[i - 1].zooms.find((x) => x[0] === who)?.[1] !== z);
83
+ for (const [id, who, , , x, y] of f.sizes) {
84
+ const was = last.get(id);
85
+ last.set(id, [x, y]);
86
+ if (!was || zoomChanged || (was[0] === x && was[1] === y))
87
+ continue;
88
+ const m = moved.get(who) ?? { first: i, last: i, n: 0, step: 0 };
89
+ m.last = i;
90
+ m.n++;
91
+ m.step = Math.max(m.step, Math.hypot(x - was[0], y - was[1]));
92
+ moved.set(who, m);
93
+ }
94
+ });
95
+ for (const [who, m] of moved) {
96
+ out.push(`guard: ${who} moved in layout on ${m.n} frame(s) ${span(m.first, m.last, fps)}, up to ${m.step.toFixed(1)} px a frame. ` +
97
+ 'Layout moves land on whole pixels and can re-wrap text, so they step and wiggle. Move it with a transform, or measure both layouts and glide between them.');
98
+ }
99
+ // A block whose size goes A → B and back to A within 10 frames: a line re-wrapping and back.
100
+ const sizes = new Map();
101
+ frames.forEach((f, i) => {
102
+ for (const [id, who, w, h] of f.sizes) {
103
+ const s = sizes.get(id) ?? { who, seen: [] };
104
+ const key = `${w}×${h}`;
105
+ if (s.seen[s.seen.length - 1]?.[1] !== key)
106
+ s.seen.push([i, key]);
107
+ sizes.set(id, s);
108
+ }
109
+ });
110
+ for (const { who, seen } of sizes.values()) {
111
+ for (let k = 2; k < seen.length; k++) {
112
+ if (seen[k][1] === seen[k - 2][1] && seen[k][0] - seen[k - 1][0] <= 10) {
113
+ out.push(`guard: ${who} changed size ${seen[k - 2][1]} → ${seen[k - 1][1]} → ${seen[k][1]} ${span(seen[k - 2][0], seen[k][0], fps)}: a line re-wrapping and back. Lay it out once at its final size and move it with transforms.`);
114
+ break;
115
+ }
116
+ }
117
+ }
118
+ // CSS zoom that changes between frames re-lays out the whole page each frame.
119
+ const zooms = new Map();
120
+ const zoomed = new Map();
121
+ frames.forEach((f, i) => {
122
+ for (const [who, z] of f.zooms) {
123
+ const was = zooms.get(who);
124
+ zooms.set(who, z);
125
+ if (was === undefined || Math.abs(was - z) < 1e-4)
126
+ continue;
127
+ const m = zoomed.get(who) ?? { first: i, last: i, lo: Math.min(was, z), hi: Math.max(was, z) };
128
+ m.last = i;
129
+ m.lo = Math.min(m.lo, z);
130
+ m.hi = Math.max(m.hi, z);
131
+ zoomed.set(who, m);
132
+ }
133
+ });
134
+ for (const [who, m] of zoomed) {
135
+ out.push(`guard: CSS zoom on ${who} changes ${span(m.first, m.last, fps)} (${m.lo.toFixed(2)}–${m.hi.toFixed(2)}): every frame re-lays out the page, so text re-wraps and steps. Zoom with a transform on a page laid out once.`);
136
+ }
137
+ // A stage scaled up: content moving inside it without its own layer snaps to whole CSS px.
138
+ const scaled = Math.max(0, ...frames.map((f) => f.scaled));
139
+ if (scaled >= 1.5) {
140
+ out.push(`guard: content sits in a stage scaled ${scaled.toFixed(1)}×. Anything that moves inside it without its own compositor layer snaps to whole CSS px, ${scaled.toFixed(1)} px on screen, so slow moves judder. ` +
141
+ 'Give moving parts will-change: transform, or lay the page out at its final size. Run motion review on the footage to see whether it does.');
142
+ }
143
+ return out;
144
+ }
145
+ /** Runs in the page: where each selector's first element sits, without its own transform, in device px. */
146
+ export const MARKS = `((selectors, scale) => {
147
+ const out = {};
148
+ for (const sel of selectors) {
149
+ const el = document.querySelector(sel);
150
+ if (!el) { out[sel] = null; continue; }
151
+ const st = el.style, was = [st.transform, st.translate, st.scale, st.rotate, st.transition];
152
+ st.transition = 'none'; st.transform = 'none'; st.translate = 'none'; st.scale = 'none'; st.rotate = 'none';
153
+ const r = el.getBoundingClientRect();
154
+ [st.transform, st.translate, st.scale, st.rotate, st.transition] = was;
155
+ out[sel] = r.width || r.height ? [r.left * scale, r.top * scale, r.width * scale, r.height * scale].map((v) => Math.round(v * 10) / 10) : null;
156
+ }
157
+ return out;
158
+ })`;
@@ -0,0 +1,2 @@
1
+ import type { Library } from '../brief/types.ts';
2
+ export declare function readLibrary(root?: string): Library;
@@ -0,0 +1,55 @@
1
+ // The library entries (library/**/*.md) as data: styles, narratives and every
2
+ // primitive with its status. Written to library.json by `motion catalog --write`,
3
+ // so the wizard and the brief read one file and never parse Markdown in a browser.
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { parse } from 'yaml';
7
+ import { ROOT } from "./files.js";
8
+ function entries(dir) {
9
+ const out = [];
10
+ const walk = (d) => {
11
+ for (const name of fs.readdirSync(d).sort()) {
12
+ const p = path.join(d, name);
13
+ if (fs.statSync(p).isDirectory())
14
+ walk(p);
15
+ else if (name.endsWith('.md')) {
16
+ const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(fs.readFileSync(p, 'utf8'));
17
+ if (m)
18
+ out.push({ meta: parse(m[1]), body: m[2] });
19
+ }
20
+ }
21
+ };
22
+ walk(dir);
23
+ return out;
24
+ }
25
+ /** The first paragraph under a heading, e.g. a style's "Character". */
26
+ const section = (body, heading) => {
27
+ const m = new RegExp(`^## ${heading}\\s*\\n+([\\s\\S]*?)(?:\\n\\n|\\n##|$)`, 'm').exec(body);
28
+ return m ? m[1].trim().replace(/\s+/g, ' ') : '';
29
+ };
30
+ const FAMILIES = ['product', 'brand', 'graphics', 'social'];
31
+ const range = (v) => {
32
+ const r = (v ?? {});
33
+ return { min: Number(r.min ?? 0), max: Number(r.max ?? 0) };
34
+ };
35
+ const strings = (v) => (Array.isArray(v) ? v.map(String) : []);
36
+ export function readLibrary(root = path.join(ROOT, 'library')) {
37
+ const all = entries(root);
38
+ const of = (kind) => all.filter((e) => e.meta.kind === kind);
39
+ return {
40
+ styles: of('style').map(({ meta, body }) => ({
41
+ slug: String(meta.slug), summary: String(meta.summary ?? ''), character: section(body, 'Character'),
42
+ uses: strings(meta.uses), avoids: strings(meta.avoids), formats: strings(meta.formats), duration: range(meta.duration),
43
+ beat: Number(meta.tokens?.beat ?? 0) || undefined,
44
+ transitions: meta.tokens?.transitions === 'calm' ? 'calm' : undefined,
45
+ })),
46
+ narratives: of('narrative').map(({ meta }) => ({
47
+ slug: String(meta.slug), summary: String(meta.summary ?? ''), family: (FAMILIES.includes(meta.family) ? meta.family : 'graphics'),
48
+ duration: range(meta.duration), fits: strings(meta.fits_styles),
49
+ beats: (meta.beats ?? []).map((b) => ({
50
+ name: String(b.name), share: Number(b.share), content: String(b.content ?? ''), primitives: strings(b.primitives),
51
+ })),
52
+ })),
53
+ primitives: of('primitive').map(({ meta }) => ({ slug: String(meta.slug), summary: String(meta.summary ?? ''), status: String(meta.status ?? 'draft') })),
54
+ };
55
+ }
@@ -0,0 +1,17 @@
1
+ import type { Timeline } from '../film/types.ts';
2
+ /** The moments worth looking at: each layer settled, each scene's middle and end, each hand-over's middle. */
3
+ export declare function keyMoments(t: Timeline): {
4
+ t: number;
5
+ label: string;
6
+ }[];
7
+ /** Where `make` writes: beside the script, as <name>.film.json. */
8
+ export declare const madePath: (script: string) => string;
9
+ export declare const LIBRARY_ENTRIES: Record<string, string>;
10
+ export interface Seam {
11
+ seam: number;
12
+ step: number;
13
+ ratio: number;
14
+ seamless: boolean;
15
+ steps: number[];
16
+ }
17
+ export declare function main(argv: string[]): Promise<void>;