@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
@@ -0,0 +1,104 @@
1
+ import { PrototypeReaction, SceneGraph } from "@pairdraw/scene-graph";
2
+ import * as v from "valibot";
3
+ //#region src/figma-api/reactions.d.ts
4
+ declare const reactionSchema: v.StrictObjectSchema<{
5
+ readonly trigger: v.VariantSchema<"type", [v.StrictObjectSchema<{
6
+ readonly type: v.LiteralSchema<"ON_CLICK", undefined>;
7
+ }, undefined>, v.StrictObjectSchema<{
8
+ readonly type: v.LiteralSchema<"AFTER_TIMEOUT", undefined>;
9
+ readonly timeout: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
10
+ }, undefined>], undefined>;
11
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
12
+ readonly type: v.LiteralSchema<"NODE", undefined>;
13
+ readonly destinationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "Top-level frame on the page.">]>;
14
+ readonly navigation: v.PicklistSchema<("OVERLAY" | "NAVIGATE")[], undefined>;
15
+ readonly transition: v.OptionalSchema<v.StrictObjectSchema<{
16
+ readonly type: v.PicklistSchema<("INSTANT" | "DISSOLVE")[], undefined>;
17
+ readonly duration: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
18
+ }, undefined>, {
19
+ readonly type: "INSTANT";
20
+ readonly duration: 0;
21
+ }>;
22
+ readonly overlayRelativePosition: v.OptionalSchema<v.PicklistSchema<("CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT")[], undefined>, "CENTER">;
23
+ }, undefined>, v.StrictObjectSchema<{
24
+ readonly type: v.LiteralSchema<"BACK", undefined>;
25
+ }, undefined>, v.StrictObjectSchema<{
26
+ readonly type: v.LiteralSchema<"CLOSE", undefined>;
27
+ }, undefined>], undefined>, undefined>, v.MinLengthAction<({
28
+ type: "NODE";
29
+ destinationId: string;
30
+ navigation: "OVERLAY" | "NAVIGATE";
31
+ transition: {
32
+ type: "INSTANT" | "DISSOLVE";
33
+ duration: number;
34
+ };
35
+ overlayRelativePosition: "CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT";
36
+ } | {
37
+ type: "BACK";
38
+ } | {
39
+ type: "CLOSE";
40
+ })[], 1, undefined>]>;
41
+ }, undefined>;
42
+ /** The plugin shape as a contract, for a tool that takes connections as arguments. */
43
+ declare const figmaReactionsSchema: v.ArraySchema<v.StrictObjectSchema<{
44
+ readonly trigger: v.VariantSchema<"type", [v.StrictObjectSchema<{
45
+ readonly type: v.LiteralSchema<"ON_CLICK", undefined>;
46
+ }, undefined>, v.StrictObjectSchema<{
47
+ readonly type: v.LiteralSchema<"AFTER_TIMEOUT", undefined>;
48
+ readonly timeout: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
49
+ }, undefined>], undefined>;
50
+ readonly actions: v.SchemaWithPipe<readonly [v.ArraySchema<v.VariantSchema<"type", [v.StrictObjectSchema<{
51
+ readonly type: v.LiteralSchema<"NODE", undefined>;
52
+ readonly destinationId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.DescriptionAction<string, "Top-level frame on the page.">]>;
53
+ readonly navigation: v.PicklistSchema<("OVERLAY" | "NAVIGATE")[], undefined>;
54
+ readonly transition: v.OptionalSchema<v.StrictObjectSchema<{
55
+ readonly type: v.PicklistSchema<("INSTANT" | "DISSOLVE")[], undefined>;
56
+ readonly duration: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 0, undefined>]>;
57
+ }, undefined>, {
58
+ readonly type: "INSTANT";
59
+ readonly duration: 0;
60
+ }>;
61
+ readonly overlayRelativePosition: v.OptionalSchema<v.PicklistSchema<("CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT")[], undefined>, "CENTER">;
62
+ }, undefined>, v.StrictObjectSchema<{
63
+ readonly type: v.LiteralSchema<"BACK", undefined>;
64
+ }, undefined>, v.StrictObjectSchema<{
65
+ readonly type: v.LiteralSchema<"CLOSE", undefined>;
66
+ }, undefined>], undefined>, undefined>, v.MinLengthAction<({
67
+ type: "NODE";
68
+ destinationId: string;
69
+ navigation: "OVERLAY" | "NAVIGATE";
70
+ transition: {
71
+ type: "INSTANT" | "DISSOLVE";
72
+ duration: number;
73
+ };
74
+ overlayRelativePosition: "CENTER" | "TOP_LEFT" | "TOP_CENTER" | "TOP_RIGHT" | "BOTTOM_LEFT" | "BOTTOM_CENTER" | "BOTTOM_RIGHT";
75
+ } | {
76
+ type: "BACK";
77
+ } | {
78
+ type: "CLOSE";
79
+ })[], 1, undefined>]>;
80
+ }, undefined>, undefined>;
81
+ /** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */
82
+ type FigmaReaction = v.InferOutput<typeof reactionSchema>;
83
+ type FigmaReactionTrigger = FigmaReaction['trigger'];
84
+ type FigmaReactionAction = FigmaReaction['actions'][number];
85
+ /** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */
86
+ declare function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction;
87
+ /** The validation context: where the reactions live, and what they may point at. */
88
+ interface ReactionContext {
89
+ graph: SceneGraph;
90
+ /** The page the layer is on; a destination must be a top-level frame on it. */
91
+ pageId: string;
92
+ /** The reactions the layer has now, whose ids this keeps by position. */
93
+ previous?: readonly PrototypeReaction[];
94
+ }
95
+ /**
96
+ * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.
97
+ * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,
98
+ * an action, transition, navigation or overlay spot outside the model, and a destination that
99
+ * is not a top-level frame on the layer's page are refused rather than kept unplayable.
100
+ */
101
+ declare function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[];
102
+ //#endregion
103
+ export { FigmaReaction, FigmaReactionAction, FigmaReactionTrigger, ReactionContext, figmaReactionsSchema, parseFigmaReactions, toFigmaReaction };
104
+ //# sourceMappingURL=reactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactions.d.ts","names":[],"sources":["../../src/figma-api/reactions.ts"],"mappings":";;;cA4EM,gBAAc,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAQP,sBAAoB,EAAA,YAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAGrB,gBAAgB,EAAE,mBAAmB;KACrC,uBAAuB;KACvB,sBAAsB;;iBAGlB,gBAAgB,UAAU,oBAAoB;;UAoB7C;EACf,OAAO;;EAEP;;EAEA,oBAAoB;;;;;;;;iBASN,oBAAoB,gBAAgB,SAAS,kBAAkB"}
@@ -0,0 +1,157 @@
1
+ import { issuePath } from "./effects.js";
2
+ import { generateId } from "@pairdraw/scene-graph";
3
+ import * as v from "valibot";
4
+ //#region src/figma-api/reactions.ts
5
+ /**
6
+ * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the
7
+ * message it gets instead. Only a click and a timeout play.
8
+ */
9
+ const UNSUPPORTED_TRIGGERS = {
10
+ ON_DRAG: true,
11
+ ON_HOVER: true,
12
+ ON_PRESS: true,
13
+ MOUSE_ENTER: true,
14
+ MOUSE_LEAVE: true,
15
+ MOUSE_UP: true,
16
+ MOUSE_DOWN: true,
17
+ ON_KEY_DOWN: true
18
+ };
19
+ /** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */
20
+ const UNSUPPORTED_ACTIONS = {
21
+ URL: true,
22
+ SET_VARIABLE: true,
23
+ CONDITIONAL: true,
24
+ SET_VARIABLE_MODE: true
25
+ };
26
+ const secondsSchema = v.pipe(v.number(), v.minValue(0));
27
+ const overlayPositionSchema = v.picklist([
28
+ "CENTER",
29
+ "TOP_LEFT",
30
+ "TOP_CENTER",
31
+ "TOP_RIGHT",
32
+ "BOTTOM_LEFT",
33
+ "BOTTOM_CENTER",
34
+ "BOTTOM_RIGHT"
35
+ ]);
36
+ const transitionSchema = v.strictObject({
37
+ type: v.picklist(["INSTANT", "DISSOLVE"]),
38
+ duration: secondsSchema
39
+ });
40
+ const nodeActionSchema = v.strictObject({
41
+ type: v.literal("NODE"),
42
+ destinationId: v.pipe(v.string(), v.minLength(1), v.description("Top-level frame on the page.")),
43
+ navigation: v.picklist(["NAVIGATE", "OVERLAY"]),
44
+ transition: v.optional(transitionSchema, {
45
+ type: "INSTANT",
46
+ duration: 0
47
+ }),
48
+ overlayRelativePosition: v.optional(overlayPositionSchema, "CENTER")
49
+ });
50
+ const actionSchema = v.variant("type", [
51
+ nodeActionSchema,
52
+ v.strictObject({ type: v.literal("BACK") }),
53
+ v.strictObject({ type: v.literal("CLOSE") })
54
+ ]);
55
+ const triggerSchema = v.variant("type", [v.strictObject({ type: v.literal("ON_CLICK") }), v.strictObject({
56
+ type: v.literal("AFTER_TIMEOUT"),
57
+ timeout: secondsSchema
58
+ })]);
59
+ const reactionSchema = v.strictObject({
60
+ trigger: triggerSchema,
61
+ actions: v.pipe(v.array(actionSchema), v.minLength(1))
62
+ });
63
+ const reactionsSchema = v.array(reactionSchema);
64
+ /** The plugin shape as a contract, for a tool that takes connections as arguments. */
65
+ const figmaReactionsSchema = reactionsSchema;
66
+ /** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */
67
+ function toFigmaReaction(reaction) {
68
+ return {
69
+ trigger: reaction.trigger.type === "AFTER_TIMEOUT" ? {
70
+ type: "AFTER_TIMEOUT",
71
+ timeout: reaction.trigger.delay
72
+ } : { type: "ON_CLICK" },
73
+ actions: reaction.actions.map(toFigmaAction)
74
+ };
75
+ }
76
+ function toFigmaAction(action) {
77
+ if (action.type !== "NODE") return { type: action.type };
78
+ return {
79
+ type: "NODE",
80
+ destinationId: action.nodeId ?? "",
81
+ navigation: action.navigation,
82
+ transition: {
83
+ type: action.transition.type,
84
+ duration: action.transition.duration
85
+ },
86
+ overlayRelativePosition: action.overlayPosition
87
+ };
88
+ }
89
+ /**
90
+ * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.
91
+ * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,
92
+ * an action, transition, navigation or overlay spot outside the model, and a destination that
93
+ * is not a top-level frame on the layer's page are refused rather than kept unplayable.
94
+ */
95
+ function parseFigmaReactions(value, context) {
96
+ const unsupported = unsupportedKind(value);
97
+ if (unsupported) throw new Error(`Property "reactions" failed validation: ${unsupported}`);
98
+ const result = v.safeParse(reactionsSchema, value);
99
+ if (!result.success) {
100
+ const [issue] = result.issues;
101
+ throw new Error(`Property "reactions" failed validation: ${issue.message} at ${issuePath(issue.path) || "reactions"}`);
102
+ }
103
+ return result.output.map((reaction, index) => {
104
+ return {
105
+ id: context.previous?.[index]?.id ?? generateId(),
106
+ trigger: toTrigger(reaction.trigger),
107
+ actions: reaction.actions.map((action) => toAction(action, context, index))
108
+ };
109
+ });
110
+ }
111
+ function toTrigger(trigger) {
112
+ return {
113
+ type: trigger.type,
114
+ delay: trigger.type === "AFTER_TIMEOUT" ? trigger.timeout : 0
115
+ };
116
+ }
117
+ function toAction(action, context, reactionIndex) {
118
+ if (action.type !== "NODE") return { type: action.type };
119
+ assertDestination(action.destinationId, context, reactionIndex);
120
+ return {
121
+ type: "NODE",
122
+ nodeId: action.destinationId,
123
+ navigation: action.navigation,
124
+ transition: action.transition,
125
+ overlayPosition: action.navigation === "OVERLAY" ? action.overlayRelativePosition : "CENTER"
126
+ };
127
+ }
128
+ /** A destination must be a frame at the top of the layer's page, as the play can only show one. */
129
+ function assertDestination(destinationId, context, index) {
130
+ const destination = context.graph.getNode(destinationId);
131
+ const at = `reactions[${index}]`;
132
+ if (!destination) throw new Error(`Property "reactions" failed validation: no layer ${destinationId} at ${at}.actions[0].destinationId`);
133
+ if (destination.type !== "FRAME" || destination.parentId !== context.pageId) throw new Error(`Property "reactions" failed validation: ${at} must navigate to a top-level frame on the same page, not ${destination.type} "${destination.name}"`);
134
+ }
135
+ /** Figma's first unsupported trigger or action kind in `value`, if it has one. */
136
+ function unsupportedKind(value) {
137
+ if (!Array.isArray(value)) return null;
138
+ const reactions = value.filter((reaction) => Boolean(reaction) && typeof reaction === "object");
139
+ for (const reaction of reactions) {
140
+ const trigger = reaction.trigger;
141
+ if (trigger && typeof trigger === "object" && "type" in trigger) {
142
+ const type = trigger.type;
143
+ if (typeof type === "string" && type in UNSUPPORTED_TRIGGERS) return `a prototype starts from ON_CLICK or AFTER_TIMEOUT, not ${type}`;
144
+ }
145
+ const actions = reaction.actions;
146
+ if (!Array.isArray(actions)) continue;
147
+ for (const action of actions) if (action && typeof action === "object" && "type" in action) {
148
+ const type = action.type;
149
+ if (typeof type === "string" && type in UNSUPPORTED_ACTIONS) return `an action is NODE, BACK or CLOSE, not ${type}`;
150
+ }
151
+ }
152
+ return null;
153
+ }
154
+ //#endregion
155
+ export { figmaReactionsSchema, parseFigmaReactions, toFigmaReaction };
156
+
157
+ //# sourceMappingURL=reactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactions.js","names":[],"sources":["../../src/figma-api/reactions.ts"],"sourcesContent":["import * as v from 'valibot'\n\nimport { generateId } from '@pairdraw/scene-graph'\nimport type {\n PrototypeAction,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph\n} from '@pairdraw/scene-graph'\n\nimport { issuePath } from '#core/figma-api/effects'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead. Only a click and a timeout play.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: true,\n ON_HOVER: true,\n ON_PRESS: true,\n MOUSE_ENTER: true,\n MOUSE_LEAVE: true,\n MOUSE_UP: true,\n MOUSE_DOWN: true,\n ON_KEY_DOWN: true\n}\n\n/** Actions Figma's plugin API offers that a prototype in Pairdraw cannot run. */\nconst UNSUPPORTED_ACTIONS: Record<string, true> = {\n URL: true,\n SET_VARIABLE: true,\n CONDITIONAL: true,\n SET_VARIABLE_MODE: true\n}\n\n// No `v.finite()` action: the MCP tool contract turns this schema into JSON Schema, which\n// has no notion of infinities, and JSON numbers are always finite anyway.\nconst secondsSchema = v.pipe(v.number(), v.minValue(0))\n\nconst overlayPositionSchema = v.picklist([\n 'CENTER',\n 'TOP_LEFT',\n 'TOP_CENTER',\n 'TOP_RIGHT',\n 'BOTTOM_LEFT',\n 'BOTTOM_CENTER',\n 'BOTTOM_RIGHT'\n] satisfies PrototypeOverlayPositionType[])\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema\n})\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.pipe(v.string(), v.minLength(1), v.description('Top-level frame on the page.')),\n navigation: v.picklist(['NAVIGATE', 'OVERLAY'] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.literal('ON_CLICK') }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema })\n])\n\nconst reactionSchema = v.strictObject({\n trigger: triggerSchema,\n actions: v.pipe(v.array(actionSchema), v.minLength(1))\n})\n\nconst reactionsSchema = v.array(reactionSchema)\n\n/** The plugin shape as a contract, for a tool that takes connections as arguments. */\nexport const figmaReactionsSchema = reactionsSchema\n\n/** A reaction as Figma's plugin API reads and writes it (`Reaction` in `@figma/plugin-typings`). */\nexport type FigmaReaction = v.InferOutput<typeof reactionSchema>\nexport type FigmaReactionTrigger = FigmaReaction['trigger']\nexport type FigmaReactionAction = FigmaReaction['actions'][number]\n\n/** `reaction` in the plugin shape: the trigger and every action, named as Figma names them. */\nexport function toFigmaReaction(reaction: PrototypeReaction): FigmaReaction {\n const trigger: FigmaReactionTrigger =\n reaction.trigger.type === 'AFTER_TIMEOUT'\n ? { type: 'AFTER_TIMEOUT', timeout: reaction.trigger.delay }\n : { type: 'ON_CLICK' }\n return { trigger, actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: { type: action.transition.type, duration: action.transition.duration },\n overlayRelativePosition: action.overlayPosition\n }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The page the layer is on; a destination must be a top-level frame on it. */\n pageId: string\n /** The reactions the layer has now, whose ids this keeps by position. */\n previous?: readonly PrototypeReaction[]\n}\n\n/**\n * `value` as the layer's prototype reactions, or an error naming what Pairdraw cannot play.\n * Accepts Figma's plugin shape only: a trigger Figma offers but playback does not start from,\n * an action, transition, navigation or overlay spot outside the model, and a destination that\n * is not a top-level frame on the layer's page are refused rather than kept unplayable.\n */\nexport function parseFigmaReactions(value: unknown, context: ReactionContext): PrototypeReaction[] {\n const unsupported = unsupportedKind(value)\n if (unsupported) throw new Error(`Property \"reactions\" failed validation: ${unsupported}`)\n const result = v.safeParse(reactionsSchema, value)\n if (!result.success) {\n const [issue] = result.issues\n throw new Error(\n `Property \"reactions\" failed validation: ${issue.message} at ${issuePath(issue.path) || 'reactions'}`\n )\n }\n return result.output.map((reaction, index) => {\n const id = context.previous?.[index]?.id ?? generateId()\n return {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n return { type, delay: trigger.type === 'AFTER_TIMEOUT' ? trigger.timeout : 0 }\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type !== 'NODE') return { type: action.type }\n assertDestination(action.destinationId, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: action.destinationId,\n navigation: action.navigation,\n transition: action.transition,\n // Only an overlay uses the spot; Figma keeps CENTER on a navigation.\n overlayPosition: action.navigation === 'OVERLAY' ? action.overlayRelativePosition : 'CENTER'\n }\n}\n\n/** A destination must be a frame at the top of the layer's page, as the play can only show one. */\nfunction assertDestination(destinationId: string, context: ReactionContext, index: number): void {\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) {\n throw new Error(\n `Property \"reactions\" failed validation: no layer ${destinationId} at ${at}.actions[0].destinationId`\n )\n }\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw new Error(\n `Property \"reactions\" failed validation: ${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** Figma's first unsupported trigger or action kind in `value`, if it has one. */\nfunction unsupportedKind(value: unknown): string | null {\n if (!Array.isArray(value)) return null\n const reactions = value.filter(\n (reaction): reaction is Record<string, unknown> =>\n Boolean(reaction) && typeof reaction === 'object'\n )\n for (const reaction of reactions) {\n const trigger = reaction.trigger\n if (trigger && typeof trigger === 'object' && 'type' in trigger) {\n const type = trigger.type\n if (typeof type === 'string' && type in UNSUPPORTED_TRIGGERS) {\n return `a prototype starts from ON_CLICK or AFTER_TIMEOUT, not ${type}`\n }\n }\n const actions = reaction.actions\n if (!Array.isArray(actions)) continue\n for (const action of actions) {\n if (action && typeof action === 'object' && 'type' in action) {\n const type = action.type\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n }\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;AAmBA,MAAM,uBAA6C;CACjD,SAAS;CACT,UAAU;CACV,UAAU;CACV,aAAa;CACb,aAAa;CACb,UAAU;CACV,YAAY;CACZ,aAAa;AACf;;AAGA,MAAM,sBAA4C;CAChD,KAAK;CACL,cAAc;CACd,aAAa;CACb,mBAAmB;AACrB;AAIA,MAAM,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC;AAEtD,MAAM,wBAAwB,EAAE,SAAS;CACvC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAA0C;AAE1C,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,SAAS,CAAC,WAAW,UAAU,CAAqC;CAC5E,UAAU;AACZ,CAAC;AAED,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,QAAQ,MAAM;CACtB,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,8BAA8B,CAAC;CAC/F,YAAY,EAAE,SAAS,CAAC,YAAY,SAAS,CAAqC;CAClF,YAAY,EAAE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,YAAY,MAAM,QACrB,aACC,QAAQ,QAAQ,KAAK,OAAO,aAAa,QAC7C;CACA,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,SAAS;EACzB,IAAI,WAAW,OAAO,YAAY,YAAY,UAAU,SAAS;GAC/D,MAAM,OAAO,QAAQ;GACrB,IAAI,OAAO,SAAS,YAAY,QAAQ,sBACtC,OAAO,0DAA0D;EAErE;EACA,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;EAC7B,KAAK,MAAM,UAAU,SACnB,IAAI,UAAU,OAAO,WAAW,YAAY,UAAU,QAAQ;GAC5D,MAAM,OAAO,OAAO;GACpB,IAAI,OAAO,SAAS,YAAY,QAAQ,qBACtC,OAAO,yCAAyC;EAEpD;CAEJ;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"render-bounds.d.ts","names":[],"sources":["../../src/figma-api/render-bounds.ts"],"mappings":";;;;iBA0KgB,4BAA4B,OAAO,YAAY,MAAM,YAAY"}
1
+ {"version":3,"file":"render-bounds.d.ts","names":[],"sources":["../../src/figma-api/render-bounds.ts"],"mappings":";;;;iBAmLgB,4BAA4B,OAAO,YAAY,MAAM,YAAY"}
@@ -1,6 +1,6 @@
1
1
  import { getWorldMatrix } from "@pairdraw/scene-graph/coordinate";
2
2
  import { geometryBlobBounds, intersectVisualBounds, strokeOverflow, unionVisualBounds } from "@pairdraw/scene-graph/geometry";
3
- import { textLinesOverflow } from "@pairdraw/scene-graph/text";
3
+ import { textLinesReach } from "@pairdraw/scene-graph/text";
4
4
  import Matrix from "@pairdraw/scene-graph/matrix";
5
5
  //#region src/figma-api/render-bounds.ts
6
6
  const INTRINSIC_CONTAINER_TYPES = /* @__PURE__ */ new Set([
@@ -58,13 +58,13 @@ function translatedBounds(bounds, offset, overflow) {
58
58
  }
59
59
  function ownRenderBounds(node, graph) {
60
60
  if (!hasRenderableGeometry(node)) return null;
61
- const linesOverflow = textLinesOverflow(node);
62
- const base = transformedRect(node, graph, 0, 0, node.width, node.height + linesOverflow);
61
+ const linesReach = textLinesReach(node);
62
+ const base = transformedRect(node, graph, 0, linesReach.minY, node.width, linesReach.maxY - linesReach.minY);
63
63
  const stroke = strokeOverflow(node.strokes, node.strokeCap, node.vectorNetwork, node);
64
64
  let bounds = transformedRect(node, graph, -stroke, -stroke, node.width + stroke * 2, node.height + stroke * 2);
65
65
  const localGeometry = geometryBlobBounds([...node.fillGeometry, ...node.strokeGeometry]);
66
66
  if (localGeometry) bounds = unionVisualBounds(bounds, transformedRect(node, graph, localGeometry.x, localGeometry.y, localGeometry.width, localGeometry.height)) ?? bounds;
67
- if (linesOverflow > 0) bounds = unionVisualBounds(bounds, base) ?? bounds;
67
+ if (linesReach.minY < 0 || linesReach.maxY > node.height) bounds = unionVisualBounds(bounds, base) ?? bounds;
68
68
  for (const effect of node.effects) {
69
69
  if (!effect.visible) continue;
70
70
  if (effect.type === "DROP_SHADOW") bounds = unionVisualBounds(bounds, translatedBounds(base, effect.offset, effect.radius * 3 + effect.spread)) ?? bounds;
@@ -1 +1 @@
1
- {"version":3,"file":"render-bounds.js","names":[],"sources":["../../src/figma-api/render-bounds.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { getWorldMatrix } from '@pairdraw/scene-graph/coordinate'\nimport {\n geometryBlobBounds,\n intersectVisualBounds,\n strokeOverflow,\n unionVisualBounds,\n type VisualBounds\n} from '@pairdraw/scene-graph/geometry'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport { textLinesOverflow } from '@pairdraw/scene-graph/text'\n\nconst INTRINSIC_CONTAINER_TYPES = new Set([\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE',\n 'SECTION'\n])\n\nfunction aabb(points: number[]): VisualBounds {\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (let index = 0; index < points.length; index += 2) {\n minX = Math.min(minX, points[index])\n minY = Math.min(minY, points[index + 1])\n maxX = Math.max(maxX, points[index])\n maxY = Math.max(maxY, points[index + 1])\n }\n return { minX, minY, maxX, maxY }\n}\n\nfunction transformedRect(\n node: SceneNode,\n graph: SceneGraph,\n x: number,\n y: number,\n width: number,\n height: number\n): VisualBounds {\n return aabb(\n Matrix.mapPoints(getWorldMatrix(node, graph), [\n x,\n y,\n x + width,\n y,\n x + width,\n y + height,\n x,\n y + height\n ])\n )\n}\n\nfunction hasRenderableGeometry(node: SceneNode): boolean {\n if (INTRINSIC_CONTAINER_TYPES.has(node.type)) return true\n if (node.type === 'GROUP') return false\n if (node.type === 'TEXT') return node.text.length > 0 && node.fills.some((fill) => fill.visible)\n // A vector without a path draws nothing, whatever its paints.\n if (\n node.type === 'VECTOR' &&\n !node.vectorNetwork?.vertices.length &&\n node.fillGeometry.length === 0 &&\n node.strokeGeometry.length === 0\n ) {\n return false\n }\n if (node.fills.some((fill) => fill.visible) || node.strokes.some((stroke) => stroke.visible)) {\n return true\n }\n return node.fillGeometry.length > 0 || node.strokeGeometry.length > 0\n}\n\nfunction translatedBounds(bounds: VisualBounds, offset: Vector, overflow: number): VisualBounds {\n return {\n minX: bounds.minX + offset.x - overflow,\n minY: bounds.minY + offset.y - overflow,\n maxX: bounds.maxX + offset.x + overflow,\n maxY: bounds.maxY + offset.y + overflow\n }\n}\n\nfunction ownRenderBounds(node: SceneNode, graph: SceneGraph): VisualBounds | null {\n if (!hasRenderableGeometry(node)) return null\n\n // Text lines past a fixed-size box draw, and cast their shadow, as in Figma.\n const linesOverflow = textLinesOverflow(node)\n const base = transformedRect(node, graph, 0, 0, node.width, node.height + linesOverflow)\n const stroke = strokeOverflow(node.strokes, node.strokeCap, node.vectorNetwork, node)\n let bounds = transformedRect(\n node,\n graph,\n -stroke,\n -stroke,\n node.width + stroke * 2,\n node.height + stroke * 2\n )\n const localGeometry = geometryBlobBounds([...node.fillGeometry, ...node.strokeGeometry])\n if (localGeometry) {\n bounds =\n unionVisualBounds(\n bounds,\n transformedRect(\n node,\n graph,\n localGeometry.x,\n localGeometry.y,\n localGeometry.width,\n localGeometry.height\n )\n ) ?? bounds\n }\n\n if (linesOverflow > 0) bounds = unionVisualBounds(bounds, base) ?? bounds\n\n for (const effect of node.effects) {\n if (!effect.visible) continue\n if (effect.type === 'DROP_SHADOW') {\n bounds =\n unionVisualBounds(\n bounds,\n translatedBounds(base, effect.offset, effect.radius * 3 + effect.spread)\n ) ?? bounds\n } else if (effect.type === 'LAYER_BLUR' || effect.type === 'FOREGROUND_BLUR') {\n bounds = translatedBounds(bounds, { x: 0, y: 0 }, effect.radius + effect.spread)\n }\n }\n return bounds\n}\n\nfunction effectiveClip(node: SceneNode, graph: SceneGraph): VisualBounds | null | undefined {\n let clip: VisualBounds | null | undefined\n let current: SceneNode | undefined = node\n while (current) {\n if (!current.visible || current.opacity <= 0) return null\n if (\n current.id !== node.id &&\n current.clipsContent &&\n (current.type === 'FRAME' || current.type === 'COMPONENT' || current.type === 'INSTANCE')\n ) {\n const currentClip = transformedRect(current, graph, 0, 0, current.width, current.height)\n clip = clip ? intersectVisualBounds(clip, currentClip) : currentClip\n if (!clip) return null\n }\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return clip\n}\n\nfunction groupRenderBounds(node: SceneNode, graph: SceneGraph): VisualBounds | null {\n let bounds: VisualBounds | null = null\n for (const childId of node.childIds) {\n const child = graph.getNode(childId)\n if (!child) continue\n const childBounds = computeAbsoluteRenderBounds(graph, child)\n if (!childBounds) continue\n bounds = unionVisualBounds(bounds, {\n minX: childBounds.x,\n minY: childBounds.y,\n maxX: childBounds.x + childBounds.width,\n maxY: childBounds.y + childBounds.height\n })\n }\n return bounds\n}\n\n/** Return Figma-compatible rendered bounds, or null when the node paints no visible pixels. */\nexport function computeAbsoluteRenderBounds(graph: SceneGraph, node: SceneNode): Rect | null {\n const clip = effectiveClip(node, graph)\n if (clip === null) return null\n\n const visual =\n node.type === 'GROUP' ? groupRenderBounds(node, graph) : ownRenderBounds(node, graph)\n const clipped = visual && clip ? intersectVisualBounds(visual, clip) : visual\n if (!clipped || clipped.maxX <= clipped.minX || clipped.maxY <= clipped.minY) return null\n return {\n x: clipped.minX,\n y: clipped.minY,\n width: clipped.maxX - clipped.minX,\n height: clipped.maxY - clipped.minY\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,KAAK,QAAgC;CAC5C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS,GAAG;EACrD,OAAO,KAAK,IAAI,MAAM,OAAO,MAAM;EACnC,OAAO,KAAK,IAAI,MAAM,OAAO,QAAQ,EAAE;EACvC,OAAO,KAAK,IAAI,MAAM,OAAO,MAAM;EACnC,OAAO,KAAK,IAAI,MAAM,OAAO,QAAQ,EAAE;CACzC;CACA,OAAO;EAAE;EAAM;EAAM;EAAM;CAAK;AAClC;AAEA,SAAS,gBACP,MACA,OACA,GACA,GACA,OACA,QACc;CACd,OAAO,KACL,OAAO,UAAU,eAAe,MAAM,KAAK,GAAG;EAC5C;EACA;EACA,IAAI;EACJ;EACA,IAAI;EACJ,IAAI;EACJ;EACA,IAAI;CACN,CAAC,CACH;AACF;AAEA,SAAS,sBAAsB,MAA0B;CACvD,IAAI,0BAA0B,IAAI,KAAK,IAAI,GAAG,OAAO;CACrD,IAAI,KAAK,SAAS,SAAS,OAAO;CAClC,IAAI,KAAK,SAAS,QAAQ,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,MAAM,MAAM,SAAS,KAAK,OAAO;CAE/F,IACE,KAAK,SAAS,YACd,CAAC,KAAK,eAAe,SAAS,UAC9B,KAAK,aAAa,WAAW,KAC7B,KAAK,eAAe,WAAW,GAE/B,OAAO;CAET,I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Q,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,OAAO;CACrF,OAAO;EACL,GAAG,QAAQ;EACX,GAAG,QAAQ;EACX,OAAO,QAAQ,OAAO,QAAQ;EAC9B,QAAQ,QAAQ,OAAO,QAAQ;CACjC;AACF"}
1
+ {"version":3,"file":"render-bounds.js","names":[],"sources":["../../src/figma-api/render-bounds.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { getWorldMatrix } from '@pairdraw/scene-graph/coordinate'\nimport {\n geometryBlobBounds,\n intersectVisualBounds,\n strokeOverflow,\n unionVisualBounds,\n type VisualBounds\n} from '@pairdraw/scene-graph/geometry'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Rect, Vector } from '@pairdraw/scene-graph/primitives'\nimport { textLinesReach } from '@pairdraw/scene-graph/text'\n\nconst INTRINSIC_CONTAINER_TYPES = new Set([\n 'FRAME',\n 'COMPONENT',\n 'COMPONENT_SET',\n 'INSTANCE',\n 'SECTION'\n])\n\nfunction aabb(points: number[]): VisualBounds {\n let minX = Infinity\n let minY = Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n for (let index = 0; index < points.length; index += 2) {\n minX = Math.min(minX, points[index])\n minY = Math.min(minY, points[index + 1])\n maxX = Math.max(maxX, points[index])\n maxY = Math.max(maxY, points[index + 1])\n }\n return { minX, minY, maxX, maxY }\n}\n\nfunction transformedRect(\n node: SceneNode,\n graph: SceneGraph,\n x: number,\n y: number,\n width: number,\n height: number\n): VisualBounds {\n return aabb(\n Matrix.mapPoints(getWorldMatrix(node, graph), [\n x,\n y,\n x + width,\n y,\n x + width,\n y + height,\n x,\n y + height\n ])\n )\n}\n\nfunction hasRenderableGeometry(node: SceneNode): boolean {\n if (INTRINSIC_CONTAINER_TYPES.has(node.type)) return true\n if (node.type === 'GROUP') return false\n if (node.type === 'TEXT') return node.text.length > 0 && node.fills.some((fill) => fill.visible)\n // A vector without a path draws nothing, whatever its paints.\n if (\n node.type === 'VECTOR' &&\n !node.vectorNetwork?.vertices.length &&\n node.fillGeometry.length === 0 &&\n node.strokeGeometry.length === 0\n ) {\n return false\n }\n if (node.fills.some((fill) => fill.visible) || node.strokes.some((stroke) => stroke.visible)) {\n return true\n }\n return node.fillGeometry.length > 0 || node.strokeGeometry.length > 0\n}\n\nfunction translatedBounds(bounds: VisualBounds, offset: Vector, overflow: number): VisualBounds {\n return {\n minX: bounds.minX + offset.x - overflow,\n minY: bounds.minY + offset.y - overflow,\n maxX: bounds.maxX + offset.x + overflow,\n maxY: bounds.maxY + offset.y + overflow\n }\n}\n\nfunction ownRenderBounds(node: SceneNode, graph: SceneGraph): VisualBounds | null {\n if (!hasRenderableGeometry(node)) return null\n\n // Text lines past a fixed-size box draw, and cast their shadow, as in Figma.\n const linesReach = textLinesReach(node)\n const base = transformedRect(\n node,\n graph,\n 0,\n linesReach.minY,\n node.width,\n linesReach.maxY - linesReach.minY\n )\n const stroke = strokeOverflow(node.strokes, node.strokeCap, node.vectorNetwork, node)\n let bounds = transformedRect(\n node,\n graph,\n -stroke,\n -stroke,\n node.width + stroke * 2,\n node.height + stroke * 2\n )\n const localGeometry = geometryBlobBounds([...node.fillGeometry, ...node.strokeGeometry])\n if (localGeometry) {\n bounds =\n unionVisualBounds(\n bounds,\n transformedRect(\n node,\n graph,\n localGeometry.x,\n localGeometry.y,\n localGeometry.width,\n localGeometry.height\n )\n ) ?? bounds\n }\n\n if (linesReach.minY < 0 || linesReach.maxY > node.height) {\n bounds = unionVisualBounds(bounds, base) ?? bounds\n }\n\n for (const effect of node.effects) {\n if (!effect.visible) continue\n if (effect.type === 'DROP_SHADOW') {\n bounds =\n unionVisualBounds(\n bounds,\n translatedBounds(base, effect.offset, effect.radius * 3 + effect.spread)\n ) ?? bounds\n } else if (effect.type === 'LAYER_BLUR' || effect.type === 'FOREGROUND_BLUR') {\n bounds = translatedBounds(bounds, { x: 0, y: 0 }, effect.radius + effect.spread)\n }\n }\n return bounds\n}\n\nfunction effectiveClip(node: SceneNode, graph: SceneGraph): VisualBounds | null | undefined {\n let clip: VisualBounds | null | undefined\n let current: SceneNode | undefined = node\n while (current) {\n if (!current.visible || current.opacity <= 0) return null\n if (\n current.id !== node.id &&\n current.clipsContent &&\n (current.type === 'FRAME' || current.type === 'COMPONENT' || current.type === 'INSTANCE')\n ) {\n const currentClip = transformedRect(current, graph, 0, 0, current.width, current.height)\n clip = clip ? intersectVisualBounds(clip, currentClip) : currentClip\n if (!clip) return null\n }\n current = current.parentId ? graph.getNode(current.parentId) : undefined\n }\n return clip\n}\n\nfunction groupRenderBounds(node: SceneNode, graph: SceneGraph): VisualBounds | null {\n let bounds: VisualBounds | null = null\n for (const childId of node.childIds) {\n const child = graph.getNode(childId)\n if (!child) continue\n const childBounds = computeAbsoluteRenderBounds(graph, child)\n if (!childBounds) continue\n bounds = unionVisualBounds(bounds, {\n minX: childBounds.x,\n minY: childBounds.y,\n maxX: childBounds.x + childBounds.width,\n maxY: childBounds.y + childBounds.height\n })\n }\n return bounds\n}\n\n/** Return Figma-compatible rendered bounds, or null when the node paints no visible pixels. */\nexport function computeAbsoluteRenderBounds(graph: SceneGraph, node: SceneNode): Rect | null {\n const clip = effectiveClip(node, graph)\n if (clip === null) return null\n\n const visual =\n node.type === 'GROUP' ? groupRenderBounds(node, graph) : ownRenderBounds(node, graph)\n const clipped = visual && clip ? intersectVisualBounds(visual, clip) : visual\n if (!clipped || clipped.maxX <= clipped.minX || clipped.maxY <= clipped.minY) return null\n return {\n x: clipped.minX,\n y: clipped.minY,\n width: clipped.maxX - clipped.minX,\n height: clipped.maxY - clipped.minY\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,4CAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,KAAK,QAAgC;CAC5C,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,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WAAW,IAAI;GACzD,IAAI,CAAC,MAAM,OAAO;EACpB;EACA,UAAU,QAAQ,WAAW,MAAM,QAAQ,QAAQ,QAAQ,IAAI,KAAA;CACjE;CACA,OAAO;AACT;AAEA,SAAS,kBAAkB,MAAiB,OAAwC;CAClF,IAAI,SAA8B;CAClC,KAAK,MAAM,WAAW,KAAK,UAAU;EACnC,MAAM,QAAQ,MAAM,QAAQ,OAAO;EACnC,IAAI,CAAC,OAAO;EACZ,MAAM,cAAc,4BAA4B,OAAO,KAAK;EAC5D,IAAI,CAAC,aAAa;EAClB,SAAS,kBAAkB,QAAQ;GACjC,MAAM,YAAY;GAClB,MAAM,YAAY;GAClB,MAAM,YAAY,IAAI,YAAY;GAClC,MAAM,YAAY,IAAI,YAAY;EACpC,CAAC;CACH;CACA,OAAO;AACT;;AAGA,SAAgB,4BAA4B,OAAmB,MAA8B;CAC3F,MAAM,OAAO,cAAc,MAAM,KAAK;CACtC,IAAI,SAAS,MAAM,OAAO;CAE1B,MAAM,SACJ,KAAK,SAAS,UAAU,kBAAkB,MAAM,KAAK,IAAI,gBAAgB,MAAM,KAAK;CACtF,MAAM,UAAU,UAAU,OAAO,sBAAsB,QAAQ,IAAI,IAAI;CACvE,IAAI,CAAC,WAAW,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,OAAO;CACrF,OAAO;EACL,GAAG,QAAQ;EACX,GAAG,QAAQ;EACX,OAAO,QAAQ,OAAO,QAAQ;EAC9B,QAAQ,QAAQ,OAAO,QAAQ;CACjC;AACF"}
@@ -44,18 +44,28 @@ function nodeProxyToJSON(graph, api, nodeId, maxDepth, currentDepth = 0) {
44
44
  width: n.width,
45
45
  height: n.height
46
46
  };
47
- if (n.fills.length > 0) obj.fills = figmaFills(graph, n);
48
- if (n.strokes.length > 0) obj.strokes = figmaStrokes(graph, n);
47
+ if (n.fills.length > 0) obj.fills = figmaFills(n);
48
+ if (n.strokes.length > 0) obj.strokes = figmaStrokes(n);
49
49
  if (n.effects.length > 0) obj.effects = n.effects;
50
50
  if (n.opacity !== 1) obj.opacity = n.opacity;
51
+ if (n.rotation !== 0) obj.rotation = api.wrapNode(nodeId).rotation;
51
52
  if (n.cornerRadius > 0) obj.cornerRadius = n.cornerRadius;
52
53
  if (!n.visible) obj.visible = false;
53
54
  if (n.text) obj.characters = n.text;
54
55
  if (n.type === "TEXT") appendTextProps(obj, n);
55
56
  if (n.layoutMode !== "NONE") {
57
+ const proxy = api.wrapNode(nodeId);
56
58
  obj.layoutMode = n.layoutMode;
57
59
  obj.layoutDirection = n.layoutDirection;
58
60
  obj.itemSpacing = n.itemSpacing;
61
+ obj.paddingTop = proxy.paddingTop;
62
+ obj.paddingRight = proxy.paddingRight;
63
+ obj.paddingBottom = proxy.paddingBottom;
64
+ obj.paddingLeft = proxy.paddingLeft;
65
+ obj.primaryAxisAlignItems = proxy.primaryAxisAlignItems;
66
+ obj.counterAxisAlignItems = proxy.counterAxisAlignItems;
67
+ obj.primaryAxisSizingMode = proxy.primaryAxisSizingMode;
68
+ obj.counterAxisSizingMode = proxy.counterAxisSizingMode;
59
69
  }
60
70
  const bindings = resolveBindings(graph, n);
61
71
  if (bindings) obj.boundVariables = bindings;
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.js","names":[],"sources":["../../src/figma-api/serialization.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { pluginChildren } from './accessors/sticky'\nimport { figmaFills, figmaStrokes } from './accessors/visual'\nimport type { NodeProxyHost } from './proxy'\n\nfunction resolveBindings(graph: SceneGraph, node: SceneNode): Record<string, unknown> | undefined {\n const keys = Object.keys(node.boundVariables)\n if (keys.length === 0) return undefined\n const result: Record<string, unknown> = {}\n for (const [field, varId] of Object.entries(node.boundVariables)) {\n const variable = graph.variables.get(varId)\n result[field] = {\n variableId: varId,\n variableName: variable?.name ?? varId,\n resolvedValue: variable ? graph.resolveVariable(varId) : undefined\n }\n }\n return result\n}\n\nfunction appendTextProps(obj: Record<string, unknown>, n: SceneNode): void {\n obj.fontFamily = n.fontFamily\n obj.fontSize = n.fontSize\n obj.fontWeight = n.fontWeight\n obj.italic = n.italic\n obj.textAlignHorizontal = n.textAlignHorizontal\n obj.textAlignVertical = n.textAlignVertical\n obj.textAutoResize = n.textAutoResize\n obj.textDirection = n.textDirection\n if (n.lineHeight != null) obj.lineHeight = n.lineHeight\n if (n.letterSpacing.value !== 0) obj.letterSpacing = n.letterSpacing\n if (n.textCase !== 'ORIGINAL') obj.textCase = n.textCase\n if (n.textDecoration !== 'NONE') obj.textDecoration = n.textDecoration\n if (n.maxLines != null) obj.maxLines = n.maxLines\n}\n\nexport function nodeProxyToJSON(\n graph: SceneGraph,\n api: NodeProxyHost,\n nodeId: string,\n maxDepth?: number,\n currentDepth = 0\n): Record<string, unknown> {\n const n = graph.getNode(nodeId)\n if (!n) return { id: nodeId, removed: true }\n\n const obj: Record<string, unknown> = {\n id: n.id,\n type: n.type,\n name: n.name,\n x: n.x,\n y: n.y,\n width: n.width,\n height: n.height\n }\n if (n.fills.length > 0) obj.fills = figmaFills(graph, n)\n if (n.strokes.length > 0) obj.strokes = figmaStrokes(graph, n)\n if (n.effects.length > 0) obj.effects = n.effects\n if (n.opacity !== 1) obj.opacity = n.opacity\n if (n.cornerRadius > 0) obj.cornerRadius = n.cornerRadius\n if (!n.visible) obj.visible = false\n if (n.text) obj.characters = n.text\n if (n.type === 'TEXT') {\n appendTextProps(obj, n)\n }\n if (n.layoutMode !== 'NONE') {\n obj.layoutMode = n.layoutMode\n obj.layoutDirection = n.layoutDirection\n obj.itemSpacing = n.itemSpacing\n }\n // Include variable bindings with resolved values\n const bindings = resolveBindings(graph, n)\n if (bindings) obj.boundVariables = bindings\n const children = pluginChildren(graph, nodeId)\n if (children.length > 0) {\n if (maxDepth !== undefined && currentDepth >= maxDepth) {\n obj.childCount = children.length\n } else {\n obj.children = children.map((child) =>\n api.wrapNode(child.id).toJSON(maxDepth, currentDepth + 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M,SAAS,GAAG,IAAI,QAAQ,WAAW,OAAO,CAAC;CACvD,IAAI,EAAE,QAAQ,SAAS,GAAG,IAAI,UAAU,aAAa,OAAO,CAAC;CAC7D,IAAI,EAAE,QAAQ,SAAS,GAAG,IAAI,UAAU,EAAE;CAC1C,IAAI,EAAE,YAAY,GAAG,IAAI,UAAU,EAAE;CACrC,IAAI,EAAE,eAAe,GAAG,IAAI,eAAe,EAAE;CAC7C,IAAI,CAAC,EAAE,SAAS,IAAI,UAAU;CAC9B,IAAI,EAAE,MAAM,IAAI,aAAa,EAAE;CAC/B,IAAI,EAAE,SAAS,QACb,gBAAgB,KAAK,CAAC;CAExB,IAAI,EAAE,eAAe,QAAQ;EAC3B,IAAI,aAAa,EAAE;EACnB,IAAI,kBAAkB,EAAE;EACxB,IAAI,cAAc,EAAE;CACtB;CAEA,MAAM,WAAW,gBAAgB,OAAO,CAAC;CACzC,IAAI,UAAU,IAAI,iBAAiB;CACnC,MAAM,WAAW,eAAe,OAAO,MAAM;CAC7C,IAAI,SAAS,SAAS,GAAG;EACvB,IAAI,aAAa,KAAA,KAAa,gBAAgB,UAC5C,IAAI,aAAa,SAAS;OAE1B,IAAI,WAAW,SAAS,KAAK,UAC3B,IAAI,SAAS,MAAM,EAAE,CAAC,CAAC,OAAO,UAAU,eAAe,CAAC,CAC1D;CAEJ;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"serialization.js","names":[],"sources":["../../src/figma-api/serialization.ts"],"sourcesContent":["import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { pluginChildren } from './accessors/sticky'\nimport { figmaFills, figmaStrokes } from './accessors/visual'\nimport type { NodeProxyHost } from './proxy'\n\nfunction resolveBindings(graph: SceneGraph, node: SceneNode): Record<string, unknown> | undefined {\n const keys = Object.keys(node.boundVariables)\n if (keys.length === 0) return undefined\n const result: Record<string, unknown> = {}\n for (const [field, varId] of Object.entries(node.boundVariables)) {\n const variable = graph.variables.get(varId)\n result[field] = {\n variableId: varId,\n variableName: variable?.name ?? varId,\n resolvedValue: variable ? graph.resolveVariable(varId) : undefined\n }\n }\n return result\n}\n\nfunction appendTextProps(obj: Record<string, unknown>, n: SceneNode): void {\n obj.fontFamily = n.fontFamily\n obj.fontSize = n.fontSize\n obj.fontWeight = n.fontWeight\n obj.italic = n.italic\n obj.textAlignHorizontal = n.textAlignHorizontal\n obj.textAlignVertical = n.textAlignVertical\n obj.textAutoResize = n.textAutoResize\n obj.textDirection = n.textDirection\n if (n.lineHeight != null) obj.lineHeight = n.lineHeight\n if (n.letterSpacing.value !== 0) obj.letterSpacing = n.letterSpacing\n if (n.textCase !== 'ORIGINAL') obj.textCase = n.textCase\n if (n.textDecoration !== 'NONE') obj.textDecoration = n.textDecoration\n if (n.maxLines != null) obj.maxLines = n.maxLines\n}\n\nexport function nodeProxyToJSON(\n graph: SceneGraph,\n api: NodeProxyHost,\n nodeId: string,\n maxDepth?: number,\n currentDepth = 0\n): Record<string, unknown> {\n const n = graph.getNode(nodeId)\n if (!n) return { id: nodeId, removed: true }\n\n const obj: Record<string, unknown> = {\n id: n.id,\n type: n.type,\n name: n.name,\n x: n.x,\n y: n.y,\n width: n.width,\n height: n.height\n }\n if (n.fills.length > 0) obj.fills = figmaFills(n)\n if (n.strokes.length > 0) obj.strokes = figmaStrokes(n)\n if (n.effects.length > 0) obj.effects = n.effects\n if (n.opacity !== 1) obj.opacity = n.opacity\n // The angle `set_rotation` writes, as the Figma API reports it. The scene stores the turn in\n // the opposite direction and keeps floating-point noise, so read it through the proxy.\n if (n.rotation !== 0) obj.rotation = api.wrapNode(nodeId).rotation\n if (n.cornerRadius > 0) obj.cornerRadius = n.cornerRadius\n if (!n.visible) obj.visible = false\n if (n.text) obj.characters = n.text\n if (n.type === 'TEXT') {\n appendTextProps(obj, n)\n }\n if (n.layoutMode !== 'NONE') {\n // An auto layout frame reports the insets and alignment a tool sets, so a caller can read back\n // what it wrote instead of measuring the result.\n const proxy = api.wrapNode(nodeId)\n obj.layoutMode = n.layoutMode\n obj.layoutDirection = n.layoutDirection\n obj.itemSpacing = n.itemSpacing\n obj.paddingTop = proxy.paddingTop\n obj.paddingRight = proxy.paddingRight\n obj.paddingBottom = proxy.paddingBottom\n obj.paddingLeft = proxy.paddingLeft\n obj.primaryAxisAlignItems = proxy.primaryAxisAlignItems\n obj.counterAxisAlignItems = proxy.counterAxisAlignItems\n obj.primaryAxisSizingMode = proxy.primaryAxisSizingMode\n obj.counterAxisSizingMode = proxy.counterAxisSizingMode\n }\n // Include variable bindings with resolved values\n const bindings = resolveBindings(graph, n)\n if (bindings) obj.boundVariables = bindings\n const children = pluginChildren(graph, nodeId)\n if (children.length > 0) {\n if (maxDepth !== undefined && currentDepth >= maxDepth) {\n obj.childCount = children.length\n } else {\n obj.children = children.map((child) =>\n api.wrapNode(child.id).toJSON(maxDepth, currentDepth + 1)\n )\n }\n }\n return obj\n}\n"],"mappings":";;;AAMA,SAAS,gBAAgB,OAAmB,MAAsD;CAEhG,IADa,OAAO,KAAK,KAAK,cACvB,CAAC,CAAC,WAAW,GAAG,OAAO,KAAA;CAC9B,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,cAAc,GAAG;EAChE,MAAM,WAAW,MAAM,UAAU,IAAI,KAAK;EAC1C,OAAO,SAAS;GACd,YAAY;GACZ,cAAc,UAAU,QAAQ;GAChC,eAAe,WAAW,MAAM,gBAAgB,KAAK,IAAI,KAAA;EAC3D;CACF;CACA,OAAO;AACT;AAEA,SAAS,gBAAgB,KAA8B,GAAoB;CACzE,IAAI,aAAa,EAAE;CACnB,IAAI,WAAW,EAAE;CACjB,IAAI,aAAa,EAAE;CACnB,IAAI,SAAS,EAAE;CACf,IAAI,sBAAsB,EAAE;CAC5B,IAAI,oBAAoB,EAAE;CAC1B,IAAI,iBAAiB,EAAE;CACvB,IAAI,gBAAgB,EAAE;CACtB,IAAI,EAAE,cAAc,MAAM,IAAI,aAAa,EAAE;CAC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MAAM;EACxB,IAAI,wBAAwB,MAAM;EAClC,IAAI,wBAAwB,MAAM;EAClC,IAAI,wBAAwB,MAAM;EAClC,IAAI,wBAAwB,MAAM;CACpC;CAEA,MAAM,WAAW,gBAAgB,OAAO,CAAC;CACzC,IAAI,UAAU,IAAI,iBAAiB;CACnC,MAAM,WAAW,eAAe,OAAO,MAAM;CAC7C,IAAI,SAAS,SAAS,GAAG;EACvB,IAAI,aAAa,KAAA,KAAa,gBAAgB,UAC5C,IAAI,aAAa,SAAS;OAE1B,IAAI,WAAW,SAAS,KAAK,UAC3B,IAAI,SAAS,MAAM,EAAE,CAAC,CAAC,OAAO,UAAU,eAAe,CAAC,CAC1D;CAEJ;CACA,OAAO;AACT"}
@@ -18,6 +18,12 @@ declare function assertSlotSettings(type: ComponentPropertyType, settings: Figma
18
18
  * of an instance refuses it, and a slot on either side becomes the instance's own content.
19
19
  */
20
20
  declare function prepareSlotMove(g: SceneGraph, parentId: string, childId: string, method: 'appendChild' | 'insertChild'): void;
21
+ /**
22
+ * Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the
23
+ * rule appendChild follows: the locked part of an instance refuses them, since its layers come
24
+ * from the component, and a slot's content becomes the instance's own first.
25
+ */
26
+ declare function prepareSlotInsertion(g: SceneGraph, parentId: string, method: string): void;
21
27
  /**
22
28
  * Ready removing a layer the way Figma's remove() does: the locked part of an instance,
23
29
  * slot frames included, refuses it, and slot content becomes the instance's own first.
@@ -26,5 +32,5 @@ declare function prepareSlotRemoval(g: SceneGraph, nodeId: string): void;
26
32
  /** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */
27
33
  declare function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void;
28
34
  //#endregion
29
- export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotMove, prepareSlotRemoval };
35
+ export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
30
36
  //# sourceMappingURL=slots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slots.d.ts","names":[],"sources":["../../src/figma-api/slots.ts"],"mappings":";;;;UAqBiB;EACf;EACA;EACA;EACA;EACA;;;iBASc,kBACd,SAAS,0BACT,SAAS,oBACR;iBAca,kBAAkB,UAAU,eAAe;iBAQ3C,mBACd,MAAM,uBACN,UAAU;;;;;iBAUI,gBACd,GAAG,YACH,kBACA,iBACA;;;;;iBAiBc,mBAAmB,GAAG,YAAY;;iBAmBlC,qBAAqB,mBAAmB,WAAW"}
1
+ {"version":3,"file":"slots.d.ts","names":[],"sources":["../../src/figma-api/slots.ts"],"mappings":";;;;UAqBiB;EACf;EACA;EACA;EACA;EACA;;;iBASc,kBACd,SAAS,0BACT,SAAS,oBACR;iBAca,kBAAkB,UAAU,eAAe;iBAQ3C,mBACd,MAAM,uBACN,UAAU;;;;;iBAUI,gBACd,GAAG,YACH,kBACA,iBACA;;;;;;iBAac,qBAAqB,GAAG,YAAY,kBAAkB;;;;;iBAatD,mBAAmB,GAAG,YAAY;;iBAmBlC,qBAAqB,mBAAmB,WAAW"}
@@ -38,14 +38,22 @@ function assertSlotSettings(type, settings) {
38
38
  * of an instance refuses it, and a slot on either side becomes the instance's own content.
39
39
  */
40
40
  function prepareSlotMove(g, parentId, childId, method) {
41
- const target = slotScope(g, parentId);
42
- if (target.kind === "locked") throw new Error(`in ${method}: Cannot move node. New parent is an instance or is inside of an instance`);
43
41
  const sourceParentId = g.getNode(childId)?.parentId;
44
42
  const source = sourceParentId ? slotScope(g, sourceParentId) : void 0;
45
- if (target.kind === "slot") claimSlotContent(g, target);
43
+ prepareSlotInsertion(g, parentId, method);
46
44
  if (source?.kind === "slot") claimSlotContent(g, source);
47
45
  }
48
46
  /**
47
+ * Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the
48
+ * rule appendChild follows: the locked part of an instance refuses them, since its layers come
49
+ * from the component, and a slot's content becomes the instance's own first.
50
+ */
51
+ function prepareSlotInsertion(g, parentId, method) {
52
+ const target = slotScope(g, parentId);
53
+ if (target.kind === "locked") throw new Error(`in ${method}: Cannot move node. New parent is an instance or is inside of an instance`);
54
+ if (target.kind === "slot") claimSlotContent(g, target);
55
+ }
56
+ /**
49
57
  * Ready removing a layer the way Figma's remove() does: the locked part of an instance,
50
58
  * slot frames included, refuses it, and slot content becomes the instance's own first.
51
59
  */
@@ -95,6 +103,6 @@ function installSlotAccessors(prototype, internals) {
95
103
  });
96
104
  }
97
105
  //#endregion
98
- export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotMove, prepareSlotRemoval };
106
+ export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
99
107
 
100
108
  //# sourceMappingURL=slots.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"slots.js","names":[],"sources":["../../src/figma-api/slots.ts"],"sourcesContent":["import type { ComponentPropertyType, SceneGraph, SlotSettings } from '@pairdraw/scene-graph'\nimport {\n createComponentPropertyId,\n componentPropertyDefinitions\n} from '@pairdraw/scene-graph/components'\nimport {\n DEFAULT_SLOT_SETTINGS,\n claimSlotContent,\n createSlotProperty,\n resetSlotContent,\n slotLimitViolations,\n slotPropertyId,\n slotScope,\n type SlotLimitViolation\n} from '@pairdraw/scene-graph/slots'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, nodeId, raw } from './accessor-utils'\nimport type { NodeProxyHost } from './proxy'\n\n/** Figma's slot limits, where an unset count reads as null. */\nexport interface FigmaSlotSettings {\n stretchChildOnInsert?: boolean\n displayEmptyByDefault?: boolean\n minChildren?: number | null\n maxChildren?: number | null\n allowPreferredValuesOnly?: boolean\n}\n\n/** A count after a Figma change: null clears it, undefined keeps the current one. */\nfunction count(change: number | null | undefined, current: number | undefined) {\n return change === null ? undefined : (change ?? current)\n}\n\n/** Apply Figma slot settings to a definition's own. */\nexport function mergeSlotSettings(\n current: SlotSettings | undefined,\n changes: FigmaSlotSettings\n): SlotSettings {\n const base = { ...DEFAULT_SLOT_SETTINGS, ...current }\n const next: SlotSettings = {\n stretchChildOnInsert: changes.stretchChildOnInsert ?? base.stretchChildOnInsert,\n displayEmptyByDefault: changes.displayEmptyByDefault ?? base.displayEmptyByDefault,\n allowPreferredValuesOnly: changes.allowPreferredValuesOnly ?? base.allowPreferredValuesOnly\n }\n const minChildren = count(changes.minChildren, base.minChildren)\n const maxChildren = count(changes.maxChildren, base.maxChildren)\n if (minChildren !== undefined) next.minChildren = minChildren\n if (maxChildren !== undefined) next.maxChildren = maxChildren\n return next\n}\n\nexport function figmaSlotSettings(settings: SlotSettings): FigmaSlotSettings {\n return {\n ...settings,\n minChildren: settings.minChildren ?? null,\n maxChildren: settings.maxChildren ?? null\n }\n}\n\nexport function assertSlotSettings(\n type: ComponentPropertyType,\n settings: FigmaSlotSettings | undefined\n): void {\n if (settings && type !== 'SLOT')\n throw new Error(\"slotSettings is only supported for 'SLOT' properties\")\n}\n\n/**\n * Ready a move of `childId` into `parentId` the way Figma's appendChild does: the locked part\n * of an instance refuses it, and a slot on either side becomes the instance's own content.\n */\nexport function prepareSlotMove(\n g: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n const target = slotScope(g, parentId)\n if (target.kind === 'locked')\n throw new Error(\n `in ${method}: Cannot move node. New parent is an instance or is inside of an instance`\n )\n const sourceParentId = g.getNode(childId)?.parentId\n const source = sourceParentId ? slotScope(g, sourceParentId) : undefined\n if (target.kind === 'slot') claimSlotContent(g, target)\n if (source?.kind === 'slot') claimSlotContent(g, source)\n}\n\n/**\n * Ready removing a layer the way Figma's remove() does: the locked part of an instance,\n * slot frames included, refuses it, and slot content becomes the instance's own first.\n */\nexport function prepareSlotRemoval(g: SceneGraph, nodeId: string): void {\n const parentId = g.getNode(nodeId)?.parentId\n if (!parentId) return\n const scope = slotScope(g, parentId)\n if (scope.kind === 'locked') throw new Error('in remove: Removing this node is not allowed')\n if (scope.kind === 'slot') claimSlotContent(g, scope)\n}\n\nfunction host(target: ProxyThis, internals: NodeProxyInternals): NodeProxyHost {\n return target[internals.api] as NodeProxyHost\n}\n\n/** The instance slot a proxy is, if it is the frame of one. */\nfunction instanceSlot(target: ProxyThis, internals: NodeProxyInternals) {\n const scope = slotScope(graph(target, internals), nodeId(target, internals))\n return scope.kind === 'slot' && scope.frame.id === nodeId(target, internals) ? scope : undefined\n}\n\n/** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */\nexport function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n createSlot: {\n // Figma appends a 100×100 frame named Slot, Slot 2, … and a SLOT property of that name.\n value(this: ProxyThis) {\n const component = raw(this, internals)\n if (component.type !== 'COMPONENT')\n throw new Error('createSlot() can only be called on components')\n assertProxyEditable(this, internals)\n const g = graph(this, internals)\n const frame = g.createNode('FRAME', component.id, { name: 'Slot' })\n const definition = createSlotProperty(g, frame.id, createComponentPropertyId())\n if (!definition) throw new Error('Failed to create slot')\n g.updateNode(frame.id, { name: definition.name })\n return host(this, internals).wrapNode(frame.id)\n }\n },\n resetSlot: {\n value(this: ProxyThis) {\n if (!slotPropertyId(raw(this, internals)))\n throw new Error('resetSlot() can only be called on slots')\n assertProxyEditable(this, internals)\n const scope = instanceSlot(this, internals)\n if (scope) resetSlotContent(graph(this, internals), scope)\n }\n },\n limitViolations: {\n // Figma measures limits only where an instance shows the slot; a main component's slot\n // reports none.\n get(this: ProxyThis): SlotLimitViolation[] {\n const scope = instanceSlot(this, internals)\n if (!scope) return []\n const g = graph(this, internals)\n const definition = componentPropertyDefinitions(g, scope.instance).find(\n (item) => item.id === scope.propertyId\n )\n if (!definition) return []\n return slotLimitViolations(g, definition, g.getChildren(scope.frame.id))\n }\n }\n })\n}\n"],"mappings":";;;;;AA8BA,SAAS,MAAM,QAAmC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AAO,OAAO,CAAC;GACpB,MAAM,IAAI,MAAM,MAAM,SAAS;GAC/B,MAAM,aAAa,6BAA6B,GAAG,MAAM,QAAQ,CAAC,CAAC,MAChE,SAAS,KAAK,OAAO,MAAM,UAC9B;GACA,IAAI,CAAC,YAAY,OAAO,CAAC;GACzB,OAAO,oBAAoB,GAAG,YAAY,EAAE,YAAY,MAAM,MAAM,EAAE,CAAC;EACzE,EACF;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"slots.js","names":[],"sources":["../../src/figma-api/slots.ts"],"sourcesContent":["import type { ComponentPropertyType, SceneGraph, SlotSettings } from '@pairdraw/scene-graph'\nimport {\n createComponentPropertyId,\n componentPropertyDefinitions\n} from '@pairdraw/scene-graph/components'\nimport {\n DEFAULT_SLOT_SETTINGS,\n claimSlotContent,\n createSlotProperty,\n resetSlotContent,\n slotLimitViolations,\n slotPropertyId,\n slotScope,\n type SlotLimitViolation\n} from '@pairdraw/scene-graph/slots'\n\nimport type { NodeProxyInternals, ProxyThis } from './accessor-utils'\nimport { assertProxyEditable, graph, nodeId, raw } from './accessor-utils'\nimport type { NodeProxyHost } from './proxy'\n\n/** Figma's slot limits, where an unset count reads as null. */\nexport interface FigmaSlotSettings {\n stretchChildOnInsert?: boolean\n displayEmptyByDefault?: boolean\n minChildren?: number | null\n maxChildren?: number | null\n allowPreferredValuesOnly?: boolean\n}\n\n/** A count after a Figma change: null clears it, undefined keeps the current one. */\nfunction count(change: number | null | undefined, current: number | undefined) {\n return change === null ? undefined : (change ?? current)\n}\n\n/** Apply Figma slot settings to a definition's own. */\nexport function mergeSlotSettings(\n current: SlotSettings | undefined,\n changes: FigmaSlotSettings\n): SlotSettings {\n const base = { ...DEFAULT_SLOT_SETTINGS, ...current }\n const next: SlotSettings = {\n stretchChildOnInsert: changes.stretchChildOnInsert ?? base.stretchChildOnInsert,\n displayEmptyByDefault: changes.displayEmptyByDefault ?? base.displayEmptyByDefault,\n allowPreferredValuesOnly: changes.allowPreferredValuesOnly ?? base.allowPreferredValuesOnly\n }\n const minChildren = count(changes.minChildren, base.minChildren)\n const maxChildren = count(changes.maxChildren, base.maxChildren)\n if (minChildren !== undefined) next.minChildren = minChildren\n if (maxChildren !== undefined) next.maxChildren = maxChildren\n return next\n}\n\nexport function figmaSlotSettings(settings: SlotSettings): FigmaSlotSettings {\n return {\n ...settings,\n minChildren: settings.minChildren ?? null,\n maxChildren: settings.maxChildren ?? null\n }\n}\n\nexport function assertSlotSettings(\n type: ComponentPropertyType,\n settings: FigmaSlotSettings | undefined\n): void {\n if (settings && type !== 'SLOT')\n throw new Error(\"slotSettings is only supported for 'SLOT' properties\")\n}\n\n/**\n * Ready a move of `childId` into `parentId` the way Figma's appendChild does: the locked part\n * of an instance refuses it, and a slot on either side becomes the instance's own content.\n */\nexport function prepareSlotMove(\n g: SceneGraph,\n parentId: string,\n childId: string,\n method: 'appendChild' | 'insertChild'\n): void {\n const sourceParentId = g.getNode(childId)?.parentId\n const source = sourceParentId ? slotScope(g, sourceParentId) : undefined\n prepareSlotInsertion(g, parentId, method)\n if (source?.kind === 'slot') claimSlotContent(g, source)\n}\n\n/**\n * Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the\n * rule appendChild follows: the locked part of an instance refuses them, since its layers come\n * from the component, and a slot's content becomes the instance's own first.\n */\nexport function prepareSlotInsertion(g: SceneGraph, parentId: string, method: string): void {\n const target = slotScope(g, parentId)\n if (target.kind === 'locked')\n throw new Error(\n `in ${method}: Cannot move node. New parent is an instance or is inside of an instance`\n )\n if (target.kind === 'slot') claimSlotContent(g, target)\n}\n\n/**\n * Ready removing a layer the way Figma's remove() does: the locked part of an instance,\n * slot frames included, refuses it, and slot content becomes the instance's own first.\n */\nexport function prepareSlotRemoval(g: SceneGraph, nodeId: string): void {\n const parentId = g.getNode(nodeId)?.parentId\n if (!parentId) return\n const scope = slotScope(g, parentId)\n if (scope.kind === 'locked') throw new Error('in remove: Removing this node is not allowed')\n if (scope.kind === 'slot') claimSlotContent(g, scope)\n}\n\nfunction host(target: ProxyThis, internals: NodeProxyInternals): NodeProxyHost {\n return target[internals.api] as NodeProxyHost\n}\n\n/** The instance slot a proxy is, if it is the frame of one. */\nfunction instanceSlot(target: ProxyThis, internals: NodeProxyInternals) {\n const scope = slotScope(graph(target, internals), nodeId(target, internals))\n return scope.kind === 'slot' && scope.frame.id === nodeId(target, internals) ? scope : undefined\n}\n\n/** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */\nexport function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void {\n Object.defineProperties(prototype, {\n createSlot: {\n // Figma appends a 100×100 frame named Slot, Slot 2, … and a SLOT property of that name.\n value(this: ProxyThis) {\n const component = raw(this, internals)\n if (component.type !== 'COMPONENT')\n throw new Error('createSlot() can only be called on components')\n assertProxyEditable(this, internals)\n const g = graph(this, internals)\n const frame = g.createNode('FRAME', component.id, { name: 'Slot' })\n const definition = createSlotProperty(g, frame.id, createComponentPropertyId())\n if (!definition) throw new Error('Failed to create slot')\n g.updateNode(frame.id, { name: definition.name })\n return host(this, internals).wrapNode(frame.id)\n }\n },\n resetSlot: {\n value(this: ProxyThis) {\n if (!slotPropertyId(raw(this, internals)))\n throw new Error('resetSlot() can only be called on slots')\n assertProxyEditable(this, internals)\n const scope = instanceSlot(this, internals)\n if (scope) resetSlotContent(graph(this, internals), scope)\n }\n },\n limitViolations: {\n // Figma measures limits only where an instance shows the slot; a main component's slot\n // reports none.\n get(this: ProxyThis): SlotLimitViolation[] {\n const scope = instanceSlot(this, internals)\n if (!scope) return []\n const g = graph(this, internals)\n const definition = componentPropertyDefinitions(g, scope.instance).find(\n (item) => item.id === scope.propertyId\n )\n if (!definition) return []\n return slotLimitViolations(g, definition, g.getChildren(scope.frame.id))\n }\n }\n })\n}\n"],"mappings":";;;;;AA8BA,SAAS,MAAM,QAAmC,SAA6B;CAC7E,OAAO,WAAW,OAAO,KAAA,IAAa,UAAU;AAClD;;AAGA,SAAgB,kBACd,SACA,SACc;CACd,MA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AO,CAAC;GACpB,MAAM,IAAI,MAAM,MAAM,SAAS;GAC/B,MAAM,aAAa,6BAA6B,GAAG,MAAM,QAAQ,CAAC,CAAC,MAChE,SAAS,KAAK,OAAO,MAAM,UAC9B;GACA,IAAI,CAAC,YAAY,OAAO,CAAC;GACzB,OAAO,oBAAoB,GAAG,YAAY,EAAE,YAAY,MAAM,MAAM,EAAE,CAAC;EACzE,EACF;CACF,CAAC;AACH"}
@@ -2,12 +2,15 @@ import { SceneGraph, SceneNode, Stroke } from "@pairdraw/scene-graph";
2
2
  //#region src/figma-api/strokes.d.ts
3
3
  /**
4
4
  * Sets the weight of all of a node's strokes and the weight it keeps with none, as Figma's
5
- * node-level `strokeWeight` does; see `SceneNode.strokeWeight`.
5
+ * node-level `strokeWeight` does; the graph gives the strokes the layer's value
6
+ * (`strokeLineChanges`).
6
7
  */
7
8
  declare function setStrokeWeight(graph: SceneGraph, node: SceneNode, weight: number): void;
8
9
  /** Sets the alignment of all of a node's strokes and the one it keeps with none. */
9
10
  declare function setStrokeAlign(graph: SceneGraph, node: SceneNode, align: Stroke['align']): void;
11
+ /** Dashes the layer and every stroke on it. */
12
+ declare function setDashPattern(graph: SceneGraph, node: SceneNode, pattern: readonly number[]): void;
10
13
  declare function setIndependentStrokeWeight(graph: SceneGraph, nodeId: string, field: 'borderTopWeight' | 'borderRightWeight' | 'borderBottomWeight' | 'borderLeftWeight', value: number): void;
11
14
  //#endregion
12
- export { setIndependentStrokeWeight, setStrokeAlign, setStrokeWeight };
15
+ export { setDashPattern, setIndependentStrokeWeight, setStrokeAlign, setStrokeWeight };
13
16
  //# sourceMappingURL=strokes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strokes.d.ts","names":[],"sources":["../../src/figma-api/strokes.ts"],"mappings":";;;;;;iBAQgB,gBAAgB,OAAO,YAAY,MAAM,WAAW;;iBASpD,eAAe,OAAO,YAAY,MAAM,WAAW,OAAO;iBAQ1D,2BACd,OAAO,YACP,gBACA,4FACA"}
1
+ {"version":3,"file":"strokes.d.ts","names":[],"sources":["../../src/figma-api/strokes.ts"],"mappings":";;;;;;;iBAQgB,gBAAgB,OAAO,YAAY,MAAM,WAAW;;iBAMpD,eAAe,OAAO,YAAY,MAAM,WAAW,OAAO;;iBAM1D,eACd,OAAO,YACP,MAAM,WACN;iBAMc,2BACd,OAAO,YACP,gBACA,4FACA"}
@@ -1,30 +1,23 @@
1
- import { copyStroke } from "@pairdraw/scene-graph/copy";
2
1
  import { recordInstanceOverride } from "@pairdraw/scene-graph/instances";
3
2
  //#region src/figma-api/strokes.ts
4
3
  /**
5
4
  * Sets the weight of all of a node's strokes and the weight it keeps with none, as Figma's
6
- * node-level `strokeWeight` does; see `SceneNode.strokeWeight`.
5
+ * node-level `strokeWeight` does; the graph gives the strokes the layer's value
6
+ * (`strokeLineChanges`).
7
7
  */
8
8
  function setStrokeWeight(graph, node, weight) {
9
- graph.updateNode(node.id, {
10
- strokeWeight: weight,
11
- strokes: node.strokes.map((stroke) => ({
12
- ...copyStroke(stroke),
13
- weight
14
- }))
15
- });
16
- recordInstanceOverride(graph, node.id, ["strokes", "strokeWeight"]);
9
+ graph.updateNode(node.id, { strokeWeight: weight });
10
+ recordInstanceOverride(graph, node.id, ["strokeWeight"]);
17
11
  }
18
12
  /** Sets the alignment of all of a node's strokes and the one it keeps with none. */
19
13
  function setStrokeAlign(graph, node, align) {
20
- graph.updateNode(node.id, {
21
- strokeAlign: align,
22
- strokes: node.strokes.map((stroke) => ({
23
- ...copyStroke(stroke),
24
- align
25
- }))
26
- });
27
- recordInstanceOverride(graph, node.id, ["strokes", "strokeAlign"]);
14
+ graph.updateNode(node.id, { strokeAlign: align });
15
+ recordInstanceOverride(graph, node.id, ["strokeAlign"]);
16
+ }
17
+ /** Dashes the layer and every stroke on it. */
18
+ function setDashPattern(graph, node, pattern) {
19
+ graph.updateNode(node.id, { dashPattern: [...pattern] });
20
+ recordInstanceOverride(graph, node.id, ["dashPattern"]);
28
21
  }
29
22
  function setIndependentStrokeWeight(graph, nodeId, field, value) {
30
23
  graph.updateNode(nodeId, {
@@ -34,6 +27,6 @@ function setIndependentStrokeWeight(graph, nodeId, field, value) {
34
27
  recordInstanceOverride(graph, nodeId, [field, "independentStrokeWeights"]);
35
28
  }
36
29
  //#endregion
37
- export { setIndependentStrokeWeight, setStrokeAlign, setStrokeWeight };
30
+ export { setDashPattern, setIndependentStrokeWeight, setStrokeAlign, setStrokeWeight };
38
31
 
39
32
  //# sourceMappingURL=strokes.js.map