@pairdraw/core 0.19.2 → 0.21.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 (1170) 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 +46 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +166 -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 +74 -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/colors.d.ts +20 -5
  49. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  50. package/dist/canvas/renderer/colors.js +48 -42
  51. package/dist/canvas/renderer/colors.js.map +1 -1
  52. package/dist/canvas/renderer/document-surface.d.ts +25 -0
  53. package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
  54. package/dist/canvas/renderer/document-surface.js +46 -0
  55. package/dist/canvas/renderer/document-surface.js.map +1 -0
  56. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  57. package/dist/canvas/renderer/fonts.js +6 -4
  58. package/dist/canvas/renderer/fonts.js.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  60. package/dist/canvas/renderer/lifecycle.js +10 -3
  61. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +1 -0
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  66. package/dist/canvas/renderer/pipeline.js +36 -3
  67. package/dist/canvas/renderer/pipeline.js.map +1 -1
  68. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  69. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  70. package/dist/canvas/renderer/play-scenes.js +40 -0
  71. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  72. package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
  73. package/dist/canvas/renderer/retained-backing.js +2 -1
  74. package/dist/canvas/renderer/retained-backing.js.map +1 -1
  75. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  76. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  77. package/dist/canvas/renderer/tiles/cache.js +32 -1
  78. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  79. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  80. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  81. package/dist/canvas/renderer/tiles/controller.js +18 -1
  82. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  83. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  84. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  85. package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
  86. package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
  87. package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
  88. package/dist/canvas/renderer/types.d.ts +18 -3
  89. package/dist/canvas/renderer/types.d.ts.map +1 -1
  90. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  91. package/dist/canvas/renderer/visual-bounds.js +1 -1
  92. package/dist/canvas/renderer.d.ts +42 -4
  93. package/dist/canvas/renderer.d.ts.map +1 -1
  94. package/dist/canvas/renderer.js +57 -5
  95. package/dist/canvas/renderer.js.map +1 -1
  96. package/dist/canvas/scene.d.ts +2 -1
  97. package/dist/canvas/scene.d.ts.map +1 -1
  98. package/dist/canvas/scene.js +45 -12
  99. package/dist/canvas/scene.js.map +1 -1
  100. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  101. package/dist/canvas/shaders/effect.js +2 -1
  102. package/dist/canvas/shaders/effect.js.map +1 -1
  103. package/dist/canvas/shadows/shape.d.ts.map +1 -1
  104. package/dist/canvas/shadows/shape.js +4 -2
  105. package/dist/canvas/shadows/shape.js.map +1 -1
  106. package/dist/canvas/shadows/silhouette.js +1 -1
  107. package/dist/canvas/shadows.d.ts.map +1 -1
  108. package/dist/canvas/shadows.js +4 -2
  109. package/dist/canvas/shadows.js.map +1 -1
  110. package/dist/canvas/text/decorations.d.ts +2 -2
  111. package/dist/canvas/text/decorations.d.ts.map +1 -1
  112. package/dist/canvas/text/decorations.js +5 -5
  113. package/dist/canvas/text/decorations.js.map +1 -1
  114. package/dist/canvas/text/index.js +1 -1
  115. package/dist/canvas/text/index.js.map +1 -1
  116. package/dist/canvas/text/paragraph/index.d.ts +2 -2
  117. package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
  118. package/dist/canvas/text/paragraph/index.js +16 -5
  119. package/dist/canvas/text/paragraph/index.js.map +1 -1
  120. package/dist/canvas/text/renderer.d.ts +2 -1
  121. package/dist/canvas/text/renderer.d.ts.map +1 -1
  122. package/dist/canvas/text/shape.js +4 -4
  123. package/dist/canvas/text/shape.js.map +1 -1
  124. package/dist/canvas/texture.d.ts +20 -0
  125. package/dist/canvas/texture.d.ts.map +1 -0
  126. package/dist/canvas/texture.js +101 -0
  127. package/dist/canvas/texture.js.map +1 -0
  128. package/dist/clipboard.js +16 -5
  129. package/dist/clipboard.js.map +1 -1
  130. package/dist/constants.d.ts +5 -1
  131. package/dist/constants.d.ts.map +1 -1
  132. package/dist/constants.js +5 -1
  133. package/dist/constants.js.map +1 -1
  134. package/dist/design-jsx/renderer.d.ts.map +1 -1
  135. package/dist/design-memory/check.d.ts +90 -0
  136. package/dist/design-memory/check.d.ts.map +1 -0
  137. package/dist/design-memory/check.js +281 -0
  138. package/dist/design-memory/check.js.map +1 -0
  139. package/dist/design-memory/describe.d.ts +37 -0
  140. package/dist/design-memory/describe.d.ts.map +1 -0
  141. package/dist/design-memory/describe.js +52 -0
  142. package/dist/design-memory/describe.js.map +1 -0
  143. package/dist/design-memory/distil.d.ts +22 -0
  144. package/dist/design-memory/distil.d.ts.map +1 -0
  145. package/dist/design-memory/distil.js +54 -0
  146. package/dist/design-memory/distil.js.map +1 -0
  147. package/dist/design-memory/document.d.ts +12 -0
  148. package/dist/design-memory/document.d.ts.map +1 -0
  149. package/dist/design-memory/document.js +64 -0
  150. package/dist/design-memory/document.js.map +1 -0
  151. package/dist/design-memory/guard.d.ts +48 -0
  152. package/dist/design-memory/guard.d.ts.map +1 -0
  153. package/dist/design-memory/guard.js +105 -0
  154. package/dist/design-memory/guard.js.map +1 -0
  155. package/dist/design-memory/index.d.ts +9 -0
  156. package/dist/design-memory/index.js +9 -0
  157. package/dist/design-memory/refusal.d.ts +32 -0
  158. package/dist/design-memory/refusal.d.ts.map +1 -0
  159. package/dist/design-memory/refusal.js +68 -0
  160. package/dist/design-memory/refusal.js.map +1 -0
  161. package/dist/design-memory/rules.d.ts +63 -0
  162. package/dist/design-memory/rules.d.ts.map +1 -0
  163. package/dist/design-memory/rules.js +224 -0
  164. package/dist/design-memory/rules.js.map +1 -0
  165. package/dist/design-memory/values.d.ts +28 -0
  166. package/dist/design-memory/values.d.ts.map +1 -0
  167. package/dist/design-memory/values.js +160 -0
  168. package/dist/design-memory/values.js.map +1 -0
  169. package/dist/editor/alignment.js +1 -1
  170. package/dist/editor/bridges/components.d.ts +2 -0
  171. package/dist/editor/bridges/components.d.ts.map +1 -1
  172. package/dist/editor/bridges/components.js +2 -0
  173. package/dist/editor/bridges/components.js.map +1 -1
  174. package/dist/editor/clipboard/assets.d.ts.map +1 -1
  175. package/dist/editor/clipboard/assets.js +3 -3
  176. package/dist/editor/clipboard/assets.js.map +1 -1
  177. package/dist/editor/clipboard/component-matches.d.ts +13 -0
  178. package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
  179. package/dist/editor/clipboard/component-matches.js +50 -0
  180. package/dist/editor/clipboard/component-matches.js.map +1 -0
  181. package/dist/editor/clipboard/dependencies.d.ts +7 -0
  182. package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
  183. package/dist/editor/clipboard/dependencies.js +5 -0
  184. package/dist/editor/clipboard/dependencies.js.map +1 -1
  185. package/dist/editor/clipboard/export.d.ts.map +1 -1
  186. package/dist/editor/clipboard/export.js +16 -2
  187. package/dist/editor/clipboard/export.js.map +1 -1
  188. package/dist/editor/clipboard/placement.d.ts +1 -1
  189. package/dist/editor/clipboard/placement.js +1 -1
  190. package/dist/editor/clipboard.d.ts.map +1 -1
  191. package/dist/editor/clipboard.js +48 -19
  192. package/dist/editor/clipboard.js.map +1 -1
  193. package/dist/editor/components/instances.d.ts +2 -0
  194. package/dist/editor/components/instances.d.ts.map +1 -1
  195. package/dist/editor/components/instances.js +22 -1
  196. package/dist/editor/components/instances.js.map +1 -1
  197. package/dist/editor/components/properties.d.ts.map +1 -1
  198. package/dist/editor/components/properties.js +3 -3
  199. package/dist/editor/components/properties.js.map +1 -1
  200. package/dist/editor/components.d.ts +2 -0
  201. package/dist/editor/components.d.ts.map +1 -1
  202. package/dist/editor/connectors/attach.js +1 -1
  203. package/dist/editor/create.d.ts +26 -2
  204. package/dist/editor/create.d.ts.map +1 -1
  205. package/dist/editor/create.js +16 -60
  206. package/dist/editor/create.js.map +1 -1
  207. package/dist/editor/design-memory.d.ts +11 -0
  208. package/dist/editor/design-memory.d.ts.map +1 -0
  209. package/dist/editor/design-memory.js +40 -0
  210. package/dist/editor/design-memory.js.map +1 -0
  211. package/dist/editor/design-tokens.d.ts +4 -0
  212. package/dist/editor/design-tokens.d.ts.map +1 -1
  213. package/dist/editor/design-tokens.js +30 -1
  214. package/dist/editor/design-tokens.js.map +1 -1
  215. package/dist/editor/document-colors.d.ts +23 -0
  216. package/dist/editor/document-colors.d.ts.map +1 -0
  217. package/dist/editor/document-colors.js +53 -0
  218. package/dist/editor/document-colors.js.map +1 -0
  219. package/dist/editor/eyedropper.d.ts +47 -0
  220. package/dist/editor/eyedropper.d.ts.map +1 -0
  221. package/dist/editor/eyedropper.js +171 -0
  222. package/dist/editor/eyedropper.js.map +1 -0
  223. package/dist/editor/fonts.d.ts +9 -0
  224. package/dist/editor/fonts.d.ts.map +1 -0
  225. package/dist/editor/fonts.js +14 -0
  226. package/dist/editor/fonts.js.map +1 -0
  227. package/dist/editor/history/atomic-tool.d.ts +9 -2
  228. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  229. package/dist/editor/history/atomic-tool.js +9 -2
  230. package/dist/editor/history/atomic-tool.js.map +1 -1
  231. package/dist/editor/history/capture.d.ts +13 -0
  232. package/dist/editor/history/capture.d.ts.map +1 -0
  233. package/dist/editor/history/capture.js +28 -0
  234. package/dist/editor/history/capture.js.map +1 -0
  235. package/dist/editor/history/document-change.d.ts.map +1 -1
  236. package/dist/editor/history/document-change.js +2 -22
  237. package/dist/editor/history/document-change.js.map +1 -1
  238. package/dist/editor/history/edit.d.ts +7 -0
  239. package/dist/editor/history/edit.d.ts.map +1 -1
  240. package/dist/editor/history/edit.js +4 -2
  241. package/dist/editor/history/edit.js.map +1 -1
  242. package/dist/editor/history/subtree.d.ts +9 -0
  243. package/dist/editor/history/subtree.d.ts.map +1 -1
  244. package/dist/editor/history/subtree.js +12 -2
  245. package/dist/editor/history/subtree.js.map +1 -1
  246. package/dist/editor/index.d.ts +4 -2
  247. package/dist/editor/index.js +4 -2
  248. package/dist/editor/pages.d.ts +7 -5
  249. package/dist/editor/pages.d.ts.map +1 -1
  250. package/dist/editor/pages.js +35 -25
  251. package/dist/editor/pages.js.map +1 -1
  252. package/dist/editor/play/states.d.ts +3 -1
  253. package/dist/editor/play/states.d.ts.map +1 -1
  254. package/dist/editor/play/states.js +1 -1
  255. package/dist/editor/play/states.js.map +1 -1
  256. package/dist/editor/read-only/actions.js +4 -0
  257. package/dist/editor/read-only/actions.js.map +1 -1
  258. package/dist/editor/render-requests.d.ts +18 -0
  259. package/dist/editor/render-requests.d.ts.map +1 -0
  260. package/dist/editor/render-requests.js +76 -0
  261. package/dist/editor/render-requests.js.map +1 -0
  262. package/dist/editor/scale/rescale.d.ts +1 -1
  263. package/dist/editor/selection/overlays.d.ts.map +1 -1
  264. package/dist/editor/selection/overlays.js +1 -1
  265. package/dist/editor/selection/overlays.js.map +1 -1
  266. package/dist/editor/selection/read.d.ts +4 -0
  267. package/dist/editor/selection.d.ts +5 -0
  268. package/dist/editor/selection.d.ts.map +1 -1
  269. package/dist/editor/shapes/pencil.js +1 -1
  270. package/dist/editor/structure/state.d.ts.map +1 -1
  271. package/dist/editor/structure/state.js +2 -2
  272. package/dist/editor/structure/state.js.map +1 -1
  273. package/dist/editor/text.d.ts.map +1 -1
  274. package/dist/editor/text.js +2 -2
  275. package/dist/editor/text.js.map +1 -1
  276. package/dist/editor/tool-registry.d.ts.map +1 -1
  277. package/dist/editor/tool-registry.js +2 -1
  278. package/dist/editor/tool-registry.js.map +1 -1
  279. package/dist/editor/types.d.ts +5 -1
  280. package/dist/editor/types.d.ts.map +1 -1
  281. package/dist/editor/variables.js +3 -3
  282. package/dist/editor/variables.js.map +1 -1
  283. package/dist/editor/variations/create.d.ts +28 -0
  284. package/dist/editor/variations/create.d.ts.map +1 -0
  285. package/dist/editor/variations/create.js +176 -0
  286. package/dist/editor/variations/create.js.map +1 -0
  287. package/dist/editor/variations/pick.d.ts +16 -0
  288. package/dist/editor/variations/pick.d.ts.map +1 -0
  289. package/dist/editor/variations/pick.js +23 -0
  290. package/dist/editor/variations/pick.js.map +1 -0
  291. package/dist/editor/variations.d.ts +28 -0
  292. package/dist/editor/variations.d.ts.map +1 -0
  293. package/dist/editor/variations.js +88 -0
  294. package/dist/editor/variations.js.map +1 -0
  295. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  296. package/dist/figma-api/accessors/reactions.js +4 -1
  297. package/dist/figma-api/accessors/reactions.js.map +1 -1
  298. package/dist/figma-api/accessors/text/index.js +3 -0
  299. package/dist/figma-api/accessors/text/index.js.map +1 -1
  300. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  301. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  302. package/dist/figma-api/accessors/text/opentype.js +28 -0
  303. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  304. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  305. package/dist/figma-api/accessors/visual.js +33 -0
  306. package/dist/figma-api/accessors/visual.js.map +1 -1
  307. package/dist/figma-api/effects.d.ts +79 -3
  308. package/dist/figma-api/effects.d.ts.map +1 -1
  309. package/dist/figma-api/effects.js +150 -9
  310. package/dist/figma-api/effects.js.map +1 -1
  311. package/dist/figma-api/fresh-read.d.ts +15 -0
  312. package/dist/figma-api/fresh-read.d.ts.map +1 -0
  313. package/dist/figma-api/fresh-read.js +54 -0
  314. package/dist/figma-api/fresh-read.js.map +1 -0
  315. package/dist/figma-api/graph-ref.d.ts +9 -0
  316. package/dist/figma-api/graph-ref.d.ts.map +1 -0
  317. package/dist/figma-api/graph-ref.js +14 -0
  318. package/dist/figma-api/graph-ref.js.map +1 -0
  319. package/dist/figma-api/index.d.ts +11 -1
  320. package/dist/figma-api/index.d.ts.map +1 -1
  321. package/dist/figma-api/index.js +16 -4
  322. package/dist/figma-api/index.js.map +1 -1
  323. package/dist/figma-api/overrides.d.ts +13 -1
  324. package/dist/figma-api/overrides.d.ts.map +1 -1
  325. package/dist/figma-api/overrides.js +196 -4
  326. package/dist/figma-api/overrides.js.map +1 -1
  327. package/dist/figma-api/paints.d.ts +3 -3
  328. package/dist/figma-api/paints.d.ts.map +1 -1
  329. package/dist/figma-api/paints.js +14 -4
  330. package/dist/figma-api/paints.js.map +1 -1
  331. package/dist/figma-api/pending-layout.d.ts +3 -3
  332. package/dist/figma-api/pending-layout.d.ts.map +1 -1
  333. package/dist/figma-api/pending-layout.js +7 -3
  334. package/dist/figma-api/pending-layout.js.map +1 -1
  335. package/dist/figma-api/pending-sync.d.ts +1 -1
  336. package/dist/figma-api/pending-sync.d.ts.map +1 -1
  337. package/dist/figma-api/pending-sync.js +3 -1
  338. package/dist/figma-api/pending-sync.js.map +1 -1
  339. package/dist/figma-api/proxy.d.ts +4 -1
  340. package/dist/figma-api/proxy.d.ts.map +1 -1
  341. package/dist/figma-api/proxy.js +2 -1
  342. package/dist/figma-api/proxy.js.map +1 -1
  343. package/dist/figma-api/reactions.d.ts +59 -15
  344. package/dist/figma-api/reactions.d.ts.map +1 -1
  345. package/dist/figma-api/reactions.js +160 -32
  346. package/dist/figma-api/reactions.js.map +1 -1
  347. package/dist/figma-api/render-bounds.js +1 -1
  348. package/dist/figma-api/surface.d.ts +6 -3
  349. package/dist/figma-api/surface.d.ts.map +1 -1
  350. package/dist/figma-api/surface.js +6 -2
  351. package/dist/figma-api/surface.js.map +1 -1
  352. package/dist/figma-api/transform.d.ts +1 -1
  353. package/dist/figma-api/variables/index.d.ts.map +1 -1
  354. package/dist/figma-api/variables/index.js +2 -2
  355. package/dist/figma-api/variables/index.js.map +1 -1
  356. package/dist/geometry/figma.d.ts +1 -1
  357. package/dist/geometry/image-crop.d.ts +1 -1
  358. package/dist/geometry/image-crop.js +1 -1
  359. package/dist/index.d.ts +4 -2
  360. package/dist/index.js +4 -2
  361. package/dist/io/formats/boolean-path.d.ts +19 -0
  362. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  363. package/dist/io/formats/boolean-path.js +47 -0
  364. package/dist/io/formats/boolean-path.js.map +1 -0
  365. package/dist/io/formats/design-tokens/css/known.js +1 -1
  366. package/dist/io/formats/design-tokens/css/known.js.map +1 -1
  367. package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
  368. package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
  369. package/dist/io/formats/design-tokens/css/read.js +11 -5
  370. package/dist/io/formats/design-tokens/css/read.js.map +1 -1
  371. package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
  372. package/dist/io/formats/design-tokens/css/sync.js +17 -4
  373. package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
  374. package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
  375. package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
  376. package/dist/io/formats/design-tokens/css/values.js +24 -8
  377. package/dist/io/formats/design-tokens/css/values.js.map +1 -1
  378. package/dist/io/formats/design-tokens/decode.d.ts +7 -6
  379. package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
  380. package/dist/io/formats/design-tokens/decode.js +14 -13
  381. package/dist/io/formats/design-tokens/decode.js.map +1 -1
  382. package/dist/io/formats/design-tokens/export.js +3 -3
  383. package/dist/io/formats/design-tokens/export.js.map +1 -1
  384. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  385. package/dist/io/formats/design-tokens/index.js +4 -1
  386. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  387. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  388. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  389. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  390. package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
  391. package/dist/io/formats/design-tokens/plan/index.js +4 -3
  392. package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
  393. package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
  394. package/dist/io/formats/design-tokens/plan/styles.js +9 -9
  395. package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
  396. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  397. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  398. package/dist/io/formats/design-tokens/project.js +29 -8
  399. package/dist/io/formats/design-tokens/project.js.map +1 -1
  400. package/dist/io/formats/design-tokens/styles.d.ts +4 -4
  401. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  402. package/dist/io/formats/design-tokens/styles.js +7 -7
  403. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  404. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  405. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  406. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  407. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  408. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  409. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  410. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  411. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  412. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  413. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  414. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  415. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  416. package/dist/io/formats/design-tokens/values.d.ts +10 -5
  417. package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
  418. package/dist/io/formats/design-tokens/values.js +13 -7
  419. package/dist/io/formats/design-tokens/values.js.map +1 -1
  420. package/dist/io/formats/drawio/edges.d.ts +7 -1
  421. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  422. package/dist/io/formats/drawio/edges.js +54 -1
  423. package/dist/io/formats/drawio/edges.js.map +1 -1
  424. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  425. package/dist/io/formats/drawio/export.js +19 -2
  426. package/dist/io/formats/drawio/export.js.map +1 -1
  427. package/dist/io/formats/drawio/index.js +1 -0
  428. package/dist/io/formats/drawio/index.js.map +1 -1
  429. package/dist/io/formats/drawio/placement.d.ts +1 -1
  430. package/dist/io/formats/drawio/warnings.js +2 -2
  431. package/dist/io/formats/drawio/warnings.js.map +1 -1
  432. package/dist/io/formats/fig/export/index.d.ts.map +1 -1
  433. package/dist/io/formats/fig/export/index.js +15 -3
  434. package/dist/io/formats/fig/export/index.js.map +1 -1
  435. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  436. package/dist/io/formats/fig/export/patch/index.js +7 -1
  437. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  438. package/dist/io/formats/fig/export/setup.d.ts +7 -2
  439. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  440. package/dist/io/formats/fig/export/setup.js +12 -13
  441. package/dist/io/formats/fig/export/setup.js.map +1 -1
  442. package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
  443. package/dist/io/formats/fig/export/variables.js +9 -7
  444. package/dist/io/formats/fig/export/variables.js.map +1 -1
  445. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  446. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  447. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  448. package/dist/io/formats/html/import.d.ts.map +1 -1
  449. package/dist/io/formats/html/import.js +3 -1
  450. package/dist/io/formats/html/import.js.map +1 -1
  451. package/dist/io/formats/html/index.d.ts +2 -2
  452. package/dist/io/formats/html/index.d.ts.map +1 -1
  453. package/dist/io/formats/html/index.js +6 -4
  454. package/dist/io/formats/html/index.js.map +1 -1
  455. package/dist/io/formats/html/vectors.d.ts +2 -1
  456. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  457. package/dist/io/formats/html/vectors.js +4 -2
  458. package/dist/io/formats/html/vectors.js.map +1 -1
  459. package/dist/io/formats/mermaid/layers.js +2 -2
  460. package/dist/io/formats/mermaid/layers.js.map +1 -1
  461. package/dist/io/formats/pdf/document.d.ts +3 -1
  462. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  463. package/dist/io/formats/pdf/document.js +6 -3
  464. package/dist/io/formats/pdf/document.js.map +1 -1
  465. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  466. package/dist/io/formats/pdf/export.js +1 -0
  467. package/dist/io/formats/pdf/export.js.map +1 -1
  468. package/dist/io/formats/pdf/prepare.d.ts +4 -4
  469. package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
  470. package/dist/io/formats/pdf/prepare.js +2 -2
  471. package/dist/io/formats/pdf/prepare.js.map +1 -1
  472. package/dist/io/formats/pen/imports.d.ts +4 -1
  473. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  474. package/dist/io/formats/pen/imports.js.map +1 -1
  475. package/dist/io/formats/pen/index.d.ts.map +1 -1
  476. package/dist/io/formats/pen/index.js +35 -5
  477. package/dist/io/formats/pen/index.js.map +1 -1
  478. package/dist/io/formats/pptx/export.js +1 -1
  479. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  480. package/dist/io/formats/pptx/style.js +1 -1
  481. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  482. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  483. package/dist/io/formats/raster/adjusted-images.js +118 -0
  484. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  485. package/dist/io/formats/raster/headless.d.ts +11 -1
  486. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  487. package/dist/io/formats/raster/headless.js +4 -4
  488. package/dist/io/formats/raster/headless.js.map +1 -1
  489. package/dist/io/formats/raster/index.d.ts +2 -2
  490. package/dist/io/formats/raster/pixels.d.ts +7 -1
  491. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  492. package/dist/io/formats/raster/pixels.js.map +1 -1
  493. package/dist/io/formats/raster/render.d.ts +1 -1
  494. package/dist/io/formats/raster/render.d.ts.map +1 -1
  495. package/dist/io/formats/raster/render.js +13 -4
  496. package/dist/io/formats/raster/render.js.map +1 -1
  497. package/dist/io/formats/svg/defs.d.ts +10 -8
  498. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  499. package/dist/io/formats/svg/defs.js +13 -64
  500. package/dist/io/formats/svg/defs.js.map +1 -1
  501. package/dist/io/formats/svg/effects.d.ts +16 -0
  502. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  503. package/dist/io/formats/svg/effects.js +126 -0
  504. package/dist/io/formats/svg/effects.js.map +1 -0
  505. package/dist/io/formats/svg/export.d.ts +11 -2
  506. package/dist/io/formats/svg/export.d.ts.map +1 -1
  507. package/dist/io/formats/svg/export.js +177 -37
  508. package/dist/io/formats/svg/export.js.map +1 -1
  509. package/dist/io/formats/svg/filter.d.ts +30 -0
  510. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  511. package/dist/io/formats/svg/filter.js +48 -0
  512. package/dist/io/formats/svg/filter.js.map +1 -0
  513. package/dist/io/formats/svg/grain.d.ts +26 -0
  514. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  515. package/dist/io/formats/svg/grain.js +298 -0
  516. package/dist/io/formats/svg/grain.js.map +1 -0
  517. package/dist/io/formats/svg/import.d.ts +4 -2
  518. package/dist/io/formats/svg/import.d.ts.map +1 -1
  519. package/dist/io/formats/svg/import.js +2 -1
  520. package/dist/io/formats/svg/import.js.map +1 -1
  521. package/dist/io/formats/svg/strokes.d.ts +1 -1
  522. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  523. package/dist/io/formats/svg/strokes.js +1 -2
  524. package/dist/io/formats/svg/strokes.js.map +1 -1
  525. package/dist/io/formats/svg/text/export.d.ts.map +1 -1
  526. package/dist/io/formats/svg/text/export.js +8 -8
  527. package/dist/io/formats/svg/text/export.js.map +1 -1
  528. package/dist/io/formats/svg/text/import.js +1 -1
  529. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  530. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  531. package/dist/io/formats/svg/text/layout.js +8 -5
  532. package/dist/io/formats/svg/text/layout.js.map +1 -1
  533. package/dist/io/formats/video/composite.d.ts +18 -0
  534. package/dist/io/formats/video/composite.d.ts.map +1 -0
  535. package/dist/io/formats/video/composite.js +79 -0
  536. package/dist/io/formats/video/composite.js.map +1 -0
  537. package/dist/io/formats/video/formats.d.ts +29 -0
  538. package/dist/io/formats/video/formats.d.ts.map +1 -0
  539. package/dist/io/formats/video/formats.js +43 -0
  540. package/dist/io/formats/video/formats.js.map +1 -0
  541. package/dist/io/formats/video/gif.d.ts +13 -0
  542. package/dist/io/formats/video/gif.d.ts.map +1 -0
  543. package/dist/io/formats/video/gif.js +56 -0
  544. package/dist/io/formats/video/gif.js.map +1 -0
  545. package/dist/io/formats/video/index.d.ts +9 -0
  546. package/dist/io/formats/video/index.js +9 -0
  547. package/dist/io/formats/video/plan.d.ts +64 -0
  548. package/dist/io/formats/video/plan.d.ts.map +1 -0
  549. package/dist/io/formats/video/plan.js +90 -0
  550. package/dist/io/formats/video/plan.js.map +1 -0
  551. package/dist/io/formats/video/record.d.ts +36 -0
  552. package/dist/io/formats/video/record.d.ts.map +1 -0
  553. package/dist/io/formats/video/record.js +154 -0
  554. package/dist/io/formats/video/record.js.map +1 -0
  555. package/dist/io/formats/video/sink.d.ts +29 -0
  556. package/dist/io/formats/video/sink.d.ts.map +1 -0
  557. package/dist/io/formats/video/sink.js +16 -0
  558. package/dist/io/formats/video/sink.js.map +1 -0
  559. package/dist/io/formats/video/size.d.ts +19 -0
  560. package/dist/io/formats/video/size.d.ts.map +1 -0
  561. package/dist/io/formats/video/size.js +26 -0
  562. package/dist/io/formats/video/size.js.map +1 -0
  563. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  564. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  565. package/dist/io/formats/video/webcodecs.js +74 -0
  566. package/dist/io/formats/video/webcodecs.js.map +1 -0
  567. package/dist/io/formats.d.ts.map +1 -1
  568. package/dist/io/formats.js +41 -11
  569. package/dist/io/formats.js.map +1 -1
  570. package/dist/io/subgraph.d.ts.map +1 -1
  571. package/dist/io/subgraph.js +1 -1
  572. package/dist/io/subgraph.js.map +1 -1
  573. package/dist/io/types.d.ts +20 -5
  574. package/dist/io/types.d.ts.map +1 -1
  575. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  576. package/dist/kiwi/fig/session/options.d.ts +3 -0
  577. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  578. package/dist/kiwi/fig/session/options.js +4 -0
  579. package/dist/kiwi/fig/session/options.js.map +1 -1
  580. package/dist/layout/auto-layout-handles.d.ts +66 -0
  581. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  582. package/dist/layout/auto-layout-handles.js +291 -0
  583. package/dist/layout/auto-layout-handles.js.map +1 -0
  584. package/dist/layout/yoga-helpers.d.ts +2 -1
  585. package/dist/layout/yoga-helpers.d.ts.map +1 -1
  586. package/dist/layout/yoga-helpers.js +7 -1
  587. package/dist/layout/yoga-helpers.js.map +1 -1
  588. package/dist/layout.d.ts +3 -2
  589. package/dist/layout.d.ts.map +1 -1
  590. package/dist/layout.js +26 -2
  591. package/dist/layout.js.map +1 -1
  592. package/dist/lint/fixes.d.ts.map +1 -1
  593. package/dist/lint/fixes.js +10 -4
  594. package/dist/lint/fixes.js.map +1 -1
  595. package/dist/lint/index.d.ts +3 -2
  596. package/dist/lint/index.js +2 -1
  597. package/dist/lint/linter.d.ts +12 -0
  598. package/dist/lint/linter.d.ts.map +1 -1
  599. package/dist/lint/linter.js +112 -10
  600. package/dist/lint/linter.js.map +1 -1
  601. package/dist/lint/presets.d.ts.map +1 -1
  602. package/dist/lint/presets.js +2 -0
  603. package/dist/lint/presets.js.map +1 -1
  604. package/dist/lint/rules/design-memory.d.ts +15 -0
  605. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  606. package/dist/lint/rules/design-memory.js +90 -0
  607. package/dist/lint/rules/design-memory.js.map +1 -0
  608. package/dist/lint/rules/index.d.ts +6 -5
  609. package/dist/lint/rules/index.d.ts.map +1 -1
  610. package/dist/lint/rules/index.js +6 -2
  611. package/dist/lint/rules/index.js.map +1 -1
  612. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  613. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  614. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  615. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  616. package/dist/lint/types.d.ts +25 -2
  617. package/dist/lint/types.d.ts.map +1 -1
  618. package/dist/node/video.d.ts +12 -0
  619. package/dist/node/video.d.ts.map +1 -0
  620. package/dist/node/video.js +206 -0
  621. package/dist/node/video.js.map +1 -0
  622. package/dist/pairdraw-api/comments.d.ts +4 -1
  623. package/dist/pairdraw-api/comments.d.ts.map +1 -1
  624. package/dist/pairdraw-api/comments.js +5 -0
  625. package/dist/pairdraw-api/comments.js.map +1 -1
  626. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  627. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  628. package/dist/pairdraw-api/design-memory.js +39 -0
  629. package/dist/pairdraw-api/design-memory.js.map +1 -0
  630. package/dist/pairdraw-api/index.d.ts +48 -4
  631. package/dist/pairdraw-api/index.d.ts.map +1 -1
  632. package/dist/pairdraw-api/index.js +59 -6
  633. package/dist/pairdraw-api/index.js.map +1 -1
  634. package/dist/pairdraw-api/nodes.d.ts +13 -2
  635. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  636. package/dist/pairdraw-api/nodes.js +28 -1
  637. package/dist/pairdraw-api/nodes.js.map +1 -1
  638. package/dist/pairdraw-api/variations.d.ts +48 -0
  639. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  640. package/dist/pairdraw-api/variations.js +76 -0
  641. package/dist/pairdraw-api/variations.js.map +1 -0
  642. package/dist/prototype/easing.d.ts +13 -0
  643. package/dist/prototype/easing.d.ts.map +1 -0
  644. package/dist/prototype/easing.js +36 -0
  645. package/dist/prototype/easing.js.map +1 -0
  646. package/dist/prototype/frames.d.ts +10 -0
  647. package/dist/prototype/frames.d.ts.map +1 -0
  648. package/dist/prototype/frames.js +12 -0
  649. package/dist/prototype/frames.js.map +1 -0
  650. package/dist/prototype/hit.d.ts +17 -0
  651. package/dist/prototype/hit.d.ts.map +1 -0
  652. package/dist/prototype/hit.js +45 -0
  653. package/dist/prototype/hit.js.map +1 -0
  654. package/dist/prototype/index.d.ts +14 -0
  655. package/dist/prototype/index.js +14 -0
  656. package/dist/prototype/pointer.d.ts +63 -0
  657. package/dist/prototype/pointer.d.ts.map +1 -0
  658. package/dist/prototype/pointer.js +104 -0
  659. package/dist/prototype/pointer.js.map +1 -0
  660. package/dist/prototype/reactions.d.ts +45 -0
  661. package/dist/prototype/reactions.d.ts.map +1 -0
  662. package/dist/prototype/reactions.js +122 -0
  663. package/dist/prototype/reactions.js.map +1 -0
  664. package/dist/prototype/scene.d.ts +35 -0
  665. package/dist/prototype/scene.d.ts.map +1 -0
  666. package/dist/prototype/scene.js +86 -0
  667. package/dist/prototype/scene.js.map +1 -0
  668. package/dist/prototype/scenes.d.ts +81 -0
  669. package/dist/prototype/scenes.d.ts.map +1 -0
  670. package/dist/prototype/scenes.js +175 -0
  671. package/dist/prototype/scenes.js.map +1 -0
  672. package/dist/prototype/scroll.d.ts +48 -0
  673. package/dist/prototype/scroll.d.ts.map +1 -0
  674. package/dist/prototype/scroll.js +159 -0
  675. package/dist/prototype/scroll.js.map +1 -0
  676. package/dist/prototype/session.d.ts +71 -0
  677. package/dist/prototype/session.d.ts.map +1 -0
  678. package/dist/prototype/session.js +135 -0
  679. package/dist/prototype/session.js.map +1 -0
  680. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  681. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  682. package/dist/prototype/smart-animate/animation.js +212 -0
  683. package/dist/prototype/smart-animate/animation.js.map +1 -0
  684. package/dist/prototype/smart-animate/match.d.ts +24 -0
  685. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  686. package/dist/prototype/smart-animate/match.js +72 -0
  687. package/dist/prototype/smart-animate/match.js.map +1 -0
  688. package/dist/prototype/snapshot.d.ts +19 -0
  689. package/dist/prototype/snapshot.d.ts.map +1 -0
  690. package/dist/prototype/snapshot.js +56 -0
  691. package/dist/prototype/snapshot.js.map +1 -0
  692. package/dist/prototype/timeline.d.ts +132 -0
  693. package/dist/prototype/timeline.d.ts.map +1 -0
  694. package/dist/prototype/timeline.js +260 -0
  695. package/dist/prototype/timeline.js.map +1 -0
  696. package/dist/rpc/analyze-commands.js +1 -1
  697. package/dist/rpc/read-commands.d.ts +2 -2
  698. package/dist/rpc/read-commands.js +2 -2
  699. package/dist/rpc/read-commands.js.map +1 -1
  700. package/dist/rpc/variables-command.js +2 -2
  701. package/dist/rpc/variables-command.js.map +1 -1
  702. package/dist/text/font/features.d.ts +9 -0
  703. package/dist/text/font/features.d.ts.map +1 -0
  704. package/dist/text/font/features.js +27 -0
  705. package/dist/text/font/features.js.map +1 -0
  706. package/dist/text/font/manager.d.ts +12 -0
  707. package/dist/text/font/manager.d.ts.map +1 -1
  708. package/dist/text/font/manager.js +60 -1
  709. package/dist/text/font/manager.js.map +1 -1
  710. package/dist/text/font/provider.d.ts +15 -0
  711. package/dist/text/font/provider.d.ts.map +1 -0
  712. package/dist/text/font/provider.js +18 -0
  713. package/dist/text/font/provider.js.map +1 -0
  714. package/dist/text/font/readiness.d.ts +32 -0
  715. package/dist/text/font/readiness.d.ts.map +1 -0
  716. package/dist/text/font/{status.js → readiness.js} +8 -4
  717. package/dist/text/font/readiness.js.map +1 -0
  718. package/dist/text/index.d.ts +12 -9
  719. package/dist/text/index.js +6 -3
  720. package/dist/text/prepare.d.ts +9 -4
  721. package/dist/text/prepare.d.ts.map +1 -1
  722. package/dist/text/prepare.js +9 -4
  723. package/dist/text/prepare.js.map +1 -1
  724. package/dist/text/replace-fonts.d.ts +41 -0
  725. package/dist/text/replace-fonts.d.ts.map +1 -0
  726. package/dist/text/replace-fonts.js +121 -0
  727. package/dist/text/replace-fonts.js.map +1 -0
  728. package/dist/tools/analyze/colors.js +1 -1
  729. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  730. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  731. package/dist/tools/analyze/responsive/index.js +192 -0
  732. package/dist/tools/analyze/responsive/index.js.map +1 -0
  733. package/dist/tools/analyze/responsive/widths.d.ts +27 -0
  734. package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
  735. package/dist/tools/analyze/responsive/widths.js +49 -0
  736. package/dist/tools/analyze/responsive/widths.js.map +1 -0
  737. package/dist/tools/analyze.d.ts +3 -1
  738. package/dist/tools/analyze.js +3 -1
  739. package/dist/tools/codegen/token-sync.d.ts +7 -0
  740. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  741. package/dist/tools/codegen/token-sync.js +85 -0
  742. package/dist/tools/codegen/token-sync.js.map +1 -0
  743. package/dist/tools/codegen/tokens.d.ts +1 -1
  744. package/dist/tools/codegen/tokens.d.ts.map +1 -1
  745. package/dist/tools/codegen/tokens.js +2 -2
  746. package/dist/tools/codegen/tokens.js.map +1 -1
  747. package/dist/tools/codegen.d.ts +2 -1
  748. package/dist/tools/codegen.js +2 -1
  749. package/dist/tools/comments.d.ts.map +1 -1
  750. package/dist/tools/comments.js +2 -2
  751. package/dist/tools/comments.js.map +1 -1
  752. package/dist/tools/component-catalog.d.ts.map +1 -1
  753. package/dist/tools/component-catalog.js +5 -3
  754. package/dist/tools/component-catalog.js.map +1 -1
  755. package/dist/tools/create/components.d.ts.map +1 -1
  756. package/dist/tools/create/components.js +4 -0
  757. package/dist/tools/create/components.js.map +1 -1
  758. package/dist/tools/create/html.d.ts.map +1 -1
  759. package/dist/tools/create/html.js +2 -3
  760. package/dist/tools/create/html.js.map +1 -1
  761. package/dist/tools/create/icons.d.ts.map +1 -1
  762. package/dist/tools/create/icons.js +2 -1
  763. package/dist/tools/create/icons.js.map +1 -1
  764. package/dist/tools/create/mermaid.js +1 -0
  765. package/dist/tools/create/mermaid.js.map +1 -1
  766. package/dist/tools/create/svg.js +5 -1
  767. package/dist/tools/create/svg.js.map +1 -1
  768. package/dist/tools/create/vector.js +2 -2
  769. package/dist/tools/create/vector.js.map +1 -1
  770. package/dist/tools/css/shorthand.d.ts +20 -0
  771. package/dist/tools/css/shorthand.d.ts.map +1 -0
  772. package/dist/tools/css/shorthand.js +54 -0
  773. package/dist/tools/css/shorthand.js.map +1 -0
  774. package/dist/tools/describe/index.js +2 -2
  775. package/dist/tools/describe/index.js.map +1 -1
  776. package/dist/tools/describe/issues.js +1 -1
  777. package/dist/tools/design-memory.d.ts +8 -0
  778. package/dist/tools/design-memory.d.ts.map +1 -0
  779. package/dist/tools/design-memory.js +68 -0
  780. package/dist/tools/design-memory.js.map +1 -0
  781. package/dist/tools/html-host.d.ts.map +1 -1
  782. package/dist/tools/html-host.js +5 -3
  783. package/dist/tools/html-host.js.map +1 -1
  784. package/dist/tools/image-ai/apply.d.ts.map +1 -1
  785. package/dist/tools/image-ai/apply.js +1 -3
  786. package/dist/tools/image-ai/apply.js.map +1 -1
  787. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  788. package/dist/tools/image-ai/generate.js +2 -0
  789. package/dist/tools/image-ai/generate.js.map +1 -1
  790. package/dist/tools/image-ai/service.d.ts.map +1 -1
  791. package/dist/tools/image-ai/service.js +5 -3
  792. package/dist/tools/image-ai/service.js.map +1 -1
  793. package/dist/tools/index.d.ts +3 -1
  794. package/dist/tools/index.js +3 -1
  795. package/dist/tools/modify/effects.js +1 -1
  796. package/dist/tools/modify/effects.js.map +1 -1
  797. package/dist/tools/modify/fonts.d.ts +6 -0
  798. package/dist/tools/modify/fonts.d.ts.map +1 -0
  799. package/dist/tools/modify/fonts.js +27 -0
  800. package/dist/tools/modify/fonts.js.map +1 -0
  801. package/dist/tools/modify/geometry.d.ts.map +1 -1
  802. package/dist/tools/modify/geometry.js +14 -3
  803. package/dist/tools/modify/geometry.js.map +1 -1
  804. package/dist/tools/modify/layout.d.ts.map +1 -1
  805. package/dist/tools/modify/layout.js +35 -8
  806. package/dist/tools/modify/layout.js.map +1 -1
  807. package/dist/tools/modify/matching.d.ts.map +1 -1
  808. package/dist/tools/modify/matching.js +10 -10
  809. package/dist/tools/modify/matching.js.map +1 -1
  810. package/dist/tools/modify/paint.d.ts.map +1 -1
  811. package/dist/tools/modify/paint.js +56 -4
  812. package/dist/tools/modify/paint.js.map +1 -1
  813. package/dist/tools/modify/reactions.d.ts.map +1 -1
  814. package/dist/tools/modify/reactions.js +2 -2
  815. package/dist/tools/modify/reactions.js.map +1 -1
  816. package/dist/tools/modify/text.d.ts.map +1 -1
  817. package/dist/tools/modify/text.js +29 -8
  818. package/dist/tools/modify/text.js.map +1 -1
  819. package/dist/tools/modify/update.d.ts +10 -1
  820. package/dist/tools/modify/update.d.ts.map +1 -1
  821. package/dist/tools/modify/update.js +34 -3
  822. package/dist/tools/modify/update.js.map +1 -1
  823. package/dist/tools/modify.d.ts +2 -1
  824. package/dist/tools/modify.js +2 -1
  825. package/dist/tools/prompts/codegen.js +1 -1
  826. package/dist/tools/prompts/codegen.js.map +1 -1
  827. package/dist/tools/read/css.d.ts +14 -0
  828. package/dist/tools/read/css.d.ts.map +1 -0
  829. package/dist/tools/read/css.js +306 -0
  830. package/dist/tools/read/css.js.map +1 -0
  831. package/dist/tools/read/fonts.d.ts.map +1 -1
  832. package/dist/tools/read/fonts.js +17 -2
  833. package/dist/tools/read/fonts.js.map +1 -1
  834. package/dist/tools/read/libraries.js +1 -0
  835. package/dist/tools/read/libraries.js.map +1 -1
  836. package/dist/tools/read/reactions.js +1 -1
  837. package/dist/tools/read/reactions.js.map +1 -1
  838. package/dist/tools/read/space.d.ts +3 -1
  839. package/dist/tools/read/space.d.ts.map +1 -1
  840. package/dist/tools/read/space.js +4 -5
  841. package/dist/tools/read/space.js.map +1 -1
  842. package/dist/tools/read.d.ts +2 -1
  843. package/dist/tools/read.js +2 -1
  844. package/dist/tools/registry/core.d.ts +1 -1
  845. package/dist/tools/registry/core.d.ts.map +1 -1
  846. package/dist/tools/registry/core.js +5 -1
  847. package/dist/tools/registry/core.js.map +1 -1
  848. package/dist/tools/registry/extended.d.ts.map +1 -1
  849. package/dist/tools/registry/extended.js +16 -1
  850. package/dist/tools/registry/extended.js.map +1 -1
  851. package/dist/tools/schema.d.ts +24 -6
  852. package/dist/tools/schema.d.ts.map +1 -1
  853. package/dist/tools/schema.js +10 -6
  854. package/dist/tools/schema.js.map +1 -1
  855. package/dist/tools/script/host.d.ts.map +1 -1
  856. package/dist/tools/script/host.js +5 -3
  857. package/dist/tools/script/host.js.map +1 -1
  858. package/dist/tools/stock-photo.js +1 -0
  859. package/dist/tools/stock-photo.js.map +1 -1
  860. package/dist/tools/structure/basic.d.ts.map +1 -1
  861. package/dist/tools/structure/basic.js +1 -0
  862. package/dist/tools/structure/basic.js.map +1 -1
  863. package/dist/tools/structure/batch.d.ts.map +1 -1
  864. package/dist/tools/structure/batch.js +8 -1
  865. package/dist/tools/structure/batch.js.map +1 -1
  866. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  867. package/dist/tools/structure/hierarchy.js +4 -0
  868. package/dist/tools/structure/hierarchy.js.map +1 -1
  869. package/dist/tools/structure/variations.d.ts +8 -0
  870. package/dist/tools/structure/variations.d.ts.map +1 -0
  871. package/dist/tools/structure/variations.js +106 -0
  872. package/dist/tools/structure/variations.js.map +1 -0
  873. package/dist/tools/structure.d.ts +2 -1
  874. package/dist/tools/structure.js +2 -1
  875. package/dist/tools/styles/types.d.ts +2 -4
  876. package/dist/tools/styles/types.d.ts.map +1 -1
  877. package/dist/tools/styles/types.js.map +1 -1
  878. package/dist/tools/variables/collections.js +1 -1
  879. package/dist/tools/variables/collections.js.map +1 -1
  880. package/dist/tools/variables/values.d.ts.map +1 -1
  881. package/dist/tools/variables/values.js +4 -4
  882. package/dist/tools/variables/values.js.map +1 -1
  883. package/dist/tools/vector/boolean.d.ts.map +1 -1
  884. package/dist/tools/vector/boolean.js +4 -0
  885. package/dist/tools/vector/boolean.js.map +1 -1
  886. package/dist/tools/vector/vectorize.d.ts.map +1 -1
  887. package/dist/tools/vector/vectorize.js +7 -4
  888. package/dist/tools/vector/vectorize.js.map +1 -1
  889. package/dist/tools/vector/video.d.ts +6 -0
  890. package/dist/tools/vector/video.d.ts.map +1 -0
  891. package/dist/tools/vector/video.js +133 -0
  892. package/dist/tools/vector/video.js.map +1 -0
  893. package/dist/tools/vector.d.ts +2 -1
  894. package/dist/tools/vector.js +2 -1
  895. package/dist/tools/video-host.d.ts +12 -0
  896. package/dist/tools/video-host.d.ts.map +1 -0
  897. package/dist/tools/video-host.js +21 -0
  898. package/dist/tools/video-host.js.map +1 -0
  899. package/dist/vector/point-transform.d.ts +1 -1
  900. package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
  901. package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
  902. package/dist/vector/vectorize/svg/gradients.js +5 -5
  903. package/dist/vector/vectorize/svg/gradients.js.map +1 -1
  904. package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
  905. package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
  906. package/dist/vector/vectorize/svg/to-vectors.js +13 -12
  907. package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
  908. package/package.json +31 -9
  909. package/src/ai/providers.ts +2 -0
  910. package/src/cache/resource.ts +24 -1
  911. package/src/canvas/effects.ts +47 -50
  912. package/src/canvas/fills.ts +19 -15
  913. package/src/canvas/images/adjustments.ts +203 -0
  914. package/src/canvas/images/sampling.ts +88 -0
  915. package/src/canvas/index.ts +1 -0
  916. package/src/canvas/masks.ts +1 -1
  917. package/src/canvas/noise/render.ts +75 -0
  918. package/src/canvas/noise/shader.ts +169 -0
  919. package/src/canvas/noise/table.ts +91 -0
  920. package/src/canvas/noise/tile.ts +95 -0
  921. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  922. package/src/canvas/renderer/colors.ts +76 -50
  923. package/src/canvas/renderer/document-surface.ts +53 -0
  924. package/src/canvas/renderer/fonts.ts +6 -4
  925. package/src/canvas/renderer/lifecycle.ts +10 -4
  926. package/src/canvas/renderer/methods.ts +1 -0
  927. package/src/canvas/renderer/pipeline.ts +40 -4
  928. package/src/canvas/renderer/play-scenes.ts +51 -0
  929. package/src/canvas/renderer/retained-backing.ts +2 -1
  930. package/src/canvas/renderer/tiles/cache.ts +54 -1
  931. package/src/canvas/renderer/tiles/controller.ts +30 -1
  932. package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
  933. package/src/canvas/renderer/types.ts +18 -2
  934. package/src/canvas/renderer.ts +76 -14
  935. package/src/canvas/scene.ts +69 -12
  936. package/src/canvas/shaders/effect.ts +2 -1
  937. package/src/canvas/shadows/shape.ts +4 -2
  938. package/src/canvas/shadows.ts +5 -2
  939. package/src/canvas/text/decorations.ts +15 -5
  940. package/src/canvas/text/index.ts +9 -1
  941. package/src/canvas/text/paragraph/index.ts +16 -6
  942. package/src/canvas/text/renderer.ts +2 -1
  943. package/src/canvas/text/shape.ts +4 -4
  944. package/src/canvas/texture.ts +137 -0
  945. package/src/clipboard.ts +23 -10
  946. package/src/constants.ts +6 -0
  947. package/src/design-memory/check.ts +376 -0
  948. package/src/design-memory/describe.ts +77 -0
  949. package/src/design-memory/distil.ts +69 -0
  950. package/src/design-memory/document.ts +80 -0
  951. package/src/design-memory/guard.ts +157 -0
  952. package/src/design-memory/index.ts +8 -0
  953. package/src/design-memory/refusal.ts +90 -0
  954. package/src/design-memory/rules.ts +274 -0
  955. package/src/design-memory/values.ts +179 -0
  956. package/src/editor/bridges/components.ts +2 -0
  957. package/src/editor/clipboard/assets.ts +6 -2
  958. package/src/editor/clipboard/component-matches.ts +65 -0
  959. package/src/editor/clipboard/dependencies.ts +22 -1
  960. package/src/editor/clipboard/export.ts +24 -7
  961. package/src/editor/clipboard.ts +74 -20
  962. package/src/editor/components/instances.ts +31 -0
  963. package/src/editor/components/properties.ts +3 -2
  964. package/src/editor/create.ts +25 -69
  965. package/src/editor/design-memory.ts +39 -0
  966. package/src/editor/design-tokens.ts +41 -2
  967. package/src/editor/document-colors.ts +65 -0
  968. package/src/editor/eyedropper.ts +208 -0
  969. package/src/editor/fonts.ts +19 -0
  970. package/src/editor/history/atomic-tool.ts +32 -3
  971. package/src/editor/history/capture.ts +19 -0
  972. package/src/editor/history/document-change.ts +5 -17
  973. package/src/editor/history/edit.ts +11 -1
  974. package/src/editor/history/subtree.ts +13 -2
  975. package/src/editor/index.ts +11 -0
  976. package/src/editor/pages.ts +40 -29
  977. package/src/editor/play/states.ts +1 -1
  978. package/src/editor/read-only/actions.ts +4 -0
  979. package/src/editor/render-requests.ts +83 -0
  980. package/src/editor/selection/overlays.ts +1 -0
  981. package/src/editor/structure/state.ts +2 -1
  982. package/src/editor/text.ts +2 -1
  983. package/src/editor/tool-registry.ts +2 -1
  984. package/src/editor/types.ts +4 -0
  985. package/src/editor/variables.ts +3 -3
  986. package/src/editor/variations/create.ts +235 -0
  987. package/src/editor/variations/pick.ts +35 -0
  988. package/src/editor/variations.ts +110 -0
  989. package/src/figma-api/accessors/reactions.ts +11 -1
  990. package/src/figma-api/accessors/text/index.ts +7 -0
  991. package/src/figma-api/accessors/text/opentype.ts +33 -0
  992. package/src/figma-api/accessors/visual.ts +55 -2
  993. package/src/figma-api/compatibility.ts +5 -2
  994. package/src/figma-api/effects.ts +143 -5
  995. package/src/figma-api/fresh-read.ts +57 -0
  996. package/src/figma-api/graph-ref.ts +13 -0
  997. package/src/figma-api/index.ts +22 -4
  998. package/src/figma-api/overrides.ts +295 -3
  999. package/src/figma-api/paints.ts +24 -9
  1000. package/src/figma-api/pending-layout.ts +7 -3
  1001. package/src/figma-api/pending-sync.ts +4 -1
  1002. package/src/figma-api/proxy.ts +8 -2
  1003. package/src/figma-api/reactions.ts +212 -33
  1004. package/src/figma-api/surface.ts +6 -2
  1005. package/src/figma-api/variables/index.ts +5 -4
  1006. package/src/global.d.ts +26 -0
  1007. package/src/io/formats/boolean-path.ts +60 -0
  1008. package/src/io/formats/design-tokens/css/known.ts +1 -1
  1009. package/src/io/formats/design-tokens/css/read.ts +20 -7
  1010. package/src/io/formats/design-tokens/css/sync.ts +9 -4
  1011. package/src/io/formats/design-tokens/css/values.ts +37 -9
  1012. package/src/io/formats/design-tokens/decode.ts +17 -12
  1013. package/src/io/formats/design-tokens/export.ts +3 -3
  1014. package/src/io/formats/design-tokens/index.ts +21 -0
  1015. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  1016. package/src/io/formats/design-tokens/plan/index.ts +6 -5
  1017. package/src/io/formats/design-tokens/plan/styles.ts +37 -10
  1018. package/src/io/formats/design-tokens/project.ts +40 -9
  1019. package/src/io/formats/design-tokens/styles.ts +20 -9
  1020. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  1021. package/src/io/formats/design-tokens/sync/drift.ts +589 -0
  1022. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  1023. package/src/io/formats/design-tokens/values.ts +15 -8
  1024. package/src/io/formats/drawio/edges.ts +65 -0
  1025. package/src/io/formats/drawio/export.ts +37 -14
  1026. package/src/io/formats/drawio/index.ts +2 -0
  1027. package/src/io/formats/drawio/warnings.ts +2 -2
  1028. package/src/io/formats/fig/export/index.ts +36 -3
  1029. package/src/io/formats/fig/export/patch/index.ts +12 -1
  1030. package/src/io/formats/fig/export/setup.ts +25 -15
  1031. package/src/io/formats/fig/export/variables.ts +17 -6
  1032. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  1033. package/src/io/formats/html/import.ts +9 -1
  1034. package/src/io/formats/html/index.ts +14 -7
  1035. package/src/io/formats/html/vectors.ts +9 -2
  1036. package/src/io/formats/mermaid/layers.ts +2 -2
  1037. package/src/io/formats/pdf/document.ts +14 -4
  1038. package/src/io/formats/pdf/export.ts +1 -0
  1039. package/src/io/formats/pdf/prepare.ts +6 -6
  1040. package/src/io/formats/pen/imports.ts +5 -6
  1041. package/src/io/formats/pen/index.ts +41 -7
  1042. package/src/io/formats/raster/adjusted-images.ts +125 -0
  1043. package/src/io/formats/raster/headless.ts +3 -3
  1044. package/src/io/formats/raster/index.ts +6 -1
  1045. package/src/io/formats/raster/pixels.ts +7 -0
  1046. package/src/io/formats/raster/render.ts +24 -5
  1047. package/src/io/formats/svg/defs.ts +24 -80
  1048. package/src/io/formats/svg/effects.ts +131 -0
  1049. package/src/io/formats/svg/export.ts +295 -49
  1050. package/src/io/formats/svg/filter.ts +57 -0
  1051. package/src/io/formats/svg/grain.ts +249 -0
  1052. package/src/io/formats/svg/import.ts +6 -3
  1053. package/src/io/formats/svg/strokes.ts +2 -2
  1054. package/src/io/formats/svg/text/export.ts +10 -8
  1055. package/src/io/formats/svg/text/layout.ts +15 -5
  1056. package/src/io/formats/video/composite.ts +79 -0
  1057. package/src/io/formats/video/formats.ts +77 -0
  1058. package/src/io/formats/video/gif.ts +65 -0
  1059. package/src/io/formats/video/index.ts +30 -0
  1060. package/src/io/formats/video/plan.ts +116 -0
  1061. package/src/io/formats/video/record.ts +227 -0
  1062. package/src/io/formats/video/sink.ts +32 -0
  1063. package/src/io/formats/video/size.ts +25 -0
  1064. package/src/io/formats/video/webcodecs.ts +89 -0
  1065. package/src/io/formats.ts +66 -11
  1066. package/src/io/subgraph.ts +4 -1
  1067. package/src/io/types.ts +29 -10
  1068. package/src/kiwi/fig/session/options.ts +4 -1
  1069. package/src/layout/auto-layout-handles.ts +396 -0
  1070. package/src/layout/yoga-helpers.ts +8 -0
  1071. package/src/layout.ts +49 -1
  1072. package/src/lint/fixes.ts +12 -3
  1073. package/src/lint/index.ts +3 -1
  1074. package/src/lint/linter.ts +108 -11
  1075. package/src/lint/presets.ts +2 -0
  1076. package/src/lint/rules/design-memory.ts +97 -0
  1077. package/src/lint/rules/index.ts +6 -1
  1078. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  1079. package/src/lint/types.ts +32 -0
  1080. package/src/node/video.ts +196 -0
  1081. package/src/pairdraw-api/comments.ts +6 -0
  1082. package/src/pairdraw-api/design-memory.ts +61 -0
  1083. package/src/pairdraw-api/index.ts +88 -9
  1084. package/src/pairdraw-api/nodes.ts +38 -0
  1085. package/src/pairdraw-api/variations.ts +109 -0
  1086. package/src/prototype/easing.ts +37 -0
  1087. package/src/prototype/frames.ts +9 -0
  1088. package/src/prototype/hit.ts +70 -0
  1089. package/src/prototype/index.ts +69 -0
  1090. package/src/prototype/pointer.ts +146 -0
  1091. package/src/prototype/reactions.ts +178 -0
  1092. package/src/prototype/scene.ts +116 -0
  1093. package/src/prototype/scenes.ts +256 -0
  1094. package/src/prototype/scroll.ts +190 -0
  1095. package/src/prototype/session.ts +188 -0
  1096. package/src/prototype/smart-animate/animation.ts +267 -0
  1097. package/src/prototype/smart-animate/match.ts +85 -0
  1098. package/src/prototype/snapshot.ts +60 -0
  1099. package/src/prototype/timeline.ts +400 -0
  1100. package/src/rpc/read-commands.ts +4 -4
  1101. package/src/rpc/variables-command.ts +2 -2
  1102. package/src/text/font/features.ts +27 -0
  1103. package/src/text/font/manager.ts +79 -1
  1104. package/src/text/font/provider.ts +26 -0
  1105. package/src/text/font/{status.ts → readiness.ts} +13 -9
  1106. package/src/text/index.ts +4 -1
  1107. package/src/text/prepare.ts +9 -4
  1108. package/src/text/replace-fonts.ts +171 -0
  1109. package/src/tools/analyze/responsive/index.ts +257 -0
  1110. package/src/tools/analyze/responsive/widths.ts +63 -0
  1111. package/src/tools/analyze.ts +4 -0
  1112. package/src/tools/codegen/token-sync.ts +98 -0
  1113. package/src/tools/codegen/tokens.ts +4 -2
  1114. package/src/tools/codegen.ts +1 -0
  1115. package/src/tools/comments.ts +6 -4
  1116. package/src/tools/component-catalog.ts +5 -3
  1117. package/src/tools/create/components.ts +4 -0
  1118. package/src/tools/create/html.ts +1 -3
  1119. package/src/tools/create/icons.ts +2 -1
  1120. package/src/tools/create/mermaid.ts +1 -0
  1121. package/src/tools/create/svg.ts +5 -1
  1122. package/src/tools/create/vector.ts +2 -2
  1123. package/src/tools/css/shorthand.ts +64 -0
  1124. package/src/tools/describe/index.ts +2 -8
  1125. package/src/tools/design-memory.ts +72 -0
  1126. package/src/tools/html-host.ts +5 -3
  1127. package/src/tools/image-ai/apply.ts +0 -2
  1128. package/src/tools/image-ai/generate.ts +2 -0
  1129. package/src/tools/image-ai/service.ts +5 -3
  1130. package/src/tools/index.ts +3 -0
  1131. package/src/tools/modify/effects.ts +1 -1
  1132. package/src/tools/modify/fonts.ts +34 -0
  1133. package/src/tools/modify/geometry.ts +16 -3
  1134. package/src/tools/modify/layout.ts +47 -13
  1135. package/src/tools/modify/matching.ts +14 -11
  1136. package/src/tools/modify/paint.ts +85 -5
  1137. package/src/tools/modify/reactions.ts +16 -8
  1138. package/src/tools/modify/text.ts +56 -15
  1139. package/src/tools/modify/update.ts +46 -2
  1140. package/src/tools/modify.ts +1 -0
  1141. package/src/tools/prompts/codegen.md +2 -1
  1142. package/src/tools/read/css.ts +365 -0
  1143. package/src/tools/read/fonts.ts +24 -2
  1144. package/src/tools/read/libraries.ts +1 -0
  1145. package/src/tools/read/reactions.ts +3 -2
  1146. package/src/tools/read/space.ts +3 -4
  1147. package/src/tools/read.ts +1 -0
  1148. package/src/tools/registry/core.ts +5 -2
  1149. package/src/tools/registry/extended.ts +28 -1
  1150. package/src/tools/schema.ts +42 -9
  1151. package/src/tools/script/host.ts +6 -3
  1152. package/src/tools/stock-photo.ts +1 -0
  1153. package/src/tools/structure/basic.ts +1 -0
  1154. package/src/tools/structure/batch.ts +12 -1
  1155. package/src/tools/structure/hierarchy.ts +4 -0
  1156. package/src/tools/structure/variations.ts +118 -0
  1157. package/src/tools/structure.ts +2 -0
  1158. package/src/tools/styles/types.ts +3 -4
  1159. package/src/tools/variables/collections.ts +1 -1
  1160. package/src/tools/variables/values.ts +16 -5
  1161. package/src/tools/vector/boolean.ts +4 -0
  1162. package/src/tools/vector/vectorize.ts +11 -4
  1163. package/src/tools/vector/video.ts +228 -0
  1164. package/src/tools/vector.ts +1 -0
  1165. package/src/tools/video-host.ts +20 -0
  1166. package/src/vector/vectorize/svg/gradients.ts +8 -5
  1167. package/src/vector/vectorize/svg/to-vectors.ts +48 -14
  1168. package/dist/text/font/status.d.ts +0 -28
  1169. package/dist/text/font/status.d.ts.map +0 -1
  1170. package/dist/text/font/status.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.js","names":[],"sources":["../../src/node/video.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\nimport { once } from 'node:events'\nimport { rmSync } from 'node:fs'\nimport { mkdtemp, readFile, rm, stat } from 'node:fs/promises'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\n\nimport type { VideoFormat, VideoHostEncoder, VideoSink } from '#core/io/formats/video'\n\n/** The encoder and settings ffmpeg records each format with: H.264 and VP9 in 4:2:0. */\nconst ENCODERS = {\n mp4: {\n encoder: 'libx264',\n args: ['-c:v', 'libx264', '-preset', 'medium', '-crf', '20', '-movflags', '+faststart']\n },\n webm: { encoder: 'libvpx-vp9', args: ['-c:v', 'libvpx-vp9', '-b:v', '0', '-crf', '32'] }\n} as const\n\n/** The tail of ffmpeg's error output a failure reports. */\nconst STDERR_TAIL = 2000\n\n/** Folders of ffmpeg sinks still running in this process, removed when it is interrupted. */\nconst temporaryDirs = new Set<string>()\nlet cleanupInstalled = false\n\nfunction cleanupTemporaryDirs(): void {\n for (const dir of temporaryDirs) rmSync(dir, { recursive: true, force: true })\n temporaryDirs.clear()\n removeCleanupListeners()\n}\n\nfunction interrupted(signal: 'SIGINT' | 'SIGTERM'): void {\n cleanupTemporaryDirs()\n // With our listener gone, the same signal takes its default path, so the exit code stays.\n process.kill(process.pid, signal)\n}\n\nconst onInterrupt = () => interrupted('SIGINT')\nconst onTerminate = () => interrupted('SIGTERM')\n\nfunction installCleanupListeners(): void {\n if (cleanupInstalled) return\n cleanupInstalled = true\n process.once('exit', cleanupTemporaryDirs)\n process.once('SIGINT', onInterrupt)\n process.once('SIGTERM', onTerminate)\n}\n\nfunction removeCleanupListeners(): void {\n if (!cleanupInstalled) return\n cleanupInstalled = false\n process.off('exit', cleanupTemporaryDirs)\n process.off('SIGINT', onInterrupt)\n process.off('SIGTERM', onTerminate)\n}\n\nfunction trackTemporaryDir(dir: string): void {\n temporaryDirs.add(dir)\n installCleanupListeners()\n}\n\nfunction releaseTemporaryDir(dir: string): void {\n temporaryDirs.delete(dir)\n if (temporaryDirs.size === 0) removeCleanupListeners()\n}\n\n/** The encoders `command` lists, or none when it cannot run. */\nfunction listEncoders(command: string): Promise<string> {\n return new Promise((resolve) => {\n const child = spawn(command, ['-hide_banner', '-encoders'], {\n stdio: ['ignore', 'pipe', 'ignore']\n })\n let output = ''\n child.stdout.setEncoding('utf8')\n child.stdout.on('data', (chunk: string) => {\n output += chunk\n })\n child.on('error', () => resolve(''))\n child.on('close', (code) => resolve(code === 0 ? output : ''))\n })\n}\n\n/**\n * Encodes recorded frames with an ffmpeg on the machine, for hosts without WebCodecs such as the\n * CLI: raw RGBA frames go to its input as they come, and the file is read back when it ends.\n * A missing `command`, or one without libx264 or libvpx-vp9, supports nothing.\n */\nexport function createFFmpegEncoder(command = 'ffmpeg'): VideoHostEncoder {\n let encoders: Promise<string> | null = null\n\n return {\n async supports(format: VideoFormat) {\n if (format === 'gif') return false\n encoders ??= listEncoders(command)\n return (await encoders).includes(ENCODERS[format].encoder)\n },\n async create(format, options): Promise<VideoSink> {\n if (format === 'gif') throw new Error('ffmpeg records MP4 and WebM, not GIF')\n const dir = await mkdtemp(join(tmpdir(), 'pairdraw-ffmpeg-'))\n trackTemporaryDir(dir)\n const output = join(dir, `video.${format}`)\n let byteLength = 0\n const state = {\n /** finish or cancel ran, so no frame may follow. */\n ended: false,\n /** ffmpeg stopped reading, which a dying ffmpeg does before it exits. */\n inputClosed: false\n }\n const child = spawn(\n command,\n [\n '-hide_banner',\n '-loglevel',\n 'error',\n '-f',\n 'rawvideo',\n '-pix_fmt',\n 'rgba',\n '-s',\n `${options.width}x${options.height}`,\n '-r',\n String(options.fps),\n '-i',\n 'pipe:0',\n ...ENCODERS[format].args,\n '-pix_fmt',\n 'yuv420p',\n '-y',\n output\n ],\n { stdio: ['pipe', 'ignore', 'pipe'] }\n )\n let stderr = ''\n // ffmpeg stopping early closes its input; the frame that finds it closed reports why.\n child.stdin.on('error', () => {\n state.inputClosed = true\n })\n child.stderr.setEncoding('utf8')\n child.stderr.on('data', (chunk: string) => {\n stderr = (stderr + chunk).slice(-STDERR_TAIL)\n })\n const exited = new Promise<number | null>((resolve) => {\n child.on('error', () => resolve(-1))\n child.on('close', (code) => resolve(code))\n })\n\n const failure = () =>\n new Error(`ffmpeg could not encode the video: ${stderr.trim() || 'it stopped'}`)\n /** Waits for ffmpeg to exit, so its error output is complete, then reports it. */\n const failed = async (): Promise<never> => {\n await exited\n throw failure()\n }\n\n return {\n async add(image) {\n if (state.ended) throw new Error('The recording has ended')\n if (state.inputClosed) await failed()\n if (!child.stdin.write(image.data)) {\n // `once` drops its listeners whichever way the wait ends; ffmpeg exiting ends it too.\n const drained = once(child.stdin, 'drain').then(() => true)\n const ok = await Promise.race([drained, exited.then(() => false)]).catch(() => false)\n if (!ok || state.inputClosed) await failed()\n }\n byteLength = (await stat(output).catch(() => null))?.size ?? byteLength\n },\n async finish() {\n if (state.ended) throw new Error('The recording has ended')\n state.ended = true\n child.stdin.end()\n const code = await exited\n try {\n if (code !== 0) throw failure()\n return new Uint8Array(await readFile(output))\n } finally {\n await rm(dir, { recursive: true, force: true })\n releaseTemporaryDir(dir)\n }\n },\n async cancel() {\n if (!state.ended) {\n state.ended = true\n child.kill('SIGKILL')\n }\n await exited\n // Whatever ended the recording, its folder goes with it.\n await rm(dir, { recursive: true, force: true })\n releaseTemporaryDir(dir)\n },\n get byteLength() {\n return byteLength\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,WAAW;CACf,KAAK;EACH,SAAS;EACT,MAAM;GAAC;GAAQ;GAAW;GAAW;GAAU;GAAQ;GAAM;GAAa;EAAY;CACxF;CACA,MAAM;EAAE,SAAS;EAAc,MAAM;GAAC;GAAQ;GAAc;GAAQ;GAAK;GAAQ;EAAI;CAAE;AACzF;;AAMA,MAAM,gCAAgB,IAAI,IAAY;AACtC,IAAI,mBAAmB;AAEvB,SAAS,uBAA6B;CACpC,KAAK,MAAM,OAAO,eAAe,OAAO,KAAK;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC;CAC7E,cAAc,MAAM;CACpB,uBAAuB;AACzB;AAEA,SAAS,YAAY,QAAoC;CACvD,qBAAqB;CAErB,QAAQ,KAAK,QAAQ,KAAK,MAAM;AAClC;AAEA,MAAM,oBAAoB,YAAY,QAAQ;AAC9C,MAAM,oBAAoB,YAAY,SAAS;AAE/C,SAAS,0BAAgC;CACvC,IAAI,kBAAkB;CACtB,mBAAmB;CACnB,QAAQ,KAAK,QAAQ,oBAAoB;CACzC,QAAQ,KAAK,UAAU,WAAW;CAClC,QAAQ,KAAK,WAA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b,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,yBAAyB;KAC1D,MAAM,QAAQ;KACd,MAAM,MAAM,IAAI;KAChB,MAAM,OAAO,MAAM;KACnB,IAAI;MACF,IAAI,SAAS,GAAG,MAAM,QAAQ;MAC9B,OAAO,IAAI,WAAW,MAAM,SAAS,MAAM,CAAC;KAC9C,UAAU;MACR,MAAM,GAAG,KAAK;OAAE,WAAW;OAAM,OAAO;MAAK,CAAC;MAC9C,oBAAoB,GAAG;KACzB;IACF;IACA,MAAM,SAAS;KACb,IAAI,CAAC,MAAM,OAAO;MAChB,MAAM,QAAQ;MACd,MAAM,KAAK,SAAS;KACtB;KACA,MAAM;KAEN,MAAM,GAAG,KAAK;MAAE,WAAW;MAAM,OAAO;KAAK,CAAC;KAC9C,oBAAoB,GAAG;IACzB;IACA,IAAI,aAAa;KACf,OAAO;IACT;GACF;EACF;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { NodeRef } from "./behaviours.js";
2
- import { SceneGraph } from "@pairdraw/scene-graph";
2
+ import { CommentThread, SceneGraph } from "@pairdraw/scene-graph";
3
3
  import { Vector } from "@pairdraw/scene-graph/primitives";
4
4
  //#region src/pairdraw-api/comments.d.ts
5
5
  /** Who scripts and agents comment as when they give no name. */
@@ -49,6 +49,8 @@ declare class CommentHandle {
49
49
  } | null;
50
50
  /** Where the pin is on the page's canvas. */
51
51
  get position(): Vector;
52
+ /** The area the person circled, in canvas units relative to the pin; null for a clicked pin. */
53
+ get region(): CommentThread['region'];
52
54
  get replies(): {
53
55
  id: string;
54
56
  author: string;
@@ -78,6 +80,7 @@ declare class CommentHandle {
78
80
  name: string;
79
81
  } | null;
80
82
  position: Vector;
83
+ region: import("@pairdraw/scene-graph").CommentRegion | null | undefined;
81
84
  replies: {
82
85
  id: string;
83
86
  author: string;
@@ -1 +1 @@
1
- {"version":3,"file":"comments.d.ts","names":[],"sources":["../../src/pairdraw-api/comments.ts"],"mappings":";;;;;cAuBa;UAEI;;EAEf;;EAEA,OAAO;;EAEP;;UAGe;;EAEf,OAAO;;EAEP,OAAO;;EAEP;EACA;EACA;;;;;;;cAkBW;mBAEQ;WACR;EADQ,YAAA,OAAO,YACf;cAGC;UAMJ;MAOJ;MAIA;MAIA;MAIA;;MAKA;IAAU;IAAY;;;MAMtB;IAAU;IAAY;;;MAOtB,YAAY;MAIZ;IAAa;IAAY;IAAgB;IAAc;;;EAU3D,MAAM,cAAc;IAAW;;EAO/B;EAIA;;EAKA;EAIA;;;;;;;MA/CkB;MAAc;;;MAMd;MAAc;;;;MAWX;MAAgB;MAAc;MAAmB;;;;;iBA8CxD,YAAY,OAAO,YAAY,SAAQ,gBAAqB;iBAc5D,WAAW,OAAO,YAAY,aAAa;;iBAK3C,WACd,OAAO,YACP,uBACA,cACA,UAAS,aACR"}
1
+ {"version":3,"file":"comments.d.ts","names":[],"sources":["../../src/pairdraw-api/comments.ts"],"mappings":";;;;;cAuBa;UAEI;;EAEf;;EAEA,OAAO;;EAEP;;UAGe;;EAEf,OAAO;;EAEP,OAAO;;EAEP;EACA;EACA;;;;;;;cAkBW;mBAEQ;WACR;EADQ,YAAA,OAAO,YACf;cAGC;UAMJ;MAOJ;MAIA;MAIA;MAIA;;MAKA;IAAU;IAAY;;;MAMtB;IAAU;IAAY;;;MAOtB,YAAY;;MAKZ,UAAU;MAIV;IAAa;IAAY;IAAgB;IAAc;;;EAU3D,MAAM,cAAc;IAAW;;EAO/B;EAIA;;EAKA;EAIA;;;;;;;MApDkB;MAAc;;;MAMd;MAAc;;;;;MAgBX;MAAgB;MAAc;MAAmB;;;;;iBA+CxD,YAAY,OAAO,YAAY,SAAQ,gBAAqB;iBAc5D,WAAW,OAAO,YAAY,aAAa;;iBAK3C,WACd,OAAO,YACP,uBACA,cACA,UAAS,aACR"}
@@ -67,6 +67,10 @@ var CommentHandle = class {
67
67
  get position() {
68
68
  return commentPosition(this.graph, this.thread);
69
69
  }
70
+ /** The area the person circled, in canvas units relative to the pin; null for a clicked pin. */
71
+ get region() {
72
+ return this.thread.region ?? null;
73
+ }
70
74
  get replies() {
71
75
  return liveReplies(this.thread).map(({ id, author, text, createdAt }) => ({
72
76
  id,
@@ -102,6 +106,7 @@ var CommentHandle = class {
102
106
  page: this.page,
103
107
  node: this.node,
104
108
  position: this.position,
109
+ region: this.region,
105
110
  replies: this.replies
106
111
  };
107
112
  }
@@ -1 +1 @@
1
- {"version":3,"file":"comments.js","names":["now"],"sources":["../../src/pairdraw-api/comments.ts"],"sourcesContent":["import type { CommentThread, SceneGraph } from '@pairdraw/scene-graph'\nimport {\n byCreatedAt,\n commentPosition,\n commentTimestamp as now,\n createCommentReply,\n createCommentThread,\n deleteCommentThread,\n editCommentThread,\n findLiveCommentThread,\n liveReplies,\n readComments,\n replyToCommentThread,\n resolveCommentThread,\n takesPartInThread,\n writeComments,\n type CommentAuthor\n} from '@pairdraw/scene-graph/comments'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\n/** Who scripts and agents comment as when they give no name. */\nexport const DEFAULT_COMMENT_AUTHOR = 'Agent'\n\nexport interface CommentFilter {\n /** true for resolved threads only, false for open ones; both when left out. */\n resolved?: boolean\n /** Only threads on this page. */\n page?: NodeRef\n /** Only threads this person started or replied to. */\n author?: string\n}\n\nexport interface NewComment {\n /** Pin the comment on this layer; it follows the top-level layer it lands on. */\n node?: NodeRef\n /** The page to comment on without a layer; the current page by default. */\n page?: NodeRef\n /** Canvas position on the page, or offset from the layer's top-left corner. */\n x?: number\n y?: number\n author?: string\n}\n\nfunction author(name: string | undefined): CommentAuthor {\n return { name: name?.trim() || DEFAULT_COMMENT_AUTHOR }\n}\n\nfunction pageOf(graph: SceneGraph, nodeId: string): string {\n const page = graph.pageOf(nodeId)\n if (page === null) throw new Error(`${graph.getNode(nodeId)?.name ?? nodeId} is not on a page`)\n return page\n}\n\n/**\n * A comment thread as scripts read and answer it, in the style of the Figma API: properties\n * read the thread as the document holds it now, and every change is written at once, where\n * the editor and collaborators see it.\n */\nexport class CommentHandle {\n constructor(\n private readonly graph: SceneGraph,\n readonly id: string\n ) {}\n\n private get thread(): CommentThread {\n const thread = findLiveCommentThread(readComments(this.graph), this.id)\n if (!thread) throw new Error(`Comment ${this.id} was deleted`)\n return thread\n }\n\n private edit(change: (thread: CommentThread) => CommentThread): this {\n const threads = readComments(this.graph)\n if (!findLiveCommentThread(threads, this.id)) throw new Error(`Comment ${this.id} was deleted`)\n writeComments(this.graph, editCommentThread(threads, this.id, now(), change))\n return this\n }\n\n get text(): string {\n return this.thread.text\n }\n\n get author(): string {\n return this.thread.author\n }\n\n get createdAt(): string {\n return this.thread.createdAt\n }\n\n get resolved(): boolean {\n return this.thread.resolved\n }\n\n /** The page the comment is on. */\n get page(): { id: string; name: string } {\n const { pageId, pageName } = this.thread\n return { id: pageId, name: this.graph.getNode(pageId)?.name ?? pageName ?? '' }\n }\n\n /** The top-level layer the comment is pinned to, while it exists. */\n get node(): { id: string; name: string } | null {\n const { nodeId } = this.thread\n const node = nodeId ? this.graph.getNode(nodeId) : undefined\n return node ? { id: node.id, name: node.name } : null\n }\n\n /** Where the pin is on the page's canvas. */\n get position(): Vector {\n return commentPosition(this.graph, this.thread)\n }\n\n get replies(): { id: string; author: string; text: string; createdAt: string }[] {\n return liveReplies(this.thread).map(({ id, author, text, createdAt }) => ({\n id,\n author,\n text,\n createdAt\n }))\n }\n\n /** Answer the thread, which reopens it if it was resolved. */\n reply(text: string, options: { author?: string } = {}): this {\n const body = text.trim()\n if (!body) throw new Error('A reply needs text')\n const entry = createCommentReply(author(options.author), body, now())\n return this.edit((thread) => replyToCommentThread(thread, entry))\n }\n\n resolve(): this {\n return this.edit((thread) => resolveCommentThread(thread, true, now()))\n }\n\n reopen(): this {\n return this.edit((thread) => resolveCommentThread(thread, false, now()))\n }\n\n /** Delete the thread and its replies for everyone. */\n remove(): void {\n this.edit(deleteCommentThread)\n }\n\n toJSON() {\n return {\n id: this.id,\n text: this.text,\n author: this.author,\n createdAt: this.createdAt,\n resolved: this.resolved,\n page: this.page,\n node: this.node,\n position: this.position,\n replies: this.replies\n }\n }\n}\n\n/** The document's live threads, oldest first, narrowed by `filter`. */\nexport function getComments(graph: SceneGraph, filter: CommentFilter = {}): CommentHandle[] {\n const pageId = filter.page === undefined ? undefined : nodeOf(graph, filter.page).id\n return readComments(graph)\n .filter(\n (thread) =>\n !thread.deleted &&\n (filter.resolved === undefined || thread.resolved === filter.resolved) &&\n (pageId === undefined || thread.pageId === pageId) &&\n (filter.author === undefined || takesPartInThread(thread, filter.author))\n )\n .sort(byCreatedAt)\n .map((thread) => new CommentHandle(graph, thread.id))\n}\n\nexport function getComment(graph: SceneGraph, id: string): CommentHandle | null {\n return findLiveCommentThread(readComments(graph), id) ? new CommentHandle(graph, id) : null\n}\n\n/** Leave a comment on a layer, or at a point of a page. */\nexport function addComment(\n graph: SceneGraph,\n currentPageId: string,\n text: string,\n options: NewComment = {}\n): CommentHandle {\n const body = text.trim()\n if (!body) throw new Error('A comment needs text')\n const dx = options.x ?? 0\n const dy = options.y ?? 0\n let pageId: string\n let at: Vector\n const node = options.node === undefined ? undefined : nodeOf(graph, options.node)\n if (node) {\n pageId = pageOf(graph, node.id)\n const abs = graph.getAbsolutePosition(node.id)\n at = { x: abs.x + dx, y: abs.y + dy }\n } else {\n pageId = options.page === undefined ? currentPageId : nodeOf(graph, options.page).id\n if (graph.getNode(pageId)?.type !== 'CANVAS') throw new Error(`${pageId} is not a page`)\n at = { x: dx, y: dy }\n }\n const thread = createCommentThread(graph, {\n pageId,\n at,\n node,\n author: author(options.author),\n text: body,\n now: now()\n })\n writeComments(graph, [...readComments(graph), thread])\n return new CommentHandle(graph, thread.id)\n}\n"],"mappings":";;;;AAuBA,MAAa,yBAAyB;AAsBtC,SAAS,OAAO,MAAyC;CACvD,OAAO,EAAE,MAAM,MAAM,KAAK,KAAA,QAA4B;AACxD;AAEA,SAAS,OAAO,OAAmB,QAAwB;CACzD,MAAM,OAAO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AAK,WAAW,IAAI,cAAc,OAAO,OAAO,EAAE,CAAC;AACxD;AAEA,SAAgB,WAAW,OAAmB,IAAkC;CAC9E,OAAO,sBAAsB,aAAa,KAAK,GAAG,EAAE,IAAI,IAAI,cAAc,OAAO,EAAE,IAAI;AACzF;;AAGA,SAAgB,WACd,OACA,eACA,MACA,UAAsB,CAAC,GACR;CACf,MAAM,OAAO,KAAK,KAAK;CACvB,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,sBAAsB;CACjD,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,KAAK,QAAQ,KAAK;CACxB,IAAI;CACJ,IAAI;CACJ,MAAM,OAAO,QAAQ,SAAS,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,QAAQ,IAAI;CAChF,IAAI,MAAM;EACR,SAAS,OAAO,OAAO,KAAK,EAAE;EAC9B,MAAM,MAAM,MAAM,oBAAoB,KAAK,EAAE;EAC7C,KAAK;GAAE,GAAG,IAAI,IAAI;GAAI,GAAG,IAAI,IAAI;EAAG;CACtC,OAAO;EACL,SAAS,QAAQ,SAAS,KAAA,IAAY,gBAAgB,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC;EAClF,IAAI,MAAM,QAAQ,MAAM,CAAC,EAAE,SAAS,UAAU,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe;EACvF,KAAK;GAAE,GAAG;GAAI,GAAG;EAAG;CACtB;CACA,MAAM,SAAS,oBAAoB,OAAO;EACxC;EACA;EACA;EACA,QAAQ,OAAO,QAAQ,MAAM;EAC7B,MAAM;EACN,KAAKA,iBAAI;CACX,CAAC;CACD,cAAc,OAAO,CAAC,GAAG,aAAa,KAAK,GAAG,MAAM,CAAC;CACrD,OAAO,IAAI,cAAc,OAAO,OAAO,EAAE;AAC3C"}
1
+ {"version":3,"file":"comments.js","names":["now"],"sources":["../../src/pairdraw-api/comments.ts"],"sourcesContent":["import type { CommentThread, SceneGraph } from '@pairdraw/scene-graph'\nimport {\n byCreatedAt,\n commentPosition,\n commentTimestamp as now,\n createCommentReply,\n createCommentThread,\n deleteCommentThread,\n editCommentThread,\n findLiveCommentThread,\n liveReplies,\n readComments,\n replyToCommentThread,\n resolveCommentThread,\n takesPartInThread,\n writeComments,\n type CommentAuthor\n} from '@pairdraw/scene-graph/comments'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\n/** Who scripts and agents comment as when they give no name. */\nexport const DEFAULT_COMMENT_AUTHOR = 'Agent'\n\nexport interface CommentFilter {\n /** true for resolved threads only, false for open ones; both when left out. */\n resolved?: boolean\n /** Only threads on this page. */\n page?: NodeRef\n /** Only threads this person started or replied to. */\n author?: string\n}\n\nexport interface NewComment {\n /** Pin the comment on this layer; it follows the top-level layer it lands on. */\n node?: NodeRef\n /** The page to comment on without a layer; the current page by default. */\n page?: NodeRef\n /** Canvas position on the page, or offset from the layer's top-left corner. */\n x?: number\n y?: number\n author?: string\n}\n\nfunction author(name: string | undefined): CommentAuthor {\n return { name: name?.trim() || DEFAULT_COMMENT_AUTHOR }\n}\n\nfunction pageOf(graph: SceneGraph, nodeId: string): string {\n const page = graph.pageOf(nodeId)\n if (page === null) throw new Error(`${graph.getNode(nodeId)?.name ?? nodeId} is not on a page`)\n return page\n}\n\n/**\n * A comment thread as scripts read and answer it, in the style of the Figma API: properties\n * read the thread as the document holds it now, and every change is written at once, where\n * the editor and collaborators see it.\n */\nexport class CommentHandle {\n constructor(\n private readonly graph: SceneGraph,\n readonly id: string\n ) {}\n\n private get thread(): CommentThread {\n const thread = findLiveCommentThread(readComments(this.graph), this.id)\n if (!thread) throw new Error(`Comment ${this.id} was deleted`)\n return thread\n }\n\n private edit(change: (thread: CommentThread) => CommentThread): this {\n const threads = readComments(this.graph)\n if (!findLiveCommentThread(threads, this.id)) throw new Error(`Comment ${this.id} was deleted`)\n writeComments(this.graph, editCommentThread(threads, this.id, now(), change))\n return this\n }\n\n get text(): string {\n return this.thread.text\n }\n\n get author(): string {\n return this.thread.author\n }\n\n get createdAt(): string {\n return this.thread.createdAt\n }\n\n get resolved(): boolean {\n return this.thread.resolved\n }\n\n /** The page the comment is on. */\n get page(): { id: string; name: string } {\n const { pageId, pageName } = this.thread\n return { id: pageId, name: this.graph.getNode(pageId)?.name ?? pageName ?? '' }\n }\n\n /** The top-level layer the comment is pinned to, while it exists. */\n get node(): { id: string; name: string } | null {\n const { nodeId } = this.thread\n const node = nodeId ? this.graph.getNode(nodeId) : undefined\n return node ? { id: node.id, name: node.name } : null\n }\n\n /** Where the pin is on the page's canvas. */\n get position(): Vector {\n return commentPosition(this.graph, this.thread)\n }\n\n /** The area the person circled, in canvas units relative to the pin; null for a clicked pin. */\n get region(): CommentThread['region'] {\n return this.thread.region ?? null\n }\n\n get replies(): { id: string; author: string; text: string; createdAt: string }[] {\n return liveReplies(this.thread).map(({ id, author, text, createdAt }) => ({\n id,\n author,\n text,\n createdAt\n }))\n }\n\n /** Answer the thread, which reopens it if it was resolved. */\n reply(text: string, options: { author?: string } = {}): this {\n const body = text.trim()\n if (!body) throw new Error('A reply needs text')\n const entry = createCommentReply(author(options.author), body, now())\n return this.edit((thread) => replyToCommentThread(thread, entry))\n }\n\n resolve(): this {\n return this.edit((thread) => resolveCommentThread(thread, true, now()))\n }\n\n reopen(): this {\n return this.edit((thread) => resolveCommentThread(thread, false, now()))\n }\n\n /** Delete the thread and its replies for everyone. */\n remove(): void {\n this.edit(deleteCommentThread)\n }\n\n toJSON() {\n return {\n id: this.id,\n text: this.text,\n author: this.author,\n createdAt: this.createdAt,\n resolved: this.resolved,\n page: this.page,\n node: this.node,\n position: this.position,\n region: this.region,\n replies: this.replies\n }\n }\n}\n\n/** The document's live threads, oldest first, narrowed by `filter`. */\nexport function getComments(graph: SceneGraph, filter: CommentFilter = {}): CommentHandle[] {\n const pageId = filter.page === undefined ? undefined : nodeOf(graph, filter.page).id\n return readComments(graph)\n .filter(\n (thread) =>\n !thread.deleted &&\n (filter.resolved === undefined || thread.resolved === filter.resolved) &&\n (pageId === undefined || thread.pageId === pageId) &&\n (filter.author === undefined || takesPartInThread(thread, filter.author))\n )\n .sort(byCreatedAt)\n .map((thread) => new CommentHandle(graph, thread.id))\n}\n\nexport function getComment(graph: SceneGraph, id: string): CommentHandle | null {\n return findLiveCommentThread(readComments(graph), id) ? new CommentHandle(graph, id) : null\n}\n\n/** Leave a comment on a layer, or at a point of a page. */\nexport function addComment(\n graph: SceneGraph,\n currentPageId: string,\n text: string,\n options: NewComment = {}\n): CommentHandle {\n const body = text.trim()\n if (!body) throw new Error('A comment needs text')\n const dx = options.x ?? 0\n const dy = options.y ?? 0\n let pageId: string\n let at: Vector\n const node = options.node === undefined ? undefined : nodeOf(graph, options.node)\n if (node) {\n pageId = pageOf(graph, node.id)\n const abs = graph.getAbsolutePosition(node.id)\n at = { x: abs.x + dx, y: abs.y + dy }\n } else {\n pageId = options.page === undefined ? currentPageId : nodeOf(graph, options.page).id\n if (graph.getNode(pageId)?.type !== 'CANVAS') throw new Error(`${pageId} is not a page`)\n at = { x: dx, y: dy }\n }\n const thread = createCommentThread(graph, {\n pageId,\n at,\n node,\n author: author(options.author),\n text: body,\n now: now()\n })\n writeComments(graph, [...readComments(graph), thread])\n return new CommentHandle(graph, thread.id)\n}\n"],"mappings":";;;;AAuBA,MAAa,yBAAyB;AAsBtC,SAAS,OAAO,MAAyC;CACvD,OAAO,EAAE,MAAM,MAAM,KAAK,KAAA,QAA4B;AACxD;AAEA,SAAS,OAAO,OAAmB,QAAwB;CACzD,MAAM,OAAO,MAAM,OAAO,MAAM;CAChC,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,GAAG,MAAM,QAAQ,MAAM,CAAC,EAAE,QAAQ,OAAO,kBAAkB;CAC9F,OAAO;AACT;;;;;;AAOA,IAAa,gBAAb,MAA2B;CAEN;CACR;CAFX,YACE,OACA,IACA;EAFiB,KAAA,QAAA;EACR,KAAA,KAAA;CACR;CAEH,IAAY,SAAwB;EAClC,MAAM,SAAS,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ACA,UAAsB,CAAC,GACR;CACf,MAAM,OAAO,KAAK,KAAK;CACvB,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,sBAAsB;CACjD,MAAM,KAAK,QAAQ,KAAK;CACxB,MAAM,KAAK,QAAQ,KAAK;CACxB,IAAI;CACJ,IAAI;CACJ,MAAM,OAAO,QAAQ,SAAS,KAAA,IAAY,KAAA,IAAY,OAAO,OAAO,QAAQ,IAAI;CAChF,IAAI,MAAM;EACR,SAAS,OAAO,OAAO,KAAK,EAAE;EAC9B,MAAM,MAAM,MAAM,oBAAoB,KAAK,EAAE;EAC7C,KAAK;GAAE,GAAG,IAAI,IAAI;GAAI,GAAG,IAAI,IAAI;EAAG;CACtC,OAAO;EACL,SAAS,QAAQ,SAAS,KAAA,IAAY,gBAAgB,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC;EAClF,IAAI,MAAM,QAAQ,MAAM,CAAC,EAAE,SAAS,UAAU,MAAM,IAAI,MAAM,GAAG,OAAO,eAAe;EACvF,KAAK;GAAE,GAAG;GAAI,GAAG;EAAG;CACtB;CACA,MAAM,SAAS,oBAAoB,OAAO;EACxC;EACA;EACA;EACA,QAAQ,OAAO,QAAQ,MAAM;EAC7B,MAAM;EACN,KAAKA,iBAAI;CACX,CAAC;CACD,cAAc,OAAO,CAAC,GAAG,aAAa,KAAK,GAAG,MAAM,CAAC;CACrD,OAAO,IAAI,cAAc,OAAO,OAAO,EAAE;AAC3C"}
@@ -0,0 +1,19 @@
1
+ import { DesignValueVerdict } from "../design-memory/check.js";
2
+ import "../design-memory/index.js";
3
+ import { NodeRef } from "./behaviours.js";
4
+ import { SceneGraph } from "@pairdraw/scene-graph";
5
+ import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
6
+ //#region src/pairdraw-api/design-memory.d.ts
7
+ /** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */
8
+ declare function checkProposedDesignValues(graph: SceneGraph, proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>): DesignValueVerdict[];
9
+ /**
10
+ * Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add
11
+ * to the memory but never change what it allows: only the person does that.
12
+ */
13
+ declare function recordDesignDecision(graph: SceneGraph, text: string, example?: NodeRef): {
14
+ decisions: number;
15
+ examples: number;
16
+ };
17
+ //#endregion
18
+ export { checkProposedDesignValues, recordDesignDecision };
19
+ //# sourceMappingURL=design-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-memory.d.ts","names":[],"sources":["../../src/pairdraw-api/design-memory.ts"],"mappings":";;;;;;;iBAwBgB,0BACd,OAAO,YACP,UAAU,QAAQ,OAAO,oDACxB;;;;;iBAQa,qBACd,OAAO,YACP,cACA,UAAU;EACP;EAAmB"}
@@ -0,0 +1,39 @@
1
+ import { currentDesignRules } from "../design-memory/document.js";
2
+ import { checkDesignValues } from "../design-memory/check.js";
3
+ import { nodeOf } from "./behaviours.js";
4
+ import { addDesignDecision, cachedDesignMemory, pinDesignExample, writeDesignMemory } from "@pairdraw/scene-graph/design-memory";
5
+ //#region src/pairdraw-api/design-memory.ts
6
+ const NO_MEMORY = "This document has no design memory; the person creates one in the Design panel with nothing selected.";
7
+ function memoryOf(graph) {
8
+ const memory = cachedDesignMemory(graph);
9
+ if (!memory) throw new Error(NO_MEMORY);
10
+ return memory;
11
+ }
12
+ /** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */
13
+ function checkProposedDesignValues(graph, proposal) {
14
+ return checkDesignValues(currentDesignRules(graph, memoryOf(graph)), proposal);
15
+ }
16
+ /**
17
+ * Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add
18
+ * to the memory but never change what it allows: only the person does that.
19
+ */
20
+ function recordDesignDecision(graph, text, example) {
21
+ let memory = memoryOf(graph);
22
+ const decisions = memory.decisions.length;
23
+ memory = addDesignDecision(memory, text, "agent");
24
+ if (memory.decisions.length === decisions) throw new Error(text.trim() ? "The design memory holds as many decisions as it can; ask the person to remove some." : "A decision needs text.");
25
+ if (example !== void 0) {
26
+ const nodeId = nodeOf(graph, example).id;
27
+ memory = pinDesignExample(memory, nodeId);
28
+ if (!memory.examples.some((pinned) => pinned.nodeId === nodeId)) throw new Error("The design memory holds as many examples as it can; ask the person to unpin some.");
29
+ }
30
+ writeDesignMemory(graph, memory);
31
+ return {
32
+ decisions: memory.decisions.length,
33
+ examples: memory.examples.length
34
+ };
35
+ }
36
+ //#endregion
37
+ export { checkProposedDesignValues, recordDesignDecision };
38
+
39
+ //# sourceMappingURL=design-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-memory.js","names":[],"sources":["../../src/pairdraw-api/design-memory.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n addDesignDecision,\n cachedDesignMemory,\n pinDesignExample,\n writeDesignMemory,\n type DesignMemory,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { checkDesignValues, currentDesignRules, type DesignValueVerdict } from '#core/design-memory'\n\nimport { nodeOf, type NodeRef } from './behaviours'\n\nconst NO_MEMORY =\n 'This document has no design memory; the person creates one in the Design panel with nothing selected.'\n\nfunction memoryOf(graph: SceneGraph): DesignMemory {\n const memory = cachedDesignMemory(graph)\n if (!memory) throw new Error(NO_MEMORY)\n return memory\n}\n\n/** Judges values before they are used: `ok`, `warn`, `refuse`, or `invalid`, with the nearest allowed. */\nexport function checkProposedDesignValues(\n graph: SceneGraph,\n proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>\n): DesignValueVerdict[] {\n return checkDesignValues(currentDesignRules(graph, memoryOf(graph)), proposal)\n}\n\n/**\n * Writes down a decision an agent made, and pins `example` as a layer that shows it. Agents add\n * to the memory but never change what it allows: only the person does that.\n */\nexport function recordDesignDecision(\n graph: SceneGraph,\n text: string,\n example?: NodeRef\n): { decisions: number; examples: number } {\n let memory = memoryOf(graph)\n const decisions = memory.decisions.length\n memory = addDesignDecision(memory, text, 'agent')\n if (memory.decisions.length === decisions) {\n throw new Error(\n text.trim()\n ? 'The design memory holds as many decisions as it can; ask the person to remove some.'\n : 'A decision needs text.'\n )\n }\n if (example !== undefined) {\n const nodeId = nodeOf(graph, example).id\n memory = pinDesignExample(memory, nodeId)\n if (!memory.examples.some((pinned) => pinned.nodeId === nodeId))\n throw new Error(\n 'The design memory holds as many examples as it can; ask the person to unpin some.'\n )\n }\n writeDesignMemory(graph, memory)\n return { decisions: memory.decisions.length, examples: memory.examples.length }\n}\n"],"mappings":";;;;;AAcA,MAAM,YACJ;AAEF,SAAS,SAAS,OAAiC;CACjD,MAAM,SAAS,mBAAmB,KAAK;CACvC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,SAAS;CACtC,OAAO;AACT;;AAGA,SAAgB,0BACd,OACA,UACsB;CACtB,OAAO,kBAAkB,mBAAmB,OAAO,SAAS,KAAK,CAAC,GAAG,QAAQ;AAC/E;;;;;AAMA,SAAgB,qBACd,OACA,MACA,SACyC;CACzC,IAAI,SAAS,SAAS,KAAK;CAC3B,MAAM,YAAY,OAAO,UAAU;CACnC,SAAS,kBAAkB,QAAQ,MAAM,OAAO;CAChD,IAAI,OAAO,UAAU,WAAW,WAC9B,MAAM,IAAI,MACR,KAAK,KAAK,IACN,wFACA,wBACN;CAEF,IAAI,YAAY,KAAA,GAAW;EACzB,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC,CAAC;EACtC,SAAS,iBAAiB,QAAQ,MAAM;EACxC,IAAI,CAAC,OAAO,SAAS,MAAM,WAAW,OAAO,WAAW,MAAM,GAC5D,MAAM,IAAI,MACR,mFACF;CACJ;CACA,kBAAkB,OAAO,MAAM;CAC/B,OAAO;EAAE,WAAW,OAAO,UAAU;EAAQ,UAAU,OAAO,SAAS;CAAO;AAChF"}
@@ -1,13 +1,18 @@
1
+ import { DesignValueVerdict } from "../design-memory/check.js";
2
+ import { DesignMemoryReport } from "../design-memory/describe.js";
1
3
  import { FigmaNodeProxy } from "../figma-api/proxy.js";
2
4
  import { FigmaAPI } from "../figma-api/index.js";
3
- import { DocumentFontStatus } from "../text/font/status.js";
5
+ import "../design-memory/index.js";
6
+ import { FontReadiness } from "../text/font/readiness.js";
4
7
  import { BehaviourHandle, NodeRef } from "./behaviours.js";
5
8
  import { CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, NewComment } from "./comments.js";
6
9
  import { StatusInfo } from "./statuses.js";
7
10
  import { VariableRef } from "./variables.js";
11
+ import { VariationSetHandle, VariationSetInfo } from "./variations.js";
8
12
  import { BehaviourKind, BehaviourSpec } from "@pairdraw/scene-graph/behaviours";
9
- import { VariableLiteral } from "@pairdraw/scene-graph";
10
13
  import { OkHCLColor, OkHCLPayload } from "@pairdraw/scene-graph/color";
14
+ import { VariableLiteral } from "@pairdraw/scene-graph";
15
+ import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
11
16
  //#region src/pairdraw-api/index.d.ts
12
17
  /**
13
18
  * What Pairdraw adds to the Figma Plugin API for scripts, as the `pairdraw` global next to
@@ -73,6 +78,41 @@ declare class PairdrawAPI {
73
78
  * frames, components, sets and instances directly on a page or in a section take one.
74
79
  */
75
80
  setStatus(node: NodeRef, status: string | null): void;
81
+ /**
82
+ * The document's design memory: the colors, fonts, sizes, spacing and radii agents may use,
83
+ * whether an off-system value is refused or warned about, the decisions written down, and the
84
+ * layers pinned as examples. Null when the document has none.
85
+ */
86
+ get designMemory(): DesignMemoryReport | null;
87
+ /**
88
+ * Judge values before using them, such as `{ colors: ['#FF00AA'], spacing: [13] }`: each comes
89
+ * back `ok`, `warn`, `refuse` or `invalid`, with the nearest allowed value.
90
+ */
91
+ checkDesignValues(proposal: Partial<Record<DesignMemoryGroup, readonly (string | number)[]>>): DesignValueVerdict[];
92
+ /**
93
+ * Write a decision down in the design memory, optionally pinning a layer that shows it as an
94
+ * example. The memory's allowed values stay as the person set them.
95
+ */
96
+ recordDesignDecision(text: string, example?: NodeRef): {
97
+ decisions: number;
98
+ examples: number;
99
+ };
100
+ /**
101
+ * Copy a layer `count` times (1 to 8) into a section of variations beside it, made the first
102
+ * time; `labels` name what each version tries, as in `V2 · Calmer palette`. On a version, it
103
+ * copies that version into its set. The original does not change.
104
+ */
105
+ createVariations(node: NodeRef, options: {
106
+ count: number;
107
+ labels?: readonly string[];
108
+ }): {
109
+ set: VariationSetHandle;
110
+ versions: FigmaNodeProxy[];
111
+ };
112
+ /** The set of variations a layer belongs to, from its section, a version or a layer inside one. */
113
+ getVariations(node: NodeRef): VariationSetHandle | null;
114
+ /** The sets of variations on the current page. */
115
+ get variations(): VariationSetHandle[];
76
116
  /**
77
117
  * Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;
78
118
  * returns the layer that holds the property.
@@ -82,7 +122,7 @@ declare class PairdrawAPI {
82
122
  * Whether the current page's fonts are faithfully available: requested faces, where each
83
123
  * loaded from, substitutions, why an installed face could not load, and the layers affected.
84
124
  */
85
- getFontStatus(): DocumentFontStatus;
125
+ getFontStatus(): FontReadiness;
86
126
  /** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */
87
127
  getFillOkHCL(node: NodeRef, index?: number): OkHCLPayload | null;
88
128
  /** Set a fill's color in OkHCL; its RGB follows in the document's color space. */
@@ -95,7 +135,11 @@ declare class PairdrawAPI {
95
135
  /** Which way a text runs: `AUTO`, `LTR` or `RTL`. */
96
136
  getTextDirection(node: NodeRef): string;
97
137
  setTextDirection(node: NodeRef, direction: string): void;
138
+ /** Merges OpenType feature toggles into the text's own, keeping the tags it does not name. */
139
+ setFontFeatures(node: NodeRef, features: Record<string, boolean>): void;
140
+ /** Merges OpenType feature toggles into a text range's own, keeping its other features. */
141
+ setRangeFontFeatures(node: NodeRef, start: number, end: number, features: Record<string, boolean>): void;
98
142
  }
99
143
  //#endregion
100
- export { BehaviourHandle, type CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, type NewComment, type NodeRef, PairdrawAPI, type StatusInfo, type VariableRef };
144
+ export { BehaviourHandle, type CommentFilter, CommentHandle, DEFAULT_COMMENT_AUTHOR, type NewComment, type NodeRef, PairdrawAPI, type StatusInfo, type VariableRef, VariationSetHandle, type VariationSetInfo };
101
145
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/pairdraw-api/index.ts"],"mappings":";;;;;;;;;;;;;;;;cA2Da;mBACkB;EAAA,YAAA,OAAO;;;;;;;;EASpC,mBACE,wBACA,sBACA,gBACA,oBACC;;;;;;;EA8BH,aAAa,MAAM,SAAS,eAAe,UAAU;;EAKrD,eAAe,MAAM,SAAS;;MAK1B;;;;;;EAKJ,aAAa,MAAM,UAAU;;;;;;EAS7B,aAAa,MAAM,SAAS,MAAM,gBAAgB,gBAAgB;;EAKlE,WAAW,OAAO;;;;;EAQlB,YAAY,SAAS,gBAAgB;EAIrC,WAAW,aAAa;;;;;EAQxB,WAAW,cAAc,UAAU,aAAa;;;;;MAQ5C,YAAY;;EAKhB,UAAU,MAAM;;;;;EAQhB,UAAU,MAAM,SAAS;;;;;EAQzB,mBACE,oBAAoB,WACpB,qBAAqB,WACrB,wBACC;;;;;EAgBH,iBAAiB;;EAKjB,aAAa,MAAM,SAAS,iBAAY;;EAKxC,aAAa,MAAM,SAAS,OAAO,YAAY;EAI/C,eAAe,MAAM,SAAS,iBAAY;EAI1C,eAAe,MAAM,SAAS,OAAO,YAAY;;EAKjD,mBAAmB,MAAM;EAIzB,mBAAmB,MAAM,SAAS;;EAKlC,iBAAiB,MAAM;EAIvB,iBAAiB,MAAM,SAAS"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/pairdraw-api/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;cA2Ea;mBACkB;EAAA,YAAA,OAAO;;;;;;;;EASpC,mBACE,wBACA,sBACA,gBACA,oBACC;;;;;;;EA4BH,aAAa,MAAM,SAAS,eAAe,UAAU;;EAKrD,eAAe,MAAM,SAAS;;MAK1B;;;;;;EAKJ,aAAa,MAAM,UAAU;;;;;;EAS7B,aAAa,MAAM,SAAS,MAAM,gBAAgB,gBAAgB;;EAKlE,WAAW,OAAO;;;;;EAQlB,YAAY,SAAS,gBAAgB;EAIrC,WAAW,aAAa;;;;;EAQxB,WAAW,cAAc,UAAU,aAAa;;;;;MAQ5C,YAAY;;EAKhB,UAAU,MAAM;;;;;EAQhB,UAAU,MAAM,SAAS;;;;;;MASrB,gBAAgB;;;;;EAQpB,kBACE,UAAU,QAAQ,OAAO,oDACxB;;;;;EAQH,qBAAqB,cAAc,UAAU;IAAY;IAAmB;;;;;;;EAS5E,iBACE,MAAM,SACN;IAAW;IAAe;;IACvB,KAAK;IAAoB,UAAU;;;EAMxC,cAAc,MAAM,UAAU;;MAK1B,cAAc;;;;;EAQlB,mBACE,oBAAoB,WACpB,qBAAqB,WACrB,wBACC;;;;;EAgBH,iBAAiB;;EAKjB,aAAa,MAAM,SAAS,iBAAY;;EAKxC,aAAa,MAAM,SAAS,OAAO,YAAY;EAI/C,eAAe,MAAM,SAAS,iBAAY;EAI1C,eAAe,MAAM,SAAS,OAAO,YAAY;;EAKjD,mBAAmB,MAAM;EAIzB,mBAAmB,MAAM,SAAS;;EAKlC,iBAAiB,MAAM;EAIvB,iBAAiB,MAAM,SAAS;;EAKhC,gBAAgB,MAAM,SAAS,UAAU;;EAKzC,qBACE,MAAM,SACN,eACA,aACA,UAAU"}
@@ -1,11 +1,14 @@
1
- import { documentFontStatus } from "../text/font/status.js";
1
+ import { readFontReadiness } from "../text/font/readiness.js";
2
+ import { describeDesignMemory } from "../design-memory/describe.js";
2
3
  import { exposeInstanceSwap } from "../figma-api/components.js";
3
4
  import { writeVariableValue } from "../figma-api/variables/variable.js";
4
5
  import { BehaviourHandle, getBehaviour, makeSlot, nodeOf, setBehaviour } from "./behaviours.js";
5
6
  import { CommentHandle, DEFAULT_COMMENT_AUTHOR, addComment, getComment, getComments } from "./comments.js";
6
- import { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeLayoutDirection, writeStrokeOkHCL, writeTextDirection } from "./nodes.js";
7
+ import { checkProposedDesignValues, recordDesignDecision } from "./design-memory.js";
8
+ import { readFillOkHCL, readLayoutDirection, readStrokeOkHCL, readTextDirection, writeFillOkHCL, writeFontFeatures, writeLayoutDirection, writeRangeFontFeatures, writeStrokeOkHCL, writeTextDirection } from "./nodes.js";
7
9
  import { getStatus, listStatuses, setStatus } from "./statuses.js";
8
10
  import { bindVariable, unbindVariable } from "./variables.js";
11
+ import { VariationSetHandle, createVariationSet, getVariationSet, listVariationSets } from "./variations.js";
9
12
  import { BEHAVIOUR_CONTRACTS, BEHAVIOUR_KINDS } from "@pairdraw/scene-graph/behaviours";
10
13
  import { parseVariableFormula } from "@pairdraw/scene-graph/variables";
11
14
  //#region src/pairdraw-api/index.ts
@@ -28,10 +31,10 @@ var PairdrawAPI = class {
28
31
  */
29
32
  setVariableFormula(collectionName, variableName, source, modeName) {
30
33
  const graph = this.figma.graph;
31
- const collections = [...graph.variableCollections.values()].filter((item) => item.name === collectionName);
34
+ const collections = graph.getLiveCollections().filter((item) => item.name === collectionName);
32
35
  const collection = collections.at(0);
33
36
  if (!collection || collections.length !== 1) throw new Error(`Unknown or ambiguous collection: ${collectionName}`);
34
- const variables = [...graph.variables.values()].filter((item) => item.collectionId === collection.id && item.name === variableName);
37
+ const variables = graph.getLiveVariables().filter((item) => item.collectionId === collection.id && item.name === variableName);
35
38
  const variable = variables.at(0);
36
39
  if (!variable || variables.length !== 1) throw new Error(`Unknown or ambiguous variable: ${variableName}`);
37
40
  const modes = collection.modes.filter((mode) => modeName ? mode.name === modeName : mode.modeId === collection.defaultModeId);
@@ -113,6 +116,48 @@ var PairdrawAPI = class {
113
116
  setStatus(this.figma.graph, node, status);
114
117
  }
115
118
  /**
119
+ * The document's design memory: the colors, fonts, sizes, spacing and radii agents may use,
120
+ * whether an off-system value is refused or warned about, the decisions written down, and the
121
+ * layers pinned as examples. Null when the document has none.
122
+ */
123
+ get designMemory() {
124
+ return describeDesignMemory(this.figma.graph);
125
+ }
126
+ /**
127
+ * Judge values before using them, such as `{ colors: ['#FF00AA'], spacing: [13] }`: each comes
128
+ * back `ok`, `warn`, `refuse` or `invalid`, with the nearest allowed value.
129
+ */
130
+ checkDesignValues(proposal) {
131
+ return checkProposedDesignValues(this.figma.graph, proposal);
132
+ }
133
+ /**
134
+ * Write a decision down in the design memory, optionally pinning a layer that shows it as an
135
+ * example. The memory's allowed values stay as the person set them.
136
+ */
137
+ recordDesignDecision(text, example) {
138
+ return recordDesignDecision(this.figma.graph, text, example);
139
+ }
140
+ /**
141
+ * Copy a layer `count` times (1 to 8) into a section of variations beside it, made the first
142
+ * time; `labels` name what each version tries, as in `V2 · Calmer palette`. On a version, it
143
+ * copies that version into its set. The original does not change.
144
+ */
145
+ createVariations(node, options) {
146
+ const { set, created } = createVariationSet(this.figma, node, options);
147
+ return {
148
+ set,
149
+ versions: created
150
+ };
151
+ }
152
+ /** The set of variations a layer belongs to, from its section, a version or a layer inside one. */
153
+ getVariations(node) {
154
+ return getVariationSet(this.figma, node);
155
+ }
156
+ /** The sets of variations on the current page. */
157
+ get variations() {
158
+ return listVariationSets(this.figma, this.figma.currentPageId);
159
+ }
160
+ /**
116
161
  * Expose a swap on instances as one INSTANCE_SWAP property, offering the candidate components;
117
162
  * returns the layer that holds the property.
118
163
  */
@@ -126,7 +171,7 @@ var PairdrawAPI = class {
126
171
  * loaded from, substitutions, why an installed face could not load, and the layers affected.
127
172
  */
128
173
  getFontStatus() {
129
- return documentFontStatus(this.figma.graph, this.figma.currentPageId);
174
+ return readFontReadiness(this.figma.graph, this.figma.currentPageId);
130
175
  }
131
176
  /** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */
132
177
  getFillOkHCL(node, index = 0) {
@@ -156,8 +201,16 @@ var PairdrawAPI = class {
156
201
  setTextDirection(node, direction) {
157
202
  writeTextDirection(this.figma.graph, node, direction);
158
203
  }
204
+ /** Merges OpenType feature toggles into the text's own, keeping the tags it does not name. */
205
+ setFontFeatures(node, features) {
206
+ writeFontFeatures(this.figma.graph, node, features);
207
+ }
208
+ /** Merges OpenType feature toggles into a text range's own, keeping its other features. */
209
+ setRangeFontFeatures(node, start, end, features) {
210
+ writeRangeFontFeatures(this.figma.graph, node, start, end, features);
211
+ }
159
212
  };
160
213
  //#endregion
161
- export { BehaviourHandle, CommentHandle, DEFAULT_COMMENT_AUTHOR, PairdrawAPI };
214
+ export { BehaviourHandle, CommentHandle, DEFAULT_COMMENT_AUTHOR, PairdrawAPI, VariationSetHandle };
162
215
 
163
216
  //# sourceMappingURL=index.js.map
@@ -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":";;;;;;;;;;;;;;;;AA2DA,IAAa,cAAb,MAAyB;CACM;CAA7B,YAAY,OAAkC;EAAjB,KAAA,QAAA;CAAkB;;;;;;;;CAS/C,mBACE,gBACA,cACA,QACA,UACiB;EACjB,MAAM,QAAQ,KAAK,MAAM;EACzB,MAAM,cAAc,CAAC,GAAG,MAAM,oBAAoB,OAAO,CAAC,CAAC,CAAC,QACzD,SAAS,KAAK,SAAS,cAC1B;EACA,MAAM,aAAa,YAAY,GAAG,CAAC;EACnC,IAAI,CAAC,cAAc,YAAY,WAAW,GACxC,MAAM,IAAI,MAAM,oCAAoC,gBAAgB;EACtE,MAAM,YAAY,CAAC,GAAG,MAAM,UAAU,OAAO,CAAC,CAAC,CAAC,QAC7C,SAAS,KAAK,iBAAiB,WAAW,MAAM,KAAK,SAAS,YACjE;EACA,MAAM,WAAW,UAAU,GAAG,CAAC;EAC/B,IAAI,CAAC,YAAY,UAAU,WAAW,GACpC,MAAM,IAAI,MAAM,kCAAkC,cAAc;EAClE,MAAM,QAAQ,WAAW,MAAM,QAAQ,SACrC,WAAW,KAAK,SAAS,WAAW,KAAK,WAAW,WAAW,aACjE;EACA,MAAM,OAAO,MAAM,GAAG,CAAC;EACvB,IAAI,CAAC,QAAQ,MAAM,WAAW,GAAG,MAAM,IAAI,MAAM,8BAA8B,UAAU;EACzF,MAAM,EAAE,OAAO,aAAa,qBAAqB,OAAO,SAAS,IAAI,KAAK,QAAQ,MAAM;EACxF,mBAAmB,OAAO,UAAU,KAAK,QAAQ,KAAK;EACtD,OAAO;CACT;;;;;;;CAQA,aAAa,MAAe,OAAe,UAA6B;EACtE,aAAa,KAAK,MAAM,OAAO,MAAM,OAAO,QAAQ;CACtD;;CAGA,eAAe,MAAe,OAAqB;EACjD,eAAe,KAAK,MAA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OAAO,cAAc,KAAK,MAAM,OAAO,MAAM,KAAK;CACpD;;CAGA,aAAa,MAAe,OAAmB,QAAQ,GAAS;EAC9D,eAAe,KAAK,MAAM,OAAO,MAAM,OAAO,KAAK;CACrD;CAEA,eAAe,MAAe,QAAQ,GAAwB;EAC5D,OAAO,gBAAgB,KAAK,MAAM,OAAO,MAAM,KAAK;CACtD;CAEA,eAAe,MAAe,OAAmB,QAAQ,GAAS;EAChE,iBAAiB,KAAK,MAAM,OAAO,MAAM,OAAO,KAAK;CACvD;;CAGA,mBAAmB,MAAuB;EACxC,OAAO,oBAAoB,KAAK,MAAM,OAAO,IAAI;CACnD;CAEA,mBAAmB,MAAe,WAAyB;EACzD,qBAAqB,KAAK,MAAM,OAAO,MAAM,SAAS;CACxD;;CAGA,iBAAiB,MAAuB;EACtC,OAAO,kBAAkB,KAAK,MAAM,OAAO,IAAI;CACjD;CAEA,iBAAiB,MAAe,WAAyB;EACvD,mBAAmB,KAAK,MAAM,OAAO,MAAM,SAAS;CACtD;AACF"}
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 { readFontReadiness, type FontReadiness } from '#core/text/font/readiness'\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.getLiveCollections().filter((item) => item.name === collectionName)\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\n .getLiveVariables()\n .filter((item) => item.collectionId === collection.id && item.name === variableName)\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(): FontReadiness {\n return readFontReadiness(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":";;;;;;;;;;;;;;;;;;;AA2EA,IAAa,cAAb,MAAyB;CACM;CAA7B,YAAY,OAAkC;EAAjB,KAAA,QAAA;CAAkB;;;;;;;;CAS/C,mBACE,gBACA,cACA,QACA,UACiB;EACjB,MAAM,QAAQ,KAAK,MAAM;EACzB,MAAM,cAAc,MAAM,mBAAmB,CAAC,CAAC,QAAQ,SAAS,KAAK,SAAS,cAAc;EAC5F,MAAM,aAAa,YAAY,GAAG,CAAC;EACnC,IAAI,CAAC,cAAc,YAAY,WAAW,GACxC,MAAM,IAAI,MAAM,oCAAoC,gBAAgB;EACtE,MAAM,YAAY,MACf,iBAAiB,CAAC,CAClB,QAAQ,SAAS,KAAK,iBAAiB,WAAW,MAAM,KAAK,SAAS,YAAY;EACrF,MAAM,WAAW,UAAU,GAAG,CAAC;EAC/B,IAAI,CAAC,YAAY,UAAU,WAAW,GACpC,MAAM,IAAI,MAAM,kCAAkC,cAAc;EAClE,MAAM,QAAQ,WAAW,MAAM,QAAQ,SACrC,WAAW,KAAK,SAAS,WAAW,KAA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O,MAAM,OAAO,KAAK;CACvD;;CAGA,mBAAmB,MAAuB;EACxC,OAAO,oBAAoB,KAAK,MAAM,OAAO,IAAI;CACnD;CAEA,mBAAmB,MAAe,WAAyB;EACzD,qBAAqB,KAAK,MAAM,OAAO,MAAM,SAAS;CACxD;;CAGA,iBAAiB,MAAuB;EACtC,OAAO,kBAAkB,KAAK,MAAM,OAAO,IAAI;CACjD;CAEA,iBAAiB,MAAe,WAAyB;EACvD,mBAAmB,KAAK,MAAM,OAAO,MAAM,SAAS;CACtD;;CAGA,gBAAgB,MAAe,UAAyC;EACtE,kBAAkB,KAAK,MAAM,OAAO,MAAM,QAAQ;CACpD;;CAGA,qBACE,MACA,OACA,KACA,UACM;EACN,uBAAuB,KAAK,MAAM,OAAO,MAAM,OAAO,KAAK,QAAQ;CACrE;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { NodeRef } from "./behaviours.js";
2
- import { LayoutDirection, SceneGraph, TextDirection } from "@pairdraw/scene-graph";
3
2
  import { OkHCLColor, OkHCLPayload } from "@pairdraw/scene-graph/color";
3
+ import { LayoutDirection, SceneGraph, TextDirection } from "@pairdraw/scene-graph";
4
4
  //#region src/pairdraw-api/nodes.d.ts
5
5
  declare function readFillOkHCL(graph: SceneGraph, ref: NodeRef, index: number): OkHCLPayload | null;
6
6
  declare function writeFillOkHCL(graph: SceneGraph, ref: NodeRef, color: OkHCLColor, index: number): void;
@@ -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,OA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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,a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;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