@pairdraw/core 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (626) hide show
  1. package/dist/canvas/boolean.d.ts +6 -1
  2. package/dist/canvas/boolean.d.ts.map +1 -1
  3. package/dist/canvas/boolean.js +10 -2
  4. package/dist/canvas/boolean.js.map +1 -1
  5. package/dist/canvas/color-space.d.ts +45 -0
  6. package/dist/canvas/color-space.d.ts.map +1 -0
  7. package/dist/canvas/color-space.js +39 -0
  8. package/dist/canvas/color-space.js.map +1 -0
  9. package/dist/canvas/fills.d.ts +10 -10
  10. package/dist/canvas/fills.d.ts.map +1 -1
  11. package/dist/canvas/fills.js +116 -62
  12. package/dist/canvas/fills.js.map +1 -1
  13. package/dist/canvas/flatten.d.ts +11 -3
  14. package/dist/canvas/flatten.d.ts.map +1 -1
  15. package/dist/canvas/flatten.js +62 -4
  16. package/dist/canvas/flatten.js.map +1 -1
  17. package/dist/canvas/index.d.ts +2 -1
  18. package/dist/canvas/index.js +2 -1
  19. package/dist/canvas/layout-grids.d.ts +5 -2
  20. package/dist/canvas/layout-grids.d.ts.map +1 -1
  21. package/dist/canvas/layout-grids.js +7 -2
  22. package/dist/canvas/layout-grids.js.map +1 -1
  23. package/dist/canvas/noise/render.d.ts +17 -4
  24. package/dist/canvas/noise/render.d.ts.map +1 -1
  25. package/dist/canvas/noise/render.js +21 -6
  26. package/dist/canvas/noise/render.js.map +1 -1
  27. package/dist/canvas/noise/shader.d.ts +4 -4
  28. package/dist/canvas/noise/shader.d.ts.map +1 -1
  29. package/dist/canvas/noise/shader.js +5 -6
  30. package/dist/canvas/noise/shader.js.map +1 -1
  31. package/dist/canvas/overlays/annotations.d.ts +19 -0
  32. package/dist/canvas/overlays/annotations.d.ts.map +1 -0
  33. package/dist/canvas/overlays/annotations.js +110 -0
  34. package/dist/canvas/overlays/annotations.js.map +1 -0
  35. package/dist/canvas/overlays/auto-layout-hover.d.ts +11 -1
  36. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  37. package/dist/canvas/overlays/auto-layout-hover.js +25 -1
  38. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  39. package/dist/canvas/overlays/feedback.js +1 -1
  40. package/dist/canvas/overlays/feedback.js.map +1 -1
  41. package/dist/canvas/overlays/index.d.ts +2 -2
  42. package/dist/canvas/overlays/index.js +2 -2
  43. package/dist/canvas/overlays/measurement.d.ts +7 -1
  44. package/dist/canvas/overlays/measurement.d.ts.map +1 -1
  45. package/dist/canvas/overlays/measurement.js +42 -4
  46. package/dist/canvas/overlays/measurement.js.map +1 -1
  47. package/dist/canvas/overlays/presence.d.ts.map +1 -1
  48. package/dist/canvas/overlays/presence.js +21 -24
  49. package/dist/canvas/overlays/presence.js.map +1 -1
  50. package/dist/canvas/renderer/colors.d.ts +7 -1
  51. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  52. package/dist/canvas/renderer/colors.js +9 -1
  53. package/dist/canvas/renderer/colors.js.map +1 -1
  54. package/dist/canvas/renderer/document-surface.d.ts +15 -6
  55. package/dist/canvas/renderer/document-surface.d.ts.map +1 -1
  56. package/dist/canvas/renderer/document-surface.js +1 -0
  57. package/dist/canvas/renderer/document-surface.js.map +1 -1
  58. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.js +2 -2
  60. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  61. package/dist/canvas/renderer/methods.d.ts +1 -0
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +4 -1
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/overlay-pass.d.ts.map +1 -1
  66. package/dist/canvas/renderer/overlay-pass.js +6 -1
  67. package/dist/canvas/renderer/overlay-pass.js.map +1 -1
  68. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  69. package/dist/canvas/renderer/pipeline.js +7 -0
  70. package/dist/canvas/renderer/pipeline.js.map +1 -1
  71. package/dist/canvas/renderer/types.d.ts +10 -0
  72. package/dist/canvas/renderer/types.d.ts.map +1 -1
  73. package/dist/canvas/renderer.d.ts +10 -2
  74. package/dist/canvas/renderer.d.ts.map +1 -1
  75. package/dist/canvas/renderer.js +15 -3
  76. package/dist/canvas/renderer.js.map +1 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +9 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shaders/compile.d.ts +3 -1
  81. package/dist/canvas/shaders/compile.d.ts.map +1 -1
  82. package/dist/canvas/shaders/compile.js +12 -3
  83. package/dist/canvas/shaders/compile.js.map +1 -1
  84. package/dist/canvas/shaders/draw.d.ts.map +1 -1
  85. package/dist/canvas/shaders/draw.js +10 -3
  86. package/dist/canvas/shaders/draw.js.map +1 -1
  87. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  88. package/dist/canvas/shaders/effect.js +6 -16
  89. package/dist/canvas/shaders/effect.js.map +1 -1
  90. package/dist/clipboard/pairdraw.d.ts.map +1 -1
  91. package/dist/clipboard/pairdraw.js +1 -0
  92. package/dist/clipboard/pairdraw.js.map +1 -1
  93. package/dist/editor/bridges/clipboard.d.ts +2 -0
  94. package/dist/editor/bridges/clipboard.d.ts.map +1 -1
  95. package/dist/editor/bridges/clipboard.js +1 -0
  96. package/dist/editor/bridges/clipboard.js.map +1 -1
  97. package/dist/editor/bridges/components.d.ts +14 -7
  98. package/dist/editor/bridges/components.d.ts.map +1 -1
  99. package/dist/editor/bridges/components.js +6 -0
  100. package/dist/editor/bridges/components.js.map +1 -1
  101. package/dist/editor/bridges/structure.d.ts +1 -1
  102. package/dist/editor/bridges/structure.d.ts.map +1 -1
  103. package/dist/editor/bridges/undo.d.ts +1 -1
  104. package/dist/editor/clipboard/code.d.ts +32 -0
  105. package/dist/editor/clipboard/code.d.ts.map +1 -0
  106. package/dist/editor/clipboard/code.js +30 -0
  107. package/dist/editor/clipboard/code.js.map +1 -0
  108. package/dist/editor/clipboard/export.js +2 -2
  109. package/dist/editor/clipboard/export.js.map +1 -1
  110. package/dist/editor/clipboard/paste/dependencies.d.ts +14 -0
  111. package/dist/editor/clipboard/paste/dependencies.d.ts.map +1 -0
  112. package/dist/editor/clipboard/paste/dependencies.js +0 -0
  113. package/dist/editor/clipboard/paste/run.d.ts +14 -0
  114. package/dist/editor/clipboard/paste/run.d.ts.map +1 -0
  115. package/dist/editor/clipboard/paste/run.js +47 -0
  116. package/dist/editor/clipboard/paste/run.js.map +1 -0
  117. package/dist/editor/clipboard/styled.d.ts +2 -8
  118. package/dist/editor/clipboard/styled.d.ts.map +1 -1
  119. package/dist/editor/clipboard/styled.js +2 -32
  120. package/dist/editor/clipboard/styled.js.map +1 -1
  121. package/dist/editor/clipboard.d.ts +2 -0
  122. package/dist/editor/clipboard.d.ts.map +1 -1
  123. package/dist/editor/clipboard.js +34 -0
  124. package/dist/editor/clipboard.js.map +1 -1
  125. package/dist/editor/components/instances.d.ts +5 -0
  126. package/dist/editor/components/instances.d.ts.map +1 -1
  127. package/dist/editor/components/instances.js +69 -4
  128. package/dist/editor/components/instances.js.map +1 -1
  129. package/dist/editor/components/slots/index.d.ts.map +1 -1
  130. package/dist/editor/components/slots/index.js +7 -0
  131. package/dist/editor/components/slots/index.js.map +1 -1
  132. package/dist/editor/components.d.ts +6 -0
  133. package/dist/editor/components.d.ts.map +1 -1
  134. package/dist/editor/components.js +14 -2
  135. package/dist/editor/components.js.map +1 -1
  136. package/dist/editor/create.d.ts +30 -3
  137. package/dist/editor/create.d.ts.map +1 -1
  138. package/dist/editor/create.js +11 -2
  139. package/dist/editor/create.js.map +1 -1
  140. package/dist/editor/design-tokens.d.ts +1 -1
  141. package/dist/editor/design-tokens.d.ts.map +1 -1
  142. package/dist/editor/design-tokens.js +4 -18
  143. package/dist/editor/design-tokens.js.map +1 -1
  144. package/dist/editor/image-edit.d.ts.map +1 -1
  145. package/dist/editor/image-edit.js +1 -2
  146. package/dist/editor/image-edit.js.map +1 -1
  147. package/dist/editor/index.d.ts +4 -4
  148. package/dist/editor/index.js +1 -1
  149. package/dist/editor/layout-mode.d.ts +3 -1
  150. package/dist/editor/layout-mode.d.ts.map +1 -1
  151. package/dist/editor/layout-mode.js +97 -2
  152. package/dist/editor/layout-mode.js.map +1 -1
  153. package/dist/editor/nodes.d.ts +2 -0
  154. package/dist/editor/nodes.d.ts.map +1 -1
  155. package/dist/editor/nodes.js +22 -7
  156. package/dist/editor/nodes.js.map +1 -1
  157. package/dist/editor/read-only/actions.js +6 -0
  158. package/dist/editor/read-only/actions.js.map +1 -1
  159. package/dist/editor/selection/overlays.d.ts +1 -0
  160. package/dist/editor/selection/overlays.d.ts.map +1 -1
  161. package/dist/editor/selection/overlays.js +7 -0
  162. package/dist/editor/selection/overlays.js.map +1 -1
  163. package/dist/editor/selection/read.d.ts +8 -0
  164. package/dist/editor/selection.d.ts +9 -0
  165. package/dist/editor/selection.d.ts.map +1 -1
  166. package/dist/editor/state/shared.js +1 -0
  167. package/dist/editor/state/shared.js.map +1 -1
  168. package/dist/editor/state/view.d.ts.map +1 -1
  169. package/dist/editor/state/view.js +2 -0
  170. package/dist/editor/state/view.js.map +1 -1
  171. package/dist/editor/structure/boolean.d.ts +1 -1
  172. package/dist/editor/structure/boolean.d.ts.map +1 -1
  173. package/dist/editor/structure/boolean.js +20 -1
  174. package/dist/editor/structure/boolean.js.map +1 -1
  175. package/dist/editor/structure/container-wrap.d.ts +8 -2
  176. package/dist/editor/structure/container-wrap.d.ts.map +1 -1
  177. package/dist/editor/structure/container-wrap.js +17 -5
  178. package/dist/editor/structure/container-wrap.js.map +1 -1
  179. package/dist/editor/structure/flatten.d.ts.map +1 -1
  180. package/dist/editor/structure/flatten.js +8 -7
  181. package/dist/editor/structure/flatten.js.map +1 -1
  182. package/dist/editor/structure/group/ungroup.d.ts.map +1 -1
  183. package/dist/editor/structure/group/ungroup.js +2 -0
  184. package/dist/editor/structure/group/ungroup.js.map +1 -1
  185. package/dist/editor/structure/outline-stroke.d.ts.map +1 -1
  186. package/dist/editor/structure/outline-stroke.js +5 -0
  187. package/dist/editor/structure/outline-stroke.js.map +1 -1
  188. package/dist/editor/structure.d.ts +1 -1
  189. package/dist/editor/structure.d.ts.map +1 -1
  190. package/dist/editor/styles.d.ts +26 -0
  191. package/dist/editor/styles.d.ts.map +1 -0
  192. package/dist/editor/styles.js +127 -0
  193. package/dist/editor/styles.js.map +1 -0
  194. package/dist/editor/text/selection-style.d.ts +1 -0
  195. package/dist/editor/text/selection-style.d.ts.map +1 -1
  196. package/dist/editor/text/selection-style.js +10 -2
  197. package/dist/editor/text/selection-style.js.map +1 -1
  198. package/dist/editor/tool-registry.d.ts.map +1 -1
  199. package/dist/editor/tool-registry.js +6 -0
  200. package/dist/editor/tool-registry.js.map +1 -1
  201. package/dist/editor/types.d.ts +14 -2
  202. package/dist/editor/types.d.ts.map +1 -1
  203. package/dist/editor/variable-bindings.d.ts.map +1 -1
  204. package/dist/editor/variable-bindings.js +6 -1
  205. package/dist/editor/variable-bindings.js.map +1 -1
  206. package/dist/figma-api/accessors/basic.d.ts.map +1 -1
  207. package/dist/figma-api/accessors/basic.js +22 -1
  208. package/dist/figma-api/accessors/basic.js.map +1 -1
  209. package/dist/figma-api/accessors/shape.js +1 -1
  210. package/dist/figma-api/accessors/text/index.js +1 -1
  211. package/dist/figma-api/accessors/text/ranges.js +1 -1
  212. package/dist/figma-api/accessors/text/references.js +1 -1
  213. package/dist/figma-api/accessors/variables.js +1 -1
  214. package/dist/figma-api/accessors/vector.d.ts.map +1 -1
  215. package/dist/figma-api/accessors/vector.js +8 -22
  216. package/dist/figma-api/accessors/vector.js.map +1 -1
  217. package/dist/figma-api/accessors/visual.js +1 -1
  218. package/dist/figma-api/compatibility.d.ts +1 -1
  219. package/dist/figma-api/compatibility.d.ts.map +1 -1
  220. package/dist/figma-api/component-scope.d.ts +14 -0
  221. package/dist/figma-api/component-scope.d.ts.map +1 -0
  222. package/dist/figma-api/component-scope.js +28 -0
  223. package/dist/figma-api/component-scope.js.map +1 -0
  224. package/dist/figma-api/components.d.ts.map +1 -1
  225. package/dist/figma-api/components.js +26 -2
  226. package/dist/figma-api/components.js.map +1 -1
  227. package/dist/figma-api/flatten.js +3 -3
  228. package/dist/figma-api/flatten.js.map +1 -1
  229. package/dist/figma-api/index.d.ts +77 -6
  230. package/dist/figma-api/index.d.ts.map +1 -1
  231. package/dist/figma-api/index.js +188 -2
  232. package/dist/figma-api/index.js.map +1 -1
  233. package/dist/figma-api/node-types.d.ts +2 -1
  234. package/dist/figma-api/node-types.d.ts.map +1 -1
  235. package/dist/figma-api/overrides.d.ts +26 -1
  236. package/dist/figma-api/overrides.d.ts.map +1 -1
  237. package/dist/figma-api/overrides.js +157 -10
  238. package/dist/figma-api/overrides.js.map +1 -1
  239. package/dist/figma-api/proxy.d.ts +2 -0
  240. package/dist/figma-api/proxy.d.ts.map +1 -1
  241. package/dist/figma-api/proxy.js +10 -2
  242. package/dist/figma-api/proxy.js.map +1 -1
  243. package/dist/figma-api/reactions.d.ts +61 -5
  244. package/dist/figma-api/reactions.d.ts.map +1 -1
  245. package/dist/figma-api/reactions.js +144 -11
  246. package/dist/figma-api/reactions.js.map +1 -1
  247. package/dist/figma-api/shape-with-text.js +1 -1
  248. package/dist/figma-api/slots.d.ts +3 -1
  249. package/dist/figma-api/slots.d.ts.map +1 -1
  250. package/dist/figma-api/slots.js +9 -8
  251. package/dist/figma-api/slots.js.map +1 -1
  252. package/dist/index.d.ts +4 -4
  253. package/dist/index.js +1 -1
  254. package/dist/io/formats/code/detect.d.ts +23 -0
  255. package/dist/io/formats/code/detect.d.ts.map +1 -0
  256. package/dist/io/formats/code/detect.js +46 -0
  257. package/dist/io/formats/code/detect.js.map +1 -0
  258. package/dist/io/formats/code/index.d.ts +5 -0
  259. package/dist/io/formats/code/index.js +5 -0
  260. package/dist/io/formats/code/read.d.ts +45 -0
  261. package/dist/io/formats/code/read.d.ts.map +1 -0
  262. package/dist/io/formats/code/read.js +86 -0
  263. package/dist/io/formats/code/read.js.map +1 -0
  264. package/dist/io/formats/code/stylesheet.d.ts +13 -0
  265. package/dist/io/formats/code/stylesheet.d.ts.map +1 -0
  266. package/dist/io/formats/code/stylesheet.js +21 -0
  267. package/dist/io/formats/code/stylesheet.js.map +1 -0
  268. package/dist/io/formats/code/tokens.d.ts +18 -0
  269. package/dist/io/formats/code/tokens.d.ts.map +1 -0
  270. package/dist/io/formats/code/tokens.js +135 -0
  271. package/dist/io/formats/code/tokens.js.map +1 -0
  272. package/dist/io/formats/design-tokens/apply.d.ts +7 -3
  273. package/dist/io/formats/design-tokens/apply.d.ts.map +1 -1
  274. package/dist/io/formats/design-tokens/apply.js.map +1 -1
  275. package/dist/io/formats/drawio/warnings.d.ts +17 -2
  276. package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
  277. package/dist/io/formats/drawio/warnings.js +14 -7
  278. package/dist/io/formats/drawio/warnings.js.map +1 -1
  279. package/dist/io/formats/fig/export/patch/fields.js +5 -0
  280. package/dist/io/formats/fig/export/patch/fields.js.map +1 -1
  281. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  282. package/dist/io/formats/fig/export/patch/index.js +20 -20
  283. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  284. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  285. package/dist/io/formats/fig/export/setup.js +5 -1
  286. package/dist/io/formats/fig/export/setup.js.map +1 -1
  287. package/dist/io/formats/fig/index.d.ts +3 -2
  288. package/dist/io/formats/fig/index.js +2 -2
  289. package/dist/io/formats/fig/read.d.ts.map +1 -1
  290. package/dist/io/formats/fig/read.js +5 -2
  291. package/dist/io/formats/fig/read.js.map +1 -1
  292. package/dist/io/formats/html/index.d.ts +1 -0
  293. package/dist/io/formats/html/index.d.ts.map +1 -1
  294. package/dist/io/formats/html/index.js +5 -3
  295. package/dist/io/formats/html/index.js.map +1 -1
  296. package/dist/io/formats/html/layers.d.ts +3 -1
  297. package/dist/io/formats/html/layers.d.ts.map +1 -1
  298. package/dist/io/formats/html/layers.js +6 -1
  299. package/dist/io/formats/html/layers.js.map +1 -1
  300. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  301. package/dist/io/formats/pdf/export.js +7 -3
  302. package/dist/io/formats/pdf/export.js.map +1 -1
  303. package/dist/io/formats/pdf/plan.d.ts +3 -0
  304. package/dist/io/formats/pdf/plan.d.ts.map +1 -1
  305. package/dist/io/formats/pdf/plan.js +60 -36
  306. package/dist/io/formats/pdf/plan.js.map +1 -1
  307. package/dist/io/formats/pen/index.d.ts.map +1 -1
  308. package/dist/io/formats/pen/index.js +13 -4
  309. package/dist/io/formats/pen/index.js.map +1 -1
  310. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  311. package/dist/io/formats/raster/headless.js +3 -2
  312. package/dist/io/formats/raster/headless.js.map +1 -1
  313. package/dist/io/formats/raster/index.d.ts +2 -2
  314. package/dist/io/formats/raster/index.js +2 -2
  315. package/dist/io/formats/raster/render.d.ts +10 -2
  316. package/dist/io/formats/raster/render.d.ts.map +1 -1
  317. package/dist/io/formats/raster/render.js +35 -9
  318. package/dist/io/formats/raster/render.js.map +1 -1
  319. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  320. package/dist/io/formats/svg/defs.js +19 -1
  321. package/dist/io/formats/svg/defs.js.map +1 -1
  322. package/dist/io/formats/svg/export.d.ts +5 -2
  323. package/dist/io/formats/svg/export.d.ts.map +1 -1
  324. package/dist/io/formats/svg/export.js +59 -10
  325. package/dist/io/formats/svg/export.js.map +1 -1
  326. package/dist/io/formats/svg/index.d.ts +2 -2
  327. package/dist/io/formats/svg/index.js +2 -2
  328. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  329. package/dist/io/formats/svg/text/layout.js +4 -2
  330. package/dist/io/formats/svg/text/layout.js.map +1 -1
  331. package/dist/io/formats/video/record.d.ts.map +1 -1
  332. package/dist/io/formats/video/record.js +24 -9
  333. package/dist/io/formats/video/record.js.map +1 -1
  334. package/dist/io/formats.d.ts.map +1 -1
  335. package/dist/io/formats.js +30 -17
  336. package/dist/io/formats.js.map +1 -1
  337. package/dist/io/index.d.ts +2 -2
  338. package/dist/io/types.d.ts +11 -2
  339. package/dist/io/types.d.ts.map +1 -1
  340. package/dist/kiwi/fig/population/client.d.ts.map +1 -1
  341. package/dist/kiwi/fig/population/client.js +2 -1
  342. package/dist/kiwi/fig/population/client.js.map +1 -1
  343. package/dist/kiwi/fig/session/document-state.d.ts +46 -2
  344. package/dist/kiwi/fig/session/document-state.d.ts.map +1 -1
  345. package/dist/kiwi/fig/session/document-state.js +113 -5
  346. package/dist/kiwi/fig/session/document-state.js.map +1 -1
  347. package/dist/kiwi/fig/session/options.d.ts +4 -0
  348. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  349. package/dist/kiwi/fig/session/options.js.map +1 -1
  350. package/dist/layout/apply.d.ts.map +1 -1
  351. package/dist/layout/apply.js +8 -4
  352. package/dist/layout/apply.js.map +1 -1
  353. package/dist/layout/auto-layout-handles.js +1 -1
  354. package/dist/layout/auto-layout-handles.js.map +1 -1
  355. package/dist/layout/axis-sizing.d.ts.map +1 -1
  356. package/dist/layout/axis-sizing.js +1 -1
  357. package/dist/layout/axis-sizing.js.map +1 -1
  358. package/dist/layout/derived.d.ts.map +1 -1
  359. package/dist/layout/derived.js +1 -1
  360. package/dist/layout/derived.js.map +1 -1
  361. package/dist/layout/effective-generated-text.js +1 -1
  362. package/dist/layout/effective-generated-text.js.map +1 -1
  363. package/dist/layout/grid.d.ts +3 -1
  364. package/dist/layout/grid.d.ts.map +1 -1
  365. package/dist/layout/grid.js +57 -16
  366. package/dist/layout/grid.js.map +1 -1
  367. package/dist/layout.d.ts +1 -1
  368. package/dist/layout.js +6 -5
  369. package/dist/layout.js.map +1 -1
  370. package/dist/node/fs.d.ts.map +1 -1
  371. package/dist/node/fs.js +28 -7
  372. package/dist/node/fs.js.map +1 -1
  373. package/dist/prototype/easing.d.ts +13 -5
  374. package/dist/prototype/easing.d.ts.map +1 -1
  375. package/dist/prototype/easing.js +46 -6
  376. package/dist/prototype/easing.js.map +1 -1
  377. package/dist/prototype/scenes.d.ts +31 -0
  378. package/dist/prototype/scenes.d.ts.map +1 -1
  379. package/dist/prototype/scenes.js +220 -31
  380. package/dist/prototype/scenes.js.map +1 -1
  381. package/dist/prototype/session.d.ts.map +1 -1
  382. package/dist/prototype/session.js +1 -0
  383. package/dist/prototype/session.js.map +1 -1
  384. package/dist/prototype/smart-animate/animation.d.ts +2 -1
  385. package/dist/prototype/smart-animate/animation.d.ts.map +1 -1
  386. package/dist/prototype/smart-animate/animation.js +2 -2
  387. package/dist/prototype/smart-animate/animation.js.map +1 -1
  388. package/dist/prototype/timeline.d.ts +10 -1
  389. package/dist/prototype/timeline.d.ts.map +1 -1
  390. package/dist/prototype/timeline.js +69 -23
  391. package/dist/prototype/timeline.js.map +1 -1
  392. package/dist/prototype/variables.d.ts +23 -0
  393. package/dist/prototype/variables.d.ts.map +1 -0
  394. package/dist/prototype/variables.js +237 -0
  395. package/dist/prototype/variables.js.map +1 -0
  396. package/dist/rpc/read-commands.d.ts +5 -0
  397. package/dist/rpc/read-commands.d.ts.map +1 -1
  398. package/dist/rpc/read-commands.js +4 -1
  399. package/dist/rpc/read-commands.js.map +1 -1
  400. package/dist/text/character-style.d.ts +8 -1
  401. package/dist/text/character-style.d.ts.map +1 -1
  402. package/dist/text/character-style.js +39 -1
  403. package/dist/text/character-style.js.map +1 -1
  404. package/dist/text/index.d.ts +2 -2
  405. package/dist/text/index.js +2 -2
  406. package/dist/tools/create/basic.js +3 -4
  407. package/dist/tools/create/basic.js.map +1 -1
  408. package/dist/tools/create/behaviours.js +1 -1
  409. package/dist/tools/create/code.d.ts +6 -0
  410. package/dist/tools/create/code.d.ts.map +1 -0
  411. package/dist/tools/create/code.js +68 -0
  412. package/dist/tools/create/code.js.map +1 -0
  413. package/dist/tools/create/html.d.ts.map +1 -1
  414. package/dist/tools/create/html.js +9 -57
  415. package/dist/tools/create/html.js.map +1 -1
  416. package/dist/tools/create/icons.js +1 -1
  417. package/dist/tools/create/inputs.d.ts +11 -0
  418. package/dist/tools/create/inputs.d.ts.map +1 -0
  419. package/dist/tools/create/inputs.js +15 -0
  420. package/dist/tools/create/inputs.js.map +1 -0
  421. package/dist/tools/create/mermaid.d.ts.map +1 -1
  422. package/dist/tools/create/mermaid.js +5 -6
  423. package/dist/tools/create/mermaid.js.map +1 -1
  424. package/dist/tools/create/place.d.ts +30 -0
  425. package/dist/tools/create/place.d.ts.map +1 -0
  426. package/dist/tools/create/place.js +70 -0
  427. package/dist/tools/create/place.js.map +1 -0
  428. package/dist/tools/create/render.js +1 -1
  429. package/dist/tools/create/svg.js +1 -1
  430. package/dist/tools/create/vector.js +1 -1
  431. package/dist/tools/create.d.ts +2 -1
  432. package/dist/tools/create.js +2 -1
  433. package/dist/tools/css/gradient.d.ts +28 -0
  434. package/dist/tools/css/gradient.d.ts.map +1 -0
  435. package/dist/tools/css/gradient.js +118 -0
  436. package/dist/tools/css/gradient.js.map +1 -0
  437. package/dist/tools/image-ai/generate.js +1 -1
  438. package/dist/tools/modify/geometry.js +5 -5
  439. package/dist/tools/modify/geometry.js.map +1 -1
  440. package/dist/tools/modify/layout.d.ts.map +1 -1
  441. package/dist/tools/modify/layout.js +7 -1
  442. package/dist/tools/modify/layout.js.map +1 -1
  443. package/dist/tools/modify/matching.js +1 -1
  444. package/dist/tools/modify/overrides.d.ts +6 -0
  445. package/dist/tools/modify/overrides.d.ts.map +1 -0
  446. package/dist/tools/modify/overrides.js +27 -0
  447. package/dist/tools/modify/overrides.js.map +1 -0
  448. package/dist/tools/modify/paint.d.ts.map +1 -1
  449. package/dist/tools/modify/paint.js +84 -39
  450. package/dist/tools/modify/paint.js.map +1 -1
  451. package/dist/tools/modify/text.d.ts +2 -1
  452. package/dist/tools/modify/text.d.ts.map +1 -1
  453. package/dist/tools/modify/text.js +79 -8
  454. package/dist/tools/modify/text.js.map +1 -1
  455. package/dist/tools/modify/update.d.ts.map +1 -1
  456. package/dist/tools/modify/update.js +18 -2
  457. package/dist/tools/modify/update.js.map +1 -1
  458. package/dist/tools/modify.d.ts +3 -2
  459. package/dist/tools/modify.js +3 -2
  460. package/dist/tools/read/css.d.ts.map +1 -1
  461. package/dist/tools/read/css.js +29 -12
  462. package/dist/tools/read/css.js.map +1 -1
  463. package/dist/tools/read/libraries.js +1 -1
  464. package/dist/tools/read/nodes.d.ts.map +1 -1
  465. package/dist/tools/read/nodes.js +19 -5
  466. package/dist/tools/read/nodes.js.map +1 -1
  467. package/dist/tools/registry/extended.d.ts.map +1 -1
  468. package/dist/tools/registry/extended.js +6 -1
  469. package/dist/tools/registry/extended.js.map +1 -1
  470. package/dist/tools/text-range.d.ts +11 -0
  471. package/dist/tools/text-range.d.ts.map +1 -0
  472. package/dist/tools/text-range.js +26 -0
  473. package/dist/tools/text-range.js.map +1 -0
  474. package/dist/tools/variables/bindings.js +1 -1
  475. package/dist/tools/variables/bindings.js.map +1 -1
  476. package/dist/tools/variables/unbind.js +1 -1
  477. package/dist/tools/variables/unbind.js.map +1 -1
  478. package/dist/tools/vector/path.d.ts.map +1 -1
  479. package/dist/tools/vector/path.js +7 -21
  480. package/dist/tools/vector/path.js.map +1 -1
  481. package/dist/vector/rebase.d.ts +17 -0
  482. package/dist/vector/rebase.d.ts.map +1 -0
  483. package/dist/vector/rebase.js +32 -0
  484. package/dist/vector/rebase.js.map +1 -0
  485. package/package.json +14 -9
  486. package/src/canvas/boolean.ts +12 -1
  487. package/src/canvas/color-space.ts +73 -0
  488. package/src/canvas/fills.ts +130 -83
  489. package/src/canvas/flatten.ts +92 -7
  490. package/src/canvas/index.ts +9 -0
  491. package/src/canvas/layout-grids.ts +15 -2
  492. package/src/canvas/noise/render.ts +35 -7
  493. package/src/canvas/noise/shader.ts +8 -10
  494. package/src/canvas/overlays/annotations.ts +117 -0
  495. package/src/canvas/overlays/auto-layout-hover.ts +41 -1
  496. package/src/canvas/overlays/feedback.ts +7 -2
  497. package/src/canvas/overlays/index.ts +1 -1
  498. package/src/canvas/overlays/measurement.ts +49 -3
  499. package/src/canvas/overlays/presence.ts +35 -32
  500. package/src/canvas/renderer/colors.ts +14 -0
  501. package/src/canvas/renderer/document-surface.ts +16 -6
  502. package/src/canvas/renderer/lifecycle.ts +2 -2
  503. package/src/canvas/renderer/methods.ts +4 -0
  504. package/src/canvas/renderer/overlay-pass.ts +4 -0
  505. package/src/canvas/renderer/pipeline.ts +8 -0
  506. package/src/canvas/renderer/types.ts +8 -0
  507. package/src/canvas/renderer.ts +21 -2
  508. package/src/canvas/scene.ts +15 -7
  509. package/src/canvas/shaders/compile.ts +14 -3
  510. package/src/canvas/shaders/draw.ts +11 -4
  511. package/src/canvas/shaders/effect.ts +6 -18
  512. package/src/clipboard/pairdraw.ts +1 -0
  513. package/src/editor/bridges/clipboard.ts +1 -0
  514. package/src/editor/bridges/components.ts +10 -0
  515. package/src/editor/clipboard/code.ts +50 -0
  516. package/src/editor/clipboard/export.ts +2 -2
  517. package/src/editor/clipboard/paste/dependencies.ts +18 -0
  518. package/src/editor/clipboard/paste/run.ts +64 -0
  519. package/src/editor/clipboard/styled.ts +4 -52
  520. package/src/editor/clipboard.ts +40 -0
  521. package/src/editor/components/instances.ts +92 -4
  522. package/src/editor/components/slots/index.ts +7 -0
  523. package/src/editor/components.ts +16 -2
  524. package/src/editor/create.ts +15 -1
  525. package/src/editor/design-tokens.ts +3 -23
  526. package/src/editor/image-edit.ts +5 -2
  527. package/src/editor/index.ts +1 -0
  528. package/src/editor/layout-mode.ts +131 -3
  529. package/src/editor/nodes.ts +30 -5
  530. package/src/editor/read-only/actions.ts +6 -0
  531. package/src/editor/selection/overlays.ts +8 -0
  532. package/src/editor/state/shared.ts +1 -0
  533. package/src/editor/state/view.ts +2 -0
  534. package/src/editor/structure/boolean.ts +29 -1
  535. package/src/editor/structure/container-wrap.ts +20 -4
  536. package/src/editor/structure/flatten.ts +15 -8
  537. package/src/editor/structure/group/ungroup.ts +2 -0
  538. package/src/editor/structure/outline-stroke.ts +5 -0
  539. package/src/editor/styles.ts +203 -0
  540. package/src/editor/text/selection-style.ts +18 -1
  541. package/src/editor/tool-registry.ts +2 -0
  542. package/src/editor/types.ts +14 -0
  543. package/src/editor/variable-bindings.ts +11 -0
  544. package/src/figma-api/accessors/basic.ts +33 -1
  545. package/src/figma-api/accessors/vector.ts +6 -13
  546. package/src/figma-api/compatibility.ts +1 -0
  547. package/src/figma-api/component-scope.ts +36 -0
  548. package/src/figma-api/components.ts +24 -0
  549. package/src/figma-api/flatten.ts +7 -3
  550. package/src/figma-api/index.ts +302 -6
  551. package/src/figma-api/node-types.ts +1 -0
  552. package/src/figma-api/overrides.ts +192 -5
  553. package/src/figma-api/proxy.ts +16 -1
  554. package/src/figma-api/reactions.ts +163 -12
  555. package/src/figma-api/slots.ts +10 -9
  556. package/src/io/formats/code/detect.ts +67 -0
  557. package/src/io/formats/code/index.ts +17 -0
  558. package/src/io/formats/code/read.ts +143 -0
  559. package/src/io/formats/code/stylesheet.ts +24 -0
  560. package/src/io/formats/code/tokens.ts +159 -0
  561. package/src/io/formats/design-tokens/apply.ts +3 -2
  562. package/src/io/formats/drawio/warnings.ts +27 -8
  563. package/src/io/formats/fig/export/patch/fields.ts +11 -0
  564. package/src/io/formats/fig/export/patch/index.ts +23 -19
  565. package/src/io/formats/fig/export/setup.ts +8 -1
  566. package/src/io/formats/fig/index.ts +6 -0
  567. package/src/io/formats/fig/read.ts +11 -2
  568. package/src/io/formats/html/index.ts +9 -3
  569. package/src/io/formats/html/layers.ts +7 -0
  570. package/src/io/formats/pdf/export.ts +19 -7
  571. package/src/io/formats/pdf/plan.ts +71 -32
  572. package/src/io/formats/pen/index.ts +14 -6
  573. package/src/io/formats/raster/headless.ts +3 -1
  574. package/src/io/formats/raster/index.ts +2 -0
  575. package/src/io/formats/raster/render.ts +49 -9
  576. package/src/io/formats/svg/defs.ts +27 -1
  577. package/src/io/formats/svg/export.ts +75 -13
  578. package/src/io/formats/svg/index.ts +1 -0
  579. package/src/io/formats/svg/text/layout.ts +5 -3
  580. package/src/io/formats/video/record.ts +33 -9
  581. package/src/io/formats.ts +45 -19
  582. package/src/io/index.ts +1 -0
  583. package/src/io/types.ts +10 -0
  584. package/src/kiwi/fig/population/client.ts +6 -1
  585. package/src/kiwi/fig/session/document-state.ts +195 -5
  586. package/src/kiwi/fig/session/options.ts +2 -0
  587. package/src/layout/apply.ts +12 -4
  588. package/src/layout/auto-layout-handles.ts +1 -1
  589. package/src/layout/axis-sizing.ts +3 -1
  590. package/src/layout/derived.ts +3 -1
  591. package/src/layout/effective-generated-text.ts +1 -1
  592. package/src/layout/grid.ts +91 -21
  593. package/src/layout.ts +16 -3
  594. package/src/node/fs.ts +32 -7
  595. package/src/prototype/easing.ts +79 -7
  596. package/src/prototype/scenes.ts +244 -15
  597. package/src/prototype/session.ts +1 -0
  598. package/src/prototype/smart-animate/animation.ts +4 -3
  599. package/src/prototype/timeline.ts +118 -26
  600. package/src/prototype/variables.ts +189 -0
  601. package/src/rpc/read-commands.ts +19 -1
  602. package/src/text/character-style.ts +47 -0
  603. package/src/text/index.ts +1 -1
  604. package/src/tools/create/basic.ts +2 -3
  605. package/src/tools/create/code.ts +85 -0
  606. package/src/tools/create/html.ts +9 -46
  607. package/src/tools/create/inputs.ts +12 -0
  608. package/src/tools/create/mermaid.ts +6 -6
  609. package/src/tools/create/place.ts +80 -0
  610. package/src/tools/create.ts +1 -0
  611. package/src/tools/css/gradient.ts +147 -0
  612. package/src/tools/modify/geometry.ts +5 -5
  613. package/src/tools/modify/layout.ts +19 -0
  614. package/src/tools/modify/overrides.ts +35 -0
  615. package/src/tools/modify/paint.ts +124 -54
  616. package/src/tools/modify/text.ts +91 -7
  617. package/src/tools/modify/update.ts +23 -2
  618. package/src/tools/modify.ts +9 -1
  619. package/src/tools/read/css.ts +46 -12
  620. package/src/tools/read/nodes.ts +26 -4
  621. package/src/tools/registry/extended.ts +6 -0
  622. package/src/tools/text-range.ts +29 -0
  623. package/src/tools/variables/bindings.ts +4 -1
  624. package/src/tools/variables/unbind.ts +4 -1
  625. package/src/tools/vector/path.ts +11 -13
  626. package/src/vector/rebase.ts +33 -0
@@ -17,12 +17,7 @@ const UNSUPPORTED_TRIGGERS = {
17
17
  ON_KEY_DOWN: true
18
18
  };
19
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
- };
20
+ const UNSUPPORTED_ACTIONS = { URL: true };
26
21
  const secondsSchema = v.pipe(v.number(), v.minValue(0));
27
22
  const overlayPositionSchema = v.picklist([
28
23
  "CENTER",
@@ -62,10 +57,85 @@ const nodeActionSchema = v.strictObject({
62
57
  }),
63
58
  overlayRelativePosition: v.optional(overlayPositionSchema, "CENTER")
64
59
  });
60
+ const colorSchema = v.strictObject({
61
+ r: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
62
+ g: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
63
+ b: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
64
+ a: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))
65
+ });
66
+ const expressionFunctionSchema = v.picklist([
67
+ "ADDITION",
68
+ "SUBTRACTION",
69
+ "RESOLVE_VARIANT",
70
+ "MULTIPLY",
71
+ "DIVIDE",
72
+ "EQUALS",
73
+ "NOT_EQUAL",
74
+ "LESS_THAN",
75
+ "LESS_THAN_OR_EQUAL",
76
+ "GREATER_THAN",
77
+ "GREATER_THAN_OR_EQUAL",
78
+ "AND",
79
+ "OR",
80
+ "NOT",
81
+ "STRINGIFY",
82
+ "TERNARY",
83
+ "VAR_MODE_LOOKUP",
84
+ "NEGATE",
85
+ "IS_TRUTHY",
86
+ "KEYFRAME",
87
+ "COMPOSE_COLOR"
88
+ ]);
89
+ /** Figma's plugin `VariableData`: a literal, an alias, or an expression tree. */
90
+ const variableDataSchema = v.lazy(() => v.variant("kind", [
91
+ v.strictObject({
92
+ kind: v.literal("boolean"),
93
+ value: v.boolean()
94
+ }),
95
+ v.strictObject({
96
+ kind: v.literal("number"),
97
+ value: v.number()
98
+ }),
99
+ v.strictObject({
100
+ kind: v.literal("string"),
101
+ value: v.string()
102
+ }),
103
+ v.strictObject({
104
+ kind: v.literal("color"),
105
+ value: colorSchema
106
+ }),
107
+ v.strictObject({
108
+ kind: v.literal("alias"),
109
+ variableId: v.string()
110
+ }),
111
+ v.strictObject({
112
+ kind: v.literal("expression"),
113
+ fn: expressionFunctionSchema,
114
+ args: v.array(variableDataSchema)
115
+ })
116
+ ]));
117
+ const conditionalBlockSchema = v.strictObject({
118
+ condition: v.optional(variableDataSchema),
119
+ actions: v.array(v.unknown())
120
+ });
65
121
  const actionSchema = v.variant("type", [
66
122
  nodeActionSchema,
67
123
  v.strictObject({ type: v.literal("BACK") }),
68
- v.strictObject({ type: v.literal("CLOSE") })
124
+ v.strictObject({ type: v.literal("CLOSE") }),
125
+ v.strictObject({
126
+ type: v.literal("SET_VARIABLE"),
127
+ variableId: v.optional(v.string()),
128
+ variableValue: variableDataSchema
129
+ }),
130
+ v.strictObject({
131
+ type: v.literal("SET_VARIABLE_MODE"),
132
+ variableCollectionId: v.optional(v.string()),
133
+ variableModeId: v.optional(v.string())
134
+ }),
135
+ v.strictObject({
136
+ type: v.literal("CONDITIONAL"),
137
+ conditionalBlocks: v.array(conditionalBlockSchema)
138
+ })
69
139
  ]);
70
140
  const triggerSchema = v.variant("type", [
71
141
  v.strictObject({ type: v.picklist([
@@ -109,6 +179,28 @@ function toFigmaTrigger({ type, delay }) {
109
179
  return { type };
110
180
  }
111
181
  function toFigmaAction(action) {
182
+ if (action.type === "SET_VARIABLE") {
183
+ const set = {
184
+ type: "SET_VARIABLE",
185
+ variableValue: action.value
186
+ };
187
+ return action.variableId ? {
188
+ ...set,
189
+ variableId: action.variableId
190
+ } : set;
191
+ }
192
+ if (action.type === "SET_VARIABLE_MODE") return {
193
+ type: "SET_VARIABLE_MODE",
194
+ variableCollectionId: action.collectionId ?? void 0,
195
+ variableModeId: action.modeId ?? void 0
196
+ };
197
+ if (action.type === "CONDITIONAL") return {
198
+ type: "CONDITIONAL",
199
+ conditionalBlocks: action.blocks.map((block) => ({
200
+ ...block.condition ? { condition: block.condition } : {},
201
+ actions: block.actions.map(toFigmaAction)
202
+ }))
203
+ };
112
204
  if (action.type !== "NODE") return { type: action.type };
113
205
  return {
114
206
  type: "NODE",
@@ -174,8 +266,36 @@ function toTrigger(trigger) {
174
266
  delay: "delay" in trigger ? trigger.delay : 0
175
267
  };
176
268
  }
269
+ function parseNestedAction(nested, reactionIndex) {
270
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) throw failure(`reactions[${reactionIndex}] has a conditional action that is not an object`);
271
+ const result = v.safeParse(actionSchema, nested);
272
+ if (!result.success) {
273
+ const [issue] = result.issues;
274
+ const path = issuePath(issue.path);
275
+ throw failure(`reactions[${reactionIndex}] has a conditional action failing validation: ${issue.message}${path ? ` at ${path}` : ""}`);
276
+ }
277
+ return result.output;
278
+ }
177
279
  function toAction(action, context, reactionIndex) {
178
- if (action.type !== "NODE") return { type: action.type };
280
+ if (action.type === "BACK") return { type: "BACK" };
281
+ if (action.type === "CLOSE") return { type: "CLOSE" };
282
+ if (action.type === "SET_VARIABLE") return {
283
+ type: "SET_VARIABLE",
284
+ variableId: action.variableId ?? null,
285
+ value: action.variableValue
286
+ };
287
+ if (action.type === "SET_VARIABLE_MODE") return {
288
+ type: "SET_VARIABLE_MODE",
289
+ collectionId: action.variableCollectionId ?? null,
290
+ modeId: action.variableModeId ?? null
291
+ };
292
+ if (action.type === "CONDITIONAL") return {
293
+ type: "CONDITIONAL",
294
+ blocks: action.conditionalBlocks.map((block) => ({
295
+ ...block.condition ? { condition: block.condition } : {},
296
+ actions: block.actions.map((nested) => toAction(parseNestedAction(nested, reactionIndex), context, reactionIndex))
297
+ }))
298
+ };
179
299
  const destinationId = resolveDestinationId(action, context, reactionIndex);
180
300
  assertDestination({
181
301
  ...action,
@@ -260,6 +380,19 @@ function assertScrollTarget(destination, context, at) {
260
380
  const top = topLevelOf(graph, nodeId, pageId);
261
381
  if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) throw failure(`${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} "${destination.name}"`);
262
382
  }
383
+ function unsupportedActionReason(action) {
384
+ if (!action || typeof action !== "object" || !("type" in action)) return null;
385
+ const { type } = action;
386
+ if (typeof type === "string" && type in UNSUPPORTED_ACTIONS) return `an action is NODE, BACK or CLOSE, not ${type}`;
387
+ if (type === "CONDITIONAL" && "conditionalBlocks" in action && Array.isArray(action.conditionalBlocks)) for (const block of action.conditionalBlocks) {
388
+ if (!block || typeof block !== "object" || !("actions" in block) || !Array.isArray(block.actions)) continue;
389
+ for (const nested of block.actions) {
390
+ const nestedReason = unsupportedActionReason(nested);
391
+ if (nestedReason) return nestedReason;
392
+ }
393
+ }
394
+ return null;
395
+ }
263
396
  /** Figma's first unsupported trigger or action kind in `value`, if it has one. */
264
397
  function unsupportedKind(value) {
265
398
  if (!Array.isArray(value)) return null;
@@ -272,9 +405,9 @@ function unsupportedKind(value) {
272
405
  }
273
406
  const actions = reaction.actions;
274
407
  if (!Array.isArray(actions)) continue;
275
- for (const action of actions) if (action && typeof action === "object" && "type" in action) {
276
- const type = action.type;
277
- if (typeof type === "string" && type in UNSUPPORTED_ACTIONS) return `an action is NODE, BACK or CLOSE, not ${type}`;
408
+ for (const action of actions) {
409
+ const reason = unsupportedActionReason(action);
410
+ if (reason) return reason;
278
411
  }
279
412
  }
280
413
  return null;
@@ -1 +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 PrototypeTransition,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { variantSetsAround } from '@pairdraw/scene-graph/components'\nimport { PROTOTYPE_EASINGS } from '@pairdraw/scene-graph/constants'\nimport { parseVariantName } from '@pairdraw/scene-graph/variant-name'\n\nimport { issuePath } from '#core/figma-api/effects'\nimport { asInstanceEdit, sameReaction } from '#core/prototype/reactions'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: 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\n/** Figma's easing presets, which play has; a spring or a custom curve is refused. */\nconst easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) })\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE', 'SMART_ANIMATE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema,\n easing: v.optional(easingSchema)\n})\n\n/** A variant's values for its set's properties, as `{ State: 'Hover', Size: 'Large' }`. */\nconst variantPropertiesSchema = v.pipe(\n v.record(v.string(), v.string()),\n v.minEntries(1),\n v.description(\n \"CHANGE_TO: the values of the variant to change to, in the layer's nearest component set, \" +\n 'such as { State: \"Hover\" }. Name every property of a set whose variants share values, as ' +\n 'a partial match is refused. Resolved to the variant, so get_reactions reads it back as ' +\n 'a destinationId.'\n )\n)\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.optional(\n v.pipe(\n v.string(),\n v.minLength(1),\n v.description(\n 'NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the ' +\n \"layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's \" +\n 'top-level frame. Omit only for CHANGE_TO, and name the variant with variantProperties.'\n )\n )\n ),\n variantProperties: v.optional(variantPropertiesSchema),\n navigation: v.picklist([\n 'NAVIGATE',\n 'OVERLAY',\n 'CHANGE_TO',\n 'SCROLL_TO'\n ] 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.picklist(['ON_CLICK', 'ON_HOVER', 'ON_PRESS']) }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema }),\n v.strictObject({\n type: v.picklist(['MOUSE_ENTER', 'MOUSE_LEAVE']),\n delay: v.optional(secondsSchema, 0),\n // Figma's plugin API reads it; play treats both versions alike.\n deprecatedVersion: v.optional(v.boolean())\n })\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 return { trigger: toFigmaTrigger(reaction.trigger), actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaTrigger({ type, delay }: PrototypeReaction['trigger']): FigmaReactionTrigger {\n if (type === 'AFTER_TIMEOUT') return { type, timeout: delay }\n if (type === 'MOUSE_ENTER' || type === 'MOUSE_LEAVE') return { type, delay }\n return { type }\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: toFigmaTransition(action.transition),\n overlayRelativePosition: action.overlayPosition\n }\n}\n\nfunction toFigmaTransition({\n type,\n duration,\n easing\n}: PrototypeTransition): v.InferOutput<typeof transitionSchema> {\n return easing ? { type, duration, easing: { type: easing } } : { type, duration }\n}\n\nfunction fromFigmaTransition({\n type,\n duration,\n easing\n}: v.InferOutput<typeof transitionSchema>): PrototypeTransition {\n return easing ? { type, duration, easing: easing.type } : { type, duration }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The layer the reactions are on, which a Change to or Scroll to destination must suit. */\n nodeId: string\n /** The page the layer is on; a navigation's 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 * An instance's main component's reactions: a reaction kept under one of their ids that an\n * edit changed, from what the layer held at its place and from the main's, becomes the\n * instance's own, with an id of its own.\n */\n inherited?: 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 const parsed: PrototypeReaction = {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n // One the layer already held unchanged stays as it was, a copy of the main's included, so\n // writing reactions back as read never re-ids a copy whose main was edited since.\n const held = context.previous?.[index]\n if (held && sameReaction(held, parsed)) return parsed\n return asInstanceEdit(parsed, context.inherited ?? [])\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n if (trigger.type === 'AFTER_TIMEOUT') return { type, delay: trigger.timeout }\n return { type, delay: 'delay' in trigger ? trigger.delay : 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 const destinationId = resolveDestinationId(action, context, reactionIndex)\n assertDestination({ ...action, destinationId }, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: destinationId,\n navigation: action.navigation,\n transition: fromFigmaTransition(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/**\n * The layer a NODE action points at: its `destinationId`, or for a Change to, the variant of the\n * layer's set whose `variantProperties` it names.\n */\nfunction resolveDestinationId(\n action: v.InferOutput<typeof nodeActionSchema>,\n context: ReactionContext,\n index: number\n): string {\n const at = `reactions[${index}]`\n const { destinationId, variantProperties, navigation } = action\n if (destinationId && variantProperties) {\n throw failure(`${at} names both destinationId and variantProperties; give one`)\n }\n if (variantProperties) {\n if (navigation !== 'CHANGE_TO') {\n throw failure(`${at}: variantProperties is for CHANGE_TO only, not ${navigation}`)\n }\n return variantByProperties(variantProperties, context, at)\n }\n if (!destinationId) {\n throw failure(\n navigation === 'CHANGE_TO'\n ? `${at} must name the variant it Changes to, in destinationId or variantProperties`\n : `${at} must name the layer it goes to, in destinationId`\n )\n }\n return destinationId\n}\n\n/** The id of the variant of the sets around the layer whose properties are `properties`. */\nfunction variantByProperties(\n properties: Record<string, string>,\n context: ReactionContext,\n at: string\n): string {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const wanted = Object.entries(properties)\n .map(([name, value]) => `${name}=${value}`)\n .join(', ')\n for (const set of sets) {\n const matches = context.graph.getChildren(set.id).filter((child) => {\n if (child.type !== 'COMPONENT') return false\n const values = { ...parseVariantName(child.name), ...child.componentPropertyValues }\n return Object.entries(properties).every(([name, value]) => values[name] === value)\n })\n if (matches.length === 1) return matches[0].id\n // A set can hold variants a partial map matches equally: refuse rather than pick one.\n if (matches.length > 1) {\n const names = matches.map((match) => `\"${match.name}\"`).join(', ')\n throw failure(\n `${at}: ${wanted} matches ${matches.length} variants of ${set.name} (${names}); name every property of the variant`\n )\n }\n }\n throw failure(`${at}: no variant of ${nearest.name} with ${wanted}`)\n}\n\nfunction failure(message: string): Error {\n return new Error(`Property \"reactions\" failed validation: ${message}`)\n}\n\n/**\n * A destination play can show: a navigation's is a frame at the top of the layer's page, a Change\n * to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's\n * top-level frame.\n */\nfunction assertDestination(\n action: Pick<v.InferOutput<typeof nodeActionSchema>, 'navigation'> & { destinationId: string },\n context: ReactionContext,\n index: number\n): void {\n const { destinationId, navigation } = action\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`)\n if (navigation === 'CHANGE_TO') return assertVariant(destination, context, at)\n if (navigation === 'SCROLL_TO') return assertScrollTarget(destination, context, at)\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw failure(\n `${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction assertVariant(destination: SceneNode, context: ReactionContext, at: string): void {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const inSet = sets.some((set) => set.id === destination.parentId)\n if (destination.type !== 'COMPONENT' || !inSet) {\n throw failure(\n `${at} must Change to a variant of ${nearest.name}, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** The page's direct child a layer sits in, which play shows as one screen. */\nfunction topLevelOf(graph: SceneGraph, nodeId: string, pageId: string): SceneNode | undefined {\n return graph.closest(nodeId, (node) => node.parentId === pageId)\n}\n\nfunction assertScrollTarget(destination: SceneNode, context: ReactionContext, at: string): void {\n const { graph, nodeId, pageId } = context\n const top = topLevelOf(graph, nodeId, pageId)\n if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) {\n throw failure(\n `${at} must Scroll to a layer inside the same top-level frame, 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, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE 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":";;;;;;;;;;;;AAyBA,MAAM,uBAA6C;CACjD,SAAS;CACT,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;;AAG1C,MAAM,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;AAE3E,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,SAAS;EAAC;EAAW;EAAY;CAAe,CAAqC;CAC7F,UAAU;CACV,QAAQ,EAAE,SAAS,YAAY;AACjC,CAAC;;AAGD,MAAM,0BAA0B,EAAE,KAChC,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,GAC/B,EAAE,WAAW,CAAC,GACd,EAAE,YACA,6RAIF,CACF;AAEA,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,QAAQ,MAAM;CACtB,eAAe,EAAE,SACf,EAAE,KACA,EAAE,OAAO,GACT,EAAE,UAAU,CAAC,GACb,EAAE,YACA,iQAGF,CACF,CACF;CACA,mBAAmB,EAAE,SAAS,uBAAuB;CACrD,YAAY,EAAE,SAAS;EACrB;E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OAAO,yCAAyC;EAEpD;CAEJ;CACA,OAAO;AACT"}
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 PrototypeExpressionFunction,\n PrototypeVariableValue,\n PrototypeNavigationType,\n PrototypeOverlayPositionType,\n PrototypeReaction,\n PrototypeTransition,\n PrototypeTransitionType,\n PrototypeTriggerType,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { variantSetsAround } from '@pairdraw/scene-graph/components'\nimport { PROTOTYPE_EASINGS } from '@pairdraw/scene-graph/constants'\nimport { parseVariantName } from '@pairdraw/scene-graph/variant-name'\n\nimport { issuePath } from '#core/figma-api/effects'\nimport { asInstanceEdit, sameReaction } from '#core/prototype/reactions'\n\n/**\n * Triggers Figma's plugin API offers that a prototype in Pairdraw cannot start from, and the\n * message it gets instead.\n */\nconst UNSUPPORTED_TRIGGERS: Record<string, true> = {\n ON_DRAG: 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}\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\n/** Figma's easing presets, which play has; a spring or a custom curve is refused. */\nconst easingSchema = v.strictObject({ type: v.picklist(PROTOTYPE_EASINGS) })\n\nconst transitionSchema = v.strictObject({\n type: v.picklist(['INSTANT', 'DISSOLVE', 'SMART_ANIMATE'] satisfies PrototypeTransitionType[]),\n duration: secondsSchema,\n easing: v.optional(easingSchema)\n})\n\n/** A variant's values for its set's properties, as `{ State: 'Hover', Size: 'Large' }`. */\nconst variantPropertiesSchema = v.pipe(\n v.record(v.string(), v.string()),\n v.minEntries(1),\n v.description(\n \"CHANGE_TO: the values of the variant to change to, in the layer's nearest component set, \" +\n 'such as { State: \"Hover\" }. Name every property of a set whose variants share values, as ' +\n 'a partial match is refused. Resolved to the variant, so get_reactions reads it back as ' +\n 'a destinationId.'\n )\n)\n\nconst nodeActionSchema = v.strictObject({\n type: v.literal('NODE'),\n destinationId: v.optional(\n v.pipe(\n v.string(),\n v.minLength(1),\n v.description(\n 'NAVIGATE/OVERLAY: a top-level frame on the page; CHANGE_TO: a variant of the set the ' +\n \"layer is a variant of, an instance of, or inside; SCROLL_TO: a layer in the layer's \" +\n 'top-level frame. Omit only for CHANGE_TO, and name the variant with variantProperties.'\n )\n )\n ),\n variantProperties: v.optional(variantPropertiesSchema),\n navigation: v.picklist([\n 'NAVIGATE',\n 'OVERLAY',\n 'CHANGE_TO',\n 'SCROLL_TO'\n ] satisfies PrototypeNavigationType[]),\n transition: v.optional(transitionSchema, { type: 'INSTANT', duration: 0 }),\n overlayRelativePosition: v.optional(overlayPositionSchema, 'CENTER')\n})\n\nconst colorSchema = v.strictObject({\n r: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n g: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n b: v.pipe(v.number(), v.minValue(0), v.maxValue(1)),\n a: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1)))\n})\n\nconst expressionFunctionSchema = v.picklist([\n 'ADDITION',\n 'SUBTRACTION',\n 'RESOLVE_VARIANT',\n 'MULTIPLY',\n 'DIVIDE',\n 'EQUALS',\n 'NOT_EQUAL',\n 'LESS_THAN',\n 'LESS_THAN_OR_EQUAL',\n 'GREATER_THAN',\n 'GREATER_THAN_OR_EQUAL',\n 'AND',\n 'OR',\n 'NOT',\n 'STRINGIFY',\n 'TERNARY',\n 'VAR_MODE_LOOKUP',\n 'NEGATE',\n 'IS_TRUTHY',\n 'KEYFRAME',\n 'COMPOSE_COLOR'\n] satisfies PrototypeExpressionFunction[])\n\n/** Figma's plugin `VariableData`: a literal, an alias, or an expression tree. */\nconst variableDataSchema: v.GenericSchema<PrototypeVariableValue> = v.lazy(() =>\n v.variant('kind', [\n v.strictObject({ kind: v.literal('boolean'), value: v.boolean() }),\n v.strictObject({ kind: v.literal('number'), value: v.number() }),\n v.strictObject({ kind: v.literal('string'), value: v.string() }),\n v.strictObject({ kind: v.literal('color'), value: colorSchema }),\n v.strictObject({ kind: v.literal('alias'), variableId: v.string() }),\n v.strictObject({\n kind: v.literal('expression'),\n fn: expressionFunctionSchema,\n args: v.array(variableDataSchema)\n })\n ])\n) as v.GenericSchema<PrototypeVariableValue>\n\nconst conditionalBlockSchema: v.GenericSchema<{\n condition?: PrototypeVariableValue\n actions: unknown[]\n}> = v.strictObject({\n condition: v.optional(variableDataSchema),\n // Nested actions are validated when the model is written; the schema keeps the tree open to\n // avoid a recursive type that TypeScript cannot name.\n actions: v.array(v.unknown())\n})\n\nconst actionSchema = v.variant('type', [\n nodeActionSchema,\n v.strictObject({ type: v.literal('BACK') }),\n v.strictObject({ type: v.literal('CLOSE') }),\n v.strictObject({\n type: v.literal('SET_VARIABLE'),\n variableId: v.optional(v.string()),\n variableValue: variableDataSchema\n }),\n v.strictObject({\n type: v.literal('SET_VARIABLE_MODE'),\n variableCollectionId: v.optional(v.string()),\n variableModeId: v.optional(v.string())\n }),\n v.strictObject({\n type: v.literal('CONDITIONAL'),\n conditionalBlocks: v.array(conditionalBlockSchema)\n })\n])\n\nconst triggerSchema = v.variant('type', [\n v.strictObject({ type: v.picklist(['ON_CLICK', 'ON_HOVER', 'ON_PRESS']) }),\n v.strictObject({ type: v.literal('AFTER_TIMEOUT'), timeout: secondsSchema }),\n v.strictObject({\n type: v.picklist(['MOUSE_ENTER', 'MOUSE_LEAVE']),\n delay: v.optional(secondsSchema, 0),\n // Figma's plugin API reads it; play treats both versions alike.\n deprecatedVersion: v.optional(v.boolean())\n })\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 return { trigger: toFigmaTrigger(reaction.trigger), actions: reaction.actions.map(toFigmaAction) }\n}\n\nfunction toFigmaTrigger({ type, delay }: PrototypeReaction['trigger']): FigmaReactionTrigger {\n if (type === 'AFTER_TIMEOUT') return { type, timeout: delay }\n if (type === 'MOUSE_ENTER' || type === 'MOUSE_LEAVE') return { type, delay }\n return { type }\n}\n\nfunction toFigmaAction(action: PrototypeAction): FigmaReactionAction {\n if (action.type === 'SET_VARIABLE') {\n const set = { type: 'SET_VARIABLE' as const, variableValue: action.value }\n return action.variableId ? { ...set, variableId: action.variableId } : set\n }\n if (action.type === 'SET_VARIABLE_MODE')\n return {\n type: 'SET_VARIABLE_MODE',\n variableCollectionId: action.collectionId ?? undefined,\n variableModeId: action.modeId ?? undefined\n }\n if (action.type === 'CONDITIONAL')\n return {\n type: 'CONDITIONAL',\n conditionalBlocks: action.blocks.map((block) => ({\n ...(block.condition ? { condition: block.condition } : {}),\n actions: block.actions.map(toFigmaAction)\n }))\n }\n if (action.type !== 'NODE') return { type: action.type }\n return {\n type: 'NODE',\n destinationId: action.nodeId ?? '',\n navigation: action.navigation,\n transition: toFigmaTransition(action.transition),\n overlayRelativePosition: action.overlayPosition\n }\n}\n\nfunction toFigmaTransition({\n type,\n duration,\n easing\n}: PrototypeTransition): v.InferOutput<typeof transitionSchema> {\n return easing ? { type, duration, easing: { type: easing } } : { type, duration }\n}\n\nfunction fromFigmaTransition({\n type,\n duration,\n easing\n}: v.InferOutput<typeof transitionSchema>): PrototypeTransition {\n return easing ? { type, duration, easing: easing.type } : { type, duration }\n}\n\n/** The validation context: where the reactions live, and what they may point at. */\nexport interface ReactionContext {\n graph: SceneGraph\n /** The layer the reactions are on, which a Change to or Scroll to destination must suit. */\n nodeId: string\n /** The page the layer is on; a navigation's 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 * An instance's main component's reactions: a reaction kept under one of their ids that an\n * edit changed, from what the layer held at its place and from the main's, becomes the\n * instance's own, with an id of its own.\n */\n inherited?: 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 const parsed: PrototypeReaction = {\n id,\n trigger: toTrigger(reaction.trigger),\n actions: reaction.actions.map((action) => toAction(action, context, index))\n }\n // One the layer already held unchanged stays as it was, a copy of the main's included, so\n // writing reactions back as read never re-ids a copy whose main was edited since.\n const held = context.previous?.[index]\n if (held && sameReaction(held, parsed)) return parsed\n return asInstanceEdit(parsed, context.inherited ?? [])\n })\n}\n\nfunction toTrigger(trigger: FigmaReactionTrigger): PrototypeReaction['trigger'] {\n const type: PrototypeTriggerType = trigger.type\n if (trigger.type === 'AFTER_TIMEOUT') return { type, delay: trigger.timeout }\n return { type, delay: 'delay' in trigger ? trigger.delay : 0 }\n}\n\nfunction parseNestedAction(nested: unknown, reactionIndex: number): FigmaReactionAction {\n if (!nested || typeof nested !== 'object' || Array.isArray(nested)) {\n throw failure(`reactions[${reactionIndex}] has a conditional action that is not an object`)\n }\n const result = v.safeParse(actionSchema, nested)\n if (!result.success) {\n const [issue] = result.issues\n const path = issuePath(issue.path)\n throw failure(\n `reactions[${reactionIndex}] has a conditional action failing validation: ${issue.message}${path ? ` at ${path}` : ''}`\n )\n }\n return result.output\n}\n\nfunction toAction(\n action: FigmaReactionAction,\n context: ReactionContext,\n reactionIndex: number\n): PrototypeAction {\n if (action.type === 'BACK') return { type: 'BACK' }\n if (action.type === 'CLOSE') return { type: 'CLOSE' }\n if (action.type === 'SET_VARIABLE')\n return {\n type: 'SET_VARIABLE',\n variableId: action.variableId ?? null,\n value: action.variableValue\n }\n if (action.type === 'SET_VARIABLE_MODE')\n return {\n type: 'SET_VARIABLE_MODE',\n collectionId: action.variableCollectionId ?? null,\n modeId: action.variableModeId ?? null\n }\n if (action.type === 'CONDITIONAL')\n return {\n type: 'CONDITIONAL',\n blocks: action.conditionalBlocks.map((block) => ({\n ...(block.condition ? { condition: block.condition } : {}),\n actions: block.actions.map((nested) =>\n // The schema keeps nested actions open to a tree, so each nested object is parsed here.\n toAction(parseNestedAction(nested, reactionIndex), context, reactionIndex)\n )\n }))\n }\n const destinationId = resolveDestinationId(action, context, reactionIndex)\n assertDestination({ ...action, destinationId }, context, reactionIndex)\n return {\n type: 'NODE',\n nodeId: destinationId,\n navigation: action.navigation,\n transition: fromFigmaTransition(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/**\n * The layer a NODE action points at: its `destinationId`, or for a Change to, the variant of the\n * layer's set whose `variantProperties` it names.\n */\nfunction resolveDestinationId(\n action: v.InferOutput<typeof nodeActionSchema>,\n context: ReactionContext,\n index: number\n): string {\n const at = `reactions[${index}]`\n const { destinationId, variantProperties, navigation } = action\n if (destinationId && variantProperties) {\n throw failure(`${at} names both destinationId and variantProperties; give one`)\n }\n if (variantProperties) {\n if (navigation !== 'CHANGE_TO') {\n throw failure(`${at}: variantProperties is for CHANGE_TO only, not ${navigation}`)\n }\n return variantByProperties(variantProperties, context, at)\n }\n if (!destinationId) {\n throw failure(\n navigation === 'CHANGE_TO'\n ? `${at} must name the variant it Changes to, in destinationId or variantProperties`\n : `${at} must name the layer it goes to, in destinationId`\n )\n }\n return destinationId\n}\n\n/** The id of the variant of the sets around the layer whose properties are `properties`. */\nfunction variantByProperties(\n properties: Record<string, string>,\n context: ReactionContext,\n at: string\n): string {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const wanted = Object.entries(properties)\n .map(([name, value]) => `${name}=${value}`)\n .join(', ')\n for (const set of sets) {\n const matches = context.graph.getChildren(set.id).filter((child) => {\n if (child.type !== 'COMPONENT') return false\n const values = { ...parseVariantName(child.name), ...child.componentPropertyValues }\n return Object.entries(properties).every(([name, value]) => values[name] === value)\n })\n if (matches.length === 1) return matches[0].id\n // A set can hold variants a partial map matches equally: refuse rather than pick one.\n if (matches.length > 1) {\n const names = matches.map((match) => `\"${match.name}\"`).join(', ')\n throw failure(\n `${at}: ${wanted} matches ${matches.length} variants of ${set.name} (${names}); name every property of the variant`\n )\n }\n }\n throw failure(`${at}: no variant of ${nearest.name} with ${wanted}`)\n}\n\nfunction failure(message: string): Error {\n return new Error(`Property \"reactions\" failed validation: ${message}`)\n}\n\n/**\n * A destination play can show: a navigation's is a frame at the top of the layer's page, a Change\n * to's a variant of a set the layer belongs to, and a Scroll to's a layer in the layer's\n * top-level frame.\n */\nfunction assertDestination(\n action: Pick<v.InferOutput<typeof nodeActionSchema>, 'navigation'> & { destinationId: string },\n context: ReactionContext,\n index: number\n): void {\n const { destinationId, navigation } = action\n const destination = context.graph.getNode(destinationId)\n const at = `reactions[${index}]`\n if (!destination) throw failure(`no layer ${destinationId} at ${at}.actions[0].destinationId`)\n if (navigation === 'CHANGE_TO') return assertVariant(destination, context, at)\n if (navigation === 'SCROLL_TO') return assertScrollTarget(destination, context, at)\n if (destination.type !== 'FRAME' || destination.parentId !== context.pageId) {\n throw failure(\n `${at} must navigate to a top-level frame on the same page, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction assertVariant(destination: SceneNode, context: ReactionContext, at: string): void {\n const sets = variantSetsAround(context.graph, context.nodeId)\n const nearest = sets.at(0)\n if (!nearest) {\n throw failure(\n `${at}: only a variant, an instance of one, or a layer inside one can Change to another variant`\n )\n }\n const inSet = sets.some((set) => set.id === destination.parentId)\n if (destination.type !== 'COMPONENT' || !inSet) {\n throw failure(\n `${at} must Change to a variant of ${nearest.name}, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\n/** The page's direct child a layer sits in, which play shows as one screen. */\nfunction topLevelOf(graph: SceneGraph, nodeId: string, pageId: string): SceneNode | undefined {\n return graph.closest(nodeId, (node) => node.parentId === pageId)\n}\n\nfunction assertScrollTarget(destination: SceneNode, context: ReactionContext, at: string): void {\n const { graph, nodeId, pageId } = context\n const top = topLevelOf(graph, nodeId, pageId)\n if (!top || destination.id === top.id || !graph.isDescendant(destination.id, top.id)) {\n throw failure(\n `${at} must Scroll to a layer inside the same top-level frame, not ${destination.type} \"${destination.name}\"`\n )\n }\n}\n\nfunction unsupportedActionReason(action: unknown): string | null {\n if (!action || typeof action !== 'object' || !('type' in action)) return null\n const { type } = action\n if (typeof type === 'string' && type in UNSUPPORTED_ACTIONS) {\n return `an action is NODE, BACK or CLOSE, not ${type}`\n }\n if (\n type === 'CONDITIONAL' &&\n 'conditionalBlocks' in action &&\n Array.isArray(action.conditionalBlocks)\n ) {\n for (const block of action.conditionalBlocks) {\n if (\n !block ||\n typeof block !== 'object' ||\n !('actions' in block) ||\n !Array.isArray(block.actions)\n )\n continue\n for (const nested of block.actions) {\n const nestedReason = unsupportedActionReason(nested)\n if (nestedReason) return nestedReason\n }\n }\n }\n return null\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, ON_HOVER, ON_PRESS, MOUSE_ENTER, MOUSE_LEAVE 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 const reason = unsupportedActionReason(action)\n if (reason) return reason\n }\n }\n return null\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,uBAA6C;CACjD,SAAS;CACT,UAAU;CACV,YAAY;CACZ,aAAa;AACf;;AAGA,MAAM,sBAA4C,EAChD,KAAK,KACP;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;;AAG1C,MAAM,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;AAE3E,MAAM,mBAAmB,EAAE,aAAa;CACtC,MAAM,EAAE,SAAS;EAAC;EAAW;EAAY;CA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QAAQ,sBACtC,OAAO,wGAAwG;EAEnH;EACA,MAAM,UAAU,SAAS;EACzB,IAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;EAC7B,KAAK,MAAM,UAAU,SAAS;GAC5B,MAAM,SAAS,wBAAwB,MAAM;GAC7C,IAAI,QAAQ,OAAO;EACrB;CACF;CACA,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
- import { newLayerDefaults } from "../editor/shapes/defaults.js";
2
1
  import { graph, prepareFollowedFieldEdit, raw, updateNode } from "./accessor-utils.js";
2
+ import { newLayerDefaults } from "../editor/shapes/defaults.js";
3
3
  import { SHAPE_WITH_TEXT_TYPES, isShapeWithTextType } from "@pairdraw/scene-graph/shape-with-text";
4
4
  import { createShapeWithText, shapeWithTextKindFields } from "@pairdraw/scene-graph/generated";
5
5
  //#region src/figma-api/shape-with-text.ts
@@ -24,6 +24,8 @@ declare function prepareSlotMove(g: SceneGraph, parentId: string, childId: strin
24
24
  * from the component, and a slot's content becomes the instance's own first.
25
25
  */
26
26
  declare function prepareSlotInsertion(g: SceneGraph, parentId: string, method: string): void;
27
+ /** Ready a clone under the node's current parent, which that parent's scope decides. */
28
+ declare function prepareNodeClone(g: SceneGraph, nodeId: string, method: string): void;
27
29
  /**
28
30
  * Ready removing a layer the way Figma's remove() does: the locked part of an instance,
29
31
  * slot frames included, refuses it, and slot content becomes the instance's own first.
@@ -32,5 +34,5 @@ declare function prepareSlotRemoval(g: SceneGraph, nodeId: string): void;
32
34
  /** `ComponentNode.createSlot` and the `SlotNode` members Figma's plugin API defines. */
33
35
  declare function installSlotAccessors(prototype: object, internals: NodeProxyInternals): void;
34
36
  //#endregion
35
- export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
37
+ export { FigmaSlotSettings, assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareNodeClone, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
36
38
  //# 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;;;;;;iBAac,qBAAqB,GAAG,YAAY,kBAAkB;;;;;iBAatD,mBAAmB,GAAG,YAAY;;iBAmBlC,qBAAqB,mBAAmB,WAAW"}
1
+ {"version":3,"file":"slots.d.ts","names":[],"sources":["../../src/figma-api/slots.ts"],"mappings":";;;;UAuBiB;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;;;;;;iBAWc,qBAAqB,GAAG,YAAY,kBAAkB;;iBAKtD,iBAAiB,GAAG,YAAY,gBAAgB;;;;;iBAShD,mBAAmB,GAAG,YAAY;;iBAmBlC,qBAAqB,mBAAmB,WAAW"}
@@ -1,5 +1,5 @@
1
1
  import { assertProxyEditable, graph, nodeId, raw } from "./accessor-utils.js";
2
- import { DEFAULT_SLOT_SETTINGS, claimSlotContent, createSlotProperty, resetSlotContent, slotLimitViolations, slotPropertyId, slotScope } from "@pairdraw/scene-graph/slots";
2
+ import { DEFAULT_SLOT_SETTINGS, assertChildPlacement, assertNodeMovable, claimSlotContent, createSlotProperty, resetSlotContent, slotLimitViolations, slotPropertyId, slotScope } from "@pairdraw/scene-graph/slots";
3
3
  import { componentPropertyDefinitions, createComponentPropertyId } from "@pairdraw/scene-graph/components";
4
4
  //#region src/figma-api/slots.ts
5
5
  /** A count after a Figma change: null clears it, undefined keeps the current one. */
@@ -38,10 +38,8 @@ 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 sourceParentId = g.getNode(childId)?.parentId;
42
- const source = sourceParentId ? slotScope(g, sourceParentId) : void 0;
41
+ assertNodeMovable(g, childId, method);
43
42
  prepareSlotInsertion(g, parentId, method);
44
- if (source?.kind === "slot") claimSlotContent(g, source);
45
43
  }
46
44
  /**
47
45
  * Ready adding new layers under `parentId`, as a tool that builds layers in place does, by the
@@ -49,9 +47,12 @@ function prepareSlotMove(g, parentId, childId, method) {
49
47
  * from the component, and a slot's content becomes the instance's own first.
50
48
  */
51
49
  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);
50
+ assertChildPlacement(g, parentId, method);
51
+ }
52
+ /** Ready a clone under the node's current parent, which that parent's scope decides. */
53
+ function prepareNodeClone(g, nodeId, method) {
54
+ const parentId = g.getNode(nodeId)?.parentId;
55
+ if (parentId) assertChildPlacement(g, parentId, method);
55
56
  }
56
57
  /**
57
58
  * Ready removing a layer the way Figma's remove() does: the locked part of an instance,
@@ -103,6 +104,6 @@ function installSlotAccessors(prototype, internals) {
103
104
  });
104
105
  }
105
106
  //#endregion
106
- export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
107
+ export { assertSlotSettings, figmaSlotSettings, installSlotAccessors, mergeSlotSettings, prepareNodeClone, prepareSlotInsertion, prepareSlotMove, prepareSlotRemoval };
107
108
 
108
109
  //# 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 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,MAAM,OAAO;EAAE,GAAG;EAAuB,GAAG;CAAQ;CACpD,MAAM,OAAqB;EACzB,sBAAsB,QAAQ,wBAAwB,KAAK;EAC3D,uBAAuB,QAAQ,yBAAyB,KAAK;EAC7D,0BAA0B,QAAQ,4BAA4B,KAAK;CACrE;CACA,MAAM,cAAc,MAAM,QAAQ,aAAa,KAAK,WAAW;CAC/D,MAAM,cAAc,MAAM,QAAQ,aAAa,KAAK,WAAW;CAC/D,IAAI,gBAAgB,KAAA,GAAW,KAAK,cAAc;CAClD,IAAI,gBAAgB,KAAA,GAAW,KAAK,cAAc;CAClD,OAAO;AACT;AAEA,SAAgB,kBA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AAW;EACjC,YAAY,EAEV,QAAuB;GACrB,MAAM,YAAY,IAAI,MAAM,SAAS;GACrC,IAAI,UAAU,SAAS,aACrB,MAAM,IAAI,MAAM,+CAA+C;GACjE,oBAAoB,MAAM,SAAS;GACnC,MAAM,IAAI,MAAM,MAAM,SAAS;GAC/B,MAAM,QAAQ,EAAE,WAAW,SAAS,UAAU,IAAI,EAAE,MAAM,OAAO,CAAC;GAClE,MAAM,aAAa,mBAAmB,GAAG,MAAM,IAAI,0BAA0B,CAAC;GAC9E,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,uBAAuB;GACxD,EAAE,WAAW,MAAM,IAAI,EAAE,MAAM,WAAW,KAAK,CAAC;GAChD,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE;EAChD,EACF;EACA,WAAW,EACT,QAAuB;GACrB,IAAI,CAAC,eAAe,IAAI,MAAM,SAAS,CAAC,GACtC,MAAM,IAAI,MAAM,yCAAyC;GAC3D,oBAAoB,MAAM,SAAS;GACnC,MAAM,QAAQ,aAAa,MAAM,SAAS;GAC1C,IAAI,OAAO,iBAAiB,MAAM,MAAM,SAAS,GAAG,KAAK;EAC3D,EACF;EACA,iBAAiB,EAGf,MAA2C;GACzC,MAAM,QAAQ,aAAa,MAAM,SAAS;GAC1C,IAAI,CAAC,OAAO,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 assertChildPlacement,\n assertNodeMovable,\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 assertNodeMovable(g, childId, method)\n prepareSlotInsertion(g, parentId, method)\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 assertChildPlacement(g, parentId, method)\n}\n\n/** Ready a clone under the node's current parent, which that parent's scope decides. */\nexport function prepareNodeClone(g: SceneGraph, nodeId: string, method: string): void {\n const parentId = g.getNode(nodeId)?.parentId\n if (parentId) assertChildPlacement(g, parentId, method)\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":";;;;;AAgCA,SAAS,MAAM,QAAmC,SAA6B;CAC7E,OAAO,WAAW,OAAO,KAAA,IAAa,UAAU;AAClD;;AAGA,SAAgB,kBACd,SACA,SACc;CACd,MAAM,OAAO;EAAE,GAAG;EAAuB,GAAG;CAAQ;CACpD,MAAM,OAAqB;EACzB,sBAAsB,QAAQ,wBAAwB,KAAK;EAC3D,uBAAuB,QAAQ,yBAAyB,KAAK;EAC7D,0BAA0B,QAAQ,4BAA4B,KAAK;CACrE;CACA,MAAM,cAAc,MAAM,QAAQ,aAAa,KAAK,WAAW;CAC/D,MAAM,cAAc,MAAM,QAAQ,aAAa,KAAK,WAAW;CAC/D,IAAI,gBAAgB,KAAA,GAAW,KAAK,cAAc;CAClD,IAAI,gBAAgB,KAAA,GAAW,KAAK,cAAc;CAClD,OAAO;AACT;AAEA,SAAgB,kBAAkB,UAA2C;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A+C;GACjE,oBAAoB,MAAM,SAAS;GACnC,MAAM,IAAI,MAAM,MAAM,SAAS;GAC/B,MAAM,QAAQ,EAAE,WAAW,SAAS,UAAU,IAAI,EAAE,MAAM,OAAO,CAAC;GAClE,MAAM,aAAa,mBAAmB,GAAG,MAAM,IAAI,0BAA0B,CAAC;GAC9E,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,uBAAuB;GACxD,EAAE,WAAW,MAAM,IAAI,EAAE,MAAM,WAAW,KAAK,CAAC;GAChD,OAAO,KAAK,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE;EAChD,EACF;EACA,WAAW,EACT,QAAuB;GACrB,IAAI,CAAC,eAAe,IAAI,MAAM,SAAS,CAAC,GACtC,MAAM,IAAI,MAAM,yCAAyC;GAC3D,oBAAoB,MAAM,SAAS;GACnC,MAAM,QAAQ,aAAa,MAAM,SAAS;GAC1C,IAAI,OAAO,iBAAiB,MAAM,MAAM,SAAS,GAAG,KAAK;EAC3D,EACF;EACA,iBAAiB,EAGf,MAA2C;GACzC,MAAM,QAAQ,aAAa,MAAM,SAAS;GAC1C,IAAI,CAAC,OAAO,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"}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { AttachModifiers } from "./editor/connectors/attach.js";
2
2
  import { DEFAULT_SNAPPING_PREFERENCES, SnappingPreferences } from "./editor/preferences.js";
3
3
  import { ShaderRasterizer } from "./editor/shaders/types.js";
4
4
  import { CanvasView, EditorProfile, EditorProfileInputs, EditorRestrictions, PresentationScale, ShaderView } from "./editor/views/types.js";
5
- import { ClipboardImageResolution, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
5
+ import { ClipboardImageResolution, ClipboardPatternSources, EditorContext, EditorEventName, EditorEvents, EditorOptions, EditorSharedState, EditorState, EditorViewState, FigmaClipboardImageResolver, GradientEdit, ImageEdit, ResumedPath, ShapeHandleHover, Tool, ViewportInsets, VisibleCanvas } from "./editor/types.js";
6
6
  import { ClipboardCollectionDependency, ClipboardConflictResolution, ClipboardImportChoice, ClipboardImportPlan, ClipboardStyleDependency, clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
7
7
  import { ClipboardSnapshot } from "./editor/clipboard/snapshot.js";
8
8
  import { ClipboardPayload, CopyOptions } from "./editor/clipboard/copy.js";
@@ -21,8 +21,9 @@ import { SelectionColor, replaceSelectionColor, selectionColors, selectionColors
21
21
  import { DOCUMENT_COLOR_LIMIT, DocumentColor, documentColors } from "./editor/document-colors.js";
22
22
  import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
23
23
  import { VariantConflict, VariantMutationResult, VariantValidationIssue } from "./editor/components/variants/model.js";
24
- import { VariableTokenFields } from "./editor/variables.js";
25
24
  import { NodePreview } from "./editor/node-preview.js";
25
+ import { opacityFromBuffer } from "./editor/nodes.js";
26
+ import { VariableTokenFields } from "./editor/variables.js";
26
27
  import { DEFAULT_SCALE_ANCHOR, SCALE_ANCHORS, ScaleAnchor, isScaleAnchor, parseScaleFactor, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds } from "./editor/scale/anchor.js";
27
28
  import { ScaleSession } from "./editor/scale/actions.js";
28
29
  import { RescaleSnapshot, rescaleNodes } from "./editor/scale/rescale.js";
@@ -47,11 +48,10 @@ import { reapplyInstanceComponentProperties } from "./editor/components/properti
47
48
  import { createGuideActions } from "./editor/guides.js";
48
49
  import { createTextActions } from "./editor/text.js";
49
50
  import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
50
- import { opacityFromBuffer } from "./editor/nodes.js";
51
51
  import { LayerType, layerTypeOptions } from "./editor/structure/layer-type.js";
52
52
  import { BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, EDITOR_TOOLS, EditorToolDef, TOOL_SHORTCUTS } from "./editor/tool-registry.js";
53
53
  import { EyedropperTarget, ScenePixels, applySampledColor, eyedropperChanges, sampleSceneColor, sampleScenePixels, scenePixelColor } from "./editor/eyedropper.js";
54
54
  import { newLayerDefaults } from "./editor/shapes/defaults.js";
55
55
  import { RenameSelectionOptions, RenameSelectionPreview } from "./editor/structure/rename.js";
56
56
  import "./editor/index.js";
57
- export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
57
+ export { type AttachModifiers, BOARD_TOOLS, BOARD_TOOL_SHORTCUTS, type CanvasView, type ClipboardCollectionDependency, type ClipboardConflictResolution, type ClipboardImageResolution, type ClipboardImportChoice, type ClipboardImportPlan, type ClipboardPatternSources, type ClipboardPayload, type ClipboardSnapshot, type ClipboardStyleDependency, type CopyOptions, DEFAULT_SCALE_ANCHOR, DEFAULT_SNAPPING_PREFERENCES, DOCUMENT_COLOR_LIMIT, type DocumentChange, type DocumentColor, EDITOR_TOOLS, EDIT_VIEW, type EditedImage, type Editor, type EditorContext, type EditorEventName, type EditorEvents, type EditorOptions, type EditorProfile, type EditorProfileInputs, type EditorRestrictions, type EditorSharedState, type EditorState, type EditorToolDef, type EditorViewState, type ExposableComponentField, type EyedropperTarget, type FigmaClipboardImageResolver, type GradientEdit, type HyperlinkHit, type ImageEdit, type ImageEditModifiers, type InstanceState, type LayerType, type MovePlace, type NodeEditCapability, type NodePreview, type PageSnapshot, type PageSwitchProgress, type PreparePageOptions, type PreparedPage, type PresentationScale, type PresentationState, ReadOnlyDocumentError, ReadOnlyLibraryDefinitionError, type RecordEditOptions, type RenameSelectionOptions, type RenameSelectionPreview, type RescaleSnapshot, type ResumedPath, SCALE_ANCHORS, type ScaleAnchor, type ScaleSession, type ScenePixels, type SelectionColor, type SelectionSpacing, type ShaderModeState, type ShaderModeTarget, type ShaderPaintList, type ShaderRasterizer, type ShaderView, type ShapeHandleHover, type SlideMoveTarget, type SnappingPreferences, type SwitchPageOptions, TOOL_SHORTCUTS, type TextHyperlinkState, type Tool, type VariableTokenFields, type VariantConflict, type VariantMutationResult, type VariantValidationIssue, type ViewportInsets, type VisibleCanvas, applyDocumentChange, applySampledColor, assertNodeEditable, clipboardImportHasConflicts, clipboardImportHasDependencies, copyEditorViewState, createDefaultEditorSharedState, createDefaultEditorState, createDefaultEditorViewState, createDocumentGraph, createEditor, createGuideActions, createTextActions, documentColors, editableImageFillIndex, editedGradient, editedGradientLayout, editedImage, editedImageLayout, executeAtomicTool, eyedropperChanges, findShaderModeTarget, getNodeEditCapability, graphFromDocumentChange, graphFromPageSnapshot, graphsFromDocumentChange, imageEditChanges, imageEditCrops, isEmptyDocumentChange, isScaleAnchor, layerTypeOptions, newLayerDefaults, opacityFromBuffer, pageSlides, parseScaleFactor, pastedPropertyChanges, pickEditorViewState, planClipboardImport, playIslandRoots, presentationViewport, reapplyInstanceComponentProperties, recordDocumentChange, replaceSelectionColor, rescaleNodes, resizedPathTextGlyphs, resolveEditorProfile, resolvePasteTarget, resolvePlayState, sampleSceneColor, sampleScenePixels, scaleAnchorFraction, scaleAnchorPoint, scaleFactorForSize, scaledBounds, scenePixelColor, selectionColors, selectionColorsShown, slideMoveTarget, syncEditedComponents, touchedTopLevelIds };
package/dist/index.js CHANGED
@@ -15,12 +15,12 @@ import { replaceSelectionColor, selectionColors, selectionColorsShown } from "./
15
15
  import { DOCUMENT_COLOR_LIMIT, documentColors } from "./editor/document-colors.js";
16
16
  import { copyEditorViewState, createDefaultEditorViewState, pickEditorViewState } from "./editor/state/view.js";
17
17
  import { applyDocumentChange, isEmptyDocumentChange, recordDocumentChange, touchedTopLevelIds } from "./editor/history/document-change.js";
18
+ import { syncEditedComponents } from "./editor/component-sync.js";
18
19
  import { resolvePasteTarget } from "./editor/clipboard/paste/target.js";
19
20
  import { clipboardImportHasConflicts, clipboardImportHasDependencies, planClipboardImport } from "./editor/clipboard/conflicts.js";
20
21
  import { reapplyInstanceComponentProperties } from "./editor/components/properties.js";
21
22
  import { newLayerDefaults } from "./editor/shapes/defaults.js";
22
23
  import { pastedPropertyChanges } from "./editor/clipboard/paste/properties.js";
23
- import { syncEditedComponents } from "./editor/component-sync.js";
24
24
  import { resizedPathTextGlyphs } from "./editor/text/path-edit.js";
25
25
  import { createGuideActions } from "./editor/guides.js";
26
26
  import { opacityFromBuffer } from "./editor/nodes.js";
@@ -0,0 +1,23 @@
1
+ //#region src/io/formats/code/detect.d.ts
2
+ /** The most source a paste reads: 200 000 characters of JSX or HTML. */
3
+ declare const MAX_CODE_LENGTH = 200000;
4
+ /** What a pasted source is written in, which decides how its layers are built. */
5
+ type PasteCodeKind = 'jsx' | 'html';
6
+ /** Detection's answer for source longer than a paste reads. */
7
+ declare const CODE_TOO_LARGE = "too-large";
8
+ /** What detection says about a text: the code it holds, or that it is past the size a paste reads. */
9
+ type CodeDetection = PasteCodeKind | typeof CODE_TOO_LARGE;
10
+ /**
11
+ * What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is
12
+ * markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it
13
+ * draws no element, so ordinary text keeps pasting as text.
14
+ */
15
+ declare function detectCode(text: string): CodeDetection | null;
16
+ /**
17
+ * The code a pasted text holds, or null when it is not code or is past the size a paste reads;
18
+ * `detectCode` says which of the two refused it.
19
+ */
20
+ declare function detectCodeText(text: string): PasteCodeKind | null;
21
+ //#endregion
22
+ export { CODE_TOO_LARGE, CodeDetection, MAX_CODE_LENGTH, PasteCodeKind, detectCode, detectCodeText };
23
+ //# sourceMappingURL=detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.d.ts","names":[],"sources":["../../../../src/io/formats/code/detect.ts"],"mappings":";;cACa;;KAGD;;cAGC;;KAGD,gBAAgB,uBAAuB;;;;;;iBAqCnC,WAAW,eAAe;;;;;iBAgB1B,eAAe,eAAe"}
@@ -0,0 +1,46 @@
1
+ //#region src/io/formats/code/detect.ts
2
+ /** The most source a paste reads: 200 000 characters of JSX or HTML. */
3
+ const MAX_CODE_LENGTH = 2e5;
4
+ /** Detection's answer for source longer than a paste reads. */
5
+ const CODE_TOO_LARGE = "too-large";
6
+ const ELEMENT = /<([A-Za-z][\w.:-]*)(?:\s[^<>]*)?\/?>/;
7
+ const CLOSING = /<\/([A-Za-z][\w.:-]*)\s*>/;
8
+ const SELF_CLOSING = /<([A-Za-z][\w.:-]*)(?:\s[^<>]*)?\/>/;
9
+ const FRAGMENT = /<>[\s\S]*<\/>/;
10
+ /** A source that names a component, an export, or an arrow body, rather than plain markup. */
11
+ const JSX_SOURCE = /\b(?:className\s*=|export\s+(?:default|function|const)\b|=>|function\s+[A-Z_a-z]\w*\s*\()/;
12
+ /** The kind of code a trimmed text draws, or null when it draws no element. */
13
+ function looksLikeCode(trimmed, tail) {
14
+ if (!ELEMENT.test(trimmed)) return null;
15
+ if (!CLOSING.test(trimmed) && !SELF_CLOSING.test(trimmed) && !FRAGMENT.test(trimmed) && !CLOSING.test(tail)) return null;
16
+ if (!trimmed.startsWith("<")) {
17
+ if (!/\breturn\b|\bimport\b|\bexport\b/.test(trimmed)) return null;
18
+ return "jsx";
19
+ }
20
+ return JSX_SOURCE.test(trimmed) ? "jsx" : "html";
21
+ }
22
+ /**
23
+ * What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is
24
+ * markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it
25
+ * draws no element, so ordinary text keeps pasting as text.
26
+ */
27
+ function detectCode(text) {
28
+ const tooLarge = text.length > MAX_CODE_LENGTH;
29
+ const trimmed = (tooLarge ? text.slice(0, MAX_CODE_LENGTH) : text).trim();
30
+ const tail = tooLarge ? text.slice(-4096) : "";
31
+ const kind = trimmed.length > 0 ? looksLikeCode(trimmed, tail) : null;
32
+ if (!kind) return null;
33
+ return tooLarge ? CODE_TOO_LARGE : kind;
34
+ }
35
+ /**
36
+ * The code a pasted text holds, or null when it is not code or is past the size a paste reads;
37
+ * `detectCode` says which of the two refused it.
38
+ */
39
+ function detectCodeText(text) {
40
+ const detection = detectCode(text);
41
+ return detection === "too-large" ? null : detection;
42
+ }
43
+ //#endregion
44
+ export { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, detectCodeText };
45
+
46
+ //# sourceMappingURL=detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect.js","names":[],"sources":["../../../../src/io/formats/code/detect.ts"],"sourcesContent":["/** The most source a paste reads: 200 000 characters of JSX or HTML. */\nexport const MAX_CODE_LENGTH = 200_000\n\n/** What a pasted source is written in, which decides how its layers are built. */\nexport type PasteCodeKind = 'jsx' | 'html'\n\n/** Detection's answer for source longer than a paste reads. */\nexport const CODE_TOO_LARGE = 'too-large'\n\n/** What detection says about a text: the code it holds, or that it is past the size a paste reads. */\nexport type CodeDetection = PasteCodeKind | typeof CODE_TOO_LARGE\n\nconst ELEMENT = /<([A-Za-z][\\w.:-]*)(?:\\s[^<>]*)?\\/?>/\nconst CLOSING = /<\\/([A-Za-z][\\w.:-]*)\\s*>/\nconst SELF_CLOSING = /<([A-Za-z][\\w.:-]*)(?:\\s[^<>]*)?\\/>/\nconst FRAGMENT = /<>[\\s\\S]*<\\/>/\n/** A source that names a component, an export, or an arrow body, rather than plain markup. */\nconst JSX_SOURCE =\n /\\b(?:className\\s*=|export\\s+(?:default|function|const)\\b|=>|function\\s+[A-Z_a-z]\\w*\\s*\\()/\n\n/** The end of a paste too long to read whole, where its closing markup still is. */\nconst STRUCTURE_TAIL = 4096\n\n/** The kind of code a trimmed text draws, or null when it draws no element. */\nfunction looksLikeCode(trimmed: string, tail: string): PasteCodeKind | null {\n if (!ELEMENT.test(trimmed)) return null\n if (\n !CLOSING.test(trimmed) &&\n !SELF_CLOSING.test(trimmed) &&\n !FRAGMENT.test(trimmed) &&\n !CLOSING.test(tail)\n ) {\n return null\n }\n if (!trimmed.startsWith('<')) {\n // Markup with code around it is a component; anything else without a return is markup.\n if (!/\\breturn\\b|\\bimport\\b|\\bexport\\b/.test(trimmed)) return null\n return 'jsx'\n }\n return JSX_SOURCE.test(trimmed) ? 'jsx' : 'html'\n}\n\n/**\n * What a pasted text is: JSX or TSX when it names components or inline props, HTML when it is\n * markup alone, `too-large` when it is either but longer than a paste reads, and nothing when it\n * draws no element, so ordinary text keeps pasting as text.\n */\nexport function detectCode(text: string): CodeDetection | null {\n // A paste past the size a paste reads is only scanned up to that size, so its length bounds work;\n // the tail still decides whether markup is closed, since the cut can land inside an element.\n const tooLarge = text.length > MAX_CODE_LENGTH\n const limited = tooLarge ? text.slice(0, MAX_CODE_LENGTH) : text\n const trimmed = limited.trim()\n const tail = tooLarge ? text.slice(-STRUCTURE_TAIL) : ''\n const kind = trimmed.length > 0 ? looksLikeCode(trimmed, tail) : null\n if (!kind) return null\n return tooLarge ? CODE_TOO_LARGE : kind\n}\n\n/**\n * The code a pasted text holds, or null when it is not code or is past the size a paste reads;\n * `detectCode` says which of the two refused it.\n */\nexport function detectCodeText(text: string): PasteCodeKind | null {\n const detection = detectCode(text)\n return detection === CODE_TOO_LARGE ? null : detection\n}\n"],"mappings":";;AACA,MAAa,kBAAkB;;AAM/B,MAAa,iBAAiB;AAK9B,MAAM,UAAU;AAChB,MAAM,UAAU;AAChB,MAAM,eAAe;AACrB,MAAM,WAAW;;AAEjB,MAAM,aACJ;;AAMF,SAAS,cAAc,SAAiB,MAAoC;CAC1E,IAAI,CAAC,QAAQ,KAAK,OAAO,GAAG,OAAO;CACnC,IACE,CAAC,QAAQ,KAAK,OAAO,KACrB,CAAC,aAAa,KAAK,OAAO,KAC1B,CAAC,SAAS,KAAK,OAAO,KACtB,CAAC,QAAQ,KAAK,IAAI,GAElB,OAAO;CAET,IAAI,CAAC,QAAQ,WAAW,GAAG,GAAG;EAE5B,IAAI,CAAC,mCAAmC,KAAK,OAAO,GAAG,OAAO;EAC9D,OAAO;CACT;CACA,OAAO,WAAW,KAAK,OAAO,IAAI,QAAQ;AAC5C;;;;;;AAOA,SAAgB,WAAW,MAAoC;CAG7D,MAAM,WAAW,KAAK,SAAS;CAE/B,MAAM,WADU,WAAW,KAAK,MAAM,GAAG,eAAe,IAAI,KAAA,CACpC,KAAK;CAC7B,MAAM,OAAO,WAAW,KAAK,MAAM,KAAe,IAAI;CACtD,MAAM,OAAO,QAAQ,SAAS,IAAI,cAAc,SAAS,IAAI,IAAI;CACjE,IAAI,CAAC,MAAM,OAAO;CAClB,OAAO,WAAW,iBAAiB;AACrC;;;;;AAMA,SAAgB,eAAe,MAAoC;CACjE,MAAM,YAAY,WAAW,IAAI;CACjC,OAAO,cAAA,cAA+B,OAAO;AAC/C"}
@@ -0,0 +1,5 @@
1
+ import { CODE_TOO_LARGE, CodeDetection, MAX_CODE_LENGTH, PasteCodeKind, detectCode, detectCodeText } from "./detect.js";
2
+ import { CodeStylesheet, codeStylesheet } from "./stylesheet.js";
3
+ import { ReadCodeOptions, ReadCodeReport, ReadCodeResult, codeLayerCount, readCodeDocument } from "./read.js";
4
+ import { TokenBindingReport, bindCodeTokens, codeLayerNodes } from "./tokens.js";
5
+ export { CODE_TOO_LARGE, type CodeDetection, type CodeStylesheet, MAX_CODE_LENGTH, type PasteCodeKind, type ReadCodeOptions, type ReadCodeReport, type ReadCodeResult, type TokenBindingReport, bindCodeTokens, codeLayerCount, codeLayerNodes, codeStylesheet, detectCode, detectCodeText, readCodeDocument };
@@ -0,0 +1,5 @@
1
+ import { CODE_TOO_LARGE, MAX_CODE_LENGTH, detectCode, detectCodeText } from "./detect.js";
2
+ import { codeStylesheet } from "./stylesheet.js";
3
+ import { codeLayerCount, readCodeDocument } from "./read.js";
4
+ import { bindCodeTokens, codeLayerNodes } from "./tokens.js";
5
+ export { CODE_TOO_LARGE, MAX_CODE_LENGTH, bindCodeTokens, codeLayerCount, codeLayerNodes, codeStylesheet, detectCode, detectCodeText, readCodeDocument };