@llc3233149/core 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (457) hide show
  1. package/dist/canvaskit.d.ts +9 -0
  2. package/dist/canvaskit.d.ts.map +1 -0
  3. package/dist/canvaskit.js +55 -0
  4. package/dist/canvaskit.js.map +1 -0
  5. package/dist/clipboard.d.ts +32 -0
  6. package/dist/clipboard.d.ts.map +1 -0
  7. package/dist/clipboard.js +345 -0
  8. package/dist/clipboard.js.map +1 -0
  9. package/dist/color.d.ts +28 -0
  10. package/dist/color.d.ts.map +1 -0
  11. package/dist/color.js +67 -0
  12. package/dist/color.js.map +1 -0
  13. package/dist/constants.d.ts +159 -0
  14. package/dist/constants.d.ts.map +1 -0
  15. package/dist/constants.js +224 -0
  16. package/dist/constants.js.map +1 -0
  17. package/dist/copy.d.ts +20 -0
  18. package/dist/copy.d.ts.map +1 -0
  19. package/dist/copy.js +64 -0
  20. package/dist/copy.js.map +1 -0
  21. package/dist/fig-export-worker.d.ts +2 -0
  22. package/dist/fig-export-worker.d.ts.map +1 -0
  23. package/dist/fig-export-worker.js +17 -0
  24. package/dist/fig-export-worker.js.map +1 -0
  25. package/dist/fig-export.d.ts +13 -0
  26. package/dist/fig-export.d.ts.map +1 -0
  27. package/dist/fig-export.js +243 -0
  28. package/dist/fig-export.js.map +1 -0
  29. package/dist/figma-api.d.ts +268 -0
  30. package/dist/figma-api.d.ts.map +1 -0
  31. package/dist/figma-api.js +1074 -0
  32. package/dist/figma-api.js.map +1 -0
  33. package/dist/figma-rest-import.d.ts +122 -0
  34. package/dist/figma-rest-import.d.ts.map +1 -0
  35. package/dist/figma-rest-import.js +319 -0
  36. package/dist/figma-rest-import.js.map +1 -0
  37. package/dist/fonts.d.ts +24 -0
  38. package/dist/fonts.d.ts.map +1 -0
  39. package/dist/fonts.js +356 -0
  40. package/dist/fonts.js.map +1 -0
  41. package/dist/geometry.d.ts +14 -0
  42. package/dist/geometry.d.ts.map +1 -0
  43. package/dist/geometry.js +47 -0
  44. package/dist/geometry.js.map +1 -0
  45. package/dist/index.d.ts +38 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/kiwi/codec.d.ts +292 -0
  50. package/dist/kiwi/codec.d.ts.map +1 -0
  51. package/dist/kiwi/codec.js +340 -0
  52. package/dist/kiwi/codec.js.map +1 -0
  53. package/dist/kiwi/fig-file.d.ts +4 -0
  54. package/dist/kiwi/fig-file.d.ts.map +1 -0
  55. package/dist/kiwi/fig-file.js +236 -0
  56. package/dist/kiwi/fig-file.js.map +1 -0
  57. package/dist/kiwi/fig-import.d.ts +4 -0
  58. package/dist/kiwi/fig-import.d.ts.map +1 -0
  59. package/dist/kiwi/fig-import.js +248 -0
  60. package/dist/kiwi/fig-import.js.map +1 -0
  61. package/dist/kiwi/fig-parse-worker.d.ts +7 -0
  62. package/dist/kiwi/fig-parse-worker.d.ts.map +1 -0
  63. package/dist/kiwi/fig-parse-worker.js +184 -0
  64. package/dist/kiwi/fig-parse-worker.js.map +1 -0
  65. package/dist/kiwi/instance-overrides.d.ts +66 -0
  66. package/dist/kiwi/instance-overrides.d.ts.map +1 -0
  67. package/dist/kiwi/instance-overrides.js +644 -0
  68. package/dist/kiwi/instance-overrides.js.map +1 -0
  69. package/dist/kiwi/kiwi-convert.d.ts +19 -0
  70. package/dist/kiwi/kiwi-convert.d.ts.map +1 -0
  71. package/dist/kiwi/kiwi-convert.js +678 -0
  72. package/dist/kiwi/kiwi-convert.js.map +1 -0
  73. package/dist/kiwi/kiwi-schema/bb.d.ts +25 -0
  74. package/dist/kiwi/kiwi-schema/bb.d.ts.map +1 -0
  75. package/dist/kiwi/kiwi-schema/bb.js +225 -0
  76. package/dist/kiwi/kiwi-schema/bb.js.map +1 -0
  77. package/dist/kiwi/kiwi-schema/binary.d.ts +5 -0
  78. package/dist/kiwi/kiwi-schema/binary.d.ts.map +1 -0
  79. package/dist/kiwi/kiwi-schema/binary.js +86 -0
  80. package/dist/kiwi/kiwi-schema/binary.js.map +1 -0
  81. package/dist/kiwi/kiwi-schema/index.d.ts +6 -0
  82. package/dist/kiwi/kiwi-schema/index.d.ts.map +1 -0
  83. package/dist/kiwi/kiwi-schema/index.js +5 -0
  84. package/dist/kiwi/kiwi-schema/index.js.map +1 -0
  85. package/dist/kiwi/kiwi-schema/js.d.ts +4 -0
  86. package/dist/kiwi/kiwi-schema/js.d.ts.map +1 -0
  87. package/dist/kiwi/kiwi-schema/js.js +282 -0
  88. package/dist/kiwi/kiwi-schema/js.js.map +1 -0
  89. package/dist/kiwi/kiwi-schema/parser.d.ts +5 -0
  90. package/dist/kiwi/kiwi-schema/parser.d.ts.map +1 -0
  91. package/dist/kiwi/kiwi-schema/parser.js +228 -0
  92. package/dist/kiwi/kiwi-schema/parser.js.map +1 -0
  93. package/dist/kiwi/kiwi-schema/schema.d.ts +22 -0
  94. package/dist/kiwi/kiwi-schema/schema.d.ts.map +1 -0
  95. package/dist/kiwi/kiwi-schema/schema.js +2 -0
  96. package/dist/kiwi/kiwi-schema/schema.js.map +1 -0
  97. package/dist/kiwi/kiwi-schema/util.d.ts +3 -0
  98. package/dist/kiwi/kiwi-schema/util.d.ts.map +1 -0
  99. package/dist/kiwi/kiwi-schema/util.js +10 -0
  100. package/dist/kiwi/kiwi-schema/util.js.map +1 -0
  101. package/dist/kiwi/protocol.d.ts +172 -0
  102. package/dist/kiwi/protocol.d.ts.map +1 -0
  103. package/dist/kiwi/protocol.js +214 -0
  104. package/dist/kiwi/protocol.js.map +1 -0
  105. package/dist/kiwi/schema.d.ts +3 -0
  106. package/dist/kiwi/schema.d.ts.map +1 -0
  107. package/dist/kiwi/schema.js +2285 -0
  108. package/dist/kiwi/schema.js.map +1 -0
  109. package/dist/kiwi-serialize.d.ts +17 -0
  110. package/dist/kiwi-serialize.d.ts.map +1 -0
  111. package/dist/kiwi-serialize.js +419 -0
  112. package/dist/kiwi-serialize.js.map +1 -0
  113. package/dist/layout.d.ts +9 -0
  114. package/dist/layout.d.ts.map +1 -0
  115. package/dist/layout.js +533 -0
  116. package/dist/layout.js.map +1 -0
  117. package/dist/profiler/draw-call-counter.d.ts +9 -0
  118. package/dist/profiler/draw-call-counter.d.ts.map +1 -0
  119. package/dist/profiler/draw-call-counter.js +37 -0
  120. package/dist/profiler/draw-call-counter.js.map +1 -0
  121. package/dist/profiler/frame-capture.d.ts +34 -0
  122. package/dist/profiler/frame-capture.d.ts.map +1 -0
  123. package/dist/profiler/frame-capture.js +90 -0
  124. package/dist/profiler/frame-capture.js.map +1 -0
  125. package/dist/profiler/frame-stats.d.ts +33 -0
  126. package/dist/profiler/frame-stats.d.ts.map +1 -0
  127. package/dist/profiler/frame-stats.js +103 -0
  128. package/dist/profiler/frame-stats.js.map +1 -0
  129. package/dist/profiler/gpu-timer.d.ts +15 -0
  130. package/dist/profiler/gpu-timer.d.ts.map +1 -0
  131. package/dist/profiler/gpu-timer.js +77 -0
  132. package/dist/profiler/gpu-timer.js.map +1 -0
  133. package/dist/profiler/hud-renderer.d.ts +22 -0
  134. package/dist/profiler/hud-renderer.d.ts.map +1 -0
  135. package/dist/profiler/hud-renderer.js +200 -0
  136. package/dist/profiler/hud-renderer.js.map +1 -0
  137. package/dist/profiler/index.d.ts +9 -0
  138. package/dist/profiler/index.d.ts.map +1 -0
  139. package/dist/profiler/index.js +8 -0
  140. package/dist/profiler/index.js.map +1 -0
  141. package/dist/profiler/phase-timer.d.ts +9 -0
  142. package/dist/profiler/phase-timer.d.ts.map +1 -0
  143. package/dist/profiler/phase-timer.js +51 -0
  144. package/dist/profiler/phase-timer.js.map +1 -0
  145. package/dist/profiler/render-profiler.d.ts +41 -0
  146. package/dist/profiler/render-profiler.d.ts.map +1 -0
  147. package/dist/profiler/render-profiler.js +142 -0
  148. package/dist/profiler/render-profiler.js.map +1 -0
  149. package/dist/render/components.d.ts +25 -0
  150. package/dist/render/components.d.ts.map +1 -0
  151. package/dist/render/components.js +55 -0
  152. package/dist/render/components.js.map +1 -0
  153. package/dist/render/emoji-icons.d.ts +5 -0
  154. package/dist/render/emoji-icons.d.ts.map +1 -0
  155. package/dist/render/emoji-icons.js +55 -0
  156. package/dist/render/emoji-icons.js.map +1 -0
  157. package/dist/render/export-code.d.ts +9 -0
  158. package/dist/render/export-code.d.ts.map +1 -0
  159. package/dist/render/export-code.js +335 -0
  160. package/dist/render/export-code.js.map +1 -0
  161. package/dist/render/export-jsx.d.ts +5 -0
  162. package/dist/render/export-jsx.d.ts.map +1 -0
  163. package/dist/render/export-jsx.js +621 -0
  164. package/dist/render/export-jsx.js.map +1 -0
  165. package/dist/render/index.d.ts +8 -0
  166. package/dist/render/index.d.ts.map +1 -0
  167. package/dist/render/index.js +8 -0
  168. package/dist/render/index.js.map +1 -0
  169. package/dist/render/jsx-runtime.d.ts +31 -0
  170. package/dist/render/jsx-runtime.d.ts.map +1 -0
  171. package/dist/render/jsx-runtime.js +13 -0
  172. package/dist/render/jsx-runtime.js.map +1 -0
  173. package/dist/render/mini-react.d.ts +14 -0
  174. package/dist/render/mini-react.d.ts.map +1 -0
  175. package/dist/render/mini-react.js +16 -0
  176. package/dist/render/mini-react.js.map +1 -0
  177. package/dist/render/render-jsx.d.ts +24 -0
  178. package/dist/render/render-jsx.d.ts.map +1 -0
  179. package/dist/render/render-jsx.js +51 -0
  180. package/dist/render/render-jsx.js.map +1 -0
  181. package/dist/render/renderer.d.ts +16 -0
  182. package/dist/render/renderer.d.ts.map +1 -0
  183. package/dist/render/renderer.js +437 -0
  184. package/dist/render/renderer.js.map +1 -0
  185. package/dist/render/tailwind.d.ts +20 -0
  186. package/dist/render/tailwind.d.ts.map +1 -0
  187. package/dist/render/tailwind.js +115 -0
  188. package/dist/render/tailwind.js.map +1 -0
  189. package/dist/render/tree.d.ts +72 -0
  190. package/dist/render/tree.d.ts.map +1 -0
  191. package/dist/render/tree.js +63 -0
  192. package/dist/render/tree.js.map +1 -0
  193. package/dist/render-image.d.ts +19 -0
  194. package/dist/render-image.d.ts.map +1 -0
  195. package/dist/render-image.js +84 -0
  196. package/dist/render-image.js.map +1 -0
  197. package/dist/renderer/effects.d.ts +9 -0
  198. package/dist/renderer/effects.d.ts.map +1 -0
  199. package/dist/renderer/effects.js +44 -0
  200. package/dist/renderer/effects.js.map +1 -0
  201. package/dist/renderer/fills.d.ts +9 -0
  202. package/dist/renderer/fills.d.ts.map +1 -0
  203. package/dist/renderer/fills.js +189 -0
  204. package/dist/renderer/fills.js.map +1 -0
  205. package/dist/renderer/index.d.ts +2 -0
  206. package/dist/renderer/index.d.ts.map +1 -0
  207. package/dist/renderer/index.js +2 -0
  208. package/dist/renderer/index.js.map +1 -0
  209. package/dist/renderer/label-cache.d.ts +43 -0
  210. package/dist/renderer/label-cache.d.ts.map +1 -0
  211. package/dist/renderer/label-cache.js +85 -0
  212. package/dist/renderer/label-cache.js.map +1 -0
  213. package/dist/renderer/labels.d.ts +6 -0
  214. package/dist/renderer/labels.d.ts.map +1 -0
  215. package/dist/renderer/labels.js +126 -0
  216. package/dist/renderer/labels.js.map +1 -0
  217. package/dist/renderer/lru-cache.d.ts +20 -0
  218. package/dist/renderer/lru-cache.d.ts.map +1 -0
  219. package/dist/renderer/lru-cache.js +65 -0
  220. package/dist/renderer/lru-cache.js.map +1 -0
  221. package/dist/renderer/overlays.d.ts +25 -0
  222. package/dist/renderer/overlays.d.ts.map +1 -0
  223. package/dist/renderer/overlays.js +783 -0
  224. package/dist/renderer/overlays.js.map +1 -0
  225. package/dist/renderer/renderer.d.ts +229 -0
  226. package/dist/renderer/renderer.d.ts.map +1 -0
  227. package/dist/renderer/renderer.js +909 -0
  228. package/dist/renderer/renderer.js.map +1 -0
  229. package/dist/renderer/rulers.d.ts +8 -0
  230. package/dist/renderer/rulers.d.ts.map +1 -0
  231. package/dist/renderer/rulers.js +147 -0
  232. package/dist/renderer/rulers.js.map +1 -0
  233. package/dist/renderer/scene.d.ts +11 -0
  234. package/dist/renderer/scene.d.ts.map +1 -0
  235. package/dist/renderer/scene.js +392 -0
  236. package/dist/renderer/scene.js.map +1 -0
  237. package/dist/renderer/shapes.d.ts +13 -0
  238. package/dist/renderer/shapes.d.ts.map +1 -0
  239. package/dist/renderer/shapes.js +160 -0
  240. package/dist/renderer/shapes.js.map +1 -0
  241. package/dist/renderer/strokes.d.ts +9 -0
  242. package/dist/renderer/strokes.d.ts.map +1 -0
  243. package/dist/renderer/strokes.js +180 -0
  244. package/dist/renderer/strokes.js.map +1 -0
  245. package/dist/rpc/commands.d.ts +202 -0
  246. package/dist/rpc/commands.d.ts.map +1 -0
  247. package/dist/rpc/commands.js +429 -0
  248. package/dist/rpc/commands.js.map +1 -0
  249. package/dist/rpc/index.d.ts +3 -0
  250. package/dist/rpc/index.d.ts.map +1 -0
  251. package/dist/rpc/index.js +2 -0
  252. package/dist/rpc/index.js.map +1 -0
  253. package/dist/scene-graph.d.ts +318 -0
  254. package/dist/scene-graph.d.ts.map +1 -0
  255. package/dist/scene-graph.js +803 -0
  256. package/dist/scene-graph.js.map +1 -0
  257. package/dist/snap.d.ts +16 -0
  258. package/dist/snap.d.ts.map +1 -0
  259. package/dist/snap.js +97 -0
  260. package/dist/snap.js.map +1 -0
  261. package/dist/style-runs.d.ts +20 -0
  262. package/dist/style-runs.d.ts.map +1 -0
  263. package/dist/style-runs.js +168 -0
  264. package/dist/style-runs.js.map +1 -0
  265. package/dist/svg-export/defs.d.ts +19 -0
  266. package/dist/svg-export/defs.d.ts.map +1 -0
  267. package/dist/svg-export/defs.js +191 -0
  268. package/dist/svg-export/defs.js.map +1 -0
  269. package/dist/svg-export/index.d.ts +8 -0
  270. package/dist/svg-export/index.d.ts.map +1 -0
  271. package/dist/svg-export/index.js +318 -0
  272. package/dist/svg-export/index.js.map +1 -0
  273. package/dist/svg-export/paths.d.ts +9 -0
  274. package/dist/svg-export/paths.d.ts.map +1 -0
  275. package/dist/svg-export/paths.js +189 -0
  276. package/dist/svg-export/paths.js.map +1 -0
  277. package/dist/svg-node.d.ts +8 -0
  278. package/dist/svg-node.d.ts.map +1 -0
  279. package/dist/svg-node.js +48 -0
  280. package/dist/svg-node.js.map +1 -0
  281. package/dist/text-editor.d.ts +57 -0
  282. package/dist/text-editor.d.ts.map +1 -0
  283. package/dist/text-editor.js +337 -0
  284. package/dist/text-editor.js.map +1 -0
  285. package/dist/tools/ai-adapter.d.ts +22 -0
  286. package/dist/tools/ai-adapter.d.ts.map +1 -0
  287. package/dist/tools/ai-adapter.js +121 -0
  288. package/dist/tools/ai-adapter.js.map +1 -0
  289. package/dist/tools/analyze.d.ts +22 -0
  290. package/dist/tools/analyze.d.ts.map +1 -0
  291. package/dist/tools/analyze.js +677 -0
  292. package/dist/tools/analyze.js.map +1 -0
  293. package/dist/tools/create.d.ts +8 -0
  294. package/dist/tools/create.d.ts.map +1 -0
  295. package/dist/tools/create.js +204 -0
  296. package/dist/tools/create.js.map +1 -0
  297. package/dist/tools/describe.d.ts +9 -0
  298. package/dist/tools/describe.d.ts.map +1 -0
  299. package/dist/tools/describe.js +295 -0
  300. package/dist/tools/describe.js.map +1 -0
  301. package/dist/tools/export-code.d.ts +2 -0
  302. package/dist/tools/export-code.d.ts.map +1 -0
  303. package/dist/tools/export-code.js +34 -0
  304. package/dist/tools/export-code.js.map +1 -0
  305. package/dist/tools/export-tailwind-config.d.ts +27 -0
  306. package/dist/tools/export-tailwind-config.d.ts.map +1 -0
  307. package/dist/tools/export-tailwind-config.js +215 -0
  308. package/dist/tools/export-tailwind-config.js.map +1 -0
  309. package/dist/tools/icons.d.ts +5 -0
  310. package/dist/tools/icons.d.ts.map +1 -0
  311. package/dist/tools/icons.js +192 -0
  312. package/dist/tools/icons.js.map +1 -0
  313. package/dist/tools/index.d.ts +7 -0
  314. package/dist/tools/index.d.ts.map +1 -0
  315. package/dist/tools/index.js +6 -0
  316. package/dist/tools/index.js.map +1 -0
  317. package/dist/tools/modify.d.ts +22 -0
  318. package/dist/tools/modify.d.ts.map +1 -0
  319. package/dist/tools/modify.js +653 -0
  320. package/dist/tools/modify.js.map +1 -0
  321. package/dist/tools/patterns.d.ts +2 -0
  322. package/dist/tools/patterns.d.ts.map +1 -0
  323. package/dist/tools/patterns.js +173 -0
  324. package/dist/tools/patterns.js.map +1 -0
  325. package/dist/tools/read.d.ts +17 -0
  326. package/dist/tools/read.d.ts.map +1 -0
  327. package/dist/tools/read.js +379 -0
  328. package/dist/tools/read.js.map +1 -0
  329. package/dist/tools/registry.d.ts +3 -0
  330. package/dist/tools/registry.d.ts.map +1 -0
  331. package/dist/tools/registry.js +124 -0
  332. package/dist/tools/registry.js.map +1 -0
  333. package/dist/tools/schema.d.ts +46 -0
  334. package/dist/tools/schema.d.ts.map +1 -0
  335. package/dist/tools/schema.js +17 -0
  336. package/dist/tools/schema.js.map +1 -0
  337. package/dist/tools/structure.d.ts +18 -0
  338. package/dist/tools/structure.d.ts.map +1 -0
  339. package/dist/tools/structure.js +345 -0
  340. package/dist/tools/structure.js.map +1 -0
  341. package/dist/tools/variables.d.ts +12 -0
  342. package/dist/tools/variables.d.ts.map +1 -0
  343. package/dist/tools/variables.js +190 -0
  344. package/dist/tools/variables.js.map +1 -0
  345. package/dist/tools/vector.d.ts +15 -0
  346. package/dist/tools/vector.d.ts.map +1 -0
  347. package/dist/tools/vector.js +312 -0
  348. package/dist/tools/vector.js.map +1 -0
  349. package/dist/types.d.ts +29 -0
  350. package/dist/types.d.ts.map +1 -0
  351. package/dist/types.js +2 -0
  352. package/dist/types.js.map +1 -0
  353. package/dist/undo.d.ts +33 -0
  354. package/dist/undo.d.ts.map +1 -0
  355. package/dist/undo.js +98 -0
  356. package/dist/undo.js.map +1 -0
  357. package/dist/vector.d.ts +14 -0
  358. package/dist/vector.d.ts.map +1 -0
  359. package/dist/vector.js +334 -0
  360. package/dist/vector.js.map +1 -0
  361. package/dist/xpath.d.ts +8 -0
  362. package/dist/xpath.d.ts.map +1 -0
  363. package/dist/xpath.js +199 -0
  364. package/dist/xpath.js.map +1 -0
  365. package/package.json +54 -0
  366. package/src/canvaskit.ts +66 -0
  367. package/src/clipboard.ts +444 -0
  368. package/src/color.ts +83 -0
  369. package/src/constants.ts +277 -0
  370. package/src/copy.ts +75 -0
  371. package/src/fig-export-worker.ts +28 -0
  372. package/src/fig-export.ts +321 -0
  373. package/src/figma-api.ts +1297 -0
  374. package/src/figma-rest-import.ts +443 -0
  375. package/src/fonts.ts +369 -0
  376. package/src/geometry.ts +73 -0
  377. package/src/global.d.ts +20 -0
  378. package/src/index.ts +247 -0
  379. package/src/kiwi/codec.ts +614 -0
  380. package/src/kiwi/fig-file.ts +248 -0
  381. package/src/kiwi/fig-import.ts +300 -0
  382. package/src/kiwi/fig-parse-worker.ts +213 -0
  383. package/src/kiwi/instance-overrides.ts +682 -0
  384. package/src/kiwi/kiwi-convert.ts +771 -0
  385. package/src/kiwi/kiwi-schema/bb.ts +244 -0
  386. package/src/kiwi/kiwi-schema/binary.ts +102 -0
  387. package/src/kiwi/kiwi-schema/index.ts +5 -0
  388. package/src/kiwi/kiwi-schema/js.ts +339 -0
  389. package/src/kiwi/kiwi-schema/parser.ts +287 -0
  390. package/src/kiwi/kiwi-schema/schema.ts +24 -0
  391. package/src/kiwi/kiwi-schema/util.ts +10 -0
  392. package/src/kiwi/protocol.ts +237 -0
  393. package/src/kiwi/schema.ts +2286 -0
  394. package/src/kiwi-serialize.ts +467 -0
  395. package/src/layout.ts +608 -0
  396. package/src/profiler/draw-call-counter.ts +43 -0
  397. package/src/profiler/frame-capture.ts +139 -0
  398. package/src/profiler/frame-stats.ts +122 -0
  399. package/src/profiler/gpu-timer.ts +93 -0
  400. package/src/profiler/hud-renderer.ts +242 -0
  401. package/src/profiler/index.ts +8 -0
  402. package/src/profiler/phase-timer.ts +62 -0
  403. package/src/profiler/render-profiler.ts +163 -0
  404. package/src/render/components.ts +69 -0
  405. package/src/render/emoji-icons.ts +60 -0
  406. package/src/render/export-code.ts +366 -0
  407. package/src/render/export-jsx.ts +633 -0
  408. package/src/render/index.ts +38 -0
  409. package/src/render/jsx-runtime.ts +36 -0
  410. package/src/render/mini-react.ts +30 -0
  411. package/src/render/render-jsx.ts +74 -0
  412. package/src/render/renderer.ts +508 -0
  413. package/src/render/tailwind.ts +114 -0
  414. package/src/render/tree.ts +137 -0
  415. package/src/render-image.ts +139 -0
  416. package/src/renderer/effects.ts +64 -0
  417. package/src/renderer/fills.ts +248 -0
  418. package/src/renderer/index.ts +1 -0
  419. package/src/renderer/label-cache.ts +114 -0
  420. package/src/renderer/labels.ts +168 -0
  421. package/src/renderer/lru-cache.ts +71 -0
  422. package/src/renderer/overlays.ts +1089 -0
  423. package/src/renderer/renderer.ts +1226 -0
  424. package/src/renderer/rulers.ts +230 -0
  425. package/src/renderer/scene.ts +554 -0
  426. package/src/renderer/shapes.ts +193 -0
  427. package/src/renderer/strokes.ts +221 -0
  428. package/src/rpc/commands.ts +667 -0
  429. package/src/rpc/index.ts +25 -0
  430. package/src/scene-graph.ts +1254 -0
  431. package/src/snap.ts +122 -0
  432. package/src/style-runs.ts +234 -0
  433. package/src/svg-export/defs.ts +255 -0
  434. package/src/svg-export/index.ts +427 -0
  435. package/src/svg-export/paths.ts +212 -0
  436. package/src/svg-node.ts +62 -0
  437. package/src/text-editor.ts +349 -0
  438. package/src/tools/ai-adapter.ts +144 -0
  439. package/src/tools/analyze.ts +786 -0
  440. package/src/tools/create.ts +206 -0
  441. package/src/tools/describe.ts +280 -0
  442. package/src/tools/export-code.ts +41 -0
  443. package/src/tools/export-tailwind-config.ts +266 -0
  444. package/src/tools/icons.ts +213 -0
  445. package/src/tools/index.ts +6 -0
  446. package/src/tools/modify.ts +651 -0
  447. package/src/tools/patterns.ts +189 -0
  448. package/src/tools/read.ts +401 -0
  449. package/src/tools/registry.ts +155 -0
  450. package/src/tools/schema.ts +65 -0
  451. package/src/tools/structure.ts +348 -0
  452. package/src/tools/variables.ts +193 -0
  453. package/src/tools/vector.ts +311 -0
  454. package/src/types.ts +32 -0
  455. package/src/undo.ts +126 -0
  456. package/src/vector.ts +413 -0
  457. package/src/xpath.ts +259 -0
@@ -0,0 +1,651 @@
1
+ import { parseColor } from '../color'
2
+ import { DEFAULT_SHADOW_COLOR } from '../constants'
3
+
4
+ import { defineTool } from './schema'
5
+
6
+ export const setFill = defineTool({
7
+ name: 'set_fill',
8
+ mutates: true,
9
+ description: 'Set the fill color of a node. Accepts hex (#ff0000) or named color.',
10
+ params: {
11
+ id: { type: 'string', description: 'Node ID', required: true },
12
+ color: { type: 'color', description: 'Color value (hex like #ff0000)', required: true }
13
+ },
14
+ execute: (figma, { id, color }) => {
15
+ const node = figma.getNodeById(id)
16
+ if (!node) return { error: `Node "${id}" not found` }
17
+
18
+ const c = parseColor(color)
19
+ node.fills = [{ type: 'SOLID', color: c, opacity: 1, visible: true }]
20
+ return { id, color: c }
21
+ }
22
+ })
23
+
24
+ export const setStroke = defineTool({
25
+ name: 'set_stroke',
26
+ mutates: true,
27
+ description: 'Set the stroke (border) of a node.',
28
+ params: {
29
+ id: { type: 'string', description: 'Node ID', required: true },
30
+ color: { type: 'color', description: 'Stroke color (hex)', required: true },
31
+ weight: { type: 'number', description: 'Stroke weight', default: 1, min: 0.1 },
32
+ align: {
33
+ type: 'string',
34
+ description: 'Stroke alignment',
35
+ default: 'INSIDE',
36
+ enum: ['INSIDE', 'CENTER', 'OUTSIDE']
37
+ }
38
+ },
39
+ execute: (figma, { id, color, weight, align }) => {
40
+ const node = figma.getNodeById(id)
41
+ if (!node) return { error: `Node "${id}" not found` }
42
+
43
+ const c = parseColor(color)
44
+ node.strokes = [
45
+ {
46
+ color: c,
47
+ weight: weight ?? 1,
48
+ opacity: 1,
49
+ visible: true,
50
+ align: (align ?? 'INSIDE') as 'INSIDE' | 'CENTER' | 'OUTSIDE'
51
+ }
52
+ ]
53
+ return { id, color: c, weight: weight ?? 1 }
54
+ }
55
+ })
56
+
57
+ export const setEffects = defineTool({
58
+ name: 'set_effects',
59
+ mutates: true,
60
+ description:
61
+ 'Set effects on a node (drop shadow, inner shadow, blur). Pass an array or a single effect.',
62
+ params: {
63
+ id: { type: 'string', description: 'Node ID', required: true },
64
+ type: {
65
+ type: 'string',
66
+ description: 'Effect type',
67
+ required: true,
68
+ enum: ['DROP_SHADOW', 'INNER_SHADOW', 'FOREGROUND_BLUR', 'BACKGROUND_BLUR']
69
+ },
70
+ color: { type: 'color', description: 'Shadow color (hex). Ignored for blur.' },
71
+ offset_x: { type: 'number', description: 'Shadow X offset', default: 0 },
72
+ offset_y: { type: 'number', description: 'Shadow Y offset', default: 4 },
73
+ radius: { type: 'number', description: 'Blur radius', default: 4, min: 0 },
74
+ spread: { type: 'number', description: 'Shadow spread', default: 0 }
75
+ },
76
+ execute: (figma, args) => {
77
+ const node = figma.getNodeById(args.id)
78
+ if (!node) return { error: `Node "${args.id}" not found` }
79
+
80
+ const isBlur = args.type === 'FOREGROUND_BLUR' || args.type === 'BACKGROUND_BLUR'
81
+ const effect: Record<string, unknown> = {
82
+ type: args.type,
83
+ visible: true,
84
+ radius: args.radius ?? 4
85
+ }
86
+
87
+ if (!isBlur) {
88
+ effect.color = args.color ? parseColor(args.color) : { ...DEFAULT_SHADOW_COLOR }
89
+ effect.offset = { x: args.offset_x ?? 0, y: args.offset_y ?? 4 }
90
+ effect.spread = args.spread ?? 0
91
+ }
92
+
93
+ node.effects = [...node.effects, effect as any]
94
+ return { id: args.id, effects: node.effects.length }
95
+ }
96
+ })
97
+
98
+ export const updateNode = defineTool({
99
+ name: 'update_node',
100
+ mutates: true,
101
+ description:
102
+ 'Update properties of an existing node: position, size, opacity, corner radius, visibility, text, font.',
103
+ params: {
104
+ id: { type: 'string', description: 'Node ID', required: true },
105
+ x: { type: 'number', description: 'X position' },
106
+ y: { type: 'number', description: 'Y position' },
107
+ width: { type: 'number', description: 'Width', min: 1 },
108
+ height: { type: 'number', description: 'Height', min: 1 },
109
+ opacity: { type: 'number', description: 'Opacity (0-1)', min: 0, max: 1 },
110
+ corner_radius: { type: 'number', description: 'Corner radius', min: 0 },
111
+ visible: { type: 'boolean', description: 'Visibility' },
112
+ text: { type: 'string', description: 'Text content (TEXT nodes)' },
113
+ font_size: { type: 'number', description: 'Font size', min: 1 },
114
+ font_weight: { type: 'number', description: 'Font weight (100-900)' },
115
+ name: { type: 'string', description: 'Layer name' }
116
+ },
117
+ execute: (figma, args) => {
118
+ const node = figma.getNodeById(args.id)
119
+ if (!node) return { error: `Node "${args.id}" not found` }
120
+ const updated: string[] = []
121
+ if (args.x !== undefined) {
122
+ node.x = args.x
123
+ updated.push('x')
124
+ }
125
+ if (args.y !== undefined) {
126
+ node.y = args.y
127
+ updated.push('y')
128
+ }
129
+ if (args.width !== undefined || args.height !== undefined) {
130
+ node.resize(args.width ?? node.width, args.height ?? node.height)
131
+ updated.push('size')
132
+ }
133
+ if (args.opacity !== undefined) {
134
+ node.opacity = args.opacity
135
+ updated.push('opacity')
136
+ }
137
+ if (args.corner_radius !== undefined) {
138
+ node.cornerRadius = args.corner_radius
139
+ updated.push('cornerRadius')
140
+ }
141
+ if (args.visible !== undefined) {
142
+ node.visible = args.visible
143
+ updated.push('visible')
144
+ }
145
+ if (args.name !== undefined) {
146
+ node.name = args.name
147
+ updated.push('name')
148
+ }
149
+ if (args.text !== undefined) {
150
+ figma.graph.updateNode(node.id, { text: args.text })
151
+ updated.push('text')
152
+ }
153
+ if (args.font_size !== undefined) {
154
+ figma.graph.updateNode(node.id, { fontSize: args.font_size })
155
+ updated.push('fontSize')
156
+ }
157
+ if (args.font_weight !== undefined) {
158
+ figma.graph.updateNode(node.id, { fontWeight: args.font_weight })
159
+ updated.push('fontWeight')
160
+ }
161
+ return { id: args.id, updated }
162
+ }
163
+ })
164
+
165
+ export const setLayout = defineTool({
166
+ name: 'set_layout',
167
+ mutates: true,
168
+ description: 'Set auto-layout (flexbox) on a frame. Direction, alignment, spacing, padding.',
169
+ params: {
170
+ id: { type: 'string', description: 'Frame node ID', required: true },
171
+ direction: {
172
+ type: 'string',
173
+ description: 'Layout direction',
174
+ required: true,
175
+ enum: ['HORIZONTAL', 'VERTICAL']
176
+ },
177
+ spacing: { type: 'number', description: 'Gap between items', default: 0, min: 0 },
178
+ padding: { type: 'number', description: 'Equal padding on all sides', min: 0 },
179
+ padding_horizontal: { type: 'number', description: 'Horizontal padding', min: 0 },
180
+ padding_vertical: { type: 'number', description: 'Vertical padding', min: 0 },
181
+ align: {
182
+ type: 'string',
183
+ description: 'Primary axis alignment',
184
+ default: 'MIN',
185
+ enum: ['MIN', 'CENTER', 'MAX', 'SPACE_BETWEEN']
186
+ },
187
+ counter_align: {
188
+ type: 'string',
189
+ description: 'Cross axis alignment',
190
+ default: 'MIN',
191
+ enum: ['MIN', 'CENTER', 'MAX', 'STRETCH']
192
+ }
193
+ },
194
+ execute: (figma, args) => {
195
+ const node = figma.getNodeById(args.id)
196
+ if (!node) return { error: `Node "${args.id}" not found` }
197
+
198
+ node.layoutMode = args.direction as 'HORIZONTAL' | 'VERTICAL'
199
+ node.itemSpacing = args.spacing ?? 0
200
+ node.primaryAxisAlignItems = (args.align ?? 'MIN') as any
201
+ node.counterAxisAlignItems = (args.counter_align ?? 'MIN') as any
202
+
203
+ const ph = args.padding_horizontal ?? args.padding ?? 0
204
+ const pv = args.padding_vertical ?? args.padding ?? 0
205
+ node.paddingLeft = ph
206
+ node.paddingRight = ph
207
+ node.paddingTop = pv
208
+ node.paddingBottom = pv
209
+
210
+ return { id: args.id, direction: args.direction, spacing: args.spacing ?? 0 }
211
+ }
212
+ })
213
+
214
+ export const setConstraints = defineTool({
215
+ name: 'set_constraints',
216
+ mutates: true,
217
+ description: 'Set resize constraints for a node within its parent.',
218
+ params: {
219
+ id: { type: 'string', description: 'Node ID', required: true },
220
+ horizontal: {
221
+ type: 'string',
222
+ description: 'Horizontal constraint',
223
+ enum: ['MIN', 'CENTER', 'MAX', 'STRETCH', 'SCALE']
224
+ },
225
+ vertical: {
226
+ type: 'string',
227
+ description: 'Vertical constraint',
228
+ enum: ['MIN', 'CENTER', 'MAX', 'STRETCH', 'SCALE']
229
+ }
230
+ },
231
+ execute: (figma, args) => {
232
+ const node = figma.getNodeById(args.id)
233
+ if (!node) return { error: `Node "${args.id}" not found` }
234
+ if (args.horizontal || args.vertical) {
235
+ node.constraints = {
236
+ horizontal: args.horizontal ?? node.constraints.horizontal,
237
+ vertical: args.vertical ?? node.constraints.vertical
238
+ }
239
+ }
240
+ return { id: args.id, constraints: node.constraints }
241
+ }
242
+ })
243
+
244
+ export const setRotation = defineTool({
245
+ name: 'set_rotation',
246
+ mutates: true,
247
+ description: 'Set rotation angle of a node in degrees.',
248
+ params: {
249
+ id: { type: 'string', description: 'Node ID', required: true },
250
+ angle: { type: 'number', description: 'Rotation angle in degrees', required: true }
251
+ },
252
+ execute: (figma, { id, angle }) => {
253
+ const node = figma.getNodeById(id)
254
+ if (!node) return { error: `Node "${id}" not found` }
255
+ node.rotation = angle
256
+ return { id, rotation: angle }
257
+ }
258
+ })
259
+
260
+ export const setOpacity = defineTool({
261
+ name: 'set_opacity',
262
+ mutates: true,
263
+ description: 'Set opacity of a node (0-1).',
264
+ params: {
265
+ id: { type: 'string', description: 'Node ID', required: true },
266
+ value: { type: 'number', description: 'Opacity (0-1)', required: true, min: 0, max: 1 }
267
+ },
268
+ execute: (figma, { id, value }) => {
269
+ const node = figma.getNodeById(id)
270
+ if (!node) return { error: `Node "${id}" not found` }
271
+ node.opacity = value
272
+ return { id, opacity: value }
273
+ }
274
+ })
275
+
276
+ export const setRadius = defineTool({
277
+ name: 'set_radius',
278
+ mutates: true,
279
+ description: 'Set corner radius. Use individual corners for independent values.',
280
+ params: {
281
+ id: { type: 'string', description: 'Node ID', required: true },
282
+ radius: { type: 'number', description: 'Corner radius for all corners', min: 0 },
283
+ top_left: { type: 'number', description: 'Top-left radius', min: 0 },
284
+ top_right: { type: 'number', description: 'Top-right radius', min: 0 },
285
+ bottom_right: { type: 'number', description: 'Bottom-right radius', min: 0 },
286
+ bottom_left: { type: 'number', description: 'Bottom-left radius', min: 0 }
287
+ },
288
+ execute: (figma, args) => {
289
+ const node = figma.getNodeById(args.id)
290
+ if (!node) return { error: `Node "${args.id}" not found` }
291
+ if (args.radius !== undefined) {
292
+ node.cornerRadius = args.radius
293
+ }
294
+ if (args.top_left !== undefined) node.topLeftRadius = args.top_left
295
+ if (args.top_right !== undefined) node.topRightRadius = args.top_right
296
+ if (args.bottom_right !== undefined) node.bottomRightRadius = args.bottom_right
297
+ if (args.bottom_left !== undefined) node.bottomLeftRadius = args.bottom_left
298
+ return { id: args.id, cornerRadius: node.cornerRadius }
299
+ }
300
+ })
301
+
302
+ export const setMinMax = defineTool({
303
+ name: 'set_minmax',
304
+ mutates: true,
305
+ description: 'Set min/max width and height constraints on a node.',
306
+ params: {
307
+ id: { type: 'string', description: 'Node ID', required: true },
308
+ min_width: { type: 'number', description: 'Minimum width', min: 0 },
309
+ max_width: { type: 'number', description: 'Maximum width', min: 0 },
310
+ min_height: { type: 'number', description: 'Minimum height', min: 0 },
311
+ max_height: { type: 'number', description: 'Maximum height', min: 0 }
312
+ },
313
+ execute: (figma, args) => {
314
+ const node = figma.getNodeById(args.id)
315
+ if (!node) return { error: `Node "${args.id}" not found` }
316
+ if (args.min_width !== undefined) node.minWidth = args.min_width
317
+ if (args.max_width !== undefined) node.maxWidth = args.max_width
318
+ if (args.min_height !== undefined) node.minHeight = args.min_height
319
+ if (args.max_height !== undefined) node.maxHeight = args.max_height
320
+ return {
321
+ id: args.id,
322
+ minWidth: node.minWidth,
323
+ maxWidth: node.maxWidth,
324
+ minHeight: node.minHeight,
325
+ maxHeight: node.maxHeight
326
+ }
327
+ }
328
+ })
329
+
330
+ export const setText = defineTool({
331
+ name: 'set_text',
332
+ mutates: true,
333
+ description: 'Set text content of a text node.',
334
+ params: {
335
+ id: { type: 'string', description: 'Node ID', required: true },
336
+ text: { type: 'string', description: 'Text content', required: true }
337
+ },
338
+ execute: (figma, { id, text }) => {
339
+ const node = figma.getNodeById(id)
340
+ if (!node) return { error: `Node "${id}" not found` }
341
+ node.characters = text
342
+ return { id, text }
343
+ }
344
+ })
345
+
346
+ export const setFont = defineTool({
347
+ name: 'set_font',
348
+ mutates: true,
349
+ description: 'Set font properties of a text node.',
350
+ params: {
351
+ id: { type: 'string', description: 'Node ID', required: true },
352
+ family: { type: 'string', description: 'Font family name' },
353
+ size: { type: 'number', description: 'Font size', min: 1 },
354
+ style: { type: 'string', description: 'Font style (e.g. "Bold", "Regular", "Bold Italic")' }
355
+ },
356
+ execute: (figma, args) => {
357
+ const node = figma.getNodeById(args.id)
358
+ if (!node) return { error: `Node "${args.id}" not found` }
359
+ if (args.size !== undefined) node.fontSize = args.size
360
+ if (args.family || args.style) {
361
+ const current = node.fontName
362
+ node.fontName = {
363
+ family: args.family ?? current.family,
364
+ style: args.style ?? current.style
365
+ }
366
+ }
367
+ return { id: args.id, fontName: node.fontName, fontSize: node.fontSize }
368
+ }
369
+ })
370
+
371
+ export const setFontRange = defineTool({
372
+ name: 'set_font_range',
373
+ mutates: true,
374
+ description: 'Set font properties for a text range.',
375
+ params: {
376
+ id: { type: 'string', description: 'Node ID', required: true },
377
+ start: { type: 'number', description: 'Start character index', required: true, min: 0 },
378
+ end: { type: 'number', description: 'End character index', required: true, min: 0 },
379
+ family: { type: 'string', description: 'Font family name' },
380
+ size: { type: 'number', description: 'Font size', min: 1 },
381
+ style: { type: 'string', description: 'Font style' },
382
+ color: { type: 'color', description: 'Text color (hex)' }
383
+ },
384
+ execute: (figma, args) => {
385
+ const node = figma.getNodeById(args.id)
386
+ if (!node) return { error: `Node "${args.id}" not found` }
387
+ const run: Record<string, unknown> = { start: args.start, end: args.end }
388
+ if (args.family) run.fontFamily = args.family
389
+ if (args.size) run.fontSize = args.size
390
+ if (args.style) run.fontStyle = args.style
391
+ if (args.color) run.color = parseColor(args.color)
392
+ figma.graph.updateNode(node.id, {
393
+ styleRuns: [...(figma.graph.getNode(node.id)?.styleRuns ?? []), run as any]
394
+ })
395
+ return { id: args.id, range: { start: args.start, end: args.end } }
396
+ }
397
+ })
398
+
399
+ export const setTextResize = defineTool({
400
+ name: 'set_text_resize',
401
+ mutates: true,
402
+ description: 'Set text auto-resize mode.',
403
+ params: {
404
+ id: { type: 'string', description: 'Node ID', required: true },
405
+ mode: {
406
+ type: 'string',
407
+ description: 'Resize mode',
408
+ required: true,
409
+ enum: ['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']
410
+ }
411
+ },
412
+ execute: (figma, { id, mode }) => {
413
+ const node = figma.getNodeById(id)
414
+ if (!node) return { error: `Node "${id}" not found` }
415
+ node.textAutoResize = mode
416
+ return { id, textAutoResize: mode }
417
+ }
418
+ })
419
+
420
+ export const setVisible = defineTool({
421
+ name: 'set_visible',
422
+ mutates: true,
423
+ description: 'Set visibility of a node.',
424
+ params: {
425
+ id: { type: 'string', description: 'Node ID', required: true },
426
+ value: { type: 'boolean', description: 'Visible (true/false)', required: true }
427
+ },
428
+ execute: (figma, { id, value }) => {
429
+ const node = figma.getNodeById(id)
430
+ if (!node) return { error: `Node "${id}" not found` }
431
+ node.visible = value
432
+ return { id, visible: value }
433
+ }
434
+ })
435
+
436
+ export const setBlend = defineTool({
437
+ name: 'set_blend',
438
+ mutates: true,
439
+ description: 'Set blend mode of a node.',
440
+ params: {
441
+ id: { type: 'string', description: 'Node ID', required: true },
442
+ mode: {
443
+ type: 'string',
444
+ description: 'Blend mode',
445
+ required: true,
446
+ enum: [
447
+ 'NORMAL',
448
+ 'DARKEN',
449
+ 'MULTIPLY',
450
+ 'COLOR_BURN',
451
+ 'LIGHTEN',
452
+ 'SCREEN',
453
+ 'COLOR_DODGE',
454
+ 'OVERLAY',
455
+ 'SOFT_LIGHT',
456
+ 'HARD_LIGHT',
457
+ 'DIFFERENCE',
458
+ 'EXCLUSION',
459
+ 'HUE',
460
+ 'SATURATION',
461
+ 'COLOR',
462
+ 'LUMINOSITY'
463
+ ]
464
+ }
465
+ },
466
+ execute: (figma, { id, mode }) => {
467
+ const node = figma.getNodeById(id)
468
+ if (!node) return { error: `Node "${id}" not found` }
469
+ node.blendMode = mode
470
+ return { id, blendMode: mode }
471
+ }
472
+ })
473
+
474
+ export const setLocked = defineTool({
475
+ name: 'set_locked',
476
+ mutates: true,
477
+ description: 'Set locked state of a node.',
478
+ params: {
479
+ id: { type: 'string', description: 'Node ID', required: true },
480
+ value: { type: 'boolean', description: 'Locked (true/false)', required: true }
481
+ },
482
+ execute: (figma, { id, value }) => {
483
+ const node = figma.getNodeById(id)
484
+ if (!node) return { error: `Node "${id}" not found` }
485
+ node.locked = value
486
+ return { id, locked: value }
487
+ }
488
+ })
489
+
490
+ export const setStrokeAlign = defineTool({
491
+ name: 'set_stroke_align',
492
+ mutates: true,
493
+ description: 'Set stroke alignment of a node.',
494
+ params: {
495
+ id: { type: 'string', description: 'Node ID', required: true },
496
+ align: {
497
+ type: 'string',
498
+ description: 'Stroke alignment',
499
+ required: true,
500
+ enum: ['INSIDE', 'CENTER', 'OUTSIDE']
501
+ }
502
+ },
503
+ execute: (figma, { id, align }) => {
504
+ const node = figma.getNodeById(id)
505
+ if (!node) return { error: `Node "${id}" not found` }
506
+ node.strokeAlign = align
507
+ return { id, strokeAlign: align }
508
+ }
509
+ })
510
+
511
+ export const setTextProperties = defineTool({
512
+ name: 'set_text_properties',
513
+ mutates: true,
514
+ description:
515
+ 'Set text layout properties: alignment, auto-resize, text case, decoration, truncation.',
516
+ params: {
517
+ id: { type: 'string', description: 'Text node ID', required: true },
518
+ align_horizontal: {
519
+ type: 'string',
520
+ description: 'Horizontal text alignment',
521
+ enum: ['LEFT', 'CENTER', 'RIGHT', 'JUSTIFIED']
522
+ },
523
+ align_vertical: {
524
+ type: 'string',
525
+ description: 'Vertical text alignment',
526
+ enum: ['TOP', 'CENTER', 'BOTTOM']
527
+ },
528
+ auto_resize: {
529
+ type: 'string',
530
+ description: 'Text auto-resize mode',
531
+ enum: ['NONE', 'WIDTH_AND_HEIGHT', 'HEIGHT', 'TRUNCATE']
532
+ },
533
+ text_decoration: {
534
+ type: 'string',
535
+ description: 'Text decoration',
536
+ enum: ['NONE', 'UNDERLINE', 'STRIKETHROUGH']
537
+ }
538
+ },
539
+ execute: (figma, args) => {
540
+ const node = figma.getNodeById(args.id)
541
+ if (!node) return { error: `Node "${args.id}" not found` }
542
+ if (node.type !== 'TEXT') return { error: `Node "${args.id}" is not a TEXT node` }
543
+ const updated: string[] = []
544
+ if (args.align_horizontal !== undefined) {
545
+ node.textAlignHorizontal = args.align_horizontal
546
+ updated.push('textAlignHorizontal')
547
+ }
548
+ if (args.align_vertical !== undefined) {
549
+ node.textAlignVertical = args.align_vertical
550
+ updated.push('textAlignVertical')
551
+ }
552
+ if (args.auto_resize !== undefined) {
553
+ node.textAutoResize = args.auto_resize
554
+ updated.push('textAutoResize')
555
+ }
556
+ if (args.text_decoration !== undefined) {
557
+ node.textDecoration = args.text_decoration
558
+ updated.push('textDecoration')
559
+ }
560
+ return { id: args.id, updated }
561
+ }
562
+ })
563
+
564
+ export const setLayoutChild = defineTool({
565
+ name: 'set_layout_child',
566
+ mutates: true,
567
+ description:
568
+ 'Configure auto-layout child: sizing (FIXED/HUG/FILL), grow, alignment, absolute positioning.',
569
+ params: {
570
+ id: { type: 'string', description: 'Child node ID', required: true },
571
+ sizing_horizontal: {
572
+ type: 'string',
573
+ description: 'Horizontal sizing mode',
574
+ enum: ['FIXED', 'HUG', 'FILL']
575
+ },
576
+ sizing_vertical: {
577
+ type: 'string',
578
+ description: 'Vertical sizing mode',
579
+ enum: ['FIXED', 'HUG', 'FILL']
580
+ },
581
+ grow: { type: 'number', description: 'Flex grow factor (0 = fixed, 1 = grow)', min: 0 },
582
+ align_self: {
583
+ type: 'string',
584
+ description: 'Self alignment override (cross-axis)',
585
+ enum: ['INHERIT', 'MIN', 'CENTER', 'MAX', 'STRETCH', 'BASELINE']
586
+ },
587
+ positioning: {
588
+ type: 'string',
589
+ description: 'ABSOLUTE to take node out of auto-layout flow',
590
+ enum: ['AUTO', 'ABSOLUTE']
591
+ }
592
+ },
593
+ execute: (figma, args) => {
594
+ const node = figma.getNodeById(args.id)
595
+ if (!node) return { error: `Node "${args.id}" not found` }
596
+ const updated: string[] = []
597
+ if (args.sizing_horizontal !== undefined) {
598
+ node.layoutSizingHorizontal = args.sizing_horizontal
599
+ updated.push('layoutSizingHorizontal')
600
+ }
601
+ if (args.sizing_vertical !== undefined) {
602
+ node.layoutSizingVertical = args.sizing_vertical
603
+ updated.push('layoutSizingVertical')
604
+ }
605
+ if (args.grow !== undefined) {
606
+ node.layoutGrow = args.grow
607
+ updated.push('layoutGrow')
608
+ }
609
+ if (args.align_self !== undefined) {
610
+ node.layoutAlign = args.align_self
611
+ updated.push('layoutAlign')
612
+ }
613
+ if (args.positioning !== undefined) {
614
+ node.layoutPositioning = args.positioning
615
+ updated.push('layoutPositioning')
616
+ }
617
+ return { id: args.id, updated }
618
+ }
619
+ })
620
+
621
+ export const setImageFill = defineTool({
622
+ name: 'set_image_fill',
623
+ mutates: true,
624
+ description: 'Set an image fill on a node from base64-encoded image data.',
625
+ params: {
626
+ id: { type: 'string', description: 'Node ID', required: true },
627
+ image_data: { type: 'string', description: 'Base64-encoded image bytes (PNG, JPEG, or WEBP)', required: true },
628
+ scale_mode: {
629
+ type: 'string',
630
+ description: 'Image scale mode',
631
+ default: 'FILL',
632
+ enum: ['FILL', 'FIT', 'CROP', 'TILE']
633
+ }
634
+ },
635
+ execute: (figma, { id, image_data, scale_mode }) => {
636
+ const node = figma.getNodeById(id)
637
+ if (!node) return { error: `Node "${id}" not found` }
638
+ const bytes = Uint8Array.fromBase64(image_data)
639
+ const image = figma.createImage(bytes)
640
+ const mode = (scale_mode ?? 'FILL') as 'FILL' | 'FIT' | 'CROP' | 'TILE'
641
+ node.fills = [{
642
+ type: 'IMAGE',
643
+ color: { r: 0, g: 0, b: 0, a: 1 },
644
+ opacity: 1,
645
+ visible: true,
646
+ imageHash: image.hash,
647
+ imageScaleMode: mode
648
+ }]
649
+ return { id, imageHash: image.hash, scaleMode: mode }
650
+ }
651
+ })