@pairdraw/core 0.21.0 → 0.22.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 (626) hide show
  1. package/dist/canvas/boolean.d.ts +6 -1
  2. package/dist/canvas/boolean.d.ts.map +1 -1
  3. package/dist/canvas/boolean.js +10 -2
  4. package/dist/canvas/boolean.js.map +1 -1
  5. package/dist/canvas/color-space.d.ts +45 -0
  6. package/dist/canvas/color-space.d.ts.map +1 -0
  7. package/dist/canvas/color-space.js +39 -0
  8. package/dist/canvas/color-space.js.map +1 -0
  9. package/dist/canvas/fills.d.ts +10 -10
  10. package/dist/canvas/fills.d.ts.map +1 -1
  11. package/dist/canvas/fills.js +116 -62
  12. package/dist/canvas/fills.js.map +1 -1
  13. package/dist/canvas/flatten.d.ts +11 -3
  14. package/dist/canvas/flatten.d.ts.map +1 -1
  15. package/dist/canvas/flatten.js +62 -4
  16. package/dist/canvas/flatten.js.map +1 -1
  17. package/dist/canvas/index.d.ts +2 -1
  18. package/dist/canvas/index.js +2 -1
  19. package/dist/canvas/layout-grids.d.ts +5 -2
  20. package/dist/canvas/layout-grids.d.ts.map +1 -1
  21. package/dist/canvas/layout-grids.js +7 -2
  22. package/dist/canvas/layout-grids.js.map +1 -1
  23. package/dist/canvas/noise/render.d.ts +17 -4
  24. package/dist/canvas/noise/render.d.ts.map +1 -1
  25. package/dist/canvas/noise/render.js +21 -6
  26. package/dist/canvas/noise/render.js.map +1 -1
  27. package/dist/canvas/noise/shader.d.ts +4 -4
  28. package/dist/canvas/noise/shader.d.ts.map +1 -1
  29. package/dist/canvas/noise/shader.js +5 -6
  30. package/dist/canvas/noise/shader.js.map +1 -1
  31. package/dist/canvas/overlays/annotations.d.ts +19 -0
  32. package/dist/canvas/overlays/annotations.d.ts.map +1 -0
  33. package/dist/canvas/overlays/annotations.js +110 -0
  34. package/dist/canvas/overlays/annotations.js.map +1 -0
  35. package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
  36. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  37. package/dist/canvas/overlays/auto-layout-hover.js +25 -1
  38. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  39. package/dist/canvas/overlays/feedback.js +1 -1
  40. package/dist/canvas/overlays/feedback.js.map +1 -1
  41. package/dist/canvas/overlays/index.d.ts +2 -2
  42. package/dist/canvas/overlays/index.js +2 -2
  43. package/dist/canvas/overlays/measurement.d.ts +7 -1
  44. package/dist/canvas/overlays/measurement.d.ts.map +1 -1
  45. package/dist/canvas/overlays/measurement.js +42 -4
  46. package/dist/canvas/overlays/measurement.js.map +1 -1
  47. package/dist/canvas/overlays/presence.d.ts.map +1 -1
  48. package/dist/canvas/overlays/presence.js +21 -24
  49. package/dist/canvas/overlays/presence.js.map +1 -1
  50. package/dist/canvas/renderer/colors.d.ts +7 -1
  51. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  52. package/dist/canvas/renderer/colors.js +9 -1
  53. package/dist/canvas/renderer/colors.js.map +1 -1
  54. package/dist/canvas/renderer/document-surface.d.ts +15 -6
  55. package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
  56. package/dist/canvas/renderer/document-surface.js +1 -0
  57. package/dist/canvas/renderer/document-surface.js.map +1 -1
  58. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.js +2 -2
  60. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  61. package/dist/canvas/renderer/methods.d.ts +1 -0
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +4 -1
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.js +6 -1
  67. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  68. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  69. package/dist/canvas/renderer/pipeline.js +7 -0
  70. package/dist/canvas/renderer/pipeline.js.map +1 -1
  71. package/dist/canvas/renderer/types.d.ts +10 -0
  72. package/dist/canvas/renderer/types.d.ts.map +1 -1
  73. package/dist/canvas/renderer.d.ts +10 -2
  74. package/dist/canvas/renderer.d.ts.map +1 -1
  75. package/dist/canvas/renderer.js +15 -3
  76. package/dist/canvas/renderer.js.map +1 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +9 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shaders/compile.d.ts +3 -1
  81. package/dist/canvas/shaders/compile.d.ts.map +1 -1
  82. package/dist/canvas/shaders/compile.js +12 -3
  83. package/dist/canvas/shaders/compile.js.map +1 -1
  84. package/dist/canvas/shaders/draw.d.ts.map +1 -1
  85. package/dist/canvas/shaders/draw.js +10 -3
  86. package/dist/canvas/shaders/draw.js.map +1 -1
  87. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  88. package/dist/canvas/shaders/effect.js +6 -16
  89. package/dist/canvas/shaders/effect.js.map +1 -1
  90. package/dist/clipboard/pairdraw.d.ts.map +1 -1
  91. package/dist/clipboard/pairdraw.js +1 -0
  92. package/dist/clipboard/pairdraw.js.map +1 -1
  93. package/dist/editor/bridges/clipboard.d.ts +2 -0
  94. package/dist/editor/bridges/clipboard.d.ts.map +1 -1
  95. package/dist/editor/bridges/clipboard.js +1 -0
  96. package/dist/editor/bridges/clipboard.js.map +1 -1
  97. package/dist/editor/bridges/components.d.ts +14 -7
  98. package/dist/editor/bridges/components.d.ts.map +1 -1
  99. package/dist/editor/bridges/components.js +6 -0
  100. package/dist/editor/bridges/components.js.map +1 -1
  101. package/dist/editor/bridges/structure.d.ts +1 -1
  102. package/dist/editor/bridges/structure.d.ts.map +1 -1
  103. package/dist/editor/bridges/undo.d.ts +1 -1
  104. package/dist/editor/clipboard/code.d.ts +32 -0
  105. package/dist/editor/clipboard/code.d.ts.map +1 -0
  106. package/dist/editor/clipboard/code.js +30 -0
  107. package/dist/editor/clipboard/code.js.map +1 -0
  108. package/dist/editor/clipboard/export.js +2 -2
  109. package/dist/editor/clipboard/export.js.map +1 -1
  110. package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
  111. package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
  112. package/dist/editor/clipboard/paste/dependencies.js +0 -0
  113. package/dist/editor/clipboard/paste/run.d.ts +14 -0
  114. package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
  115. package/dist/editor/clipboard/paste/run.js +47 -0
  116. package/dist/editor/clipboard/paste/run.js.map +1 -0
  117. package/dist/editor/clipboard/styled.d.ts +2 -8
  118. package/dist/editor/clipboard/styled.d.ts.map +1 -1
  119. package/dist/editor/clipboard/styled.js +2 -32
  120. package/dist/editor/clipboard/styled.js.map +1 -1
  121. package/dist/editor/clipboard.d.ts +2 -0
  122. package/dist/editor/clipboard.d.ts.map +1 -1
  123. package/dist/editor/clipboard.js +34 -0
  124. package/dist/editor/clipboard.js.map +1 -1
  125. package/dist/editor/components/instances.d.ts +5 -0
  126. package/dist/editor/components/instances.d.ts.map +1 -1
  127. package/dist/editor/components/instances.js +69 -4
  128. package/dist/editor/components/instances.js.map +1 -1
  129. package/dist/editor/components/slots/index.d.ts.map +1 -1
  130. package/dist/editor/components/slots/index.js +7 -0
  131. package/dist/editor/components/slots/index.js.map +1 -1
  132. package/dist/editor/components.d.ts +6 -0
  133. package/dist/editor/components.d.ts.map +1 -1
  134. package/dist/editor/components.js +14 -2
  135. package/dist/editor/components.js.map +1 -1
  136. package/dist/editor/create.d.ts +30 -3
  137. package/dist/editor/create.d.ts.map +1 -1
  138. package/dist/editor/create.js +11 -2
  139. package/dist/editor/create.js.map +1 -1
  140. package/dist/editor/design-tokens.d.ts +1 -1
  141. package/dist/editor/design-tokens.d.ts.map +1 -1
  142. package/dist/editor/design-tokens.js +4 -18
  143. package/dist/editor/design-tokens.js.map +1 -1
  144. package/dist/editor/image-edit.d.ts.map +1 -1
  145. package/dist/editor/image-edit.js +1 -2
  146. package/dist/editor/image-edit.js.map +1 -1
  147. package/dist/editor/index.d.ts +4 -4
  148. package/dist/editor/index.js +1 -1
  149. package/dist/editor/layout-mode.d.ts +3 -1
  150. package/dist/editor/layout-mode.d.ts.map +1 -1
  151. package/dist/editor/layout-mode.js +97 -2
  152. package/dist/editor/layout-mode.js.map +1 -1
  153. package/dist/editor/nodes.d.ts +2 -0
  154. package/dist/editor/nodes.d.ts.map +1 -1
  155. package/dist/editor/nodes.js +22 -7
  156. package/dist/editor/nodes.js.map +1 -1
  157. package/dist/editor/read-only/actions.js +6 -0
  158. package/dist/editor/read-only/actions.js.map +1 -1
  159. package/dist/editor/selection/overlays.d.ts +1 -0
  160. package/dist/editor/selection/overlays.d.ts.map +1 -1
  161. package/dist/editor/selection/overlays.js +7 -0
  162. package/dist/editor/selection/overlays.js.map +1 -1
  163. package/dist/editor/selection/read.d.ts +8 -0
  164. package/dist/editor/selection.d.ts +9 -0
  165. package/dist/editor/selection.d.ts.map +1 -1
  166. package/dist/editor/state/shared.js +1 -0
  167. package/dist/editor/state/shared.js.map +1 -1
  168. package/dist/editor/state/view.d.ts.map +1 -1
  169. package/dist/editor/state/view.js +2 -0
  170. package/dist/editor/state/view.js.map +1 -1
  171. package/dist/editor/structure/boolean.d.ts +1 -1
  172. package/dist/editor/structure/boolean.d.ts.map +1 -1
  173. package/dist/editor/structure/boolean.js +20 -1
  174. package/dist/editor/structure/boolean.js.map +1 -1
  175. package/dist/editor/structure/container-wrap.d.ts +8 -2
  176. package/dist/editor/structure/container-wrap.d.ts.map +1 -1
  177. package/dist/editor/structure/container-wrap.js +17 -5
  178. package/dist/editor/structure/container-wrap.js.map +1 -1
  179. package/dist/editor/structure/flatten.d.ts.map +1 -1
  180. package/dist/editor/structure/flatten.js +8 -7
  181. package/dist/editor/structure/flatten.js.map +1 -1
  182. package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
  183. package/dist/editor/structure/group/ungroup.js +2 -0
  184. package/dist/editor/structure/group/ungroup.js.map +1 -1
  185. package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
  186. package/dist/editor/structure/outline-stroke.js +5 -0
  187. package/dist/editor/structure/outline-stroke.js.map +1 -1
  188. package/dist/editor/structure.d.ts +1 -1
  189. package/dist/editor/structure.d.ts.map +1 -1
  190. package/dist/editor/styles.d.ts +26 -0
  191. package/dist/editor/styles.d.ts.map +1 -0
  192. package/dist/editor/styles.js +127 -0
  193. package/dist/editor/styles.js.map +1 -0
  194. package/dist/editor/text/selection-style.d.ts +1 -0
  195. package/dist/editor/text/selection-style.d.ts.map +1 -1
  196. package/dist/editor/text/selection-style.js +10 -2
  197. package/dist/editor/text/selection-style.js.map +1 -1
  198. package/dist/editor/tool-registry.d.ts.map +1 -1
  199. package/dist/editor/tool-registry.js +6 -0
  200. package/dist/editor/tool-registry.js.map +1 -1
  201. package/dist/editor/types.d.ts +14 -2
  202. package/dist/editor/types.d.ts.map +1 -1
  203. package/dist/editor/variable-bindings.d.ts.map +1 -1
  204. package/dist/editor/variable-bindings.js +6 -1
  205. package/dist/editor/variable-bindings.js.map +1 -1
  206. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  207. package/dist/figma-api/accessors/basic.js +22 -1
  208. package/dist/figma-api/accessors/basic.js.map +1 -1
  209. package/dist/figma-api/accessors/shape.js +1 -1
  210. package/dist/figma-api/accessors/text/index.js +1 -1
  211. package/dist/figma-api/accessors/text/ranges.js +1 -1
  212. package/dist/figma-api/accessors/text/references.js +1 -1
  213. package/dist/figma-api/accessors/variables.js +1 -1
  214. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  215. package/dist/figma-api/accessors/vector.js +8 -22
  216. package/dist/figma-api/accessors/vector.js.map +1 -1
  217. package/dist/figma-api/accessors/visual.js +1 -1
  218. package/dist/figma-api/compatibility.d.ts +1 -1
  219. package/dist/figma-api/compatibility.d.ts.map +1 -1
  220. package/dist/figma-api/component-scope.d.ts +14 -0
  221. package/dist/figma-api/component-scope.d.ts.map +1 -0
  222. package/dist/figma-api/component-scope.js +28 -0
  223. package/dist/figma-api/component-scope.js.map +1 -0
  224. package/dist/figma-api/components.d.ts.map +1 -1
  225. package/dist/figma-api/components.js +26 -2
  226. package/dist/figma-api/components.js.map +1 -1
  227. package/dist/figma-api/flatten.js +3 -3
  228. package/dist/figma-api/flatten.js.map +1 -1
  229. package/dist/figma-api/index.d.ts +77 -6
  230. package/dist/figma-api/index.d.ts.map +1 -1
  231. package/dist/figma-api/index.js +188 -2
  232. package/dist/figma-api/index.js.map +1 -1
  233. package/dist/figma-api/node-types.d.ts +2 -1
  234. package/dist/figma-api/node-types.d.ts.map +1 -1
  235. package/dist/figma-api/overrides.d.ts +26 -1
  236. package/dist/figma-api/overrides.d.ts.map +1 -1
  237. package/dist/figma-api/overrides.js +157 -10
  238. package/dist/figma-api/overrides.js.map +1 -1
  239. package/dist/figma-api/proxy.d.ts +2 -0
  240. package/dist/figma-api/proxy.d.ts.map +1 -1
  241. package/dist/figma-api/proxy.js +10 -2
  242. package/dist/figma-api/proxy.js.map +1 -1
  243. package/dist/figma-api/reactions.d.ts +61 -5
  244. package/dist/figma-api/reactions.d.ts.map +1 -1
  245. package/dist/figma-api/reactions.js +144 -11
  246. package/dist/figma-api/reactions.js.map +1 -1
  247. package/dist/figma-api/shape-with-text.js +1 -1
  248. package/dist/figma-api/slots.d.ts +3 -1
  249. package/dist/figma-api/slots.d.ts.map +1 -1
  250. package/dist/figma-api/slots.js +9 -8
  251. package/dist/figma-api/slots.js.map +1 -1
  252. package/dist/index.d.ts +4 -4
  253. package/dist/index.js +1 -1
  254. package/dist/io/formats/code/detect.d.ts +23 -0
  255. package/dist/io/formats/code/detect.d.ts.map +1 -0
  256. package/dist/io/formats/code/detect.js +46 -0
  257. package/dist/io/formats/code/detect.js.map +1 -0
  258. package/dist/io/formats/code/index.d.ts +5 -0
  259. package/dist/io/formats/code/index.js +5 -0
  260. package/dist/io/formats/code/read.d.ts +45 -0
  261. package/dist/io/formats/code/read.d.ts.map +1 -0
  262. package/dist/io/formats/code/read.js +86 -0
  263. package/dist/io/formats/code/read.js.map +1 -0
  264. package/dist/io/formats/code/stylesheet.d.ts +13 -0
  265. package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
  266. package/dist/io/formats/code/stylesheet.js +21 -0
  267. package/dist/io/formats/code/stylesheet.js.map +1 -0
  268. package/dist/io/formats/code/tokens.d.ts +18 -0
  269. package/dist/io/formats/code/tokens.d.ts.map +1 -0
  270. package/dist/io/formats/code/tokens.js +135 -0
  271. package/dist/io/formats/code/tokens.js.map +1 -0
  272. package/dist/io/formats/design-tokens/apply.d.ts +7 -3
  273. package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
  274. package/dist/io/formats/design-tokens/apply.js.map +1 -1
  275. package/dist/io/formats/drawio/warnings.d.ts +17 -2
  276. package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
  277. package/dist/io/formats/drawio/warnings.js +14 -7
  278. package/dist/io/formats/drawio/warnings.js.map +1 -1
  279. package/dist/io/formats/fig/export/patch/fields.js +5 -0
  280. package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
  281. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  282. package/dist/io/formats/fig/export/patch/index.js +20 -20
  283. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  284. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  285. package/dist/io/formats/fig/export/setup.js +5 -1
  286. package/dist/io/formats/fig/export/setup.js.map +1 -1
  287. package/dist/io/formats/fig/index.d.ts +3 -2
  288. package/dist/io/formats/fig/index.js +2 -2
  289. package/dist/io/formats/fig/read.d.ts.map +1 -1
  290. package/dist/io/formats/fig/read.js +5 -2
  291. package/dist/io/formats/fig/read.js.map +1 -1
  292. package/dist/io/formats/html/index.d.ts +1 -0
  293. package/dist/io/formats/html/index.d.ts.map +1 -1
  294. package/dist/io/formats/html/index.js +5 -3
  295. package/dist/io/formats/html/index.js.map +1 -1
  296. package/dist/io/formats/html/layers.d.ts +3 -1
  297. package/dist/io/formats/html/layers.d.ts.map +1 -1
  298. package/dist/io/formats/html/layers.js +6 -1
  299. package/dist/io/formats/html/layers.js.map +1 -1
  300. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  301. package/dist/io/formats/pdf/export.js +7 -3
  302. package/dist/io/formats/pdf/export.js.map +1 -1
  303. package/dist/io/formats/pdf/plan.d.ts +3 -0
  304. package/dist/io/formats/pdf/plan.d.ts.map +1 -1
  305. package/dist/io/formats/pdf/plan.js +60 -36
  306. package/dist/io/formats/pdf/plan.js.map +1 -1
  307. package/dist/io/formats/pen/index.d.ts.map +1 -1
  308. package/dist/io/formats/pen/index.js +13 -4
  309. package/dist/io/formats/pen/index.js.map +1 -1
  310. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  311. package/dist/io/formats/raster/headless.js +3 -2
  312. package/dist/io/formats/raster/headless.js.map +1 -1
  313. package/dist/io/formats/raster/index.d.ts +2 -2
  314. package/dist/io/formats/raster/index.js +2 -2
  315. package/dist/io/formats/raster/render.d.ts +10 -2
  316. package/dist/io/formats/raster/render.d.ts.map +1 -1
  317. package/dist/io/formats/raster/render.js +35 -9
  318. package/dist/io/formats/raster/render.js.map +1 -1
  319. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  320. package/dist/io/formats/svg/defs.js +19 -1
  321. package/dist/io/formats/svg/defs.js.map +1 -1
  322. package/dist/io/formats/svg/export.d.ts +5 -2
  323. package/dist/io/formats/svg/export.d.ts.map +1 -1
  324. package/dist/io/formats/svg/export.js +59 -10
  325. package/dist/io/formats/svg/export.js.map +1 -1
  326. package/dist/io/formats/svg/index.d.ts +2 -2
  327. package/dist/io/formats/svg/index.js +2 -2
  328. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  329. package/dist/io/formats/svg/text/layout.js +4 -2
  330. package/dist/io/formats/svg/text/layout.js.map +1 -1
  331. package/dist/io/formats/video/record.d.ts.map +1 -1
  332. package/dist/io/formats/video/record.js +24 -9
  333. package/dist/io/formats/video/record.js.map +1 -1
  334. package/dist/io/formats.d.ts.map +1 -1
  335. package/dist/io/formats.js +30 -17
  336. package/dist/io/formats.js.map +1 -1
  337. package/dist/io/index.d.ts +2 -2
  338. package/dist/io/types.d.ts +11 -2
  339. package/dist/io/types.d.ts.map +1 -1
  340. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  341. package/dist/kiwi/fig/population/client.js +2 -1
  342. package/dist/kiwi/fig/population/client.js.map +1 -1
  343. package/dist/kiwi/fig/session/document-state.d.ts +46 -2
  344. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  345. package/dist/kiwi/fig/session/document-state.js +113 -5
  346. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  347. package/dist/kiwi/fig/session/options.d.ts +4 -0
  348. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  349. package/dist/kiwi/fig/session/options.js.map +1 -1
  350. package/dist/layout/apply.d.ts.map +1 -1
  351. package/dist/layout/apply.js +8 -4
  352. package/dist/layout/apply.js.map +1 -1
  353. package/dist/layout/auto-layout-handles.js +1 -1
  354. package/dist/layout/auto-layout-handles.js.map +1 -1
  355. package/dist/layout/axis-sizing.d.ts.map +1 -1
  356. package/dist/layout/axis-sizing.js +1 -1
  357. package/dist/layout/axis-sizing.js.map +1 -1
  358. package/dist/layout/derived.d.ts.map +1 -1
  359. package/dist/layout/derived.js +1 -1
  360. package/dist/layout/derived.js.map +1 -1
  361. package/dist/layout/effective-generated-text.js +1 -1
  362. package/dist/layout/effective-generated-text.js.map +1 -1
  363. package/dist/layout/grid.d.ts +3 -1
  364. package/dist/layout/grid.d.ts.map +1 -1
  365. package/dist/layout/grid.js +57 -16
  366. package/dist/layout/grid.js.map +1 -1
  367. package/dist/layout.d.ts +1 -1
  368. package/dist/layout.js +6 -5
  369. package/dist/layout.js.map +1 -1
  370. package/dist/node/fs.d.ts.map +1 -1
  371. package/dist/node/fs.js +28 -7
  372. package/dist/node/fs.js.map +1 -1
  373. package/dist/prototype/easing.d.ts +13 -5
  374. package/dist/prototype/easing.d.ts.map +1 -1
  375. package/dist/prototype/easing.js +46 -6
  376. package/dist/prototype/easing.js.map +1 -1
  377. package/dist/prototype/scenes.d.ts +31 -0
  378. package/dist/prototype/scenes.d.ts.map +1 -1
  379. package/dist/prototype/scenes.js +220 -31
  380. package/dist/prototype/scenes.js.map +1 -1
  381. package/dist/prototype/session.d.ts.map +1 -1
  382. package/dist/prototype/session.js +1 -0
  383. package/dist/prototype/session.js.map +1 -1
  384. package/dist/prototype/smart-animate/animation.d.ts +2 -1
  385. package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
  386. package/dist/prototype/smart-animate/animation.js +2 -2
  387. package/dist/prototype/smart-animate/animation.js.map +1 -1
  388. package/dist/prototype/timeline.d.ts +10 -1
  389. package/dist/prototype/timeline.d.ts.map +1 -1
  390. package/dist/prototype/timeline.js +69 -23
  391. package/dist/prototype/timeline.js.map +1 -1
  392. package/dist/prototype/variables.d.ts +23 -0
  393. package/dist/prototype/variables.d.ts.map +1 -0
  394. package/dist/prototype/variables.js +237 -0
  395. package/dist/prototype/variables.js.map +1 -0
  396. package/dist/rpc/read-commands.d.ts +5 -0
  397. package/dist/rpc/read-commands.d.ts.map +1 -1
  398. package/dist/rpc/read-commands.js +4 -1
  399. package/dist/rpc/read-commands.js.map +1 -1
  400. package/dist/text/character-style.d.ts +8 -1
  401. package/dist/text/character-style.d.ts.map +1 -1
  402. package/dist/text/character-style.js +39 -1
  403. package/dist/text/character-style.js.map +1 -1
  404. package/dist/text/index.d.ts +2 -2
  405. package/dist/text/index.js +2 -2
  406. package/dist/tools/create/basic.js +3 -4
  407. package/dist/tools/create/basic.js.map +1 -1
  408. package/dist/tools/create/behaviours.js +1 -1
  409. package/dist/tools/create/code.d.ts +6 -0
  410. package/dist/tools/create/code.d.ts.map +1 -0
  411. package/dist/tools/create/code.js +68 -0
  412. package/dist/tools/create/code.js.map +1 -0
  413. package/dist/tools/create/html.d.ts.map +1 -1
  414. package/dist/tools/create/html.js +9 -57
  415. package/dist/tools/create/html.js.map +1 -1
  416. package/dist/tools/create/icons.js +1 -1
  417. package/dist/tools/create/inputs.d.ts +11 -0
  418. package/dist/tools/create/inputs.d.ts.map +1 -0
  419. package/dist/tools/create/inputs.js +15 -0
  420. package/dist/tools/create/inputs.js.map +1 -0
  421. package/dist/tools/create/mermaid.d.ts.map +1 -1
  422. package/dist/tools/create/mermaid.js +5 -6
  423. package/dist/tools/create/mermaid.js.map +1 -1
  424. package/dist/tools/create/place.d.ts +30 -0
  425. package/dist/tools/create/place.d.ts.map +1 -0
  426. package/dist/tools/create/place.js +70 -0
  427. package/dist/tools/create/place.js.map +1 -0
  428. package/dist/tools/create/render.js +1 -1
  429. package/dist/tools/create/svg.js +1 -1
  430. package/dist/tools/create/vector.js +1 -1
  431. package/dist/tools/create.d.ts +2 -1
  432. package/dist/tools/create.js +2 -1
  433. package/dist/tools/css/gradient.d.ts +28 -0
  434. package/dist/tools/css/gradient.d.ts.map +1 -0
  435. package/dist/tools/css/gradient.js +118 -0
  436. package/dist/tools/css/gradient.js.map +1 -0
  437. package/dist/tools/image-ai/generate.js +1 -1
  438. package/dist/tools/modify/geometry.js +5 -5
  439. package/dist/tools/modify/geometry.js.map +1 -1
  440. package/dist/tools/modify/layout.d.ts.map +1 -1
  441. package/dist/tools/modify/layout.js +7 -1
  442. package/dist/tools/modify/layout.js.map +1 -1
  443. package/dist/tools/modify/matching.js +1 -1
  444. package/dist/tools/modify/overrides.d.ts +6 -0
  445. package/dist/tools/modify/overrides.d.ts.map +1 -0
  446. package/dist/tools/modify/overrides.js +27 -0
  447. package/dist/tools/modify/overrides.js.map +1 -0
  448. package/dist/tools/modify/paint.d.ts.map +1 -1
  449. package/dist/tools/modify/paint.js +84 -39
  450. package/dist/tools/modify/paint.js.map +1 -1
  451. package/dist/tools/modify/text.d.ts +2 -1
  452. package/dist/tools/modify/text.d.ts.map +1 -1
  453. package/dist/tools/modify/text.js +79 -8
  454. package/dist/tools/modify/text.js.map +1 -1
  455. package/dist/tools/modify/update.d.ts.map +1 -1
  456. package/dist/tools/modify/update.js +18 -2
  457. package/dist/tools/modify/update.js.map +1 -1
  458. package/dist/tools/modify.d.ts +3 -2
  459. package/dist/tools/modify.js +3 -2
  460. package/dist/tools/read/css.d.ts.map +1 -1
  461. package/dist/tools/read/css.js +29 -12
  462. package/dist/tools/read/css.js.map +1 -1
  463. package/dist/tools/read/libraries.js +1 -1
  464. package/dist/tools/read/nodes.d.ts.map +1 -1
  465. package/dist/tools/read/nodes.js +19 -5
  466. package/dist/tools/read/nodes.js.map +1 -1
  467. package/dist/tools/registry/extended.d.ts.map +1 -1
  468. package/dist/tools/registry/extended.js +6 -1
  469. package/dist/tools/registry/extended.js.map +1 -1
  470. package/dist/tools/text-range.d.ts +11 -0
  471. package/dist/tools/text-range.d.ts.map +1 -0
  472. package/dist/tools/text-range.js +26 -0
  473. package/dist/tools/text-range.js.map +1 -0
  474. package/dist/tools/variables/bindings.js +1 -1
  475. package/dist/tools/variables/bindings.js.map +1 -1
  476. package/dist/tools/variables/unbind.js +1 -1
  477. package/dist/tools/variables/unbind.js.map +1 -1
  478. package/dist/tools/vector/path.d.ts.map +1 -1
  479. package/dist/tools/vector/path.js +7 -21
  480. package/dist/tools/vector/path.js.map +1 -1
  481. package/dist/vector/rebase.d.ts +17 -0
  482. package/dist/vector/rebase.d.ts.map +1 -0
  483. package/dist/vector/rebase.js +32 -0
  484. package/dist/vector/rebase.js.map +1 -0
  485. package/package.json +14 -9
  486. package/src/canvas/boolean.ts +12 -1
  487. package/src/canvas/color-space.ts +73 -0
  488. package/src/canvas/fills.ts +130 -83
  489. package/src/canvas/flatten.ts +92 -7
  490. package/src/canvas/index.ts +9 -0
  491. package/src/canvas/layout-grids.ts +15 -2
  492. package/src/canvas/noise/render.ts +35 -7
  493. package/src/canvas/noise/shader.ts +8 -10
  494. package/src/canvas/overlays/annotations.ts +117 -0
  495. package/src/canvas/overlays/auto-layout-hover.ts +41 -1
  496. package/src/canvas/overlays/feedback.ts +7 -2
  497. package/src/canvas/overlays/index.ts +1 -1
  498. package/src/canvas/overlays/measurement.ts +49 -3
  499. package/src/canvas/overlays/presence.ts +35 -32
  500. package/src/canvas/renderer/colors.ts +14 -0
  501. package/src/canvas/renderer/document-surface.ts +16 -6
  502. package/src/canvas/renderer/lifecycle.ts +2 -2
  503. package/src/canvas/renderer/methods.ts +4 -0
  504. package/src/canvas/renderer/overlay-pass.ts +4 -0
  505. package/src/canvas/renderer/pipeline.ts +8 -0
  506. package/src/canvas/renderer/types.ts +8 -0
  507. package/src/canvas/renderer.ts +21 -2
  508. package/src/canvas/scene.ts +15 -7
  509. package/src/canvas/shaders/compile.ts +14 -3
  510. package/src/canvas/shaders/draw.ts +11 -4
  511. package/src/canvas/shaders/effect.ts +6 -18
  512. package/src/clipboard/pairdraw.ts +1 -0
  513. package/src/editor/bridges/clipboard.ts +1 -0
  514. package/src/editor/bridges/components.ts +10 -0
  515. package/src/editor/clipboard/code.ts +50 -0
  516. package/src/editor/clipboard/export.ts +2 -2
  517. package/src/editor/clipboard/paste/dependencies.ts +18 -0
  518. package/src/editor/clipboard/paste/run.ts +64 -0
  519. package/src/editor/clipboard/styled.ts +4 -52
  520. package/src/editor/clipboard.ts +40 -0
  521. package/src/editor/components/instances.ts +92 -4
  522. package/src/editor/components/slots/index.ts +7 -0
  523. package/src/editor/components.ts +16 -2
  524. package/src/editor/create.ts +15 -1
  525. package/src/editor/design-tokens.ts +3 -23
  526. package/src/editor/image-edit.ts +5 -2
  527. package/src/editor/index.ts +1 -0
  528. package/src/editor/layout-mode.ts +131 -3
  529. package/src/editor/nodes.ts +30 -5
  530. package/src/editor/read-only/actions.ts +6 -0
  531. package/src/editor/selection/overlays.ts +8 -0
  532. package/src/editor/state/shared.ts +1 -0
  533. package/src/editor/state/view.ts +2 -0
  534. package/src/editor/structure/boolean.ts +29 -1
  535. package/src/editor/structure/container-wrap.ts +20 -4
  536. package/src/editor/structure/flatten.ts +15 -8
  537. package/src/editor/structure/group/ungroup.ts +2 -0
  538. package/src/editor/structure/outline-stroke.ts +5 -0
  539. package/src/editor/styles.ts +203 -0
  540. package/src/editor/text/selection-style.ts +18 -1
  541. package/src/editor/tool-registry.ts +2 -0
  542. package/src/editor/types.ts +14 -0
  543. package/src/editor/variable-bindings.ts +11 -0
  544. package/src/figma-api/accessors/basic.ts +33 -1
  545. package/src/figma-api/accessors/vector.ts +6 -13
  546. package/src/figma-api/compatibility.ts +1 -0
  547. package/src/figma-api/component-scope.ts +36 -0
  548. package/src/figma-api/components.ts +24 -0
  549. package/src/figma-api/flatten.ts +7 -3
  550. package/src/figma-api/index.ts +302 -6
  551. package/src/figma-api/node-types.ts +1 -0
  552. package/src/figma-api/overrides.ts +192 -5
  553. package/src/figma-api/proxy.ts +16 -1
  554. package/src/figma-api/reactions.ts +163 -12
  555. package/src/figma-api/slots.ts +10 -9
  556. package/src/io/formats/code/detect.ts +67 -0
  557. package/src/io/formats/code/index.ts +17 -0
  558. package/src/io/formats/code/read.ts +143 -0
  559. package/src/io/formats/code/stylesheet.ts +24 -0
  560. package/src/io/formats/code/tokens.ts +159 -0
  561. package/src/io/formats/design-tokens/apply.ts +3 -2
  562. package/src/io/formats/drawio/warnings.ts +27 -8
  563. package/src/io/formats/fig/export/patch/fields.ts +11 -0
  564. package/src/io/formats/fig/export/patch/index.ts +23 -19
  565. package/src/io/formats/fig/export/setup.ts +8 -1
  566. package/src/io/formats/fig/index.ts +6 -0
  567. package/src/io/formats/fig/read.ts +11 -2
  568. package/src/io/formats/html/index.ts +9 -3
  569. package/src/io/formats/html/layers.ts +7 -0
  570. package/src/io/formats/pdf/export.ts +19 -7
  571. package/src/io/formats/pdf/plan.ts +71 -32
  572. package/src/io/formats/pen/index.ts +14 -6
  573. package/src/io/formats/raster/headless.ts +3 -1
  574. package/src/io/formats/raster/index.ts +2 -0
  575. package/src/io/formats/raster/render.ts +49 -9
  576. package/src/io/formats/svg/defs.ts +27 -1
  577. package/src/io/formats/svg/export.ts +75 -13
  578. package/src/io/formats/svg/index.ts +1 -0
  579. package/src/io/formats/svg/text/layout.ts +5 -3
  580. package/src/io/formats/video/record.ts +33 -9
  581. package/src/io/formats.ts +45 -19
  582. package/src/io/index.ts +1 -0
  583. package/src/io/types.ts +10 -0
  584. package/src/kiwi/fig/population/client.ts +6 -1
  585. package/src/kiwi/fig/session/document-state.ts +195 -5
  586. package/src/kiwi/fig/session/options.ts +2 -0
  587. package/src/layout/apply.ts +12 -4
  588. package/src/layout/auto-layout-handles.ts +1 -1
  589. package/src/layout/axis-sizing.ts +3 -1
  590. package/src/layout/derived.ts +3 -1
  591. package/src/layout/effective-generated-text.ts +1 -1
  592. package/src/layout/grid.ts +91 -21
  593. package/src/layout.ts +16 -3
  594. package/src/node/fs.ts +32 -7
  595. package/src/prototype/easing.ts +79 -7
  596. package/src/prototype/scenes.ts +244 -15
  597. package/src/prototype/session.ts +1 -0
  598. package/src/prototype/smart-animate/animation.ts +4 -3
  599. package/src/prototype/timeline.ts +118 -26
  600. package/src/prototype/variables.ts +189 -0
  601. package/src/rpc/read-commands.ts +19 -1
  602. package/src/text/character-style.ts +47 -0
  603. package/src/text/index.ts +1 -1
  604. package/src/tools/create/basic.ts +2 -3
  605. package/src/tools/create/code.ts +85 -0
  606. package/src/tools/create/html.ts +9 -46
  607. package/src/tools/create/inputs.ts +12 -0
  608. package/src/tools/create/mermaid.ts +6 -6
  609. package/src/tools/create/place.ts +80 -0
  610. package/src/tools/create.ts +1 -0
  611. package/src/tools/css/gradient.ts +147 -0
  612. package/src/tools/modify/geometry.ts +5 -5
  613. package/src/tools/modify/layout.ts +19 -0
  614. package/src/tools/modify/overrides.ts +35 -0
  615. package/src/tools/modify/paint.ts +124 -54
  616. package/src/tools/modify/text.ts +91 -7
  617. package/src/tools/modify/update.ts +23 -2
  618. package/src/tools/modify.ts +9 -1
  619. package/src/tools/read/css.ts +46 -12
  620. package/src/tools/read/nodes.ts +26 -4
  621. package/src/tools/registry/extended.ts +6 -0
  622. package/src/tools/text-range.ts +29 -0
  623. package/src/tools/variables/bindings.ts +4 -1
  624. package/src/tools/variables/unbind.ts +4 -1
  625. package/src/tools/vector/path.ts +11 -13
  626. package/src/vector/rebase.ts +33 -0
@@ -1,13 +1,16 @@
1
1
  import { isValid, toUint8Array } from 'js-base64'
2
2
  import * as v from 'valibot'
3
3
 
4
- import type { Variable, VariableCollection, VariableValue } from '@pairdraw/scene-graph'
4
+ import type { Fill, Variable, VariableCollection, VariableValue } from '@pairdraw/scene-graph'
5
5
  import { gradientTransformRows, linearGradientTransform } from '@pairdraw/scene-graph/gradient'
6
6
  import type { Color, Vector } from '@pairdraw/scene-graph/primitives'
7
7
 
8
8
  import type { FigmaAPI } from '#core/figma-api'
9
9
  import { storeImage } from '#core/figma-api/images'
10
+ import { toFigmaPaint, type FigmaPaint } from '#core/figma-api/paints'
10
11
  import { PairdrawAPI } from '#core/pairdraw-api'
12
+ import type { WritableGradient } from '#core/tools/css/gradient'
13
+ import { gradientFillFromCSS } from '#core/tools/css/gradient'
11
14
  import {
12
15
  defineTool,
13
16
  nodeIdInputSchema,
@@ -25,6 +28,14 @@ const STRETCH_IMAGE_TRANSFORM: [[number, number, number], [number, number, numbe
25
28
  [0, 1, 0]
26
29
  ]
27
30
 
31
+ /**
32
+ * A solid paint with its alpha where Figma stores it: in `opacity`, with the colour opaque, so the
33
+ * read side's `color.a * opacity` prints the colour that paints. `get_css` writes the same product.
34
+ */
35
+ function solidFillPaint(color: Color): Fill {
36
+ return { type: 'SOLID', color: { ...color, a: 1 }, opacity: color.a, visible: true }
37
+ }
38
+
28
39
  /**
29
40
  * `var(--color/brand)` or `var(--color/brand, #4F46E5)`: a token by name, as `get_css` writes it.
30
41
  * The fallback runs to the last `)`, since a Display P3 document writes one as `color(display-p3 …)`.
@@ -57,74 +68,134 @@ function tokenColor(
57
68
  return { color: value, collection }
58
69
  }
59
70
 
71
+ /** The direction words `set_fill` takes as a gradient, as opposed to a CSS gradient string. */
72
+ const GRADIENT_DIRECTIONS = new Set(['top-bottom', 'bottom-top', 'left-right', 'right-left'])
73
+
74
+ /** A `get_css` gradient string, parsed into the fill it describes, or the reason it cannot be. */
75
+ function cssGradientFill(
76
+ figma: FigmaAPI,
77
+ node: { width: number; height: number },
78
+ gradient: string,
79
+ color: string | undefined,
80
+ color_end: string | undefined
81
+ ): { fill: WritableGradient } | { error: string } {
82
+ if (!(node.width > 0) || !(node.height > 0)) {
83
+ return { error: 'A gradient needs a layer with a width and a height.' }
84
+ }
85
+ if (color !== undefined || color_end !== undefined) {
86
+ return {
87
+ error:
88
+ 'A CSS gradient string carries its own colours; omit color and color_end. Use a direction word with color for a two-stop gradient.'
89
+ }
90
+ }
91
+ const parsed = gradientFillFromCSS({
92
+ text: gradient,
93
+ width: node.width,
94
+ height: node.height,
95
+ profile: figma.graph.documentColorSpace,
96
+ color: (text) => parseToolColor(text, figma.graph.documentColorSpace)
97
+ })
98
+ return 'error' in parsed ? parsed : { fill: parsed.fill }
99
+ }
100
+
101
+ /**
102
+ * A `var(--name)` fill, painted with the token it names and bound to it, or the reason it cannot be.
103
+ * `undefined` when `color` is not a token, so the caller paints it as a plain colour.
104
+ */
105
+ function tokenFill(
106
+ figma: FigmaAPI,
107
+ node: { id: string; fills: readonly FigmaPaint[] | symbol },
108
+ color: string,
109
+ color_end: string | undefined,
110
+ gradient: boolean
111
+ ): { id: string; color: Color; bound: string } | { error: string } | undefined {
112
+ const token = COLOR_TOKEN.exec(color)
113
+ const endToken = color_end === undefined ? null : COLOR_TOKEN.exec(color_end)
114
+ // Gradient stops carry no variable binding, so a token there would paint the wrong thing.
115
+ if (gradient && (token !== null || endToken !== null)) {
116
+ const named = [
117
+ token === null ? undefined : `"${token[1]}"`,
118
+ endToken === null ? undefined : `"${endToken[1]}"`
119
+ ]
120
+ .filter((entry) => entry !== undefined)
121
+ .join(' and ')
122
+ return {
123
+ error: `A gradient cannot take the token ${named}: gradient stops have no variable binding. Pass hex colours for a gradient, or a token only for a solid fill.`
124
+ }
125
+ }
126
+ if (token === null) return undefined
127
+ const name = token[1]
128
+ const matches = colorVariablesNamed(figma, name)
129
+ if (matches.length === 0) {
130
+ return {
131
+ error: `No COLOR variable named "${name}". Call find_variables to list the document's tokens.`
132
+ }
133
+ }
134
+ if (matches.length > 1) {
135
+ const where = matches
136
+ .map(
137
+ (variable) =>
138
+ figma.graph.variableCollections.get(variable.collectionId)?.name ?? variable.collectionId
139
+ )
140
+ .join(', ')
141
+ return {
142
+ error: `${matches.length} variables named "${name}" (${where}); bind one with bind_variable.`
143
+ }
144
+ }
145
+ for (const variable of matches) {
146
+ const resolved = tokenColor(figma, variable)
147
+ if ('error' in resolved) return resolved
148
+ node.fills = [toFigmaPaint(solidFillPaint(resolved.color))]
149
+ new PairdrawAPI(figma).bindVariable(node.id, 'fills/0/color', variable)
150
+ return { id: node.id, color: resolved.color, bound: name }
151
+ }
152
+ return { error: `No COLOR variable named "${name}"` }
153
+ }
154
+
60
155
  export const setFill = defineTool({
61
156
  name: 'set_fill',
62
157
 
63
158
  description:
64
- 'Set fill on a node. Solid: color="#ff0000". A token by name: color="var(--color/brand)" paints its colour and binds the fill. Linear gradient: gradient="top-bottom" or "left-right" with color (start) and color_end (end); gradient stops take hex colours, not tokens.',
159
+ 'Set fill on a node. Solid: color="#ff0000" (rgba() and color(display-p3 … / a) keep their alpha). A token by name: color="var(--color/brand)" paints its colour and binds the fill. Direction gradient: gradient="top-bottom" or "left-right" with color (start) and color_end (end). A CSS gradient string from get_css, such as gradient="linear-gradient(180deg, #FF0000 0%, #0000FF 100%)" or gradient="diamond-gradient(#FF0000, #0000FF)", carries its own colours; gradient stops take colours, not tokens.',
65
160
  execution: { kind: 'sync', mutation: 'properties' },
66
161
  input: v.strictObject({
67
162
  id: nodeIdInputSchema,
68
- color: v.pipe(v.string(), v.description('Color (hex). For gradient: start color.')),
69
- color_end: v.optional(
70
- v.pipe(v.string(), v.description('End color for gradient (if omitted, solid fill)'))
163
+ color: v.optional(
164
+ v.pipe(v.string(), v.description('Color (hex, rgba(), or color(display-p3 …)).'))
71
165
  ),
166
+ color_end: v.optional(v.pipe(v.string(), v.description('End color for a direction gradient'))),
72
167
  gradient: v.optional(
73
- v.pipe(
74
- v.picklist(['top-bottom', 'bottom-top', 'left-right', 'right-left']),
75
- v.description('Gradient direction')
76
- )
168
+ v.union([
169
+ v.pipe(
170
+ v.picklist(['top-bottom', 'bottom-top', 'left-right', 'right-left']),
171
+ v.description('Gradient direction')
172
+ ),
173
+ v.pipe(
174
+ v.string(),
175
+ v.description('A CSS gradient string from get_css, e.g. linear-gradient(180deg, …)')
176
+ )
177
+ ])
77
178
  )
78
179
  }),
79
180
  execute: (figma, { id, color, color_end, gradient }) => {
80
181
  const node = figma.getNodeById(id)
81
182
  if (!node) return { error: `Node "${id}" not found` }
82
-
83
- // A token name paints the colour it holds and binds the fill, so the layer follows the token.
84
- const token = COLOR_TOKEN.exec(color)
85
- const endToken = color_end === undefined ? null : COLOR_TOKEN.exec(color_end)
86
- // Gradient stops carry no variable binding, so a token there would paint the wrong thing.
87
- if (gradient && (token !== null || endToken !== null)) {
88
- const named = [
89
- token === null ? undefined : `"${token[1]}"`,
90
- endToken === null ? undefined : `"${endToken[1]}"`
91
- ]
92
- .filter((entry) => entry !== undefined)
93
- .join(' and ')
94
- return {
95
- error: `A gradient cannot take the token ${named}: gradient stops have no variable binding. Pass hex colours for a gradient, or a token only for a solid fill.`
96
- }
183
+ if (typeof gradient === 'string' && !GRADIENT_DIRECTIONS.has(gradient)) {
184
+ const result = cssGradientFill(figma, node, gradient, color, color_end)
185
+ if ('error' in result) return result
186
+ node.fills = [result.fill]
187
+ return { id, gradient }
97
188
  }
98
- const name = token === null ? null : token[1]
99
- if (name !== null) {
100
- const matches = colorVariablesNamed(figma, name)
101
- if (matches.length === 0) {
102
- return {
103
- error: `No COLOR variable named "${name}". Call find_variables to list the document's tokens.`
104
- }
105
- }
106
- if (matches.length > 1) {
107
- const where = matches
108
- .map(
109
- (variable) =>
110
- figma.graph.variableCollections.get(variable.collectionId)?.name ??
111
- variable.collectionId
112
- )
113
- .join(', ')
114
- return {
115
- error: `${matches.length} variables named "${name}" (${where}); bind one with bind_variable.`
116
- }
117
- }
118
- for (const variable of matches) {
119
- const resolved = tokenColor(figma, variable)
120
- if ('error' in resolved) return resolved
121
- node.fills = [{ type: 'SOLID', color: resolved.color }]
122
- new PairdrawAPI(figma).bindVariable(node.id, 'fills/0/color', variable)
123
- return { id, color: resolved.color, bound: name }
189
+ if (color === undefined) {
190
+ return {
191
+ error: 'Provide color for a solid fill, or gradient for a gradient.'
124
192
  }
125
- return { error: `No COLOR variable named "${name}"` }
126
193
  }
127
194
 
195
+ // A token name paints the colour it holds and binds the fill, so the layer follows the token.
196
+ const bound = tokenFill(figma, node, color, color_end, gradient !== undefined)
197
+ if (bound !== undefined) return bound
198
+
128
199
  const c = parseToolColor(color, figma.graph.documentColorSpace)
129
200
  if ('error' in c) return c
130
201
 
@@ -164,8 +235,7 @@ export const setFill = defineTool({
164
235
  return { id, gradient, start: c, end: cEnd }
165
236
  }
166
237
 
167
- // A colour's alpha becomes the paint's opacity, as Figma takes it.
168
- node.fills = [{ type: 'SOLID', color: c }]
238
+ node.fills = [toFigmaPaint(solidFillPaint(c))]
169
239
  return { id, color: c }
170
240
  }
171
241
  })
@@ -193,7 +263,7 @@ export const setStroke = defineTool({
193
263
 
194
264
  const c = parseToolColor(color, figma.graph.documentColorSpace)
195
265
  if ('error' in c) return c
196
- node.strokes = [{ type: 'SOLID', color: c }]
266
+ node.strokes = [toFigmaPaint(solidFillPaint(c))]
197
267
  node.strokeWeight = weight
198
268
  node.strokeAlign = align
199
269
  return { id, color: c, weight: weight }
@@ -17,6 +17,7 @@ import {
17
17
  nodeNotFound,
18
18
  toolFailure
19
19
  } from '#core/tools/schema'
20
+ import { textRangeError } from '#core/tools/text-range'
20
21
 
21
22
  /**
22
23
  * A link a text tool sets, as the editor's link field takes it: a web or mail address, with
@@ -257,6 +258,17 @@ function rangeEdit(
257
258
  return { hyperlink: hyperlink ?? null, color: color.color }
258
259
  }
259
260
 
261
+ const rangeIndex = (description: string) =>
262
+ toolNumber(v.pipe(v.number(), v.integer(), v.minValue(0), v.description(description)))
263
+
264
+ /** A TEXT node for a range edit, or the error the tool returns when the id is not one. */
265
+ function textNodeFor(figma: FigmaAPI, id: string): FigmaNodeProxy | { error: string } {
266
+ const node = figma.getNodeById(id)
267
+ if (!node) return nodeNotFound(id)
268
+ if (node.type !== 'TEXT') return { error: `Node "${id}" is not a TEXT node` }
269
+ return node
270
+ }
271
+
260
272
  export const setFontRange = defineTool({
261
273
  name: 'set_font_range',
262
274
 
@@ -264,8 +276,8 @@ export const setFontRange = defineTool({
264
276
  execution: { kind: 'sync', mutation: 'properties' },
265
277
  input: v.strictObject({
266
278
  id: nodeIdInputSchema,
267
- start: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Start character index'))),
268
- end: toolNumber(v.pipe(v.number(), v.minValue(0), v.description('End character index'))),
279
+ start: rangeIndex('Start character index, in UTF-16 code units'),
280
+ end: rangeIndex('End character index, in UTF-16 code units'),
269
281
  family: v.optional(v.pipe(v.string(), v.description('Font family name'))),
270
282
  size: v.optional(toolNumber(v.pipe(v.number(), v.minValue(1), v.description('Font size')))),
271
283
  style: v.optional(v.pipe(v.string(), v.description('Font style'))),
@@ -284,8 +296,8 @@ export const setFontRange = defineTool({
284
296
  return [...(font ? [font] : []), ...(laysOut ? textFonts(figma, args.id) : [])]
285
297
  },
286
298
  execute: (figma, args) => {
287
- const node = figma.getNodeById(args.id)
288
- if (!node) return nodeNotFound(args.id)
299
+ const node = textNodeFor(figma, args.id)
300
+ if ('error' in node) return node
289
301
  const { start, end } = args
290
302
  const badTag = badVariationTag(args.variations)
291
303
  if (badTag) return badTag
@@ -293,6 +305,8 @@ export const setFontRange = defineTool({
293
305
  if (badFeature) return badFeature
294
306
  const edit = rangeEdit(args, figma.graph.documentColorSpace)
295
307
  if ('error' in edit) return edit
308
+ const rangeError = textRangeError(node.characters, start, end)
309
+ if (rangeError) return { error: rangeError }
296
310
  const { hyperlink, color } = edit
297
311
  // The range methods reject an empty range or one past the text, before changing anything.
298
312
  try {
@@ -316,6 +330,77 @@ export const setFontRange = defineTool({
316
330
  }
317
331
  })
318
332
 
333
+ export const setTextRangeStyle = defineTool({
334
+ name: 'set_text_range_style',
335
+
336
+ description:
337
+ "Set line height, letter spacing, text case, or decoration for a character range. Indices are UTF-16 code units, as the editor's text ranges are.",
338
+
339
+ execution: { kind: 'sync', mutation: 'properties' },
340
+ input: v.strictObject({
341
+ id: nodeIdInputSchema,
342
+ start: rangeIndex('Start index, in UTF-16 code units'),
343
+ end: rangeIndex('End index, in UTF-16 code units'),
344
+ line_height: v.optional(
345
+ toolNumber(v.pipe(v.number(), v.minValue(0), v.description('Line height in pixels')))
346
+ ),
347
+ letter_spacing: v.optional(
348
+ toolNumber(v.pipe(v.number(), v.description('Letter spacing in pixels')))
349
+ ),
350
+ text_case: v.optional(
351
+ v.pipe(
352
+ v.picklist(['ORIGINAL', 'UPPER', 'LOWER', 'TITLE']),
353
+ v.description('Letter case in the range')
354
+ )
355
+ ),
356
+ text_decoration: v.optional(
357
+ v.pipe(
358
+ v.picklist(['NONE', 'UNDERLINE', 'STRIKETHROUGH']),
359
+ v.description('Decoration in the range')
360
+ )
361
+ )
362
+ }),
363
+ fonts: (figma, { id }) => textFonts(figma, id),
364
+ execute: (figma, args) => {
365
+ const node = textNodeFor(figma, args.id)
366
+ if ('error' in node) return node
367
+ const updated: string[] = []
368
+ if (args.line_height !== undefined) updated.push('lineHeight')
369
+ if (args.letter_spacing !== undefined) updated.push('letterSpacing')
370
+ if (args.text_case !== undefined) updated.push('textCase')
371
+ if (args.text_decoration !== undefined) updated.push('textDecoration')
372
+ if (updated.length === 0) {
373
+ return {
374
+ error:
375
+ 'set_text_range_style needs at least one of line_height, letter_spacing, text_case, or text_decoration'
376
+ }
377
+ }
378
+ const rangeError = textRangeError(node.characters, args.start, args.end)
379
+ if (rangeError) return { error: rangeError }
380
+ // The range setters reject a bad range, but the guard above names what went wrong.
381
+ try {
382
+ if (args.line_height !== undefined) {
383
+ node.setRangeLineHeight(args.start, args.end, { unit: 'PIXELS', value: args.line_height })
384
+ }
385
+ if (args.letter_spacing !== undefined) {
386
+ node.setRangeLetterSpacing(args.start, args.end, {
387
+ unit: 'PIXELS',
388
+ value: args.letter_spacing
389
+ })
390
+ }
391
+ if (args.text_case !== undefined) {
392
+ node.setRangeTextCase(args.start, args.end, args.text_case)
393
+ }
394
+ if (args.text_decoration !== undefined) {
395
+ node.setRangeTextDecoration(args.start, args.end, args.text_decoration)
396
+ }
397
+ } catch (error) {
398
+ return toolFailure(error)
399
+ }
400
+ return { id: args.id, range: { start: args.start, end: args.end }, updated }
401
+ }
402
+ })
403
+
319
404
  export const setTextResize = defineTool({
320
405
  name: 'set_text_resize',
321
406
 
@@ -371,9 +456,8 @@ export const setTextProperties = defineTool({
371
456
  }),
372
457
  fonts: (figma, { id }) => textFonts(figma, id),
373
458
  execute: (figma, args) => {
374
- const node = figma.getNodeById(args.id)
375
- if (!node) return nodeNotFound(args.id)
376
- if (node.type !== 'TEXT') return { error: `Node "${args.id}" is not a TEXT node` }
459
+ const node = textNodeFor(figma, args.id)
460
+ if ('error' in node) return node
377
461
  // Refused before anything changes, so a bad address leaves the text as it was.
378
462
  const hyperlink = requestedHyperlink(args.hyperlink)
379
463
  if (hyperlink && 'error' in hyperlink) return hyperlink
@@ -63,6 +63,17 @@ export function scrollBehaviorInput() {
63
63
  )
64
64
  }
65
65
 
66
+ /** Why this edit cannot run, before anything is written. */
67
+ function editRefusal(
68
+ node: FigmaNodeProxy,
69
+ args: { overflow_direction?: string; boolean_operation?: string }
70
+ ): string | null {
71
+ if (args.overflow_direction !== undefined) return scrollRefusal(node)
72
+ if (args.boolean_operation !== undefined && node.type !== 'BOOLEAN_OPERATION')
73
+ return `Only a boolean operation has boolean_operation; ${node.type} "${node.name}" does not.`
74
+ return null
75
+ }
76
+
66
77
  export const updateNode = defineTool({
67
78
  name: 'update_node',
68
79
 
@@ -102,14 +113,20 @@ export const updateNode = defineTool({
102
113
  ),
103
114
  name: v.optional(v.pipe(v.string(), v.description('Layer name'))),
104
115
  overflow_direction: v.optional(overflowDirectionInput()),
105
- scroll_behavior: v.optional(scrollBehaviorInput())
116
+ scroll_behavior: v.optional(scrollBehaviorInput()),
117
+ boolean_operation: v.optional(
118
+ v.pipe(
119
+ v.picklist(['UNION', 'SUBTRACT', 'INTERSECT', 'EXCLUDE']),
120
+ v.description('How a BOOLEAN_OPERATION combines its children')
121
+ )
122
+ )
106
123
  }),
107
124
  execute: (figma, args) => {
108
125
  const node = figma.getNodeById(args.id)
109
126
  if (!node) return nodeNotFound(args.id)
110
127
  assertNodeEditable(figma.graph, args.id)
111
128
  // Refused before anything is written, so the call changes all or nothing.
112
- const refusal = args.overflow_direction === undefined ? null : scrollRefusal(node)
129
+ const refusal = editRefusal(node, args)
113
130
  if (refusal) return { error: refusal }
114
131
  // Written to the layer directly, since the plugin setters need a loaded font; an edit to a
115
132
  // text style's field leaves the style, as the editor's updates do.
@@ -176,6 +193,10 @@ export const updateNode = defineTool({
176
193
  node.scrollBehavior = args.scroll_behavior
177
194
  updated.push('scrollBehavior')
178
195
  }
196
+ if (args.boolean_operation !== undefined) {
197
+ node.booleanOperation = args.boolean_operation
198
+ updated.push('booleanOperation')
199
+ }
179
200
  return { id: args.id, updated }
180
201
  }
181
202
  })
@@ -3,8 +3,16 @@ export { replaceFonts } from './modify/fonts'
3
3
  export { rescale, setMinMax, setOpacity, setRadius, setRotation } from './modify/geometry'
4
4
  export { setConstraints, setLayout, setLayoutChild } from './modify/layout'
5
5
  export { replaceMatchingProperties } from './modify/matching'
6
+ export { resetOverrideFields } from './modify/overrides'
6
7
  export { setFill, setImageFill, setStroke } from './modify/paint'
7
8
  export { setReactions } from './modify/reactions'
8
9
  export { setBlend, setLocked, setStrokeAlign, setVisible } from './modify/state'
9
- export { setFont, setFontRange, setText, setTextProperties, setTextResize } from './modify/text'
10
+ export {
11
+ setFont,
12
+ setFontRange,
13
+ setText,
14
+ setTextProperties,
15
+ setTextRangeStyle,
16
+ setTextResize
17
+ } from './modify/text'
10
18
  export { updateNode } from './modify/update'
@@ -1,5 +1,6 @@
1
1
  import * as v from 'valibot'
2
2
 
3
+ import { diamondFillToCSS, gradientFillToCSS } from '@pairdraw/dom-css/export'
3
4
  import type { ColorProfile, SceneGraph, SceneNode, ShadowEffect } from '@pairdraw/scene-graph'
4
5
  import { colorToDocumentCSS } from '@pairdraw/scene-graph/color'
5
6
  import type { Color } from '@pairdraw/scene-graph/primitives'
@@ -80,11 +81,25 @@ function boundName(graph: SceneGraph, node: SceneNode, field: string): string |
80
81
 
81
82
  /**
82
83
  * A stored colour as the shorthand writes it: `#RRGGBB` in an sRGB document, `color(display-p3 …)`
83
- * in a Display P3 one, where hex would name a different colour. The shorthand carries no alpha, as
84
- * it never has, so the paint's opacity is left to `opacity`.
84
+ * in a Display P3 one, where hex would name a different colour, and `rgba()` or `color(… / a)` when
85
+ * the paint is translucent. What paints is the colour's alpha times the paint's `opacity`, so both
86
+ * are folded into the shorthand; the setters store that product the same way.
85
87
  */
86
- function cssColor(color: Color, profile: ColorProfile): string {
87
- return colorToDocumentCSS({ ...color, a: 1 }, profile)
88
+ function cssColor(color: Color, opacity: number, profile: ColorProfile): string {
89
+ return colorToDocumentCSS({ ...color, a: color.a * opacity }, profile)
90
+ }
91
+
92
+ /** A solid paint's colour and opacity, which the shorthand folds into one colour. */
93
+ interface SolidFill {
94
+ color: Color
95
+ opacity: number
96
+ }
97
+
98
+ /** The first visible solid fill and its index, which a text colour or a background can name. */
99
+ function solidFill(node: SceneNode): { index: number; fill: SolidFill } | null {
100
+ const index = node.fills.findIndex((candidate) => candidate.type === 'SOLID' && candidate.visible)
101
+ const fill = index === -1 ? undefined : node.fills[index]
102
+ return fill?.type === 'SOLID' ? { index, fill } : null
88
103
  }
89
104
 
90
105
  /** A colour in the document's profile, or `var(--token, …)` when a variable paints it. */
@@ -94,23 +109,39 @@ function paintOf(node: SceneNode, graph: SceneGraph, field: string, paint: strin
94
109
  }
95
110
 
96
111
  function background(node: SceneNode, graph: SceneGraph): string | null {
97
- const index = node.fills.findIndex((candidate) => candidate.type === 'SOLID' && candidate.visible)
98
- const solid = index === -1 ? undefined : node.fills[index]
112
+ const solid = solidFill(node)
99
113
  if (solid) {
100
- const paint = cssColor(solid.color, graph.documentColorSpace)
101
- return paintOf(node, graph, `fills/${index}/color`, paint)
114
+ const paint = cssColor(solid.fill.color, solid.fill.opacity, graph.documentColorSpace)
115
+ return paintOf(node, graph, `fills/${solid.index}/color`, paint)
102
116
  }
103
117
  const otherIndex = node.fills.findIndex((candidate) => candidate.visible)
104
118
  const other = otherIndex === -1 ? undefined : node.fills[otherIndex]
105
119
  if (!other) return null
106
- return other.type.startsWith('GRADIENT') ? 'gradient' : 'image'
120
+ switch (other.type) {
121
+ case 'GRADIENT_DIAMOND':
122
+ // CSS has no diamond; the Pairdraw spelling carries the same stops so set_fill can close the
123
+ // round trip instead of losing them behind a word.
124
+ return diamondFillToCSS(other, graph.documentColorSpace) ?? 'gradient'
125
+ case 'GRADIENT_LINEAR':
126
+ case 'GRADIENT_RADIAL':
127
+ case 'GRADIENT_ANGULAR':
128
+ return (
129
+ gradientFillToCSS(other, node.width, node.height, graph.documentColorSpace) ?? 'gradient'
130
+ )
131
+ case 'IMAGE':
132
+ return `image(${other.imageScaleMode ?? 'FILL'})`
133
+ default:
134
+ // A paint CSS has neither a gradient nor an image for keeps the image word, as §3.3's table
135
+ // says, rather than claiming a gradient it would not draw.
136
+ return 'image'
137
+ }
107
138
  }
108
139
 
109
140
  function border(node: SceneNode, graph: SceneGraph): string | null {
110
141
  const index = node.strokes.findIndex((candidate) => candidate.visible)
111
142
  const stroke = index === -1 ? undefined : node.strokes[index]
112
143
  if (!stroke) return null
113
- const paint = cssColor(stroke.color, graph.documentColorSpace)
144
+ const paint = cssColor(stroke.color, stroke.opacity, graph.documentColorSpace)
114
145
  return `${px(stroke.weight)} ${paintOf(node, graph, `strokes/${index}/color`, paint)}`
115
146
  }
116
147
 
@@ -127,7 +158,8 @@ function padding(node: SceneNode): string | null {
127
158
  }
128
159
 
129
160
  function shadowOf(prefix: string, effect: ShadowEffect, profile: ColorProfile): string {
130
- return `${prefix}:${px(effect.offset.x)} ${px(effect.offset.y)} ${px(effect.radius)} ${cssColor(effect.color, profile)}`
161
+ // A shadow's colour carries its whole alpha; the effect has no separate opacity.
162
+ return `${prefix}:${px(effect.offset.x)} ${px(effect.offset.y)} ${px(effect.radius)} ${cssColor(effect.color, 1, profile)}`
131
163
  }
132
164
 
133
165
  function effects(node: SceneNode, profile: ColorProfile): string[] {
@@ -197,8 +229,10 @@ function textDecls(node: SceneNode, graph: SceneGraph): string[] {
197
229
  const out = [
198
230
  `font:${node.fontWeight} ${px(node.fontSize)}/${lineHeightOf(node)} ${node.fontFamily}`
199
231
  ]
232
+ // `color:` takes a colour; a gradient or an image fill is not one, and no setter writes a text
233
+ // paint, so text with such a fill prints no colour line at all.
200
234
  const bg = background(node, graph)
201
- if (bg) out.push(`color:${bg}`)
235
+ if (bg && solidFill(node)) out.push(`color:${bg}`)
202
236
  if (node.textAlignHorizontal !== 'LEFT') {
203
237
  out.push(`text-align:${node.textAlignHorizontal.toLowerCase()}`)
204
238
  }
@@ -122,6 +122,16 @@ export const getPageTree = defineTool({
122
122
  }
123
123
  })
124
124
 
125
+ function withTextRuns(
126
+ figma: FigmaAPI,
127
+ id: string,
128
+ result: Record<string, unknown>
129
+ ): Record<string, unknown> {
130
+ const node = figma.graph.getNode(id)
131
+ if (node?.type !== 'TEXT') return result
132
+ return { ...result, styleRuns: node.styleRuns, textParagraphs: node.textParagraphs }
133
+ }
134
+
125
135
  export const getNode = defineTool({
126
136
  name: 'get_node',
127
137
  description:
@@ -136,17 +146,29 @@ export const getNode = defineTool({
136
146
  v.description('Max depth of children to include (0 = no children). Default: unlimited')
137
147
  )
138
148
  )
149
+ ),
150
+ include_text_runs: v.optional(
151
+ v.pipe(
152
+ v.boolean(),
153
+ v.description(
154
+ 'Include character style runs and paragraph styles, so mixed text can be read'
155
+ )
156
+ )
139
157
  )
140
158
  }),
141
- executeSync: (figma, { id, depth }) => {
159
+ executeSync: (figma, { id, depth, include_text_runs }) => {
142
160
  const node = figma.getNodeById(id)
143
- return node ? nodeToResult(node, depth) : undefined
161
+ if (!node) return undefined
162
+ const result = nodeToResult(node, depth)
163
+ return include_text_runs ? withTextRuns(figma, id, result) : result
144
164
  },
145
- execute: async (figma, { id, depth }) => {
165
+ execute: async (figma, { id, depth, include_text_runs }) => {
146
166
  const node = figma.getNodeById(id)
147
167
  // A layer on a page not yet visited loads that page, as in Figma's dynamic-page mode.
148
168
  const loaded = node ?? (await figma.getNodeByIdAsync(id))
149
- return loaded ? nodeToResult(loaded, depth) : { error: `Node "${id}" not found` }
169
+ if (!loaded) return { error: `Node "${id}" not found` }
170
+ const result = nodeToResult(loaded, depth)
171
+ return include_text_runs ? withTextRuns(figma, id, result) : result
150
172
  }
151
173
  })
152
174
 
@@ -31,6 +31,7 @@ import {
31
31
  createSlot,
32
32
  fetchIconsTool,
33
33
  getBehaviour,
34
+ importCode,
34
35
  importHTML,
35
36
  importMermaid,
36
37
  importSVG,
@@ -57,8 +58,10 @@ import {
57
58
  setEffects,
58
59
  setFont,
59
60
  setFontRange,
61
+ setTextRangeStyle,
60
62
  setImageFill,
61
63
  setLocked,
64
+ resetOverrideFields,
62
65
  setMinMax,
63
66
  replaceMatchingProperties,
64
67
  rescale,
@@ -183,6 +186,7 @@ export const EXTENDED_TOOLS: ToolDef[] = [
183
186
  createComponent,
184
187
  createInstance,
185
188
  detachInstance,
189
+ resetOverrideFields,
186
190
  exposeInstanceSwap,
187
191
  createSlot,
188
192
  getBehaviour,
@@ -193,6 +197,7 @@ export const EXTENDED_TOOLS: ToolDef[] = [
193
197
  createConnectorTool,
194
198
  importSVG,
195
199
  importMermaid,
200
+ importCode,
196
201
  importHTML,
197
202
  // Image AI, run on the services the user set up in the app
198
203
  generateImage,
@@ -209,6 +214,7 @@ export const EXTENDED_TOOLS: ToolDef[] = [
209
214
  setRotation,
210
215
  setMinMax,
211
216
  setFontRange,
217
+ setTextRangeStyle,
212
218
  setTextResize,
213
219
  replaceFonts,
214
220
  setBlend,