@pairdraw/core 0.17.0 → 0.19.0-beta.1

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 (1025) hide show
  1. package/dist/canvas/effects.d.ts +5 -11
  2. package/dist/canvas/effects.d.ts.map +1 -1
  3. package/dist/canvas/effects.js +25 -30
  4. package/dist/canvas/effects.js.map +1 -1
  5. package/dist/canvas/labels/hit-test.d.ts +5 -0
  6. package/dist/canvas/labels/hit-test.d.ts.map +1 -1
  7. package/dist/canvas/labels/hit-test.js +1 -1
  8. package/dist/canvas/labels/hit-test.js.map +1 -1
  9. package/dist/canvas/labels/paragraph-cache.d.ts.map +1 -1
  10. package/dist/canvas/labels/paragraph-cache.js +3 -2
  11. package/dist/canvas/labels/paragraph-cache.js.map +1 -1
  12. package/dist/canvas/labels/selection.js +3 -2
  13. package/dist/canvas/labels/selection.js.map +1 -1
  14. package/dist/canvas/labels/style.d.ts +1 -1
  15. package/dist/canvas/node-edit-overlay.js +2 -2
  16. package/dist/canvas/node-edit-overlay.js.map +1 -1
  17. package/dist/canvas/outline-stroke.d.ts.map +1 -1
  18. package/dist/canvas/outline-stroke.js.map +1 -1
  19. package/dist/canvas/overlays/index.d.ts +2 -2
  20. package/dist/canvas/overlays/index.js +2 -2
  21. package/dist/canvas/overlays/prototype.d.ts +2 -5
  22. package/dist/canvas/overlays/prototype.d.ts.map +1 -1
  23. package/dist/canvas/overlays/prototype.js +3 -19
  24. package/dist/canvas/overlays/prototype.js.map +1 -1
  25. package/dist/canvas/overlays/selection.d.ts +1 -2
  26. package/dist/canvas/overlays/selection.d.ts.map +1 -1
  27. package/dist/canvas/overlays/selection.js +4 -37
  28. package/dist/canvas/overlays/selection.js.map +1 -1
  29. package/dist/canvas/region-hatch.js +3 -2
  30. package/dist/canvas/region-hatch.js.map +1 -1
  31. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  32. package/dist/canvas/renderer/colors.js +36 -18
  33. package/dist/canvas/renderer/colors.js.map +1 -1
  34. package/dist/canvas/renderer/font-waiters.d.ts +9 -0
  35. package/dist/canvas/renderer/font-waiters.d.ts.map +1 -0
  36. package/dist/canvas/renderer/font-waiters.js +26 -0
  37. package/dist/canvas/renderer/font-waiters.js.map +1 -0
  38. package/dist/canvas/renderer/fonts.d.ts +4 -2
  39. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  40. package/dist/canvas/renderer/fonts.js +25 -10
  41. package/dist/canvas/renderer/fonts.js.map +1 -1
  42. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  43. package/dist/canvas/renderer/lifecycle.js +6 -9
  44. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  45. package/dist/canvas/renderer/methods.d.ts +4 -5
  46. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  47. package/dist/canvas/renderer/methods.js +1 -4
  48. package/dist/canvas/renderer/methods.js.map +1 -1
  49. package/dist/canvas/renderer/paints.d.ts.map +1 -1
  50. package/dist/canvas/renderer/paints.js +0 -6
  51. package/dist/canvas/renderer/paints.js.map +1 -1
  52. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  53. package/dist/canvas/renderer/pipeline.js +20 -2
  54. package/dist/canvas/renderer/pipeline.js.map +1 -1
  55. package/dist/canvas/renderer/retained-backing.js +4 -4
  56. package/dist/canvas/renderer/retained-backing.js.map +1 -1
  57. package/dist/canvas/renderer/state.js +1 -1
  58. package/dist/canvas/renderer/state.js.map +1 -1
  59. package/dist/canvas/renderer/tiles/controller.d.ts +2 -0
  60. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  61. package/dist/canvas/renderer/tiles/controller.js +8 -0
  62. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  63. package/dist/canvas/renderer/tiles/surface-pool.js +1 -1
  64. package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
  65. package/dist/canvas/renderer/visual-bounds.d.ts.map +1 -1
  66. package/dist/canvas/renderer/visual-bounds.js +7 -5
  67. package/dist/canvas/renderer/visual-bounds.js.map +1 -1
  68. package/dist/canvas/renderer.d.ts +26 -7
  69. package/dist/canvas/renderer.d.ts.map +1 -1
  70. package/dist/canvas/renderer.js +50 -11
  71. package/dist/canvas/renderer.js.map +1 -1
  72. package/dist/canvas/rulers.d.ts +8 -1
  73. package/dist/canvas/rulers.d.ts.map +1 -1
  74. package/dist/canvas/rulers.js +30 -5
  75. package/dist/canvas/rulers.js.map +1 -1
  76. package/dist/canvas/scene.d.ts +2 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +90 -54
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shadows/shape.js +1 -1
  81. package/dist/canvas/shadows/shape.js.map +1 -1
  82. package/dist/canvas/shadows/silhouette.d.ts.map +1 -1
  83. package/dist/canvas/shadows/silhouette.js +4 -2
  84. package/dist/canvas/shadows/silhouette.js.map +1 -1
  85. package/dist/canvas/shadows.d.ts.map +1 -1
  86. package/dist/canvas/shadows.js +3 -2
  87. package/dist/canvas/shadows.js.map +1 -1
  88. package/dist/canvas/text/derived.d.ts +1 -2
  89. package/dist/canvas/text/derived.d.ts.map +1 -1
  90. package/dist/canvas/text/derived.js +1 -7
  91. package/dist/canvas/text/derived.js.map +1 -1
  92. package/dist/canvas/text/emoji/index.js +1 -1
  93. package/dist/canvas/text/emoji/raster.d.ts.map +1 -1
  94. package/dist/canvas/text/emoji/raster.js +14 -10
  95. package/dist/canvas/text/emoji/raster.js.map +1 -1
  96. package/dist/canvas/text/font-families.d.ts +4 -3
  97. package/dist/canvas/text/font-families.d.ts.map +1 -1
  98. package/dist/canvas/text/font-families.js +13 -9
  99. package/dist/canvas/text/font-families.js.map +1 -1
  100. package/dist/canvas/text/index.d.ts +1 -3
  101. package/dist/canvas/text/index.d.ts.map +1 -1
  102. package/dist/canvas/text/index.js +2 -9
  103. package/dist/canvas/text/index.js.map +1 -1
  104. package/dist/canvas/text/layout/build.d.ts.map +1 -1
  105. package/dist/canvas/text/layout/build.js +25 -9
  106. package/dist/canvas/text/layout/build.js.map +1 -1
  107. package/dist/canvas/text/layout/index.d.ts.map +1 -1
  108. package/dist/canvas/text/layout/index.js +8 -4
  109. package/dist/canvas/text/layout/index.js.map +1 -1
  110. package/dist/canvas/text/layout/lines.js +5 -3
  111. package/dist/canvas/text/layout/lines.js.map +1 -1
  112. package/dist/canvas/text/paragraph/index.d.ts +5 -0
  113. package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
  114. package/dist/canvas/text/paragraph/index.js +18 -9
  115. package/dist/canvas/text/paragraph/index.js.map +1 -1
  116. package/dist/canvas/text/paragraph/inputs.d.ts +1 -1
  117. package/dist/canvas/text/paragraph/inputs.d.ts.map +1 -1
  118. package/dist/canvas/text/paragraph/inputs.js +9 -2
  119. package/dist/canvas/text/paragraph/inputs.js.map +1 -1
  120. package/dist/canvas/text/placed.js +3 -3
  121. package/dist/canvas/text/placed.js.map +1 -1
  122. package/dist/canvas/text/renderer.d.ts +2 -0
  123. package/dist/canvas/text/renderer.d.ts.map +1 -1
  124. package/dist/canvas/text/shape.d.ts +4 -3
  125. package/dist/canvas/text/shape.d.ts.map +1 -1
  126. package/dist/canvas/text/shape.js +9 -22
  127. package/dist/canvas/text/shape.js.map +1 -1
  128. package/dist/constants.d.ts +6 -2
  129. package/dist/constants.d.ts.map +1 -1
  130. package/dist/constants.js +6 -2
  131. package/dist/constants.js.map +1 -1
  132. package/dist/design-jsx/renderer.d.ts.map +1 -1
  133. package/dist/editor/bridges/clipboard.d.ts +1 -0
  134. package/dist/editor/bridges/clipboard.js +1 -0
  135. package/dist/editor/bridges/clipboard.js.map +1 -1
  136. package/dist/editor/bridges/components.d.ts +2 -0
  137. package/dist/editor/bridges/components.d.ts.map +1 -1
  138. package/dist/editor/bridges/components.js +2 -0
  139. package/dist/editor/bridges/components.js.map +1 -1
  140. package/dist/editor/bridges/frames.d.ts +4 -3
  141. package/dist/editor/bridges/frames.d.ts.map +1 -1
  142. package/dist/editor/bridges/frames.js +6 -4
  143. package/dist/editor/bridges/frames.js.map +1 -1
  144. package/dist/editor/bridges/structure.d.ts +1 -0
  145. package/dist/editor/bridges/structure.d.ts.map +1 -1
  146. package/dist/editor/bridges/structure.js +1 -0
  147. package/dist/editor/bridges/structure.js.map +1 -1
  148. package/dist/editor/bridges/undo.d.ts +1 -1
  149. package/dist/editor/clipboard/detach.js +2 -2
  150. package/dist/editor/clipboard/detach.js.map +1 -1
  151. package/dist/editor/clipboard/paste/properties.js +1 -1
  152. package/dist/editor/clipboard/paste/target.js +2 -2
  153. package/dist/editor/clipboard/paste/target.js.map +1 -1
  154. package/dist/editor/clipboard/snapshot.d.ts +3 -0
  155. package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
  156. package/dist/editor/clipboard/snapshot.js +2 -0
  157. package/dist/editor/clipboard/snapshot.js.map +1 -1
  158. package/dist/editor/clipboard/variables.d.ts.map +1 -1
  159. package/dist/editor/clipboard/variables.js +14 -1
  160. package/dist/editor/clipboard/variables.js.map +1 -1
  161. package/dist/editor/clipboard.d.ts +1 -0
  162. package/dist/editor/clipboard.d.ts.map +1 -1
  163. package/dist/editor/clipboard.js +122 -16
  164. package/dist/editor/clipboard.js.map +1 -1
  165. package/dist/editor/component-sync.d.ts +10 -1
  166. package/dist/editor/component-sync.d.ts.map +1 -1
  167. package/dist/editor/component-sync.js +25 -8
  168. package/dist/editor/component-sync.js.map +1 -1
  169. package/dist/editor/components/authoring/text-edit.d.ts.map +1 -1
  170. package/dist/editor/components/authoring/text-edit.js +11 -2
  171. package/dist/editor/components/authoring/text-edit.js.map +1 -1
  172. package/dist/editor/components/authoring/visibility-edit.d.ts.map +1 -1
  173. package/dist/editor/components/authoring/visibility-edit.js +7 -3
  174. package/dist/editor/components/authoring/visibility-edit.js.map +1 -1
  175. package/dist/editor/components/instances.d.ts +2 -0
  176. package/dist/editor/components/instances.d.ts.map +1 -1
  177. package/dist/editor/components/instances.js +37 -7
  178. package/dist/editor/components/instances.js.map +1 -1
  179. package/dist/editor/components/properties.d.ts.map +1 -1
  180. package/dist/editor/components/properties.js +3 -0
  181. package/dist/editor/components/properties.js.map +1 -1
  182. package/dist/editor/components/slots/authoring.js +2 -1
  183. package/dist/editor/components/slots/authoring.js.map +1 -1
  184. package/dist/editor/components.d.ts +2 -0
  185. package/dist/editor/components.d.ts.map +1 -1
  186. package/dist/editor/create.d.ts +18 -4
  187. package/dist/editor/create.d.ts.map +1 -1
  188. package/dist/editor/create.js +43 -6
  189. package/dist/editor/create.js.map +1 -1
  190. package/dist/editor/guides.d.ts.map +1 -1
  191. package/dist/editor/guides.js +20 -13
  192. package/dist/editor/guides.js.map +1 -1
  193. package/dist/editor/history/document-change.d.ts +19 -3
  194. package/dist/editor/history/document-change.d.ts.map +1 -1
  195. package/dist/editor/history/document-change.js +94 -8
  196. package/dist/editor/history/document-change.js.map +1 -1
  197. package/dist/editor/history/edit.d.ts.map +1 -1
  198. package/dist/editor/history/edit.js +56 -12
  199. package/dist/editor/history/edit.js.map +1 -1
  200. package/dist/editor/history/position.js +1 -4
  201. package/dist/editor/history/position.js.map +1 -1
  202. package/dist/editor/history/sources.d.ts +14 -0
  203. package/dist/editor/history/sources.d.ts.map +1 -0
  204. package/dist/editor/history/sources.js +24 -0
  205. package/dist/editor/history/sources.js.map +1 -0
  206. package/dist/editor/index.d.ts +2 -2
  207. package/dist/editor/index.js +1 -1
  208. package/dist/editor/layout-mode.d.ts.map +1 -1
  209. package/dist/editor/layout-mode.js +16 -1
  210. package/dist/editor/layout-mode.js.map +1 -1
  211. package/dist/editor/node-preview.d.ts.map +1 -1
  212. package/dist/editor/node-preview.js +26 -7
  213. package/dist/editor/node-preview.js.map +1 -1
  214. package/dist/editor/nodes.d.ts.map +1 -1
  215. package/dist/editor/nodes.js +33 -10
  216. package/dist/editor/nodes.js.map +1 -1
  217. package/dist/editor/nudge.d.ts.map +1 -1
  218. package/dist/editor/nudge.js +12 -2
  219. package/dist/editor/nudge.js.map +1 -1
  220. package/dist/editor/pages.d.ts +2 -1
  221. package/dist/editor/pages.d.ts.map +1 -1
  222. package/dist/editor/pages.js +94 -15
  223. package/dist/editor/pages.js.map +1 -1
  224. package/dist/editor/play/states.d.ts.map +1 -1
  225. package/dist/editor/play/states.js +0 -5
  226. package/dist/editor/play/states.js.map +1 -1
  227. package/dist/editor/read-only/actions.js +3 -0
  228. package/dist/editor/read-only/actions.js.map +1 -1
  229. package/dist/editor/selection/hit-test.d.ts +2 -1
  230. package/dist/editor/selection/hit-test.d.ts.map +1 -1
  231. package/dist/editor/selection/hit-test.js +29 -4
  232. package/dist/editor/selection/hit-test.js.map +1 -1
  233. package/dist/editor/selection.d.ts +2 -2
  234. package/dist/editor/selection.d.ts.map +1 -1
  235. package/dist/editor/shapes/pen.js +6 -2
  236. package/dist/editor/shapes/pen.js.map +1 -1
  237. package/dist/editor/shapes.d.ts.map +1 -1
  238. package/dist/editor/shapes.js +2 -1
  239. package/dist/editor/shapes.js.map +1 -1
  240. package/dist/editor/structure/auto-layout-wrap.d.ts.map +1 -1
  241. package/dist/editor/structure/auto-layout-wrap.js +12 -0
  242. package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
  243. package/dist/editor/structure/boolean.js +1 -1
  244. package/dist/editor/structure/group/bounds.d.ts +4 -2
  245. package/dist/editor/structure/group/bounds.d.ts.map +1 -1
  246. package/dist/editor/structure/group/bounds.js +17 -4
  247. package/dist/editor/structure/group/bounds.js.map +1 -1
  248. package/dist/editor/structure/rename.d.ts +2 -3
  249. package/dist/editor/structure/rename.d.ts.map +1 -1
  250. package/dist/editor/structure/rename.js +2 -5
  251. package/dist/editor/structure/rename.js.map +1 -1
  252. package/dist/editor/structure/reorder.d.ts.map +1 -1
  253. package/dist/editor/structure/reorder.js +20 -9
  254. package/dist/editor/structure/reorder.js.map +1 -1
  255. package/dist/editor/structure/state.js +1 -1
  256. package/dist/editor/structure.d.ts +1 -0
  257. package/dist/editor/structure.d.ts.map +1 -1
  258. package/dist/editor/structure.js +76 -20
  259. package/dist/editor/structure.js.map +1 -1
  260. package/dist/editor/text/hyperlink.d.ts.map +1 -1
  261. package/dist/editor/text/hyperlink.js +1 -1
  262. package/dist/editor/text/hyperlink.js.map +1 -1
  263. package/dist/editor/text/name.d.ts +13 -5
  264. package/dist/editor/text/name.d.ts.map +1 -1
  265. package/dist/editor/text/name.js +47 -17
  266. package/dist/editor/text/name.js.map +1 -1
  267. package/dist/editor/text/pending-layout.d.ts +2 -1
  268. package/dist/editor/text/pending-layout.d.ts.map +1 -1
  269. package/dist/editor/text/pending-layout.js +33 -6
  270. package/dist/editor/text/pending-layout.js.map +1 -1
  271. package/dist/editor/text/selection-style.d.ts +1 -0
  272. package/dist/editor/text/selection-style.d.ts.map +1 -1
  273. package/dist/editor/text/selection-style.js +16 -4
  274. package/dist/editor/text/selection-style.js.map +1 -1
  275. package/dist/editor/text.d.ts +5 -0
  276. package/dist/editor/text.d.ts.map +1 -1
  277. package/dist/editor/text.js +70 -3
  278. package/dist/editor/text.js.map +1 -1
  279. package/dist/editor/types.d.ts +18 -1
  280. package/dist/editor/types.d.ts.map +1 -1
  281. package/dist/editor/undo.d.ts.map +1 -1
  282. package/dist/editor/undo.js +14 -2
  283. package/dist/editor/undo.js.map +1 -1
  284. package/dist/editor/variable-bindings.d.ts.map +1 -1
  285. package/dist/editor/variable-bindings.js +21 -2
  286. package/dist/editor/variable-bindings.js.map +1 -1
  287. package/dist/editor/variables.d.ts +1 -1
  288. package/dist/editor/variables.d.ts.map +1 -1
  289. package/dist/editor/variables.js +7 -8
  290. package/dist/editor/variables.js.map +1 -1
  291. package/dist/editor/viewport.d.ts +11 -2
  292. package/dist/editor/viewport.d.ts.map +1 -1
  293. package/dist/editor/viewport.js +61 -21
  294. package/dist/editor/viewport.js.map +1 -1
  295. package/dist/editor/views/actions.d.ts.map +1 -1
  296. package/dist/editor/views/actions.js +13 -5
  297. package/dist/editor/views/actions.js.map +1 -1
  298. package/dist/editor/views/present.d.ts +6 -4
  299. package/dist/editor/views/present.d.ts.map +1 -1
  300. package/dist/editor/views/present.js +12 -10
  301. package/dist/editor/views/present.js.map +1 -1
  302. package/dist/editor/views/types.d.ts +11 -5
  303. package/dist/editor/views/types.d.ts.map +1 -1
  304. package/dist/figma-api/accessor-utils.d.ts.map +1 -1
  305. package/dist/figma-api/accessor-utils.js +4 -1
  306. package/dist/figma-api/accessor-utils.js.map +1 -1
  307. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  308. package/dist/figma-api/accessors/basic.js +41 -21
  309. package/dist/figma-api/accessors/basic.js.map +1 -1
  310. package/dist/figma-api/accessors/layout.d.ts.map +1 -1
  311. package/dist/figma-api/accessors/layout.js +37 -7
  312. package/dist/figma-api/accessors/layout.js.map +1 -1
  313. package/dist/figma-api/accessors/reactions.d.ts +11 -0
  314. package/dist/figma-api/accessors/reactions.d.ts.map +1 -0
  315. package/dist/figma-api/accessors/reactions.js +30 -0
  316. package/dist/figma-api/accessors/reactions.js.map +1 -0
  317. package/dist/figma-api/accessors/strokes.d.ts.map +1 -1
  318. package/dist/figma-api/accessors/strokes.js +12 -4
  319. package/dist/figma-api/accessors/strokes.js.map +1 -1
  320. package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
  321. package/dist/figma-api/accessors/text/index.js +3 -1
  322. package/dist/figma-api/accessors/text/index.js.map +1 -1
  323. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  324. package/dist/figma-api/accessors/vector.js +1 -1
  325. package/dist/figma-api/accessors/vector.js.map +1 -1
  326. package/dist/figma-api/accessors/visual.d.ts +6 -5
  327. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  328. package/dist/figma-api/accessors/visual.js +20 -17
  329. package/dist/figma-api/accessors/visual.js.map +1 -1
  330. package/dist/figma-api/components.d.ts.map +1 -1
  331. package/dist/figma-api/components.js +2 -1
  332. package/dist/figma-api/components.js.map +1 -1
  333. package/dist/figma-api/finite.d.ts +27 -0
  334. package/dist/figma-api/finite.d.ts.map +1 -0
  335. package/dist/figma-api/finite.js +69 -0
  336. package/dist/figma-api/finite.js.map +1 -0
  337. package/dist/figma-api/fonts/list.d.ts +13 -0
  338. package/dist/figma-api/fonts/list.d.ts.map +1 -0
  339. package/dist/figma-api/fonts/list.js +25 -0
  340. package/dist/figma-api/fonts/list.js.map +1 -0
  341. package/dist/figma-api/index.d.ts +63 -10
  342. package/dist/figma-api/index.d.ts.map +1 -1
  343. package/dist/figma-api/index.js +104 -17
  344. package/dist/figma-api/index.js.map +1 -1
  345. package/dist/figma-api/overrides.d.ts +6 -1
  346. package/dist/figma-api/overrides.d.ts.map +1 -1
  347. package/dist/figma-api/overrides.js +2 -2
  348. package/dist/figma-api/overrides.js.map +1 -1
  349. package/dist/figma-api/pending-layout.d.ts +12 -2
  350. package/dist/figma-api/pending-layout.d.ts.map +1 -1
  351. package/dist/figma-api/pending-layout.js +41 -1
  352. package/dist/figma-api/pending-layout.js.map +1 -1
  353. package/dist/figma-api/pending-sync.d.ts +19 -0
  354. package/dist/figma-api/pending-sync.d.ts.map +1 -0
  355. package/dist/figma-api/pending-sync.js +52 -0
  356. package/dist/figma-api/pending-sync.js.map +1 -0
  357. package/dist/figma-api/proxy.d.ts +15 -2
  358. package/dist/figma-api/proxy.d.ts.map +1 -1
  359. package/dist/figma-api/proxy.js +23 -3
  360. package/dist/figma-api/proxy.js.map +1 -1
  361. package/dist/figma-api/reactions.d.ts +104 -0
  362. package/dist/figma-api/reactions.d.ts.map +1 -0
  363. package/dist/figma-api/reactions.js +157 -0
  364. package/dist/figma-api/reactions.js.map +1 -0
  365. package/dist/figma-api/render-bounds.d.ts.map +1 -1
  366. package/dist/figma-api/render-bounds.js +4 -4
  367. package/dist/figma-api/render-bounds.js.map +1 -1
  368. package/dist/figma-api/serialization.js +12 -2
  369. package/dist/figma-api/serialization.js.map +1 -1
  370. package/dist/figma-api/slots.d.ts +7 -1
  371. package/dist/figma-api/slots.d.ts.map +1 -1
  372. package/dist/figma-api/slots.js +12 -4
  373. package/dist/figma-api/slots.js.map +1 -1
  374. package/dist/figma-api/strokes.d.ts +5 -2
  375. package/dist/figma-api/strokes.d.ts.map +1 -1
  376. package/dist/figma-api/strokes.js +12 -19
  377. package/dist/figma-api/strokes.js.map +1 -1
  378. package/dist/figma-api/text/bindings.js +1 -1
  379. package/dist/figma-api/text/index.d.ts +2 -3
  380. package/dist/figma-api/text/index.d.ts.map +1 -1
  381. package/dist/figma-api/text/index.js +2 -12
  382. package/dist/figma-api/text/index.js.map +1 -1
  383. package/dist/figma-api/variables/bindings.js +1 -1
  384. package/dist/figma-api/variables/variable.d.ts.map +1 -1
  385. package/dist/figma-api/variables/variable.js +2 -2
  386. package/dist/figma-api/variables/variable.js.map +1 -1
  387. package/dist/geometry/connectors.js +2 -14
  388. package/dist/geometry/connectors.js.map +1 -1
  389. package/dist/geometry/figma.d.ts +6 -1
  390. package/dist/geometry/figma.d.ts.map +1 -1
  391. package/dist/geometry/figma.js +8 -1
  392. package/dist/geometry/figma.js.map +1 -1
  393. package/dist/geometry/index.d.ts +3 -3
  394. package/dist/geometry/index.js +2 -2
  395. package/dist/geometry/scene.d.ts +3 -1
  396. package/dist/geometry/scene.d.ts.map +1 -1
  397. package/dist/geometry/scene.js +16 -1
  398. package/dist/geometry/scene.js.map +1 -1
  399. package/dist/geometry/types.d.ts +7 -1
  400. package/dist/geometry/types.d.ts.map +1 -1
  401. package/dist/icons/api.d.ts +3 -2
  402. package/dist/icons/api.d.ts.map +1 -1
  403. package/dist/icons/api.js +12 -12
  404. package/dist/icons/api.js.map +1 -1
  405. package/dist/icons/provider.d.ts +4 -3
  406. package/dist/icons/provider.d.ts.map +1 -1
  407. package/dist/icons/provider.js +6 -13
  408. package/dist/icons/provider.js.map +1 -1
  409. package/dist/icons/schema.d.ts +33 -1
  410. package/dist/icons/schema.d.ts.map +1 -1
  411. package/dist/icons/schema.js +30 -1
  412. package/dist/icons/schema.js.map +1 -1
  413. package/dist/icons/svg/presentation.d.ts +8 -1
  414. package/dist/icons/svg/presentation.d.ts.map +1 -1
  415. package/dist/icons/svg/presentation.js +21 -3
  416. package/dist/icons/svg/presentation.js.map +1 -1
  417. package/dist/icons/svg/text.js +1 -1
  418. package/dist/icons/svg/text.js.map +1 -1
  419. package/dist/icons/svg.d.ts +8 -3
  420. package/dist/icons/svg.d.ts.map +1 -1
  421. package/dist/icons/svg.js +15 -13
  422. package/dist/icons/svg.js.map +1 -1
  423. package/dist/icons/types.d.ts +1 -19
  424. package/dist/icons/types.d.ts.map +1 -1
  425. package/dist/index.d.ts +2 -2
  426. package/dist/index.js +1 -1
  427. package/dist/io/formats/design-tokens/css/read.js +1 -1
  428. package/dist/io/formats/design-tokens/decode.js +1 -1
  429. package/dist/io/formats/design-tokens/plan/index.js +4 -2
  430. package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
  431. package/dist/io/formats/design-tokens/plan/styles.d.ts +9 -1
  432. package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
  433. package/dist/io/formats/design-tokens/plan/styles.js +23 -3
  434. package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
  435. package/dist/io/formats/design-tokens/styles.d.ts +9 -1
  436. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  437. package/dist/io/formats/design-tokens/styles.js +41 -4
  438. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  439. package/dist/io/formats/design-tokens/types.d.ts +5 -0
  440. package/dist/io/formats/design-tokens/types.d.ts.map +1 -1
  441. package/dist/io/formats/design-tokens/types.js +1 -0
  442. package/dist/io/formats/design-tokens/types.js.map +1 -1
  443. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  444. package/dist/io/formats/drawio/export.js +10 -0
  445. package/dist/io/formats/drawio/export.js.map +1 -1
  446. package/dist/io/formats/drawio/index.d.ts.map +1 -1
  447. package/dist/io/formats/drawio/index.js +32 -1
  448. package/dist/io/formats/drawio/index.js.map +1 -1
  449. package/dist/io/formats/drawio/shapes.d.ts +10 -5
  450. package/dist/io/formats/drawio/shapes.d.ts.map +1 -1
  451. package/dist/io/formats/drawio/shapes.js +10 -6
  452. package/dist/io/formats/drawio/shapes.js.map +1 -1
  453. package/dist/io/formats/drawio/warnings.d.ts +11 -0
  454. package/dist/io/formats/drawio/warnings.d.ts.map +1 -0
  455. package/dist/io/formats/drawio/warnings.js +23 -0
  456. package/dist/io/formats/drawio/warnings.js.map +1 -0
  457. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  458. package/dist/io/formats/fig/export/setup.js +8 -4
  459. package/dist/io/formats/fig/export/setup.js.map +1 -1
  460. package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
  461. package/dist/io/formats/fig/export/variables.js +2 -2
  462. package/dist/io/formats/fig/export/variables.js.map +1 -1
  463. package/dist/io/formats/fig/index.d.ts +2 -2
  464. package/dist/io/formats/fig/index.js +2 -2
  465. package/dist/io/formats/fig/read.d.ts +9 -2
  466. package/dist/io/formats/fig/read.d.ts.map +1 -1
  467. package/dist/io/formats/fig/read.js +44 -20
  468. package/dist/io/formats/fig/read.js.map +1 -1
  469. package/dist/io/formats/html/index.d.ts.map +1 -1
  470. package/dist/io/formats/html/index.js +2 -6
  471. package/dist/io/formats/html/index.js.map +1 -1
  472. package/dist/io/formats/pdf/dom.d.ts +10 -1
  473. package/dist/io/formats/pdf/dom.d.ts.map +1 -1
  474. package/dist/io/formats/pdf/dom.js +96 -2
  475. package/dist/io/formats/pdf/dom.js.map +1 -1
  476. package/dist/io/formats/pdf/export.js +3 -2
  477. package/dist/io/formats/pdf/export.js.map +1 -1
  478. package/dist/io/formats/pdf/prepare.js +1 -1
  479. package/dist/io/formats/pen/fonts.d.ts +14 -0
  480. package/dist/io/formats/pen/fonts.d.ts.map +1 -0
  481. package/dist/io/formats/pen/fonts.js +39 -0
  482. package/dist/io/formats/pen/fonts.js.map +1 -0
  483. package/dist/io/formats/pen/index.d.ts.map +1 -1
  484. package/dist/io/formats/pen/index.js +25 -6
  485. package/dist/io/formats/pen/index.js.map +1 -1
  486. package/dist/io/formats/raster/headless.d.ts +3 -3
  487. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  488. package/dist/io/formats/raster/headless.js +25 -14
  489. package/dist/io/formats/raster/headless.js.map +1 -1
  490. package/dist/io/formats/raster/index.d.ts +2 -2
  491. package/dist/io/formats/raster/index.js +2 -2
  492. package/dist/io/formats/raster/render.d.ts +8 -2
  493. package/dist/io/formats/raster/render.d.ts.map +1 -1
  494. package/dist/io/formats/raster/render.js +42 -8
  495. package/dist/io/formats/raster/render.js.map +1 -1
  496. package/dist/io/formats/svg/export.d.ts.map +1 -1
  497. package/dist/io/formats/svg/export.js +28 -24
  498. package/dist/io/formats/svg/export.js.map +1 -1
  499. package/dist/io/formats/svg/paths.d.ts +8 -2
  500. package/dist/io/formats/svg/paths.d.ts.map +1 -1
  501. package/dist/io/formats/svg/paths.js +11 -3
  502. package/dist/io/formats/svg/paths.js.map +1 -1
  503. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  504. package/dist/io/formats/svg/strokes.js +2 -5
  505. package/dist/io/formats/svg/strokes.js.map +1 -1
  506. package/dist/io/formats/svg/text/export.d.ts.map +1 -1
  507. package/dist/io/formats/svg/text/export.js +19 -1
  508. package/dist/io/formats/svg/text/export.js.map +1 -1
  509. package/dist/io/formats/svg/text/import.d.ts.map +1 -1
  510. package/dist/io/formats/svg/text/import.js +2 -1
  511. package/dist/io/formats/svg/text/import.js.map +1 -1
  512. package/dist/io/formats.d.ts.map +1 -1
  513. package/dist/io/formats.js +3 -1
  514. package/dist/io/formats.js.map +1 -1
  515. package/dist/io/registry.d.ts +2 -0
  516. package/dist/io/registry.d.ts.map +1 -1
  517. package/dist/io/registry.js +5 -0
  518. package/dist/io/registry.js.map +1 -1
  519. package/dist/io/subgraph.d.ts.map +1 -1
  520. package/dist/io/subgraph.js +5 -2
  521. package/dist/io/subgraph.js.map +1 -1
  522. package/dist/io/types.d.ts +2 -0
  523. package/dist/io/types.d.ts.map +1 -1
  524. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  525. package/dist/kiwi/fig/population/client.js +63 -45
  526. package/dist/kiwi/fig/population/client.js.map +1 -1
  527. package/dist/kiwi/fig/population/delta.d.ts +34 -3
  528. package/dist/kiwi/fig/population/delta.d.ts.map +1 -1
  529. package/dist/kiwi/fig/population/delta.js +99 -16
  530. package/dist/kiwi/fig/population/delta.js.map +1 -1
  531. package/dist/kiwi/fig/population/edits.d.ts +51 -0
  532. package/dist/kiwi/fig/population/edits.d.ts.map +1 -0
  533. package/dist/kiwi/fig/population/edits.js +169 -0
  534. package/dist/kiwi/fig/population/edits.js.map +1 -0
  535. package/dist/kiwi/fig/session/archive/access.d.ts +3 -0
  536. package/dist/kiwi/fig/session/archive/access.d.ts.map +1 -1
  537. package/dist/kiwi/fig/session/archive/access.js +8 -1
  538. package/dist/kiwi/fig/session/archive/access.js.map +1 -1
  539. package/dist/kiwi/fig/session/archive/changes.d.ts +2 -1
  540. package/dist/kiwi/fig/session/archive/changes.d.ts.map +1 -1
  541. package/dist/kiwi/fig/session/archive/changes.js +12 -5
  542. package/dist/kiwi/fig/session/archive/changes.js.map +1 -1
  543. package/dist/kiwi/fig/session/document-state.d.ts +7 -1
  544. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  545. package/dist/kiwi/fig/session/document-state.js +16 -2
  546. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  547. package/dist/kiwi/fig/session/protocol.d.ts +31 -3
  548. package/dist/kiwi/fig/session/protocol.d.ts.map +1 -1
  549. package/dist/kiwi/fig/session/worker.js +33 -8
  550. package/dist/kiwi/fig/session/worker.js.map +1 -1
  551. package/dist/layout/apply.d.ts +6 -1
  552. package/dist/layout/apply.d.ts.map +1 -1
  553. package/dist/layout/apply.js +39 -14
  554. package/dist/layout/apply.js.map +1 -1
  555. package/dist/layout/arrange/boxes.d.ts.map +1 -1
  556. package/dist/layout/arrange/boxes.js +31 -0
  557. package/dist/layout/arrange/boxes.js.map +1 -1
  558. package/dist/layout/flow-edges.d.ts +26 -0
  559. package/dist/layout/flow-edges.d.ts.map +1 -0
  560. package/dist/layout/flow-edges.js +105 -0
  561. package/dist/layout/flow-edges.js.map +1 -0
  562. package/dist/layout/grid.d.ts.map +1 -1
  563. package/dist/layout/grid.js +9 -5
  564. package/dist/layout/grid.js.map +1 -1
  565. package/dist/layout/text-auto-resize.d.ts.map +1 -1
  566. package/dist/layout/text-auto-resize.js +9 -4
  567. package/dist/layout/text-auto-resize.js.map +1 -1
  568. package/dist/layout/text-measurement.d.ts +15 -1
  569. package/dist/layout/text-measurement.d.ts.map +1 -1
  570. package/dist/layout/text-measurement.js +40 -4
  571. package/dist/layout/text-measurement.js.map +1 -1
  572. package/dist/layout/variables.d.ts +1 -1
  573. package/dist/layout.d.ts.map +1 -1
  574. package/dist/layout.js +35 -35
  575. package/dist/layout.js.map +1 -1
  576. package/dist/library/asset-keys.d.ts +3 -2
  577. package/dist/library/asset-keys.d.ts.map +1 -1
  578. package/dist/library/asset-keys.js +4 -3
  579. package/dist/library/asset-keys.js.map +1 -1
  580. package/dist/library/copied-references.d.ts +8 -3
  581. package/dist/library/copied-references.d.ts.map +1 -1
  582. package/dist/library/copied-references.js +15 -5
  583. package/dist/library/copied-references.js.map +1 -1
  584. package/dist/library/materialize.js +1 -1
  585. package/dist/library/materialize.js.map +1 -1
  586. package/dist/library/schema.js.map +1 -1
  587. package/dist/library/snapshot.d.ts.map +1 -1
  588. package/dist/library/snapshot.js +11 -2
  589. package/dist/library/snapshot.js.map +1 -1
  590. package/dist/lint/linter.d.ts.map +1 -1
  591. package/dist/lint/linter.js +11 -2
  592. package/dist/lint/linter.js.map +1 -1
  593. package/dist/pairdraw-api/variables.d.ts.map +1 -1
  594. package/dist/pairdraw-api/variables.js +0 -2
  595. package/dist/pairdraw-api/variables.js.map +1 -1
  596. package/dist/profiler/hud-controller.d.ts +4 -3
  597. package/dist/profiler/hud-controller.d.ts.map +1 -1
  598. package/dist/profiler/hud-controller.js +7 -5
  599. package/dist/profiler/hud-controller.js.map +1 -1
  600. package/dist/profiler/hud-renderer.d.ts +5 -2
  601. package/dist/profiler/hud-renderer.d.ts.map +1 -1
  602. package/dist/profiler/hud-renderer.js +8 -5
  603. package/dist/profiler/hud-renderer.js.map +1 -1
  604. package/dist/profiler/render-profiler.d.ts +3 -2
  605. package/dist/profiler/render-profiler.d.ts.map +1 -1
  606. package/dist/profiler/render-profiler.js +3 -2
  607. package/dist/profiler/render-profiler.js.map +1 -1
  608. package/dist/rpc/variables-command.d.ts.map +1 -1
  609. package/dist/rpc/variables-command.js +4 -2
  610. package/dist/rpc/variables-command.js.map +1 -1
  611. package/dist/text/character-style.d.ts +11 -1
  612. package/dist/text/character-style.d.ts.map +1 -1
  613. package/dist/text/character-style.js +27 -5
  614. package/dist/text/character-style.js.map +1 -1
  615. package/dist/text/coverage.d.ts.map +1 -1
  616. package/dist/text/coverage.js +16 -14
  617. package/dist/text/coverage.js.map +1 -1
  618. package/dist/text/editor.d.ts.map +1 -1
  619. package/dist/text/editor.js +3 -8
  620. package/dist/text/editor.js.map +1 -1
  621. package/dist/text/fallbacks.d.ts +26 -3
  622. package/dist/text/fallbacks.d.ts.map +1 -1
  623. package/dist/text/fallbacks.js +135 -18
  624. package/dist/text/fallbacks.js.map +1 -1
  625. package/dist/text/font/catalog.d.ts +4 -0
  626. package/dist/text/font/catalog.d.ts.map +1 -1
  627. package/dist/text/font/catalog.js +8 -0
  628. package/dist/text/font/catalog.js.map +1 -1
  629. package/dist/text/font/collection.d.ts +13 -0
  630. package/dist/text/font/collection.d.ts.map +1 -0
  631. package/dist/text/font/collection.js +51 -0
  632. package/dist/text/font/collection.js.map +1 -0
  633. package/dist/text/font/faces.d.ts +2 -1
  634. package/dist/text/font/faces.d.ts.map +1 -1
  635. package/dist/text/font/faces.js +9 -5
  636. package/dist/text/font/faces.js.map +1 -1
  637. package/dist/text/font/glyphs.d.ts +14 -3
  638. package/dist/text/font/glyphs.d.ts.map +1 -1
  639. package/dist/text/font/glyphs.js +22 -5
  640. package/dist/text/font/glyphs.js.map +1 -1
  641. package/dist/text/font/local.js +2 -2
  642. package/dist/text/font/local.js.map +1 -1
  643. package/dist/text/font/manager.d.ts +50 -6
  644. package/dist/text/font/manager.d.ts.map +1 -1
  645. package/dist/text/font/manager.js +178 -32
  646. package/dist/text/font/manager.js.map +1 -1
  647. package/dist/text/font/style.d.ts +7 -2
  648. package/dist/text/font/style.d.ts.map +1 -1
  649. package/dist/text/font/style.js +31 -3
  650. package/dist/text/font/style.js.map +1 -1
  651. package/dist/text/index.d.ts +5 -4
  652. package/dist/text/index.js +5 -4
  653. package/dist/text/outlines.d.ts.map +1 -1
  654. package/dist/text/outlines.js +71 -71
  655. package/dist/text/outlines.js.map +1 -1
  656. package/dist/text/path/caret.d.ts +2 -4
  657. package/dist/text/path/caret.d.ts.map +1 -1
  658. package/dist/text/path/caret.js.map +1 -1
  659. package/dist/text/prepare.d.ts +5 -1
  660. package/dist/text/prepare.d.ts.map +1 -1
  661. package/dist/text/prepare.js +26 -3
  662. package/dist/text/prepare.js.map +1 -1
  663. package/dist/text/style-runs.d.ts +14 -2
  664. package/dist/text/style-runs.d.ts.map +1 -1
  665. package/dist/text/style-runs.js +22 -14
  666. package/dist/text/style-runs.js.map +1 -1
  667. package/dist/text/web-font/assets.d.ts.map +1 -1
  668. package/dist/text/web-font/assets.js +13 -21
  669. package/dist/text/web-font/assets.js.map +1 -1
  670. package/dist/text/web-font/resolver.d.ts.map +1 -1
  671. package/dist/text/web-font/resolver.js +4 -1
  672. package/dist/text/web-font/resolver.js.map +1 -1
  673. package/dist/tools/analyze/overlaps/helpers.d.ts.map +1 -1
  674. package/dist/tools/analyze/overlaps/helpers.js +9 -1
  675. package/dist/tools/analyze/overlaps/helpers.js.map +1 -1
  676. package/dist/tools/analyze/overlaps/index.d.ts.map +1 -1
  677. package/dist/tools/analyze/overlaps/index.js +27 -5
  678. package/dist/tools/analyze/overlaps/index.js.map +1 -1
  679. package/dist/tools/codegen/component-map.js +3 -3
  680. package/dist/tools/codegen/component-map.js.map +1 -1
  681. package/dist/tools/create/basic.d.ts.map +1 -1
  682. package/dist/tools/create/basic.js +5 -4
  683. package/dist/tools/create/basic.js.map +1 -1
  684. package/dist/tools/create/components.d.ts +2 -1
  685. package/dist/tools/create/components.d.ts.map +1 -1
  686. package/dist/tools/create/components.js +27 -1
  687. package/dist/tools/create/components.js.map +1 -1
  688. package/dist/tools/create/html.d.ts.map +1 -1
  689. package/dist/tools/create/html.js +4 -2
  690. package/dist/tools/create/html.js.map +1 -1
  691. package/dist/tools/create/icons.d.ts.map +1 -1
  692. package/dist/tools/create/icons.js +14 -6
  693. package/dist/tools/create/icons.js.map +1 -1
  694. package/dist/tools/create/mermaid.d.ts.map +1 -1
  695. package/dist/tools/create/mermaid.js +2 -0
  696. package/dist/tools/create/mermaid.js.map +1 -1
  697. package/dist/tools/create/render.d.ts.map +1 -1
  698. package/dist/tools/create/render.js +2 -0
  699. package/dist/tools/create/render.js.map +1 -1
  700. package/dist/tools/create/script.js +3 -1
  701. package/dist/tools/create/script.js.map +1 -1
  702. package/dist/tools/create/svg.d.ts.map +1 -1
  703. package/dist/tools/create/svg.js +4 -1
  704. package/dist/tools/create/svg.js.map +1 -1
  705. package/dist/tools/create/vector.d.ts.map +1 -1
  706. package/dist/tools/create/vector.js +13 -10
  707. package/dist/tools/create/vector.js.map +1 -1
  708. package/dist/tools/create.d.ts +2 -2
  709. package/dist/tools/create.js +2 -2
  710. package/dist/tools/image-ai/apply.js +1 -1
  711. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  712. package/dist/tools/image-ai/generate.js +3 -0
  713. package/dist/tools/image-ai/generate.js.map +1 -1
  714. package/dist/tools/modify/effects.d.ts.map +1 -1
  715. package/dist/tools/modify/effects.js +5 -3
  716. package/dist/tools/modify/effects.js.map +1 -1
  717. package/dist/tools/modify/matching.d.ts.map +1 -1
  718. package/dist/tools/modify/matching.js +9 -6
  719. package/dist/tools/modify/matching.js.map +1 -1
  720. package/dist/tools/modify/paint.d.ts.map +1 -1
  721. package/dist/tools/modify/paint.js +7 -5
  722. package/dist/tools/modify/paint.js.map +1 -1
  723. package/dist/tools/modify/reactions.d.ts +6 -0
  724. package/dist/tools/modify/reactions.d.ts.map +1 -0
  725. package/dist/tools/modify/reactions.js +35 -0
  726. package/dist/tools/modify/reactions.js.map +1 -0
  727. package/dist/tools/modify/text.d.ts.map +1 -1
  728. package/dist/tools/modify/text.js +28 -8
  729. package/dist/tools/modify/text.js.map +1 -1
  730. package/dist/tools/modify.d.ts +2 -1
  731. package/dist/tools/modify.js +2 -1
  732. package/dist/tools/read/components.js +20 -22
  733. package/dist/tools/read/components.js.map +1 -1
  734. package/dist/tools/read/fonts.js +1 -1
  735. package/dist/tools/read/fonts.js.map +1 -1
  736. package/dist/tools/read/libraries.d.ts.map +1 -1
  737. package/dist/tools/read/libraries.js +18 -4
  738. package/dist/tools/read/libraries.js.map +1 -1
  739. package/dist/tools/read/nodes.d.ts.map +1 -1
  740. package/dist/tools/read/nodes.js +38 -16
  741. package/dist/tools/read/nodes.js.map +1 -1
  742. package/dist/tools/read/pages.d.ts.map +1 -1
  743. package/dist/tools/read/pages.js +4 -3
  744. package/dist/tools/read/pages.js.map +1 -1
  745. package/dist/tools/read/query.js +1 -0
  746. package/dist/tools/read/query.js.map +1 -1
  747. package/dist/tools/read/reactions.d.ts +6 -0
  748. package/dist/tools/read/reactions.d.ts.map +1 -0
  749. package/dist/tools/read/reactions.js +24 -0
  750. package/dist/tools/read/reactions.js.map +1 -0
  751. package/dist/tools/read/space.js +1 -1
  752. package/dist/tools/read.d.ts +2 -1
  753. package/dist/tools/read.js +2 -1
  754. package/dist/tools/registry/extended.d.ts.map +1 -1
  755. package/dist/tools/registry/extended.js +6 -1
  756. package/dist/tools/registry/extended.js.map +1 -1
  757. package/dist/tools/schema.d.ts +30 -5
  758. package/dist/tools/schema.d.ts.map +1 -1
  759. package/dist/tools/schema.js +125 -7
  760. package/dist/tools/schema.js.map +1 -1
  761. package/dist/tools/stock-photo/apply.js +8 -9
  762. package/dist/tools/stock-photo/apply.js.map +1 -1
  763. package/dist/tools/structure/batch.d.ts.map +1 -1
  764. package/dist/tools/structure/batch.js +86 -90
  765. package/dist/tools/structure/batch.js.map +1 -1
  766. package/dist/tools/variables/values.d.ts.map +1 -1
  767. package/dist/tools/variables/values.js +4 -2
  768. package/dist/tools/variables/values.js.map +1 -1
  769. package/dist/tools/vector/export.d.ts.map +1 -1
  770. package/dist/tools/vector/export.js +5 -2
  771. package/dist/tools/vector/export.js.map +1 -1
  772. package/dist/vector/fill-geometry.d.ts +4 -1
  773. package/dist/vector/fill-geometry.d.ts.map +1 -1
  774. package/dist/vector/fill-geometry.js +8 -5
  775. package/dist/vector/fill-geometry.js.map +1 -1
  776. package/dist/vector/index.js +1 -1
  777. package/dist/vector/index.js.map +1 -1
  778. package/dist/vector/path-helpers.d.ts +1 -1
  779. package/dist/vector/path-helpers.d.ts.map +1 -1
  780. package/dist/vector/path-helpers.js +24 -7
  781. package/dist/vector/path-helpers.js.map +1 -1
  782. package/dist/vector/placement.js +1 -1
  783. package/dist/vector/placement.js.map +1 -1
  784. package/dist/vector/vectorize/preprocess.js +1 -1
  785. package/dist/vector/vectorize/preprocess.js.map +1 -1
  786. package/package.json +10 -10
  787. package/src/canvas/effects.ts +29 -33
  788. package/src/canvas/labels/hit-test.ts +6 -2
  789. package/src/canvas/labels/paragraph-cache.ts +2 -1
  790. package/src/canvas/labels/selection.ts +3 -3
  791. package/src/canvas/node-edit-overlay.ts +3 -2
  792. package/src/canvas/outline-stroke.ts +2 -6
  793. package/src/canvas/overlays/index.ts +0 -1
  794. package/src/canvas/overlays/prototype.ts +5 -27
  795. package/src/canvas/overlays/selection.ts +4 -52
  796. package/src/canvas/region-hatch.ts +7 -2
  797. package/src/canvas/renderer/colors.ts +41 -26
  798. package/src/canvas/renderer/font-waiters.ts +25 -0
  799. package/src/canvas/renderer/fonts.ts +42 -18
  800. package/src/canvas/renderer/lifecycle.ts +8 -10
  801. package/src/canvas/renderer/methods.ts +9 -13
  802. package/src/canvas/renderer/paints.ts +0 -10
  803. package/src/canvas/renderer/pipeline.ts +29 -3
  804. package/src/canvas/renderer/retained-backing.ts +4 -4
  805. package/src/canvas/renderer/state.ts +1 -1
  806. package/src/canvas/renderer/tiles/controller.ts +8 -0
  807. package/src/canvas/renderer/tiles/surface-pool.ts +1 -1
  808. package/src/canvas/renderer/visual-bounds.ts +7 -6
  809. package/src/canvas/renderer.ts +43 -11
  810. package/src/canvas/rulers.ts +55 -26
  811. package/src/canvas/scene.ts +127 -77
  812. package/src/canvas/shadows/shape.ts +1 -1
  813. package/src/canvas/shadows/silhouette.ts +4 -2
  814. package/src/canvas/shadows.ts +4 -2
  815. package/src/canvas/text/derived.ts +0 -9
  816. package/src/canvas/text/emoji/raster.ts +14 -10
  817. package/src/canvas/text/font-families.ts +14 -7
  818. package/src/canvas/text/index.ts +3 -9
  819. package/src/canvas/text/layout/build.ts +35 -18
  820. package/src/canvas/text/layout/index.ts +15 -6
  821. package/src/canvas/text/layout/lines.ts +10 -4
  822. package/src/canvas/text/paragraph/index.ts +19 -10
  823. package/src/canvas/text/paragraph/inputs.ts +4 -2
  824. package/src/canvas/text/placed.ts +2 -2
  825. package/src/canvas/text/renderer.ts +2 -0
  826. package/src/canvas/text/shape.ts +20 -31
  827. package/src/constants.ts +6 -1
  828. package/src/editor/bridges/clipboard.ts +1 -0
  829. package/src/editor/bridges/components.ts +2 -0
  830. package/src/editor/bridges/frames.ts +6 -4
  831. package/src/editor/bridges/structure.ts +1 -0
  832. package/src/editor/clipboard/detach.ts +3 -3
  833. package/src/editor/clipboard/paste/target.ts +2 -2
  834. package/src/editor/clipboard/snapshot.ts +7 -0
  835. package/src/editor/clipboard/variables.ts +20 -0
  836. package/src/editor/clipboard.ts +133 -14
  837. package/src/editor/component-sync.ts +28 -7
  838. package/src/editor/components/authoring/text-edit.ts +15 -2
  839. package/src/editor/components/authoring/visibility-edit.ts +11 -3
  840. package/src/editor/components/instances.ts +61 -11
  841. package/src/editor/components/properties.ts +10 -0
  842. package/src/editor/components/slots/authoring.ts +4 -1
  843. package/src/editor/create.ts +58 -8
  844. package/src/editor/guides.ts +27 -12
  845. package/src/editor/history/document-change.ts +115 -7
  846. package/src/editor/history/edit.ts +62 -14
  847. package/src/editor/history/position.ts +1 -4
  848. package/src/editor/history/sources.ts +25 -0
  849. package/src/editor/index.ts +3 -1
  850. package/src/editor/layout-mode.ts +20 -1
  851. package/src/editor/node-preview.ts +44 -8
  852. package/src/editor/nodes.ts +52 -12
  853. package/src/editor/nudge.ts +16 -2
  854. package/src/editor/pages.ts +100 -17
  855. package/src/editor/play/states.ts +0 -7
  856. package/src/editor/read-only/actions.ts +4 -0
  857. package/src/editor/selection/hit-test.ts +37 -4
  858. package/src/editor/shapes/pen.ts +6 -3
  859. package/src/editor/shapes.ts +2 -1
  860. package/src/editor/structure/auto-layout-wrap.ts +26 -0
  861. package/src/editor/structure/group/bounds.ts +22 -4
  862. package/src/editor/structure/rename.ts +2 -6
  863. package/src/editor/structure/reorder.ts +26 -8
  864. package/src/editor/structure.ts +88 -24
  865. package/src/editor/text/hyperlink.ts +2 -1
  866. package/src/editor/text/name.ts +51 -15
  867. package/src/editor/text/pending-layout.ts +42 -4
  868. package/src/editor/text/selection-style.ts +17 -3
  869. package/src/editor/text.ts +86 -4
  870. package/src/editor/types.ts +19 -0
  871. package/src/editor/undo.ts +21 -2
  872. package/src/editor/variable-bindings.ts +22 -2
  873. package/src/editor/variables.ts +10 -6
  874. package/src/editor/viewport.ts +55 -21
  875. package/src/editor/views/actions.ts +17 -7
  876. package/src/editor/views/present.ts +20 -11
  877. package/src/editor/views/types.ts +11 -5
  878. package/src/figma-api/accessor-utils.ts +4 -1
  879. package/src/figma-api/accessors/basic.ts +54 -18
  880. package/src/figma-api/accessors/layout.ts +46 -7
  881. package/src/figma-api/accessors/reactions.ts +29 -0
  882. package/src/figma-api/accessors/strokes.ts +28 -8
  883. package/src/figma-api/accessors/text/index.ts +4 -0
  884. package/src/figma-api/accessors/vector.ts +3 -1
  885. package/src/figma-api/accessors/visual.ts +25 -28
  886. package/src/figma-api/components.ts +9 -7
  887. package/src/figma-api/finite.ts +102 -0
  888. package/src/figma-api/fonts/list.ts +24 -0
  889. package/src/figma-api/index.ts +170 -19
  890. package/src/figma-api/overrides.ts +1 -1
  891. package/src/figma-api/pending-layout.ts +50 -1
  892. package/src/figma-api/pending-sync.ts +61 -0
  893. package/src/figma-api/proxy.ts +35 -2
  894. package/src/figma-api/reactions.ts +212 -0
  895. package/src/figma-api/render-bounds.ts +13 -4
  896. package/src/figma-api/serialization.ts +16 -2
  897. package/src/figma-api/slots.ts +12 -3
  898. package/src/figma-api/strokes.ts +16 -12
  899. package/src/figma-api/text/index.ts +9 -15
  900. package/src/figma-api/variables/variable.ts +3 -2
  901. package/src/geometry/connectors.ts +2 -12
  902. package/src/geometry/figma.ts +9 -0
  903. package/src/geometry/index.ts +2 -1
  904. package/src/geometry/scene.ts +19 -0
  905. package/src/geometry/types.ts +8 -0
  906. package/src/global.d.ts +6 -0
  907. package/src/icons/api.ts +27 -16
  908. package/src/icons/provider.ts +9 -20
  909. package/src/icons/schema.ts +31 -0
  910. package/src/icons/svg/presentation.ts +27 -3
  911. package/src/icons/svg/text.ts +1 -1
  912. package/src/icons/svg.ts +21 -19
  913. package/src/icons/types.ts +0 -14
  914. package/src/io/formats/design-tokens/plan/index.ts +7 -1
  915. package/src/io/formats/design-tokens/plan/styles.ts +40 -4
  916. package/src/io/formats/design-tokens/styles.ts +60 -3
  917. package/src/io/formats/design-tokens/types.ts +3 -0
  918. package/src/io/formats/drawio/export.ts +11 -0
  919. package/src/io/formats/drawio/index.ts +36 -1
  920. package/src/io/formats/drawio/shapes.ts +13 -9
  921. package/src/io/formats/drawio/warnings.ts +27 -0
  922. package/src/io/formats/fig/export/setup.ts +16 -14
  923. package/src/io/formats/fig/export/variables.ts +7 -8
  924. package/src/io/formats/fig/index.ts +1 -0
  925. package/src/io/formats/fig/read.ts +66 -23
  926. package/src/io/formats/html/index.ts +2 -6
  927. package/src/io/formats/pdf/dom.ts +125 -3
  928. package/src/io/formats/pdf/export.ts +3 -2
  929. package/src/io/formats/pen/fonts.ts +45 -0
  930. package/src/io/formats/pen/index.ts +30 -6
  931. package/src/io/formats/raster/headless.ts +40 -14
  932. package/src/io/formats/raster/index.ts +3 -0
  933. package/src/io/formats/raster/render.ts +66 -8
  934. package/src/io/formats/svg/export.ts +24 -25
  935. package/src/io/formats/svg/paths.ts +11 -2
  936. package/src/io/formats/svg/strokes.ts +8 -2
  937. package/src/io/formats/svg/text/export.ts +23 -0
  938. package/src/io/formats/svg/text/import.ts +2 -1
  939. package/src/io/formats.ts +3 -1
  940. package/src/io/registry.ts +12 -0
  941. package/src/io/subgraph.ts +3 -1
  942. package/src/io/types.ts +2 -0
  943. package/src/kiwi/fig/population/client.ts +77 -43
  944. package/src/kiwi/fig/population/delta.ts +141 -18
  945. package/src/kiwi/fig/population/edits.ts +235 -0
  946. package/src/kiwi/fig/session/archive/access.ts +15 -0
  947. package/src/kiwi/fig/session/archive/changes.ts +27 -6
  948. package/src/kiwi/fig/session/document-state.ts +23 -1
  949. package/src/kiwi/fig/session/protocol.ts +26 -1
  950. package/src/kiwi/fig/session/worker.ts +38 -11
  951. package/src/layout/apply.ts +52 -10
  952. package/src/layout/arrange/boxes.ts +36 -0
  953. package/src/layout/flow-edges.ts +139 -0
  954. package/src/layout/grid.ts +14 -4
  955. package/src/layout/text-auto-resize.ts +13 -4
  956. package/src/layout/text-measurement.ts +46 -3
  957. package/src/layout.ts +60 -66
  958. package/src/library/asset-keys.ts +4 -3
  959. package/src/library/copied-references.ts +29 -5
  960. package/src/library/materialize.ts +1 -1
  961. package/src/library/schema.ts +1 -1
  962. package/src/library/snapshot.ts +12 -2
  963. package/src/lint/linter.ts +12 -2
  964. package/src/pairdraw-api/variables.ts +1 -3
  965. package/src/profiler/hud-controller.ts +8 -6
  966. package/src/profiler/hud-renderer.ts +9 -6
  967. package/src/profiler/render-profiler.ts +4 -3
  968. package/src/rpc/variables-command.ts +6 -5
  969. package/src/text/character-style.ts +29 -9
  970. package/src/text/coverage.ts +29 -15
  971. package/src/text/editor.ts +3 -8
  972. package/src/text/fallbacks.ts +163 -22
  973. package/src/text/font/catalog.ts +10 -0
  974. package/src/text/font/collection.ts +60 -0
  975. package/src/text/font/faces.ts +9 -5
  976. package/src/text/font/glyphs.ts +29 -4
  977. package/src/text/font/local.ts +2 -2
  978. package/src/text/font/manager.ts +220 -49
  979. package/src/text/font/style.ts +52 -3
  980. package/src/text/index.ts +1 -0
  981. package/src/text/outlines.ts +106 -90
  982. package/src/text/path/caret.ts +3 -4
  983. package/src/text/prepare.ts +51 -2
  984. package/src/text/style-runs.ts +43 -16
  985. package/src/text/web-font/assets.ts +11 -15
  986. package/src/text/web-font/resolver.ts +7 -1
  987. package/src/tools/analyze/overlaps/helpers.ts +18 -1
  988. package/src/tools/analyze/overlaps/index.ts +37 -6
  989. package/src/tools/codegen/component-map.ts +3 -3
  990. package/src/tools/create/basic.ts +6 -4
  991. package/src/tools/create/components.ts +33 -0
  992. package/src/tools/create/html.ts +3 -1
  993. package/src/tools/create/icons.ts +16 -6
  994. package/src/tools/create/mermaid.ts +2 -0
  995. package/src/tools/create/render.ts +2 -0
  996. package/src/tools/create/script.ts +5 -1
  997. package/src/tools/create/svg.ts +4 -1
  998. package/src/tools/create/vector.ts +20 -10
  999. package/src/tools/create.ts +1 -0
  1000. package/src/tools/image-ai/generate.ts +3 -0
  1001. package/src/tools/modify/effects.ts +11 -4
  1002. package/src/tools/modify/matching.ts +10 -6
  1003. package/src/tools/modify/paint.ts +13 -5
  1004. package/src/tools/modify/reactions.ts +40 -0
  1005. package/src/tools/modify/text.ts +53 -20
  1006. package/src/tools/modify.ts +1 -0
  1007. package/src/tools/read/components.ts +28 -25
  1008. package/src/tools/read/fonts.ts +1 -1
  1009. package/src/tools/read/libraries.ts +24 -4
  1010. package/src/tools/read/nodes.ts +47 -17
  1011. package/src/tools/read/pages.ts +7 -3
  1012. package/src/tools/read/query.ts +2 -0
  1013. package/src/tools/read/reactions.ts +21 -0
  1014. package/src/tools/read.ts +1 -0
  1015. package/src/tools/registry/extended.ts +6 -0
  1016. package/src/tools/schema.ts +166 -6
  1017. package/src/tools/stock-photo/apply.ts +17 -5
  1018. package/src/tools/structure/batch.ts +84 -98
  1019. package/src/tools/variables/values.ts +6 -3
  1020. package/src/tools/vector/export.ts +5 -1
  1021. package/src/vector/fill-geometry.ts +11 -5
  1022. package/src/vector/index.ts +1 -1
  1023. package/src/vector/path-helpers.ts +34 -8
  1024. package/src/vector/placement.ts +1 -1
  1025. package/src/vector/vectorize/preprocess.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/tools/schema.ts"],"sourcesContent":["/**\n * Tool definition schema.\n *\n * Native Valibot inputs and execution capabilities are owned by each tool.\n * Adapters consume these contracts rather than maintaining transport-specific schemas.\n */\n\nimport * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\n\nexport type ToolCapability =\n | 'document:read'\n | 'document:write'\n | 'filesystem:read'\n | 'filesystem:write'\n | 'network:access'\n | 'code:execute'\n | 'settings:read'\n | 'settings:write'\n\nexport type ToolExecution =\n | { kind: 'sync'; mutation: 'none' | 'view' | 'properties' | 'document' }\n | { kind: 'async'; mutation: 'none' | 'view' | 'document' }\n\nexport type ToolInterface = 'mcp' | 'ai' | 'webmcp'\nexport type ToolExposure = Partial<Record<ToolInterface, boolean>>\n\ninterface ToolMetadata {\n name: string\n description: string\n execution: ToolExecution\n /** Interface inclusion defaults to true; execution support and user permissions remain separate. */\n exposure: ToolExposure\n capabilities: readonly ToolCapability[]\n availability: 'default' | 'eval'\n}\n\nexport interface ToolDef extends ToolMetadata {\n input: v.StrictObjectSchema<v.ObjectEntries, undefined>\n /** Derived from execution metadata, never declared independently by a tool. */\n readonly mutates: boolean\n /**\n * Loads the fonts the call's text edits need, as a Figma plugin loads them before it edits\n * text; rejects when one cannot load. Every executor awaits it before `execute`, so a\n * synchronous tool still edits in one step.\n */\n loadFonts: (figma: FigmaAPI, args: Record<string, unknown>) => Promise<void>\n execute: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n}\n\ntype ToolDefinitionMetadata = Omit<ToolMetadata, 'exposure' | 'capabilities' | 'availability'> &\n Partial<Pick<ToolMetadata, 'exposure' | 'capabilities' | 'availability'>>\n\nexport function defineTool<P extends v.ObjectEntries, R>(\n def: ToolDefinitionMetadata & {\n input: v.StrictObjectSchema<P, undefined>\n execution: ToolExecution & (R extends PromiseLike<unknown> ? { kind: 'async' } : unknown)\n /** The fonts a call's text edits need loaded first; text edits refuse unloaded fonts. */\n fonts?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => FigmaFontNameInput[]\n execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => R\n }\n): ToolDef {\n const { fonts } = def\n return {\n ...def,\n exposure: def.exposure ?? {},\n capabilities: def.capabilities ?? [\n toolChangesDocument(def) ? 'document:write' : 'document:read'\n ],\n availability: def.availability ?? 'default',\n get mutates() {\n return def.execution.mutation !== 'none'\n },\n async loadFonts(figma, args) {\n if (!fonts) return\n // Wrong arguments are for `execute` to report.\n const parsed = v.safeParse(def.input, args)\n if (!parsed.success) return\n for (const font of fonts(figma, parsed.output)) await figma.loadFontAsync(font)\n },\n execute: (figma, args) => def.execute(figma, parseToolArgs(def.name, def.input, args))\n }\n}\n\n/**\n * Every tool run goes through here, so a wrong call from AI chat, the CLI, or WebMCP names the\n * tool and lists each problem with its argument, as `v.summarize` formats them. MCP clients get\n * the MCP SDK's own report, which validates the same schema before the handler runs. Inputs are\n * strict objects, so a misspelled or mis-nested argument fails here instead of being dropped.\n */\nexport function parseToolArgs<S extends v.GenericSchema>(\n name: string,\n schema: S,\n args: unknown\n): v.InferOutput<S> {\n const result = v.safeParse(schema, args)\n if (result.success) return result.output\n throw new Error(`Invalid arguments for ${name}:\\n${v.summarize(result.issues)}`)\n}\n\nexport function toolChangesDocument(def: Pick<ToolDef, 'execution'>): boolean {\n return def.execution.mutation === 'properties' || def.execution.mutation === 'document'\n}\n\nexport function isToolExposed(def: Pick<ToolDef, 'exposure'>, target: ToolInterface): boolean {\n return def.exposure[target] !== false\n}\n\nexport function isAtomicTool(def: ToolDef): boolean {\n return def.execution.kind === 'sync' && def.execution.mutation === 'properties'\n}\n\nexport class NodeNotFoundError extends Error {\n constructor(id: string) {\n super(`Node not found: ${id}`)\n this.name = 'NodeNotFoundError'\n }\n}\n\nexport function requireNode(figma: FigmaAPI, id: string): ReturnType<FigmaAPI['getNodeById']> {\n const node = figma.getNodeById(id)\n if (!node) throw new NodeNotFoundError(id)\n return node\n}\n\nexport function requireNodes(figma: FigmaAPI, ids: ReadonlyArray<string>): FigmaNodeProxy[] | null {\n const nodes: FigmaNodeProxy[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) return null\n nodes.push(node)\n }\n return nodes\n}\n\n/** A tool's answer when the operation it wraps throws: the error's message for the caller. */\nexport function toolFailure(error: unknown): { error: string } {\n return { error: error instanceof Error ? error.message : String(error) }\n}\n\nexport function nodeNotFound(id: string): { error: string } {\n return { error: `Node \"${id}\" not found` }\n}\n\nexport function getRawNodeOrError(\n figma: FigmaAPI,\n id: string\n): { node: SceneNode } | { error: string } {\n const node = figma.graph.getNode(id)\n return node ? { node } : nodeNotFound(id)\n}\n\nexport function nodeToResult(node: FigmaNodeProxy, maxDepth?: number): Record<string, unknown> {\n return node.toJSON(maxDepth)\n}\n\nexport function nodeSummary(node: FigmaNodeProxy): { id: string; name: string; type: string } {\n return { id: node.id, name: node.name, type: node.type }\n}\n\nexport const nodeIdInputSchema = v.pipe(v.string(), v.description('Node ID'))\nexport const nodeInputSchema = v.strictObject({ id: nodeIdInputSchema })\nexport const nodeComparisonInputSchema = v.strictObject({\n from: v.pipe(v.string(), v.description('Source node ID')),\n to: v.pipe(v.string(), v.description('Target node ID'))\n})\n\nexport function nodeTraversalInput(depthDescription: string) {\n return v.strictObject({\n id: nodeIdInputSchema,\n depth: v.optional(toolNumber(v.pipe(v.number(), v.description(depthDescription))))\n })\n}\nexport const positionInputs = {\n x: toolNumber(v.pipe(v.number(), v.description('X position in the parent, or on the page'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position in the parent, or on the page')))\n}\n\n/** Reuse a native number schema for both numeric and numeric-string agent inputs. */\nexport function toolNumber(schema: v.GenericSchema<number, number> = v.number()) {\n // JSON Schema numbers are finite. Express that with representable bounds as well as at runtime.\n const finite = v.pipe(schema, v.minValue(-Number.MAX_VALUE), v.maxValue(Number.MAX_VALUE))\n return v.union([\n finite,\n v.pipe(\n v.string(),\n v.regex(/\\S/, 'Expected a nonblank numeric string'),\n v.description(v.getDescription(schema) ?? 'Numeric value'),\n v.transform(Number),\n finite\n )\n ])\n}\n"],"mappings":";;;;;;;;AAyDA,SAAgB,WACd,KAUS;CACT,MAAM,EAAE,UAAU;CAClB,OAAO;EACL,GAAG;EACH,UAAU,IAAI,YAAY,CAAC;EAC3B,cAAc,IAAI,gBAAgB,CAChC,oBAAoB,GAAG,IAAI,mBAAmB,eAChD;EACA,cAAc,IAAI,gBAAgB;EAClC,IAAI,UAAU;GACZ,OAAO,IAAI,UAAU,aAAa;EACpC;EACA,MAAM,UAAU,OAAO,MAAM;GAC3B,IAAI,CAAC,OAAO;GAEZ,MAAM,SAAS,EAAE,UAAU,IAAI,OAAO,IAAI;GAC1C,IAAI,CAAC,OAAO,SAAS;GACrB,KAAK,MAAM,QAAQ,MAAM,OAAO,OAAO,MAAM,GAAG,MAAM,MAAM,cAAc,IAAI;EAChF;EACA,UAAU,OAAO,SAAS,IAAI,QAAQ,OAAO,cAAc,IAAI,MAAM,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file":"schema.js","names":[],"sources":["../../src/tools/schema.ts"],"sourcesContent":["/**\n * Tool definition schema.\n *\n * Native Valibot inputs and execution capabilities are owned by each tool.\n * Adapters consume these contracts rather than maintaining transport-specific schemas.\n */\n\nimport * as v from 'valibot'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api'\nimport type { FigmaFontNameInput } from '#core/figma-api/fonts/names'\n\nexport type ToolCapability =\n | 'document:read'\n | 'document:write'\n | 'filesystem:read'\n | 'filesystem:write'\n | 'network:access'\n | 'code:execute'\n | 'settings:read'\n | 'settings:write'\n\nexport type ToolExecution =\n | { kind: 'sync'; mutation: 'none' | 'view' | 'properties' | 'document' }\n | { kind: 'async'; mutation: 'none' | 'view' | 'document' }\n\nexport type ToolInterface = 'mcp' | 'ai' | 'webmcp'\nexport type ToolExposure = Partial<Record<ToolInterface, boolean>>\n\ninterface ToolMetadata {\n name: string\n description: string\n execution: ToolExecution\n /** Interface inclusion defaults to true; execution support and user permissions remain separate. */\n exposure: ToolExposure\n capabilities: readonly ToolCapability[]\n availability: 'default' | 'eval'\n}\n\nexport interface ToolDef extends ToolMetadata {\n input: v.StrictObjectSchema<v.ObjectEntries, undefined>\n /** Derived from execution metadata, never declared independently by a tool. */\n readonly mutates: boolean\n /**\n * Loads the fonts the call's text edits need, as a Figma plugin loads them before it edits\n * text; rejects when one cannot load. Every executor awaits it before `execute`, so a\n * synchronous tool still edits in one step.\n */\n loadFonts: (figma: FigmaAPI, args: Record<string, unknown>) => Promise<void>\n execute: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n /**\n * The synchronous answer of a read whose `execute` may load a page first, or `undefined`\n * when answering would load. Hosts that cannot wait refuse on `undefined` before any load.\n */\n executeSync?: (figma: FigmaAPI, args: Record<string, unknown>) => unknown\n}\n\ntype ToolDefinitionMetadata = Omit<ToolMetadata, 'exposure' | 'capabilities' | 'availability'> &\n Partial<Pick<ToolMetadata, 'exposure' | 'capabilities' | 'availability'>>\n\nexport function defineTool<P extends v.ObjectEntries, R>(\n def: ToolDefinitionMetadata & {\n input: v.StrictObjectSchema<P, undefined>\n execution: ToolExecution & (R extends PromiseLike<unknown> ? { kind: 'async' } : unknown)\n /** The fonts a call's text edits need loaded first; text edits refuse unloaded fonts. */\n fonts?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => FigmaFontNameInput[]\n execute: (figma: FigmaAPI, args: v.InferOutput<v.StrictObjectSchema<P, undefined>>) => R\n executeSync?: (\n figma: FigmaAPI,\n args: v.InferOutput<v.StrictObjectSchema<P, undefined>>\n ) => unknown\n }\n): ToolDef {\n const { fonts } = def\n return {\n ...def,\n exposure: def.exposure ?? {},\n capabilities: def.capabilities ?? [\n toolChangesDocument(def) ? 'document:write' : 'document:read'\n ],\n availability: def.availability ?? 'default',\n get mutates() {\n return def.execution.mutation !== 'none'\n },\n async loadFonts(figma, args) {\n if (!fonts) return\n // Wrong arguments are for `execute` to report.\n const parsed = v.safeParse(def.input, args)\n if (!parsed.success) return\n for (const font of fonts(figma, parsed.output)) await figma.loadFontAsync(font)\n },\n execute: (figma, args) => def.execute(figma, parseToolArgs(def.name, def.input, args)),\n executeSync: def.executeSync\n ? (figma, args) => def.executeSync?.(figma, parseToolArgs(def.name, def.input, args))\n : undefined\n }\n}\n\n/**\n * Every tool run goes through here, so a wrong call from AI chat, the CLI, WebMCP, and MCP names\n * the tool and lists each problem with its argument. An unknown or missing argument names the\n * arguments the tool takes, and a picklist names the values it accepts, read from the schema, so\n * the caller does not have to guess. Inputs are strict objects, so a misspelled or mis-nested\n * argument fails here instead of being dropped.\n */\nexport function parseToolArgs<S extends v.GenericSchema>(\n name: string,\n schema: S,\n args: unknown\n): v.InferOutput<S> {\n const result = v.safeParse(schema, args)\n if (result.success) return result.output\n throw new Error(formatToolArgumentError(name, schema, result.issues))\n}\n\n/** One refusal for every surface: the tool, then each problem with where it is. */\nfunction formatToolArgumentError(\n name: string,\n schema: v.GenericSchema,\n issues: readonly v.BaseIssue<unknown>[]\n): string {\n const problems = issues\n .flatMap((issue) => branchIssues(schema, issue))\n .map(({ keys, issue }) => {\n const place = keys.length > 0 ? `\\n → at ${placeOf(keys)}` : ''\n return `× ${formatToolArgIssue(schema, keys, issue)}${place}`\n })\n return `Invalid arguments for ${name}:\\n${problems.join('\\n')}`\n}\n\n/** The parts of a Valibot schema this module reads to name what a call should have sent. */\ntype SchemaParts = {\n readonly entries?: v.ObjectEntries\n readonly item?: v.GenericSchema\n readonly wrapped?: v.GenericSchema\n readonly options?: readonly unknown[]\n}\n\nfunction schemaParts(schema: unknown): SchemaParts {\n return typeof schema === 'object' && schema !== null ? schema : {}\n}\n\n/** The schema a wrapper such as `optional` or `pipe` holds, down to the one with the rules. */\nfunction unwrappedSchema(schema: v.GenericSchema): v.GenericSchema {\n let current = schema\n for (;;) {\n const wrapped = schemaParts(current).wrapped\n if (!wrapped) return current\n current = wrapped\n }\n}\n\ntype ArgumentKey = string | number\n\nfunction issueKeys(issue: v.BaseIssue<unknown>): ArgumentKey[] {\n const keys: ArgumentKey[] = []\n for (const item of issue.path ?? []) {\n if (!('key' in item)) continue\n if (typeof item.key === 'string' || typeof item.key === 'number') keys.push(item.key)\n }\n return keys\n}\n\n/** `operations[0].props`: an index reads as part of its array, a name follows a dot. */\nfunction placeOf(keys: readonly ArgumentKey[]): string {\n return keys.reduce<string>((place, key) => {\n if (typeof key === 'number') return `${place}[${key}]`\n return place ? `${place}.${key}` : key\n }, '')\n}\n\n/**\n * `v.union` reports one issue for every branch, which reads as \"Expected Object but received\n * Object\". Re-check the value against each branch and keep the one that got furthest: the branch\n * whose own problems name the field the caller has to fix.\n */\nfunction branchIssues(\n schema: v.GenericSchema,\n issue: v.BaseIssue<unknown>\n): { keys: ArgumentKey[]; issue: v.BaseIssue<unknown> }[] {\n const keys = issueKeys(issue)\n if (issue.type !== 'union') return [{ keys, issue }]\n const union = schemaAtPath(schema, keys)\n const options = union ? schemaParts(union).options : undefined\n if (!options || options.length === 0) return [{ keys, issue }]\n let best: readonly v.BaseIssue<unknown>[] | null = null\n for (const option of options) {\n const parsed = v.safeParse(option as v.GenericSchema, issue.input)\n if (parsed.success) continue\n if (!best || parsed.issues.length < best.length) best = parsed.issues\n }\n if (!best || best.length === 0) return [{ keys, issue }]\n return best.map((nested) => ({ keys: [...keys, ...issueKeys(nested)], issue: nested }))\n}\n\nfunction schemaAtPath(root: v.GenericSchema, keys: readonly ArgumentKey[]): v.GenericSchema | null {\n let current = unwrappedSchema(root)\n for (const key of keys) {\n const parts = schemaParts(current)\n const name = String(key)\n const next = parts.entries && name in parts.entries ? parts.entries[name] : parts.item\n if (!next) return null\n current = unwrappedSchema(next)\n }\n return current\n}\n\nfunction formatToolArgIssue(\n schema: v.GenericSchema,\n keys: readonly ArgumentKey[],\n issue: v.BaseIssue<unknown>\n): string {\n const key = keys.at(-1)\n if (key !== undefined && (issue.type === 'object' || issue.type === 'strict_object')) {\n if (issue.expected === 'never') {\n const parent = schemaAtPath(schema, keys.slice(0, -1))\n const accepted = parent ? Object.keys(schemaParts(parent).entries ?? {}) : []\n return accepted.length > 0\n ? `Unknown argument \"${key}\". Accepted: ${accepted.join(', ')}`\n : `Unknown argument \"${key}\"`\n }\n if (issue.received === 'undefined') return `Missing required argument \"${key}\"`\n }\n if (issue.type === 'picklist' && key !== undefined) {\n const resolved = schemaAtPath(schema, keys)\n const options = resolved ? schemaParts(resolved).options : undefined\n if (options && options.length > 0) {\n const accepted = options.map((option) => JSON.stringify(option)).join(', ')\n return `Invalid value ${issue.received} for argument \"${key}\". Accepted: ${accepted}`\n }\n }\n return issue.message\n}\n\nexport function toolChangesDocument(def: Pick<ToolDef, 'execution'>): boolean {\n return def.execution.mutation === 'properties' || def.execution.mutation === 'document'\n}\n\nexport function isToolExposed(def: Pick<ToolDef, 'exposure'>, target: ToolInterface): boolean {\n return def.exposure[target] !== false\n}\n\nexport function isAtomicTool(def: ToolDef): boolean {\n return def.execution.kind === 'sync' && def.execution.mutation === 'properties'\n}\n\nexport class NodeNotFoundError extends Error {\n constructor(id: string) {\n super(`Node not found: ${id}`)\n this.name = 'NodeNotFoundError'\n }\n}\n\nexport function requireNode(figma: FigmaAPI, id: string): ReturnType<FigmaAPI['getNodeById']> {\n const node = figma.getNodeById(id)\n if (!node) throw new NodeNotFoundError(id)\n return node\n}\n\nexport function requireNodes(figma: FigmaAPI, ids: ReadonlyArray<string>): FigmaNodeProxy[] | null {\n const nodes: FigmaNodeProxy[] = []\n for (const id of ids) {\n const node = figma.getNodeById(id)\n if (!node) return null\n nodes.push(node)\n }\n return nodes\n}\n\n/** A tool's answer when the operation it wraps throws: the error's message for the caller. */\nexport function toolFailure(error: unknown): { error: string } {\n return { error: error instanceof Error ? error.message : String(error) }\n}\n\nexport function nodeNotFound(id: string): { error: string } {\n return { error: `Node \"${id}\" not found` }\n}\n\nexport function getRawNodeOrError(\n figma: FigmaAPI,\n id: string\n): { node: SceneNode } | { error: string } {\n const node = figma.graph.getNode(id)\n return node ? { node } : nodeNotFound(id)\n}\n\nexport function nodeToResult(node: FigmaNodeProxy, maxDepth?: number): Record<string, unknown> {\n return node.toJSON(maxDepth)\n}\n\nexport function nodeSummary(node: FigmaNodeProxy): { id: string; name: string; type: string } {\n return { id: node.id, name: node.name, type: node.type }\n}\n\n/**\n * A tool colour, refusing text that would otherwise land as black: `set_fill { color: \"#GGG\" }`\n * used to paint black and report success. Read through `tryParseColor`, since a published schema\n * cannot express what the parser accepts.\n */\nexport function parseToolColor(value: string): Color | { error: string } {\n return (\n tryParseColor(value) ?? {\n error: `\"${value}\" is not a color; use a hex value, a color name, or a color function`\n }\n )\n}\n\n/**\n * A colour the caller may leave out. Missing stays missing; text that is not a colour is the\n * same refusal `parseToolColor` gives, so each tool does not repeat that check.\n */\nexport function parseOptionalToolColor(\n value: string | undefined\n): { color: Color | undefined } | { error: string } {\n if (value === undefined) return { color: undefined }\n const parsed = parseToolColor(value)\n if ('error' in parsed) return parsed\n return { color: parsed }\n}\n\nexport const nodeIdInputSchema = v.pipe(v.string(), v.description('Node ID'))\nexport const nodeInputSchema = v.strictObject({ id: nodeIdInputSchema })\nexport const nodeComparisonInputSchema = v.strictObject({\n from: v.pipe(v.string(), v.description('Source node ID')),\n to: v.pipe(v.string(), v.description('Target node ID'))\n})\n\nexport function nodeTraversalInput(depthDescription: string) {\n return v.strictObject({\n id: nodeIdInputSchema,\n depth: v.optional(toolNumber(v.pipe(v.number(), v.description(depthDescription))))\n })\n}\nexport const positionInputs = {\n x: toolNumber(v.pipe(v.number(), v.description('X position in the parent, or on the page'))),\n y: toolNumber(v.pipe(v.number(), v.description('Y position in the parent, or on the page')))\n}\n\n/** Reuse a native number schema for both numeric and numeric-string agent inputs. */\nexport function toolNumber(schema: v.GenericSchema<number, number> = v.number()) {\n // JSON Schema numbers are finite. Express that with representable bounds as well as at runtime.\n const finite = v.pipe(schema, v.minValue(-Number.MAX_VALUE), v.maxValue(Number.MAX_VALUE))\n return v.union([\n finite,\n v.pipe(\n v.string(),\n v.regex(/\\S/, 'Expected a nonblank numeric string'),\n v.description(v.getDescription(schema) ?? 'Numeric value'),\n v.transform(Number),\n finite\n )\n ])\n}\n"],"mappings":";;;;;;;;;AAgEA,SAAgB,WACd,KAcS;CACT,MAAM,EAAE,UAAU;CAClB,OAAO;EACL,GAAG;EACH,UAAU,IAAI,YAAY,CAAC;EAC3B,cAAc,IAAI,gBAAgB,CAChC,oBAAoB,GAAG,IAAI,mBAAmB,eAChD;EACA,cAAc,IAAI,gBAAgB;EAClC,IAAI,UAAU;GACZ,OAAO,IAAI,UAAU,aAAa;EACpC;EACA,MAAM,UAAU,OAAO,MAAM;GAC3B,IAAI,CAAC,OAAO;GAEZ,MAAM,SAAS,EAAE,UAAU,IAAI,OAAO,IAAI;GAC1C,IAAI,CAAC,OAAO,SAAS;GACrB,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A4B,EAAE,aAAa;CACtD,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC;CACxD,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC;AACxD,CAAC;AAED,SAAgB,mBAAmB,kBAA0B;CAC3D,OAAO,EAAE,aAAa;EACpB,IAAI;EACJ,OAAO,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,gBAAgB,CAAC,CAAC,CAAC;CACnF,CAAC;AACH;AACA,MAAa,iBAAiB;CAC5B,GAAG,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;CAC3F,GAAG,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,0CAA0C,CAAC,CAAC;AAC7F;;AAGA,SAAgB,WAAW,SAA0C,EAAE,OAAO,GAAG;CAE/E,MAAM,SAAS,EAAE,KAAK,QAAQ,EAAE,SAAS,CAAC,OAAO,SAAS,GAAG,EAAE,SAAS,OAAO,SAAS,CAAC;CACzF,OAAO,EAAE,MAAM,CACb,QACA,EAAE,KACA,EAAE,OAAO,GACT,EAAE,MAAM,MAAM,oCAAoC,GAClD,EAAE,YAAY,EAAE,eAAe,MAAM,KAAK,eAAe,GACzD,EAAE,UAAU,MAAM,GAClB,MACF,CACF,CAAC;AACH"}
@@ -36,11 +36,11 @@ async function applyPhoto(figma, provider, req) {
36
36
  const targetDim = Math.max(node.width, node.height);
37
37
  let results;
38
38
  try {
39
- results = await provider.search(req.query, {
39
+ results = await figma.graph.waitOutsideEdit(provider.search(req.query, {
40
40
  perPage,
41
41
  orientation,
42
42
  targetDim
43
- });
43
+ }));
44
44
  } catch (err) {
45
45
  return {
46
46
  id: req.id,
@@ -54,12 +54,11 @@ async function applyPhoto(figma, provider, req) {
54
54
  const photo = results[Math.min(req.index ?? 0, results.length - 1)];
55
55
  let imageBytes;
56
56
  try {
57
- const response = await fetch(photo.url);
58
- if (!response.ok) return {
59
- id: req.id,
60
- error: `Download ${response.status}`
61
- };
62
- imageBytes = new Uint8Array(await response.arrayBuffer());
57
+ imageBytes = await figma.graph.waitOutsideEdit((async () => {
58
+ const response = await fetch(photo.url);
59
+ if (!response.ok) throw new Error(`Download ${response.status}`);
60
+ return new Uint8Array(await response.arrayBuffer());
61
+ })());
63
62
  } catch (err) {
64
63
  return {
65
64
  id: req.id,
@@ -71,7 +70,7 @@ async function applyPhoto(figma, provider, req) {
71
70
  imageHash: storeImage(figma.graph, imageBytes),
72
71
  scaleMode: "FILL"
73
72
  }];
74
- await provider.reportUse?.(photo).catch(() => void 0);
73
+ if (provider.reportUse) await figma.graph.waitOutsideEdit(Promise.resolve(provider.reportUse(photo)).catch(() => void 0));
75
74
  return {
76
75
  id: node.id,
77
76
  photo: {
@@ -1 +1 @@
1
- {"version":3,"file":"apply.js","names":[],"sources":["../../../src/tools/stock-photo/apply.ts"],"sourcesContent":["import type { FigmaAPI } from '#core/figma-api'\nimport { storeImage } from '#core/figma-api/images'\nimport type { FigmaNodeProxy } from '#core/figma-api/proxy'\n\nimport type { StockPhotoProvider, StockPhotoResult } from './providers'\n\nconst STOCK_PHOTO_TARGET_TYPES: ReadonlySet<FigmaNodeProxy['type']> = new Set([\n 'FRAME',\n 'SLOT',\n 'RECTANGLE',\n 'ROUNDED_RECTANGLE',\n 'ELLIPSE',\n 'STAR',\n 'POLYGON',\n 'VECTOR',\n 'BOOLEAN_OPERATION',\n 'COMPONENT',\n 'INSTANCE'\n])\n\nexport interface PhotoRequest {\n id: string\n query: string\n index?: number\n orientation?: 'landscape' | 'portrait' | 'square'\n}\n\nexport interface PhotoResult {\n id: string\n photo?: {\n sourceId: string\n photographer: string\n width: number\n height: number\n provider: string\n }\n error?: string\n}\n\nexport async function applyPhoto(\n figma: FigmaAPI,\n provider: StockPhotoProvider,\n req: PhotoRequest\n): Promise<PhotoResult> {\n const node = figma.getNodeById(req.id)\n if (!node) return { id: req.id, error: 'Not found' }\n\n if (!STOCK_PHOTO_TARGET_TYPES.has(node.type)) {\n return {\n id: req.id,\n error: `\"${node.name}\" (${node.type}) is not a suitable stock photo target`\n }\n }\n\n if (node.type === 'VECTOR' && (node.vectorNetwork.regions?.length ?? 0) === 0) {\n return {\n id: req.id,\n error: `\"${node.name}\" has no closed vector regions — use closed area geometry`\n }\n }\n\n if (node.type !== 'BOOLEAN_OPERATION' && node.children.length > 0) {\n return { id: req.id, error: `\"${node.name}\" has children — use a leaf image placeholder` }\n }\n\n const perPage = Math.min((req.index ?? 0) + 3, 15)\n const orientation = req.orientation ?? 'landscape'\n const targetDim = Math.max(node.width, node.height)\n\n let results: StockPhotoResult[]\n try {\n results = await provider.search(req.query, { perPage, orientation, targetDim })\n } catch (err) {\n return { id: req.id, error: err instanceof Error ? err.message : String(err) }\n }\n\n if (results.length === 0) return { id: req.id, error: `No photos for \"${req.query}\"` }\n const photo = results[Math.min(req.index ?? 0, results.length - 1)]\n\n let imageBytes: Uint8Array\n try {\n const response = await fetch(photo.url)\n if (!response.ok) return { id: req.id, error: `Download ${response.status}` }\n imageBytes = new Uint8Array(await response.arrayBuffer())\n } catch (err) {\n return { id: req.id, error: `Download: ${err instanceof Error ? err.message : String(err)}` }\n }\n\n const imageHash = storeImage(figma.graph, imageBytes)\n node.fills = [{ type: 'IMAGE', imageHash, scaleMode: 'FILL' }]\n // A missed report does not undo the photo the document already shows.\n await provider.reportUse?.(photo).catch(() => undefined)\n\n return {\n id: node.id,\n photo: {\n sourceId: photo.sourceId,\n photographer: photo.photographer,\n width: photo.width,\n height: photo.height,\n provider: provider.name\n }\n }\n}\n"],"mappings":";;AAMA,MAAM,2CAAgE,IAAI,IAAI;CAC5E;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAqBD,eAAsB,WACpB,OACA,UACA,KACsB;CACtB,MAAM,OAAO,MAAM,YAAY,IAAI,EAAE;CACrC,IAAI,CAAC,MA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AAO,GAAG;EAAI;CAC9F;CAGA,KAAK,QAAQ,CAAC;EAAE,MAAM;EAAS,WADb,WAAW,MAAM,OAAO,UACH;EAAG,WAAW;CAAO,CAAC;CAE7D,MAAM,SAAS,YAAY,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;CAEvD,OAAO;EACL,IAAI,KAAK;EACT,OAAO;GACL,UAAU,MAAM;GAChB,cAAc,MAAM;GACpB,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,UAAU,SAAS;EACrB;CACF;AACF"}
1
+ {"version":3,"file":"apply.js","names":[],"sources":["../../../src/tools/stock-photo/apply.ts"],"sourcesContent":["import type { FigmaAPI } from '#core/figma-api'\nimport { storeImage } from '#core/figma-api/images'\nimport type { FigmaNodeProxy } from '#core/figma-api/proxy'\n\nimport type { StockPhotoProvider, StockPhotoResult } from './providers'\n\nconst STOCK_PHOTO_TARGET_TYPES: ReadonlySet<FigmaNodeProxy['type']> = new Set([\n 'FRAME',\n 'SLOT',\n 'RECTANGLE',\n 'ROUNDED_RECTANGLE',\n 'ELLIPSE',\n 'STAR',\n 'POLYGON',\n 'VECTOR',\n 'BOOLEAN_OPERATION',\n 'COMPONENT',\n 'INSTANCE'\n])\n\nexport interface PhotoRequest {\n id: string\n query: string\n index?: number\n orientation?: 'landscape' | 'portrait' | 'square'\n}\n\nexport interface PhotoResult {\n id: string\n photo?: {\n sourceId: string\n photographer: string\n width: number\n height: number\n provider: string\n }\n error?: string\n}\n\nexport async function applyPhoto(\n figma: FigmaAPI,\n provider: StockPhotoProvider,\n req: PhotoRequest\n): Promise<PhotoResult> {\n const node = figma.getNodeById(req.id)\n if (!node) return { id: req.id, error: 'Not found' }\n\n if (!STOCK_PHOTO_TARGET_TYPES.has(node.type)) {\n return {\n id: req.id,\n error: `\"${node.name}\" (${node.type}) is not a suitable stock photo target`\n }\n }\n\n if (node.type === 'VECTOR' && (node.vectorNetwork.regions?.length ?? 0) === 0) {\n return {\n id: req.id,\n error: `\"${node.name}\" has no closed vector regions — use closed area geometry`\n }\n }\n\n if (node.type !== 'BOOLEAN_OPERATION' && node.children.length > 0) {\n return { id: req.id, error: `\"${node.name}\" has children — use a leaf image placeholder` }\n }\n\n const perPage = Math.min((req.index ?? 0) + 3, 15)\n const orientation = req.orientation ?? 'landscape'\n const targetDim = Math.max(node.width, node.height)\n\n let results: StockPhotoResult[]\n try {\n // The download is not part of an enclosing edit: what someone else changes meanwhile stays\n // out of its undo step.\n results = await figma.graph.waitOutsideEdit(\n provider.search(req.query, { perPage, orientation, targetDim })\n )\n } catch (err) {\n return { id: req.id, error: err instanceof Error ? err.message : String(err) }\n }\n\n if (results.length === 0) return { id: req.id, error: `No photos for \"${req.query}\"` }\n const photo = results[Math.min(req.index ?? 0, results.length - 1)]\n\n let imageBytes: Uint8Array\n try {\n imageBytes = await figma.graph.waitOutsideEdit(\n (async () => {\n const response = await fetch(photo.url)\n if (!response.ok) throw new Error(`Download ${response.status}`)\n return new Uint8Array(await response.arrayBuffer())\n })()\n )\n } catch (err) {\n return { id: req.id, error: `Download: ${err instanceof Error ? err.message : String(err)}` }\n }\n\n const imageHash = storeImage(figma.graph, imageBytes)\n node.fills = [{ type: 'IMAGE', imageHash, scaleMode: 'FILL' }]\n // A missed report does not undo the photo the document already shows.\n if (provider.reportUse) {\n await figma.graph.waitOutsideEdit(\n Promise.resolve(provider.reportUse(photo)).catch(() => undefined)\n )\n }\n\n return {\n id: node.id,\n photo: {\n sourceId: photo.sourceId,\n photographer: photo.photographer,\n width: photo.width,\n height: photo.height,\n provider: provider.name\n }\n }\n}\n"],"mappings":";;AAMA,MAAM,2CAAgE,IAAI,IAAI;CAC5E;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAqBD,eAAsB,WACpB,OACA,UACA,KACsB;CACtB,MAAM,OAAO,MAAM,YAAY,IAAI,EAAE;CACrC,IAAI,CAAC,MAAM,OAAO;EAAE,IAAI,IAAI;EAAI,OAAO;CAAY;CAEnD,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QAAQ,IAAI,UAAU,OAAO,GAAG;EAAI;CAC9F;CAGA,KAAK,QAAQ,CAAC;EAAE,MAAM;EAAS,WADb,WAAW,MAAM,OAAO,UACH;EAAG,WAAW;CAAO,CAAC;CAE7D,IAAI,SAAS,WACX,MAAM,MAAM,MAAM,gBAChB,QAAQ,QAAQ,SAAS,UAAU,KAAK,CAAC,CAAC,CAAC,YAAY,KAAA,CAAS,CAClE;CAGF,OAAO;EACL,IAAI,KAAK;EACT,OAAO;GACL,UAAU,MAAM;GAChB,cAAc,MAAM;GACpB,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,UAAU,SAAS;EACrB;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"batch.d.ts","names":[],"sources":["../../../src/tools/structure/batch.ts"],"mappings":";;cAqGa,aAAA"}
1
+ {"version":3,"file":"batch.d.ts","names":[],"sources":["../../../src/tools/structure/batch.ts"],"mappings":";;cAiFa,aAAA"}
@@ -1,128 +1,124 @@
1
- import { defineTool } from "../schema.js";
1
+ import { defineTool, nodeNotFound, toolNumber } from "../schema.js";
2
2
  import { textFonts } from "../modify/text.js";
3
3
  import * as v from "valibot";
4
4
  //#region src/tools/structure/batch.ts
5
- const batchOpsSchema = v.array(v.object({
5
+ const nonNegative = () => toolNumber(v.pipe(v.number(), v.minValue(0)));
6
+ /** Every prop an operation may set; anything else rejects the whole batch. */
7
+ const batchPropsSchema = v.strictObject({
8
+ spacing: v.optional(nonNegative()),
9
+ padding: v.optional(nonNegative()),
10
+ padding_horizontal: v.optional(nonNegative()),
11
+ padding_vertical: v.optional(nonNegative()),
12
+ align: v.optional(v.picklist([
13
+ "MIN",
14
+ "CENTER",
15
+ "MAX",
16
+ "SPACE_BETWEEN",
17
+ "SPACE_AROUND"
18
+ ])),
19
+ counter_align: v.optional(v.picklist([
20
+ "MIN",
21
+ "CENTER",
22
+ "MAX",
23
+ "STRETCH"
24
+ ])),
25
+ sizing_horizontal: v.optional(v.picklist([
26
+ "FIXED",
27
+ "HUG",
28
+ "FILL"
29
+ ])),
30
+ sizing_vertical: v.optional(v.picklist([
31
+ "FIXED",
32
+ "HUG",
33
+ "FILL"
34
+ ])),
35
+ grow: v.optional(nonNegative()),
36
+ name: v.optional(v.string()),
37
+ visible: v.optional(v.boolean()),
38
+ corner_radius: v.optional(nonNegative()),
39
+ opacity: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))),
40
+ auto_resize: v.optional(v.picklist([
41
+ "NONE",
42
+ "WIDTH_AND_HEIGHT",
43
+ "HEIGHT",
44
+ "TRUNCATE"
45
+ ])),
46
+ direction: v.optional(v.picklist(["HORIZONTAL", "VERTICAL"]))
47
+ });
48
+ const batchOpsSchema = v.array(v.strictObject({
6
49
  id: v.string(),
7
- props: v.record(v.string(), v.unknown())
50
+ props: batchPropsSchema
8
51
  }));
9
- /** The operations a call names, or why they cannot be read. */
52
+ /** The operations a call names, or every problem with them. */
10
53
  function parseOperations(operations) {
11
- const json = v.safeParse(v.pipe(v.string(), v.parseJson()), operations);
12
- if (!json.success) return { error: "Invalid JSON in operations" };
13
- const ops = v.safeParse(batchOpsSchema, json.output);
14
- if (!ops.success) return { error: "operations must be a JSON array of {id, props}" };
15
- return ops.output;
16
- }
17
- function str(value) {
18
- return typeof value === "string" ? value : "";
19
- }
20
- function num(value) {
21
- return typeof value === "number" ? value : 0;
54
+ const result = typeof operations === "string" ? v.safeParse(v.pipe(v.string(), v.parseJson(), batchOpsSchema), operations) : v.safeParse(batchOpsSchema, operations);
55
+ if (result.success) return result.output;
56
+ return { error: `Invalid operations:\n${v.summarize(result.issues)}` };
22
57
  }
23
58
  function applyBatchProps(node, props) {
24
- const updated = [];
25
- if (props.spacing !== void 0) {
26
- node.itemSpacing = num(props.spacing);
27
- updated.push("spacing");
28
- }
59
+ if (props.spacing !== void 0) node.itemSpacing = props.spacing;
29
60
  if (props.padding !== void 0) {
30
- const value = num(props.padding);
31
- node.paddingTop = value;
32
- node.paddingRight = value;
33
- node.paddingBottom = value;
34
- node.paddingLeft = value;
35
- updated.push("padding");
61
+ node.paddingTop = props.padding;
62
+ node.paddingRight = props.padding;
63
+ node.paddingBottom = props.padding;
64
+ node.paddingLeft = props.padding;
36
65
  }
37
66
  if (props.padding_horizontal !== void 0) {
38
- node.paddingLeft = num(props.padding_horizontal);
39
- node.paddingRight = num(props.padding_horizontal);
40
- updated.push("padding_horizontal");
67
+ node.paddingLeft = props.padding_horizontal;
68
+ node.paddingRight = props.padding_horizontal;
41
69
  }
42
70
  if (props.padding_vertical !== void 0) {
43
- node.paddingTop = num(props.padding_vertical);
44
- node.paddingBottom = num(props.padding_vertical);
45
- updated.push("padding_vertical");
46
- }
47
- if (props.counter_align !== void 0) {
48
- node.counterAxisAlignItems = str(props.counter_align);
49
- updated.push("counter_align");
50
- }
51
- if (props.align !== void 0) {
52
- node.primaryAxisAlignItems = str(props.align);
53
- updated.push("align");
54
- }
55
- if (props.sizing_horizontal !== void 0) {
56
- node.layoutSizingHorizontal = str(props.sizing_horizontal);
57
- updated.push("sizing_horizontal");
58
- }
59
- if (props.sizing_vertical !== void 0) {
60
- node.layoutSizingVertical = str(props.sizing_vertical);
61
- updated.push("sizing_vertical");
62
- }
63
- if (props.grow !== void 0) {
64
- node.layoutGrow = num(props.grow);
65
- updated.push("grow");
66
- }
67
- if (props.name !== void 0) {
68
- node.name = str(props.name);
69
- updated.push("name");
70
- }
71
- if (props.visible !== void 0) {
72
- node.visible = Boolean(props.visible);
73
- updated.push("visible");
74
- }
75
- if (props.corner_radius !== void 0) {
76
- node.cornerRadius = num(props.corner_radius);
77
- updated.push("corner_radius");
78
- }
79
- if (props.opacity !== void 0) {
80
- node.opacity = num(props.opacity);
81
- updated.push("opacity");
82
- }
83
- if (props.auto_resize !== void 0) {
84
- node.textAutoResize = str(props.auto_resize);
85
- updated.push("auto_resize");
86
- }
87
- if (props.direction !== void 0) {
88
- node.layoutMode = str(props.direction);
89
- updated.push("direction");
90
- }
91
- return updated;
71
+ node.paddingTop = props.padding_vertical;
72
+ node.paddingBottom = props.padding_vertical;
73
+ }
74
+ if (props.align !== void 0) node.primaryAxisAlignItems = props.align;
75
+ if (props.counter_align !== void 0) node.counterAxisAlignItems = props.counter_align;
76
+ if (props.sizing_horizontal !== void 0) node.layoutSizingHorizontal = props.sizing_horizontal;
77
+ if (props.sizing_vertical !== void 0) node.layoutSizingVertical = props.sizing_vertical;
78
+ if (props.grow !== void 0) node.layoutGrow = props.grow;
79
+ if (props.name !== void 0) node.name = props.name;
80
+ if (props.visible !== void 0) node.visible = props.visible;
81
+ if (props.corner_radius !== void 0) node.cornerRadius = props.corner_radius;
82
+ if (props.opacity !== void 0) node.opacity = props.opacity;
83
+ if (props.auto_resize !== void 0) node.textAutoResize = props.auto_resize;
84
+ if (props.direction !== void 0) node.layoutMode = props.direction;
92
85
  }
93
86
  const batchUpdate = defineTool({
94
87
  name: "batch_update",
95
- description: "Execute multiple modifications in one call. Each operation is {id, props} where props can include: spacing, padding, padding_horizontal, padding_vertical, counter_align, sizing_horizontal, sizing_vertical, grow, name, visible, corner_radius, auto_resize (for text), direction. Runs all updates with one layout recompute.",
88
+ description: `Execute multiple modifications in one call, all or nothing: if any operation names a missing node or an invalid prop, nothing changes. Each operation is {id, props} where props can include: ${Object.keys(batchPropsSchema.entries).join(", ")}. Runs all updates with one layout recompute.`,
96
89
  execution: {
97
90
  kind: "sync",
98
91
  mutation: "document"
99
92
  },
100
- input: v.strictObject({ operations: v.pipe(v.string(), v.description("JSON array: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]")) }),
93
+ input: v.strictObject({ operations: v.pipe(v.union([batchOpsSchema, v.string()]), v.description("Array of {\"id\",\"props\"}, or the same array as a JSON string: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]")) }),
101
94
  fonts: (figma, { operations }) => {
102
95
  const ops = parseOperations(operations);
103
96
  if (!Array.isArray(ops)) return [];
104
97
  return ops.flatMap((op) => op.props.auto_resize === void 0 ? [] : textFonts(figma, op.id));
105
98
  },
106
- execute: (figma, { operations }) => {
99
+ execute(figma, { operations }) {
107
100
  const ops = parseOperations(operations);
108
101
  if (!Array.isArray(ops)) return ops;
109
- const results = [];
110
- const errors = [];
102
+ const targets = [];
111
103
  for (const op of ops) {
112
104
  const node = figma.getNodeById(op.id);
113
- if (!node) {
114
- errors.push(`Node "${op.id}" not found`);
115
- continue;
116
- }
117
- const updated = applyBatchProps(node, op.props);
105
+ if (!node) return nodeNotFound(op.id);
106
+ targets.push({
107
+ node,
108
+ props: op.props
109
+ });
110
+ }
111
+ const results = [];
112
+ for (const { node, props } of targets) {
113
+ applyBatchProps(node, props);
114
+ const updated = Object.keys(props);
118
115
  if (updated.length > 0) results.push({
119
- id: op.id,
116
+ id: node.id,
120
117
  updated
121
118
  });
122
119
  }
123
120
  const out = { updated: results.length };
124
121
  if (results.length > 0) out.results = results;
125
- if (errors.length > 0) out.errors = errors;
126
122
  return out;
127
123
  }
128
124
  });
@@ -1 +1 @@
1
- {"version":3,"file":"batch.js","names":[],"sources":["../../../src/tools/structure/batch.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { textFonts } from '#core/tools/modify/text'\nimport { defineTool } from '#core/tools/schema'\n\nconst batchOpsSchema = v.array(\n v.object({ id: v.string(), props: v.record(v.string(), v.unknown()) })\n)\ntype BatchOp = v.InferOutput<typeof batchOpsSchema>[number]\n\n/** The operations a call names, or why they cannot be read. */\nfunction parseOperations(operations: string): BatchOp[] | { error: string } {\n const json = v.safeParse(v.pipe(v.string(), v.parseJson()), operations)\n if (!json.success) return { error: 'Invalid JSON in operations' }\n const ops = v.safeParse(batchOpsSchema, json.output)\n if (!ops.success) return { error: 'operations must be a JSON array of {id, props}' }\n return ops.output\n}\n\nfunction str(value: unknown): string {\n return typeof value === 'string' ? value : ''\n}\n\nfunction num(value: unknown): number {\n return typeof value === 'number' ? value : 0\n}\n\nfunction applyBatchProps(node: FigmaNodeProxy, props: Record<string, unknown>): string[] {\n const updated: string[] = []\n\n if (props.spacing !== undefined) {\n node.itemSpacing = num(props.spacing)\n updated.push('spacing')\n }\n if (props.padding !== undefined) {\n const value = num(props.padding)\n node.paddingTop = value\n node.paddingRight = value\n node.paddingBottom = value\n node.paddingLeft = value\n updated.push('padding')\n }\n if (props.padding_horizontal !== undefined) {\n node.paddingLeft = num(props.padding_horizontal)\n node.paddingRight = num(props.padding_horizontal)\n updated.push('padding_horizontal')\n }\n if (props.padding_vertical !== undefined) {\n node.paddingTop = num(props.padding_vertical)\n node.paddingBottom = num(props.padding_vertical)\n updated.push('padding_vertical')\n }\n if (props.counter_align !== undefined) {\n node.counterAxisAlignItems = str(props.counter_align)\n updated.push('counter_align')\n }\n if (props.align !== undefined) {\n node.primaryAxisAlignItems = str(props.align)\n updated.push('align')\n }\n if (props.sizing_horizontal !== undefined) {\n node.layoutSizingHorizontal = str(props.sizing_horizontal)\n updated.push('sizing_horizontal')\n }\n if (props.sizing_vertical !== undefined) {\n node.layoutSizingVertical = str(props.sizing_vertical)\n updated.push('sizing_vertical')\n }\n if (props.grow !== undefined) {\n node.layoutGrow = num(props.grow)\n updated.push('grow')\n }\n if (props.name !== undefined) {\n node.name = str(props.name)\n updated.push('name')\n }\n if (props.visible !== undefined) {\n node.visible = Boolean(props.visible)\n updated.push('visible')\n }\n if (props.corner_radius !== undefined) {\n node.cornerRadius = num(props.corner_radius)\n updated.push('corner_radius')\n }\n if (props.opacity !== undefined) {\n node.opacity = num(props.opacity)\n updated.push('opacity')\n }\n if (props.auto_resize !== undefined) {\n node.textAutoResize = str(props.auto_resize)\n updated.push('auto_resize')\n }\n if (props.direction !== undefined) {\n node.layoutMode = str(props.direction) as 'HORIZONTAL' | 'VERTICAL'\n updated.push('direction')\n }\n\n return updated\n}\n\nexport const batchUpdate = defineTool({\n name: 'batch_update',\n\n description:\n 'Execute multiple modifications in one call. Each operation is {id, props} where props can include: spacing, padding, padding_horizontal, padding_vertical, counter_align, sizing_horizontal, sizing_vertical, grow, name, visible, corner_radius, auto_resize (for text), direction. Runs all updates with one layout recompute.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n operations: v.pipe(\n v.string(),\n v.description(\n 'JSON array: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]'\n )\n )\n }),\n // Text that resizes itself lays out again, so its fonts load first.\n fonts: (figma, { operations }) => {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return []\n return ops.flatMap((op) => (op.props.auto_resize === undefined ? [] : textFonts(figma, op.id)))\n },\n execute: (figma, { operations }) => {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return ops\n\n const results: Array<{ id: string; updated: string[] }> = []\n const errors: string[] = []\n\n for (const op of ops) {\n const node = figma.getNodeById(op.id)\n if (!node) {\n errors.push(`Node \"${op.id}\" not found`)\n continue\n }\n const updated = applyBatchProps(node, op.props)\n if (updated.length > 0) results.push({ id: op.id, updated })\n }\n\n const out: Record<string, unknown> = { updated: results.length }\n if (results.length > 0) out.results = results\n if (errors.length > 0) out.errors = errors\n return out\n }\n})\n"],"mappings":";;;;AAMA,MAAM,iBAAiB,EAAE,MACvB,EAAE,OAAO;CAAE,IAAI,EAAE,OAAO;CAAG,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAAE,CAAC,CACvE;;AAIA,SAAS,gBAAgB,YAAmD;CAC1E,MAAM,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,UAAU;CACtE,IAAI,CAAC,KAAK,SAAS,OAAO,EAAE,OAAO,6BAA6B;CAChE,MAAM,MAAM,EAAE,UAAU,gBAAgB,KAAK,MAAM;CACnD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E;CAChG;CACA,UAAU,OAAO,EAAE,iBAAiB;EAClC,MAAM,MAAM,gBAAgB,UAAU;EACtC,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,OAAO;EAEhC,MAAM,UAAoD,CAAC;EAC3D,MAAM,SAAmB,CAAC;EAE1B,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,OAAO,MAAM,YAAY,GAAG,EAAE;GACpC,IAAI,CAAC,MAAM;IACT,OAAO,KAAK,SAAS,GAAG,GAAG,YAAY;IACvC;GACF;GACA,MAAM,UAAU,gBAAgB,MAAM,GAAG,KAAK;GAC9C,IAAI,QAAQ,SAAS,GAAG,QAAQ,KAAK;IAAE,IAAI,GAAG;IAAI;GAAQ,CAAC;EAC7D;EAEA,MAAM,MAA+B,EAAE,SAAS,QAAQ,OAAO;EAC/D,IAAI,QAAQ,SAAS,GAAG,IAAI,UAAU;EACtC,IAAI,OAAO,SAAS,GAAG,IAAI,SAAS;EACpC,OAAO;CACT;AACF,CAAC"}
1
+ {"version":3,"file":"batch.js","names":[],"sources":["../../../src/tools/structure/batch.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { LayoutAlign } from '@pairdraw/scene-graph'\n\nimport type { FigmaNodeProxy } from '#core/figma-api'\nimport { textFonts } from '#core/tools/modify/text'\nimport { defineTool, nodeNotFound, toolNumber } from '#core/tools/schema'\n\nconst nonNegative = () => toolNumber(v.pipe(v.number(), v.minValue(0)))\n\n/** The primary-axis alignments, from the type the graph stores, so the list cannot drift. */\nconst layoutAligns = [\n 'MIN',\n 'CENTER',\n 'MAX',\n 'SPACE_BETWEEN',\n 'SPACE_AROUND'\n] as const satisfies readonly LayoutAlign[]\n\n/** Every prop an operation may set; anything else rejects the whole batch. */\nconst batchPropsSchema = v.strictObject({\n spacing: v.optional(nonNegative()),\n padding: v.optional(nonNegative()),\n padding_horizontal: v.optional(nonNegative()),\n padding_vertical: v.optional(nonNegative()),\n align: v.optional(v.picklist(layoutAligns)),\n counter_align: v.optional(v.picklist(['MIN', 'CENTER', 'MAX', 'STRETCH'])),\n sizing_horizontal: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n sizing_vertical: v.optional(v.picklist(['FIXED', 'HUG', 'FILL'])),\n grow: v.optional(nonNegative()),\n name: v.optional(v.string()),\n visible: v.optional(v.boolean()),\n corner_radius: v.optional(nonNegative()),\n opacity: v.optional(toolNumber(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))),\n auto_resize: v.optional(v.picklist(['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE'])),\n direction: v.optional(v.picklist(['HORIZONTAL', 'VERTICAL']))\n})\ntype BatchProps = v.InferOutput<typeof batchPropsSchema>\n\nconst batchOpsSchema = v.array(v.strictObject({ id: v.string(), props: batchPropsSchema }))\ntype BatchOp = v.InferOutput<typeof batchOpsSchema>[number]\n\n/** The operations a call names, or every problem with them. */\nfunction parseOperations(operations: BatchOp[] | string): BatchOp[] | { error: string } {\n const result =\n typeof operations === 'string'\n ? v.safeParse(v.pipe(v.string(), v.parseJson(), batchOpsSchema), operations)\n : v.safeParse(batchOpsSchema, operations)\n if (result.success) return result.output\n return { error: `Invalid operations:\\n${v.summarize(result.issues)}` }\n}\n\nfunction applyBatchProps(node: FigmaNodeProxy, props: BatchProps): void {\n if (props.spacing !== undefined) node.itemSpacing = props.spacing\n if (props.padding !== undefined) {\n node.paddingTop = props.padding\n node.paddingRight = props.padding\n node.paddingBottom = props.padding\n node.paddingLeft = props.padding\n }\n if (props.padding_horizontal !== undefined) {\n node.paddingLeft = props.padding_horizontal\n node.paddingRight = props.padding_horizontal\n }\n if (props.padding_vertical !== undefined) {\n node.paddingTop = props.padding_vertical\n node.paddingBottom = props.padding_vertical\n }\n if (props.align !== undefined) node.primaryAxisAlignItems = props.align\n if (props.counter_align !== undefined) node.counterAxisAlignItems = props.counter_align\n if (props.sizing_horizontal !== undefined) node.layoutSizingHorizontal = props.sizing_horizontal\n if (props.sizing_vertical !== undefined) node.layoutSizingVertical = props.sizing_vertical\n if (props.grow !== undefined) node.layoutGrow = props.grow\n if (props.name !== undefined) node.name = props.name\n if (props.visible !== undefined) node.visible = props.visible\n if (props.corner_radius !== undefined) node.cornerRadius = props.corner_radius\n if (props.opacity !== undefined) node.opacity = props.opacity\n if (props.auto_resize !== undefined) node.textAutoResize = props.auto_resize\n if (props.direction !== undefined) node.layoutMode = props.direction\n}\n\nexport const batchUpdate = defineTool({\n name: 'batch_update',\n\n description:\n 'Execute multiple modifications in one call, all or nothing: if any operation names a missing node or an invalid prop, nothing changes. ' +\n `Each operation is {id, props} where props can include: ${Object.keys(batchPropsSchema.entries).join(', ')}. ` +\n 'Runs all updates with one layout recompute.',\n // A document edit, not an atomic property transaction: the runner rolls a thrown batch back\n // whole at the cost of the layers it touched, and documents past the atomic path's node limit\n // still batch-edit. The validate-then-apply above keeps the call all-or-nothing either way.\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n operations: v.pipe(\n v.union([batchOpsSchema, v.string()]),\n v.description(\n 'Array of {\"id\",\"props\"}, or the same array as a JSON string: [{\"id\":\"0:5\",\"props\":{\"spacing\":8}},{\"id\":\"0:6\",\"props\":{\"sizing_horizontal\":\"FILL\",\"grow\":1}}]'\n )\n )\n }),\n // Text that resizes itself lays out again, so its fonts load first.\n fonts: (figma, { operations }) => {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return []\n return ops.flatMap((op) => (op.props.auto_resize === undefined ? [] : textFonts(figma, op.id)))\n },\n execute(figma, { operations }) {\n const ops = parseOperations(operations)\n if (!Array.isArray(ops)) return ops\n\n // Find every layer before writing, so a missing one leaves the document untouched.\n const targets: Array<{ node: FigmaNodeProxy; props: BatchProps }> = []\n for (const op of ops) {\n const node = figma.getNodeById(op.id)\n if (!node) return nodeNotFound(op.id)\n targets.push({ node, props: op.props })\n }\n\n const results: Array<{ id: string; updated: string[] }> = []\n for (const { node, props } of targets) {\n applyBatchProps(node, props)\n const updated = Object.keys(props)\n if (updated.length > 0) results.push({ id: node.id, updated })\n }\n\n const out: Record<string, unknown> = { updated: results.length }\n if (results.length > 0) out.results = results\n return out\n }\n})\n"],"mappings":";;;;AAQA,MAAM,oBAAoB,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;;AAYtE,MAAM,mBAAmB,EAAE,aAAa;CACtC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,SAAS,EAAE,SAAS,YAAY,CAAC;CACjC,oBAAoB,EAAE,SAAS,YAAY,CAAC;CAC5C,kBAAkB,EAAE,SAAS,YAAY,CAAC;CAC1C,OAAO,EAAE,SAAS,EAAE,SAAS;EAb7B;EACA;EACA;EACA;EACA;CASwC,CAAC,CAAC;CAC1C,eAAe,EAAE,SAAS,EAAE,SAAS;EAAC;EAAO;EAAU;EAAO;CAAS,CAAC,CAAC;CACzE,mBAAmB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAClE,iBAAiB,EAAE,SAAS,EAAE,SAAS;EAAC;EAAS;EAAO;CAAM,CAAC,CAAC;CAChE,MAAM,EAAE,SAAS,YAAY,CAAC;CAC9B,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC;CAC3B,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC/B,eAAe,EAAE,SAAS,YAAY,CAAC;CACvC,SAAS,EAAE,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CAChF,aAAa,EAAE,SAAS,EAAE,SAAS;EAAC;EAAQ;EAAoB;EAAU;CAAU,CAAC,CAAC;CACtF,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,cAAc,UAAU,CAAC,CAAC;AAC9D,CAAC;AAGD,MAAM,iBAAiB,EAAE,MAAM,EAAE,aAAa;CAAE,IAAI,EAAE,OAAO;CAAG,OAAO;AAAiB,CAAC,CAAC;;A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Q,SAAS,GAAG,IAAI,UAAU;EACtC,OAAO;CACT;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"values.d.ts","names":[],"sources":["../../../src/tools/variables/values.ts"],"mappings":";;cAuBa,gBAAA;cA+BA,aAAA;cAmBA,gBAAA"}
1
+ {"version":3,"file":"values.d.ts","names":[],"sources":["../../../src/tools/variables/values.ts"],"mappings":";;cAuBa,gBAAA;cAgCA,aAAA;cAqBA,gBAAA"}
@@ -1,5 +1,5 @@
1
1
  import { defineTool } from "../schema.js";
2
- import { parseColor } from "@pairdraw/scene-graph/color";
2
+ import { tryParseColor } from "@pairdraw/scene-graph/color";
3
3
  import * as v from "valibot";
4
4
  //#region src/tools/variables/values.ts
5
5
  /** A parsed value as `setValueForMode` takes it; a colour gets a copy of its own. */
@@ -7,7 +7,7 @@ function figmaValue(value) {
7
7
  return typeof value === "object" ? { ...value } : value;
8
8
  }
9
9
  function parseVariableValue(type, value) {
10
- if (type === "COLOR") return parseColor(value);
10
+ if (type === "COLOR") return tryParseColor(value);
11
11
  if (type === "FLOAT") return Number(value);
12
12
  if (type === "BOOLEAN") return value === "true";
13
13
  return value;
@@ -33,6 +33,7 @@ const createVariable = defineTool({
33
33
  execute: (figma, args) => {
34
34
  const type = args.type;
35
35
  const value = args.value === void 0 ? void 0 : parseVariableValue(type, args.value);
36
+ if (value === null) return { error: `"${args.value}" is not a ${type} value` };
36
37
  if (typeof value === "number" && !Number.isFinite(value)) return { error: `"${args.value}" is not a number` };
37
38
  const variable = figma.variables.createVariable(args.name, args.collection_id, type);
38
39
  if (value !== void 0) for (const modeId of Object.keys(variable.valuesByMode)) variable.setValueForMode(modeId, figmaValue(value));
@@ -55,6 +56,7 @@ const setVariable = defineTool({
55
56
  const variable = figma.variables.getVariableById(args.id);
56
57
  if (!variable) return { error: `Variable "${args.id}" not found` };
57
58
  const parsedValue = parseVariableValue(variable.resolvedType, args.value);
59
+ if (parsedValue === null) return { error: `"${args.value}" is not a ${variable.resolvedType} value` };
58
60
  variable.setValueForMode(args.mode, figmaValue(parsedValue));
59
61
  return {
60
62
  id: args.id,
@@ -1 +1 @@
1
- {"version":3,"file":"values.js","names":[],"sources":["../../../src/tools/variables/values.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { VariableType } from '@pairdraw/scene-graph'\nimport { parseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaVariableValue } from '#core/figma-api'\nimport { defineTool } from '#core/tools/schema'\n\n/** A parsed value as `setValueForMode` takes it; a colour gets a copy of its own. */\nfunction figmaValue(value: ToolValue): FigmaVariableValue {\n return typeof value === 'object' ? { ...value } : value\n}\n\ntype ToolValue = Color | number | string | boolean\n\nfunction parseVariableValue(type: VariableType, value: string): ToolValue {\n if (type === 'COLOR') return parseColor(value)\n if (type === 'FLOAT') return Number(value)\n if (type === 'BOOLEAN') return value === 'true'\n return value\n}\n\nexport const createVariable = defineTool({\n name: 'create_variable',\n\n description: 'Create a new variable in a collection.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n name: v.pipe(v.string(), v.description('Variable name')),\n type: v.pipe(\n v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']),\n v.description('Variable type')\n ),\n collection_id: v.pipe(v.string(), v.description('Collection ID')),\n value: v.optional(\n v.pipe(v.string(), v.description('Initial value (hex for COLOR, number for FLOAT, etc.)'))\n )\n }),\n execute: (figma, args) => {\n const type = args.type\n // The value is checked first, so a value the variable cannot hold creates nothing.\n const value = args.value === undefined ? undefined : parseVariableValue(type, args.value)\n if (typeof value === 'number' && !Number.isFinite(value))\n return { error: `\"${args.value}\" is not a number` }\n const variable = figma.variables.createVariable(args.name, args.collection_id, type)\n if (value !== undefined) {\n for (const modeId of Object.keys(variable.valuesByMode))\n variable.setValueForMode(modeId, figmaValue(value))\n }\n return figma.graph.variables.get(variable.id)\n }\n})\n\nexport const setVariable = defineTool({\n name: 'set_variable',\n\n description: 'Set the value of a variable for a specific mode.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Variable ID')),\n mode: v.pipe(v.string(), v.description('Mode ID')),\n value: v.pipe(v.string(), v.description('Value (hex for COLOR, number for FLOAT, etc.)'))\n }),\n execute: (figma, args) => {\n const variable = figma.variables.getVariableById(args.id)\n if (!variable) return { error: `Variable \"${args.id}\" not found` }\n const parsedValue = parseVariableValue(variable.resolvedType, args.value)\n variable.setValueForMode(args.mode, figmaValue(parsedValue))\n return { id: args.id, mode: args.mode, value: parsedValue }\n }\n})\n\nexport const deleteVariable = defineTool({\n name: 'delete_variable',\n\n description: 'Delete a variable.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Variable ID'))\n }),\n execute: (figma, { id }) => {\n const variable = figma.variables.getVariableById(id)\n if (!variable) return { error: `Variable \"${id}\" not found` }\n variable.remove()\n return { deleted: id }\n }\n})\n"],"mappings":";;;;;AAUA,SAAS,WAAW,OAAsC;CACxD,OAAO,OAAO,UAAU,WAAW,EAAE,GAAG,MAAM,IAAI;AACpD;AAIA,SAAS,mBAAmB,MAAoB,OAA0B;CACxE,IAAI,SAAS,SAAS,OAAO,WAAW,KAAK;CAC7C,IAAI,SAAS,SAAS,OAAO,OAAO,KAAK;CACzC,IAAI,SAAS,WAAW,OAAO,UAAU;CACzC,OAAO;AACT;AAEA,MAAa,iBAAiB,WAAW;CACvC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa;EACpB,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,eAAe,CAAC;EACvD,MAAM,EAAE,KACN,EAAE,SAAS;GAAC;GAAS;GAAS;GAAU;EAAS,CAAC,GAClD,EAAE,YAAY,eAAe,CAC/B;EACA,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,eAAe,CAAC;E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C;AAED,MAAa,iBAAiB,WAAW;CACvC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa,EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,aAAa,CAAC,EACrD,CAAC;CACD,UAAU,OAAO,EAAE,SAAS;EAC1B,MAAM,WAAW,MAAM,UAAU,gBAAgB,EAAE;EACnD,IAAI,CAAC,UAAU,OAAO,EAAE,OAAO,aAAa,GAAG,aAAa;EAC5D,SAAS,OAAO;EAChB,OAAO,EAAE,SAAS,GAAG;CACvB;AACF,CAAC"}
1
+ {"version":3,"file":"values.js","names":[],"sources":["../../../src/tools/variables/values.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport type { VariableType } from '@pairdraw/scene-graph'\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FigmaVariableValue } from '#core/figma-api'\nimport { defineTool } from '#core/tools/schema'\n\n/** A parsed value as `setValueForMode` takes it; a colour gets a copy of its own. */\nfunction figmaValue(value: ToolValue): FigmaVariableValue {\n return typeof value === 'object' ? { ...value } : value\n}\n\ntype ToolValue = Color | number | string | boolean\n\nfunction parseVariableValue(type: VariableType, value: string): ToolValue | null {\n if (type === 'COLOR') return tryParseColor(value)\n if (type === 'FLOAT') return Number(value)\n if (type === 'BOOLEAN') return value === 'true'\n return value\n}\n\nexport const createVariable = defineTool({\n name: 'create_variable',\n\n description: 'Create a new variable in a collection.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n name: v.pipe(v.string(), v.description('Variable name')),\n type: v.pipe(\n v.picklist(['COLOR', 'FLOAT', 'STRING', 'BOOLEAN']),\n v.description('Variable type')\n ),\n collection_id: v.pipe(v.string(), v.description('Collection ID')),\n value: v.optional(\n v.pipe(v.string(), v.description('Initial value (hex for COLOR, number for FLOAT, etc.)'))\n )\n }),\n execute: (figma, args) => {\n const type = args.type\n // The value is checked first, so a value the variable cannot hold creates nothing.\n const value = args.value === undefined ? undefined : parseVariableValue(type, args.value)\n if (value === null) return { error: `\"${args.value}\" is not a ${type} value` }\n if (typeof value === 'number' && !Number.isFinite(value))\n return { error: `\"${args.value}\" is not a number` }\n const variable = figma.variables.createVariable(args.name, args.collection_id, type)\n if (value !== undefined) {\n for (const modeId of Object.keys(variable.valuesByMode))\n variable.setValueForMode(modeId, figmaValue(value))\n }\n return figma.graph.variables.get(variable.id)\n }\n})\n\nexport const setVariable = defineTool({\n name: 'set_variable',\n\n description: 'Set the value of a variable for a specific mode.',\n execution: { kind: 'sync', mutation: 'properties' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Variable ID')),\n mode: v.pipe(v.string(), v.description('Mode ID')),\n value: v.pipe(v.string(), v.description('Value (hex for COLOR, number for FLOAT, etc.)'))\n }),\n execute: (figma, args) => {\n const variable = figma.variables.getVariableById(args.id)\n if (!variable) return { error: `Variable \"${args.id}\" not found` }\n const parsedValue = parseVariableValue(variable.resolvedType, args.value)\n if (parsedValue === null)\n return { error: `\"${args.value}\" is not a ${variable.resolvedType} value` }\n variable.setValueForMode(args.mode, figmaValue(parsedValue))\n return { id: args.id, mode: args.mode, value: parsedValue }\n }\n})\n\nexport const deleteVariable = defineTool({\n name: 'delete_variable',\n\n description: 'Delete a variable.',\n execution: { kind: 'sync', mutation: 'document' },\n input: v.strictObject({\n id: v.pipe(v.string(), v.description('Variable ID'))\n }),\n execute: (figma, { id }) => {\n const variable = figma.variables.getVariableById(id)\n if (!variable) return { error: `Variable \"${id}\" not found` }\n variable.remove()\n return { deleted: id }\n }\n})\n"],"mappings":";;;;;AAUA,SAAS,WAAW,OAAsC;CACxD,OAAO,OAAO,UAAU,WAAW,EAAE,GAAG,MAAM,IAAI;AACpD;AAIA,SAAS,mBAAmB,MAAoB,OAAiC;CAC/E,IAAI,SAAS,SAAS,OAAO,cAAc,KAAK;CAChD,IAAI,SAAS,SAAS,OAAO,O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EAAE,YAAY,aAAa,CAAC;EACnD,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,SAAS,CAAC;EACjD,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,+CAA+C,CAAC;CAC1F,CAAC;CACD,UAAU,OAAO,SAAS;EACxB,MAAM,WAAW,MAAM,UAAU,gBAAgB,KAAK,EAAE;EACxD,IAAI,CAAC,UAAU,OAAO,EAAE,OAAO,aAAa,KAAK,GAAG,aAAa;EACjE,MAAM,cAAc,mBAAmB,SAAS,cAAc,KAAK,KAAK;EACxE,IAAI,gBAAgB,MAClB,OAAO,EAAE,OAAO,IAAI,KAAK,MAAM,aAAa,SAAS,aAAa,QAAQ;EAC5E,SAAS,gBAAgB,KAAK,MAAM,WAAW,WAAW,CAAC;EAC3D,OAAO;GAAE,IAAI,KAAK;GAAI,MAAM,KAAK;GAAM,OAAO;EAAY;CAC5D;AACF,CAAC;AAED,MAAa,iBAAiB,WAAW;CACvC,MAAM;CAEN,aAAa;CACb,WAAW;EAAE,MAAM;EAAQ,UAAU;CAAW;CAChD,OAAO,EAAE,aAAa,EACpB,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,YAAY,aAAa,CAAC,EACrD,CAAC;CACD,UAAU,OAAO,EAAE,SAAS;EAC1B,MAAM,WAAW,MAAM,UAAU,gBAAgB,EAAE;EACnD,IAAI,CAAC,UAAU,OAAO,EAAE,OAAO,aAAa,GAAG,aAAa;EAC5D,SAAS,OAAO;EAChB,OAAO,EAAE,SAAS,GAAG;CACvB;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"export.d.ts","names":[],"sources":["../../../src/tools/vector/export.ts"],"mappings":";;;;cA2Ba;;;;;iBA8BG,mBACd,eACA,gBACA,eACA;cAMW,WAAA;cAiBA,WAAA;cAyEA,aAAA;cAqFA,YAAA"}
1
+ {"version":3,"file":"export.d.ts","names":[],"sources":["../../../src/tools/vector/export.ts"],"mappings":";;;;cA2Ba;;;;;iBA8BG,mBACd,eACA,gBACA,eACA;cAMW,WAAA;cAiBA,WAAA;cAyEA,aAAA;cAyFA,YAAA"}
@@ -97,8 +97,11 @@ const exportImage = defineTool({
97
97
  format: v.optional(v.pipe(v.picklist([
98
98
  "PNG",
99
99
  "JPG",
100
- "WEBP"
101
- ]), v.description("Image format")), "PNG"),
100
+ "WEBP",
101
+ "png",
102
+ "jpg",
103
+ "webp"
104
+ ]), v.description("Image format: PNG, JPG, or WEBP")), "PNG"),
102
105
  quality: v.optional(toolNumber(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(100), v.description("JPG and WEBP quality from 1 to 100 (default: 90). PNG ignores it.")))),
103
106
  ...rasterScaleInputs
104
107
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","names":[],"sources":["../../../src/tools/vector/export.ts"],"sourcesContent":["import { fromUint8Array } from 'js-base64'\nimport * as v from 'valibot'\n\nimport { PDF_MODES, PDFPlanError, planPDFPages } from '#core/io/formats/pdf/plan'\nimport type { RasterExportFormat } from '#core/io/formats/raster'\nimport { getHTMLToolHost } from '#core/tools/html-host'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nconst exportInputs = {\n ids: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Node IDs to export. Omit to export all top-level nodes on the current page.')\n )\n ),\n path: v.optional(\n v.pipe(\n v.string(),\n v.description(\n 'Write exported data to this path instead of returning it (requires PAIRDRAW_MCP_ROOT)'\n )\n )\n )\n}\n\n/** Scale inputs shared by every tool that returns a raster image to a model. */\nexport const rasterScaleInputs = {\n scale: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(0.1),\n v.maxValue(4),\n v.description(\n 'Export scale multiplier before the maximum-edge limit is applied (default: 1)'\n )\n )\n ),\n 1\n ),\n maxEdge: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(64),\n v.maxValue(4096),\n v.description(\n 'Maximum output width or height in pixels. Preserves aspect ratio and never upscales. Defaults to 1280 for bounded model input.'\n )\n )\n ),\n 1280\n )\n}\n\n/** The requested scale, reduced so the longest edge fits `maxEdge`; 0 for empty content. */\nexport function boundedRasterScale(\n width: number,\n height: number,\n scale: number,\n maxEdge: number\n): number {\n const longestEdge = Math.max(width, height)\n return longestEdge > 0 ? Math.min(scale, maxEdge / longestEdge) : 0\n}\n\nexport const exportSVG = defineTool({\n name: 'export_svg',\n description: 'Export nodes as SVG markup. Returns the SVG string.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({ ...exportInputs }),\n execute: async (figma, args) => {\n const { renderNodesToLaidOutSVG } = await import('#core/io/formats/svg/text/layout')\n const pageId = figma.currentPageId\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const svg = await renderNodesToLaidOutSVG(figma.graph, pageId, ids)\n if (!svg) return { error: 'No visible nodes to export' }\n return { svg }\n }\n})\n\nexport const exportPDF = defineTool({\n name: 'export_pdf',\n description:\n 'Export nodes as a vector PDF document. Text remains selectable and keeps its line breaks, paths stay sharp at any zoom. Returns base64-encoded PDF data and the size of each PDF page. ' +\n 'mode \"single\" (default) puts all ids on one PDF page; \"frames\" makes one PDF page per id (or per top-level frame of the current page); \"pages\" makes one PDF page per design page (all pages, or page_ids). ' +\n 'embed_fonts embeds the TrueType file of each font face the text uses, and of a variable font a static file of each instance the text draws (its weight, optical size, and other axes), and reports which faces were embedded and which fell back to a standard PDF font.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n ...exportInputs,\n mode: v.optional(\n v.pipe(\n v.picklist(PDF_MODES),\n v.description(\n '\"single\" (default): one PDF page for all ids. \"frames\": one PDF page per id or top-level frame. \"pages\": one PDF page per design page.'\n )\n ),\n 'single'\n ),\n page_ids: v.optional(\n v.pipe(\n v.array(v.string()),\n v.description('mode \"pages\": the design pages to export, in order (default: all pages)')\n )\n ),\n embed_fonts: v.optional(\n v.pipe(\n v.boolean(),\n v.description(\n 'Embed the fonts the text uses (default false: standard PDF fonts). Makes the file larger.'\n )\n ),\n false\n )\n }),\n execute: async (figma, args) => {\n const [{ exportPDFDocument }, { readPDFPages }] = await Promise.all([\n import('#core/io/formats/pdf/document'),\n import('#core/io/formats/pdf/prepare')\n ])\n try {\n if (args.mode === 'pages') readPDFPages(figma.graph, args.page_ids)\n const specs = planPDFPages(figma.graph, {\n mode: args.mode,\n ids: args.ids,\n pageIds: args.page_ids,\n currentPageId: figma.currentPageId\n })\n const result = await exportPDFDocument(figma.graph, specs, {\n embedFonts: args.embed_fonts,\n layOutPages: args.mode === 'pages'\n })\n if (!result || result.data.length === 0) return { error: 'No visible nodes to export' }\n return {\n mimeType: 'application/pdf',\n base64: fromUint8Array(result.data),\n byteLength: result.data.length,\n pageCount: result.pages.length,\n pages: result.pages.map((page, index) => ({\n page: index + 1,\n ...(page.label ? { name: page.label } : {}),\n width: Math.round(page.width),\n height: Math.round(page.height)\n })),\n ...(result.fonts ? { fonts: result.fonts } : {})\n }\n } catch (error) {\n if (error instanceof PDFPlanError) return { error: error.message }\n throw error\n }\n }\n})\n\nexport const exportImage = defineTool({\n name: 'export_image',\n description:\n 'Export nodes as a raster image (PNG, JPG, or WEBP). Returns base64-encoded image data. Use to visually verify designs. quality sets JPG and WEBP compression.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n ...exportInputs,\n format: v.optional(\n v.pipe(v.picklist(['PNG', 'JPG', 'WEBP']), v.description('Image format')),\n 'PNG'\n ),\n quality: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.integer(),\n v.minValue(1),\n v.maxValue(100),\n v.description('JPG and WEBP quality from 1 to 100 (default: 90). PNG ignores it.')\n )\n )\n ),\n ...rasterScaleInputs\n }),\n execute: async (figma, args) => {\n if (!figma.exportImage) {\n return { error: 'Image export is not available in this environment' }\n }\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const format = args.format.toUpperCase() as RasterExportFormat\n const requestedScale = args.scale\n const maxEdge = args.maxEdge\n const missing = ids.find((id) => !figma.getNodeById(id))\n if (missing) return { error: `Node \"${missing}\" not found` }\n const nodes = ids.map((id) => figma.getNodeById(id)).filter((node) => node !== null)\n if (!nodes.some((node) => node.visible)) return { error: 'No visible nodes to export' }\n const bounds = nodes.reduce(\n (result, node) => {\n const box = node.absoluteBoundingBox\n const minX = Math.min(result.minX, box.x)\n const minY = Math.min(result.minY, box.y)\n const maxX = Math.max(result.maxX, box.x + box.width)\n const maxY = Math.max(result.maxY, box.y + box.height)\n return { minX, minY, maxX, maxY }\n },\n {\n minX: Number.POSITIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY\n }\n )\n const width = bounds.maxX - bounds.minX\n const height = bounds.maxY - bounds.minY\n const boundedScale = boundedRasterScale(width, height, requestedScale, maxEdge)\n if (boundedScale <= 0) return { error: 'No visible nodes to export' }\n // PNG is lossless, so a quality would only be ignored by the encoder.\n const quality = format === 'PNG' ? undefined : args.quality\n const data = await figma.exportImage(ids, {\n scale: boundedScale,\n format,\n ...(quality === undefined ? {} : { quality })\n })\n if (!data || data.length === 0) {\n return { error: 'The renderer returned no image for these nodes' }\n }\n const base64 = fromUint8Array(data)\n const mimeMap = { PNG: 'image/png', JPG: 'image/jpeg', WEBP: 'image/webp' } as const\n return {\n mimeType: mimeMap[format],\n base64,\n byteLength: data.length,\n width: Math.ceil(width * boundedScale),\n height: Math.ceil(height * boundedScale),\n scale: boundedScale,\n ...(quality === undefined ? {} : { quality })\n }\n }\n})\n\n/** How `export_html` styles the markup, by the names `HTMLExportOptions` uses. */\nconst HTML_STYLES = { css: 'inline', tailwind: 'tailwind' } as const\n\nexport const exportHTML = defineTool({\n name: 'export_html',\n description:\n 'Export nodes as HTML code. style \"css\" (default) writes plain CSS: style attributes in a fragment, a stylesheet in a standalone document; \"tailwind\" writes Tailwind utility classes. html \"fragment\" (default) returns markup to paste into a page; \"standalone\" returns a whole document. assets \"inline\" (default) embeds images as data URLs; \"external\", for a standalone document, returns its stylesheet, images, and web fonts as separate files, listed in assets. layer_names writes each layer name as data-name; layer_ids writes each layer ID as data-pairdraw-node-id.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n // A standalone page with separate files downloads the web fonts it ships.\n capabilities: ['document:read', 'network:access'],\n input: v.strictObject({\n ids: exportInputs.ids,\n style: v.optional(\n v.pipe(\n v.picklist(['css', 'tailwind']),\n v.description('\"css\": plain CSS. \"tailwind\": Tailwind utility classes.')\n ),\n 'css'\n ),\n html: v.optional(\n v.pipe(\n v.picklist(['fragment', 'standalone']),\n v.description('\"fragment\": markup for a page. \"standalone\": a complete HTML document.')\n ),\n 'fragment'\n ),\n assets: v.optional(\n v.pipe(\n v.picklist(['inline', 'external']),\n v.description(\n '\"inline\": images as data URLs. \"external\" (standalone only): images and the stylesheet as separate files.'\n )\n ),\n 'inline'\n ),\n layer_names: v.optional(\n v.pipe(\n v.boolean(),\n v.description('Write each layer name as a data-name attribute (default: true)')\n ),\n true\n ),\n layer_ids: v.optional(\n v.pipe(\n v.boolean(),\n v.description(\n 'Write each layer ID as a data-pairdraw-node-id attribute, to map markup back to layers (default: false)'\n )\n ),\n false\n )\n }),\n execute: async (figma, args) => {\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const missing = ids.find((id) => !figma.graph.getNode(id))\n if (missing) return { error: `Node \"${missing}\" not found` }\n if (ids.length === 0) return { error: 'No nodes to export' }\n const { renderNodesToHTML } = await import('#core/io/formats/html')\n const { html, assets } = await renderNodesToHTML(figma.graph, ids, {\n html: args.html,\n style: HTML_STYLES[args.style],\n assets: args.assets,\n fonts: args.html === 'standalone' && args.assets === 'external' ? 'assets' : 'none',\n layerNames: args.layer_names,\n layerIds: args.layer_ids,\n loadTailwindStylesheet: getHTMLToolHost(figma.graph)?.loadTailwindStylesheet\n })\n if (!html) return { error: 'No visible nodes to export' }\n return {\n html,\n ...(assets.length > 0\n ? {\n assets: assets.map(({ path, content }) =>\n typeof content === 'string'\n ? { path, text: content }\n : { path, base64: fromUint8Array(content), byteLength: content.length }\n )\n }\n : {})\n }\n }\n})\n"],"mappings":";;;;;;AAQA,MAAM,eAAe;CACnB,KAAK,EAAE,SACL,EAAE,KACA,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,UAAU,CAAC,GACb,EAAE,YAAY,6EAA6E,CAC7F,CACF;CACA,MAAM,EAAE,SACN,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YACA,uFACF,CACF,CACF;AACF;;AAGA,MAAa,oBAAoB;CAC/B,OAAO,EAAE,SACP,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,SAAS,EAAG,GACd,EAAE,SAAS,CAAC,GACZ,EAAE,YACA,+EACF,CACF,CACF,GACA,CACF;CACA,SAAS,EAAE,SACT,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,SAAS,EAAE,GACb,EAAE,SAAS,IAAI,GACf,EAAE,YACA,gIACF,CACF,CACF,GACA,IACF;AACF;;AAGA,SAAgB,mBACd,OACA,QACA,OACA,SACQ;CACR,MAAM,cAAc,KAAK,IAAI,OAAO,MAAM;CAC1C,OAAO,cAAc,IAAI,KAAK,IAAI,OAAO,UAAU,WAAW,IAAI;AACpE;AAEA,MAAa,YAAY,WAAW;CAClC,MAAM;CACN,aAAa;CACb,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,UAAU,EAAE,QAAQ,MAAM;CAC1B,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;CACzC,SAAS,OAAO,OAAO,SAAS;EAC9B,MAAM,EAAE,4BAA4B,MAAM,OAAO;EACjD,MAAM,SAAS,MAAM;EACrB,MAAM,MACJ,KAAK,OAAO,KAAK,IAAI,SAAS,IAAI,KAAK,MAAM,MAAM,YAA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AAK;GACjE,MAAM,KAAK;GACX,OAAO,YAAY,KAAK;GACxB,QAAQ,KAAK;GACb,OAAO,KAAK,SAAS,gBAAgB,KAAK,WAAW,aAAa,WAAW;GAC7E,YAAY,KAAK;GACjB,UAAU,KAAK;GACf,wBAAwB,gBAAgB,MAAM,KAAK,CAAC,EAAE;EACxD,CAAC;EACD,IAAI,CAAC,MAAM,OAAO,EAAE,OAAO,6BAA6B;EACxD,OAAO;GACL;GACA,GAAI,OAAO,SAAS,IAChB,EACE,QAAQ,OAAO,KAAK,EAAE,MAAM,cAC1B,OAAO,YAAY,WACf;IAAE;IAAM,MAAM;GAAQ,IACtB;IAAE;IAAM,QAAQ,eAAe,OAAO;IAAG,YAAY,QAAQ;GAAO,CAC1E,EACF,IACA,CAAC;EACP;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"export.js","names":[],"sources":["../../../src/tools/vector/export.ts"],"sourcesContent":["import { fromUint8Array } from 'js-base64'\nimport * as v from 'valibot'\n\nimport { PDF_MODES, PDFPlanError, planPDFPages } from '#core/io/formats/pdf/plan'\nimport type { RasterExportFormat } from '#core/io/formats/raster'\nimport { getHTMLToolHost } from '#core/tools/html-host'\nimport { toolNumber, defineTool } from '#core/tools/schema'\n\nconst exportInputs = {\n ids: v.optional(\n v.pipe(\n v.array(v.string()),\n v.minLength(1),\n v.description('Node IDs to export. Omit to export all top-level nodes on the current page.')\n )\n ),\n path: v.optional(\n v.pipe(\n v.string(),\n v.description(\n 'Write exported data to this path instead of returning it (requires PAIRDRAW_MCP_ROOT)'\n )\n )\n )\n}\n\n/** Scale inputs shared by every tool that returns a raster image to a model. */\nexport const rasterScaleInputs = {\n scale: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(0.1),\n v.maxValue(4),\n v.description(\n 'Export scale multiplier before the maximum-edge limit is applied (default: 1)'\n )\n )\n ),\n 1\n ),\n maxEdge: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.minValue(64),\n v.maxValue(4096),\n v.description(\n 'Maximum output width or height in pixels. Preserves aspect ratio and never upscales. Defaults to 1280 for bounded model input.'\n )\n )\n ),\n 1280\n )\n}\n\n/** The requested scale, reduced so the longest edge fits `maxEdge`; 0 for empty content. */\nexport function boundedRasterScale(\n width: number,\n height: number,\n scale: number,\n maxEdge: number\n): number {\n const longestEdge = Math.max(width, height)\n return longestEdge > 0 ? Math.min(scale, maxEdge / longestEdge) : 0\n}\n\nexport const exportSVG = defineTool({\n name: 'export_svg',\n description: 'Export nodes as SVG markup. Returns the SVG string.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({ ...exportInputs }),\n execute: async (figma, args) => {\n const { renderNodesToLaidOutSVG } = await import('#core/io/formats/svg/text/layout')\n const pageId = figma.currentPageId\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const svg = await renderNodesToLaidOutSVG(figma.graph, pageId, ids)\n if (!svg) return { error: 'No visible nodes to export' }\n return { svg }\n }\n})\n\nexport const exportPDF = defineTool({\n name: 'export_pdf',\n description:\n 'Export nodes as a vector PDF document. Text remains selectable and keeps its line breaks, paths stay sharp at any zoom. Returns base64-encoded PDF data and the size of each PDF page. ' +\n 'mode \"single\" (default) puts all ids on one PDF page; \"frames\" makes one PDF page per id (or per top-level frame of the current page); \"pages\" makes one PDF page per design page (all pages, or page_ids). ' +\n 'embed_fonts embeds the TrueType file of each font face the text uses, and of a variable font a static file of each instance the text draws (its weight, optical size, and other axes), and reports which faces were embedded and which fell back to a standard PDF font.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n ...exportInputs,\n mode: v.optional(\n v.pipe(\n v.picklist(PDF_MODES),\n v.description(\n '\"single\" (default): one PDF page for all ids. \"frames\": one PDF page per id or top-level frame. \"pages\": one PDF page per design page.'\n )\n ),\n 'single'\n ),\n page_ids: v.optional(\n v.pipe(\n v.array(v.string()),\n v.description('mode \"pages\": the design pages to export, in order (default: all pages)')\n )\n ),\n embed_fonts: v.optional(\n v.pipe(\n v.boolean(),\n v.description(\n 'Embed the fonts the text uses (default false: standard PDF fonts). Makes the file larger.'\n )\n ),\n false\n )\n }),\n execute: async (figma, args) => {\n const [{ exportPDFDocument }, { readPDFPages }] = await Promise.all([\n import('#core/io/formats/pdf/document'),\n import('#core/io/formats/pdf/prepare')\n ])\n try {\n if (args.mode === 'pages') readPDFPages(figma.graph, args.page_ids)\n const specs = planPDFPages(figma.graph, {\n mode: args.mode,\n ids: args.ids,\n pageIds: args.page_ids,\n currentPageId: figma.currentPageId\n })\n const result = await exportPDFDocument(figma.graph, specs, {\n embedFonts: args.embed_fonts,\n layOutPages: args.mode === 'pages'\n })\n if (!result || result.data.length === 0) return { error: 'No visible nodes to export' }\n return {\n mimeType: 'application/pdf',\n base64: fromUint8Array(result.data),\n byteLength: result.data.length,\n pageCount: result.pages.length,\n pages: result.pages.map((page, index) => ({\n page: index + 1,\n ...(page.label ? { name: page.label } : {}),\n width: Math.round(page.width),\n height: Math.round(page.height)\n })),\n ...(result.fonts ? { fonts: result.fonts } : {})\n }\n } catch (error) {\n if (error instanceof PDFPlanError) return { error: error.message }\n throw error\n }\n }\n})\n\nexport const exportImage = defineTool({\n name: 'export_image',\n description:\n 'Export nodes as a raster image (PNG, JPG, or WEBP). Returns base64-encoded image data. Use to visually verify designs. quality sets JPG and WEBP compression.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n input: v.strictObject({\n ...exportInputs,\n // Letter case does not matter here, as it does not for the other tools' options.\n format: v.optional(\n v.pipe(\n v.picklist(['PNG', 'JPG', 'WEBP', 'png', 'jpg', 'webp']),\n v.description('Image format: PNG, JPG, or WEBP')\n ),\n 'PNG'\n ),\n quality: v.optional(\n toolNumber(\n v.pipe(\n v.number(),\n v.integer(),\n v.minValue(1),\n v.maxValue(100),\n v.description('JPG and WEBP quality from 1 to 100 (default: 90). PNG ignores it.')\n )\n )\n ),\n ...rasterScaleInputs\n }),\n execute: async (figma, args) => {\n if (!figma.exportImage) {\n return { error: 'Image export is not available in this environment' }\n }\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const format = args.format.toUpperCase() as RasterExportFormat\n const requestedScale = args.scale\n const maxEdge = args.maxEdge\n const missing = ids.find((id) => !figma.getNodeById(id))\n if (missing) return { error: `Node \"${missing}\" not found` }\n const nodes = ids.map((id) => figma.getNodeById(id)).filter((node) => node !== null)\n if (!nodes.some((node) => node.visible)) return { error: 'No visible nodes to export' }\n const bounds = nodes.reduce(\n (result, node) => {\n const box = node.absoluteBoundingBox\n const minX = Math.min(result.minX, box.x)\n const minY = Math.min(result.minY, box.y)\n const maxX = Math.max(result.maxX, box.x + box.width)\n const maxY = Math.max(result.maxY, box.y + box.height)\n return { minX, minY, maxX, maxY }\n },\n {\n minX: Number.POSITIVE_INFINITY,\n minY: Number.POSITIVE_INFINITY,\n maxX: Number.NEGATIVE_INFINITY,\n maxY: Number.NEGATIVE_INFINITY\n }\n )\n const width = bounds.maxX - bounds.minX\n const height = bounds.maxY - bounds.minY\n const boundedScale = boundedRasterScale(width, height, requestedScale, maxEdge)\n if (boundedScale <= 0) return { error: 'No visible nodes to export' }\n // PNG is lossless, so a quality would only be ignored by the encoder.\n const quality = format === 'PNG' ? undefined : args.quality\n const data = await figma.exportImage(ids, {\n scale: boundedScale,\n format,\n ...(quality === undefined ? {} : { quality })\n })\n if (!data || data.length === 0) {\n return { error: 'The renderer returned no image for these nodes' }\n }\n const base64 = fromUint8Array(data)\n const mimeMap = { PNG: 'image/png', JPG: 'image/jpeg', WEBP: 'image/webp' } as const\n return {\n mimeType: mimeMap[format],\n base64,\n byteLength: data.length,\n width: Math.ceil(width * boundedScale),\n height: Math.ceil(height * boundedScale),\n scale: boundedScale,\n ...(quality === undefined ? {} : { quality })\n }\n }\n})\n\n/** How `export_html` styles the markup, by the names `HTMLExportOptions` uses. */\nconst HTML_STYLES = { css: 'inline', tailwind: 'tailwind' } as const\n\nexport const exportHTML = defineTool({\n name: 'export_html',\n description:\n 'Export nodes as HTML code. style \"css\" (default) writes plain CSS: style attributes in a fragment, a stylesheet in a standalone document; \"tailwind\" writes Tailwind utility classes. html \"fragment\" (default) returns markup to paste into a page; \"standalone\" returns a whole document. assets \"inline\" (default) embeds images as data URLs; \"external\", for a standalone document, returns its stylesheet, images, and web fonts as separate files, listed in assets. layer_names writes each layer name as data-name; layer_ids writes each layer ID as data-pairdraw-node-id.',\n execution: { kind: 'async', mutation: 'none' },\n exposure: { webmcp: false },\n // A standalone page with separate files downloads the web fonts it ships.\n capabilities: ['document:read', 'network:access'],\n input: v.strictObject({\n ids: exportInputs.ids,\n style: v.optional(\n v.pipe(\n v.picklist(['css', 'tailwind']),\n v.description('\"css\": plain CSS. \"tailwind\": Tailwind utility classes.')\n ),\n 'css'\n ),\n html: v.optional(\n v.pipe(\n v.picklist(['fragment', 'standalone']),\n v.description('\"fragment\": markup for a page. \"standalone\": a complete HTML document.')\n ),\n 'fragment'\n ),\n assets: v.optional(\n v.pipe(\n v.picklist(['inline', 'external']),\n v.description(\n '\"inline\": images as data URLs. \"external\" (standalone only): images and the stylesheet as separate files.'\n )\n ),\n 'inline'\n ),\n layer_names: v.optional(\n v.pipe(\n v.boolean(),\n v.description('Write each layer name as a data-name attribute (default: true)')\n ),\n true\n ),\n layer_ids: v.optional(\n v.pipe(\n v.boolean(),\n v.description(\n 'Write each layer ID as a data-pairdraw-node-id attribute, to map markup back to layers (default: false)'\n )\n ),\n false\n )\n }),\n execute: async (figma, args) => {\n const ids =\n args.ids && args.ids.length > 0 ? args.ids : figma.currentPage.children.map((node) => node.id)\n const missing = ids.find((id) => !figma.graph.getNode(id))\n if (missing) return { error: `Node \"${missing}\" not found` }\n if (ids.length === 0) return { error: 'No nodes to export' }\n const { renderNodesToHTML } = await import('#core/io/formats/html')\n const { html, assets } = await renderNodesToHTML(figma.graph, ids, {\n html: args.html,\n style: HTML_STYLES[args.style],\n assets: args.assets,\n fonts: args.html === 'standalone' && args.assets === 'external' ? 'assets' : 'none',\n layerNames: args.layer_names,\n layerIds: args.layer_ids,\n loadTailwindStylesheet: getHTMLToolHost(figma.graph)?.loadTailwindStylesheet\n })\n if (!html) return { error: 'No visible nodes to export' }\n return {\n html,\n ...(assets.length > 0\n ? {\n assets: assets.map(({ path, content }) =>\n typeof content === 'string'\n ? { path, text: content }\n : { path, base64: fromUint8Array(content), byteLength: content.length }\n )\n }\n : {})\n }\n }\n})\n"],"mappings":";;;;;;AAQA,MAAM,eAAe;CACnB,KAAK,EAAE,SACL,EAAE,KACA,EAAE,MAAM,EAAE,OAAO,CAAC,GAClB,EAAE,UAAU,CAAC,GACb,EAAE,YAAY,6EAA6E,CAC7F,CACF;CACA,MAAM,EAAE,SACN,EAAE,KACA,EAAE,OAAO,GACT,EAAE,YACA,uFACF,CACF,CACF;AACF;;AAGA,MAAa,oBAAoB;CAC/B,OAAO,EAAE,SACP,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,SAAS,EAAG,GACd,EAAE,SAAS,CAAC,GACZ,EAAE,YACA,+EACF,CACF,CACF,GACA,CACF;CACA,SAAS,EAAE,SACT,WACE,EAAE,KACA,EAAE,OAAO,GACT,EAAE,SAAS,EAAE,GACb,EAAE,SAAS,IAAI,GACf,EAAE,YACA,gIACF,CACF,CACF,GACA,IACF;AACF;;AAGA,SAAgB,mBACd,OACA,QACA,OACA,SACQ;CACR,MAAM,cAAc,KAAK,IAAI,OAAO,MAAM;CAC1C,OAAO,cAAc,IAAI,KAAK,IAAI,OAAO,UAAU,WAAW,IAAI;AACpE;AAEA,MAAa,YAAY,WAAW;CAClC,MAAM;CACN,aAAa;CACb,WAAW;EAAE,MAAM;EAAS,UAAU;CAAO;CAC7C,UAAU,EAAE,QAAQ,MAAM;CAC1B,OAAO,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC;CACzC,SAAS,OAAO,OAAO,SAAS;EAC9B,MAAM,EAAE,4BAA4B,MAA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