@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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/pairdraw-api/index.ts"],"sourcesContent":["import type { VariableLiteral } from '@pairdraw/scene-graph'\nimport {\n BEHAVIOUR_CONTRACTS,\n BEHAVIOUR_KINDS,\n type BehaviourKind,\n type BehaviourSpec\n} from '@pairdraw/scene-graph/behaviours'\nimport type { OkHCLColor, OkHCLPayload } from '@pairdraw/scene-graph/color'\nimport { parseVariableFormula } from '@pairdraw/scene-graph/variables'\n\nimport { exposeInstanceSwap } from '#core/figma-api/components'\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api/index'\nimport { writeVariableValue } from '#core/figma-api/variables'\nimport { documentFontStatus, type DocumentFontStatus } from '#core/text/font/status'\n\nimport {\n getBehaviour,\n makeSlot,\n nodeOf,\n setBehaviour,\n type BehaviourHandle,\n type NodeRef\n} from './behaviours'\nimport {\n addComment,\n getComment,\n getComments,\n type CommentFilter,\n type CommentHandle,\n type NewComment\n} from './comments'\nimport {\n readFillOkHCL,\n readLayoutDirection,\n readStrokeOkHCL,\n readTextDirection,\n writeFillOkHCL,\n writeLayoutDirection,\n writeStrokeOkHCL,\n writeTextDirection\n} from './nodes'\nimport { getStatus, listStatuses, setStatus, type StatusInfo } from './statuses'\nimport { bindVariable, unbindVariable, type VariableRef } from './variables'\n\nexport { BehaviourHandle, type NodeRef } from './behaviours'\nexport type { StatusInfo } from './statuses'\nexport type { VariableRef } from './variables'\nexport {\n CommentHandle,\n DEFAULT_COMMENT_AUTHOR,\n type CommentFilter,\n type NewComment\n} from './comments'\n\n/**\n * What Pairdraw adds to the Figma Plugin API for scripts, as the `pairdraw` global next to\n * `figma`: features Figma has no API for, in the same style. It edits the same document as the\n * `figma` it is made for.\n */\nexport class PairdrawAPI {\n constructor(private readonly figma: FigmaAPI) {}\n\n /**\n * Set a token formula by collection, variable and optional mode names. References use\n * `{variable/name}` or `{Collection::variable/name}` and persist by ID; a true/false formula\n * can compare numbers, as in `{width} > 600 and not {loading}`, and `if()`, `text()` and\n * `truthy()` pick values, write text, and test text or numbers, as in\n * `if({compact}, \"Hi\", \"Hello, \" + {name})`.\n */\n setVariableFormula(\n collectionName: string,\n variableName: string,\n source: string,\n modeName?: string\n ): VariableLiteral {\n const graph = this.figma.graph\n const collections = [...graph.variableCollections.values()].filter(\n (item) => item.name === collectionName\n )\n const collection = collections.at(0)\n if (!collection || collections.length !== 1)\n throw new Error(`Unknown or ambiguous collection: ${collectionName}`)\n const variables = [...graph.variables.values()].filter(\n (item) => item.collectionId === collection.id && item.name === variableName\n )\n const variable = variables.at(0)\n if (!variable || variables.length !== 1)\n throw new Error(`Unknown or ambiguous variable: ${variableName}`)\n const modes = collection.modes.filter((mode) =>\n modeName ? mode.name === modeName : mode.modeId === collection.defaultModeId\n )\n const mode = modes.at(0)\n if (!mode || modes.length !== 1) throw new Error(`Unknown or ambiguous mode: ${modeName}`)\n const { value, resolved } = parseVariableFormula(graph, variable.id, mode.modeId, source)\n writeVariableValue(graph, variable, mode.modeId, value)\n return resolved\n }\n\n /**\n * Bind a layer field to a variable from `figma.variables`, as the layer panel does:\n * fields by Pairdraw's names, such as `'text'`, `'visible'`, `'opacity'` or `'fills/0/color'`.\n * Text content takes a text or number variable, a number shown as text; visibility takes a\n * boolean, or text that shows the layer unless it is empty or reads false, no or off.\n */\n bindVariable(node: NodeRef, field: string, variable: VariableRef): void {\n bindVariable(this.figma.graph, node, field, variable)\n }\n\n /** Let a layer field go of its variable, keeping the value the variable last gave it. */\n unbindVariable(node: NodeRef, field: string): void {\n unbindVariable(this.figma.graph, node, field)\n }\n\n /** The behaviour kinds, after Reka UI's primitives, with the values and parts each binds. */\n get behaviourKinds() {\n return BEHAVIOUR_KINDS.map((kind) => ({ kind, ...structuredClone(BEHAVIOUR_CONTRACTS[kind]) }))\n }\n\n /** The behaviour a node's main component keeps, or null; a variant reads its set's. */\n getBehaviour(node: NodeRef): BehaviourHandle | null {\n return getBehaviour(this.figma.graph, node)\n }\n\n /**\n * Give a main component or component set a behaviour, replacing any it has: a kind alone, or\n * a spec naming its properties and slots, such as\n * `{ kind: 'switch', values: { value: 'State' }, parts: { thumb: 'Thumb' }, states: 'Interaction' }`.\n */\n setBehaviour(node: NodeRef, spec: BehaviourKind | BehaviourSpec): BehaviourHandle {\n return setBehaviour(this.figma.graph, node, spec)\n }\n\n /** Make a frame of a main component a slot, as Create slot does; returns the slot's name. */\n createSlot(frame: NodeRef): string {\n return makeSlot(this.figma.graph, frame)\n }\n\n /**\n * The document's comment threads, oldest first: all of them, or only resolved or open ones,\n * one page's, or those a person started or replied to, such as `{ resolved: false }`.\n */\n getComments(filter?: CommentFilter): CommentHandle[] {\n return getComments(this.figma.graph, filter)\n }\n\n getComment(id: string): CommentHandle | null {\n return getComment(this.figma.graph, id)\n }\n\n /**\n * Leave a comment pinned on a layer, `{ node }`, which it then follows, or at a point of a\n * page, `{ page, x, y }`; the current page by default. `author` names who wrote it.\n */\n addComment(text: string, options?: NewComment): CommentHandle {\n return addComment(this.figma.graph, this.figma.currentPageId, text, options)\n }\n\n /**\n * The document's statuses, such as Ready for dev or the team's own Approved, with each one's\n * color and the status Figma shows for it, if any.\n */\n get statuses(): StatusInfo[] {\n return listStatuses(this.figma.graph)\n }\n\n /** The name of the status a section, frame, component, set or instance shows, or null. */\n getStatus(node: NodeRef): string | null {\n return getStatus(this.figma.graph, node)\n }\n\n /**\n * Give a layer one of the document's statuses by name, or clear it with null. Only sections,\n * frames, components, sets and instances directly on a page or in a section take one.\n */\n setStatus(node: NodeRef, status: string | null): void {\n setStatus(this.figma.graph, node, status)\n }\n\n /**\n * Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;\n * returns the layer that holds the property.\n */\n exposeInstanceSwap(\n instances: readonly NodeRef[],\n candidates: readonly NodeRef[],\n propertyName = 'Instance'\n ): FigmaNodeProxy {\n const proxies = (refs: readonly NodeRef[]) =>\n refs.map((ref) => this.figma.wrapNode(nodeOf(this.figma.graph, ref).id))\n const host = exposeInstanceSwap(\n this.figma.graph,\n proxies(instances),\n proxies(candidates),\n propertyName\n )\n return this.figma.wrapNode(host.id)\n }\n\n /**\n * Whether the current page's fonts are faithfully available: requested faces, where each\n * loaded from, substitutions, why an installed face could not load, and the layers affected.\n */\n getFontStatus(): DocumentFontStatus {\n return documentFontStatus(this.figma.graph, this.figma.currentPageId)\n }\n\n /** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */\n getFillOkHCL(node: NodeRef, index = 0): OkHCLPayload | null {\n return readFillOkHCL(this.figma.graph, node, index)\n }\n\n /** Set a fill's color in OkHCL; its RGB follows in the document's color space. */\n setFillOkHCL(node: NodeRef, color: OkHCLColor, index = 0): void {\n writeFillOkHCL(this.figma.graph, node, color, index)\n }\n\n getStrokeOkHCL(node: NodeRef, index = 0): OkHCLPayload | null {\n return readStrokeOkHCL(this.figma.graph, node, index)\n }\n\n setStrokeOkHCL(node: NodeRef, color: OkHCLColor, index = 0): void {\n writeStrokeOkHCL(this.figma.graph, node, color, index)\n }\n\n /** Which way a frame's auto layout runs: `AUTO`, `LTR` or `RTL`. */\n getLayoutDirection(node: NodeRef): string {\n return readLayoutDirection(this.figma.graph, node)\n }\n\n setLayoutDirection(node: NodeRef, direction: string): void {\n writeLayoutDirection(this.figma.graph, node, direction)\n }\n\n /** Which way a text runs: `AUTO`, `LTR` or `RTL`. */\n getTextDirection(node: NodeRef): string {\n return readTextDirection(this.figma.graph, node)\n }\n\n setTextDirection(node: NodeRef, direction: string): void {\n writeTextDirection(this.figma.graph, node, direction)\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/pairdraw-api/index.ts"],"sourcesContent":["import type { VariableLiteral } from '@pairdraw/scene-graph'\nimport {\n BEHAVIOUR_CONTRACTS,\n BEHAVIOUR_KINDS,\n type BehaviourKind,\n type BehaviourSpec\n} from '@pairdraw/scene-graph/behaviours'\nimport type { OkHCLColor, OkHCLPayload } from '@pairdraw/scene-graph/color'\nimport type { DesignMemoryGroup } from '@pairdraw/scene-graph/design-memory'\nimport { parseVariableFormula } from '@pairdraw/scene-graph/variables'\n\nimport {\n describeDesignMemory,\n type DesignMemoryReport,\n type DesignValueVerdict\n} from '#core/design-memory'\nimport { exposeInstanceSwap } from '#core/figma-api/components'\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api/index'\nimport { writeVariableValue } from '#core/figma-api/variables'\nimport { documentFontStatus, type DocumentFontStatus } from '#core/text/font/status'\n\nimport {\n getBehaviour,\n makeSlot,\n nodeOf,\n setBehaviour,\n type BehaviourHandle,\n type NodeRef\n} from './behaviours'\nimport {\n addComment,\n getComment,\n getComments,\n type CommentFilter,\n type CommentHandle,\n type NewComment\n} from './comments'\nimport { checkProposedDesignValues, recordDesignDecision } from './design-memory'\nimport {\n readFillOkHCL,\n readLayoutDirection,\n readStrokeOkHCL,\n readTextDirection,\n writeFillOkHCL,\n writeFontFeatures,\n writeLayoutDirection,\n writeRangeFontFeatures,\n writeStrokeOkHCL,\n writeTextDirection\n} from './nodes'\nimport { getStatus, listStatuses, setStatus, type StatusInfo } from './statuses'\nimport { bindVariable, unbindVariable, type VariableRef } from './variables'\nimport {\n createVariationSet,\n getVariationSet,\n listVariationSets,\n type VariationSetHandle\n} from './variations'\n\nexport { BehaviourHandle, type NodeRef } from './behaviours'\nexport type { StatusInfo } from './statuses'\nexport type { VariableRef } from './variables'\nexport { VariationSetHandle, type VariationSetInfo } from './variations'\nexport {\n CommentHandle,\n DEFAULT_COMMENT_AUTHOR,\n type CommentFilter,\n type NewComment\n} from './comments'\n\n/**\n * What Pairdraw adds to the Figma Plugin API for scripts, as the `pairdraw` global next to\n * `figma`: features Figma has no API for, in the same style. It edits the same document as the\n * `figma` it is made for.\n */\nexport class PairdrawAPI {\n constructor(private readonly figma: FigmaAPI) {}\n\n /**\n * Set a token formula by collection, variable and optional mode names. References use\n * `{variable/name}` or `{Collection::variable/name}` and persist by ID; a true/false formula\n * can compare numbers, as in `{width} > 600 and not {loading}`, and `if()`, `text()` and\n * `truthy()` pick values, write text, and test text or numbers, as in\n * `if({compact}, \"Hi\", \"Hello, \" + {name})`.\n */\n setVariableFormula(\n collectionName: string,\n variableName: string,\n source: string,\n modeName?: string\n ): VariableLiteral {\n const graph = this.figma.graph\n const collections = [...graph.variableCollections.values()].filter(\n (item) => item.name === collectionName\n )\n const collection = collections.at(0)\n if (!collection || collections.length !== 1)\n throw new Error(`Unknown or ambiguous collection: ${collectionName}`)\n const variables = [...graph.variables.values()].filter(\n (item) => item.collectionId === collection.id && item.name === variableName\n )\n const variable = variables.at(0)\n if (!variable || variables.length !== 1)\n throw new Error(`Unknown or ambiguous variable: ${variableName}`)\n const modes = collection.modes.filter((mode) =>\n modeName ? mode.name === modeName : mode.modeId === collection.defaultModeId\n )\n const mode = modes.at(0)\n if (!mode || modes.length !== 1) throw new Error(`Unknown or ambiguous mode: ${modeName}`)\n const { value, resolved } = parseVariableFormula(graph, variable.id, mode.modeId, source)\n writeVariableValue(graph, variable, mode.modeId, value)\n return resolved\n }\n\n /**\n * Bind a layer field to a variable from `figma.variables`, as the layer panel does:\n * fields by Pairdraw's names, such as `'text'`, `'visible'`, `'opacity'` or `'fills/0/color'`.\n * Text content takes a text or number variable, a number shown as text; visibility takes a\n * boolean, or text that shows the layer unless it is empty or reads false, no or off.\n */\n bindVariable(node: NodeRef, field: string, variable: VariableRef): void {\n bindVariable(this.figma.graph, node, field, variable)\n }\n\n /** Let a layer field go of its variable, keeping the value the variable last gave it. */\n unbindVariable(node: NodeRef, field: string): void {\n unbindVariable(this.figma.graph, node, field)\n }\n\n /** The behaviour kinds, after Reka UI's primitives, with the values and parts each binds. */\n get behaviourKinds() {\n return BEHAVIOUR_KINDS.map((kind) => ({ kind, ...structuredClone(BEHAVIOUR_CONTRACTS[kind]) }))\n }\n\n /** The behaviour a node's main component keeps, or null; a variant reads its set's. */\n getBehaviour(node: NodeRef): BehaviourHandle | null {\n return getBehaviour(this.figma.graph, node)\n }\n\n /**\n * Give a main component or component set a behaviour, replacing any it has: a kind alone, or\n * a spec naming its properties and slots, such as\n * `{ kind: 'switch', values: { value: 'State' }, parts: { thumb: 'Thumb' }, states: 'Interaction' }`.\n */\n setBehaviour(node: NodeRef, spec: BehaviourKind | BehaviourSpec): BehaviourHandle {\n return setBehaviour(this.figma.graph, node, spec)\n }\n\n /** Make a frame of a main component a slot, as Create slot does; returns the slot's name. */\n createSlot(frame: NodeRef): string {\n return makeSlot(this.figma.graph, frame)\n }\n\n /**\n * The document's comment threads, oldest first: all of them, or only resolved or open ones,\n * one page's, or those a person started or replied to, such as `{ resolved: false }`.\n */\n getComments(filter?: CommentFilter): CommentHandle[] {\n return getComments(this.figma.graph, filter)\n }\n\n getComment(id: string): CommentHandle | null {\n return getComment(this.figma.graph, id)\n }\n\n /**\n * Leave a comment pinned on a layer, `{ node }`, which it then follows, or at a point of a\n * page, `{ page, x, y }`; the current page by default. `author` names who wrote it.\n */\n addComment(text: string, options?: NewComment): CommentHandle {\n return addComment(this.figma.graph, this.figma.currentPageId, text, options)\n }\n\n /**\n * The document's statuses, such as Ready for dev or the team's own Approved, with each one's\n * color and the status Figma shows for it, if any.\n */\n get statuses(): StatusInfo[] {\n return listStatuses(this.figma.graph)\n }\n\n /** The name of the status a section, frame, component, set or instance shows, or null. */\n getStatus(node: NodeRef): string | null {\n return getStatus(this.figma.graph, node)\n }\n\n /**\n * Give a layer one of the document's statuses by name, or clear it with null. Only sections,\n * frames, components, sets and instances directly on a page or in a section take one.\n */\n setStatus(node: NodeRef, status: string | null): void {\n setStatus(this.figma.graph, node, status)\n }\n\n /**\n * The document's design memory: the colors, fonts, sizes, spacing and radii agents may use,\n * whether an off-system value is refused or warned about, the decisions written down, and the\n * layers pinned as examples. Null when the document has none.\n */\n get designMemory(): DesignMemoryReport | null {\n return describeDesignMemory(this.figma.graph)\n }\n\n /**\n * Judge values before using them, such as `{ colors: ['#FF00AA'], spacing: [13] }`: each comes\n * back `ok`, `warn`, `refuse` or `invalid`, with the nearest allowed value.\n */\n checkDesignValues(\n proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>\n ): DesignValueVerdict[] {\n return checkProposedDesignValues(this.figma.graph, proposal)\n }\n\n /**\n * Write a decision down in the design memory, optionally pinning a layer that shows it as an\n * example. The memory's allowed values stay as the person set them.\n */\n recordDesignDecision(text: string, example?: NodeRef): { decisions: number; examples: number } {\n return recordDesignDecision(this.figma.graph, text, example)\n }\n\n /**\n * Copy a layer `count` times (1 to 8) into a section of variations beside it, made the first\n * time; `labels` name what each version tries, as in `V2 · Calmer palette`. On a version, it\n * copies that version into its set. The original does not change.\n */\n createVariations(\n node: NodeRef,\n options: { count: number; labels?: readonly string[] }\n ): { set: VariationSetHandle; versions: FigmaNodeProxy[] } {\n const { set, created } = createVariationSet(this.figma, node, options)\n return { set, versions: created }\n }\n\n /** The set of variations a layer belongs to, from its section, a version or a layer inside one. */\n getVariations(node: NodeRef): VariationSetHandle | null {\n return getVariationSet(this.figma, node)\n }\n\n /** The sets of variations on the current page. */\n get variations(): VariationSetHandle[] {\n return listVariationSets(this.figma, this.figma.currentPageId)\n }\n\n /**\n * Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;\n * returns the layer that holds the property.\n */\n exposeInstanceSwap(\n instances: readonly NodeRef[],\n candidates: readonly NodeRef[],\n propertyName = 'Instance'\n ): FigmaNodeProxy {\n const proxies = (refs: readonly NodeRef[]) =>\n refs.map((ref) => this.figma.wrapNode(nodeOf(this.figma.graph, ref).id))\n const host = exposeInstanceSwap(\n this.figma.graph,\n proxies(instances),\n proxies(candidates),\n propertyName\n )\n return this.figma.wrapNode(host.id)\n }\n\n /**\n * Whether the current page's fonts are faithfully available: requested faces, where each\n * loaded from, substitutions, why an installed face could not load, and the layers affected.\n */\n getFontStatus(): DocumentFontStatus {\n return documentFontStatus(this.figma.graph, this.figma.currentPageId)\n }\n\n /** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */\n getFillOkHCL(node: NodeRef, index = 0): OkHCLPayload | null {\n return readFillOkHCL(this.figma.graph, node, index)\n }\n\n /** Set a fill's color in OkHCL; its RGB follows in the document's color space. */\n setFillOkHCL(node: NodeRef, color: OkHCLColor, index = 0): void {\n writeFillOkHCL(this.figma.graph, node, color, index)\n }\n\n getStrokeOkHCL(node: NodeRef, index = 0): OkHCLPayload | null {\n return readStrokeOkHCL(this.figma.graph, node, index)\n }\n\n setStrokeOkHCL(node: NodeRef, color: OkHCLColor, index = 0): void {\n writeStrokeOkHCL(this.figma.graph, node, color, index)\n }\n\n /** Which way a frame's auto layout runs: `AUTO`, `LTR` or `RTL`. */\n getLayoutDirection(node: NodeRef): string {\n return readLayoutDirection(this.figma.graph, node)\n }\n\n setLayoutDirection(node: NodeRef, direction: string): void {\n writeLayoutDirection(this.figma.graph, node, direction)\n }\n\n /** Which way a text runs: `AUTO`, `LTR` or `RTL`. */\n getTextDirection(node: NodeRef): string {\n return readTextDirection(this.figma.graph, node)\n }\n\n setTextDirection(node: NodeRef, direction: string): void {\n writeTextDirection(this.figma.graph, node, direction)\n }\n\n /** Merges OpenType feature toggles into the text's own, keeping the tags it does not name. */\n setFontFeatures(node: NodeRef, features: Record<string, boolean>): void {\n writeFontFeatures(this.figma.graph, node, features)\n }\n\n /** Merges OpenType feature toggles into a text range's own, keeping its other features. */\n setRangeFontFeatures(\n node: NodeRef,\n start: number,\n end: number,\n features: Record<string, boolean>\n ): void {\n writeRangeFontFeatures(this.figma.graph, node, start, end, features)\n }\n}\n"],"mappings":"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"}
@@ -11,6 +11,17 @@ declare function readLayoutDirection(graph: SceneGraph, ref: NodeRef): LayoutDir
11
11
  declare function writeLayoutDirection(graph: SceneGraph, ref: NodeRef, value: string): void;
12
12
  declare function readTextDirection(graph: SceneGraph, ref: NodeRef): TextDirection;
13
13
  declare function writeTextDirection(graph: SceneGraph, ref: NodeRef, value: string): void;
14
+ /**
15
+ * Merges OpenType features into a text's own: the given tags replace their entries, the rest
16
+ * stay, as the panel's feature switches do. Figma's plugin API only reads a node's features;
17
+ * this is the write path the tools and the panel share.
18
+ */
19
+ declare function writeFontFeatures(graph: SceneGraph, ref: NodeRef, features: Record<string, boolean>): void;
20
+ /**
21
+ * Merges OpenType features into a text range's own, keeping the features its characters already
22
+ * had. Figma's plugin API has no range feature setter, so this lives on `pairdraw`.
23
+ */
24
+ declare function writeRangeFontFeatures(graph: SceneGraph, ref: NodeRef, start: number, end: number, features: Record<string, boolean>): void;
14
25
  //#endregion
15
- export { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeLayoutDirection, writeStrokeOkHCL, writeTextDirection };
26
+ export { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeFontFeatures, writeLayoutDirection, writeRangeFontFeatures, writeStrokeOkHCL, writeTextDirection };
16
27
  //# sourceMappingURL=nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/pairdraw-api/nodes.ts"],"mappings":";;;;iBAmCgB,cAAc,OAAO,YAAY,KAAK,SAAS,gBAAgB;iBAI/D,eACd,OAAO,YACP,KAAK,SACL,OAAO,YACP;iBAMc,gBACd,OAAO,YACP,KAAK,SACL,gBACC;iBAIa,iBACd,OAAO,YACP,KAAK,SACL,OAAO,YACP;;iBAOc,oBAAoB,OAAO,YAAY,KAAK,UAAU;iBAKtD,qBAAqB,OAAO,YAAY,KAAK,SAAS;iBAItD,kBAAkB,OAAO,YAAY,KAAK,UAAU;iBAIpD,mBAAmB,OAAO,YAAY,KAAK,SAAS"}
1
+ {"version":3,"file":"nodes.d.ts","names":[],"sources":["../../src/pairdraw-api/nodes.ts"],"mappings":";;;;iBAsCgB,cAAc,OAAO,YAAY,KAAK,SAAS,gBAAgB;iBAI/D,eACd,OAAO,YACP,KAAK,SACL,OAAO,YACP;iBAMc,gBACd,OAAO,YACP,KAAK,SACL,gBACC;iBAIa,iBACd,OAAO,YACP,KAAK,SACL,OAAO,YACP;;iBAOc,oBAAoB,OAAO,YAAY,KAAK,UAAU;iBAKtD,qBAAqB,OAAO,YAAY,KAAK,SAAS;iBAItD,kBAAkB,OAAO,YAAY,KAAK,UAAU;iBAIpD,mBAAmB,OAAO,YAAY,KAAK,SAAS;;;;;;iBASpD,kBACd,OAAO,YACP,KAAK,SACL,UAAU;;;;;iBAcI,uBACd,OAAO,YACP,KAAK,SACL,eACA,aACA,UAAU"}
@@ -1,5 +1,8 @@
1
+ import { styleRunsWithPatch } from "../text/character-style.js";
1
2
  import { assertNodeEditable } from "../editor/capabilities.js";
3
+ import { assertTextRange } from "../figma-api/text/style.js";
2
4
  import { nodeOf } from "./behaviours.js";
5
+ import { openTypeFeaturesPatch } from "../figma-api/accessors/text/opentype.js";
3
6
  import { getFillOkHCL, getStrokeOkHCL, setNodeFillOkHCL, setNodeStrokeOkHCL } from "@pairdraw/scene-graph/color";
4
7
  import { isEqual } from "es-toolkit/predicate";
5
8
  import { recordInstanceOverride } from "@pairdraw/scene-graph/instances";
@@ -48,7 +51,31 @@ function readTextDirection(graph, ref) {
48
51
  function writeTextDirection(graph, ref, value) {
49
52
  editNode(graph, nodeOf(graph, ref), { textDirection: direction(value) });
50
53
  }
54
+ /**
55
+ * Merges OpenType features into a text's own: the given tags replace their entries, the rest
56
+ * stay, as the panel's feature switches do. Figma's plugin API only reads a node's features;
57
+ * this is the write path the tools and the panel share.
58
+ */
59
+ function writeFontFeatures(graph, ref, features) {
60
+ const node = nodeOf(graph, ref);
61
+ const merged = new Map(node.fontFeatures.map((feature) => [feature.tag, feature.enabled]));
62
+ for (const [tag, enabled] of Object.entries(features)) merged.set(tag.toUpperCase(), enabled);
63
+ editNode(graph, node, { fontFeatures: [...merged].map(([tag, enabled]) => ({
64
+ tag,
65
+ enabled
66
+ })) });
67
+ }
68
+ /**
69
+ * Merges OpenType features into a text range's own, keeping the features its characters already
70
+ * had. Figma's plugin API has no range feature setter, so this lives on `pairdraw`.
71
+ */
72
+ function writeRangeFontFeatures(graph, ref, start, end, features) {
73
+ const node = nodeOf(graph, ref);
74
+ assertTextRange("setRangeFontFeatures", node, start, end);
75
+ const patch = openTypeFeaturesPatch("setRangeFontFeatures", node, start, features);
76
+ editNode(graph, node, { styleRuns: styleRunsWithPatch(node, start, end, patch) });
77
+ }
51
78
  //#endregion
52
- export { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeLayoutDirection, writeStrokeOkHCL, writeTextDirection };
79
+ export { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeFontFeatures, writeLayoutDirection, writeRangeFontFeatures, writeStrokeOkHCL, writeTextDirection };
53
80
 
54
81
  //# sourceMappingURL=nodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","names":[],"sources":["../../src/pairdraw-api/nodes.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { LayoutDirection, SceneGraph, SceneNode, TextDirection } from '@pairdraw/scene-graph'\nimport {\n getFillOkHCL,\n getStrokeOkHCL,\n setNodeFillOkHCL,\n setNodeStrokeOkHCL,\n type OkHCLColor,\n type OkHCLPayload\n} from '@pairdraw/scene-graph/color'\nimport { recordInstanceOverride } from '@pairdraw/scene-graph/instances'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const\n\n/** Writes a layer's fields as a script edit does: an instance's layer claims what changed. */\nfunction editNode(graph: SceneGraph, node: SceneNode, changes: Partial<SceneNode>): void {\n assertNodeEditable(graph, node.id)\n const changed = Object.keys(changes).filter(\n (key) => !isEqual(Reflect.get(changes, key), Reflect.get(node, key))\n )\n graph.updateNode(node.id, changes)\n recordInstanceOverride(graph, node.id, changed)\n}\n\nfunction direction(value: string): LayoutDirection & TextDirection {\n if (!(DIRECTIONS as readonly string[]).includes(value))\n throw new Error(`Unknown direction ${value}; use ${DIRECTIONS.join(', ')}`)\n return value as LayoutDirection & TextDirection\n}\n\nexport function readFillOkHCL(graph: SceneGraph, ref: NodeRef, index: number): OkHCLPayload | null {\n return getFillOkHCL(nodeOf(graph, ref), index)\n}\n\nexport function writeFillOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n color: OkHCLColor,\n index: number\n): void {\n const node = nodeOf(graph, ref)\n editNode(graph, node, setNodeFillOkHCL(node, index, color, graph.documentColorSpace))\n}\n\nexport function readStrokeOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n index: number\n): OkHCLPayload | null {\n return getStrokeOkHCL(nodeOf(graph, ref), index)\n}\n\nexport function writeStrokeOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n color: OkHCLColor,\n index: number\n): void {\n const node = nodeOf(graph, ref)\n editNode(graph, node, setNodeStrokeOkHCL(node, index, color, graph.documentColorSpace))\n}\n\n/** A frame's auto layout direction; a layer saved without one reads `AUTO`. */\nexport function readLayoutDirection(graph: SceneGraph, ref: NodeRef): LayoutDirection {\n const node = nodeOf(graph, ref)\n return Object.hasOwn(node, 'layoutDirection') ? node.layoutDirection : 'AUTO'\n}\n\nexport function writeLayoutDirection(graph: SceneGraph, ref: NodeRef, value: string): void {\n editNode(graph, nodeOf(graph, ref), { layoutDirection: direction(value) })\n}\n\nexport function readTextDirection(graph: SceneGraph, ref: NodeRef): TextDirection {\n return nodeOf(graph, ref).textDirection\n}\n\nexport function writeTextDirection(graph: SceneGraph, ref: NodeRef, value: string): void {\n editNode(graph, nodeOf(graph, ref), { textDirection: direction(value) })\n}\n"],"mappings":";;;;;;AAiBA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;;AAGxC,SAAS,SAAS,OAAmB,MAAiB,SAAmC;CACvF,mBAAmB,OAAO,KAAK,EAAE;CACjC,MAAM,UAAU,OAAO,KAAK,OAAO,CAAC,CAAC,QAClC,QAAQ,CAAC,QAAQ,QAAQ,IAAI,SAAS,GAAG,GAAG,QAAQ,IAAI,MAAM,GAAG,CAAC,CACrE;CACA,MAAM,WAAW,KAAK,IAAI,OAAO;CACjC,uBAAuB,OAAO,KAAK,IAAI,OAAO;AAChD;AAEA,SAAS,UAAU,OAAgD;CACjE,IAAI,CAAE,WAAiC,SAAS,KAAK,GACnD,MAAM,IAAI,MAAM,qBAAqB,MAAM,QAAQ,WAAW,KAAK,IAAI,GAAG;CAC5E,OAAO;AACT;AAEA,SAAgB,cAAc,OAAmB,KAAc,OAAoC;CACjG,OAAO,aAAa,OAAO,OAAO,GAAG,GAAG,KAAK;AAC/C;AAEA,SAAgB,eACd,OACA,KACA,OACA,OACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,SAAS,OAAO,MAAM,iBAAiB,MAAM,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACtF;AAEA,SAAgB,gBACd,OACA,KACA,OACqB;CACrB,OAAO,eAAe,OAAO,OAAO,GAAG,GAAG,KAAK;AACjD;AAEA,SAAgB,iBACd,OACA,KACA,OACA,OACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,SAAS,OAAO,MAAM,mBAAmB,MAAM,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACxF;;AAGA,SAAgB,oBAAoB,OAAmB,KAA+B;CACpF,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,OAAO,OAAO,OAAO,MAAM,iBAAiB,IAAI,KAAK,kBAAkB;AACzE;AAEA,SAAgB,qBAAqB,OAAmB,KAAc,OAAqB;CACzF,SAAS,OAAO,OAAO,OAAO,GAAG,GAAG,EAAE,iBAAiB,UAAU,KAAK,EAAE,CAAC;AAC3E;AAEA,SAAgB,kBAAkB,OAAmB,KAA6B;CAChF,OAAO,OAAO,OAAO,GAAG,CAAC,CAAC;AAC5B;AAEA,SAAgB,mBAAmB,OAAmB,KAAc,OAAqB;CACvF,SAAS,OAAO,OAAO,OAAO,GAAG,GAAG,EAAE,eAAe,UAAU,KAAK,EAAE,CAAC;AACzE"}
1
+ {"version":3,"file":"nodes.js","names":[],"sources":["../../src/pairdraw-api/nodes.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit/predicate'\n\nimport type { LayoutDirection, SceneGraph, SceneNode, TextDirection } from '@pairdraw/scene-graph'\nimport {\n getFillOkHCL,\n getStrokeOkHCL,\n setNodeFillOkHCL,\n setNodeStrokeOkHCL,\n type OkHCLColor,\n type OkHCLPayload\n} from '@pairdraw/scene-graph/color'\nimport { recordInstanceOverride } from '@pairdraw/scene-graph/instances'\n\nimport { assertNodeEditable } from '#core/editor/capabilities'\nimport { openTypeFeaturesPatch } from '#core/figma-api/accessors/text/opentype'\nimport { assertTextRange } from '#core/figma-api/text/style'\nimport { styleRunsWithPatch } from '#core/text/character-style'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\nconst DIRECTIONS = ['AUTO', 'LTR', 'RTL'] as const\n\n/** Writes a layer's fields as a script edit does: an instance's layer claims what changed. */\nfunction editNode(graph: SceneGraph, node: SceneNode, changes: Partial<SceneNode>): void {\n assertNodeEditable(graph, node.id)\n const changed = Object.keys(changes).filter(\n (key) => !isEqual(Reflect.get(changes, key), Reflect.get(node, key))\n )\n graph.updateNode(node.id, changes)\n recordInstanceOverride(graph, node.id, changed)\n}\n\nfunction direction(value: string): LayoutDirection & TextDirection {\n if (!(DIRECTIONS as readonly string[]).includes(value))\n throw new Error(`Unknown direction ${value}; use ${DIRECTIONS.join(', ')}`)\n return value as LayoutDirection & TextDirection\n}\n\nexport function readFillOkHCL(graph: SceneGraph, ref: NodeRef, index: number): OkHCLPayload | null {\n return getFillOkHCL(nodeOf(graph, ref), index)\n}\n\nexport function writeFillOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n color: OkHCLColor,\n index: number\n): void {\n const node = nodeOf(graph, ref)\n editNode(graph, node, setNodeFillOkHCL(node, index, color, graph.documentColorSpace))\n}\n\nexport function readStrokeOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n index: number\n): OkHCLPayload | null {\n return getStrokeOkHCL(nodeOf(graph, ref), index)\n}\n\nexport function writeStrokeOkHCL(\n graph: SceneGraph,\n ref: NodeRef,\n color: OkHCLColor,\n index: number\n): void {\n const node = nodeOf(graph, ref)\n editNode(graph, node, setNodeStrokeOkHCL(node, index, color, graph.documentColorSpace))\n}\n\n/** A frame's auto layout direction; a layer saved without one reads `AUTO`. */\nexport function readLayoutDirection(graph: SceneGraph, ref: NodeRef): LayoutDirection {\n const node = nodeOf(graph, ref)\n return Object.hasOwn(node, 'layoutDirection') ? node.layoutDirection : 'AUTO'\n}\n\nexport function writeLayoutDirection(graph: SceneGraph, ref: NodeRef, value: string): void {\n editNode(graph, nodeOf(graph, ref), { layoutDirection: direction(value) })\n}\n\nexport function readTextDirection(graph: SceneGraph, ref: NodeRef): TextDirection {\n return nodeOf(graph, ref).textDirection\n}\n\nexport function writeTextDirection(graph: SceneGraph, ref: NodeRef, value: string): void {\n editNode(graph, nodeOf(graph, ref), { textDirection: direction(value) })\n}\n\n/**\n * Merges OpenType features into a text's own: the given tags replace their entries, the rest\n * stay, as the panel's feature switches do. Figma's plugin API only reads a node's features;\n * this is the write path the tools and the panel share.\n */\nexport function writeFontFeatures(\n graph: SceneGraph,\n ref: NodeRef,\n features: Record<string, boolean>\n): void {\n const node = nodeOf(graph, ref)\n const merged = new Map(node.fontFeatures.map((feature) => [feature.tag, feature.enabled]))\n for (const [tag, enabled] of Object.entries(features)) merged.set(tag.toUpperCase(), enabled)\n editNode(graph, node, {\n fontFeatures: [...merged].map(([tag, enabled]) => ({ tag, enabled }))\n })\n}\n\n/**\n * Merges OpenType features into a text range's own, keeping the features its characters already\n * had. Figma's plugin API has no range feature setter, so this lives on `pairdraw`.\n */\nexport function writeRangeFontFeatures(\n graph: SceneGraph,\n ref: NodeRef,\n start: number,\n end: number,\n features: Record<string, boolean>\n): void {\n const node = nodeOf(graph, ref)\n assertTextRange('setRangeFontFeatures', node, start, end)\n const patch = openTypeFeaturesPatch('setRangeFontFeatures', node, start, features)\n editNode(graph, node, { styleRuns: styleRunsWithPatch(node, start, end, patch) })\n}\n"],"mappings":";;;;;;;;;AAoBA,MAAM,aAAa;CAAC;CAAQ;CAAO;AAAK;;AAGxC,SAAS,SAAS,OAAmB,MAAiB,SAAmC;CACvF,mBAAmB,OAAO,KAAK,EAAE;CACjC,MAAM,UAAU,OAAO,KAAK,OAAO,CAAC,CAAC,QAClC,QAAQ,CAAC,QAAQ,QAAQ,IAAI,SAAS,GAAG,GAAG,QAAQ,IAAI,MAAM,GAAG,CAAC,CACrE;CACA,MAAM,WAAW,KAAK,IAAI,OAAO;CACjC,uBAAuB,OAAO,KAAK,IAAI,OAAO;AAChD;AAEA,SAAS,UAAU,OAAgD;CACjE,IAAI,CAAE,WAAiC,SAAS,KAAK,GACnD,MAAM,IAAI,MAAM,qBAAqB,MAAM,QAAQ,WAAW,KAAK,IAAI,GAAG;CAC5E,OAAO;AACT;AAEA,SAAgB,cAAc,OAAmB,KAAc,OAAoC;CACjG,OAAO,aAAa,OAAO,OAAO,GAAG,GAAG,KAAK;AAC/C;AAEA,SAAgB,eACd,OACA,KACA,OACA,OACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,SAAS,OAAO,MAAM,iBAAiB,MAAM,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACtF;AAEA,SAAgB,gBACd,OACA,KACA,OACqB;CACrB,OAAO,eAAe,OAAO,OAAO,GAAG,GAAG,KAAK;AACjD;AAEA,SAAgB,iBACd,OACA,KACA,OACA,OACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,SAAS,OAAO,MAAM,mBAAmB,MAAM,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACxF;;AAGA,SAAgB,oBAAoB,OAAmB,KAA+B;CACpF,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,OAAO,OAAO,OAAO,MAAM,iBAAiB,IAAI,KAAK,kBAAkB;AACzE;AAEA,SAAgB,qBAAqB,OAAmB,KAAc,OAAqB;CACzF,SAAS,OAAO,OAAO,OAAO,GAAG,GAAG,EAAE,iBAAiB,UAAU,KAAK,EAAE,CAAC;AAC3E;AAEA,SAAgB,kBAAkB,OAAmB,KAA6B;CAChF,OAAO,OAAO,OAAO,GAAG,CAAC,CAAC;AAC5B;AAEA,SAAgB,mBAAmB,OAAmB,KAAc,OAAqB;CACvF,SAAS,OAAO,OAAO,OAAO,GAAG,GAAG,EAAE,eAAe,UAAU,KAAK,EAAE,CAAC;AACzE;;;;;;AAOA,SAAgB,kBACd,OACA,KACA,UACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,MAAM,SAAS,IAAI,IAAI,KAAK,aAAa,KAAK,YAAY,CAAC,QAAQ,KAAK,QAAQ,OAAO,CAAC,CAAC;CACzF,KAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,QAAQ,GAAG,OAAO,IAAI,IAAI,YAAY,GAAG,OAAO;CAC5F,SAAS,OAAO,MAAM,EACpB,cAAc,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,cAAc;EAAE;EAAK;CAAQ,EAAE,EACtE,CAAC;AACH;;;;;AAMA,SAAgB,uBACd,OACA,KACA,OACA,KACA,UACM;CACN,MAAM,OAAO,OAAO,OAAO,GAAG;CAC9B,gBAAgB,wBAAwB,MAAM,OAAO,GAAG;CACxD,MAAM,QAAQ,sBAAsB,wBAAwB,MAAM,OAAO,QAAQ;CACjF,SAAS,OAAO,MAAM,EAAE,WAAW,mBAAmB,MAAM,OAAO,KAAK,KAAK,EAAE,CAAC;AAClF"}
@@ -0,0 +1,48 @@
1
+ import { FigmaNodeProxy } from "../figma-api/proxy.js";
2
+ import { FigmaAPI } from "../figma-api/index.js";
3
+ import { VariationRequest } from "../editor/variations/create.js";
4
+ import { NodeRef } from "./behaviours.js";
5
+ import { SceneNode } from "@pairdraw/scene-graph";
6
+ //#region src/pairdraw-api/variations.d.ts
7
+ /** A layer of a set as `toJSON` and the tools report it: the node's id and name. */
8
+ type VariationLayerInfo = Pick<SceneNode, 'id' | 'name'>;
9
+ /** A set of variations as `toJSON` and the tools report it. */
10
+ interface VariationSetInfo {
11
+ id: string;
12
+ original: VariationLayerInfo | null;
13
+ versions: VariationLayerInfo[];
14
+ }
15
+ /**
16
+ * A set of variations: copies of a layer side by side in a section beside it. `id` is the
17
+ * section's; reading a set that was used or discarded throws.
18
+ */
19
+ declare class VariationSetHandle {
20
+ private readonly figma;
21
+ readonly id: string;
22
+ constructor(figma: FigmaAPI, id: string);
23
+ private get view();
24
+ /** The layer the versions vary, or null when it was deleted. */
25
+ get original(): FigmaNodeProxy | null;
26
+ /** The versions, in their order in the section. */
27
+ get versions(): FigmaNodeProxy[];
28
+ /**
29
+ * Make the original look like `version`, keeping its id, name, and place, and remove the set;
30
+ * returns the original.
31
+ */
32
+ use(version: NodeRef): FigmaNodeProxy;
33
+ /** Remove the set and every version in it; the original stays as it is. */
34
+ discard(): void;
35
+ toJSON(): VariationSetInfo;
36
+ }
37
+ /** Copy a layer into its set of variations, made beside it the first time. */
38
+ declare function createVariationSet(figma: FigmaAPI, node: NodeRef, request: VariationRequest): {
39
+ set: VariationSetHandle;
40
+ created: FigmaNodeProxy[];
41
+ };
42
+ /** The set a layer belongs to: its section, a version, or a layer inside one; else null. */
43
+ declare function getVariationSet(figma: FigmaAPI, node: NodeRef): VariationSetHandle | null;
44
+ /** The sets on a page. */
45
+ declare function listVariationSets(figma: FigmaAPI, pageId: string): VariationSetHandle[];
46
+ //#endregion
47
+ export { VariationLayerInfo, VariationSetHandle, VariationSetInfo, createVariationSet, getVariationSet, listVariationSets };
48
+ //# sourceMappingURL=variations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variations.d.ts","names":[],"sources":["../../src/pairdraw-api/variations.ts"],"mappings":";;;;;;;KAkBY,qBAAqB,KAAK;;UAGrB;EACf;EACA,UAAU;EACV,UAAU;;;;;;cASC;mBAEQ;WACR;EADQ,YAAA,OAAO,UACf;cAGC;;MAOR,YAAY;;MAMZ,YAAY;;;;;EAQhB,IAAI,SAAS,UAAU;;EAUvB;EAIA,UAAU;;;iBAWI,mBACd,OAAO,UACP,MAAM,SACN,SAAS;EACN,KAAK;EAAoB,SAAS;;;iBASvB,gBAAgB,OAAO,UAAU,MAAM,UAAU;;iBAMjD,kBAAkB,OAAO,UAAU,iBAAiB"}
@@ -0,0 +1,76 @@
1
+ import { createVariations } from "../editor/variations/create.js";
2
+ import { assertVariationPickable } from "../editor/variations/pick.js";
3
+ import { nodeOf } from "./behaviours.js";
4
+ import { pick } from "es-toolkit";
5
+ import { applyVariation, discardVariations, variationSetOf, variationSetsOnPage } from "@pairdraw/scene-graph/variations";
6
+ //#region src/pairdraw-api/variations.ts
7
+ const info = (node) => pick(node, ["id", "name"]);
8
+ /**
9
+ * A set of variations: copies of a layer side by side in a section beside it. `id` is the
10
+ * section's; reading a set that was used or discarded throws.
11
+ */
12
+ var VariationSetHandle = class {
13
+ figma;
14
+ id;
15
+ constructor(figma, id) {
16
+ this.figma = figma;
17
+ this.id = id;
18
+ }
19
+ get view() {
20
+ const view = variationSetOf(this.figma.graph, this.id);
21
+ if (view?.section.id !== this.id) throw new Error(`Variations ${this.id} are gone`);
22
+ return view;
23
+ }
24
+ /** The layer the versions vary, or null when it was deleted. */
25
+ get original() {
26
+ const { original } = this.view;
27
+ return original ? this.figma.wrapNode(original.id) : null;
28
+ }
29
+ /** The versions, in their order in the section. */
30
+ get versions() {
31
+ return this.view.versions.map((version) => this.figma.wrapNode(version.id));
32
+ }
33
+ /**
34
+ * Make the original look like `version`, keeping its id, name, and place, and remove the set;
35
+ * returns the original.
36
+ */
37
+ use(version) {
38
+ const node = nodeOf(this.figma.graph, version);
39
+ if (node.parentId !== this.view.section.id) throw new Error(`${node.name} is not one of these variations`);
40
+ assertVariationPickable(this.figma.graph, node.id);
41
+ return this.figma.wrapNode(applyVariation(this.figma.graph, node.id).originalId);
42
+ }
43
+ /** Remove the set and every version in it; the original stays as it is. */
44
+ discard() {
45
+ discardVariations(this.figma.graph, this.view.section.id);
46
+ }
47
+ toJSON() {
48
+ const { section, original, versions } = this.view;
49
+ return {
50
+ id: section.id,
51
+ original: original ? info(original) : null,
52
+ versions: versions.map(info)
53
+ };
54
+ }
55
+ };
56
+ /** Copy a layer into its set of variations, made beside it the first time. */
57
+ function createVariationSet(figma, node, request) {
58
+ const made = createVariations(figma.graph, nodeOf(figma.graph, node).id, request);
59
+ return {
60
+ set: new VariationSetHandle(figma, made.sectionId),
61
+ created: made.versions.map((version) => figma.wrapNode(version.id))
62
+ };
63
+ }
64
+ /** The set a layer belongs to: its section, a version, or a layer inside one; else null. */
65
+ function getVariationSet(figma, node) {
66
+ const view = variationSetOf(figma.graph, nodeOf(figma.graph, node).id);
67
+ return view ? new VariationSetHandle(figma, view.section.id) : null;
68
+ }
69
+ /** The sets on a page. */
70
+ function listVariationSets(figma, pageId) {
71
+ return variationSetsOnPage(figma.graph, pageId).map((view) => new VariationSetHandle(figma, view.section.id));
72
+ }
73
+ //#endregion
74
+ export { VariationSetHandle, createVariationSet, getVariationSet, listVariationSets };
75
+
76
+ //# sourceMappingURL=variations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variations.js","names":[],"sources":["../../src/pairdraw-api/variations.ts"],"sourcesContent":["import { pick } from 'es-toolkit'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport {\n applyVariation,\n discardVariations,\n variationSetOf,\n variationSetsOnPage,\n type VariationSetView\n} from '@pairdraw/scene-graph/variations'\n\nimport { createVariations, type VariationRequest } from '#core/editor/variations/create'\nimport { assertVariationPickable } from '#core/editor/variations/pick'\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api/index'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\n/** A layer of a set as `toJSON` and the tools report it: the node's id and name. */\nexport type VariationLayerInfo = Pick<SceneNode, 'id' | 'name'>\n\n/** A set of variations as `toJSON` and the tools report it. */\nexport interface VariationSetInfo {\n id: string\n original: VariationLayerInfo | null\n versions: VariationLayerInfo[]\n}\n\nconst info = (node: VariationLayerInfo): VariationLayerInfo => pick(node, ['id', 'name'])\n\n/**\n * A set of variations: copies of a layer side by side in a section beside it. `id` is the\n * section's; reading a set that was used or discarded throws.\n */\nexport class VariationSetHandle {\n constructor(\n private readonly figma: FigmaAPI,\n readonly id: string\n ) {}\n\n private get view(): VariationSetView {\n const view = variationSetOf(this.figma.graph, this.id)\n if (view?.section.id !== this.id) throw new Error(`Variations ${this.id} are gone`)\n return view\n }\n\n /** The layer the versions vary, or null when it was deleted. */\n get original(): FigmaNodeProxy | null {\n const { original } = this.view\n return original ? this.figma.wrapNode(original.id) : null\n }\n\n /** The versions, in their order in the section. */\n get versions(): FigmaNodeProxy[] {\n return this.view.versions.map((version) => this.figma.wrapNode(version.id))\n }\n\n /**\n * Make the original look like `version`, keeping its id, name, and place, and remove the set;\n * returns the original.\n */\n use(version: NodeRef): FigmaNodeProxy {\n const node = nodeOf(this.figma.graph, version)\n if (node.parentId !== this.view.section.id) {\n throw new Error(`${node.name} is not one of these variations`)\n }\n assertVariationPickable(this.figma.graph, node.id)\n return this.figma.wrapNode(applyVariation(this.figma.graph, node.id).originalId)\n }\n\n /** Remove the set and every version in it; the original stays as it is. */\n discard(): void {\n discardVariations(this.figma.graph, this.view.section.id)\n }\n\n toJSON(): VariationSetInfo {\n const { section, original, versions } = this.view\n return {\n id: section.id,\n original: original ? info(original) : null,\n versions: versions.map(info)\n }\n }\n}\n\n/** Copy a layer into its set of variations, made beside it the first time. */\nexport function createVariationSet(\n figma: FigmaAPI,\n node: NodeRef,\n request: VariationRequest\n): { set: VariationSetHandle; created: FigmaNodeProxy[] } {\n const made = createVariations(figma.graph, nodeOf(figma.graph, node).id, request)\n return {\n set: new VariationSetHandle(figma, made.sectionId),\n created: made.versions.map((version) => figma.wrapNode(version.id))\n }\n}\n\n/** The set a layer belongs to: its section, a version, or a layer inside one; else null. */\nexport function getVariationSet(figma: FigmaAPI, node: NodeRef): VariationSetHandle | null {\n const view = variationSetOf(figma.graph, nodeOf(figma.graph, node).id)\n return view ? new VariationSetHandle(figma, view.section.id) : null\n}\n\n/** The sets on a page. */\nexport function listVariationSets(figma: FigmaAPI, pageId: string): VariationSetHandle[] {\n return variationSetsOnPage(figma.graph, pageId).map(\n (view) => new VariationSetHandle(figma, view.section.id)\n )\n}\n"],"mappings":";;;;;;AA2BA,MAAM,QAAQ,SAAiD,KAAK,MAAM,CAAC,MAAM,MAAM,CAAC;;;;;AAMxF,IAAa,qBAAb,MAAgC;CAEX;CACR;CAFX,YACE,OACA,IACA;EAFiB,KAAA,QAAA;EACR,KAAA,KAAA;CACR;CAEH,IAAY,OAAyB;EACnC,MAAM,OAAO,eAAe,KAAK,MAAM,OAAO,KAAK,EAAE;EACrD,IAAI,MAAM,QAAQ,OAAO,KAAK,IAAI,MAAM,IAAI,MAAM,cAAc,KAAK,GAAG,UAAU;EAClF,OAAO;CACT;;CAGA,IAAI,WAAkC;EACpC,MAAM,EAAE,aAAa,KAAK;EAC1B,OAAO,WAAW,KAAK,MAAM,SAAS,SAAS,EAAE,IAAI;CACvD;;CAGA,IAAI,WAA6B;EAC/B,OAAO,KAAK,KAAK,SAAS,KAAK,YAAY,KAAK,MAAM,SAAS,QAAQ,EAAE,CAAC;CAC5E;;;;;CAMA,IAAI,SAAkC;EACpC,MAAM,OAAO,OAAO,KAAK,MAAM,OAAO,OAAO;EAC7C,IAAI,KAAK,aAAa,KAAK,KAAK,QAAQ,IACtC,MAAM,IAAI,MAAM,GAAG,KAAK,KAAK,gCAAgC;EAE/D,wBAAwB,KAAK,MAAM,OAAO,KAAK,EAAE;EACjD,OAAO,KAAK,MAAM,SAAS,eAAe,KAAK,MAAM,OAAO,KAAK,EAAE,CAAC,CAAC,UAAU;CACjF;;CAGA,UAAgB;EACd,kBAAkB,KAAK,MAAM,OAAO,KAAK,KAAK,QAAQ,EAAE;CAC1D;CAEA,SAA2B;EACzB,MAAM,EAAE,SAAS,UAAU,aAAa,KAAK;EAC7C,OAAO;GACL,IAAI,QAAQ;GACZ,UAAU,WAAW,KAAK,QAAQ,IAAI;GACtC,UAAU,SAAS,IAAI,IAAI;EAC7B;CACF;AACF;;AAGA,SAAgB,mBACd,OACA,MACA,SACwD;CACxD,MAAM,OAAO,iBAAiB,MAAM,OAAO,OAAO,MAAM,OAAO,IAAI,CAAC,CAAC,IAAI,OAAO;CAChF,OAAO;EACL,KAAK,IAAI,mBAAmB,OAAO,KAAK,SAAS;EACjD,SAAS,KAAK,SAAS,KAAK,YAAY,MAAM,SAAS,QAAQ,EAAE,CAAC;CACpE;AACF;;AAGA,SAAgB,gBAAgB,OAAiB,MAA0C;CACzF,MAAM,OAAO,eAAe,MAAM,OAAO,OAAO,MAAM,OAAO,IAAI,CAAC,CAAC,EAAE;CACrE,OAAO,OAAO,IAAI,mBAAmB,OAAO,KAAK,QAAQ,EAAE,IAAI;AACjE;;AAGA,SAAgB,kBAAkB,OAAiB,QAAsC;CACvF,OAAO,oBAAoB,MAAM,OAAO,MAAM,CAAC,CAAC,KAC7C,SAAS,IAAI,mBAAmB,OAAO,KAAK,QAAQ,EAAE,CACzD;AACF"}
@@ -0,0 +1,13 @@
1
+ import { PrototypeEasingType } from "@pairdraw/scene-graph";
2
+ //#region src/prototype/easing.d.ts
3
+ /**
4
+ * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no
5
+ * easing eases as Figma's default does. The player and a recording both read it, so they move
6
+ * alike.
7
+ */
8
+ declare function easingAt(easing: PrototypeEasingType | undefined, progress: number): number;
9
+ /** `easing` as a CSS timing function, for a transition the browser animates. */
10
+ declare function easingCSS(easing: PrototypeEasingType | undefined): string;
11
+ //#endregion
12
+ export { easingAt, easingCSS };
13
+ //# sourceMappingURL=easing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easing.d.ts","names":[],"sources":["../../src/prototype/easing.ts"],"mappings":";;;;;;;iBAegB,SAAS,QAAQ,iCAAiC;;iBAiBlD,UAAU,QAAQ"}
@@ -0,0 +1,36 @@
1
+ import { DEFAULT_PROTOTYPE_EASING, PROTOTYPE_EASING_CURVES } from "@pairdraw/scene-graph/constants";
2
+ //#region src/prototype/easing.ts
3
+ /** Bisection steps that solve a curve's x for its t; 32 halvings are far below a pixel. */
4
+ const BISECTION_STEPS = 32;
5
+ function bezier(t, p1, p2) {
6
+ return 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t;
7
+ }
8
+ /**
9
+ * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no
10
+ * easing eases as Figma's default does. The player and a recording both read it, so they move
11
+ * alike.
12
+ */
13
+ function easingAt(easing, progress) {
14
+ if (progress <= 0) return 0;
15
+ if (progress >= 1) return 1;
16
+ const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING];
17
+ if (x1 === y1 && x2 === y2) return progress;
18
+ let low = 0;
19
+ let high = 1;
20
+ for (let index = 0; index < BISECTION_STEPS; index++) {
21
+ const middle = (low + high) / 2;
22
+ if (bezier(middle, x1, x2) < progress) low = middle;
23
+ else high = middle;
24
+ }
25
+ return bezier((low + high) / 2, y1, y2);
26
+ }
27
+ /** `easing` as a CSS timing function, for a transition the browser animates. */
28
+ function easingCSS(easing) {
29
+ const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING];
30
+ if (x1 === y1 && x2 === y2) return "linear";
31
+ return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
32
+ }
33
+ //#endregion
34
+ export { easingAt, easingCSS };
35
+
36
+ //# sourceMappingURL=easing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easing.js","names":[],"sources":["../../src/prototype/easing.ts"],"sourcesContent":["import type { PrototypeEasingType } from '@pairdraw/scene-graph'\nimport { DEFAULT_PROTOTYPE_EASING, PROTOTYPE_EASING_CURVES } from '@pairdraw/scene-graph/constants'\n\n/** Bisection steps that solve a curve's x for its t; 32 halvings are far below a pixel. */\nconst BISECTION_STEPS = 32\n\nfunction bezier(t: number, p1: number, p2: number): number {\n return 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t\n}\n\n/**\n * How far along a transition eased by `easing` is at `progress` of its time, from 0 to 1; no\n * easing eases as Figma's default does. The player and a recording both read it, so they move\n * alike.\n */\nexport function easingAt(easing: PrototypeEasingType | undefined, progress: number): number {\n if (progress <= 0) return 0\n if (progress >= 1) return 1\n const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING]\n if (x1 === y1 && x2 === y2) return progress\n // x(t) rises monotonically, so bisection finds the t whose x is `progress`.\n let low = 0\n let high = 1\n for (let index = 0; index < BISECTION_STEPS; index++) {\n const middle = (low + high) / 2\n if (bezier(middle, x1, x2) < progress) low = middle\n else high = middle\n }\n return bezier((low + high) / 2, y1, y2)\n}\n\n/** `easing` as a CSS timing function, for a transition the browser animates. */\nexport function easingCSS(easing: PrototypeEasingType | undefined): string {\n const [x1, y1, x2, y2] = PROTOTYPE_EASING_CURVES[easing ?? DEFAULT_PROTOTYPE_EASING]\n if (x1 === y1 && x2 === y2) return 'linear'\n return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB;AAExB,SAAS,OAAO,GAAW,IAAY,IAAoB;CACzD,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI;AAC7E;;;;;;AAOA,SAAgB,SAAS,QAAyC,UAA0B;CAC1F,IAAI,YAAY,GAAG,OAAO;CAC1B,IAAI,YAAY,GAAG,OAAO;CAC1B,MAAM,CAAC,IAAI,IAAI,IAAI,MAAM,wBAAwB,UAAU;CAC3D,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CAEnC,IAAI,MAAM;CACV,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,iBAAiB,SAAS;EACpD,MAAM,UAAU,MAAM,QAAQ;EAC9B,IAAI,OAAO,QAAQ,IAAI,EAAE,IAAI,UAAU,MAAM;OACxC,OAAO;CACd;CACA,OAAO,QAAQ,MAAM,QAAQ,GAAG,IAAI,EAAE;AACxC;;AAGA,SAAgB,UAAU,QAAiD;CACzE,MAAM,CAAC,IAAI,IAAI,IAAI,MAAM,wBAAwB,UAAU;CAC3D,IAAI,OAAO,MAAM,OAAO,IAAI,OAAO;CACnC,OAAO,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AACjD"}
@@ -0,0 +1,10 @@
1
+ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
2
+ //#region src/prototype/frames.d.ts
3
+ /**
4
+ * The frames a navigation can point at: the page's top-level frames, in page order. Figma links to
5
+ * frames and components at the top of the page, not to layers inside them, so the list stays flat.
6
+ */
7
+ declare function framesOnPage(graph: SceneGraph, pageId: string): SceneNode[];
8
+ //#endregion
9
+ export { framesOnPage };
10
+ //# sourceMappingURL=frames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frames.d.ts","names":[],"sources":["../../src/prototype/frames.ts"],"mappings":";;;;;;iBAMgB,aAAa,OAAO,YAAY,iBAAiB"}
@@ -0,0 +1,12 @@
1
+ //#region src/prototype/frames.ts
2
+ /**
3
+ * The frames a navigation can point at: the page's top-level frames, in page order. Figma links to
4
+ * frames and components at the top of the page, not to layers inside them, so the list stays flat.
5
+ */
6
+ function framesOnPage(graph, pageId) {
7
+ return graph.getChildren(pageId).filter((node) => node.type === "FRAME");
8
+ }
9
+ //#endregion
10
+ export { framesOnPage };
11
+
12
+ //# sourceMappingURL=frames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frames.js","names":[],"sources":["../../src/prototype/frames.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\n/**\n * The frames a navigation can point at: the page's top-level frames, in page order. Figma links to\n * frames and components at the top of the page, not to layers inside them, so the list stays flat.\n */\nexport function framesOnPage(graph: SceneGraph, pageId: string): SceneNode[] {\n return graph.getChildren(pageId).filter((node) => node.type === 'FRAME')\n}\n"],"mappings":";;;;;AAMA,SAAgB,aAAa,OAAmB,QAA6B;CAC3E,OAAO,MAAM,YAAY,MAAM,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,OAAO;AACzE"}
@@ -0,0 +1,17 @@
1
+ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
2
+ import { Vector } from "@pairdraw/scene-graph/primitives";
3
+ //#region src/prototype/hit.d.ts
4
+ /**
5
+ * The deepest layer under a point inside `rootId` that takes the pointer, as a prototype finds
6
+ * it: one `takes` accepts, over its whole box, so a button's background takes its click as its
7
+ * label does, and one that shows a paint there, so a filled sheet laid over a button keeps the
8
+ * click from it. A layer that does neither, such as an unfilled frame laid over a screen, lets
9
+ * the pointer through to what lies under it. A clipping frame and a mask hide what lies outside
10
+ * them; hidden layers and masks take nothing. The root itself when no layer takes the point and
11
+ * it lies over the root, and null outside it. A frame play scrolled finds its layers where they
12
+ * are drawn, `scroll` offsets in.
13
+ */
14
+ declare function playHitTest(graph: SceneGraph, rootId: string, x: number, y: number, scroll?: ReadonlyMap<string, Vector>, takes?: (node: SceneNode) => boolean): SceneNode | null;
15
+ //#endregion
16
+ export { playHitTest };
17
+ //# sourceMappingURL=hit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hit.d.ts","names":[],"sources":["../../src/prototype/hit.ts"],"mappings":";;;;;;;;;;;;;iBA2BgB,YACd,OAAO,YACP,gBACA,WACA,WACA,SAAQ,oBAAoB,SAC5B,SAAQ,MAAM,wBACb"}
@@ -0,0 +1,45 @@
1
+ import { liftedChildIds, scrollShiftX, scrollShiftY } from "./scroll.js";
2
+ import { drawnChildIds } from "@pairdraw/scene-graph/layout";
3
+ import { clippingMasks, isPointInNode, isPointMaskedOut, showsPaint } from "@pairdraw/scene-graph/hit-test";
4
+ //#region src/prototype/hit.ts
5
+ const NOT_SCROLLED = /* @__PURE__ */ new Map();
6
+ /** Every layer may take the pointer. */
7
+ const ANY_LAYER = () => true;
8
+ /**
9
+ * The deepest layer under a point inside `rootId` that takes the pointer, as a prototype finds
10
+ * it: one `takes` accepts, over its whole box, so a button's background takes its click as its
11
+ * label does, and one that shows a paint there, so a filled sheet laid over a button keeps the
12
+ * click from it. A layer that does neither, such as an unfilled frame laid over a screen, lets
13
+ * the pointer through to what lies under it. A clipping frame and a mask hide what lies outside
14
+ * them; hidden layers and masks take nothing. The root itself when no layer takes the point and
15
+ * it lies over the root, and null outside it. A frame play scrolled finds its layers where they
16
+ * are drawn, `scroll` offsets in.
17
+ */
18
+ function playHitTest(graph, rootId, x, y, scroll = NOT_SCROLLED, takes = ANY_LAYER) {
19
+ const root = graph.getNode(rootId);
20
+ if (!root) return null;
21
+ return deepestIn(graph, root, x, y, scroll, takes) ?? (isPointInNode(graph, rootId, x, y) ? root : null);
22
+ }
23
+ function deepestIn(graph, parent, x, y, scroll, takes) {
24
+ if (parent.clipsContent && !isPointInNode(graph, parent.id, x, y)) return null;
25
+ const offset = scroll.get(parent.id);
26
+ const innerX = x + (offset?.x ?? 0);
27
+ const innerY = y + (offset?.y ?? 0);
28
+ const drawn = liftedChildIds(graph, drawnChildIds(parent), offset);
29
+ const masks = clippingMasks(graph, drawn);
30
+ for (let index = drawn.length - 1; index >= 0; index--) {
31
+ const child = graph.getNode(drawn[index]);
32
+ if (!child?.visible || child.internalOnly || child.isMask) continue;
33
+ if (isPointMaskedOut(graph, masks[index], innerX, innerY)) continue;
34
+ const childX = innerX - scrollShiftX(child, offset);
35
+ const childY = innerY - scrollShiftY(child, offset);
36
+ const hit = deepestIn(graph, child, childX, childY, scroll, takes);
37
+ if (hit) return hit;
38
+ if ((takes(child) || showsPaint(child)) && isPointInNode(graph, child.id, childX, childY)) return child;
39
+ }
40
+ return null;
41
+ }
42
+ //#endregion
43
+ export { playHitTest };
44
+
45
+ //# sourceMappingURL=hit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hit.js","names":[],"sources":["../../src/prototype/hit.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n clippingMasks,\n isPointInNode,\n isPointMaskedOut,\n showsPaint\n} from '@pairdraw/scene-graph/hit-test'\nimport { drawnChildIds } from '@pairdraw/scene-graph/layout'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { liftedChildIds, scrollShiftX, scrollShiftY } from '#core/prototype/scroll'\n\nconst NOT_SCROLLED: ReadonlyMap<string, Vector> = new Map()\n\n/** Every layer may take the pointer. */\nconst ANY_LAYER = (): boolean => true\n\n/**\n * The deepest layer under a point inside `rootId` that takes the pointer, as a prototype finds\n * it: one `takes` accepts, over its whole box, so a button's background takes its click as its\n * label does, and one that shows a paint there, so a filled sheet laid over a button keeps the\n * click from it. A layer that does neither, such as an unfilled frame laid over a screen, lets\n * the pointer through to what lies under it. A clipping frame and a mask hide what lies outside\n * them; hidden layers and masks take nothing. The root itself when no layer takes the point and\n * it lies over the root, and null outside it. A frame play scrolled finds its layers where they\n * are drawn, `scroll` offsets in.\n */\nexport function playHitTest(\n graph: SceneGraph,\n rootId: string,\n x: number,\n y: number,\n scroll: ReadonlyMap<string, Vector> = NOT_SCROLLED,\n takes: (node: SceneNode) => boolean = ANY_LAYER\n): SceneNode | null {\n const root = graph.getNode(rootId)\n if (!root) return null\n const hit = deepestIn(graph, root, x, y, scroll, takes)\n return hit ?? (isPointInNode(graph, rootId, x, y) ? root : null)\n}\n\nfunction deepestIn(\n graph: SceneGraph,\n parent: SceneNode,\n x: number,\n y: number,\n scroll: ReadonlyMap<string, Vector>,\n takes: (node: SceneNode) => boolean\n): SceneNode | null {\n if (parent.clipsContent && !isPointInNode(graph, parent.id, x, y)) return null\n // The layers of a scrolled frame are drawn moved up and left by its offset, except the ones\n // that stay put; their point moves with the offset they skip.\n const offset = scroll.get(parent.id)\n const innerX = x + (offset?.x ?? 0)\n const innerY = y + (offset?.y ?? 0)\n const drawn = liftedChildIds(graph, drawnChildIds(parent), offset)\n const masks = clippingMasks(graph, drawn)\n for (let index = drawn.length - 1; index >= 0; index--) {\n const child = graph.getNode(drawn[index])\n if (!child?.visible || child.internalOnly || child.isMask) continue\n if (isPointMaskedOut(graph, masks[index], innerX, innerY)) continue\n const childX = innerX - scrollShiftX(child, offset)\n const childY = innerY - scrollShiftY(child, offset)\n const hit = deepestIn(graph, child, childX, childY, scroll, takes)\n if (hit) return hit\n const captures = takes(child) || showsPaint(child)\n if (captures && isPointInNode(graph, child.id, childX, childY)) return child\n }\n return null\n}\n"],"mappings":";;;;AAYA,MAAM,+BAA4C,IAAI,IAAI;;AAG1D,MAAM,kBAA2B;;;;;;;;;;;AAYjC,SAAgB,YACd,OACA,QACA,GACA,GACA,SAAsC,cACtC,QAAsC,WACpB;CAClB,MAAM,OAAO,MAAM,QAAQ,MAAM;CACjC,IAAI,CAAC,MAAM,OAAO;CAElB,OADY,UAAU,OAAO,MAAM,GAAG,GAAG,QAAQ,KACxC,MAAM,cAAc,OAAO,QAAQ,GAAG,CAAC,IAAI,OAAO;AAC7D;AAEA,SAAS,UACP,OACA,QACA,GACA,GACA,QACA,OACkB;CAClB,IAAI,OAAO,gBAAgB,CAAC,cAAc,OAAO,OAAO,IAAI,GAAG,CAAC,GAAG,OAAO;CAG1E,MAAM,SAAS,OAAO,IAAI,OAAO,EAAE;CACnC,MAAM,SAAS,KAAK,QAAQ,KAAK;CACjC,MAAM,SAAS,KAAK,QAAQ,KAAK;CACjC,MAAM,QAAQ,eAAe,OAAO,cAAc,MAAM,GAAG,MAAM;CACjE,MAAM,QAAQ,cAAc,OAAO,KAAK;CACxC,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS;EACtD,MAAM,QAAQ,MAAM,QAAQ,MAAM,MAAM;EACxC,IAAI,CAAC,OAAO,WAAW,MAAM,gBAAgB,MAAM,QAAQ;EAC3D,IAAI,iBAAiB,OAAO,MAAM,QAAQ,QAAQ,MAAM,GAAG;EAC3D,MAAM,SAAS,SAAS,aAAa,OAAO,MAAM;EAClD,MAAM,SAAS,SAAS,aAAa,OAAO,MAAM;EAClD,MAAM,MAAM,UAAU,OAAO,OAAO,QAAQ,QAAQ,QAAQ,KAAK;EACjE,IAAI,KAAK,OAAO;EAEhB,KADiB,MAAM,KAAK,KAAK,WAAW,KAAK,MACjC,cAAc,OAAO,MAAM,IAAI,QAAQ,MAAM,GAAG,OAAO;CACzE;CACA,OAAO;AACT"}
@@ -0,0 +1,14 @@
1
+ import { easingAt, easingCSS } from "./easing.js";
2
+ import { framesOnPage } from "./frames.js";
3
+ import { playHitTest } from "./hit.js";
4
+ import { PlayChange, PlayScene, PlaySceneView, changeTarget, createPlayScene } from "./scene.js";
5
+ import { ScrollChange, scrollRange, scrollsInPlay } from "./scroll.js";
6
+ import { PlayClick, PlaySession, primaryAction, reactionAt, restartSession, shownFrame, startFrame, startSession, step, timeoutReactions, topFrameOf } from "./session.js";
7
+ import { PlayFrame, SmartAnimation, createSmartAnimation } from "./smart-animate/animation.js";
8
+ import { PLAY_SCENE_LIMIT, PlayScenes, PlayStep, PlayTimeout, createPlayScenes } from "./scenes.js";
9
+ import { PlayPointerReaction, PlayRevert, hasPointerTriggers, pathChanges, pointerLeftTrigger, pointerPath, pointerReactions, revertFor } from "./pointer.js";
10
+ import { asInstanceEdit, effectiveReactions, sameReaction } from "./reactions.js";
11
+ import { snapshotPlayFrame } from "./snapshot.js";
12
+ import { LayerMatch, matchLayers } from "./smart-animate/match.js";
13
+ import { DISSOLVE_EASING, DISSOLVE_EASING_CSS, PlayAnimation, Timeline, TimelineClick, TimelineError, TimelineErrorReason, TimelineFrame, TimelineOptions, TimelineSegment, TimelineSmartSegment, TimelineStep, animationFor, dissolveEasing, frameAt, planTimeline, sessionDrawKey, transitionMs } from "./timeline.js";
14
+ export { DISSOLVE_EASING, DISSOLVE_EASING_CSS, type LayerMatch, PLAY_SCENE_LIMIT, type PlayAnimation, type PlayChange, type PlayClick, type PlayFrame, type PlayPointerReaction, type PlayRevert, type PlayScene, type PlaySceneView, type PlayScenes, type PlaySession, type PlayStep, type PlayTimeout, type ScrollChange, type SmartAnimation, type Timeline, type TimelineClick, TimelineError, type TimelineErrorReason, type TimelineFrame, type TimelineOptions, type TimelineSegment, type TimelineSmartSegment, type TimelineStep, animationFor, asInstanceEdit, changeTarget, createPlayScene, createPlayScenes, createSmartAnimation, dissolveEasing, easingAt, easingCSS, effectiveReactions, frameAt, framesOnPage, hasPointerTriggers, matchLayers, pathChanges, planTimeline, playHitTest, pointerLeftTrigger, pointerPath, pointerReactions, primaryAction, reactionAt, restartSession, revertFor, sameReaction, scrollRange, scrollsInPlay, sessionDrawKey, shownFrame, snapshotPlayFrame, startFrame, startSession, step, timeoutReactions, topFrameOf, transitionMs };
@@ -0,0 +1,14 @@
1
+ import { scrollRange, scrollsInPlay } from "./scroll.js";
2
+ import { asInstanceEdit, effectiveReactions, sameReaction } from "./reactions.js";
3
+ import { easingAt, easingCSS } from "./easing.js";
4
+ import { framesOnPage } from "./frames.js";
5
+ import { playHitTest } from "./hit.js";
6
+ import { primaryAction, reactionAt, restartSession, shownFrame, startFrame, startSession, step, timeoutReactions, topFrameOf } from "./session.js";
7
+ import { hasPointerTriggers, pathChanges, pointerLeftTrigger, pointerPath, pointerReactions, revertFor } from "./pointer.js";
8
+ import { changeTarget, createPlayScene } from "./scene.js";
9
+ import { snapshotPlayFrame } from "./snapshot.js";
10
+ import { matchLayers } from "./smart-animate/match.js";
11
+ import { createSmartAnimation } from "./smart-animate/animation.js";
12
+ import { PLAY_SCENE_LIMIT, createPlayScenes } from "./scenes.js";
13
+ import { DISSOLVE_EASING, DISSOLVE_EASING_CSS, TimelineError, animationFor, dissolveEasing, frameAt, planTimeline, sessionDrawKey, transitionMs } from "./timeline.js";
14
+ export { DISSOLVE_EASING, DISSOLVE_EASING_CSS, PLAY_SCENE_LIMIT, TimelineError, animationFor, asInstanceEdit, changeTarget, createPlayScene, createPlayScenes, createSmartAnimation, dissolveEasing, easingAt, easingCSS, effectiveReactions, frameAt, framesOnPage, hasPointerTriggers, matchLayers, pathChanges, planTimeline, playHitTest, pointerLeftTrigger, pointerPath, pointerReactions, primaryAction, reactionAt, restartSession, revertFor, sameReaction, scrollRange, scrollsInPlay, sessionDrawKey, shownFrame, snapshotPlayFrame, startFrame, startSession, step, timeoutReactions, topFrameOf, transitionMs };
@@ -0,0 +1,63 @@
1
+ import { PlayClick, PlaySession } from "./session.js";
2
+ import { PlayStep } from "./scenes.js";
3
+ import { PrototypeTransition, PrototypeTriggerType, SceneGraph, SceneNode } from "@pairdraw/scene-graph";
4
+ import { Vector } from "@pairdraw/scene-graph/primitives";
5
+ //#region src/prototype/pointer.d.ts
6
+ /** A reaction the pointer runs, with the delay a Mouse enter or Mouse leave waits first. */
7
+ interface PlayPointerReaction extends PlayClick {
8
+ delayMs: number;
9
+ }
10
+ /**
11
+ * How to undo a While hovering or While pressing reaction once the pointer leaves or lifts, and
12
+ * the layer whose leaving undoes it: the layer the reaction ran from, or the instance it
13
+ * switched when that layer went with the switch. A Change to switches back with the transition
14
+ * it switched with, as Figma's does.
15
+ */
16
+ type PlayRevert = {
17
+ kind: 'change';
18
+ watchId: string;
19
+ rootId: string;
20
+ instanceId: string;
21
+ from: string;
22
+ to: string;
23
+ transition: PrototypeTransition | null;
24
+ } | {
25
+ kind: 'overlay';
26
+ watchId: string;
27
+ frameId: string;
28
+ } | {
29
+ kind: 'back';
30
+ watchId: string;
31
+ frameId: string;
32
+ };
33
+ /**
34
+ * The layers under a point inside `rootId`, from the frame down to the deepest one `takes` the
35
+ * pointer, any layer unless told otherwise; none outside.
36
+ */
37
+ declare function pointerPath(graph: SceneGraph, rootId: string, x: number, y: number, scroll?: ReadonlyMap<string, Vector>, takes?: (node: SceneNode) => boolean): string[];
38
+ /** The layers a pointer left, innermost first, and those it entered, outermost first. */
39
+ declare function pathChanges(before: readonly string[], after: readonly string[]): {
40
+ left: string[];
41
+ entered: string[];
42
+ };
43
+ /**
44
+ * Whether the pointer has left the layer a While hovering reaction ran from: its path in the
45
+ * frame the action opened a variant on, so an overlay covering the pointer does not count.
46
+ */
47
+ declare function pointerLeftTrigger(basePath: readonly string[], triggerId: string): boolean;
48
+ /**
49
+ * Whether any layer of `rootId` reacts to the pointer moving over or pressing on it, an instance
50
+ * by its variant; a frame without one is not hit-tested as the pointer moves.
51
+ */
52
+ declare function hasPointerTriggers(graph: SceneGraph, rootId: string): boolean;
53
+ /** A layer's reactions to `trigger`, an instance's from the variant it shows, first action each. */
54
+ declare function pointerReactions(graph: SceneGraph, nodeId: string, trigger: PrototypeTriggerType): PlayPointerReaction[];
55
+ /**
56
+ * How to undo what a While hovering or While pressing reaction did: a Change to switches back, an
57
+ * overlay it opened closes, a navigation goes back. Null when it changed nothing. `shown` is the
58
+ * graph play shows the frame from after it ran.
59
+ */
60
+ declare function revertFor(before: PlaySession, done: PlayStep, { sourceId, action, transition }: PlayClick, shown: SceneGraph): PlayRevert | null;
61
+ //#endregion
62
+ export { PlayPointerReaction, PlayRevert, hasPointerTriggers, pathChanges, pointerLeftTrigger, pointerPath, pointerReactions, revertFor };
63
+ //# sourceMappingURL=pointer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pointer.d.ts","names":[],"sources":["../../src/prototype/pointer.ts"],"mappings":";;;;;;UAsBiB,4BAA4B;EAC3C;;;;;;;;KASU;EAEN;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;;EAEZ;EAAiB;EAAiB;;EAClC;EAAc;EAAiB;;;;;;iBAMrB,YACd,OAAO,YACP,gBACA,WACA,WACA,SAAS,oBAAoB,SAC7B,SAAS,MAAM;;iBAaD,YACd,2BACA;EACG;EAAgB;;;;;;iBAYL,mBAAmB,6BAA6B;;;;;iBAQhD,mBAAmB,OAAO,YAAY;;iBAatC,iBACd,OAAO,YACP,gBACA,SAAS,uBACR;;;;;;iBAgBa,UACd,QAAQ,aACR,MAAM,YACJ,UAAU,QAAQ,cAAc,WAClC,OAAO,aACN"}