@pairdraw/core 0.19.1 → 0.20.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 (1031) hide show
  1. package/dist/ai/providers.d.ts +6 -0
  2. package/dist/ai/providers.d.ts.map +1 -1
  3. package/dist/ai/providers.js.map +1 -1
  4. package/dist/cache/resource.d.ts +8 -1
  5. package/dist/cache/resource.d.ts.map +1 -1
  6. package/dist/cache/resource.js +18 -0
  7. package/dist/cache/resource.js.map +1 -1
  8. package/dist/canvas/effects.d.ts +6 -4
  9. package/dist/canvas/effects.d.ts.map +1 -1
  10. package/dist/canvas/effects.js +37 -34
  11. package/dist/canvas/effects.js.map +1 -1
  12. package/dist/canvas/fills.d.ts.map +1 -1
  13. package/dist/canvas/fills.js +12 -8
  14. package/dist/canvas/fills.js.map +1 -1
  15. package/dist/canvas/images/adjustments.d.ts +18 -0
  16. package/dist/canvas/images/adjustments.d.ts.map +1 -0
  17. package/dist/canvas/images/adjustments.js +184 -0
  18. package/dist/canvas/images/adjustments.js.map +1 -0
  19. package/dist/canvas/images/previews.d.ts +1 -1
  20. package/dist/canvas/images/sampling.d.ts +13 -0
  21. package/dist/canvas/images/sampling.d.ts.map +1 -0
  22. package/dist/canvas/images/sampling.js +49 -0
  23. package/dist/canvas/images/sampling.js.map +1 -0
  24. package/dist/canvas/index.d.ts +2 -2
  25. package/dist/canvas/masks.d.ts +1 -1
  26. package/dist/canvas/masks.d.ts.map +1 -1
  27. package/dist/canvas/masks.js.map +1 -1
  28. package/dist/canvas/noise/render.d.ts +15 -0
  29. package/dist/canvas/noise/render.d.ts.map +1 -0
  30. package/dist/canvas/noise/render.js +56 -0
  31. package/dist/canvas/noise/render.js.map +1 -0
  32. package/dist/canvas/noise/shader.d.ts +43 -0
  33. package/dist/canvas/noise/shader.d.ts.map +1 -0
  34. package/dist/canvas/noise/shader.js +161 -0
  35. package/dist/canvas/noise/shader.js.map +1 -0
  36. package/dist/canvas/noise/table.d.ts +13 -0
  37. package/dist/canvas/noise/table.d.ts.map +1 -0
  38. package/dist/canvas/noise/table.js +408 -0
  39. package/dist/canvas/noise/table.js.map +1 -0
  40. package/dist/canvas/noise/tile.d.ts +22 -0
  41. package/dist/canvas/noise/tile.d.ts.map +1 -0
  42. package/dist/canvas/noise/tile.js +73 -0
  43. package/dist/canvas/noise/tile.js.map +1 -0
  44. package/dist/canvas/outline-stroke.js +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  46. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  47. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  48. package/dist/canvas/overlays/index.d.ts +2 -2
  49. package/dist/canvas/overlays/index.js +2 -2
  50. package/dist/canvas/overlays/selection.d.ts +1 -2
  51. package/dist/canvas/overlays/selection.d.ts.map +1 -1
  52. package/dist/canvas/overlays/selection.js +2 -9
  53. package/dist/canvas/overlays/selection.js.map +1 -1
  54. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  55. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  56. package/dist/canvas/renderer/fonts.js +2 -0
  57. package/dist/canvas/renderer/fonts.js.map +1 -1
  58. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.js +6 -0
  60. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  61. package/dist/canvas/renderer/methods.d.ts +0 -1
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +1 -4
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.js +0 -1
  67. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  68. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  69. package/dist/canvas/renderer/pipeline.js +13 -2
  70. package/dist/canvas/renderer/pipeline.js.map +1 -1
  71. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  72. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  73. package/dist/canvas/renderer/play-scenes.js +40 -0
  74. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  75. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  76. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  77. package/dist/canvas/renderer/tiles/cache.js +32 -1
  78. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  79. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  80. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  81. package/dist/canvas/renderer/tiles/controller.js +18 -1
  82. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  83. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  84. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  85. package/dist/canvas/renderer/types.d.ts +18 -4
  86. package/dist/canvas/renderer/types.d.ts.map +1 -1
  87. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  88. package/dist/canvas/renderer/visual-bounds.js +1 -1
  89. package/dist/canvas/renderer.d.ts +22 -3
  90. package/dist/canvas/renderer.d.ts.map +1 -1
  91. package/dist/canvas/renderer.js +29 -1
  92. package/dist/canvas/renderer.js.map +1 -1
  93. package/dist/canvas/scene.d.ts +2 -1
  94. package/dist/canvas/scene.d.ts.map +1 -1
  95. package/dist/canvas/scene.js +41 -9
  96. package/dist/canvas/scene.js.map +1 -1
  97. package/dist/canvas/shadows/silhouette.js +1 -1
  98. package/dist/canvas/texture.d.ts +20 -0
  99. package/dist/canvas/texture.d.ts.map +1 -0
  100. package/dist/canvas/texture.js +100 -0
  101. package/dist/canvas/texture.js.map +1 -0
  102. package/dist/clipboard.js +16 -5
  103. package/dist/clipboard.js.map +1 -1
  104. package/dist/constants.d.ts +5 -1
  105. package/dist/constants.d.ts.map +1 -1
  106. package/dist/constants.js +5 -1
  107. package/dist/constants.js.map +1 -1
  108. package/dist/design-jsx/index.d.ts +2 -2
  109. package/dist/design-jsx/index.js +2 -2
  110. package/dist/design-jsx/renderer.d.ts +3 -2
  111. package/dist/design-jsx/renderer.d.ts.map +1 -1
  112. package/dist/design-jsx/renderer.js +2 -2
  113. package/dist/design-jsx/renderer.js.map +1 -1
  114. package/dist/design-memory/check.d.ts +90 -0
  115. package/dist/design-memory/check.d.ts.map +1 -0
  116. package/dist/design-memory/check.js +281 -0
  117. package/dist/design-memory/check.js.map +1 -0
  118. package/dist/design-memory/describe.d.ts +37 -0
  119. package/dist/design-memory/describe.d.ts.map +1 -0
  120. package/dist/design-memory/describe.js +52 -0
  121. package/dist/design-memory/describe.js.map +1 -0
  122. package/dist/design-memory/distil.d.ts +22 -0
  123. package/dist/design-memory/distil.d.ts.map +1 -0
  124. package/dist/design-memory/distil.js +54 -0
  125. package/dist/design-memory/distil.js.map +1 -0
  126. package/dist/design-memory/document.d.ts +12 -0
  127. package/dist/design-memory/document.d.ts.map +1 -0
  128. package/dist/design-memory/document.js +64 -0
  129. package/dist/design-memory/document.js.map +1 -0
  130. package/dist/design-memory/guard.d.ts +48 -0
  131. package/dist/design-memory/guard.d.ts.map +1 -0
  132. package/dist/design-memory/guard.js +105 -0
  133. package/dist/design-memory/guard.js.map +1 -0
  134. package/dist/design-memory/index.d.ts +9 -0
  135. package/dist/design-memory/index.js +9 -0
  136. package/dist/design-memory/refusal.d.ts +32 -0
  137. package/dist/design-memory/refusal.d.ts.map +1 -0
  138. package/dist/design-memory/refusal.js +68 -0
  139. package/dist/design-memory/refusal.js.map +1 -0
  140. package/dist/design-memory/rules.d.ts +63 -0
  141. package/dist/design-memory/rules.d.ts.map +1 -0
  142. package/dist/design-memory/rules.js +224 -0
  143. package/dist/design-memory/rules.js.map +1 -0
  144. package/dist/design-memory/values.d.ts +28 -0
  145. package/dist/design-memory/values.d.ts.map +1 -0
  146. package/dist/design-memory/values.js +160 -0
  147. package/dist/design-memory/values.js.map +1 -0
  148. package/dist/editor/alignment.js +1 -1
  149. package/dist/editor/bridges/components.d.ts +2 -0
  150. package/dist/editor/bridges/components.d.ts.map +1 -1
  151. package/dist/editor/bridges/components.js +2 -0
  152. package/dist/editor/bridges/components.js.map +1 -1
  153. package/dist/editor/bridges/undo.d.ts +1 -1
  154. package/dist/editor/clipboard/assets.js +1 -1
  155. package/dist/editor/clipboard/export.d.ts.map +1 -1
  156. package/dist/editor/clipboard/export.js +16 -2
  157. package/dist/editor/clipboard/export.js.map +1 -1
  158. package/dist/editor/clipboard/placement.d.ts +1 -1
  159. package/dist/editor/clipboard/placement.js +1 -1
  160. package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
  161. package/dist/editor/clipboard/snapshot.js +12 -4
  162. package/dist/editor/clipboard/snapshot.js.map +1 -1
  163. package/dist/editor/clipboard.d.ts.map +1 -1
  164. package/dist/editor/clipboard.js +2 -7
  165. package/dist/editor/clipboard.js.map +1 -1
  166. package/dist/editor/color-space.d.ts.map +1 -1
  167. package/dist/editor/color-space.js +33 -38
  168. package/dist/editor/color-space.js.map +1 -1
  169. package/dist/editor/components/instances.d.ts +2 -0
  170. package/dist/editor/components/instances.d.ts.map +1 -1
  171. package/dist/editor/components/instances.js +22 -1
  172. package/dist/editor/components/instances.js.map +1 -1
  173. package/dist/editor/components.d.ts +2 -0
  174. package/dist/editor/components.d.ts.map +1 -1
  175. package/dist/editor/connectors/attach.js +1 -1
  176. package/dist/editor/create.d.ts +36 -8
  177. package/dist/editor/create.d.ts.map +1 -1
  178. package/dist/editor/create.js +26 -61
  179. package/dist/editor/create.js.map +1 -1
  180. package/dist/editor/design-memory.d.ts +11 -0
  181. package/dist/editor/design-memory.d.ts.map +1 -0
  182. package/dist/editor/design-memory.js +40 -0
  183. package/dist/editor/design-memory.js.map +1 -0
  184. package/dist/editor/design-tokens.d.ts +4 -0
  185. package/dist/editor/design-tokens.d.ts.map +1 -1
  186. package/dist/editor/design-tokens.js +30 -1
  187. package/dist/editor/design-tokens.js.map +1 -1
  188. package/dist/editor/document-colors.d.ts +23 -0
  189. package/dist/editor/document-colors.d.ts.map +1 -0
  190. package/dist/editor/document-colors.js +53 -0
  191. package/dist/editor/document-colors.js.map +1 -0
  192. package/dist/editor/eyedropper.d.ts +47 -0
  193. package/dist/editor/eyedropper.d.ts.map +1 -0
  194. package/dist/editor/eyedropper.js +168 -0
  195. package/dist/editor/eyedropper.js.map +1 -0
  196. package/dist/editor/fonts.d.ts +9 -0
  197. package/dist/editor/fonts.d.ts.map +1 -0
  198. package/dist/editor/fonts.js +14 -0
  199. package/dist/editor/fonts.js.map +1 -0
  200. package/dist/editor/history/atomic-tool.d.ts +9 -2
  201. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  202. package/dist/editor/history/atomic-tool.js +6 -0
  203. package/dist/editor/history/atomic-tool.js.map +1 -1
  204. package/dist/editor/history/capture.d.ts +13 -0
  205. package/dist/editor/history/capture.d.ts.map +1 -0
  206. package/dist/editor/history/capture.js +28 -0
  207. package/dist/editor/history/capture.js.map +1 -0
  208. package/dist/editor/history/document-change.d.ts.map +1 -1
  209. package/dist/editor/history/document-change.js +2 -22
  210. package/dist/editor/history/document-change.js.map +1 -1
  211. package/dist/editor/history/edit.d.ts +7 -0
  212. package/dist/editor/history/edit.d.ts.map +1 -1
  213. package/dist/editor/history/edit.js +6 -3
  214. package/dist/editor/history/edit.js.map +1 -1
  215. package/dist/editor/history/subtree.d.ts +9 -0
  216. package/dist/editor/history/subtree.d.ts.map +1 -1
  217. package/dist/editor/history/subtree.js +12 -2
  218. package/dist/editor/history/subtree.js.map +1 -1
  219. package/dist/editor/index.d.ts +4 -2
  220. package/dist/editor/index.js +4 -2
  221. package/dist/editor/nudge.js +1 -1
  222. package/dist/editor/nudge.js.map +1 -1
  223. package/dist/editor/pages.d.ts +7 -5
  224. package/dist/editor/pages.d.ts.map +1 -1
  225. package/dist/editor/pages.js +35 -25
  226. package/dist/editor/pages.js.map +1 -1
  227. package/dist/editor/play/states.d.ts +3 -1
  228. package/dist/editor/play/states.d.ts.map +1 -1
  229. package/dist/editor/play/states.js +1 -1
  230. package/dist/editor/play/states.js.map +1 -1
  231. package/dist/editor/read-only/actions.js +6 -0
  232. package/dist/editor/read-only/actions.js.map +1 -1
  233. package/dist/editor/render-requests.d.ts +18 -0
  234. package/dist/editor/render-requests.d.ts.map +1 -0
  235. package/dist/editor/render-requests.js +76 -0
  236. package/dist/editor/render-requests.js.map +1 -0
  237. package/dist/editor/scale/rescale.d.ts +1 -1
  238. package/dist/editor/selection/container.d.ts +2 -0
  239. package/dist/editor/selection/container.d.ts.map +1 -1
  240. package/dist/editor/selection/container.js +17 -1
  241. package/dist/editor/selection/container.js.map +1 -1
  242. package/dist/editor/selection/navigation.js +7 -4
  243. package/dist/editor/selection/navigation.js.map +1 -1
  244. package/dist/editor/selection/overlays.d.ts.map +1 -1
  245. package/dist/editor/selection/overlays.js +1 -1
  246. package/dist/editor/selection/overlays.js.map +1 -1
  247. package/dist/editor/selection/read.d.ts +6 -2
  248. package/dist/editor/selection.d.ts +9 -2
  249. package/dist/editor/selection.d.ts.map +1 -1
  250. package/dist/editor/shapes/with-text.d.ts.map +1 -1
  251. package/dist/editor/shapes/with-text.js +2 -5
  252. package/dist/editor/shapes/with-text.js.map +1 -1
  253. package/dist/editor/structure/auto-layout-wrap.js +1 -1
  254. package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
  255. package/dist/editor/structure/boolean.d.ts +2 -3
  256. package/dist/editor/structure/boolean.d.ts.map +1 -1
  257. package/dist/editor/structure/boolean.js.map +1 -1
  258. package/dist/editor/structure/group/bounds.d.ts.map +1 -1
  259. package/dist/editor/structure/group/bounds.js +1 -3
  260. package/dist/editor/structure/group/bounds.js.map +1 -1
  261. package/dist/editor/structure/outline-stroke.js +3 -3
  262. package/dist/editor/structure/outline-stroke.js.map +1 -1
  263. package/dist/editor/structure/reorder.d.ts.map +1 -1
  264. package/dist/editor/structure/reorder.js +7 -14
  265. package/dist/editor/structure/reorder.js.map +1 -1
  266. package/dist/editor/structure/state.js +1 -1
  267. package/dist/editor/structure/state.js.map +1 -1
  268. package/dist/editor/structure.d.ts +1 -2
  269. package/dist/editor/structure.d.ts.map +1 -1
  270. package/dist/editor/structure.js +3 -3
  271. package/dist/editor/structure.js.map +1 -1
  272. package/dist/editor/tool-registry.d.ts.map +1 -1
  273. package/dist/editor/tool-registry.js +2 -1
  274. package/dist/editor/tool-registry.js.map +1 -1
  275. package/dist/editor/types.d.ts +9 -2
  276. package/dist/editor/types.d.ts.map +1 -1
  277. package/dist/editor/variables.d.ts.map +1 -1
  278. package/dist/editor/variables.js +57 -1
  279. package/dist/editor/variables.js.map +1 -1
  280. package/dist/editor/variations/create.d.ts +28 -0
  281. package/dist/editor/variations/create.d.ts.map +1 -0
  282. package/dist/editor/variations/create.js +176 -0
  283. package/dist/editor/variations/create.js.map +1 -0
  284. package/dist/editor/variations/pick.d.ts +16 -0
  285. package/dist/editor/variations/pick.d.ts.map +1 -0
  286. package/dist/editor/variations/pick.js +23 -0
  287. package/dist/editor/variations/pick.js.map +1 -0
  288. package/dist/editor/variations.d.ts +28 -0
  289. package/dist/editor/variations.d.ts.map +1 -0
  290. package/dist/editor/variations.js +88 -0
  291. package/dist/editor/variations.js.map +1 -0
  292. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  293. package/dist/figma-api/accessors/reactions.js +4 -1
  294. package/dist/figma-api/accessors/reactions.js.map +1 -1
  295. package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
  296. package/dist/figma-api/accessors/text/index.js +7 -1
  297. package/dist/figma-api/accessors/text/index.js.map +1 -1
  298. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  299. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  300. package/dist/figma-api/accessors/text/opentype.js +28 -0
  301. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  302. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  303. package/dist/figma-api/accessors/visual.js +33 -0
  304. package/dist/figma-api/accessors/visual.js.map +1 -1
  305. package/dist/figma-api/effects.d.ts +79 -3
  306. package/dist/figma-api/effects.d.ts.map +1 -1
  307. package/dist/figma-api/effects.js +150 -9
  308. package/dist/figma-api/effects.js.map +1 -1
  309. package/dist/figma-api/fonts/loaded.d.ts +3 -1
  310. package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
  311. package/dist/figma-api/fonts/loaded.js +8 -1
  312. package/dist/figma-api/fonts/loaded.js.map +1 -1
  313. package/dist/figma-api/index.d.ts +18 -0
  314. package/dist/figma-api/index.d.ts.map +1 -1
  315. package/dist/figma-api/index.js +19 -1
  316. package/dist/figma-api/index.js.map +1 -1
  317. package/dist/figma-api/overrides.d.ts +13 -1
  318. package/dist/figma-api/overrides.d.ts.map +1 -1
  319. package/dist/figma-api/overrides.js +196 -4
  320. package/dist/figma-api/overrides.js.map +1 -1
  321. package/dist/figma-api/paints.d.ts +3 -3
  322. package/dist/figma-api/paints.d.ts.map +1 -1
  323. package/dist/figma-api/paints.js +14 -4
  324. package/dist/figma-api/paints.js.map +1 -1
  325. package/dist/figma-api/proxy.d.ts +4 -1
  326. package/dist/figma-api/proxy.d.ts.map +1 -1
  327. package/dist/figma-api/proxy.js +1 -1
  328. package/dist/figma-api/proxy.js.map +1 -1
  329. package/dist/figma-api/reactions.d.ts +41 -13
  330. package/dist/figma-api/reactions.d.ts.map +1 -1
  331. package/dist/figma-api/reactions.js +113 -31
  332. package/dist/figma-api/reactions.js.map +1 -1
  333. package/dist/figma-api/render-bounds.js +1 -1
  334. package/dist/figma-api/serialization.d.ts.map +1 -1
  335. package/dist/figma-api/serialization.js +2 -1
  336. package/dist/figma-api/serialization.js.map +1 -1
  337. package/dist/figma-api/shape-details.d.ts +26 -0
  338. package/dist/figma-api/shape-details.d.ts.map +1 -0
  339. package/dist/figma-api/shape-details.js +28 -0
  340. package/dist/figma-api/shape-details.js.map +1 -0
  341. package/dist/figma-api/shape-with-text.js +2 -5
  342. package/dist/figma-api/shape-with-text.js.map +1 -1
  343. package/dist/figma-api/surface.d.ts +7 -4
  344. package/dist/figma-api/surface.d.ts.map +1 -1
  345. package/dist/figma-api/surface.js +7 -2
  346. package/dist/figma-api/surface.js.map +1 -1
  347. package/dist/figma-api/transform.d.ts +1 -1
  348. package/dist/geometry/figma.d.ts +1 -1
  349. package/dist/geometry/image-crop.d.ts +1 -1
  350. package/dist/geometry/image-crop.js +1 -1
  351. package/dist/icons/svg.js +1 -1
  352. package/dist/icons/svg.js.map +1 -1
  353. package/dist/index.d.ts +4 -2
  354. package/dist/index.js +4 -2
  355. package/dist/io/formats/boolean-path.d.ts +19 -0
  356. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  357. package/dist/io/formats/boolean-path.js +47 -0
  358. package/dist/io/formats/boolean-path.js.map +1 -0
  359. package/dist/io/formats/design-tokens/decode.js +1 -1
  360. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  361. package/dist/io/formats/design-tokens/index.js +4 -1
  362. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  363. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  364. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  365. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  366. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  367. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  368. package/dist/io/formats/design-tokens/project.js +29 -8
  369. package/dist/io/formats/design-tokens/project.js.map +1 -1
  370. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  371. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  372. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  373. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  374. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  375. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  376. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  377. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  378. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  379. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  380. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  381. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  382. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  383. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  384. package/dist/io/formats/drawio/edges.d.ts +7 -1
  385. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  386. package/dist/io/formats/drawio/edges.js +54 -1
  387. package/dist/io/formats/drawio/edges.js.map +1 -1
  388. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  389. package/dist/io/formats/drawio/export.js +19 -2
  390. package/dist/io/formats/drawio/export.js.map +1 -1
  391. package/dist/io/formats/drawio/index.d.ts.map +1 -1
  392. package/dist/io/formats/drawio/index.js +2 -1
  393. package/dist/io/formats/drawio/index.js.map +1 -1
  394. package/dist/io/formats/drawio/label.js +1 -1
  395. package/dist/io/formats/drawio/paint.js +1 -1
  396. package/dist/io/formats/drawio/placement.d.ts +1 -1
  397. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  398. package/dist/io/formats/fig/export/patch/index.js +5 -0
  399. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  400. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  401. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  402. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  403. package/dist/io/formats/html/import.d.ts.map +1 -1
  404. package/dist/io/formats/html/import.js +3 -1
  405. package/dist/io/formats/html/import.js.map +1 -1
  406. package/dist/io/formats/html/index.d.ts +2 -2
  407. package/dist/io/formats/html/index.d.ts.map +1 -1
  408. package/dist/io/formats/html/index.js +6 -4
  409. package/dist/io/formats/html/index.js.map +1 -1
  410. package/dist/io/formats/html/layers.d.ts +7 -4
  411. package/dist/io/formats/html/layers.d.ts.map +1 -1
  412. package/dist/io/formats/html/layers.js +4 -1
  413. package/dist/io/formats/html/layers.js.map +1 -1
  414. package/dist/io/formats/html/vectors.d.ts +2 -1
  415. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  416. package/dist/io/formats/html/vectors.js +3 -2
  417. package/dist/io/formats/html/vectors.js.map +1 -1
  418. package/dist/io/formats/mermaid/styles.js +1 -1
  419. package/dist/io/formats/pdf/document.d.ts +3 -1
  420. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  421. package/dist/io/formats/pdf/document.js +6 -3
  422. package/dist/io/formats/pdf/document.js.map +1 -1
  423. package/dist/io/formats/pdf/dom.d.ts +6 -1
  424. package/dist/io/formats/pdf/dom.d.ts.map +1 -1
  425. package/dist/io/formats/pdf/dom.js +9 -22
  426. package/dist/io/formats/pdf/dom.js.map +1 -1
  427. package/dist/io/formats/pdf/export.js +1 -1
  428. package/dist/io/formats/pdf/export.js.map +1 -1
  429. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  430. package/dist/io/formats/pen/imports.d.ts +4 -1
  431. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  432. package/dist/io/formats/pen/imports.js.map +1 -1
  433. package/dist/io/formats/pen/index.d.ts.map +1 -1
  434. package/dist/io/formats/pen/index.js +31 -3
  435. package/dist/io/formats/pen/index.js.map +1 -1
  436. package/dist/io/formats/pptx/export.js +1 -1
  437. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  438. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  439. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  440. package/dist/io/formats/raster/adjusted-images.js +118 -0
  441. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  442. package/dist/io/formats/raster/headless.d.ts +11 -1
  443. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  444. package/dist/io/formats/raster/headless.js +4 -4
  445. package/dist/io/formats/raster/headless.js.map +1 -1
  446. package/dist/io/formats/raster/index.d.ts +2 -2
  447. package/dist/io/formats/raster/pixels.d.ts +7 -1
  448. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  449. package/dist/io/formats/raster/pixels.js.map +1 -1
  450. package/dist/io/formats/raster/render.d.ts.map +1 -1
  451. package/dist/io/formats/raster/render.js +4 -0
  452. package/dist/io/formats/raster/render.js.map +1 -1
  453. package/dist/io/formats/svg/defs.d.ts +5 -6
  454. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  455. package/dist/io/formats/svg/defs.js +4 -54
  456. package/dist/io/formats/svg/defs.js.map +1 -1
  457. package/dist/io/formats/svg/effects.d.ts +16 -0
  458. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  459. package/dist/io/formats/svg/effects.js +126 -0
  460. package/dist/io/formats/svg/effects.js.map +1 -0
  461. package/dist/io/formats/svg/export.d.ts +7 -1
  462. package/dist/io/formats/svg/export.d.ts.map +1 -1
  463. package/dist/io/formats/svg/export.js +224 -50
  464. package/dist/io/formats/svg/export.js.map +1 -1
  465. package/dist/io/formats/svg/filter.d.ts +27 -0
  466. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  467. package/dist/io/formats/svg/filter.js +44 -0
  468. package/dist/io/formats/svg/filter.js.map +1 -0
  469. package/dist/io/formats/svg/grain.d.ts +26 -0
  470. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  471. package/dist/io/formats/svg/grain.js +298 -0
  472. package/dist/io/formats/svg/grain.js.map +1 -0
  473. package/dist/io/formats/svg/strokes.d.ts +1 -1
  474. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  475. package/dist/io/formats/svg/strokes.js +1 -2
  476. package/dist/io/formats/svg/strokes.js.map +1 -1
  477. package/dist/io/formats/svg/text/import.js +1 -1
  478. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  479. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  480. package/dist/io/formats/svg/text/layout.js +6 -3
  481. package/dist/io/formats/svg/text/layout.js.map +1 -1
  482. package/dist/io/formats/video/composite.d.ts +18 -0
  483. package/dist/io/formats/video/composite.d.ts.map +1 -0
  484. package/dist/io/formats/video/composite.js +79 -0
  485. package/dist/io/formats/video/composite.js.map +1 -0
  486. package/dist/io/formats/video/formats.d.ts +29 -0
  487. package/dist/io/formats/video/formats.d.ts.map +1 -0
  488. package/dist/io/formats/video/formats.js +43 -0
  489. package/dist/io/formats/video/formats.js.map +1 -0
  490. package/dist/io/formats/video/gif.d.ts +13 -0
  491. package/dist/io/formats/video/gif.d.ts.map +1 -0
  492. package/dist/io/formats/video/gif.js +56 -0
  493. package/dist/io/formats/video/gif.js.map +1 -0
  494. package/dist/io/formats/video/index.d.ts +9 -0
  495. package/dist/io/formats/video/index.js +9 -0
  496. package/dist/io/formats/video/plan.d.ts +64 -0
  497. package/dist/io/formats/video/plan.d.ts.map +1 -0
  498. package/dist/io/formats/video/plan.js +90 -0
  499. package/dist/io/formats/video/plan.js.map +1 -0
  500. package/dist/io/formats/video/record.d.ts +36 -0
  501. package/dist/io/formats/video/record.d.ts.map +1 -0
  502. package/dist/io/formats/video/record.js +154 -0
  503. package/dist/io/formats/video/record.js.map +1 -0
  504. package/dist/io/formats/video/sink.d.ts +29 -0
  505. package/dist/io/formats/video/sink.d.ts.map +1 -0
  506. package/dist/io/formats/video/sink.js +16 -0
  507. package/dist/io/formats/video/sink.js.map +1 -0
  508. package/dist/io/formats/video/size.d.ts +19 -0
  509. package/dist/io/formats/video/size.d.ts.map +1 -0
  510. package/dist/io/formats/video/size.js +26 -0
  511. package/dist/io/formats/video/size.js.map +1 -0
  512. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  513. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  514. package/dist/io/formats/video/webcodecs.js +74 -0
  515. package/dist/io/formats/video/webcodecs.js.map +1 -0
  516. package/dist/io/formats.d.ts.map +1 -1
  517. package/dist/io/formats.js +40 -11
  518. package/dist/io/formats.js.map +1 -1
  519. package/dist/io/types.d.ts +19 -4
  520. package/dist/io/types.d.ts.map +1 -1
  521. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  522. package/dist/layout/apply.d.ts.map +1 -1
  523. package/dist/layout/apply.js +50 -12
  524. package/dist/layout/apply.js.map +1 -1
  525. package/dist/layout/auto-layout-handles.d.ts +66 -0
  526. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  527. package/dist/layout/auto-layout-handles.js +291 -0
  528. package/dist/layout/auto-layout-handles.js.map +1 -0
  529. package/dist/layout/derived.d.ts +7 -1
  530. package/dist/layout/derived.d.ts.map +1 -1
  531. package/dist/layout/derived.js +11 -1
  532. package/dist/layout/derived.js.map +1 -1
  533. package/dist/layout/grid.d.ts +7 -2
  534. package/dist/layout/grid.d.ts.map +1 -1
  535. package/dist/layout/grid.js +27 -9
  536. package/dist/layout/grid.js.map +1 -1
  537. package/dist/layout/mutations.d.ts +1 -0
  538. package/dist/layout/mutations.d.ts.map +1 -1
  539. package/dist/layout/mutations.js +10 -0
  540. package/dist/layout/mutations.js.map +1 -1
  541. package/dist/layout/strokes.d.ts +9 -1
  542. package/dist/layout/strokes.d.ts.map +1 -1
  543. package/dist/layout/strokes.js +12 -1
  544. package/dist/layout/strokes.js.map +1 -1
  545. package/dist/layout/yoga-helpers.d.ts +3 -1
  546. package/dist/layout/yoga-helpers.d.ts.map +1 -1
  547. package/dist/layout/yoga-helpers.js +16 -2
  548. package/dist/layout/yoga-helpers.js.map +1 -1
  549. package/dist/layout.d.ts +3 -2
  550. package/dist/layout.d.ts.map +1 -1
  551. package/dist/layout.js +73 -39
  552. package/dist/layout.js.map +1 -1
  553. package/dist/lint/fixes.d.ts.map +1 -1
  554. package/dist/lint/fixes.js +9 -3
  555. package/dist/lint/fixes.js.map +1 -1
  556. package/dist/lint/index.d.ts +3 -2
  557. package/dist/lint/index.js +2 -1
  558. package/dist/lint/linter.d.ts +13 -0
  559. package/dist/lint/linter.d.ts.map +1 -1
  560. package/dist/lint/linter.js +123 -9
  561. package/dist/lint/linter.js.map +1 -1
  562. package/dist/lint/presets.d.ts.map +1 -1
  563. package/dist/lint/presets.js +2 -0
  564. package/dist/lint/presets.js.map +1 -1
  565. package/dist/lint/rules/design-memory.d.ts +15 -0
  566. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  567. package/dist/lint/rules/design-memory.js +90 -0
  568. package/dist/lint/rules/design-memory.js.map +1 -0
  569. package/dist/lint/rules/effect-style-required.js +1 -0
  570. package/dist/lint/rules/effect-style-required.js.map +1 -1
  571. package/dist/lint/rules/index.d.ts +6 -5
  572. package/dist/lint/rules/index.d.ts.map +1 -1
  573. package/dist/lint/rules/index.js +6 -2
  574. package/dist/lint/rules/index.js.map +1 -1
  575. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  576. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  577. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  578. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  579. package/dist/lint/rules/text-style-required.js +1 -0
  580. package/dist/lint/rules/text-style-required.js.map +1 -1
  581. package/dist/lint/types.d.ts +32 -2
  582. package/dist/lint/types.d.ts.map +1 -1
  583. package/dist/node/video.d.ts +12 -0
  584. package/dist/node/video.d.ts.map +1 -0
  585. package/dist/node/video.js +206 -0
  586. package/dist/node/video.js.map +1 -0
  587. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  588. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  589. package/dist/pairdraw-api/design-memory.js +39 -0
  590. package/dist/pairdraw-api/design-memory.js.map +1 -0
  591. package/dist/pairdraw-api/index.d.ts +45 -1
  592. package/dist/pairdraw-api/index.d.ts.map +1 -1
  593. package/dist/pairdraw-api/index.js +55 -2
  594. package/dist/pairdraw-api/index.js.map +1 -1
  595. package/dist/pairdraw-api/nodes.d.ts +12 -1
  596. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  597. package/dist/pairdraw-api/nodes.js +28 -1
  598. package/dist/pairdraw-api/nodes.js.map +1 -1
  599. package/dist/pairdraw-api/variations.d.ts +48 -0
  600. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  601. package/dist/pairdraw-api/variations.js +76 -0
  602. package/dist/pairdraw-api/variations.js.map +1 -0
  603. package/dist/prototype/easing.d.ts +13 -0
  604. package/dist/prototype/easing.d.ts.map +1 -0
  605. package/dist/prototype/easing.js +36 -0
  606. package/dist/prototype/easing.js.map +1 -0
  607. package/dist/prototype/frames.d.ts +10 -0
  608. package/dist/prototype/frames.d.ts.map +1 -0
  609. package/dist/prototype/frames.js +12 -0
  610. package/dist/prototype/frames.js.map +1 -0
  611. package/dist/prototype/hit.d.ts +17 -0
  612. package/dist/prototype/hit.d.ts.map +1 -0
  613. package/dist/prototype/hit.js +45 -0
  614. package/dist/prototype/hit.js.map +1 -0
  615. package/dist/prototype/index.d.ts +14 -0
  616. package/dist/prototype/index.js +14 -0
  617. package/dist/prototype/pointer.d.ts +63 -0
  618. package/dist/prototype/pointer.d.ts.map +1 -0
  619. package/dist/prototype/pointer.js +104 -0
  620. package/dist/prototype/pointer.js.map +1 -0
  621. package/dist/prototype/reactions.d.ts +45 -0
  622. package/dist/prototype/reactions.d.ts.map +1 -0
  623. package/dist/prototype/reactions.js +122 -0
  624. package/dist/prototype/reactions.js.map +1 -0
  625. package/dist/prototype/scene.d.ts +35 -0
  626. package/dist/prototype/scene.d.ts.map +1 -0
  627. package/dist/prototype/scene.js +86 -0
  628. package/dist/prototype/scene.js.map +1 -0
  629. package/dist/prototype/scenes.d.ts +81 -0
  630. package/dist/prototype/scenes.d.ts.map +1 -0
  631. package/dist/prototype/scenes.js +175 -0
  632. package/dist/prototype/scenes.js.map +1 -0
  633. package/dist/prototype/scroll.d.ts +48 -0
  634. package/dist/prototype/scroll.d.ts.map +1 -0
  635. package/dist/prototype/scroll.js +159 -0
  636. package/dist/prototype/scroll.js.map +1 -0
  637. package/dist/prototype/session.d.ts +71 -0
  638. package/dist/prototype/session.d.ts.map +1 -0
  639. package/dist/prototype/session.js +135 -0
  640. package/dist/prototype/session.js.map +1 -0
  641. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  642. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  643. package/dist/prototype/smart-animate/animation.js +212 -0
  644. package/dist/prototype/smart-animate/animation.js.map +1 -0
  645. package/dist/prototype/smart-animate/match.d.ts +24 -0
  646. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  647. package/dist/prototype/smart-animate/match.js +72 -0
  648. package/dist/prototype/smart-animate/match.js.map +1 -0
  649. package/dist/prototype/snapshot.d.ts +19 -0
  650. package/dist/prototype/snapshot.d.ts.map +1 -0
  651. package/dist/prototype/snapshot.js +56 -0
  652. package/dist/prototype/snapshot.js.map +1 -0
  653. package/dist/prototype/timeline.d.ts +132 -0
  654. package/dist/prototype/timeline.d.ts.map +1 -0
  655. package/dist/prototype/timeline.js +260 -0
  656. package/dist/prototype/timeline.js.map +1 -0
  657. package/dist/rpc/commands.d.ts +2 -2
  658. package/dist/rpc/index.d.ts +2 -2
  659. package/dist/rpc/read-commands.d.ts +18 -8
  660. package/dist/rpc/read-commands.d.ts.map +1 -1
  661. package/dist/rpc/read-commands.js +18 -9
  662. package/dist/rpc/read-commands.js.map +1 -1
  663. package/dist/text/font/faces.d.ts +12 -1
  664. package/dist/text/font/faces.d.ts.map +1 -1
  665. package/dist/text/font/faces.js +15 -1
  666. package/dist/text/font/faces.js.map +1 -1
  667. package/dist/text/font/features.d.ts +9 -0
  668. package/dist/text/font/features.d.ts.map +1 -0
  669. package/dist/text/font/features.js +27 -0
  670. package/dist/text/font/features.js.map +1 -0
  671. package/dist/text/font/manager.d.ts +12 -0
  672. package/dist/text/font/manager.d.ts.map +1 -1
  673. package/dist/text/font/manager.js +66 -12
  674. package/dist/text/font/manager.js.map +1 -1
  675. package/dist/text/index.d.ts +11 -9
  676. package/dist/text/index.js +4 -2
  677. package/dist/text/replace-fonts.d.ts +41 -0
  678. package/dist/text/replace-fonts.d.ts.map +1 -0
  679. package/dist/text/replace-fonts.js +121 -0
  680. package/dist/text/replace-fonts.js.map +1 -0
  681. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  682. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  683. package/dist/tools/analyze/responsive/index.js +203 -0
  684. package/dist/tools/analyze/responsive/index.js.map +1 -0
  685. package/dist/tools/analyze.d.ts +2 -1
  686. package/dist/tools/analyze.js +2 -1
  687. package/dist/tools/codegen/token-sync.d.ts +7 -0
  688. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  689. package/dist/tools/codegen/token-sync.js +85 -0
  690. package/dist/tools/codegen/token-sync.js.map +1 -0
  691. package/dist/tools/codegen/tokens.d.ts +1 -1
  692. package/dist/tools/codegen.d.ts +2 -1
  693. package/dist/tools/codegen.js +2 -1
  694. package/dist/tools/create/basic.js +1 -1
  695. package/dist/tools/create/behaviours.js +1 -1
  696. package/dist/tools/create/components.d.ts.map +1 -1
  697. package/dist/tools/create/components.js +4 -0
  698. package/dist/tools/create/components.js.map +1 -1
  699. package/dist/tools/create/html.js +3 -2
  700. package/dist/tools/create/html.js.map +1 -1
  701. package/dist/tools/create/icons.d.ts.map +1 -1
  702. package/dist/tools/create/icons.js +2 -1
  703. package/dist/tools/create/icons.js.map +1 -1
  704. package/dist/tools/create/mermaid.js +2 -1
  705. package/dist/tools/create/mermaid.js.map +1 -1
  706. package/dist/tools/create/render.js +1 -1
  707. package/dist/tools/create/svg.js +2 -1
  708. package/dist/tools/create/svg.js.map +1 -1
  709. package/dist/tools/create/vector.js +1 -1
  710. package/dist/tools/design-memory.d.ts +8 -0
  711. package/dist/tools/design-memory.d.ts.map +1 -0
  712. package/dist/tools/design-memory.js +68 -0
  713. package/dist/tools/design-memory.js.map +1 -0
  714. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  715. package/dist/tools/image-ai/generate.js +3 -1
  716. package/dist/tools/image-ai/generate.js.map +1 -1
  717. package/dist/tools/index.d.ts +2 -1
  718. package/dist/tools/index.js +2 -1
  719. package/dist/tools/modify/fonts.d.ts +6 -0
  720. package/dist/tools/modify/fonts.d.ts.map +1 -0
  721. package/dist/tools/modify/fonts.js +27 -0
  722. package/dist/tools/modify/fonts.js.map +1 -0
  723. package/dist/tools/modify/layout.d.ts.map +1 -1
  724. package/dist/tools/modify/layout.js +1 -0
  725. package/dist/tools/modify/layout.js.map +1 -1
  726. package/dist/tools/modify/paint.js +1 -1
  727. package/dist/tools/modify/reactions.d.ts.map +1 -1
  728. package/dist/tools/modify/reactions.js +3 -3
  729. package/dist/tools/modify/reactions.js.map +1 -1
  730. package/dist/tools/modify/text.d.ts.map +1 -1
  731. package/dist/tools/modify/text.js +26 -5
  732. package/dist/tools/modify/text.js.map +1 -1
  733. package/dist/tools/modify/update.d.ts +10 -1
  734. package/dist/tools/modify/update.d.ts.map +1 -1
  735. package/dist/tools/modify/update.js +34 -3
  736. package/dist/tools/modify/update.js.map +1 -1
  737. package/dist/tools/modify.d.ts +2 -1
  738. package/dist/tools/modify.js +2 -1
  739. package/dist/tools/read/fonts.d.ts.map +1 -1
  740. package/dist/tools/read/fonts.js +17 -2
  741. package/dist/tools/read/fonts.js.map +1 -1
  742. package/dist/tools/read/libraries.js +2 -1
  743. package/dist/tools/read/libraries.js.map +1 -1
  744. package/dist/tools/read/nodes.d.ts.map +1 -1
  745. package/dist/tools/read/nodes.js.map +1 -1
  746. package/dist/tools/read/space.d.ts +3 -1
  747. package/dist/tools/read/space.d.ts.map +1 -1
  748. package/dist/tools/read/space.js +4 -3
  749. package/dist/tools/read/space.js.map +1 -1
  750. package/dist/tools/registry/core.d.ts +1 -1
  751. package/dist/tools/registry/core.d.ts.map +1 -1
  752. package/dist/tools/registry/core.js +3 -1
  753. package/dist/tools/registry/core.js.map +1 -1
  754. package/dist/tools/registry/extended.d.ts.map +1 -1
  755. package/dist/tools/registry/extended.js +16 -1
  756. package/dist/tools/registry/extended.js.map +1 -1
  757. package/dist/tools/schema.d.ts +18 -2
  758. package/dist/tools/schema.d.ts.map +1 -1
  759. package/dist/tools/schema.js +1 -1
  760. package/dist/tools/schema.js.map +1 -1
  761. package/dist/tools/stock-photo.js +1 -0
  762. package/dist/tools/stock-photo.js.map +1 -1
  763. package/dist/tools/structure/basic.d.ts.map +1 -1
  764. package/dist/tools/structure/basic.js +1 -0
  765. package/dist/tools/structure/basic.js.map +1 -1
  766. package/dist/tools/structure/batch.d.ts.map +1 -1
  767. package/dist/tools/structure/batch.js +22 -1
  768. package/dist/tools/structure/batch.js.map +1 -1
  769. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  770. package/dist/tools/structure/hierarchy.js +4 -0
  771. package/dist/tools/structure/hierarchy.js.map +1 -1
  772. package/dist/tools/structure/variations.d.ts +8 -0
  773. package/dist/tools/structure/variations.d.ts.map +1 -0
  774. package/dist/tools/structure/variations.js +106 -0
  775. package/dist/tools/structure/variations.js.map +1 -0
  776. package/dist/tools/structure.d.ts +2 -1
  777. package/dist/tools/structure.js +2 -1
  778. package/dist/tools/styles/types.d.ts +2 -4
  779. package/dist/tools/styles/types.d.ts.map +1 -1
  780. package/dist/tools/styles/types.js.map +1 -1
  781. package/dist/tools/vector/boolean.d.ts.map +1 -1
  782. package/dist/tools/vector/boolean.js +4 -0
  783. package/dist/tools/vector/boolean.js.map +1 -1
  784. package/dist/tools/vector/path.d.ts.map +1 -1
  785. package/dist/tools/vector/path.js +39 -7
  786. package/dist/tools/vector/path.js.map +1 -1
  787. package/dist/tools/vector/vectorize.js +1 -0
  788. package/dist/tools/vector/vectorize.js.map +1 -1
  789. package/dist/tools/vector/video.d.ts +6 -0
  790. package/dist/tools/vector/video.d.ts.map +1 -0
  791. package/dist/tools/vector/video.js +133 -0
  792. package/dist/tools/vector/video.js.map +1 -0
  793. package/dist/tools/vector.d.ts +2 -1
  794. package/dist/tools/vector.js +2 -1
  795. package/dist/tools/video-host.d.ts +12 -0
  796. package/dist/tools/video-host.d.ts.map +1 -0
  797. package/dist/tools/video-host.js +19 -0
  798. package/dist/tools/video-host.js.map +1 -0
  799. package/dist/vector/point-transform.d.ts +1 -1
  800. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  801. package/dist/xpath.d.ts +3 -0
  802. package/dist/xpath.d.ts.map +1 -1
  803. package/dist/xpath.js +3 -1
  804. package/dist/xpath.js.map +1 -1
  805. package/package.json +31 -9
  806. package/src/ai/providers.ts +2 -0
  807. package/src/cache/resource.ts +24 -1
  808. package/src/canvas/effects.ts +47 -50
  809. package/src/canvas/fills.ts +19 -15
  810. package/src/canvas/images/adjustments.ts +203 -0
  811. package/src/canvas/images/sampling.ts +88 -0
  812. package/src/canvas/index.ts +1 -0
  813. package/src/canvas/masks.ts +1 -1
  814. package/src/canvas/noise/render.ts +75 -0
  815. package/src/canvas/noise/shader.ts +161 -0
  816. package/src/canvas/noise/table.ts +91 -0
  817. package/src/canvas/noise/tile.ts +94 -0
  818. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  819. package/src/canvas/overlays/index.ts +0 -1
  820. package/src/canvas/overlays/selection.ts +1 -12
  821. package/src/canvas/renderer/fonts.ts +2 -0
  822. package/src/canvas/renderer/lifecycle.ts +6 -0
  823. package/src/canvas/renderer/methods.ts +0 -9
  824. package/src/canvas/renderer/overlay-pass.ts +0 -1
  825. package/src/canvas/renderer/pipeline.ts +19 -2
  826. package/src/canvas/renderer/play-scenes.ts +51 -0
  827. package/src/canvas/renderer/tiles/cache.ts +54 -1
  828. package/src/canvas/renderer/tiles/controller.ts +30 -1
  829. package/src/canvas/renderer/types.ts +18 -3
  830. package/src/canvas/renderer.ts +40 -4
  831. package/src/canvas/scene.ts +65 -9
  832. package/src/canvas/texture.ts +136 -0
  833. package/src/clipboard.ts +23 -10
  834. package/src/constants.ts +6 -0
  835. package/src/design-jsx/index.ts +1 -1
  836. package/src/design-jsx/renderer.ts +1 -1
  837. package/src/design-memory/check.ts +376 -0
  838. package/src/design-memory/describe.ts +77 -0
  839. package/src/design-memory/distil.ts +69 -0
  840. package/src/design-memory/document.ts +80 -0
  841. package/src/design-memory/guard.ts +157 -0
  842. package/src/design-memory/index.ts +8 -0
  843. package/src/design-memory/refusal.ts +90 -0
  844. package/src/design-memory/rules.ts +274 -0
  845. package/src/design-memory/values.ts +179 -0
  846. package/src/editor/bridges/components.ts +2 -0
  847. package/src/editor/clipboard/export.ts +24 -7
  848. package/src/editor/clipboard/snapshot.ts +21 -4
  849. package/src/editor/clipboard.ts +4 -14
  850. package/src/editor/color-space.ts +47 -38
  851. package/src/editor/components/instances.ts +31 -0
  852. package/src/editor/create.ts +39 -71
  853. package/src/editor/design-memory.ts +39 -0
  854. package/src/editor/design-tokens.ts +41 -2
  855. package/src/editor/document-colors.ts +65 -0
  856. package/src/editor/eyedropper.ts +198 -0
  857. package/src/editor/fonts.ts +19 -0
  858. package/src/editor/history/atomic-tool.ts +29 -1
  859. package/src/editor/history/capture.ts +19 -0
  860. package/src/editor/history/document-change.ts +5 -17
  861. package/src/editor/history/edit.ts +16 -2
  862. package/src/editor/history/subtree.ts +13 -2
  863. package/src/editor/index.ts +11 -0
  864. package/src/editor/nudge.ts +1 -1
  865. package/src/editor/pages.ts +40 -29
  866. package/src/editor/play/states.ts +1 -1
  867. package/src/editor/read-only/actions.ts +6 -0
  868. package/src/editor/render-requests.ts +83 -0
  869. package/src/editor/selection/container.ts +24 -1
  870. package/src/editor/selection/navigation.ts +8 -6
  871. package/src/editor/selection/overlays.ts +1 -0
  872. package/src/editor/shapes/with-text.ts +2 -5
  873. package/src/editor/structure/auto-layout-wrap.ts +1 -1
  874. package/src/editor/structure/boolean.ts +1 -3
  875. package/src/editor/structure/group/bounds.ts +1 -5
  876. package/src/editor/structure/outline-stroke.ts +3 -3
  877. package/src/editor/structure/reorder.ts +8 -14
  878. package/src/editor/structure/state.ts +1 -1
  879. package/src/editor/structure.ts +5 -8
  880. package/src/editor/tool-registry.ts +2 -1
  881. package/src/editor/types.ts +8 -1
  882. package/src/editor/variables.ts +74 -2
  883. package/src/editor/variations/create.ts +235 -0
  884. package/src/editor/variations/pick.ts +35 -0
  885. package/src/editor/variations.ts +110 -0
  886. package/src/figma-api/accessors/reactions.ts +11 -1
  887. package/src/figma-api/accessors/text/index.ts +17 -1
  888. package/src/figma-api/accessors/text/opentype.ts +33 -0
  889. package/src/figma-api/accessors/visual.ts +55 -2
  890. package/src/figma-api/compatibility.ts +5 -2
  891. package/src/figma-api/effects.ts +143 -5
  892. package/src/figma-api/fonts/loaded.ts +9 -0
  893. package/src/figma-api/index.ts +35 -0
  894. package/src/figma-api/overrides.ts +295 -3
  895. package/src/figma-api/paints.ts +24 -9
  896. package/src/figma-api/proxy.ts +6 -1
  897. package/src/figma-api/reactions.ts +130 -32
  898. package/src/figma-api/serialization.ts +2 -1
  899. package/src/figma-api/shape-details.ts +50 -0
  900. package/src/figma-api/shape-with-text.ts +2 -5
  901. package/src/figma-api/surface.ts +7 -2
  902. package/src/global.d.ts +31 -0
  903. package/src/icons/svg.ts +3 -1
  904. package/src/io/formats/boolean-path.ts +60 -0
  905. package/src/io/formats/design-tokens/index.ts +21 -0
  906. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  907. package/src/io/formats/design-tokens/project.ts +40 -9
  908. package/src/io/formats/design-tokens/styles.ts +10 -2
  909. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  910. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  911. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  912. package/src/io/formats/drawio/edges.ts +65 -0
  913. package/src/io/formats/drawio/export.ts +37 -14
  914. package/src/io/formats/drawio/index.ts +5 -1
  915. package/src/io/formats/fig/export/patch/index.ts +8 -0
  916. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  917. package/src/io/formats/html/import.ts +9 -1
  918. package/src/io/formats/html/index.ts +14 -7
  919. package/src/io/formats/html/layers.ts +11 -2
  920. package/src/io/formats/html/vectors.ts +8 -2
  921. package/src/io/formats/pdf/document.ts +14 -4
  922. package/src/io/formats/pdf/dom.ts +10 -18
  923. package/src/io/formats/pdf/export.ts +1 -1
  924. package/src/io/formats/pen/imports.ts +5 -6
  925. package/src/io/formats/pen/index.ts +36 -5
  926. package/src/io/formats/raster/adjusted-images.ts +125 -0
  927. package/src/io/formats/raster/headless.ts +3 -3
  928. package/src/io/formats/raster/index.ts +6 -1
  929. package/src/io/formats/raster/pixels.ts +7 -0
  930. package/src/io/formats/raster/render.ts +12 -1
  931. package/src/io/formats/svg/defs.ts +14 -73
  932. package/src/io/formats/svg/effects.ts +131 -0
  933. package/src/io/formats/svg/export.ts +371 -64
  934. package/src/io/formats/svg/filter.ts +47 -0
  935. package/src/io/formats/svg/grain.ts +249 -0
  936. package/src/io/formats/svg/strokes.ts +2 -2
  937. package/src/io/formats/svg/text/layout.ts +13 -3
  938. package/src/io/formats/video/composite.ts +79 -0
  939. package/src/io/formats/video/formats.ts +77 -0
  940. package/src/io/formats/video/gif.ts +65 -0
  941. package/src/io/formats/video/index.ts +30 -0
  942. package/src/io/formats/video/plan.ts +116 -0
  943. package/src/io/formats/video/record.ts +227 -0
  944. package/src/io/formats/video/sink.ts +32 -0
  945. package/src/io/formats/video/size.ts +25 -0
  946. package/src/io/formats/video/webcodecs.ts +89 -0
  947. package/src/io/formats.ts +59 -11
  948. package/src/io/types.ts +29 -10
  949. package/src/layout/apply.ts +87 -21
  950. package/src/layout/auto-layout-handles.ts +396 -0
  951. package/src/layout/derived.ts +14 -0
  952. package/src/layout/grid.ts +33 -9
  953. package/src/layout/mutations.ts +13 -1
  954. package/src/layout/strokes.ts +12 -0
  955. package/src/layout/yoga-helpers.ts +18 -1
  956. package/src/layout.ts +96 -49
  957. package/src/lint/fixes.ts +12 -3
  958. package/src/lint/index.ts +3 -1
  959. package/src/lint/linter.ts +124 -12
  960. package/src/lint/presets.ts +2 -0
  961. package/src/lint/rules/design-memory.ts +97 -0
  962. package/src/lint/rules/effect-style-required.ts +2 -0
  963. package/src/lint/rules/index.ts +6 -1
  964. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  965. package/src/lint/rules/text-style-required.ts +2 -0
  966. package/src/lint/types.ts +40 -0
  967. package/src/node/video.ts +196 -0
  968. package/src/pairdraw-api/design-memory.ts +61 -0
  969. package/src/pairdraw-api/index.ts +81 -0
  970. package/src/pairdraw-api/nodes.ts +38 -0
  971. package/src/pairdraw-api/variations.ts +109 -0
  972. package/src/prototype/easing.ts +37 -0
  973. package/src/prototype/frames.ts +9 -0
  974. package/src/prototype/hit.ts +70 -0
  975. package/src/prototype/index.ts +69 -0
  976. package/src/prototype/pointer.ts +146 -0
  977. package/src/prototype/reactions.ts +178 -0
  978. package/src/prototype/scene.ts +116 -0
  979. package/src/prototype/scenes.ts +256 -0
  980. package/src/prototype/scroll.ts +190 -0
  981. package/src/prototype/session.ts +188 -0
  982. package/src/prototype/smart-animate/animation.ts +267 -0
  983. package/src/prototype/smart-animate/match.ts +85 -0
  984. package/src/prototype/snapshot.ts +60 -0
  985. package/src/prototype/timeline.ts +400 -0
  986. package/src/rpc/index.ts +1 -0
  987. package/src/rpc/read-commands.ts +40 -23
  988. package/src/text/font/faces.ts +22 -0
  989. package/src/text/font/features.ts +27 -0
  990. package/src/text/font/manager.ts +88 -12
  991. package/src/text/index.ts +2 -0
  992. package/src/text/replace-fonts.ts +171 -0
  993. package/src/tools/analyze/responsive/index.ts +264 -0
  994. package/src/tools/analyze.ts +2 -0
  995. package/src/tools/codegen/token-sync.ts +98 -0
  996. package/src/tools/codegen.ts +1 -0
  997. package/src/tools/create/components.ts +4 -0
  998. package/src/tools/create/html.ts +1 -0
  999. package/src/tools/create/icons.ts +1 -0
  1000. package/src/tools/create/mermaid.ts +1 -0
  1001. package/src/tools/create/svg.ts +1 -0
  1002. package/src/tools/design-memory.ts +72 -0
  1003. package/src/tools/image-ai/generate.ts +2 -0
  1004. package/src/tools/index.ts +1 -0
  1005. package/src/tools/modify/fonts.ts +34 -0
  1006. package/src/tools/modify/layout.ts +5 -0
  1007. package/src/tools/modify/reactions.ts +15 -8
  1008. package/src/tools/modify/text.ts +42 -5
  1009. package/src/tools/modify/update.ts +46 -2
  1010. package/src/tools/modify.ts +1 -0
  1011. package/src/tools/read/fonts.ts +24 -2
  1012. package/src/tools/read/libraries.ts +1 -0
  1013. package/src/tools/read/nodes.ts +0 -1
  1014. package/src/tools/read/space.ts +3 -2
  1015. package/src/tools/registry/core.ts +3 -1
  1016. package/src/tools/registry/extended.ts +28 -1
  1017. package/src/tools/schema.ts +28 -4
  1018. package/src/tools/stock-photo.ts +1 -0
  1019. package/src/tools/structure/basic.ts +1 -0
  1020. package/src/tools/structure/batch.ts +34 -1
  1021. package/src/tools/structure/hierarchy.ts +4 -0
  1022. package/src/tools/structure/variations.ts +118 -0
  1023. package/src/tools/structure.ts +2 -0
  1024. package/src/tools/styles/types.ts +3 -4
  1025. package/src/tools/vector/boolean.ts +4 -0
  1026. package/src/tools/vector/path.ts +30 -6
  1027. package/src/tools/vector/vectorize.ts +1 -0
  1028. package/src/tools/vector/video.ts +228 -0
  1029. package/src/tools/vector.ts +1 -0
  1030. package/src/tools/video-host.ts +18 -0
  1031. package/src/xpath.ts +6 -1
@@ -0,0 +1,43 @@
1
+ import { createGIFSink } from "./gif.js";
2
+ import { VIDEO_FORMATS } from "./sink.js";
3
+ import { canRecordVideo, createWebCodecsSink } from "./webcodecs.js";
4
+ //#region src/io/formats/video/formats.ts
5
+ /** Each format's name as people know it. */
6
+ const VIDEO_FORMAT_LABELS = {
7
+ mp4: "MP4",
8
+ gif: "GIF",
9
+ webm: "WebM"
10
+ };
11
+ /** A format this engine cannot record at the size and frame rate asked for, and why. */
12
+ var VideoFormatError = class extends Error {
13
+ name = "VideoFormatError";
14
+ };
15
+ /** Whether this engine, or the host's encoder, can record `format` at `width`×`height` and `fps`. */
16
+ async function canRecordFormat(format, width, height, fps, host) {
17
+ if (format === "gif") return fps <= 50;
18
+ if (await canRecordVideo(format, width, height, fps)) return true;
19
+ return await host?.supports(format) ?? false;
20
+ }
21
+ /** The formats this engine can record at `width`×`height` and `fps`, MP4 first. */
22
+ async function recordableFormats(width, height, fps, host) {
23
+ const supported = await Promise.all(VIDEO_FORMATS.map((format) => canRecordFormat(format, width, height, fps, host)));
24
+ return VIDEO_FORMATS.filter((_, index) => supported[index]);
25
+ }
26
+ /**
27
+ * The encoder for `format`: GIF everywhere, MP4 and WebM where WebCodecs (or an encoder registered
28
+ * with mediabunny) can encode them, else through `host`. Throws a `VideoFormatError` naming the
29
+ * formats that do work here.
30
+ */
31
+ async function openVideoSink(format, options, host) {
32
+ const { width, height, fps } = options;
33
+ if (format === "gif" && fps <= 50) return createGIFSink(options);
34
+ if (format !== "gif" && await canRecordVideo(format, width, height, fps)) return createWebCodecsSink(format, options);
35
+ if (format !== "gif" && host && await host.supports(format)) return host.create(format, options);
36
+ if (format === "gif") throw new VideoFormatError(`GIF plays at most 50 frames per second`);
37
+ const working = await recordableFormats(width, height, fps, host);
38
+ throw new VideoFormatError(`${VIDEO_FORMAT_LABELS[format]} can’t be encoded here at ${width}×${height}. Formats that work here: ${working.map((entry) => VIDEO_FORMAT_LABELS[entry]).join(", ")}.`);
39
+ }
40
+ //#endregion
41
+ export { VIDEO_FORMAT_LABELS, VideoFormatError, canRecordFormat, openVideoSink, recordableFormats };
42
+
43
+ //# sourceMappingURL=formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.js","names":[],"sources":["../../../../src/io/formats/video/formats.ts"],"sourcesContent":["import { createGIFSink, MAX_GIF_FPS } from './gif'\nimport { VIDEO_FORMATS, type VideoFormat, type VideoSink, type VideoSinkOptions } from './sink'\nimport { canRecordVideo, createWebCodecsSink } from './webcodecs'\n\n/** Each format's name as people know it. */\nexport const VIDEO_FORMAT_LABELS: Record<VideoFormat, string> = {\n mp4: 'MP4',\n gif: 'GIF',\n webm: 'WebM'\n}\n\n/**\n * An encoder a host passes for the formats WebCodecs cannot encode there, such as the CLI's\n * ffmpeg. It is asked only for MP4 and WebM, after WebCodecs.\n */\nexport interface VideoHostEncoder {\n supports(format: VideoFormat): boolean | Promise<boolean>\n create(format: VideoFormat, options: VideoSinkOptions): Promise<VideoSink>\n}\n\n/** A format this engine cannot record at the size and frame rate asked for, and why. */\nexport class VideoFormatError extends Error {\n override name = 'VideoFormatError'\n}\n\n/** Whether this engine, or the host's encoder, can record `format` at `width`×`height` and `fps`. */\nexport async function canRecordFormat(\n format: VideoFormat,\n width: number,\n height: number,\n fps: number,\n host?: VideoHostEncoder | null\n): Promise<boolean> {\n if (format === 'gif') return fps <= MAX_GIF_FPS\n if (await canRecordVideo(format, width, height, fps)) return true\n return (await host?.supports(format)) ?? false\n}\n\n/** The formats this engine can record at `width`×`height` and `fps`, MP4 first. */\nexport async function recordableFormats(\n width: number,\n height: number,\n fps: number,\n host?: VideoHostEncoder | null\n): Promise<VideoFormat[]> {\n const supported = await Promise.all(\n VIDEO_FORMATS.map((format) => canRecordFormat(format, width, height, fps, host))\n )\n return VIDEO_FORMATS.filter((_, index) => supported[index])\n}\n\n/**\n * The encoder for `format`: GIF everywhere, MP4 and WebM where WebCodecs (or an encoder registered\n * with mediabunny) can encode them, else through `host`. Throws a `VideoFormatError` naming the\n * formats that do work here.\n */\nexport async function openVideoSink(\n format: VideoFormat,\n options: VideoSinkOptions,\n host?: VideoHostEncoder | null\n): Promise<VideoSink> {\n const { width, height, fps } = options\n if (format === 'gif' && fps <= MAX_GIF_FPS) return createGIFSink(options)\n if (format !== 'gif' && (await canRecordVideo(format, width, height, fps))) {\n return createWebCodecsSink(format, options)\n }\n if (format !== 'gif' && host && (await host.supports(format))) {\n return host.create(format, options)\n }\n if (format === 'gif') {\n throw new VideoFormatError(`GIF plays at most ${MAX_GIF_FPS} frames per second`)\n }\n const working = await recordableFormats(width, height, fps, host)\n throw new VideoFormatError(\n `${VIDEO_FORMAT_LABELS[format]} can’t be encoded here at ${width}×${height}. Formats that work here: ${working.map((entry) => VIDEO_FORMAT_LABELS[entry]).join(', ')}.`\n )\n}\n"],"mappings":";;;;;AAKA,MAAa,sBAAmD;CAC9D,KAAK;CACL,KAAK;CACL,MAAM;AACR;;AAYA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,OAAgB;AAClB;;AAGA,eAAsB,gBACpB,QACA,OACA,QACA,KACA,MACkB;CAClB,IAAI,WAAW,OAAO,OAAO,OAAA;CAC7B,IAAI,MAAM,eAAe,QAAQ,OAAO,QAAQ,GAAG,GAAG,OAAO;CAC7D,OAAQ,MAAM,MAAM,SAAS,MAAM,KAAM;AAC3C;;AAGA,eAAsB,kBACpB,OACA,QACA,KACA,MACwB;CACxB,MAAM,YAAY,MAAM,QAAQ,IAC9B,cAAc,KAAK,WAAW,gBAAgB,QAAQ,OAAO,QAAQ,KAAK,IAAI,CAAC,CACjF;CACA,OAAO,cAAc,QAAQ,GAAG,UAAU,UAAU,MAAM;AAC5D;;;;;;AAOA,eAAsB,cACpB,QACA,SACA,MACoB;CACpB,MAAM,EAAE,OAAO,QAAQ,QAAQ;CAC/B,IAAI,WAAW,SAAS,OAAA,IAAoB,OAAO,cAAc,OAAO;CACxE,IAAI,WAAW,SAAU,MAAM,eAAe,QAAQ,OAAO,QAAQ,GAAG,GACtE,OAAO,oBAAoB,QAAQ,OAAO;CAE5C,IAAI,WAAW,SAAS,QAAS,MAAM,KAAK,SAAS,MAAM,GACzD,OAAO,KAAK,OAAO,QAAQ,OAAO;CAEpC,IAAI,WAAW,OACb,MAAM,IAAI,iBAAiB,wCAAoD;CAEjF,MAAM,UAAU,MAAM,kBAAkB,OAAO,QAAQ,KAAK,IAAI;CAChE,MAAM,IAAI,iBACR,GAAG,oBAAoB,QAAQ,4BAA4B,MAAM,GAAG,OAAO,4BAA4B,QAAQ,KAAK,UAAU,oBAAoB,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,EACvK;AACF"}
@@ -0,0 +1,13 @@
1
+ import { VideoSink, VideoSinkOptions } from "./sink.js";
2
+ //#region src/io/formats/video/gif.d.ts
3
+ /** Browsers stretch delays under two hundredths of a second, so faster GIFs play slower. */
4
+ declare const MAX_GIF_FPS = 50;
5
+ /**
6
+ * A GIF encoder for recorded frames. A frame passed again as the same image extends the one before
7
+ * it, so a held screen is stored once with its whole delay. Delays are kept in hundredths of a
8
+ * second measured from the start, so rounding never drifts the clip's length.
9
+ */
10
+ declare function createGIFSink(options: VideoSinkOptions): VideoSink;
11
+ //#endregion
12
+ export { MAX_GIF_FPS, createGIFSink };
13
+ //# sourceMappingURL=gif.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gif.d.ts","names":[],"sources":["../../../../src/io/formats/video/gif.ts"],"mappings":";;;cASa;;;;;;iBAaG,cAAc,SAAS,mBAAmB"}
@@ -0,0 +1,56 @@
1
+ import { GIFEncoder, applyPalette, quantize } from "gifenc/dist/gifenc.esm.js";
2
+ //#region src/io/formats/video/gif.ts
3
+ /** Browsers stretch delays under two hundredths of a second, so faster GIFs play slower. */
4
+ const MAX_GIF_FPS = 50;
5
+ /**
6
+ * A GIF encoder for recorded frames. A frame passed again as the same image extends the one before
7
+ * it, so a held screen is stored once with its whole delay. Delays are kept in hundredths of a
8
+ * second measured from the start, so rounding never drifts the clip's length.
9
+ */
10
+ function createGIFSink(options) {
11
+ if (options.fps > 50) throw new Error(`GIF plays at most 50 frames per second`);
12
+ const encoder = GIFEncoder();
13
+ let pending = null;
14
+ function write(frame) {
15
+ const { data, width, height } = frame.image;
16
+ const palette = quantize(data, 256);
17
+ const delayCs = Math.round(frame.endMs / 10) - Math.round(frame.startMs / 10);
18
+ encoder.writeFrame(applyPalette(data, palette), width, height, {
19
+ palette,
20
+ delay: delayCs * 10,
21
+ repeat: options.loops ? 0 : -1
22
+ });
23
+ }
24
+ return {
25
+ add(image, timestampMs, durationMs) {
26
+ const endMs = timestampMs + durationMs;
27
+ if (pending?.image === image) pending.endMs = endMs;
28
+ else {
29
+ if (pending) write(pending);
30
+ pending = {
31
+ image,
32
+ startMs: timestampMs,
33
+ endMs
34
+ };
35
+ }
36
+ return Promise.resolve();
37
+ },
38
+ finish() {
39
+ if (pending) write(pending);
40
+ pending = null;
41
+ encoder.finish();
42
+ return Promise.resolve(encoder.bytes());
43
+ },
44
+ cancel() {
45
+ pending = null;
46
+ return Promise.resolve();
47
+ },
48
+ get byteLength() {
49
+ return encoder.bytesView().length;
50
+ }
51
+ };
52
+ }
53
+ //#endregion
54
+ export { MAX_GIF_FPS, createGIFSink };
55
+
56
+ //# sourceMappingURL=gif.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gif.js","names":[],"sources":["../../../../src/io/formats/video/gif.ts"],"sourcesContent":["// gifenc's package root resolves to its CJS build under Node, whose named exports Node ESM cannot\n// see; the ES build it ships for bundlers has them, and every runtime loads that same file.\nimport { applyPalette, GIFEncoder, quantize } from 'gifenc/dist/gifenc.esm.js'\n\nimport type { RGBAImage } from '#core/io/formats/raster'\n\nimport type { VideoSink, VideoSinkOptions } from './sink'\n\n/** Browsers stretch delays under two hundredths of a second, so faster GIFs play slower. */\nexport const MAX_GIF_FPS = 50\n\ninterface PendingFrame {\n image: RGBAImage\n startMs: number\n endMs: number\n}\n\n/**\n * A GIF encoder for recorded frames. A frame passed again as the same image extends the one before\n * it, so a held screen is stored once with its whole delay. Delays are kept in hundredths of a\n * second measured from the start, so rounding never drifts the clip's length.\n */\nexport function createGIFSink(options: VideoSinkOptions): VideoSink {\n if (options.fps > MAX_GIF_FPS) {\n throw new Error(`GIF plays at most ${MAX_GIF_FPS} frames per second`)\n }\n const encoder = GIFEncoder()\n let pending: PendingFrame | null = null\n\n function write(frame: PendingFrame) {\n const { data, width, height } = frame.image\n const palette = quantize(data, 256)\n const delayCs = Math.round(frame.endMs / 10) - Math.round(frame.startMs / 10)\n encoder.writeFrame(applyPalette(data, palette), width, height, {\n palette,\n delay: delayCs * 10,\n repeat: options.loops ? 0 : -1\n })\n }\n\n return {\n add(image, timestampMs, durationMs) {\n const endMs = timestampMs + durationMs\n if (pending?.image === image) pending.endMs = endMs\n else {\n if (pending) write(pending)\n pending = { image, startMs: timestampMs, endMs }\n }\n return Promise.resolve()\n },\n finish() {\n if (pending) write(pending)\n pending = null\n encoder.finish()\n return Promise.resolve(encoder.bytes())\n },\n cancel() {\n pending = null\n return Promise.resolve()\n },\n get byteLength() {\n return encoder.bytesView().length\n }\n }\n}\n"],"mappings":";;;AASA,MAAa,cAAc;;;;;;AAa3B,SAAgB,cAAc,SAAsC;CAClE,IAAI,QAAQ,MAAA,IACV,MAAM,IAAI,MAAM,wCAAoD;CAEtE,MAAM,UAAU,WAAW;CAC3B,IAAI,UAA+B;CAEnC,SAAS,MAAM,OAAqB;EAClC,MAAM,EAAE,MAAM,OAAO,WAAW,MAAM;EACtC,MAAM,UAAU,SAAS,MAAM,GAAG;EAClC,MAAM,UAAU,KAAK,MAAM,MAAM,QAAQ,EAAE,IAAI,KAAK,MAAM,MAAM,UAAU,EAAE;EAC5E,QAAQ,WAAW,aAAa,MAAM,OAAO,GAAG,OAAO,QAAQ;GAC7D;GACA,OAAO,UAAU;GACjB,QAAQ,QAAQ,QAAQ,IAAI;EAC9B,CAAC;CACH;CAEA,OAAO;EACL,IAAI,OAAO,aAAa,YAAY;GAClC,MAAM,QAAQ,cAAc;GAC5B,IAAI,SAAS,UAAU,OAAO,QAAQ,QAAQ;QACzC;IACH,IAAI,SAAS,MAAM,OAAO;IAC1B,UAAU;KAAE;KAAO,SAAS;KAAa;IAAM;GACjD;GACA,OAAO,QAAQ,QAAQ;EACzB;EACA,SAAS;GACP,IAAI,SAAS,MAAM,OAAO;GAC1B,UAAU;GACV,QAAQ,OAAO;GACf,OAAO,QAAQ,QAAQ,QAAQ,MAAM,CAAC;EACxC;EACA,SAAS;GACP,UAAU;GACV,OAAO,QAAQ,QAAQ;EACzB;EACA,IAAI,aAAa;GACf,OAAO,QAAQ,UAAU,CAAC,CAAC;EAC7B;CACF;AACF"}
@@ -0,0 +1,9 @@
1
+ import { crossfade, dim, drawOver, filledImage } from "./composite.js";
2
+ import { VIDEO_FORMATS, VIDEO_MIME_TYPES, VideoFormat, VideoSink, VideoSinkOptions } from "./sink.js";
3
+ import { VIDEO_FORMAT_LABELS, VideoFormatError, VideoHostEncoder, canRecordFormat, openVideoSink, recordableFormats } from "./formats.js";
4
+ import { MAX_GIF_FPS, createGIFSink } from "./gif.js";
5
+ import { RecordOptions, RecordResult, RenderFrame, recordPrototype } from "./record.js";
6
+ import { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from "./size.js";
7
+ import { EncodedVideoFormat, canRecordVideo, createWebCodecsSink } from "./webcodecs.js";
8
+ import { DEFAULT_VIDEO_TAIL_MS, MAX_GIF_EDGE, PrototypeVideoOptions, PrototypeVideoPlan, VIDEO_DEFAULTS, exportedFrameRenderer, planPrototypeVideo, recordPrototypeVideo } from "./plan.js";
9
+ export { DEFAULT_VIDEO_TAIL_MS, type EncodedVideoFormat, MAX_GIF_EDGE, MAX_GIF_FPS, MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, type PrototypeVideoOptions, type PrototypeVideoPlan, type RecordOptions, type RecordResult, type RenderFrame, VIDEO_DEFAULTS, VIDEO_FORMATS, VIDEO_FORMAT_LABELS, VIDEO_MIME_TYPES, type VideoFormat, VideoFormatError, type VideoHostEncoder, type VideoSink, type VideoSinkOptions, canRecordFormat, canRecordVideo, createGIFSink, createWebCodecsSink, crossfade, dim, drawOver, exportedFrameRenderer, filledImage, openVideoSink, planPrototypeVideo, recordPrototype, recordPrototypeVideo, recordableFormats, videoSize };
@@ -0,0 +1,9 @@
1
+ import { crossfade, dim, drawOver, filledImage } from "./composite.js";
2
+ import { MAX_GIF_FPS, createGIFSink } from "./gif.js";
3
+ import { VIDEO_FORMATS, VIDEO_MIME_TYPES } from "./sink.js";
4
+ import { canRecordVideo, createWebCodecsSink } from "./webcodecs.js";
5
+ import { VIDEO_FORMAT_LABELS, VideoFormatError, canRecordFormat, openVideoSink, recordableFormats } from "./formats.js";
6
+ import { recordPrototype } from "./record.js";
7
+ import { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from "./size.js";
8
+ import { DEFAULT_VIDEO_TAIL_MS, MAX_GIF_EDGE, VIDEO_DEFAULTS, exportedFrameRenderer, planPrototypeVideo, recordPrototypeVideo } from "./plan.js";
9
+ export { DEFAULT_VIDEO_TAIL_MS, MAX_GIF_EDGE, MAX_GIF_FPS, MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, VIDEO_DEFAULTS, VIDEO_FORMATS, VIDEO_FORMAT_LABELS, VIDEO_MIME_TYPES, VideoFormatError, canRecordFormat, canRecordVideo, createGIFSink, createWebCodecsSink, crossfade, dim, drawOver, exportedFrameRenderer, filledImage, openVideoSink, planPrototypeVideo, recordPrototype, recordPrototypeVideo, recordableFormats, videoSize };
@@ -0,0 +1,64 @@
1
+ import { RasterCodec } from "../raster/pixels.js";
2
+ import "../raster/index.js";
3
+ import { VideoFormat } from "./sink.js";
4
+ import { VideoHostEncoder } from "./formats.js";
5
+ import { Timeline, TimelineClick } from "../../../prototype/timeline.js";
6
+ import "../../../prototype/index.js";
7
+ import { RecordResult, RenderFrame } from "./record.js";
8
+ import { SceneGraph } from "@pairdraw/scene-graph";
9
+ //#region src/io/formats/video/plan.d.ts
10
+ /**
11
+ * The longest edge a GIF may have. Every GIF frame is quantized on its own and a held screen is
12
+ * stored whole, so a larger GIF costs far more memory and time than it is worth.
13
+ */
14
+ declare const MAX_GIF_EDGE = 960;
15
+ /** Frame rates and long edges each format records at unless asked otherwise. */
16
+ declare const VIDEO_DEFAULTS: Record<VideoFormat, {
17
+ fps: number;
18
+ maxEdge: number;
19
+ }>;
20
+ /** How long the last screen stays when the flow ends, unless asked otherwise. */
21
+ declare const DEFAULT_VIDEO_TAIL_MS = 1000;
22
+ interface PrototypeVideoOptions {
23
+ startFrameId: string;
24
+ format: VideoFormat;
25
+ /** The start frame's size in the video, before `maxEdge` fits it. */
26
+ scale: number;
27
+ maxEdge?: number;
28
+ fps?: number;
29
+ maxMs: number;
30
+ tailMs?: number;
31
+ clicks?: readonly TimelineClick[];
32
+ }
33
+ /** What a recording will hold: the planned timeline, and the video's size and frame rate. */
34
+ interface PrototypeVideoPlan {
35
+ format: VideoFormat;
36
+ timeline: Timeline;
37
+ width: number;
38
+ height: number;
39
+ fps: number;
40
+ }
41
+ /**
42
+ * Plans a recording of the prototype from `startFrameId`: its timeline, and a size fitted from the
43
+ * start frame (even for MP4 and WebM). Throws a `TimelineError` naming what cannot be played.
44
+ */
45
+ declare function planPrototypeVideo(graph: SceneGraph, options: PrototypeVideoOptions): PrototypeVideoPlan;
46
+ /**
47
+ * Records a planned video with `render` drawing its frames. Throws a `VideoFormatError` when this
48
+ * engine cannot encode the format, and stops at `MAX_VIDEO_BYTES` or when `signal` aborts.
49
+ */
50
+ declare function recordPrototypeVideo(graph: SceneGraph, plan: PrototypeVideoPlan, render: RenderFrame, options?: {
51
+ signal?: AbortSignal;
52
+ onProgress?: (done: number, total: number) => void;
53
+ /** The host's encoder for what WebCodecs cannot encode there, such as the CLI's ffmpeg. */
54
+ host?: VideoHostEncoder | null;
55
+ }): Promise<RecordResult>;
56
+ /**
57
+ * Draws frames through a host's raster export, as PNG, and decodes them to pixels; the app and the
58
+ * CLI each export through their own renderer. `graph`, when given, is a Smart animate's posed copy
59
+ * to draw the frame from instead of the document.
60
+ */
61
+ declare function exportedFrameRenderer(exportPNG: (frameId: string, scale: number, graph?: SceneGraph) => Promise<Uint8Array | null>, codec: RasterCodec): RenderFrame;
62
+ //#endregion
63
+ export { DEFAULT_VIDEO_TAIL_MS, MAX_GIF_EDGE, PrototypeVideoOptions, PrototypeVideoPlan, VIDEO_DEFAULTS, exportedFrameRenderer, planPrototypeVideo, recordPrototypeVideo };
64
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","names":[],"sources":["../../../../src/io/formats/video/plan.ts"],"mappings":";;;;;;;;;;;;;cAca;;cAGA,gBAAgB,OAAO;EAAe;EAAa;;;cAOnD;UAEI;EACf;EACA,QAAQ;;EAER;EACA;EACA;EACA;EACA;EACA,kBAAkB;;;UAIH;EACf,QAAQ;EACR,UAAU;EACV;EACA;EACA;;;;;;iBAOc,mBACd,OAAO,YACP,SAAS,wBACR;;;;;iBAyBmB,qBACpB,OAAO,YACP,MAAM,oBACN,QAAQ,aACR;EACE,SAAS;EACT,cAAc,cAAc;;EAE5B,OAAO;IAER,QAAQ;;;;;;iBAkBK,sBACd,YAAY,iBAAiB,eAAe,QAAQ,eAAe,QAAQ,oBAC3E,OAAO,cACN"}
@@ -0,0 +1,90 @@
1
+ import { TimelineError, planTimeline } from "../../../prototype/timeline.js";
2
+ import { openVideoSink } from "./formats.js";
3
+ import { recordPrototype } from "./record.js";
4
+ import { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from "./size.js";
5
+ //#region src/io/formats/video/plan.ts
6
+ /**
7
+ * The longest edge a GIF may have. Every GIF frame is quantized on its own and a held screen is
8
+ * stored whole, so a larger GIF costs far more memory and time than it is worth.
9
+ */
10
+ const MAX_GIF_EDGE = 960;
11
+ /** Frame rates and long edges each format records at unless asked otherwise. */
12
+ const VIDEO_DEFAULTS = {
13
+ mp4: {
14
+ fps: 30,
15
+ maxEdge: 1920
16
+ },
17
+ gif: {
18
+ fps: 15,
19
+ maxEdge: 960
20
+ },
21
+ webm: {
22
+ fps: 30,
23
+ maxEdge: 1920
24
+ }
25
+ };
26
+ /** How long the last screen stays when the flow ends, unless asked otherwise. */
27
+ const DEFAULT_VIDEO_TAIL_MS = 1e3;
28
+ /**
29
+ * Plans a recording of the prototype from `startFrameId`: its timeline, and a size fitted from the
30
+ * start frame (even for MP4 and WebM). Throws a `TimelineError` naming what cannot be played.
31
+ */
32
+ function planPrototypeVideo(graph, options) {
33
+ const start = graph.getNode(options.startFrameId);
34
+ if (!start) throw new TimelineError(`No frame with ID '${options.startFrameId}'`);
35
+ const timeline = planTimeline(graph, {
36
+ startFrameId: start.id,
37
+ clicks: options.clicks,
38
+ maxMs: options.maxMs,
39
+ tailMs: options.tailMs ?? 1e3
40
+ });
41
+ const defaults = VIDEO_DEFAULTS[options.format];
42
+ const { width, height } = videoSize(start.width, start.height, {
43
+ scale: options.scale,
44
+ maxEdge: Math.min(options.maxEdge ?? defaults.maxEdge, options.format === "gif" ? 960 : MAX_VIDEO_EDGE),
45
+ even: options.format !== "gif"
46
+ });
47
+ return {
48
+ format: options.format,
49
+ timeline,
50
+ width,
51
+ height,
52
+ fps: options.fps ?? defaults.fps
53
+ };
54
+ }
55
+ /**
56
+ * Records a planned video with `render` drawing its frames. Throws a `VideoFormatError` when this
57
+ * engine cannot encode the format, and stops at `MAX_VIDEO_BYTES` or when `signal` aborts.
58
+ */
59
+ async function recordPrototypeVideo(graph, plan, render, options = {}) {
60
+ const { width, height, fps, timeline } = plan;
61
+ const { host, ...progress } = options;
62
+ const sink = await openVideoSink(plan.format, {
63
+ width,
64
+ height,
65
+ fps,
66
+ loops: timeline.loops
67
+ }, host);
68
+ return recordPrototype(graph, timeline, render, sink, {
69
+ width,
70
+ height,
71
+ fps,
72
+ maxBytes: MAX_VIDEO_BYTES,
73
+ ...progress
74
+ });
75
+ }
76
+ /**
77
+ * Draws frames through a host's raster export, as PNG, and decodes them to pixels; the app and the
78
+ * CLI each export through their own renderer. `graph`, when given, is a Smart animate's posed copy
79
+ * to draw the frame from instead of the document.
80
+ */
81
+ function exportedFrameRenderer(exportPNG, codec) {
82
+ return async (frameId, scale, graph) => {
83
+ const png = await exportPNG(frameId, scale, graph);
84
+ return png ? codec.decode(png) : null;
85
+ };
86
+ }
87
+ //#endregion
88
+ export { DEFAULT_VIDEO_TAIL_MS, MAX_GIF_EDGE, VIDEO_DEFAULTS, exportedFrameRenderer, planPrototypeVideo, recordPrototypeVideo };
89
+
90
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","names":[],"sources":["../../../../src/io/formats/video/plan.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport type { RasterCodec } from '#core/io/formats/raster'\nimport { planTimeline, TimelineError, type Timeline, type TimelineClick } from '#core/prototype'\n\nimport { openVideoSink, type VideoHostEncoder } from './formats'\nimport { recordPrototype, type RecordResult, type RenderFrame } from './record'\nimport type { VideoFormat } from './sink'\nimport { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from './size'\n\n/**\n * The longest edge a GIF may have. Every GIF frame is quantized on its own and a held screen is\n * stored whole, so a larger GIF costs far more memory and time than it is worth.\n */\nexport const MAX_GIF_EDGE = 960\n\n/** Frame rates and long edges each format records at unless asked otherwise. */\nexport const VIDEO_DEFAULTS: Record<VideoFormat, { fps: number; maxEdge: number }> = {\n mp4: { fps: 30, maxEdge: 1920 },\n gif: { fps: 15, maxEdge: MAX_GIF_EDGE },\n webm: { fps: 30, maxEdge: 1920 }\n}\n\n/** How long the last screen stays when the flow ends, unless asked otherwise. */\nexport const DEFAULT_VIDEO_TAIL_MS = 1000\n\nexport interface PrototypeVideoOptions {\n startFrameId: string\n format: VideoFormat\n /** The start frame's size in the video, before `maxEdge` fits it. */\n scale: number\n maxEdge?: number\n fps?: number\n maxMs: number\n tailMs?: number\n clicks?: readonly TimelineClick[]\n}\n\n/** What a recording will hold: the planned timeline, and the video's size and frame rate. */\nexport interface PrototypeVideoPlan {\n format: VideoFormat\n timeline: Timeline\n width: number\n height: number\n fps: number\n}\n\n/**\n * Plans a recording of the prototype from `startFrameId`: its timeline, and a size fitted from the\n * start frame (even for MP4 and WebM). Throws a `TimelineError` naming what cannot be played.\n */\nexport function planPrototypeVideo(\n graph: SceneGraph,\n options: PrototypeVideoOptions\n): PrototypeVideoPlan {\n const start = graph.getNode(options.startFrameId)\n if (!start) throw new TimelineError(`No frame with ID '${options.startFrameId}'`)\n const timeline = planTimeline(graph, {\n startFrameId: start.id,\n clicks: options.clicks,\n maxMs: options.maxMs,\n tailMs: options.tailMs ?? DEFAULT_VIDEO_TAIL_MS\n })\n const defaults = VIDEO_DEFAULTS[options.format]\n const { width, height } = videoSize(start.width, start.height, {\n scale: options.scale,\n maxEdge: Math.min(\n options.maxEdge ?? defaults.maxEdge,\n options.format === 'gif' ? MAX_GIF_EDGE : MAX_VIDEO_EDGE\n ),\n even: options.format !== 'gif'\n })\n return { format: options.format, timeline, width, height, fps: options.fps ?? defaults.fps }\n}\n\n/**\n * Records a planned video with `render` drawing its frames. Throws a `VideoFormatError` when this\n * engine cannot encode the format, and stops at `MAX_VIDEO_BYTES` or when `signal` aborts.\n */\nexport async function recordPrototypeVideo(\n graph: SceneGraph,\n plan: PrototypeVideoPlan,\n render: RenderFrame,\n options: {\n signal?: AbortSignal\n onProgress?: (done: number, total: number) => void\n /** The host's encoder for what WebCodecs cannot encode there, such as the CLI's ffmpeg. */\n host?: VideoHostEncoder | null\n } = {}\n): Promise<RecordResult> {\n const { width, height, fps, timeline } = plan\n const { host, ...progress } = options\n const sink = await openVideoSink(plan.format, { width, height, fps, loops: timeline.loops }, host)\n return recordPrototype(graph, timeline, render, sink, {\n width,\n height,\n fps,\n maxBytes: MAX_VIDEO_BYTES,\n ...progress\n })\n}\n\n/**\n * Draws frames through a host's raster export, as PNG, and decodes them to pixels; the app and the\n * CLI each export through their own renderer. `graph`, when given, is a Smart animate's posed copy\n * to draw the frame from instead of the document.\n */\nexport function exportedFrameRenderer(\n exportPNG: (frameId: string, scale: number, graph?: SceneGraph) => Promise<Uint8Array | null>,\n codec: RasterCodec\n): RenderFrame {\n return async (frameId, scale, graph) => {\n const png = await exportPNG(frameId, scale, graph)\n return png ? codec.decode(png) : null\n }\n}\n"],"mappings":";;;;;;;;;AAcA,MAAa,eAAe;;AAG5B,MAAa,iBAAwE;CACnF,KAAK;EAAE,KAAK;EAAI,SAAS;CAAK;CAC9B,KAAK;EAAE,KAAK;EAAI,SAAA;CAAsB;CACtC,MAAM;EAAE,KAAK;EAAI,SAAS;CAAK;AACjC;;AAGA,MAAa,wBAAwB;;;;;AA2BrC,SAAgB,mBACd,OACA,SACoB;CACpB,MAAM,QAAQ,MAAM,QAAQ,QAAQ,YAAY;CAChD,IAAI,CAAC,OAAO,MAAM,IAAI,cAAc,qBAAqB,QAAQ,aAAa,EAAE;CAChF,MAAM,WAAW,aAAa,OAAO;EACnC,cAAc,MAAM;EACpB,QAAQ,QAAQ;EAChB,OAAO,QAAQ;EACf,QAAQ,QAAQ,UAAA;CAClB,CAAC;CACD,MAAM,WAAW,eAAe,QAAQ;CACxC,MAAM,EAAE,OAAO,WAAW,UAAU,MAAM,OAAO,MAAM,QAAQ;EAC7D,OAAO,QAAQ;EACf,SAAS,KAAK,IACZ,QAAQ,WAAW,SAAS,SAC5B,QAAQ,WAAW,QAAA,MAAuB,cAC5C;EACA,MAAM,QAAQ,WAAW;CAC3B,CAAC;CACD,OAAO;EAAE,QAAQ,QAAQ;EAAQ;EAAU;EAAO;EAAQ,KAAK,QAAQ,OAAO,SAAS;CAAI;AAC7F;;;;;AAMA,eAAsB,qBACpB,OACA,MACA,QACA,UAKI,CAAC,GACkB;CACvB,MAAM,EAAE,OAAO,QAAQ,KAAK,aAAa;CACzC,MAAM,EAAE,MAAM,GAAG,aAAa;CAC9B,MAAM,OAAO,MAAM,cAAc,KAAK,QAAQ;EAAE;EAAO;EAAQ;EAAK,OAAO,SAAS;CAAM,GAAG,IAAI;CACjG,OAAO,gBAAgB,OAAO,UAAU,QAAQ,MAAM;EACpD;EACA;EACA;EACA,UAAU;EACV,GAAG;CACL,CAAC;AACH;;;;;;AAOA,SAAgB,sBACd,WACA,OACa;CACb,OAAO,OAAO,SAAS,OAAO,UAAU;EACtC,MAAM,MAAM,MAAM,UAAU,SAAS,OAAO,KAAK;EACjD,OAAO,MAAM,MAAM,OAAO,GAAG,IAAI;CACnC;AACF"}
@@ -0,0 +1,36 @@
1
+ import { RGBAImage } from "../raster/pixels.js";
2
+ import "../raster/index.js";
3
+ import { VideoSink } from "./sink.js";
4
+ import { Timeline } from "../../../prototype/timeline.js";
5
+ import "../../../prototype/index.js";
6
+ import { SceneGraph } from "@pairdraw/scene-graph";
7
+ //#region src/io/formats/video/record.d.ts
8
+ /**
9
+ * Draws one top-level frame at `scale` as pixels, or null when it cannot be drawn: from the
10
+ * document, or from `graph`, a Smart animate's copy of the frame posed at one moment.
11
+ */
12
+ type RenderFrame = (frameId: string, scale: number, graph?: SceneGraph) => Promise<RGBAImage | null>;
13
+ interface RecordOptions {
14
+ width: number;
15
+ height: number;
16
+ fps: number;
17
+ signal?: AbortSignal;
18
+ onProgress?: (done: number, total: number) => void;
19
+ /** The most bytes the file may grow to before recording stops. */
20
+ maxBytes?: number;
21
+ }
22
+ interface RecordResult {
23
+ bytes: Uint8Array;
24
+ frameCount: number;
25
+ }
26
+ /**
27
+ * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen
28
+ * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a
29
+ * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at
30
+ * each frame, as the player poses it. Cancelling through `signal` stops before the next
31
+ * frame, and passing `maxBytes` stops with an error naming the limit.
32
+ */
33
+ declare function recordPrototype(graph: SceneGraph, timeline: Timeline, render: RenderFrame, sink: VideoSink, options: RecordOptions): Promise<RecordResult>;
34
+ //#endregion
35
+ export { RecordOptions, RecordResult, RenderFrame, recordPrototype };
36
+ //# sourceMappingURL=record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.d.ts","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"mappings":";;;;;;;;;;;KAuBY,eACV,iBACA,eACA,QAAQ,eACL,QAAQ;UAEI;EACf;EACA;EACA;EACA,SAAS;EACT,cAAc,cAAc;;EAE5B;;UAGe;EACf,OAAO;EACP;;;;;;;;;iBAkJoB,gBACpB,OAAO,YACP,UAAU,UACV,QAAQ,aACR,MAAM,WACN,SAAS,gBACR,QAAQ"}
@@ -0,0 +1,154 @@
1
+ import { getPageColor } from "../../../figma-api/page-backgrounds.js";
2
+ import { computeContentBounds } from "../raster/render.js";
3
+ import { shownFrame } from "../../../prototype/session.js";
4
+ import { createSmartAnimation } from "../../../prototype/smart-animate/animation.js";
5
+ import { frameAt, sessionDrawKey } from "../../../prototype/timeline.js";
6
+ import { crossfade, dim, drawOver, filledImage } from "./composite.js";
7
+ //#region src/io/formats/video/record.ts
8
+ /** How dark the screen under an open overlay is drawn, as the player's scrim. */
9
+ const OVERLAY_SCRIM = .4;
10
+ /** Screens kept drawn at once: the two of a crossfade and the one after it. */
11
+ const CACHED_SCREENS = 3;
12
+ /** Frames recorded between yields to the event loop, so the app keeps drawing. */
13
+ const FRAMES_PER_YIELD = 4;
14
+ /** Where an overlay starts along one axis of the screen: its start, its end, or centred. */
15
+ function alignOnAxis(start, size, overlay, edge) {
16
+ if (edge === "TOP" || edge === "LEFT") return start;
17
+ if (edge === "BOTTOM" || edge === "RIGHT") return start + size - overlay;
18
+ return start + (size - overlay) / 2;
19
+ }
20
+ /** Where an overlay of `width`×`height` sits on the screen `base`, as Figma positions overlays. */
21
+ function overlayOrigin(base, width, height, position) {
22
+ const [vertical, horizontal] = position === "CENTER" ? ["CENTER", "CENTER"] : position.split("_");
23
+ return {
24
+ x: alignOnAxis(base.x, base.width, width, horizontal),
25
+ y: alignOnAxis(base.y, base.height, height, vertical)
26
+ };
27
+ }
28
+ function pageOf(graph, frameId) {
29
+ const parentId = graph.getNode(frameId)?.parentId;
30
+ return parentId ? graph.getNode(parentId) : void 0;
31
+ }
32
+ /**
33
+ * Draws the screens a timeline shows, each composited once onto a `width`×`height` canvas the
34
+ * color of the page, the base frame fitted and centred as the player fits it, overlays over a scrim.
35
+ */
36
+ function createScreens(graph, timeline, render, width, height) {
37
+ const firstSegment = timeline.segments.at(0);
38
+ const startId = firstSegment?.kind === "hold" ? firstSegment.session.frameId : null;
39
+ const background = getPageColor(startId ? pageOf(graph, startId) : void 0);
40
+ const cache = /* @__PURE__ */ new Map();
41
+ async function drawFrame(target, frameId, scale, at, source = graph) {
42
+ const image = await render(frameId, scale, source === graph ? void 0 : source);
43
+ const node = source.getNode(frameId);
44
+ if (!image || !node) throw new Error(`'${node?.name ?? frameId}' could not be drawn`);
45
+ const box = source.getAbsoluteBounds(frameId);
46
+ const content = computeContentBounds(source, [frameId]) ?? {
47
+ minX: box.x,
48
+ minY: box.y,
49
+ maxX: box.x + box.width,
50
+ maxY: box.y + box.height
51
+ };
52
+ drawOver(target, image, Math.round(at.x + (content.minX - box.x) * scale), Math.round(at.y + (content.minY - box.y) * scale));
53
+ }
54
+ /** The screen `session` shows, its base frame drawn from `base` when given. */
55
+ async function compose(session, base) {
56
+ const target = filledImage(width, height, background);
57
+ const box = graph.getAbsoluteBounds(session.frameId);
58
+ const scale = Math.min(width / box.width, height / box.height);
59
+ const fitted = {
60
+ x: (width - box.width * scale) / 2,
61
+ y: (height - box.height * scale) / 2,
62
+ width: box.width * scale,
63
+ height: box.height * scale
64
+ };
65
+ await drawFrame(target, session.frameId, scale, fitted, base);
66
+ if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM);
67
+ for (const overlayId of session.overlays) {
68
+ const overlay = graph.getAbsoluteBounds(overlayId);
69
+ await drawFrame(target, overlayId, scale, overlayOrigin(fitted, overlay.width * scale, overlay.height * scale, timeline.overlayPositions[overlayId] ?? "CENTER"));
70
+ }
71
+ return target;
72
+ }
73
+ let animating = null;
74
+ /** A Smart animate `progress` of the way through its time, drawn from its posed copy. */
75
+ async function animated(segment, progress) {
76
+ if (animating?.segment !== segment) {
77
+ const from = {
78
+ graph,
79
+ rootId: shownFrame(segment.from)
80
+ };
81
+ const to = {
82
+ graph,
83
+ rootId: segment.to.frameId
84
+ };
85
+ animating = {
86
+ segment,
87
+ animation: createSmartAnimation(from, to, segment.easing)
88
+ };
89
+ }
90
+ animating.animation.seek(progress);
91
+ return compose(segment.to, animating.animation.graph);
92
+ }
93
+ async function screen(session) {
94
+ const key = sessionDrawKey(session);
95
+ const cached = cache.get(key);
96
+ if (cached) {
97
+ cache.delete(key);
98
+ cache.set(key, cached);
99
+ return cached;
100
+ }
101
+ const drawn = await compose(session);
102
+ cache.set(key, drawn);
103
+ for (const old of cache.keys()) {
104
+ if (cache.size <= CACHED_SCREENS) break;
105
+ cache.delete(old);
106
+ }
107
+ return drawn;
108
+ }
109
+ return {
110
+ screen,
111
+ animated
112
+ };
113
+ }
114
+ /**
115
+ * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen
116
+ * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a
117
+ * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at
118
+ * each frame, as the player poses it. Cancelling through `signal` stops before the next
119
+ * frame, and passing `maxBytes` stops with an error naming the limit.
120
+ */
121
+ async function recordPrototype(graph, timeline, render, sink, options) {
122
+ const { screen, animated } = createScreens(graph, timeline, render, options.width, options.height);
123
+ const frameMs = 1e3 / options.fps;
124
+ const frameCount = Math.max(1, Math.round(timeline.durationMs / frameMs));
125
+ try {
126
+ for (let index = 0; index < frameCount; index++) {
127
+ options.signal?.throwIfAborted();
128
+ const last = index === frameCount - 1 && !timeline.loops;
129
+ const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs);
130
+ let image;
131
+ if ("session" in shown) image = await screen(shown.session);
132
+ else if ("smart" in shown) image = await animated(shown.smart, shown.progress);
133
+ else image = crossfade(await screen(shown.from), await screen(shown.to), shown.mix);
134
+ await sink.add(image, index * frameMs, frameMs);
135
+ if (options.maxBytes !== void 0 && sink.byteLength > options.maxBytes) throw new Error(`The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`);
136
+ options.onProgress?.(index + 1, frameCount);
137
+ if ((index + 1) % FRAMES_PER_YIELD === 0) await new Promise((resolve) => {
138
+ setTimeout(resolve, 0);
139
+ });
140
+ }
141
+ options.signal?.throwIfAborted();
142
+ return {
143
+ bytes: await sink.finish(),
144
+ frameCount
145
+ };
146
+ } catch (error) {
147
+ await sink.cancel();
148
+ throw error;
149
+ }
150
+ }
151
+ //#endregion
152
+ export { recordPrototype };
153
+
154
+ //# sourceMappingURL=record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record.js","names":[],"sources":["../../../../src/io/formats/video/record.ts"],"sourcesContent":["import type { PrototypeOverlayPositionType, SceneGraph } from '@pairdraw/scene-graph'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { getPageColor } from '#core/figma-api/page-backgrounds'\nimport { computeContentBounds, type RGBAImage } from '#core/io/formats/raster'\nimport {\n createSmartAnimation,\n frameAt,\n sessionDrawKey,\n shownFrame,\n type PlaySession,\n type SmartAnimation,\n type Timeline,\n type TimelineSmartSegment\n} from '#core/prototype'\n\nimport { crossfade, dim, drawOver, filledImage } from './composite'\nimport type { VideoSink } from './sink'\n\n/**\n * Draws one top-level frame at `scale` as pixels, or null when it cannot be drawn: from the\n * document, or from `graph`, a Smart animate's copy of the frame posed at one moment.\n */\nexport type RenderFrame = (\n frameId: string,\n scale: number,\n graph?: SceneGraph\n) => Promise<RGBAImage | null>\n\nexport interface RecordOptions {\n width: number\n height: number\n fps: number\n signal?: AbortSignal\n onProgress?: (done: number, total: number) => void\n /** The most bytes the file may grow to before recording stops. */\n maxBytes?: number\n}\n\nexport interface RecordResult {\n bytes: Uint8Array\n frameCount: number\n}\n\n/** How dark the screen under an open overlay is drawn, as the player's scrim. */\nconst OVERLAY_SCRIM = 0.4\n/** Screens kept drawn at once: the two of a crossfade and the one after it. */\nconst CACHED_SCREENS = 3\n/** Frames recorded between yields to the event loop, so the app keeps drawing. */\nconst FRAMES_PER_YIELD = 4\n\n/** Where an overlay starts along one axis of the screen: its start, its end, or centred. */\nfunction alignOnAxis(start: number, size: number, overlay: number, edge: string): number {\n if (edge === 'TOP' || edge === 'LEFT') return start\n if (edge === 'BOTTOM' || edge === 'RIGHT') return start + size - overlay\n return start + (size - overlay) / 2\n}\n\n/** Where an overlay of `width`×`height` sits on the screen `base`, as Figma positions overlays. */\nfunction overlayOrigin(\n base: Rect,\n width: number,\n height: number,\n position: PrototypeOverlayPositionType\n): Vector {\n const [vertical, horizontal] = position === 'CENTER' ? ['CENTER', 'CENTER'] : position.split('_')\n return {\n x: alignOnAxis(base.x, base.width, width, horizontal),\n y: alignOnAxis(base.y, base.height, height, vertical)\n }\n}\n\nfunction pageOf(graph: SceneGraph, frameId: string) {\n const parentId = graph.getNode(frameId)?.parentId\n return parentId ? graph.getNode(parentId) : undefined\n}\n\n/**\n * Draws the screens a timeline shows, each composited once onto a `width`×`height` canvas the\n * color of the page, the base frame fitted and centred as the player fits it, overlays over a scrim.\n */\nfunction createScreens(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n width: number,\n height: number\n) {\n const firstSegment = timeline.segments.at(0)\n const startId = firstSegment?.kind === 'hold' ? firstSegment.session.frameId : null\n const background = getPageColor(startId ? pageOf(graph, startId) : undefined)\n const cache = new Map<string, RGBAImage>()\n\n async function drawFrame(\n target: RGBAImage,\n frameId: string,\n scale: number,\n at: Vector,\n source = graph\n ) {\n const image = await render(frameId, scale, source === graph ? undefined : source)\n const node = source.getNode(frameId)\n if (!image || !node) throw new Error(`'${node?.name ?? frameId}' could not be drawn`)\n const box = source.getAbsoluteBounds(frameId)\n // A shadow or a layer past the frame's edge widens what is drawn; the frame stays in place.\n const content = computeContentBounds(source, [frameId]) ?? {\n minX: box.x,\n minY: box.y,\n maxX: box.x + box.width,\n maxY: box.y + box.height\n }\n drawOver(\n target,\n image,\n Math.round(at.x + (content.minX - box.x) * scale),\n Math.round(at.y + (content.minY - box.y) * scale)\n )\n }\n\n /** The screen `session` shows, its base frame drawn from `base` when given. */\n async function compose(session: PlaySession, base?: SceneGraph): Promise<RGBAImage> {\n const target = filledImage(width, height, background)\n const box = graph.getAbsoluteBounds(session.frameId)\n const scale = Math.min(width / box.width, height / box.height)\n const fitted: Rect = {\n x: (width - box.width * scale) / 2,\n y: (height - box.height * scale) / 2,\n width: box.width * scale,\n height: box.height * scale\n }\n await drawFrame(target, session.frameId, scale, fitted, base)\n if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM)\n for (const overlayId of session.overlays) {\n const overlay = graph.getAbsoluteBounds(overlayId)\n const origin = overlayOrigin(\n fitted,\n overlay.width * scale,\n overlay.height * scale,\n timeline.overlayPositions[overlayId] ?? 'CENTER'\n )\n await drawFrame(target, overlayId, scale, origin)\n }\n return target\n }\n\n // The Smart animate being recorded, made once and posed for each of its frames.\n let animating: { segment: TimelineSmartSegment; animation: SmartAnimation } | null = null\n\n /** A Smart animate `progress` of the way through its time, drawn from its posed copy. */\n async function animated(segment: TimelineSmartSegment, progress: number): Promise<RGBAImage> {\n if (animating?.segment !== segment) {\n const from = { graph, rootId: shownFrame(segment.from) }\n const to = { graph, rootId: segment.to.frameId }\n animating = { segment, animation: createSmartAnimation(from, to, segment.easing) }\n }\n animating.animation.seek(progress)\n return compose(segment.to, animating.animation.graph)\n }\n\n async function screen(session: PlaySession): Promise<RGBAImage> {\n const key = sessionDrawKey(session)\n const cached = cache.get(key)\n if (cached) {\n // Most recently used last, so the oldest screen is the one dropped.\n cache.delete(key)\n cache.set(key, cached)\n return cached\n }\n const drawn = await compose(session)\n cache.set(key, drawn)\n for (const old of cache.keys()) {\n if (cache.size <= CACHED_SCREENS) break\n cache.delete(old)\n }\n return drawn\n }\n\n return { screen, animated }\n}\n\n/**\n * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen\n * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a\n * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at\n * each frame, as the player poses it. Cancelling through `signal` stops before the next\n * frame, and passing `maxBytes` stops with an error naming the limit.\n */\nexport async function recordPrototype(\n graph: SceneGraph,\n timeline: Timeline,\n render: RenderFrame,\n sink: VideoSink,\n options: RecordOptions\n): Promise<RecordResult> {\n const { screen, animated } = createScreens(graph, timeline, render, options.width, options.height)\n const frameMs = 1000 / options.fps\n const frameCount = Math.max(1, Math.round(timeline.durationMs / frameMs))\n try {\n for (let index = 0; index < frameCount; index++) {\n options.signal?.throwIfAborted()\n // A clip that does not loop ends on its last screen, even one the flow leaves no time.\n const last = index === frameCount - 1 && !timeline.loops\n const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs)\n let image: RGBAImage\n if ('session' in shown) image = await screen(shown.session)\n else if ('smart' in shown) image = await animated(shown.smart, shown.progress)\n else image = crossfade(await screen(shown.from), await screen(shown.to), shown.mix)\n await sink.add(image, index * frameMs, frameMs)\n if (options.maxBytes !== undefined && sink.byteLength > options.maxBytes) {\n throw new Error(\n `The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`\n )\n }\n options.onProgress?.(index + 1, frameCount)\n if ((index + 1) % FRAMES_PER_YIELD === 0) {\n await new Promise<void>((resolve) => {\n setTimeout(resolve, 0)\n })\n }\n }\n options.signal?.throwIfAborted()\n return { bytes: await sink.finish(), frameCount }\n } catch (error) {\n await sink.cancel()\n throw error\n }\n}\n"],"mappings":";;;;;;;;AA6CA,MAAM,gBAAgB;;AAEtB,MAAM,iBAAiB;;AAEvB,MAAM,mBAAmB;;AAGzB,SAAS,YAAY,OAAe,MAAc,SAAiB,MAAsB;CACvF,IAAI,SAAS,SAAS,SAAS,QAAQ,OAAO;CAC9C,IAAI,SAAS,YAAY,SAAS,SAAS,OAAO,QAAQ,OAAO;CACjE,OAAO,SAAS,OAAO,WAAW;AACpC;;AAGA,SAAS,cACP,MACA,OACA,QACA,UACQ;CACR,MAAM,CAAC,UAAU,cAAc,aAAa,WAAW,CAAC,UAAU,QAAQ,IAAI,SAAS,MAAM,GAAG;CAChG,OAAO;EACL,GAAG,YAAY,KAAK,GAAG,KAAK,OAAO,OAAO,UAAU;EACpD,GAAG,YAAY,KAAK,GAAG,KAAK,QAAQ,QAAQ,QAAQ;CACtD;AACF;AAEA,SAAS,OAAO,OAAmB,SAAiB;CAClD,MAAM,WAAW,MAAM,QAAQ,OAAO,CAAC,EAAE;CACzC,OAAO,WAAW,MAAM,QAAQ,QAAQ,IAAI,KAAA;AAC9C;;;;;AAMA,SAAS,cACP,OACA,UACA,QACA,OACA,QACA;CACA,MAAM,eAAe,SAAS,SAAS,GAAG,CAAC;CAC3C,MAAM,UAAU,cAAc,SAAS,SAAS,aAAa,QAAQ,UAAU;CAC/E,MAAM,aAAa,aAAa,UAAU,OAAO,OAAO,OAAO,IAAI,KAAA,CAAS;CAC5E,MAAM,wBAAQ,IAAI,IAAuB;CAEzC,eAAe,UACb,QACA,SACA,OACA,IACA,SAAS,OACT;EACA,MAAM,QAAQ,MAAM,OAAO,SAAS,OAAO,WAAW,QAAQ,KAAA,IAAY,MAAM;EAChF,MAAM,OAAO,OAAO,QAAQ,OAAO;EACnC,IAAI,CAAC,SAAS,CAAC,MAAM,MAAM,IAAI,MAAM,IAAI,MAAM,QAAQ,QAAQ,qBAAqB;EACpF,MAAM,MAAM,OAAO,kBAAkB,OAAO;EAE5C,MAAM,UAAU,qBAAqB,QAAQ,CAAC,OAAO,CAAC,KAAK;GACzD,MAAM,IAAI;GACV,MAAM,IAAI;GACV,MAAM,IAAI,IAAI,IAAI;GAClB,MAAM,IAAI,IAAI,IAAI;EACpB;EACA,SACE,QACA,OACA,KAAK,MAAM,GAAG,KAAK,QAAQ,OAAO,IAAI,KAAK,KAAK,GAChD,KAAK,MAAM,GAAG,KAAK,QAAQ,OAAO,IAAI,KAAK,KAAK,CAClD;CACF;;CAGA,eAAe,QAAQ,SAAsB,MAAuC;EAClF,MAAM,SAAS,YAAY,OAAO,QAAQ,UAAU;EACpD,MAAM,MAAM,MAAM,kBAAkB,QAAQ,OAAO;EACnD,MAAM,QAAQ,KAAK,IAAI,QAAQ,IAAI,OAAO,SAAS,IAAI,MAAM;EAC7D,MAAM,SAAe;GACnB,IAAI,QAAQ,IAAI,QAAQ,SAAS;GACjC,IAAI,SAAS,IAAI,SAAS,SAAS;GACnC,OAAO,IAAI,QAAQ;GACnB,QAAQ,IAAI,SAAS;EACvB;EACA,MAAM,UAAU,QAAQ,QAAQ,SAAS,OAAO,QAAQ,IAAI;EAC5D,IAAI,QAAQ,SAAS,SAAS,GAAG,IAAI,QAAQ,aAAa;EAC1D,KAAK,MAAM,aAAa,QAAQ,UAAU;GACxC,MAAM,UAAU,MAAM,kBAAkB,SAAS;GAOjD,MAAM,UAAU,QAAQ,WAAW,OANpB,cACb,QACA,QAAQ,QAAQ,OAChB,QAAQ,SAAS,OACjB,SAAS,iBAAiB,cAAc,QAEK,CAAC;EAClD;EACA,OAAO;CACT;CAGA,IAAI,YAAiF;;CAGrF,eAAe,SAAS,SAA+B,UAAsC;EAC3F,IAAI,WAAW,YAAY,SAAS;GAClC,MAAM,OAAO;IAAE;IAAO,QAAQ,WAAW,QAAQ,IAAI;GAAE;GACvD,MAAM,KAAK;IAAE;IAAO,QAAQ,QAAQ,GAAG;GAAQ;GAC/C,YAAY;IAAE;IAAS,WAAW,qBAAqB,MAAM,IAAI,QAAQ,MAAM;GAAE;EACnF;EACA,UAAU,UAAU,KAAK,QAAQ;EACjC,OAAO,QAAQ,QAAQ,IAAI,UAAU,UAAU,KAAK;CACtD;CAEA,eAAe,OAAO,SAA0C;EAC9D,MAAM,MAAM,eAAe,OAAO;EAClC,MAAM,SAAS,MAAM,IAAI,GAAG;EAC5B,IAAI,QAAQ;GAEV,MAAM,OAAO,GAAG;GAChB,MAAM,IAAI,KAAK,MAAM;GACrB,OAAO;EACT;EACA,MAAM,QAAQ,MAAM,QAAQ,OAAO;EACnC,MAAM,IAAI,KAAK,KAAK;EACpB,KAAK,MAAM,OAAO,MAAM,KAAK,GAAG;GAC9B,IAAI,MAAM,QAAQ,gBAAgB;GAClC,MAAM,OAAO,GAAG;EAClB;EACA,OAAO;CACT;CAEA,OAAO;EAAE;EAAQ;CAAS;AAC5B;;;;;;;;AASA,eAAsB,gBACpB,OACA,UACA,QACA,MACA,SACuB;CACvB,MAAM,EAAE,QAAQ,aAAa,cAAc,OAAO,UAAU,QAAQ,QAAQ,OAAO,QAAQ,MAAM;CACjG,MAAM,UAAU,MAAO,QAAQ;CAC/B,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,MAAM,SAAS,aAAa,OAAO,CAAC;CACxE,IAAI;EACF,KAAK,IAAI,QAAQ,GAAG,QAAQ,YAAY,SAAS;GAC/C,QAAQ,QAAQ,eAAe;GAE/B,MAAM,OAAO,UAAU,aAAa,KAAK,CAAC,SAAS;GACnD,MAAM,QAAQ,QAAQ,UAAU,OAAO,SAAS,aAAa,QAAQ,OAAO;GAC5E,IAAI;GACJ,IAAI,aAAa,OAAO,QAAQ,MAAM,OAAO,MAAM,OAAO;QACrD,IAAI,WAAW,OAAO,QAAQ,MAAM,SAAS,MAAM,OAAO,MAAM,QAAQ;QACxE,QAAQ,UAAU,MAAM,OAAO,MAAM,IAAI,GAAG,MAAM,OAAO,MAAM,EAAE,GAAG,MAAM,GAAG;GAClF,MAAM,KAAK,IAAI,OAAO,QAAQ,SAAS,OAAO;GAC9C,IAAI,QAAQ,aAAa,KAAA,KAAa,KAAK,aAAa,QAAQ,UAC9D,MAAM,IAAI,MACR,oBAAoB,KAAK,MAAM,QAAQ,WAAW,OAAO,IAAI,EAAE,kCACjE;GAEF,QAAQ,aAAa,QAAQ,GAAG,UAAU;GAC1C,KAAK,QAAQ,KAAK,qBAAqB,GACrC,MAAM,IAAI,SAAe,YAAY;IACnC,WAAW,SAAS,CAAC;GACvB,CAAC;EAEL;EACA,QAAQ,QAAQ,eAAe;EAC/B,OAAO;GAAE,OAAO,MAAM,KAAK,OAAO;GAAG;EAAW;CAClD,SAAS,OAAO;EACd,MAAM,KAAK,OAAO;EAClB,MAAM;CACR;AACF"}
@@ -0,0 +1,29 @@
1
+ import { RGBAImage } from "../raster/pixels.js";
2
+ import "../raster/index.js";
3
+ //#region src/io/formats/video/sink.d.ts
4
+ /** The video formats a prototype records to. */
5
+ declare const VIDEO_FORMATS: readonly ["mp4", "gif", "webm"];
6
+ type VideoFormat = (typeof VIDEO_FORMATS)[number];
7
+ declare const VIDEO_MIME_TYPES: Record<VideoFormat, string>;
8
+ interface VideoSinkOptions {
9
+ width: number;
10
+ height: number;
11
+ fps: number;
12
+ /** The clip ends where it started, so a GIF repeats forever. */
13
+ loops: boolean;
14
+ }
15
+ /**
16
+ * Where recorded frames go: an encoder that takes them in time order and returns the file. A
17
+ * frame passed again as the same image is the screen held still, which a format may store once.
18
+ */
19
+ interface VideoSink {
20
+ add(image: RGBAImage, timestampMs: number, durationMs: number): Promise<void>;
21
+ finish(): Promise<Uint8Array>;
22
+ /** Stops encoding without a file, releasing the encoder; recording calls it when it stops early. */
23
+ cancel(): Promise<void>;
24
+ /** Bytes encoded so far, which the recorder caps. */
25
+ readonly byteLength: number;
26
+ }
27
+ //#endregion
28
+ export { VIDEO_FORMATS, VIDEO_MIME_TYPES, VideoFormat, VideoSink, VideoSinkOptions };
29
+ //# sourceMappingURL=sink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sink.d.ts","names":[],"sources":["../../../../src/io/formats/video/sink.ts"],"mappings":";;;;cAGa;KACD,sBAAsB;cAErB,kBAAkB,OAAO;UAMrB;EACf;EACA;EACA;;EAEA;;;;;;UAOe;EACf,IAAI,OAAO,WAAW,qBAAqB,qBAAqB;EAChE,UAAU,QAAQ;;EAElB,UAAU;;WAED"}
@@ -0,0 +1,16 @@
1
+ //#region src/io/formats/video/sink.ts
2
+ /** The video formats a prototype records to. */
3
+ const VIDEO_FORMATS = [
4
+ "mp4",
5
+ "gif",
6
+ "webm"
7
+ ];
8
+ const VIDEO_MIME_TYPES = {
9
+ mp4: "video/mp4",
10
+ gif: "image/gif",
11
+ webm: "video/webm"
12
+ };
13
+ //#endregion
14
+ export { VIDEO_FORMATS, VIDEO_MIME_TYPES };
15
+
16
+ //# sourceMappingURL=sink.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sink.js","names":[],"sources":["../../../../src/io/formats/video/sink.ts"],"sourcesContent":["import type { RGBAImage } from '#core/io/formats/raster'\n\n/** The video formats a prototype records to. */\nexport const VIDEO_FORMATS = ['mp4', 'gif', 'webm'] as const\nexport type VideoFormat = (typeof VIDEO_FORMATS)[number]\n\nexport const VIDEO_MIME_TYPES: Record<VideoFormat, string> = {\n mp4: 'video/mp4',\n gif: 'image/gif',\n webm: 'video/webm'\n}\n\nexport interface VideoSinkOptions {\n width: number\n height: number\n fps: number\n /** The clip ends where it started, so a GIF repeats forever. */\n loops: boolean\n}\n\n/**\n * Where recorded frames go: an encoder that takes them in time order and returns the file. A\n * frame passed again as the same image is the screen held still, which a format may store once.\n */\nexport interface VideoSink {\n add(image: RGBAImage, timestampMs: number, durationMs: number): Promise<void>\n finish(): Promise<Uint8Array>\n /** Stops encoding without a file, releasing the encoder; recording calls it when it stops early. */\n cancel(): Promise<void>\n /** Bytes encoded so far, which the recorder caps. */\n readonly byteLength: number\n}\n"],"mappings":";;AAGA,MAAa,gBAAgB;CAAC;CAAO;CAAO;AAAM;AAGlD,MAAa,mBAAgD;CAC3D,KAAK;CACL,KAAK;CACL,MAAM;AACR"}
@@ -0,0 +1,19 @@
1
+ import { Size } from "@pairdraw/scene-graph/primitives";
2
+ //#region src/io/formats/video/size.d.ts
3
+ /** Bytes a recorded video may reach, as much as an MCP file transfer carries. */
4
+ declare const MAX_VIDEO_BYTES: number;
5
+ /** The longest edge a recorded video may have. */
6
+ declare const MAX_VIDEO_EDGE = 3840;
7
+ /**
8
+ * The pixel size of a video of a `width`×`height` frame at `scale`, its long edge fitted into
9
+ * `maxEdge` without upscaling past `scale`. `even` rounds both sides up to even numbers, which
10
+ * H.264 and VP9 need for their half-resolution color planes.
11
+ */
12
+ declare function videoSize(width: number, height: number, options: {
13
+ scale: number;
14
+ maxEdge: number;
15
+ even: boolean;
16
+ }): Size;
17
+ //#endregion
18
+ export { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize };
19
+ //# sourceMappingURL=size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size.d.ts","names":[],"sources":["../../../../src/io/formats/video/size.ts"],"mappings":";;;cAGa;;cAEA;;;;;;iBAOG,UACd,eACA,gBACA;EAAW;EAAe;EAAiB;IAC1C"}