@pairdraw/core 0.19.2 → 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 (847) 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/sampling.d.ts +13 -0
  20. package/dist/canvas/images/sampling.d.ts.map +1 -0
  21. package/dist/canvas/images/sampling.js +49 -0
  22. package/dist/canvas/images/sampling.js.map +1 -0
  23. package/dist/canvas/index.d.ts +2 -2
  24. package/dist/canvas/masks.d.ts +1 -1
  25. package/dist/canvas/masks.d.ts.map +1 -1
  26. package/dist/canvas/masks.js.map +1 -1
  27. package/dist/canvas/noise/render.d.ts +15 -0
  28. package/dist/canvas/noise/render.d.ts.map +1 -0
  29. package/dist/canvas/noise/render.js +56 -0
  30. package/dist/canvas/noise/render.js.map +1 -0
  31. package/dist/canvas/noise/shader.d.ts +43 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +161 -0
  34. package/dist/canvas/noise/shader.js.map +1 -0
  35. package/dist/canvas/noise/table.d.ts +13 -0
  36. package/dist/canvas/noise/table.d.ts.map +1 -0
  37. package/dist/canvas/noise/table.js +408 -0
  38. package/dist/canvas/noise/table.js.map +1 -0
  39. package/dist/canvas/noise/tile.d.ts +22 -0
  40. package/dist/canvas/noise/tile.d.ts.map +1 -0
  41. package/dist/canvas/noise/tile.js +73 -0
  42. package/dist/canvas/noise/tile.js.map +1 -0
  43. package/dist/canvas/outline-stroke.js +1 -1
  44. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  46. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  47. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  48. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  49. package/dist/canvas/renderer/lifecycle.js +6 -0
  50. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  51. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  52. package/dist/canvas/renderer/pipeline.js +13 -1
  53. package/dist/canvas/renderer/pipeline.js.map +1 -1
  54. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  55. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  56. package/dist/canvas/renderer/play-scenes.js +40 -0
  57. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  58. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  59. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  60. package/dist/canvas/renderer/tiles/cache.js +32 -1
  61. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  62. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  63. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  64. package/dist/canvas/renderer/tiles/controller.js +18 -1
  65. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  66. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  67. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  68. package/dist/canvas/renderer/types.d.ts +18 -3
  69. package/dist/canvas/renderer/types.d.ts.map +1 -1
  70. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  71. package/dist/canvas/renderer/visual-bounds.js +1 -1
  72. package/dist/canvas/renderer.d.ts +22 -2
  73. package/dist/canvas/renderer.d.ts.map +1 -1
  74. package/dist/canvas/renderer.js +29 -1
  75. package/dist/canvas/renderer.js.map +1 -1
  76. package/dist/canvas/scene.d.ts +2 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +41 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shadows/silhouette.js +1 -1
  81. package/dist/canvas/texture.d.ts +20 -0
  82. package/dist/canvas/texture.d.ts.map +1 -0
  83. package/dist/canvas/texture.js +100 -0
  84. package/dist/canvas/texture.js.map +1 -0
  85. package/dist/clipboard.js +16 -5
  86. package/dist/clipboard.js.map +1 -1
  87. package/dist/constants.d.ts +5 -1
  88. package/dist/constants.d.ts.map +1 -1
  89. package/dist/constants.js +5 -1
  90. package/dist/constants.js.map +1 -1
  91. package/dist/design-jsx/renderer.d.ts.map +1 -1
  92. package/dist/design-memory/check.d.ts +90 -0
  93. package/dist/design-memory/check.d.ts.map +1 -0
  94. package/dist/design-memory/check.js +281 -0
  95. package/dist/design-memory/check.js.map +1 -0
  96. package/dist/design-memory/describe.d.ts +37 -0
  97. package/dist/design-memory/describe.d.ts.map +1 -0
  98. package/dist/design-memory/describe.js +52 -0
  99. package/dist/design-memory/describe.js.map +1 -0
  100. package/dist/design-memory/distil.d.ts +22 -0
  101. package/dist/design-memory/distil.d.ts.map +1 -0
  102. package/dist/design-memory/distil.js +54 -0
  103. package/dist/design-memory/distil.js.map +1 -0
  104. package/dist/design-memory/document.d.ts +12 -0
  105. package/dist/design-memory/document.d.ts.map +1 -0
  106. package/dist/design-memory/document.js +64 -0
  107. package/dist/design-memory/document.js.map +1 -0
  108. package/dist/design-memory/guard.d.ts +48 -0
  109. package/dist/design-memory/guard.d.ts.map +1 -0
  110. package/dist/design-memory/guard.js +105 -0
  111. package/dist/design-memory/guard.js.map +1 -0
  112. package/dist/design-memory/index.d.ts +9 -0
  113. package/dist/design-memory/index.js +9 -0
  114. package/dist/design-memory/refusal.d.ts +32 -0
  115. package/dist/design-memory/refusal.d.ts.map +1 -0
  116. package/dist/design-memory/refusal.js +68 -0
  117. package/dist/design-memory/refusal.js.map +1 -0
  118. package/dist/design-memory/rules.d.ts +63 -0
  119. package/dist/design-memory/rules.d.ts.map +1 -0
  120. package/dist/design-memory/rules.js +224 -0
  121. package/dist/design-memory/rules.js.map +1 -0
  122. package/dist/design-memory/values.d.ts +28 -0
  123. package/dist/design-memory/values.d.ts.map +1 -0
  124. package/dist/design-memory/values.js +160 -0
  125. package/dist/design-memory/values.js.map +1 -0
  126. package/dist/editor/alignment.js +1 -1
  127. package/dist/editor/bridges/components.d.ts +2 -0
  128. package/dist/editor/bridges/components.d.ts.map +1 -1
  129. package/dist/editor/bridges/components.js +2 -0
  130. package/dist/editor/bridges/components.js.map +1 -1
  131. package/dist/editor/bridges/undo.d.ts +1 -1
  132. package/dist/editor/clipboard/assets.js +1 -1
  133. package/dist/editor/clipboard/export.d.ts.map +1 -1
  134. package/dist/editor/clipboard/export.js +16 -2
  135. package/dist/editor/clipboard/export.js.map +1 -1
  136. package/dist/editor/clipboard/placement.d.ts +1 -1
  137. package/dist/editor/clipboard/placement.js +1 -1
  138. package/dist/editor/components/instances.d.ts +2 -0
  139. package/dist/editor/components/instances.d.ts.map +1 -1
  140. package/dist/editor/components/instances.js +22 -1
  141. package/dist/editor/components/instances.js.map +1 -1
  142. package/dist/editor/components.d.ts +2 -0
  143. package/dist/editor/components.d.ts.map +1 -1
  144. package/dist/editor/connectors/attach.js +1 -1
  145. package/dist/editor/create.d.ts +27 -3
  146. package/dist/editor/create.d.ts.map +1 -1
  147. package/dist/editor/create.js +16 -60
  148. package/dist/editor/create.js.map +1 -1
  149. package/dist/editor/design-memory.d.ts +11 -0
  150. package/dist/editor/design-memory.d.ts.map +1 -0
  151. package/dist/editor/design-memory.js +40 -0
  152. package/dist/editor/design-memory.js.map +1 -0
  153. package/dist/editor/design-tokens.d.ts +4 -0
  154. package/dist/editor/design-tokens.d.ts.map +1 -1
  155. package/dist/editor/design-tokens.js +30 -1
  156. package/dist/editor/design-tokens.js.map +1 -1
  157. package/dist/editor/document-colors.d.ts +23 -0
  158. package/dist/editor/document-colors.d.ts.map +1 -0
  159. package/dist/editor/document-colors.js +53 -0
  160. package/dist/editor/document-colors.js.map +1 -0
  161. package/dist/editor/eyedropper.d.ts +47 -0
  162. package/dist/editor/eyedropper.d.ts.map +1 -0
  163. package/dist/editor/eyedropper.js +168 -0
  164. package/dist/editor/eyedropper.js.map +1 -0
  165. package/dist/editor/fonts.d.ts +9 -0
  166. package/dist/editor/fonts.d.ts.map +1 -0
  167. package/dist/editor/fonts.js +14 -0
  168. package/dist/editor/fonts.js.map +1 -0
  169. package/dist/editor/history/atomic-tool.d.ts +9 -2
  170. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  171. package/dist/editor/history/atomic-tool.js +6 -0
  172. package/dist/editor/history/atomic-tool.js.map +1 -1
  173. package/dist/editor/history/capture.d.ts +13 -0
  174. package/dist/editor/history/capture.d.ts.map +1 -0
  175. package/dist/editor/history/capture.js +28 -0
  176. package/dist/editor/history/capture.js.map +1 -0
  177. package/dist/editor/history/document-change.d.ts.map +1 -1
  178. package/dist/editor/history/document-change.js +2 -22
  179. package/dist/editor/history/document-change.js.map +1 -1
  180. package/dist/editor/history/edit.d.ts +7 -0
  181. package/dist/editor/history/edit.d.ts.map +1 -1
  182. package/dist/editor/history/edit.js +4 -2
  183. package/dist/editor/history/edit.js.map +1 -1
  184. package/dist/editor/history/subtree.d.ts +9 -0
  185. package/dist/editor/history/subtree.d.ts.map +1 -1
  186. package/dist/editor/history/subtree.js +12 -2
  187. package/dist/editor/history/subtree.js.map +1 -1
  188. package/dist/editor/index.d.ts +4 -2
  189. package/dist/editor/index.js +4 -2
  190. package/dist/editor/pages.d.ts +7 -5
  191. package/dist/editor/pages.d.ts.map +1 -1
  192. package/dist/editor/pages.js +35 -25
  193. package/dist/editor/pages.js.map +1 -1
  194. package/dist/editor/play/states.d.ts +3 -1
  195. package/dist/editor/play/states.d.ts.map +1 -1
  196. package/dist/editor/play/states.js +1 -1
  197. package/dist/editor/play/states.js.map +1 -1
  198. package/dist/editor/read-only/actions.js +4 -0
  199. package/dist/editor/read-only/actions.js.map +1 -1
  200. package/dist/editor/render-requests.d.ts +18 -0
  201. package/dist/editor/render-requests.d.ts.map +1 -0
  202. package/dist/editor/render-requests.js +76 -0
  203. package/dist/editor/render-requests.js.map +1 -0
  204. package/dist/editor/scale/rescale.d.ts +1 -1
  205. package/dist/editor/selection/overlays.d.ts.map +1 -1
  206. package/dist/editor/selection/overlays.js +1 -1
  207. package/dist/editor/selection/overlays.js.map +1 -1
  208. package/dist/editor/selection/read.d.ts +4 -0
  209. package/dist/editor/selection.d.ts +5 -0
  210. package/dist/editor/selection.d.ts.map +1 -1
  211. package/dist/editor/tool-registry.d.ts.map +1 -1
  212. package/dist/editor/tool-registry.js +2 -1
  213. package/dist/editor/tool-registry.js.map +1 -1
  214. package/dist/editor/types.d.ts +5 -1
  215. package/dist/editor/types.d.ts.map +1 -1
  216. package/dist/editor/variations/create.d.ts +28 -0
  217. package/dist/editor/variations/create.d.ts.map +1 -0
  218. package/dist/editor/variations/create.js +176 -0
  219. package/dist/editor/variations/create.js.map +1 -0
  220. package/dist/editor/variations/pick.d.ts +16 -0
  221. package/dist/editor/variations/pick.d.ts.map +1 -0
  222. package/dist/editor/variations/pick.js +23 -0
  223. package/dist/editor/variations/pick.js.map +1 -0
  224. package/dist/editor/variations.d.ts +28 -0
  225. package/dist/editor/variations.d.ts.map +1 -0
  226. package/dist/editor/variations.js +88 -0
  227. package/dist/editor/variations.js.map +1 -0
  228. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  229. package/dist/figma-api/accessors/reactions.js +4 -1
  230. package/dist/figma-api/accessors/reactions.js.map +1 -1
  231. package/dist/figma-api/accessors/text/index.js +3 -0
  232. package/dist/figma-api/accessors/text/index.js.map +1 -1
  233. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  234. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  235. package/dist/figma-api/accessors/text/opentype.js +28 -0
  236. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  237. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  238. package/dist/figma-api/accessors/visual.js +33 -0
  239. package/dist/figma-api/accessors/visual.js.map +1 -1
  240. package/dist/figma-api/effects.d.ts +79 -3
  241. package/dist/figma-api/effects.d.ts.map +1 -1
  242. package/dist/figma-api/effects.js +150 -9
  243. package/dist/figma-api/effects.js.map +1 -1
  244. package/dist/figma-api/index.d.ts +5 -0
  245. package/dist/figma-api/index.d.ts.map +1 -1
  246. package/dist/figma-api/index.js +6 -1
  247. package/dist/figma-api/index.js.map +1 -1
  248. package/dist/figma-api/overrides.d.ts +13 -1
  249. package/dist/figma-api/overrides.d.ts.map +1 -1
  250. package/dist/figma-api/overrides.js +196 -4
  251. package/dist/figma-api/overrides.js.map +1 -1
  252. package/dist/figma-api/paints.d.ts +3 -3
  253. package/dist/figma-api/paints.d.ts.map +1 -1
  254. package/dist/figma-api/paints.js +14 -4
  255. package/dist/figma-api/paints.js.map +1 -1
  256. package/dist/figma-api/proxy.d.ts +4 -1
  257. package/dist/figma-api/proxy.d.ts.map +1 -1
  258. package/dist/figma-api/proxy.js +1 -1
  259. package/dist/figma-api/proxy.js.map +1 -1
  260. package/dist/figma-api/reactions.d.ts +41 -13
  261. package/dist/figma-api/reactions.d.ts.map +1 -1
  262. package/dist/figma-api/reactions.js +113 -31
  263. package/dist/figma-api/reactions.js.map +1 -1
  264. package/dist/figma-api/render-bounds.js +1 -1
  265. package/dist/figma-api/surface.d.ts +6 -3
  266. package/dist/figma-api/surface.d.ts.map +1 -1
  267. package/dist/figma-api/surface.js +6 -2
  268. package/dist/figma-api/surface.js.map +1 -1
  269. package/dist/figma-api/transform.d.ts +1 -1
  270. package/dist/geometry/figma.d.ts +1 -1
  271. package/dist/geometry/image-crop.d.ts +1 -1
  272. package/dist/geometry/image-crop.js +1 -1
  273. package/dist/index.d.ts +4 -2
  274. package/dist/index.js +4 -2
  275. package/dist/io/formats/boolean-path.d.ts +19 -0
  276. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  277. package/dist/io/formats/boolean-path.js +47 -0
  278. package/dist/io/formats/boolean-path.js.map +1 -0
  279. package/dist/io/formats/design-tokens/decode.js +1 -1
  280. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  281. package/dist/io/formats/design-tokens/index.js +4 -1
  282. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  283. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  284. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  285. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  286. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  287. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  288. package/dist/io/formats/design-tokens/project.js +29 -8
  289. package/dist/io/formats/design-tokens/project.js.map +1 -1
  290. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  291. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  292. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  293. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  294. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  295. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  296. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  297. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  298. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  299. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  300. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  301. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  302. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  303. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  304. package/dist/io/formats/drawio/edges.d.ts +7 -1
  305. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  306. package/dist/io/formats/drawio/edges.js +54 -1
  307. package/dist/io/formats/drawio/edges.js.map +1 -1
  308. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  309. package/dist/io/formats/drawio/export.js +19 -2
  310. package/dist/io/formats/drawio/export.js.map +1 -1
  311. package/dist/io/formats/drawio/index.js +1 -0
  312. package/dist/io/formats/drawio/index.js.map +1 -1
  313. package/dist/io/formats/drawio/label.js +1 -1
  314. package/dist/io/formats/drawio/paint.js +1 -1
  315. package/dist/io/formats/drawio/placement.d.ts +1 -1
  316. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  317. package/dist/io/formats/fig/export/patch/index.js +5 -0
  318. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  319. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  320. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  321. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  322. package/dist/io/formats/html/import.d.ts.map +1 -1
  323. package/dist/io/formats/html/import.js +3 -1
  324. package/dist/io/formats/html/import.js.map +1 -1
  325. package/dist/io/formats/html/index.d.ts +2 -2
  326. package/dist/io/formats/html/index.d.ts.map +1 -1
  327. package/dist/io/formats/html/index.js +6 -4
  328. package/dist/io/formats/html/index.js.map +1 -1
  329. package/dist/io/formats/html/vectors.d.ts +2 -1
  330. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  331. package/dist/io/formats/html/vectors.js +3 -2
  332. package/dist/io/formats/html/vectors.js.map +1 -1
  333. package/dist/io/formats/mermaid/styles.js +1 -1
  334. package/dist/io/formats/pdf/document.d.ts +3 -1
  335. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  336. package/dist/io/formats/pdf/document.js +6 -3
  337. package/dist/io/formats/pdf/document.js.map +1 -1
  338. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  339. package/dist/io/formats/pen/imports.d.ts +4 -1
  340. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  341. package/dist/io/formats/pen/imports.js.map +1 -1
  342. package/dist/io/formats/pen/index.d.ts.map +1 -1
  343. package/dist/io/formats/pen/index.js +31 -3
  344. package/dist/io/formats/pen/index.js.map +1 -1
  345. package/dist/io/formats/pptx/export.js +1 -1
  346. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  347. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  348. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  349. package/dist/io/formats/raster/adjusted-images.js +118 -0
  350. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  351. package/dist/io/formats/raster/headless.d.ts +11 -1
  352. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  353. package/dist/io/formats/raster/headless.js +4 -4
  354. package/dist/io/formats/raster/headless.js.map +1 -1
  355. package/dist/io/formats/raster/index.d.ts +2 -2
  356. package/dist/io/formats/raster/pixels.d.ts +7 -1
  357. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  358. package/dist/io/formats/raster/pixels.js.map +1 -1
  359. package/dist/io/formats/raster/render.d.ts.map +1 -1
  360. package/dist/io/formats/raster/render.js +4 -0
  361. package/dist/io/formats/raster/render.js.map +1 -1
  362. package/dist/io/formats/svg/defs.d.ts +5 -6
  363. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  364. package/dist/io/formats/svg/defs.js +1 -53
  365. package/dist/io/formats/svg/defs.js.map +1 -1
  366. package/dist/io/formats/svg/effects.d.ts +16 -0
  367. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  368. package/dist/io/formats/svg/effects.js +126 -0
  369. package/dist/io/formats/svg/effects.js.map +1 -0
  370. package/dist/io/formats/svg/export.d.ts +7 -1
  371. package/dist/io/formats/svg/export.d.ts.map +1 -1
  372. package/dist/io/formats/svg/export.js +174 -36
  373. package/dist/io/formats/svg/export.js.map +1 -1
  374. package/dist/io/formats/svg/filter.d.ts +27 -0
  375. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  376. package/dist/io/formats/svg/filter.js +44 -0
  377. package/dist/io/formats/svg/filter.js.map +1 -0
  378. package/dist/io/formats/svg/grain.d.ts +26 -0
  379. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  380. package/dist/io/formats/svg/grain.js +298 -0
  381. package/dist/io/formats/svg/grain.js.map +1 -0
  382. package/dist/io/formats/svg/strokes.d.ts +1 -1
  383. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  384. package/dist/io/formats/svg/strokes.js +1 -2
  385. package/dist/io/formats/svg/strokes.js.map +1 -1
  386. package/dist/io/formats/svg/text/import.js +1 -1
  387. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  388. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  389. package/dist/io/formats/svg/text/layout.js +6 -3
  390. package/dist/io/formats/svg/text/layout.js.map +1 -1
  391. package/dist/io/formats/video/composite.d.ts +18 -0
  392. package/dist/io/formats/video/composite.d.ts.map +1 -0
  393. package/dist/io/formats/video/composite.js +79 -0
  394. package/dist/io/formats/video/composite.js.map +1 -0
  395. package/dist/io/formats/video/formats.d.ts +29 -0
  396. package/dist/io/formats/video/formats.d.ts.map +1 -0
  397. package/dist/io/formats/video/formats.js +43 -0
  398. package/dist/io/formats/video/formats.js.map +1 -0
  399. package/dist/io/formats/video/gif.d.ts +13 -0
  400. package/dist/io/formats/video/gif.d.ts.map +1 -0
  401. package/dist/io/formats/video/gif.js +56 -0
  402. package/dist/io/formats/video/gif.js.map +1 -0
  403. package/dist/io/formats/video/index.d.ts +9 -0
  404. package/dist/io/formats/video/index.js +9 -0
  405. package/dist/io/formats/video/plan.d.ts +64 -0
  406. package/dist/io/formats/video/plan.d.ts.map +1 -0
  407. package/dist/io/formats/video/plan.js +90 -0
  408. package/dist/io/formats/video/plan.js.map +1 -0
  409. package/dist/io/formats/video/record.d.ts +36 -0
  410. package/dist/io/formats/video/record.d.ts.map +1 -0
  411. package/dist/io/formats/video/record.js +154 -0
  412. package/dist/io/formats/video/record.js.map +1 -0
  413. package/dist/io/formats/video/sink.d.ts +29 -0
  414. package/dist/io/formats/video/sink.d.ts.map +1 -0
  415. package/dist/io/formats/video/sink.js +16 -0
  416. package/dist/io/formats/video/sink.js.map +1 -0
  417. package/dist/io/formats/video/size.d.ts +19 -0
  418. package/dist/io/formats/video/size.d.ts.map +1 -0
  419. package/dist/io/formats/video/size.js +26 -0
  420. package/dist/io/formats/video/size.js.map +1 -0
  421. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  422. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  423. package/dist/io/formats/video/webcodecs.js +74 -0
  424. package/dist/io/formats/video/webcodecs.js.map +1 -0
  425. package/dist/io/formats.d.ts.map +1 -1
  426. package/dist/io/formats.js +40 -11
  427. package/dist/io/formats.js.map +1 -1
  428. package/dist/io/types.d.ts +19 -4
  429. package/dist/io/types.d.ts.map +1 -1
  430. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  431. package/dist/layout/auto-layout-handles.d.ts +66 -0
  432. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  433. package/dist/layout/auto-layout-handles.js +291 -0
  434. package/dist/layout/auto-layout-handles.js.map +1 -0
  435. package/dist/layout.d.ts +3 -2
  436. package/dist/layout.d.ts.map +1 -1
  437. package/dist/layout.js +2 -1
  438. package/dist/layout.js.map +1 -1
  439. package/dist/lint/fixes.d.ts.map +1 -1
  440. package/dist/lint/fixes.js +9 -3
  441. package/dist/lint/fixes.js.map +1 -1
  442. package/dist/lint/index.d.ts +3 -2
  443. package/dist/lint/index.js +2 -1
  444. package/dist/lint/linter.d.ts +12 -0
  445. package/dist/lint/linter.d.ts.map +1 -1
  446. package/dist/lint/linter.js +110 -8
  447. package/dist/lint/linter.js.map +1 -1
  448. package/dist/lint/presets.d.ts.map +1 -1
  449. package/dist/lint/presets.js +2 -0
  450. package/dist/lint/presets.js.map +1 -1
  451. package/dist/lint/rules/design-memory.d.ts +15 -0
  452. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  453. package/dist/lint/rules/design-memory.js +90 -0
  454. package/dist/lint/rules/design-memory.js.map +1 -0
  455. package/dist/lint/rules/index.d.ts +6 -5
  456. package/dist/lint/rules/index.d.ts.map +1 -1
  457. package/dist/lint/rules/index.js +6 -2
  458. package/dist/lint/rules/index.js.map +1 -1
  459. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  460. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  461. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  462. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  463. package/dist/lint/types.d.ts +25 -2
  464. package/dist/lint/types.d.ts.map +1 -1
  465. package/dist/node/video.d.ts +12 -0
  466. package/dist/node/video.d.ts.map +1 -0
  467. package/dist/node/video.js +206 -0
  468. package/dist/node/video.js.map +1 -0
  469. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  470. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  471. package/dist/pairdraw-api/design-memory.js +39 -0
  472. package/dist/pairdraw-api/design-memory.js.map +1 -0
  473. package/dist/pairdraw-api/index.d.ts +45 -1
  474. package/dist/pairdraw-api/index.d.ts.map +1 -1
  475. package/dist/pairdraw-api/index.js +55 -2
  476. package/dist/pairdraw-api/index.js.map +1 -1
  477. package/dist/pairdraw-api/nodes.d.ts +12 -1
  478. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  479. package/dist/pairdraw-api/nodes.js +28 -1
  480. package/dist/pairdraw-api/nodes.js.map +1 -1
  481. package/dist/pairdraw-api/variations.d.ts +48 -0
  482. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  483. package/dist/pairdraw-api/variations.js +76 -0
  484. package/dist/pairdraw-api/variations.js.map +1 -0
  485. package/dist/prototype/easing.d.ts +13 -0
  486. package/dist/prototype/easing.d.ts.map +1 -0
  487. package/dist/prototype/easing.js +36 -0
  488. package/dist/prototype/easing.js.map +1 -0
  489. package/dist/prototype/frames.d.ts +10 -0
  490. package/dist/prototype/frames.d.ts.map +1 -0
  491. package/dist/prototype/frames.js +12 -0
  492. package/dist/prototype/frames.js.map +1 -0
  493. package/dist/prototype/hit.d.ts +17 -0
  494. package/dist/prototype/hit.d.ts.map +1 -0
  495. package/dist/prototype/hit.js +45 -0
  496. package/dist/prototype/hit.js.map +1 -0
  497. package/dist/prototype/index.d.ts +14 -0
  498. package/dist/prototype/index.js +14 -0
  499. package/dist/prototype/pointer.d.ts +63 -0
  500. package/dist/prototype/pointer.d.ts.map +1 -0
  501. package/dist/prototype/pointer.js +104 -0
  502. package/dist/prototype/pointer.js.map +1 -0
  503. package/dist/prototype/reactions.d.ts +45 -0
  504. package/dist/prototype/reactions.d.ts.map +1 -0
  505. package/dist/prototype/reactions.js +122 -0
  506. package/dist/prototype/reactions.js.map +1 -0
  507. package/dist/prototype/scene.d.ts +35 -0
  508. package/dist/prototype/scene.d.ts.map +1 -0
  509. package/dist/prototype/scene.js +86 -0
  510. package/dist/prototype/scene.js.map +1 -0
  511. package/dist/prototype/scenes.d.ts +81 -0
  512. package/dist/prototype/scenes.d.ts.map +1 -0
  513. package/dist/prototype/scenes.js +175 -0
  514. package/dist/prototype/scenes.js.map +1 -0
  515. package/dist/prototype/scroll.d.ts +48 -0
  516. package/dist/prototype/scroll.d.ts.map +1 -0
  517. package/dist/prototype/scroll.js +159 -0
  518. package/dist/prototype/scroll.js.map +1 -0
  519. package/dist/prototype/session.d.ts +71 -0
  520. package/dist/prototype/session.d.ts.map +1 -0
  521. package/dist/prototype/session.js +135 -0
  522. package/dist/prototype/session.js.map +1 -0
  523. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  524. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  525. package/dist/prototype/smart-animate/animation.js +212 -0
  526. package/dist/prototype/smart-animate/animation.js.map +1 -0
  527. package/dist/prototype/smart-animate/match.d.ts +24 -0
  528. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  529. package/dist/prototype/smart-animate/match.js +72 -0
  530. package/dist/prototype/smart-animate/match.js.map +1 -0
  531. package/dist/prototype/snapshot.d.ts +19 -0
  532. package/dist/prototype/snapshot.d.ts.map +1 -0
  533. package/dist/prototype/snapshot.js +56 -0
  534. package/dist/prototype/snapshot.js.map +1 -0
  535. package/dist/prototype/timeline.d.ts +132 -0
  536. package/dist/prototype/timeline.d.ts.map +1 -0
  537. package/dist/prototype/timeline.js +260 -0
  538. package/dist/prototype/timeline.js.map +1 -0
  539. package/dist/rpc/read-commands.js +1 -1
  540. package/dist/text/font/features.d.ts +9 -0
  541. package/dist/text/font/features.d.ts.map +1 -0
  542. package/dist/text/font/features.js +27 -0
  543. package/dist/text/font/features.js.map +1 -0
  544. package/dist/text/font/manager.d.ts +12 -0
  545. package/dist/text/font/manager.d.ts.map +1 -1
  546. package/dist/text/font/manager.js +60 -1
  547. package/dist/text/font/manager.js.map +1 -1
  548. package/dist/text/index.d.ts +10 -8
  549. package/dist/text/index.js +3 -1
  550. package/dist/text/replace-fonts.d.ts +41 -0
  551. package/dist/text/replace-fonts.d.ts.map +1 -0
  552. package/dist/text/replace-fonts.js +121 -0
  553. package/dist/text/replace-fonts.js.map +1 -0
  554. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  555. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  556. package/dist/tools/analyze/responsive/index.js +203 -0
  557. package/dist/tools/analyze/responsive/index.js.map +1 -0
  558. package/dist/tools/analyze.d.ts +2 -1
  559. package/dist/tools/analyze.js +2 -1
  560. package/dist/tools/codegen/token-sync.d.ts +7 -0
  561. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  562. package/dist/tools/codegen/token-sync.js +85 -0
  563. package/dist/tools/codegen/token-sync.js.map +1 -0
  564. package/dist/tools/codegen/tokens.d.ts +1 -1
  565. package/dist/tools/codegen.d.ts +2 -1
  566. package/dist/tools/codegen.js +2 -1
  567. package/dist/tools/create/basic.js +1 -1
  568. package/dist/tools/create/behaviours.js +1 -1
  569. package/dist/tools/create/components.d.ts.map +1 -1
  570. package/dist/tools/create/components.js +4 -0
  571. package/dist/tools/create/components.js.map +1 -1
  572. package/dist/tools/create/html.js +3 -2
  573. package/dist/tools/create/html.js.map +1 -1
  574. package/dist/tools/create/icons.d.ts.map +1 -1
  575. package/dist/tools/create/icons.js +2 -1
  576. package/dist/tools/create/icons.js.map +1 -1
  577. package/dist/tools/create/mermaid.js +2 -1
  578. package/dist/tools/create/mermaid.js.map +1 -1
  579. package/dist/tools/create/render.js +1 -1
  580. package/dist/tools/create/svg.js +2 -1
  581. package/dist/tools/create/svg.js.map +1 -1
  582. package/dist/tools/create/vector.js +1 -1
  583. package/dist/tools/design-memory.d.ts +8 -0
  584. package/dist/tools/design-memory.d.ts.map +1 -0
  585. package/dist/tools/design-memory.js +68 -0
  586. package/dist/tools/design-memory.js.map +1 -0
  587. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  588. package/dist/tools/image-ai/generate.js +3 -1
  589. package/dist/tools/image-ai/generate.js.map +1 -1
  590. package/dist/tools/index.d.ts +2 -1
  591. package/dist/tools/index.js +2 -1
  592. package/dist/tools/modify/fonts.d.ts +6 -0
  593. package/dist/tools/modify/fonts.d.ts.map +1 -0
  594. package/dist/tools/modify/fonts.js +27 -0
  595. package/dist/tools/modify/fonts.js.map +1 -0
  596. package/dist/tools/modify/paint.js +1 -1
  597. package/dist/tools/modify/reactions.d.ts.map +1 -1
  598. package/dist/tools/modify/reactions.js +3 -3
  599. package/dist/tools/modify/reactions.js.map +1 -1
  600. package/dist/tools/modify/text.d.ts.map +1 -1
  601. package/dist/tools/modify/text.js +26 -5
  602. package/dist/tools/modify/text.js.map +1 -1
  603. package/dist/tools/modify/update.d.ts +10 -1
  604. package/dist/tools/modify/update.d.ts.map +1 -1
  605. package/dist/tools/modify/update.js +34 -3
  606. package/dist/tools/modify/update.js.map +1 -1
  607. package/dist/tools/modify.d.ts +2 -1
  608. package/dist/tools/modify.js +2 -1
  609. package/dist/tools/read/fonts.d.ts.map +1 -1
  610. package/dist/tools/read/fonts.js +17 -2
  611. package/dist/tools/read/fonts.js.map +1 -1
  612. package/dist/tools/read/libraries.js +2 -1
  613. package/dist/tools/read/libraries.js.map +1 -1
  614. package/dist/tools/read/space.d.ts +3 -1
  615. package/dist/tools/read/space.d.ts.map +1 -1
  616. package/dist/tools/read/space.js +4 -3
  617. package/dist/tools/read/space.js.map +1 -1
  618. package/dist/tools/registry/core.d.ts +1 -1
  619. package/dist/tools/registry/core.d.ts.map +1 -1
  620. package/dist/tools/registry/core.js +3 -1
  621. package/dist/tools/registry/core.js.map +1 -1
  622. package/dist/tools/registry/extended.d.ts.map +1 -1
  623. package/dist/tools/registry/extended.js +16 -1
  624. package/dist/tools/registry/extended.js.map +1 -1
  625. package/dist/tools/schema.d.ts +18 -2
  626. package/dist/tools/schema.d.ts.map +1 -1
  627. package/dist/tools/schema.js +1 -1
  628. package/dist/tools/schema.js.map +1 -1
  629. package/dist/tools/stock-photo.js +1 -0
  630. package/dist/tools/stock-photo.js.map +1 -1
  631. package/dist/tools/structure/basic.d.ts.map +1 -1
  632. package/dist/tools/structure/basic.js +1 -0
  633. package/dist/tools/structure/basic.js.map +1 -1
  634. package/dist/tools/structure/batch.d.ts.map +1 -1
  635. package/dist/tools/structure/batch.js +8 -1
  636. package/dist/tools/structure/batch.js.map +1 -1
  637. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  638. package/dist/tools/structure/hierarchy.js +4 -0
  639. package/dist/tools/structure/hierarchy.js.map +1 -1
  640. package/dist/tools/structure/variations.d.ts +8 -0
  641. package/dist/tools/structure/variations.d.ts.map +1 -0
  642. package/dist/tools/structure/variations.js +106 -0
  643. package/dist/tools/structure/variations.js.map +1 -0
  644. package/dist/tools/structure.d.ts +2 -1
  645. package/dist/tools/structure.js +2 -1
  646. package/dist/tools/styles/types.d.ts +2 -4
  647. package/dist/tools/styles/types.d.ts.map +1 -1
  648. package/dist/tools/styles/types.js.map +1 -1
  649. package/dist/tools/vector/boolean.d.ts.map +1 -1
  650. package/dist/tools/vector/boolean.js +4 -0
  651. package/dist/tools/vector/boolean.js.map +1 -1
  652. package/dist/tools/vector/vectorize.js +1 -0
  653. package/dist/tools/vector/vectorize.js.map +1 -1
  654. package/dist/tools/vector/video.d.ts +6 -0
  655. package/dist/tools/vector/video.d.ts.map +1 -0
  656. package/dist/tools/vector/video.js +133 -0
  657. package/dist/tools/vector/video.js.map +1 -0
  658. package/dist/tools/vector.d.ts +2 -1
  659. package/dist/tools/vector.js +2 -1
  660. package/dist/tools/video-host.d.ts +12 -0
  661. package/dist/tools/video-host.d.ts.map +1 -0
  662. package/dist/tools/video-host.js +19 -0
  663. package/dist/tools/video-host.js.map +1 -0
  664. package/dist/vector/point-transform.d.ts +1 -1
  665. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  666. package/package.json +31 -9
  667. package/src/ai/providers.ts +2 -0
  668. package/src/cache/resource.ts +24 -1
  669. package/src/canvas/effects.ts +47 -50
  670. package/src/canvas/fills.ts +19 -15
  671. package/src/canvas/images/adjustments.ts +203 -0
  672. package/src/canvas/images/sampling.ts +88 -0
  673. package/src/canvas/index.ts +1 -0
  674. package/src/canvas/masks.ts +1 -1
  675. package/src/canvas/noise/render.ts +75 -0
  676. package/src/canvas/noise/shader.ts +161 -0
  677. package/src/canvas/noise/table.ts +91 -0
  678. package/src/canvas/noise/tile.ts +94 -0
  679. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  680. package/src/canvas/renderer/lifecycle.ts +6 -0
  681. package/src/canvas/renderer/pipeline.ts +19 -1
  682. package/src/canvas/renderer/play-scenes.ts +51 -0
  683. package/src/canvas/renderer/tiles/cache.ts +54 -1
  684. package/src/canvas/renderer/tiles/controller.ts +30 -1
  685. package/src/canvas/renderer/types.ts +18 -2
  686. package/src/canvas/renderer.ts +40 -3
  687. package/src/canvas/scene.ts +65 -9
  688. package/src/canvas/texture.ts +136 -0
  689. package/src/clipboard.ts +23 -10
  690. package/src/constants.ts +6 -0
  691. package/src/design-memory/check.ts +376 -0
  692. package/src/design-memory/describe.ts +77 -0
  693. package/src/design-memory/distil.ts +69 -0
  694. package/src/design-memory/document.ts +80 -0
  695. package/src/design-memory/guard.ts +157 -0
  696. package/src/design-memory/index.ts +8 -0
  697. package/src/design-memory/refusal.ts +90 -0
  698. package/src/design-memory/rules.ts +274 -0
  699. package/src/design-memory/values.ts +179 -0
  700. package/src/editor/bridges/components.ts +2 -0
  701. package/src/editor/clipboard/export.ts +24 -7
  702. package/src/editor/components/instances.ts +31 -0
  703. package/src/editor/create.ts +25 -69
  704. package/src/editor/design-memory.ts +39 -0
  705. package/src/editor/design-tokens.ts +41 -2
  706. package/src/editor/document-colors.ts +65 -0
  707. package/src/editor/eyedropper.ts +198 -0
  708. package/src/editor/fonts.ts +19 -0
  709. package/src/editor/history/atomic-tool.ts +29 -1
  710. package/src/editor/history/capture.ts +19 -0
  711. package/src/editor/history/document-change.ts +5 -17
  712. package/src/editor/history/edit.ts +11 -1
  713. package/src/editor/history/subtree.ts +13 -2
  714. package/src/editor/index.ts +11 -0
  715. package/src/editor/pages.ts +40 -29
  716. package/src/editor/play/states.ts +1 -1
  717. package/src/editor/read-only/actions.ts +4 -0
  718. package/src/editor/render-requests.ts +83 -0
  719. package/src/editor/selection/overlays.ts +1 -0
  720. package/src/editor/tool-registry.ts +2 -1
  721. package/src/editor/types.ts +4 -0
  722. package/src/editor/variations/create.ts +235 -0
  723. package/src/editor/variations/pick.ts +35 -0
  724. package/src/editor/variations.ts +110 -0
  725. package/src/figma-api/accessors/reactions.ts +11 -1
  726. package/src/figma-api/accessors/text/index.ts +7 -0
  727. package/src/figma-api/accessors/text/opentype.ts +33 -0
  728. package/src/figma-api/accessors/visual.ts +55 -2
  729. package/src/figma-api/compatibility.ts +5 -2
  730. package/src/figma-api/effects.ts +143 -5
  731. package/src/figma-api/index.ts +10 -0
  732. package/src/figma-api/overrides.ts +295 -3
  733. package/src/figma-api/paints.ts +24 -9
  734. package/src/figma-api/proxy.ts +6 -1
  735. package/src/figma-api/reactions.ts +130 -32
  736. package/src/figma-api/surface.ts +6 -2
  737. package/src/global.d.ts +26 -0
  738. package/src/io/formats/boolean-path.ts +60 -0
  739. package/src/io/formats/design-tokens/index.ts +21 -0
  740. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  741. package/src/io/formats/design-tokens/project.ts +40 -9
  742. package/src/io/formats/design-tokens/styles.ts +10 -2
  743. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  744. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  745. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  746. package/src/io/formats/drawio/edges.ts +65 -0
  747. package/src/io/formats/drawio/export.ts +37 -14
  748. package/src/io/formats/drawio/index.ts +2 -0
  749. package/src/io/formats/fig/export/patch/index.ts +8 -0
  750. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  751. package/src/io/formats/html/import.ts +9 -1
  752. package/src/io/formats/html/index.ts +14 -7
  753. package/src/io/formats/html/vectors.ts +8 -2
  754. package/src/io/formats/pdf/document.ts +14 -4
  755. package/src/io/formats/pen/imports.ts +5 -6
  756. package/src/io/formats/pen/index.ts +36 -5
  757. package/src/io/formats/raster/adjusted-images.ts +125 -0
  758. package/src/io/formats/raster/headless.ts +3 -3
  759. package/src/io/formats/raster/index.ts +6 -1
  760. package/src/io/formats/raster/pixels.ts +7 -0
  761. package/src/io/formats/raster/render.ts +12 -1
  762. package/src/io/formats/svg/defs.ts +4 -72
  763. package/src/io/formats/svg/effects.ts +131 -0
  764. package/src/io/formats/svg/export.ts +278 -46
  765. package/src/io/formats/svg/filter.ts +47 -0
  766. package/src/io/formats/svg/grain.ts +249 -0
  767. package/src/io/formats/svg/strokes.ts +2 -2
  768. package/src/io/formats/svg/text/layout.ts +13 -3
  769. package/src/io/formats/video/composite.ts +79 -0
  770. package/src/io/formats/video/formats.ts +77 -0
  771. package/src/io/formats/video/gif.ts +65 -0
  772. package/src/io/formats/video/index.ts +30 -0
  773. package/src/io/formats/video/plan.ts +116 -0
  774. package/src/io/formats/video/record.ts +227 -0
  775. package/src/io/formats/video/sink.ts +32 -0
  776. package/src/io/formats/video/size.ts +25 -0
  777. package/src/io/formats/video/webcodecs.ts +89 -0
  778. package/src/io/formats.ts +59 -11
  779. package/src/io/types.ts +29 -10
  780. package/src/layout/auto-layout-handles.ts +396 -0
  781. package/src/layout.ts +2 -0
  782. package/src/lint/fixes.ts +12 -3
  783. package/src/lint/index.ts +3 -1
  784. package/src/lint/linter.ts +107 -10
  785. package/src/lint/presets.ts +2 -0
  786. package/src/lint/rules/design-memory.ts +97 -0
  787. package/src/lint/rules/index.ts +6 -1
  788. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  789. package/src/lint/types.ts +32 -0
  790. package/src/node/video.ts +196 -0
  791. package/src/pairdraw-api/design-memory.ts +61 -0
  792. package/src/pairdraw-api/index.ts +81 -0
  793. package/src/pairdraw-api/nodes.ts +38 -0
  794. package/src/pairdraw-api/variations.ts +109 -0
  795. package/src/prototype/easing.ts +37 -0
  796. package/src/prototype/frames.ts +9 -0
  797. package/src/prototype/hit.ts +70 -0
  798. package/src/prototype/index.ts +69 -0
  799. package/src/prototype/pointer.ts +146 -0
  800. package/src/prototype/reactions.ts +178 -0
  801. package/src/prototype/scene.ts +116 -0
  802. package/src/prototype/scenes.ts +256 -0
  803. package/src/prototype/scroll.ts +190 -0
  804. package/src/prototype/session.ts +188 -0
  805. package/src/prototype/smart-animate/animation.ts +267 -0
  806. package/src/prototype/smart-animate/match.ts +85 -0
  807. package/src/prototype/snapshot.ts +60 -0
  808. package/src/prototype/timeline.ts +400 -0
  809. package/src/text/font/features.ts +27 -0
  810. package/src/text/font/manager.ts +79 -1
  811. package/src/text/index.ts +2 -0
  812. package/src/text/replace-fonts.ts +171 -0
  813. package/src/tools/analyze/responsive/index.ts +264 -0
  814. package/src/tools/analyze.ts +2 -0
  815. package/src/tools/codegen/token-sync.ts +98 -0
  816. package/src/tools/codegen.ts +1 -0
  817. package/src/tools/create/components.ts +4 -0
  818. package/src/tools/create/html.ts +1 -0
  819. package/src/tools/create/icons.ts +1 -0
  820. package/src/tools/create/mermaid.ts +1 -0
  821. package/src/tools/create/svg.ts +1 -0
  822. package/src/tools/design-memory.ts +72 -0
  823. package/src/tools/image-ai/generate.ts +2 -0
  824. package/src/tools/index.ts +1 -0
  825. package/src/tools/modify/fonts.ts +34 -0
  826. package/src/tools/modify/reactions.ts +15 -8
  827. package/src/tools/modify/text.ts +42 -5
  828. package/src/tools/modify/update.ts +46 -2
  829. package/src/tools/modify.ts +1 -0
  830. package/src/tools/read/fonts.ts +24 -2
  831. package/src/tools/read/libraries.ts +1 -0
  832. package/src/tools/read/space.ts +3 -2
  833. package/src/tools/registry/core.ts +3 -1
  834. package/src/tools/registry/extended.ts +28 -1
  835. package/src/tools/schema.ts +28 -4
  836. package/src/tools/stock-photo.ts +1 -0
  837. package/src/tools/structure/basic.ts +1 -0
  838. package/src/tools/structure/batch.ts +12 -1
  839. package/src/tools/structure/hierarchy.ts +4 -0
  840. package/src/tools/structure/variations.ts +118 -0
  841. package/src/tools/structure.ts +2 -0
  842. package/src/tools/styles/types.ts +3 -4
  843. package/src/tools/vector/boolean.ts +4 -0
  844. package/src/tools/vector/vectorize.ts +1 -0
  845. package/src/tools/vector/video.ts +228 -0
  846. package/src/tools/vector.ts +1 -0
  847. package/src/tools/video-host.ts +18 -0
@@ -0,0 +1,116 @@
1
+ import type { SceneGraph } from '@pairdraw/scene-graph'
2
+
3
+ import type { RasterCodec } from '#core/io/formats/raster'
4
+ import { planTimeline, TimelineError, type Timeline, type TimelineClick } from '#core/prototype'
5
+
6
+ import { openVideoSink, type VideoHostEncoder } from './formats'
7
+ import { recordPrototype, type RecordResult, type RenderFrame } from './record'
8
+ import type { VideoFormat } from './sink'
9
+ import { MAX_VIDEO_BYTES, MAX_VIDEO_EDGE, videoSize } from './size'
10
+
11
+ /**
12
+ * The longest edge a GIF may have. Every GIF frame is quantized on its own and a held screen is
13
+ * stored whole, so a larger GIF costs far more memory and time than it is worth.
14
+ */
15
+ export const MAX_GIF_EDGE = 960
16
+
17
+ /** Frame rates and long edges each format records at unless asked otherwise. */
18
+ export const VIDEO_DEFAULTS: Record<VideoFormat, { fps: number; maxEdge: number }> = {
19
+ mp4: { fps: 30, maxEdge: 1920 },
20
+ gif: { fps: 15, maxEdge: MAX_GIF_EDGE },
21
+ webm: { fps: 30, maxEdge: 1920 }
22
+ }
23
+
24
+ /** How long the last screen stays when the flow ends, unless asked otherwise. */
25
+ export const DEFAULT_VIDEO_TAIL_MS = 1000
26
+
27
+ export interface PrototypeVideoOptions {
28
+ startFrameId: string
29
+ format: VideoFormat
30
+ /** The start frame's size in the video, before `maxEdge` fits it. */
31
+ scale: number
32
+ maxEdge?: number
33
+ fps?: number
34
+ maxMs: number
35
+ tailMs?: number
36
+ clicks?: readonly TimelineClick[]
37
+ }
38
+
39
+ /** What a recording will hold: the planned timeline, and the video's size and frame rate. */
40
+ export interface PrototypeVideoPlan {
41
+ format: VideoFormat
42
+ timeline: Timeline
43
+ width: number
44
+ height: number
45
+ fps: number
46
+ }
47
+
48
+ /**
49
+ * Plans a recording of the prototype from `startFrameId`: its timeline, and a size fitted from the
50
+ * start frame (even for MP4 and WebM). Throws a `TimelineError` naming what cannot be played.
51
+ */
52
+ export function planPrototypeVideo(
53
+ graph: SceneGraph,
54
+ options: PrototypeVideoOptions
55
+ ): PrototypeVideoPlan {
56
+ const start = graph.getNode(options.startFrameId)
57
+ if (!start) throw new TimelineError(`No frame with ID '${options.startFrameId}'`)
58
+ const timeline = planTimeline(graph, {
59
+ startFrameId: start.id,
60
+ clicks: options.clicks,
61
+ maxMs: options.maxMs,
62
+ tailMs: options.tailMs ?? DEFAULT_VIDEO_TAIL_MS
63
+ })
64
+ const defaults = VIDEO_DEFAULTS[options.format]
65
+ const { width, height } = videoSize(start.width, start.height, {
66
+ scale: options.scale,
67
+ maxEdge: Math.min(
68
+ options.maxEdge ?? defaults.maxEdge,
69
+ options.format === 'gif' ? MAX_GIF_EDGE : MAX_VIDEO_EDGE
70
+ ),
71
+ even: options.format !== 'gif'
72
+ })
73
+ return { format: options.format, timeline, width, height, fps: options.fps ?? defaults.fps }
74
+ }
75
+
76
+ /**
77
+ * Records a planned video with `render` drawing its frames. Throws a `VideoFormatError` when this
78
+ * engine cannot encode the format, and stops at `MAX_VIDEO_BYTES` or when `signal` aborts.
79
+ */
80
+ export async function recordPrototypeVideo(
81
+ graph: SceneGraph,
82
+ plan: PrototypeVideoPlan,
83
+ render: RenderFrame,
84
+ options: {
85
+ signal?: AbortSignal
86
+ onProgress?: (done: number, total: number) => void
87
+ /** The host's encoder for what WebCodecs cannot encode there, such as the CLI's ffmpeg. */
88
+ host?: VideoHostEncoder | null
89
+ } = {}
90
+ ): Promise<RecordResult> {
91
+ const { width, height, fps, timeline } = plan
92
+ const { host, ...progress } = options
93
+ const sink = await openVideoSink(plan.format, { width, height, fps, loops: timeline.loops }, host)
94
+ return recordPrototype(graph, timeline, render, sink, {
95
+ width,
96
+ height,
97
+ fps,
98
+ maxBytes: MAX_VIDEO_BYTES,
99
+ ...progress
100
+ })
101
+ }
102
+
103
+ /**
104
+ * Draws frames through a host's raster export, as PNG, and decodes them to pixels; the app and the
105
+ * CLI each export through their own renderer. `graph`, when given, is a Smart animate's posed copy
106
+ * to draw the frame from instead of the document.
107
+ */
108
+ export function exportedFrameRenderer(
109
+ exportPNG: (frameId: string, scale: number, graph?: SceneGraph) => Promise<Uint8Array | null>,
110
+ codec: RasterCodec
111
+ ): RenderFrame {
112
+ return async (frameId, scale, graph) => {
113
+ const png = await exportPNG(frameId, scale, graph)
114
+ return png ? codec.decode(png) : null
115
+ }
116
+ }
@@ -0,0 +1,227 @@
1
+ import type { PrototypeOverlayPositionType, SceneGraph } from '@pairdraw/scene-graph'
2
+ import type { Rect, Vector } from '@pairdraw/scene-graph/primitives'
3
+
4
+ import { getPageColor } from '#core/figma-api/page-backgrounds'
5
+ import { computeContentBounds, type RGBAImage } from '#core/io/formats/raster'
6
+ import {
7
+ createSmartAnimation,
8
+ frameAt,
9
+ sessionDrawKey,
10
+ shownFrame,
11
+ type PlaySession,
12
+ type SmartAnimation,
13
+ type Timeline,
14
+ type TimelineSmartSegment
15
+ } from '#core/prototype'
16
+
17
+ import { crossfade, dim, drawOver, filledImage } from './composite'
18
+ import type { VideoSink } from './sink'
19
+
20
+ /**
21
+ * Draws one top-level frame at `scale` as pixels, or null when it cannot be drawn: from the
22
+ * document, or from `graph`, a Smart animate's copy of the frame posed at one moment.
23
+ */
24
+ export type RenderFrame = (
25
+ frameId: string,
26
+ scale: number,
27
+ graph?: SceneGraph
28
+ ) => Promise<RGBAImage | null>
29
+
30
+ export interface RecordOptions {
31
+ width: number
32
+ height: number
33
+ fps: number
34
+ signal?: AbortSignal
35
+ onProgress?: (done: number, total: number) => void
36
+ /** The most bytes the file may grow to before recording stops. */
37
+ maxBytes?: number
38
+ }
39
+
40
+ export interface RecordResult {
41
+ bytes: Uint8Array
42
+ frameCount: number
43
+ }
44
+
45
+ /** How dark the screen under an open overlay is drawn, as the player's scrim. */
46
+ const OVERLAY_SCRIM = 0.4
47
+ /** Screens kept drawn at once: the two of a crossfade and the one after it. */
48
+ const CACHED_SCREENS = 3
49
+ /** Frames recorded between yields to the event loop, so the app keeps drawing. */
50
+ const FRAMES_PER_YIELD = 4
51
+
52
+ /** Where an overlay starts along one axis of the screen: its start, its end, or centred. */
53
+ function alignOnAxis(start: number, size: number, overlay: number, edge: string): number {
54
+ if (edge === 'TOP' || edge === 'LEFT') return start
55
+ if (edge === 'BOTTOM' || edge === 'RIGHT') return start + size - overlay
56
+ return start + (size - overlay) / 2
57
+ }
58
+
59
+ /** Where an overlay of `width`×`height` sits on the screen `base`, as Figma positions overlays. */
60
+ function overlayOrigin(
61
+ base: Rect,
62
+ width: number,
63
+ height: number,
64
+ position: PrototypeOverlayPositionType
65
+ ): Vector {
66
+ const [vertical, horizontal] = position === 'CENTER' ? ['CENTER', 'CENTER'] : position.split('_')
67
+ return {
68
+ x: alignOnAxis(base.x, base.width, width, horizontal),
69
+ y: alignOnAxis(base.y, base.height, height, vertical)
70
+ }
71
+ }
72
+
73
+ function pageOf(graph: SceneGraph, frameId: string) {
74
+ const parentId = graph.getNode(frameId)?.parentId
75
+ return parentId ? graph.getNode(parentId) : undefined
76
+ }
77
+
78
+ /**
79
+ * Draws the screens a timeline shows, each composited once onto a `width`×`height` canvas the
80
+ * color of the page, the base frame fitted and centred as the player fits it, overlays over a scrim.
81
+ */
82
+ function createScreens(
83
+ graph: SceneGraph,
84
+ timeline: Timeline,
85
+ render: RenderFrame,
86
+ width: number,
87
+ height: number
88
+ ) {
89
+ const firstSegment = timeline.segments.at(0)
90
+ const startId = firstSegment?.kind === 'hold' ? firstSegment.session.frameId : null
91
+ const background = getPageColor(startId ? pageOf(graph, startId) : undefined)
92
+ const cache = new Map<string, RGBAImage>()
93
+
94
+ async function drawFrame(
95
+ target: RGBAImage,
96
+ frameId: string,
97
+ scale: number,
98
+ at: Vector,
99
+ source = graph
100
+ ) {
101
+ const image = await render(frameId, scale, source === graph ? undefined : source)
102
+ const node = source.getNode(frameId)
103
+ if (!image || !node) throw new Error(`'${node?.name ?? frameId}' could not be drawn`)
104
+ const box = source.getAbsoluteBounds(frameId)
105
+ // A shadow or a layer past the frame's edge widens what is drawn; the frame stays in place.
106
+ const content = computeContentBounds(source, [frameId]) ?? {
107
+ minX: box.x,
108
+ minY: box.y,
109
+ maxX: box.x + box.width,
110
+ maxY: box.y + box.height
111
+ }
112
+ drawOver(
113
+ target,
114
+ image,
115
+ Math.round(at.x + (content.minX - box.x) * scale),
116
+ Math.round(at.y + (content.minY - box.y) * scale)
117
+ )
118
+ }
119
+
120
+ /** The screen `session` shows, its base frame drawn from `base` when given. */
121
+ async function compose(session: PlaySession, base?: SceneGraph): Promise<RGBAImage> {
122
+ const target = filledImage(width, height, background)
123
+ const box = graph.getAbsoluteBounds(session.frameId)
124
+ const scale = Math.min(width / box.width, height / box.height)
125
+ const fitted: Rect = {
126
+ x: (width - box.width * scale) / 2,
127
+ y: (height - box.height * scale) / 2,
128
+ width: box.width * scale,
129
+ height: box.height * scale
130
+ }
131
+ await drawFrame(target, session.frameId, scale, fitted, base)
132
+ if (session.overlays.length > 0) dim(target, OVERLAY_SCRIM)
133
+ for (const overlayId of session.overlays) {
134
+ const overlay = graph.getAbsoluteBounds(overlayId)
135
+ const origin = overlayOrigin(
136
+ fitted,
137
+ overlay.width * scale,
138
+ overlay.height * scale,
139
+ timeline.overlayPositions[overlayId] ?? 'CENTER'
140
+ )
141
+ await drawFrame(target, overlayId, scale, origin)
142
+ }
143
+ return target
144
+ }
145
+
146
+ // The Smart animate being recorded, made once and posed for each of its frames.
147
+ let animating: { segment: TimelineSmartSegment; animation: SmartAnimation } | null = null
148
+
149
+ /** A Smart animate `progress` of the way through its time, drawn from its posed copy. */
150
+ async function animated(segment: TimelineSmartSegment, progress: number): Promise<RGBAImage> {
151
+ if (animating?.segment !== segment) {
152
+ const from = { graph, rootId: shownFrame(segment.from) }
153
+ const to = { graph, rootId: segment.to.frameId }
154
+ animating = { segment, animation: createSmartAnimation(from, to, segment.easing) }
155
+ }
156
+ animating.animation.seek(progress)
157
+ return compose(segment.to, animating.animation.graph)
158
+ }
159
+
160
+ async function screen(session: PlaySession): Promise<RGBAImage> {
161
+ const key = sessionDrawKey(session)
162
+ const cached = cache.get(key)
163
+ if (cached) {
164
+ // Most recently used last, so the oldest screen is the one dropped.
165
+ cache.delete(key)
166
+ cache.set(key, cached)
167
+ return cached
168
+ }
169
+ const drawn = await compose(session)
170
+ cache.set(key, drawn)
171
+ for (const old of cache.keys()) {
172
+ if (cache.size <= CACHED_SCREENS) break
173
+ cache.delete(old)
174
+ }
175
+ return drawn
176
+ }
177
+
178
+ return { screen, animated }
179
+ }
180
+
181
+ /**
182
+ * Records a planned timeline frame by frame at `fps` into `sink` and returns the file. Each screen
183
+ * is drawn once and reused while it holds, so a held screen reaches the sink as the same image; a
184
+ * crossfade blends its two screens per frame, and a Smart animate draws its animation posed at
185
+ * each frame, as the player poses it. Cancelling through `signal` stops before the next
186
+ * frame, and passing `maxBytes` stops with an error naming the limit.
187
+ */
188
+ export async function recordPrototype(
189
+ graph: SceneGraph,
190
+ timeline: Timeline,
191
+ render: RenderFrame,
192
+ sink: VideoSink,
193
+ options: RecordOptions
194
+ ): Promise<RecordResult> {
195
+ const { screen, animated } = createScreens(graph, timeline, render, options.width, options.height)
196
+ const frameMs = 1000 / options.fps
197
+ const frameCount = Math.max(1, Math.round(timeline.durationMs / frameMs))
198
+ try {
199
+ for (let index = 0; index < frameCount; index++) {
200
+ options.signal?.throwIfAborted()
201
+ // A clip that does not loop ends on its last screen, even one the flow leaves no time.
202
+ const last = index === frameCount - 1 && !timeline.loops
203
+ const shown = frameAt(timeline, last ? timeline.durationMs : index * frameMs)
204
+ let image: RGBAImage
205
+ if ('session' in shown) image = await screen(shown.session)
206
+ else if ('smart' in shown) image = await animated(shown.smart, shown.progress)
207
+ else image = crossfade(await screen(shown.from), await screen(shown.to), shown.mix)
208
+ await sink.add(image, index * frameMs, frameMs)
209
+ if (options.maxBytes !== undefined && sink.byteLength > options.maxBytes) {
210
+ throw new Error(
211
+ `The video passed ${Math.round(options.maxBytes / 1024 / 1024)} MB; lower the size or frame rate`
212
+ )
213
+ }
214
+ options.onProgress?.(index + 1, frameCount)
215
+ if ((index + 1) % FRAMES_PER_YIELD === 0) {
216
+ await new Promise<void>((resolve) => {
217
+ setTimeout(resolve, 0)
218
+ })
219
+ }
220
+ }
221
+ options.signal?.throwIfAborted()
222
+ return { bytes: await sink.finish(), frameCount }
223
+ } catch (error) {
224
+ await sink.cancel()
225
+ throw error
226
+ }
227
+ }
@@ -0,0 +1,32 @@
1
+ import type { RGBAImage } from '#core/io/formats/raster'
2
+
3
+ /** The video formats a prototype records to. */
4
+ export const VIDEO_FORMATS = ['mp4', 'gif', 'webm'] as const
5
+ export type VideoFormat = (typeof VIDEO_FORMATS)[number]
6
+
7
+ export const VIDEO_MIME_TYPES: Record<VideoFormat, string> = {
8
+ mp4: 'video/mp4',
9
+ gif: 'image/gif',
10
+ webm: 'video/webm'
11
+ }
12
+
13
+ export interface VideoSinkOptions {
14
+ width: number
15
+ height: number
16
+ fps: number
17
+ /** The clip ends where it started, so a GIF repeats forever. */
18
+ loops: boolean
19
+ }
20
+
21
+ /**
22
+ * Where recorded frames go: an encoder that takes them in time order and returns the file. A
23
+ * frame passed again as the same image is the screen held still, which a format may store once.
24
+ */
25
+ export interface VideoSink {
26
+ add(image: RGBAImage, timestampMs: number, durationMs: number): Promise<void>
27
+ finish(): Promise<Uint8Array>
28
+ /** Stops encoding without a file, releasing the encoder; recording calls it when it stops early. */
29
+ cancel(): Promise<void>
30
+ /** Bytes encoded so far, which the recorder caps. */
31
+ readonly byteLength: number
32
+ }
@@ -0,0 +1,25 @@
1
+ import type { Size } from '@pairdraw/scene-graph/primitives'
2
+
3
+ /** Bytes a recorded video may reach, as much as an MCP file transfer carries. */
4
+ export const MAX_VIDEO_BYTES = 64 * 1024 * 1024
5
+ /** The longest edge a recorded video may have. */
6
+ export const MAX_VIDEO_EDGE = 3840
7
+
8
+ /**
9
+ * The pixel size of a video of a `width`×`height` frame at `scale`, its long edge fitted into
10
+ * `maxEdge` without upscaling past `scale`. `even` rounds both sides up to even numbers, which
11
+ * H.264 and VP9 need for their half-resolution color planes.
12
+ */
13
+ export function videoSize(
14
+ width: number,
15
+ height: number,
16
+ options: { scale: number; maxEdge: number; even: boolean }
17
+ ): Size {
18
+ const maxEdge = Math.min(options.maxEdge, MAX_VIDEO_EDGE)
19
+ const scale = Math.min(options.scale, maxEdge / Math.max(width, height, 1))
20
+ const side = (value: number) => {
21
+ const pixels = Math.max(1, Math.round(value * scale))
22
+ return options.even ? pixels + (pixels % 2) : pixels
23
+ }
24
+ return { width: side(width), height: side(height) }
25
+ }
@@ -0,0 +1,89 @@
1
+ import {
2
+ BufferTarget,
3
+ canEncodeVideo,
4
+ Mp4OutputFormat,
5
+ Output,
6
+ QUALITY_HIGH,
7
+ VideoSample,
8
+ VideoSampleSource,
9
+ WebMOutputFormat
10
+ } from 'mediabunny'
11
+
12
+ import type { VideoFormat, VideoSink, VideoSinkOptions } from './sink'
13
+
14
+ /** The formats WebCodecs encodes: H.264 in MP4 and VP9 in WebM. */
15
+ export type EncodedVideoFormat = Exclude<VideoFormat, 'gif'>
16
+
17
+ const CODECS = { mp4: 'avc', webm: 'vp9' } as const satisfies Record<EncodedVideoFormat, string>
18
+
19
+ /** Seconds between key frames, so a player can seek without decoding the whole clip. */
20
+ const KEY_FRAME_INTERVAL = 2
21
+
22
+ /**
23
+ * Whether this engine can encode `format` at this size and frame rate: through WebCodecs in a
24
+ * browser or the desktop app's WebKit, or through an encoder registered with mediabunny.
25
+ */
26
+ export function canRecordVideo(
27
+ format: EncodedVideoFormat,
28
+ width: number,
29
+ height: number,
30
+ fps: number
31
+ ): Promise<boolean> {
32
+ return canEncodeVideo(CODECS[format], { width, height, frameRate: fps, quality: QUALITY_HIGH })
33
+ }
34
+
35
+ /**
36
+ * An MP4 (H.264) or WebM (VP9) encoder for recorded frames, at a constant frame rate. Adding a
37
+ * frame waits while the encoder is busy, so frames never pile up in memory. The file is kept in
38
+ * memory and returned whole; an MP4 puts its index first so it plays while it downloads.
39
+ */
40
+ export async function createWebCodecsSink(
41
+ format: EncodedVideoFormat,
42
+ options: VideoSinkOptions
43
+ ): Promise<VideoSink> {
44
+ const target = new BufferTarget()
45
+ const output = new Output({
46
+ format:
47
+ format === 'mp4' ? new Mp4OutputFormat({ fastStart: 'in-memory' }) : new WebMOutputFormat(),
48
+ target
49
+ })
50
+ let byteLength = 0
51
+ const source = new VideoSampleSource({
52
+ codec: CODECS[format],
53
+ quality: QUALITY_HIGH,
54
+ keyFrameInterval: KEY_FRAME_INTERVAL,
55
+ onEncodedPacket: (packet) => {
56
+ byteLength += packet.data.byteLength
57
+ }
58
+ })
59
+ output.addVideoTrack(source, { frameRate: options.fps })
60
+ await output.start()
61
+
62
+ return {
63
+ async add(image, timestampMs, durationMs) {
64
+ const sample = new VideoSample(image.data, {
65
+ format: 'RGBA',
66
+ codedWidth: image.width,
67
+ codedHeight: image.height,
68
+ timestamp: timestampMs / 1000,
69
+ duration: durationMs / 1000
70
+ })
71
+ try {
72
+ await source.add(sample)
73
+ } finally {
74
+ sample.close()
75
+ }
76
+ },
77
+ async finish() {
78
+ await output.finalize()
79
+ if (!target.buffer) throw new Error('The video encoder returned no file')
80
+ return new Uint8Array(target.buffer)
81
+ },
82
+ async cancel() {
83
+ if (output.state === 'started' || output.state === 'pending') await output.cancel()
84
+ },
85
+ get byteLength() {
86
+ return byteLength
87
+ }
88
+ }
89
+ }
package/src/io/formats.ts CHANGED
@@ -338,15 +338,22 @@ export const svgFormat: IOFormatAdapter<'svg'> = {
338
338
  mimeTypes: ['image/svg+xml'],
339
339
  support: EXPORT_EVERY_TARGET,
340
340
  exportOptions: { ...FIXED_SIZE_EXPORT, colorSpace: true },
341
- async exportContent(request, options?: SVGExportOptions) {
341
+ async exportContent(request, options?: SVGExportOptions, context?: IOContext) {
342
342
  const target = resolveExportNodes(request)
343
343
  if (!target) throw new Error('Nothing to export')
344
344
  const { renderNodesToLaidOutSVG } = await import('./formats/svg/text/layout')
345
+ const { booleanPathResolver, needsBooleanPaths } = await import('./formats/boolean-path')
346
+ // A boolean made in Pairdraw stores no result path; the export computes it from the operands.
347
+ const booleanPath = needsBooleanPaths(request.graph)
348
+ ? await booleanPathResolver(context?.canvasKit, context?.renderer)
349
+ : undefined
345
350
  const data = await renderNodesToLaidOutSVG(
346
351
  request.graph,
347
352
  target.pageId,
348
353
  target.nodeIds,
349
- options
354
+ { ...options, booleanPath },
355
+ context?.canvasKit,
356
+ context?.renderer
350
357
  )
351
358
  if (!data) throw new Error('Nothing to export')
352
359
  return {
@@ -398,11 +405,19 @@ export const pdfFormat: IOFormatAdapter<'pdf'> = {
398
405
  mimeTypes: ['application/pdf'],
399
406
  support: EXPORT_EVERY_TARGET,
400
407
  exportOptions: FIXED_SIZE_EXPORT,
401
- async exportContent(request, options?: PDFFormatExportOptions) {
408
+ async exportContent(request, options?: PDFFormatExportOptions, context?: IOContext) {
402
409
  const specs = await pdfPageSpecs(request, options)
403
410
  // Embedded, as Figma embeds every face its PDFs draw.
404
411
  const { exportPDFDocument } = await import('./formats/pdf/document')
405
- const data = (await exportPDFDocument(request.graph, specs, { embedFonts: true }))?.data
412
+ const data = (
413
+ await exportPDFDocument(
414
+ request.graph,
415
+ specs,
416
+ { embedFonts: true },
417
+ context?.canvasKit,
418
+ context?.renderer
419
+ )
420
+ )?.data
406
421
  if (!data) throw new Error('Nothing to export')
407
422
  return {
408
423
  format: 'pdf',
@@ -462,13 +477,39 @@ export const jsxFormat: IOFormatAdapter<'jsx'> = {
462
477
  mimeTypes: ['text/plain', 'text/jsx'],
463
478
  support: EXPORT_EVERY_TARGET,
464
479
  exportOptions: FIXED_SIZE_EXPORT,
465
- async exportContent(request): Promise<ExportResult> {
480
+ async exportContent(request, _options?: unknown, context?: IOContext): Promise<ExportResult> {
466
481
  const nodeId = ensureSingleNode(request.target)
467
482
  // A page or a document exports its top-level layers, as Tailwind JSX does.
468
483
  const target = nodeId ? null : resolveExportNodes(request)
484
+ const { booleanPathResolver, needsBooleanPaths } = await import('./formats/boolean-path')
485
+ const authored = needsBooleanPaths(request.graph)
486
+ ? [...request.graph.getAllNodes()].filter(
487
+ (node) => node.type === 'BOOLEAN_OPERATION' && node.fillGeometry.length === 0
488
+ )
489
+ : []
490
+ const restore: (() => void)[] = []
491
+ if (authored.length > 0) {
492
+ const { parseSVGPath } = await import('@pairdraw/scene-graph/parse-path')
493
+ const booleanPath = await booleanPathResolver(context?.canvasKit, context?.renderer)
494
+ for (const node of authored) {
495
+ const d = booleanPath(request.graph, node)
496
+ if (!d) continue
497
+ const network = parseSVGPath(d, 'EVENODD', { includeOpenRegions: true })
498
+ const carrier = node as typeof node & { vectorNetwork?: typeof network }
499
+ const previous = carrier.vectorNetwork
500
+ carrier.vectorNetwork = network
501
+ restore.push(() => {
502
+ carrier.vectorNetwork = previous
503
+ })
504
+ }
505
+ }
469
506
  let data = ''
470
- if (nodeId) data = sceneNodeToJSX(nodeId, request.graph)
471
- else if (target) data = selectionToJSX(target.nodeIds, request.graph)
507
+ try {
508
+ if (nodeId) data = sceneNodeToJSX(nodeId, request.graph)
509
+ else if (target) data = selectionToJSX(target.nodeIds, request.graph)
510
+ } finally {
511
+ for (const undo of restore) undo()
512
+ }
472
513
  if (!data) throw new Error('Nothing to export')
473
514
  return {
474
515
  format: 'jsx',
@@ -489,7 +530,7 @@ export const htmlFormat: IOFormatAdapter<'html'> = {
489
530
  mimeTypes: ['text/html'],
490
531
  support: EXPORT_EVERY_TARGET,
491
532
  exportOptions: FIXED_SIZE_EXPORT,
492
- async exportContent(request, options?: HTMLExportOptions) {
533
+ async exportContent(request, options?: HTMLExportOptions, context?: IOContext) {
493
534
  const target = resolveExportNodes(request)
494
535
  if (!target) throw new Error('Nothing to export')
495
536
  const { renderNodesToHTML } = await import('./formats/html')
@@ -497,7 +538,8 @@ export const htmlFormat: IOFormatAdapter<'html'> = {
497
538
  request.graph,
498
539
  target.nodeIds,
499
540
  options,
500
- request.fileName
541
+ request.fileName,
542
+ context
501
543
  )
502
544
  return {
503
545
  format: 'html',
@@ -519,12 +561,18 @@ export const tailwindJSXFormat: IOFormatAdapter<'tailwind-jsx'> = {
519
561
  mimeTypes: ['text/plain', 'text/jsx'],
520
562
  support: EXPORT_EVERY_TARGET,
521
563
  exportOptions: FIXED_SIZE_EXPORT,
522
- async exportContent(request) {
564
+ async exportContent(request, _options?: unknown, context?: IOContext) {
523
565
  const target = resolveExportNodes(request)
524
566
  if (!target) throw new Error('Nothing to export')
525
567
  const { sceneNodesToTailwindJSX } = await import('@pairdraw/dom-css/export')
526
568
  const { vectorElement } = await import('#core/io/formats/html/vectors')
527
- const data = sceneNodesToTailwindJSX(request.graph, target.nodeIds, { vectorElement })
569
+ const { booleanPathResolver, needsBooleanPaths } = await import('./formats/boolean-path')
570
+ const booleanPath = needsBooleanPaths(request.graph)
571
+ ? await booleanPathResolver(context?.canvasKit, context?.renderer)
572
+ : undefined
573
+ const data = sceneNodesToTailwindJSX(request.graph, target.nodeIds, {
574
+ vectorElement: (graph, node) => vectorElement(graph, node, booleanPath)
575
+ })
528
576
  if (!data) throw new Error('Nothing to export')
529
577
  return {
530
578
  format: 'tailwind-jsx',
package/src/io/types.ts CHANGED
@@ -44,16 +44,35 @@ export interface ReadDocumentInput {
44
44
  }
45
45
 
46
46
  /** Something a document names that reading it could not bring in; it opens without it. */
47
- export interface ReadDocumentWarning {
48
- kind: 'unresolved-imports'
49
- /**
50
- * Why: the host gives no access to files beside the document, as a browser does, or the files
51
- * could not be read or are not documents of the format.
52
- */
53
- reason: 'no-file-access' | 'unreadable'
54
- /** The paths the document names them with. */
55
- paths: string[]
56
- }
47
+ export type ReadDocumentWarning =
48
+ | {
49
+ kind: 'unresolved-imports'
50
+ /**
51
+ * Why: the host gives no access to files beside the document, as a browser does, or the
52
+ * files could not be read or are not documents of the format.
53
+ */
54
+ reason: 'no-file-access' | 'unreadable'
55
+ /** The paths the document names them with. */
56
+ paths: string[]
57
+ }
58
+ | {
59
+ /** Variables a document references that it does not define, which read as their fallbacks. */
60
+ kind: 'unknown-variable'
61
+ /** The variable names as the document writes them, without the `$`. */
62
+ names: string[]
63
+ }
64
+ | {
65
+ /** Image files a paint names that the host opened the document without. */
66
+ kind: 'missing-image'
67
+ /** The URLs as the document writes them. */
68
+ urls: string[]
69
+ }
70
+ | {
71
+ /** Node types this reader does not know, which read as placeholder frames. */
72
+ kind: 'unknown-node'
73
+ /** The type names as the document writes them. */
74
+ types: string[]
75
+ }
57
76
 
58
77
  export interface ReadDocumentResult {
59
78
  graph: SceneGraph