@pairdraw/core 0.19.1 → 0.20.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 (1031) hide show
  1. package/dist/ai/providers.d.ts +6 -0
  2. package/dist/ai/providers.d.ts.map +1 -1
  3. package/dist/ai/providers.js.map +1 -1
  4. package/dist/cache/resource.d.ts +8 -1
  5. package/dist/cache/resource.d.ts.map +1 -1
  6. package/dist/cache/resource.js +18 -0
  7. package/dist/cache/resource.js.map +1 -1
  8. package/dist/canvas/effects.d.ts +6 -4
  9. package/dist/canvas/effects.d.ts.map +1 -1
  10. package/dist/canvas/effects.js +37 -34
  11. package/dist/canvas/effects.js.map +1 -1
  12. package/dist/canvas/fills.d.ts.map +1 -1
  13. package/dist/canvas/fills.js +12 -8
  14. package/dist/canvas/fills.js.map +1 -1
  15. package/dist/canvas/images/adjustments.d.ts +18 -0
  16. package/dist/canvas/images/adjustments.d.ts.map +1 -0
  17. package/dist/canvas/images/adjustments.js +184 -0
  18. package/dist/canvas/images/adjustments.js.map +1 -0
  19. package/dist/canvas/images/previews.d.ts +1 -1
  20. package/dist/canvas/images/sampling.d.ts +13 -0
  21. package/dist/canvas/images/sampling.d.ts.map +1 -0
  22. package/dist/canvas/images/sampling.js +49 -0
  23. package/dist/canvas/images/sampling.js.map +1 -0
  24. package/dist/canvas/index.d.ts +2 -2
  25. package/dist/canvas/masks.d.ts +1 -1
  26. package/dist/canvas/masks.d.ts.map +1 -1
  27. package/dist/canvas/masks.js.map +1 -1
  28. package/dist/canvas/noise/render.d.ts +15 -0
  29. package/dist/canvas/noise/render.d.ts.map +1 -0
  30. package/dist/canvas/noise/render.js +56 -0
  31. package/dist/canvas/noise/render.js.map +1 -0
  32. package/dist/canvas/noise/shader.d.ts +43 -0
  33. package/dist/canvas/noise/shader.d.ts.map +1 -0
  34. package/dist/canvas/noise/shader.js +161 -0
  35. package/dist/canvas/noise/shader.js.map +1 -0
  36. package/dist/canvas/noise/table.d.ts +13 -0
  37. package/dist/canvas/noise/table.d.ts.map +1 -0
  38. package/dist/canvas/noise/table.js +408 -0
  39. package/dist/canvas/noise/table.js.map +1 -0
  40. package/dist/canvas/noise/tile.d.ts +22 -0
  41. package/dist/canvas/noise/tile.d.ts.map +1 -0
  42. package/dist/canvas/noise/tile.js +73 -0
  43. package/dist/canvas/noise/tile.js.map +1 -0
  44. package/dist/canvas/outline-stroke.js +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  46. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  47. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  48. package/dist/canvas/overlays/index.d.ts +2 -2
  49. package/dist/canvas/overlays/index.js +2 -2
  50. package/dist/canvas/overlays/selection.d.ts +1 -2
  51. package/dist/canvas/overlays/selection.d.ts.map +1 -1
  52. package/dist/canvas/overlays/selection.js +2 -9
  53. package/dist/canvas/overlays/selection.js.map +1 -1
  54. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  55. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  56. package/dist/canvas/renderer/fonts.js +2 -0
  57. package/dist/canvas/renderer/fonts.js.map +1 -1
  58. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.js +6 -0
  60. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  61. package/dist/canvas/renderer/methods.d.ts +0 -1
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +1 -4
  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 +0 -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 +13 -2
  70. package/dist/canvas/renderer/pipeline.js.map +1 -1
  71. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  72. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  73. package/dist/canvas/renderer/play-scenes.js +40 -0
  74. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  75. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  76. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  77. package/dist/canvas/renderer/tiles/cache.js +32 -1
  78. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  79. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  80. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  81. package/dist/canvas/renderer/tiles/controller.js +18 -1
  82. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  83. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  84. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  85. package/dist/canvas/renderer/types.d.ts +18 -4
  86. package/dist/canvas/renderer/types.d.ts.map +1 -1
  87. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  88. package/dist/canvas/renderer/visual-bounds.js +1 -1
  89. package/dist/canvas/renderer.d.ts +22 -3
  90. package/dist/canvas/renderer.d.ts.map +1 -1
  91. package/dist/canvas/renderer.js +29 -1
  92. package/dist/canvas/renderer.js.map +1 -1
  93. package/dist/canvas/scene.d.ts +2 -1
  94. package/dist/canvas/scene.d.ts.map +1 -1
  95. package/dist/canvas/scene.js +41 -9
  96. package/dist/canvas/scene.js.map +1 -1
  97. package/dist/canvas/shadows/silhouette.js +1 -1
  98. package/dist/canvas/texture.d.ts +20 -0
  99. package/dist/canvas/texture.d.ts.map +1 -0
  100. package/dist/canvas/texture.js +100 -0
  101. package/dist/canvas/texture.js.map +1 -0
  102. package/dist/clipboard.js +16 -5
  103. package/dist/clipboard.js.map +1 -1
  104. package/dist/constants.d.ts +5 -1
  105. package/dist/constants.d.ts.map +1 -1
  106. package/dist/constants.js +5 -1
  107. package/dist/constants.js.map +1 -1
  108. package/dist/design-jsx/index.d.ts +2 -2
  109. package/dist/design-jsx/index.js +2 -2
  110. package/dist/design-jsx/renderer.d.ts +3 -2
  111. package/dist/design-jsx/renderer.d.ts.map +1 -1
  112. package/dist/design-jsx/renderer.js +2 -2
  113. package/dist/design-jsx/renderer.js.map +1 -1
  114. package/dist/design-memory/check.d.ts +90 -0
  115. package/dist/design-memory/check.d.ts.map +1 -0
  116. package/dist/design-memory/check.js +281 -0
  117. package/dist/design-memory/check.js.map +1 -0
  118. package/dist/design-memory/describe.d.ts +37 -0
  119. package/dist/design-memory/describe.d.ts.map +1 -0
  120. package/dist/design-memory/describe.js +52 -0
  121. package/dist/design-memory/describe.js.map +1 -0
  122. package/dist/design-memory/distil.d.ts +22 -0
  123. package/dist/design-memory/distil.d.ts.map +1 -0
  124. package/dist/design-memory/distil.js +54 -0
  125. package/dist/design-memory/distil.js.map +1 -0
  126. package/dist/design-memory/document.d.ts +12 -0
  127. package/dist/design-memory/document.d.ts.map +1 -0
  128. package/dist/design-memory/document.js +64 -0
  129. package/dist/design-memory/document.js.map +1 -0
  130. package/dist/design-memory/guard.d.ts +48 -0
  131. package/dist/design-memory/guard.d.ts.map +1 -0
  132. package/dist/design-memory/guard.js +105 -0
  133. package/dist/design-memory/guard.js.map +1 -0
  134. package/dist/design-memory/index.d.ts +9 -0
  135. package/dist/design-memory/index.js +9 -0
  136. package/dist/design-memory/refusal.d.ts +32 -0
  137. package/dist/design-memory/refusal.d.ts.map +1 -0
  138. package/dist/design-memory/refusal.js +68 -0
  139. package/dist/design-memory/refusal.js.map +1 -0
  140. package/dist/design-memory/rules.d.ts +63 -0
  141. package/dist/design-memory/rules.d.ts.map +1 -0
  142. package/dist/design-memory/rules.js +224 -0
  143. package/dist/design-memory/rules.js.map +1 -0
  144. package/dist/design-memory/values.d.ts +28 -0
  145. package/dist/design-memory/values.d.ts.map +1 -0
  146. package/dist/design-memory/values.js +160 -0
  147. package/dist/design-memory/values.js.map +1 -0
  148. package/dist/editor/alignment.js +1 -1
  149. package/dist/editor/bridges/components.d.ts +2 -0
  150. package/dist/editor/bridges/components.d.ts.map +1 -1
  151. package/dist/editor/bridges/components.js +2 -0
  152. package/dist/editor/bridges/components.js.map +1 -1
  153. package/dist/editor/bridges/undo.d.ts +1 -1
  154. package/dist/editor/clipboard/assets.js +1 -1
  155. package/dist/editor/clipboard/export.d.ts.map +1 -1
  156. package/dist/editor/clipboard/export.js +16 -2
  157. package/dist/editor/clipboard/export.js.map +1 -1
  158. package/dist/editor/clipboard/placement.d.ts +1 -1
  159. package/dist/editor/clipboard/placement.js +1 -1
  160. package/dist/editor/clipboard/snapshot.d.ts.map +1 -1
  161. package/dist/editor/clipboard/snapshot.js +12 -4
  162. package/dist/editor/clipboard/snapshot.js.map +1 -1
  163. package/dist/editor/clipboard.d.ts.map +1 -1
  164. package/dist/editor/clipboard.js +2 -7
  165. package/dist/editor/clipboard.js.map +1 -1
  166. package/dist/editor/color-space.d.ts.map +1 -1
  167. package/dist/editor/color-space.js +33 -38
  168. package/dist/editor/color-space.js.map +1 -1
  169. package/dist/editor/components/instances.d.ts +2 -0
  170. package/dist/editor/components/instances.d.ts.map +1 -1
  171. package/dist/editor/components/instances.js +22 -1
  172. package/dist/editor/components/instances.js.map +1 -1
  173. package/dist/editor/components.d.ts +2 -0
  174. package/dist/editor/components.d.ts.map +1 -1
  175. package/dist/editor/connectors/attach.js +1 -1
  176. package/dist/editor/create.d.ts +36 -8
  177. package/dist/editor/create.d.ts.map +1 -1
  178. package/dist/editor/create.js +26 -61
  179. package/dist/editor/create.js.map +1 -1
  180. package/dist/editor/design-memory.d.ts +11 -0
  181. package/dist/editor/design-memory.d.ts.map +1 -0
  182. package/dist/editor/design-memory.js +40 -0
  183. package/dist/editor/design-memory.js.map +1 -0
  184. package/dist/editor/design-tokens.d.ts +4 -0
  185. package/dist/editor/design-tokens.d.ts.map +1 -1
  186. package/dist/editor/design-tokens.js +30 -1
  187. package/dist/editor/design-tokens.js.map +1 -1
  188. package/dist/editor/document-colors.d.ts +23 -0
  189. package/dist/editor/document-colors.d.ts.map +1 -0
  190. package/dist/editor/document-colors.js +53 -0
  191. package/dist/editor/document-colors.js.map +1 -0
  192. package/dist/editor/eyedropper.d.ts +47 -0
  193. package/dist/editor/eyedropper.d.ts.map +1 -0
  194. package/dist/editor/eyedropper.js +168 -0
  195. package/dist/editor/eyedropper.js.map +1 -0
  196. package/dist/editor/fonts.d.ts +9 -0
  197. package/dist/editor/fonts.d.ts.map +1 -0
  198. package/dist/editor/fonts.js +14 -0
  199. package/dist/editor/fonts.js.map +1 -0
  200. package/dist/editor/history/atomic-tool.d.ts +9 -2
  201. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  202. package/dist/editor/history/atomic-tool.js +6 -0
  203. package/dist/editor/history/atomic-tool.js.map +1 -1
  204. package/dist/editor/history/capture.d.ts +13 -0
  205. package/dist/editor/history/capture.d.ts.map +1 -0
  206. package/dist/editor/history/capture.js +28 -0
  207. package/dist/editor/history/capture.js.map +1 -0
  208. package/dist/editor/history/document-change.d.ts.map +1 -1
  209. package/dist/editor/history/document-change.js +2 -22
  210. package/dist/editor/history/document-change.js.map +1 -1
  211. package/dist/editor/history/edit.d.ts +7 -0
  212. package/dist/editor/history/edit.d.ts.map +1 -1
  213. package/dist/editor/history/edit.js +6 -3
  214. package/dist/editor/history/edit.js.map +1 -1
  215. package/dist/editor/history/subtree.d.ts +9 -0
  216. package/dist/editor/history/subtree.d.ts.map +1 -1
  217. package/dist/editor/history/subtree.js +12 -2
  218. package/dist/editor/history/subtree.js.map +1 -1
  219. package/dist/editor/index.d.ts +4 -2
  220. package/dist/editor/index.js +4 -2
  221. package/dist/editor/nudge.js +1 -1
  222. package/dist/editor/nudge.js.map +1 -1
  223. package/dist/editor/pages.d.ts +7 -5
  224. package/dist/editor/pages.d.ts.map +1 -1
  225. package/dist/editor/pages.js +35 -25
  226. package/dist/editor/pages.js.map +1 -1
  227. package/dist/editor/play/states.d.ts +3 -1
  228. package/dist/editor/play/states.d.ts.map +1 -1
  229. package/dist/editor/play/states.js +1 -1
  230. package/dist/editor/play/states.js.map +1 -1
  231. package/dist/editor/read-only/actions.js +6 -0
  232. package/dist/editor/read-only/actions.js.map +1 -1
  233. package/dist/editor/render-requests.d.ts +18 -0
  234. package/dist/editor/render-requests.d.ts.map +1 -0
  235. package/dist/editor/render-requests.js +76 -0
  236. package/dist/editor/render-requests.js.map +1 -0
  237. package/dist/editor/scale/rescale.d.ts +1 -1
  238. package/dist/editor/selection/container.d.ts +2 -0
  239. package/dist/editor/selection/container.d.ts.map +1 -1
  240. package/dist/editor/selection/container.js +17 -1
  241. package/dist/editor/selection/container.js.map +1 -1
  242. package/dist/editor/selection/navigation.js +7 -4
  243. package/dist/editor/selection/navigation.js.map +1 -1
  244. package/dist/editor/selection/overlays.d.ts.map +1 -1
  245. package/dist/editor/selection/overlays.js +1 -1
  246. package/dist/editor/selection/overlays.js.map +1 -1
  247. package/dist/editor/selection/read.d.ts +6 -2
  248. package/dist/editor/selection.d.ts +9 -2
  249. package/dist/editor/selection.d.ts.map +1 -1
  250. package/dist/editor/shapes/with-text.d.ts.map +1 -1
  251. package/dist/editor/shapes/with-text.js +2 -5
  252. package/dist/editor/shapes/with-text.js.map +1 -1
  253. package/dist/editor/structure/auto-layout-wrap.js +1 -1
  254. package/dist/editor/structure/auto-layout-wrap.js.map +1 -1
  255. package/dist/editor/structure/boolean.d.ts +2 -3
  256. package/dist/editor/structure/boolean.d.ts.map +1 -1
  257. package/dist/editor/structure/boolean.js.map +1 -1
  258. package/dist/editor/structure/group/bounds.d.ts.map +1 -1
  259. package/dist/editor/structure/group/bounds.js +1 -3
  260. package/dist/editor/structure/group/bounds.js.map +1 -1
  261. package/dist/editor/structure/outline-stroke.js +3 -3
  262. package/dist/editor/structure/outline-stroke.js.map +1 -1
  263. package/dist/editor/structure/reorder.d.ts.map +1 -1
  264. package/dist/editor/structure/reorder.js +7 -14
  265. package/dist/editor/structure/reorder.js.map +1 -1
  266. package/dist/editor/structure/state.js +1 -1
  267. package/dist/editor/structure/state.js.map +1 -1
  268. package/dist/editor/structure.d.ts +1 -2
  269. package/dist/editor/structure.d.ts.map +1 -1
  270. package/dist/editor/structure.js +3 -3
  271. package/dist/editor/structure.js.map +1 -1
  272. package/dist/editor/tool-registry.d.ts.map +1 -1
  273. package/dist/editor/tool-registry.js +2 -1
  274. package/dist/editor/tool-registry.js.map +1 -1
  275. package/dist/editor/types.d.ts +9 -2
  276. package/dist/editor/types.d.ts.map +1 -1
  277. package/dist/editor/variables.d.ts.map +1 -1
  278. package/dist/editor/variables.js +57 -1
  279. package/dist/editor/variables.js.map +1 -1
  280. package/dist/editor/variations/create.d.ts +28 -0
  281. package/dist/editor/variations/create.d.ts.map +1 -0
  282. package/dist/editor/variations/create.js +176 -0
  283. package/dist/editor/variations/create.js.map +1 -0
  284. package/dist/editor/variations/pick.d.ts +16 -0
  285. package/dist/editor/variations/pick.d.ts.map +1 -0
  286. package/dist/editor/variations/pick.js +23 -0
  287. package/dist/editor/variations/pick.js.map +1 -0
  288. package/dist/editor/variations.d.ts +28 -0
  289. package/dist/editor/variations.d.ts.map +1 -0
  290. package/dist/editor/variations.js +88 -0
  291. package/dist/editor/variations.js.map +1 -0
  292. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  293. package/dist/figma-api/accessors/reactions.js +4 -1
  294. package/dist/figma-api/accessors/reactions.js.map +1 -1
  295. package/dist/figma-api/accessors/text/index.d.ts.map +1 -1
  296. package/dist/figma-api/accessors/text/index.js +7 -1
  297. package/dist/figma-api/accessors/text/index.js.map +1 -1
  298. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  299. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  300. package/dist/figma-api/accessors/text/opentype.js +28 -0
  301. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  302. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  303. package/dist/figma-api/accessors/visual.js +33 -0
  304. package/dist/figma-api/accessors/visual.js.map +1 -1
  305. package/dist/figma-api/effects.d.ts +79 -3
  306. package/dist/figma-api/effects.d.ts.map +1 -1
  307. package/dist/figma-api/effects.js +150 -9
  308. package/dist/figma-api/effects.js.map +1 -1
  309. package/dist/figma-api/fonts/loaded.d.ts +3 -1
  310. package/dist/figma-api/fonts/loaded.d.ts.map +1 -1
  311. package/dist/figma-api/fonts/loaded.js +8 -1
  312. package/dist/figma-api/fonts/loaded.js.map +1 -1
  313. package/dist/figma-api/index.d.ts +18 -0
  314. package/dist/figma-api/index.d.ts.map +1 -1
  315. package/dist/figma-api/index.js +19 -1
  316. package/dist/figma-api/index.js.map +1 -1
  317. package/dist/figma-api/overrides.d.ts +13 -1
  318. package/dist/figma-api/overrides.d.ts.map +1 -1
  319. package/dist/figma-api/overrides.js +196 -4
  320. package/dist/figma-api/overrides.js.map +1 -1
  321. package/dist/figma-api/paints.d.ts +3 -3
  322. package/dist/figma-api/paints.d.ts.map +1 -1
  323. package/dist/figma-api/paints.js +14 -4
  324. package/dist/figma-api/paints.js.map +1 -1
  325. package/dist/figma-api/proxy.d.ts +4 -1
  326. package/dist/figma-api/proxy.d.ts.map +1 -1
  327. package/dist/figma-api/proxy.js +1 -1
  328. package/dist/figma-api/proxy.js.map +1 -1
  329. package/dist/figma-api/reactions.d.ts +41 -13
  330. package/dist/figma-api/reactions.d.ts.map +1 -1
  331. package/dist/figma-api/reactions.js +113 -31
  332. package/dist/figma-api/reactions.js.map +1 -1
  333. package/dist/figma-api/render-bounds.js +1 -1
  334. package/dist/figma-api/serialization.d.ts.map +1 -1
  335. package/dist/figma-api/serialization.js +2 -1
  336. package/dist/figma-api/serialization.js.map +1 -1
  337. package/dist/figma-api/shape-details.d.ts +26 -0
  338. package/dist/figma-api/shape-details.d.ts.map +1 -0
  339. package/dist/figma-api/shape-details.js +28 -0
  340. package/dist/figma-api/shape-details.js.map +1 -0
  341. package/dist/figma-api/shape-with-text.js +2 -5
  342. package/dist/figma-api/shape-with-text.js.map +1 -1
  343. package/dist/figma-api/surface.d.ts +7 -4
  344. package/dist/figma-api/surface.d.ts.map +1 -1
  345. package/dist/figma-api/surface.js +7 -2
  346. package/dist/figma-api/surface.js.map +1 -1
  347. package/dist/figma-api/transform.d.ts +1 -1
  348. package/dist/geometry/figma.d.ts +1 -1
  349. package/dist/geometry/image-crop.d.ts +1 -1
  350. package/dist/geometry/image-crop.js +1 -1
  351. package/dist/icons/svg.js +1 -1
  352. package/dist/icons/svg.js.map +1 -1
  353. package/dist/index.d.ts +4 -2
  354. package/dist/index.js +4 -2
  355. package/dist/io/formats/boolean-path.d.ts +19 -0
  356. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  357. package/dist/io/formats/boolean-path.js +47 -0
  358. package/dist/io/formats/boolean-path.js.map +1 -0
  359. package/dist/io/formats/design-tokens/decode.js +1 -1
  360. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  361. package/dist/io/formats/design-tokens/index.js +4 -1
  362. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  363. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  364. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  365. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  366. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  367. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  368. package/dist/io/formats/design-tokens/project.js +29 -8
  369. package/dist/io/formats/design-tokens/project.js.map +1 -1
  370. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  371. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  372. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  373. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  374. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  375. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  376. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  377. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  378. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  379. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  380. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  381. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  382. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  383. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  384. package/dist/io/formats/drawio/edges.d.ts +7 -1
  385. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  386. package/dist/io/formats/drawio/edges.js +54 -1
  387. package/dist/io/formats/drawio/edges.js.map +1 -1
  388. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  389. package/dist/io/formats/drawio/export.js +19 -2
  390. package/dist/io/formats/drawio/export.js.map +1 -1
  391. package/dist/io/formats/drawio/index.d.ts.map +1 -1
  392. package/dist/io/formats/drawio/index.js +2 -1
  393. package/dist/io/formats/drawio/index.js.map +1 -1
  394. package/dist/io/formats/drawio/label.js +1 -1
  395. package/dist/io/formats/drawio/paint.js +1 -1
  396. package/dist/io/formats/drawio/placement.d.ts +1 -1
  397. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  398. package/dist/io/formats/fig/export/patch/index.js +5 -0
  399. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  400. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  401. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  402. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  403. package/dist/io/formats/html/import.d.ts.map +1 -1
  404. package/dist/io/formats/html/import.js +3 -1
  405. package/dist/io/formats/html/import.js.map +1 -1
  406. package/dist/io/formats/html/index.d.ts +2 -2
  407. package/dist/io/formats/html/index.d.ts.map +1 -1
  408. package/dist/io/formats/html/index.js +6 -4
  409. package/dist/io/formats/html/index.js.map +1 -1
  410. package/dist/io/formats/html/layers.d.ts +7 -4
  411. package/dist/io/formats/html/layers.d.ts.map +1 -1
  412. package/dist/io/formats/html/layers.js +4 -1
  413. package/dist/io/formats/html/layers.js.map +1 -1
  414. package/dist/io/formats/html/vectors.d.ts +2 -1
  415. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  416. package/dist/io/formats/html/vectors.js +3 -2
  417. package/dist/io/formats/html/vectors.js.map +1 -1
  418. package/dist/io/formats/mermaid/styles.js +1 -1
  419. package/dist/io/formats/pdf/document.d.ts +3 -1
  420. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  421. package/dist/io/formats/pdf/document.js +6 -3
  422. package/dist/io/formats/pdf/document.js.map +1 -1
  423. package/dist/io/formats/pdf/dom.d.ts +6 -1
  424. package/dist/io/formats/pdf/dom.d.ts.map +1 -1
  425. package/dist/io/formats/pdf/dom.js +9 -22
  426. package/dist/io/formats/pdf/dom.js.map +1 -1
  427. package/dist/io/formats/pdf/export.js +1 -1
  428. package/dist/io/formats/pdf/export.js.map +1 -1
  429. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  430. package/dist/io/formats/pen/imports.d.ts +4 -1
  431. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  432. package/dist/io/formats/pen/imports.js.map +1 -1
  433. package/dist/io/formats/pen/index.d.ts.map +1 -1
  434. package/dist/io/formats/pen/index.js +31 -3
  435. package/dist/io/formats/pen/index.js.map +1 -1
  436. package/dist/io/formats/pptx/export.js +1 -1
  437. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  438. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  439. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  440. package/dist/io/formats/raster/adjusted-images.js +118 -0
  441. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  442. package/dist/io/formats/raster/headless.d.ts +11 -1
  443. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  444. package/dist/io/formats/raster/headless.js +4 -4
  445. package/dist/io/formats/raster/headless.js.map +1 -1
  446. package/dist/io/formats/raster/index.d.ts +2 -2
  447. package/dist/io/formats/raster/pixels.d.ts +7 -1
  448. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  449. package/dist/io/formats/raster/pixels.js.map +1 -1
  450. package/dist/io/formats/raster/render.d.ts.map +1 -1
  451. package/dist/io/formats/raster/render.js +4 -0
  452. package/dist/io/formats/raster/render.js.map +1 -1
  453. package/dist/io/formats/svg/defs.d.ts +5 -6
  454. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  455. package/dist/io/formats/svg/defs.js +4 -54
  456. package/dist/io/formats/svg/defs.js.map +1 -1
  457. package/dist/io/formats/svg/effects.d.ts +16 -0
  458. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  459. package/dist/io/formats/svg/effects.js +126 -0
  460. package/dist/io/formats/svg/effects.js.map +1 -0
  461. package/dist/io/formats/svg/export.d.ts +7 -1
  462. package/dist/io/formats/svg/export.d.ts.map +1 -1
  463. package/dist/io/formats/svg/export.js +224 -50
  464. package/dist/io/formats/svg/export.js.map +1 -1
  465. package/dist/io/formats/svg/filter.d.ts +27 -0
  466. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  467. package/dist/io/formats/svg/filter.js +44 -0
  468. package/dist/io/formats/svg/filter.js.map +1 -0
  469. package/dist/io/formats/svg/grain.d.ts +26 -0
  470. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  471. package/dist/io/formats/svg/grain.js +298 -0
  472. package/dist/io/formats/svg/grain.js.map +1 -0
  473. package/dist/io/formats/svg/strokes.d.ts +1 -1
  474. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  475. package/dist/io/formats/svg/strokes.js +1 -2
  476. package/dist/io/formats/svg/strokes.js.map +1 -1
  477. package/dist/io/formats/svg/text/import.js +1 -1
  478. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  479. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  480. package/dist/io/formats/svg/text/layout.js +6 -3
  481. package/dist/io/formats/svg/text/layout.js.map +1 -1
  482. package/dist/io/formats/video/composite.d.ts +18 -0
  483. package/dist/io/formats/video/composite.d.ts.map +1 -0
  484. package/dist/io/formats/video/composite.js +79 -0
  485. package/dist/io/formats/video/composite.js.map +1 -0
  486. package/dist/io/formats/video/formats.d.ts +29 -0
  487. package/dist/io/formats/video/formats.d.ts.map +1 -0
  488. package/dist/io/formats/video/formats.js +43 -0
  489. package/dist/io/formats/video/formats.js.map +1 -0
  490. package/dist/io/formats/video/gif.d.ts +13 -0
  491. package/dist/io/formats/video/gif.d.ts.map +1 -0
  492. package/dist/io/formats/video/gif.js +56 -0
  493. package/dist/io/formats/video/gif.js.map +1 -0
  494. package/dist/io/formats/video/index.d.ts +9 -0
  495. package/dist/io/formats/video/index.js +9 -0
  496. package/dist/io/formats/video/plan.d.ts +64 -0
  497. package/dist/io/formats/video/plan.d.ts.map +1 -0
  498. package/dist/io/formats/video/plan.js +90 -0
  499. package/dist/io/formats/video/plan.js.map +1 -0
  500. package/dist/io/formats/video/record.d.ts +36 -0
  501. package/dist/io/formats/video/record.d.ts.map +1 -0
  502. package/dist/io/formats/video/record.js +154 -0
  503. package/dist/io/formats/video/record.js.map +1 -0
  504. package/dist/io/formats/video/sink.d.ts +29 -0
  505. package/dist/io/formats/video/sink.d.ts.map +1 -0
  506. package/dist/io/formats/video/sink.js +16 -0
  507. package/dist/io/formats/video/sink.js.map +1 -0
  508. package/dist/io/formats/video/size.d.ts +19 -0
  509. package/dist/io/formats/video/size.d.ts.map +1 -0
  510. package/dist/io/formats/video/size.js +26 -0
  511. package/dist/io/formats/video/size.js.map +1 -0
  512. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  513. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  514. package/dist/io/formats/video/webcodecs.js +74 -0
  515. package/dist/io/formats/video/webcodecs.js.map +1 -0
  516. package/dist/io/formats.d.ts.map +1 -1
  517. package/dist/io/formats.js +40 -11
  518. package/dist/io/formats.js.map +1 -1
  519. package/dist/io/types.d.ts +19 -4
  520. package/dist/io/types.d.ts.map +1 -1
  521. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  522. package/dist/layout/apply.d.ts.map +1 -1
  523. package/dist/layout/apply.js +50 -12
  524. package/dist/layout/apply.js.map +1 -1
  525. package/dist/layout/auto-layout-handles.d.ts +66 -0
  526. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  527. package/dist/layout/auto-layout-handles.js +291 -0
  528. package/dist/layout/auto-layout-handles.js.map +1 -0
  529. package/dist/layout/derived.d.ts +7 -1
  530. package/dist/layout/derived.d.ts.map +1 -1
  531. package/dist/layout/derived.js +11 -1
  532. package/dist/layout/derived.js.map +1 -1
  533. package/dist/layout/grid.d.ts +7 -2
  534. package/dist/layout/grid.d.ts.map +1 -1
  535. package/dist/layout/grid.js +27 -9
  536. package/dist/layout/grid.js.map +1 -1
  537. package/dist/layout/mutations.d.ts +1 -0
  538. package/dist/layout/mutations.d.ts.map +1 -1
  539. package/dist/layout/mutations.js +10 -0
  540. package/dist/layout/mutations.js.map +1 -1
  541. package/dist/layout/strokes.d.ts +9 -1
  542. package/dist/layout/strokes.d.ts.map +1 -1
  543. package/dist/layout/strokes.js +12 -1
  544. package/dist/layout/strokes.js.map +1 -1
  545. package/dist/layout/yoga-helpers.d.ts +3 -1
  546. package/dist/layout/yoga-helpers.d.ts.map +1 -1
  547. package/dist/layout/yoga-helpers.js +16 -2
  548. package/dist/layout/yoga-helpers.js.map +1 -1
  549. package/dist/layout.d.ts +3 -2
  550. package/dist/layout.d.ts.map +1 -1
  551. package/dist/layout.js +73 -39
  552. package/dist/layout.js.map +1 -1
  553. package/dist/lint/fixes.d.ts.map +1 -1
  554. package/dist/lint/fixes.js +9 -3
  555. package/dist/lint/fixes.js.map +1 -1
  556. package/dist/lint/index.d.ts +3 -2
  557. package/dist/lint/index.js +2 -1
  558. package/dist/lint/linter.d.ts +13 -0
  559. package/dist/lint/linter.d.ts.map +1 -1
  560. package/dist/lint/linter.js +123 -9
  561. package/dist/lint/linter.js.map +1 -1
  562. package/dist/lint/presets.d.ts.map +1 -1
  563. package/dist/lint/presets.js +2 -0
  564. package/dist/lint/presets.js.map +1 -1
  565. package/dist/lint/rules/design-memory.d.ts +15 -0
  566. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  567. package/dist/lint/rules/design-memory.js +90 -0
  568. package/dist/lint/rules/design-memory.js.map +1 -0
  569. package/dist/lint/rules/effect-style-required.js +1 -0
  570. package/dist/lint/rules/effect-style-required.js.map +1 -1
  571. package/dist/lint/rules/index.d.ts +6 -5
  572. package/dist/lint/rules/index.d.ts.map +1 -1
  573. package/dist/lint/rules/index.js +6 -2
  574. package/dist/lint/rules/index.js.map +1 -1
  575. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  576. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  577. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  578. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  579. package/dist/lint/rules/text-style-required.js +1 -0
  580. package/dist/lint/rules/text-style-required.js.map +1 -1
  581. package/dist/lint/types.d.ts +32 -2
  582. package/dist/lint/types.d.ts.map +1 -1
  583. package/dist/node/video.d.ts +12 -0
  584. package/dist/node/video.d.ts.map +1 -0
  585. package/dist/node/video.js +206 -0
  586. package/dist/node/video.js.map +1 -0
  587. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  588. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  589. package/dist/pairdraw-api/design-memory.js +39 -0
  590. package/dist/pairdraw-api/design-memory.js.map +1 -0
  591. package/dist/pairdraw-api/index.d.ts +45 -1
  592. package/dist/pairdraw-api/index.d.ts.map +1 -1
  593. package/dist/pairdraw-api/index.js +55 -2
  594. package/dist/pairdraw-api/index.js.map +1 -1
  595. package/dist/pairdraw-api/nodes.d.ts +12 -1
  596. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  597. package/dist/pairdraw-api/nodes.js +28 -1
  598. package/dist/pairdraw-api/nodes.js.map +1 -1
  599. package/dist/pairdraw-api/variations.d.ts +48 -0
  600. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  601. package/dist/pairdraw-api/variations.js +76 -0
  602. package/dist/pairdraw-api/variations.js.map +1 -0
  603. package/dist/prototype/easing.d.ts +13 -0
  604. package/dist/prototype/easing.d.ts.map +1 -0
  605. package/dist/prototype/easing.js +36 -0
  606. package/dist/prototype/easing.js.map +1 -0
  607. package/dist/prototype/frames.d.ts +10 -0
  608. package/dist/prototype/frames.d.ts.map +1 -0
  609. package/dist/prototype/frames.js +12 -0
  610. package/dist/prototype/frames.js.map +1 -0
  611. package/dist/prototype/hit.d.ts +17 -0
  612. package/dist/prototype/hit.d.ts.map +1 -0
  613. package/dist/prototype/hit.js +45 -0
  614. package/dist/prototype/hit.js.map +1 -0
  615. package/dist/prototype/index.d.ts +14 -0
  616. package/dist/prototype/index.js +14 -0
  617. package/dist/prototype/pointer.d.ts +63 -0
  618. package/dist/prototype/pointer.d.ts.map +1 -0
  619. package/dist/prototype/pointer.js +104 -0
  620. package/dist/prototype/pointer.js.map +1 -0
  621. package/dist/prototype/reactions.d.ts +45 -0
  622. package/dist/prototype/reactions.d.ts.map +1 -0
  623. package/dist/prototype/reactions.js +122 -0
  624. package/dist/prototype/reactions.js.map +1 -0
  625. package/dist/prototype/scene.d.ts +35 -0
  626. package/dist/prototype/scene.d.ts.map +1 -0
  627. package/dist/prototype/scene.js +86 -0
  628. package/dist/prototype/scene.js.map +1 -0
  629. package/dist/prototype/scenes.d.ts +81 -0
  630. package/dist/prototype/scenes.d.ts.map +1 -0
  631. package/dist/prototype/scenes.js +175 -0
  632. package/dist/prototype/scenes.js.map +1 -0
  633. package/dist/prototype/scroll.d.ts +48 -0
  634. package/dist/prototype/scroll.d.ts.map +1 -0
  635. package/dist/prototype/scroll.js +159 -0
  636. package/dist/prototype/scroll.js.map +1 -0
  637. package/dist/prototype/session.d.ts +71 -0
  638. package/dist/prototype/session.d.ts.map +1 -0
  639. package/dist/prototype/session.js +135 -0
  640. package/dist/prototype/session.js.map +1 -0
  641. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  642. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  643. package/dist/prototype/smart-animate/animation.js +212 -0
  644. package/dist/prototype/smart-animate/animation.js.map +1 -0
  645. package/dist/prototype/smart-animate/match.d.ts +24 -0
  646. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  647. package/dist/prototype/smart-animate/match.js +72 -0
  648. package/dist/prototype/smart-animate/match.js.map +1 -0
  649. package/dist/prototype/snapshot.d.ts +19 -0
  650. package/dist/prototype/snapshot.d.ts.map +1 -0
  651. package/dist/prototype/snapshot.js +56 -0
  652. package/dist/prototype/snapshot.js.map +1 -0
  653. package/dist/prototype/timeline.d.ts +132 -0
  654. package/dist/prototype/timeline.d.ts.map +1 -0
  655. package/dist/prototype/timeline.js +260 -0
  656. package/dist/prototype/timeline.js.map +1 -0
  657. package/dist/rpc/commands.d.ts +2 -2
  658. package/dist/rpc/index.d.ts +2 -2
  659. package/dist/rpc/read-commands.d.ts +18 -8
  660. package/dist/rpc/read-commands.d.ts.map +1 -1
  661. package/dist/rpc/read-commands.js +18 -9
  662. package/dist/rpc/read-commands.js.map +1 -1
  663. package/dist/text/font/faces.d.ts +12 -1
  664. package/dist/text/font/faces.d.ts.map +1 -1
  665. package/dist/text/font/faces.js +15 -1
  666. package/dist/text/font/faces.js.map +1 -1
  667. package/dist/text/font/features.d.ts +9 -0
  668. package/dist/text/font/features.d.ts.map +1 -0
  669. package/dist/text/font/features.js +27 -0
  670. package/dist/text/font/features.js.map +1 -0
  671. package/dist/text/font/manager.d.ts +12 -0
  672. package/dist/text/font/manager.d.ts.map +1 -1
  673. package/dist/text/font/manager.js +66 -12
  674. package/dist/text/font/manager.js.map +1 -1
  675. package/dist/text/index.d.ts +11 -9
  676. package/dist/text/index.js +4 -2
  677. package/dist/text/replace-fonts.d.ts +41 -0
  678. package/dist/text/replace-fonts.d.ts.map +1 -0
  679. package/dist/text/replace-fonts.js +121 -0
  680. package/dist/text/replace-fonts.js.map +1 -0
  681. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  682. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  683. package/dist/tools/analyze/responsive/index.js +203 -0
  684. package/dist/tools/analyze/responsive/index.js.map +1 -0
  685. package/dist/tools/analyze.d.ts +2 -1
  686. package/dist/tools/analyze.js +2 -1
  687. package/dist/tools/codegen/token-sync.d.ts +7 -0
  688. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  689. package/dist/tools/codegen/token-sync.js +85 -0
  690. package/dist/tools/codegen/token-sync.js.map +1 -0
  691. package/dist/tools/codegen/tokens.d.ts +1 -1
  692. package/dist/tools/codegen.d.ts +2 -1
  693. package/dist/tools/codegen.js +2 -1
  694. package/dist/tools/create/basic.js +1 -1
  695. package/dist/tools/create/behaviours.js +1 -1
  696. package/dist/tools/create/components.d.ts.map +1 -1
  697. package/dist/tools/create/components.js +4 -0
  698. package/dist/tools/create/components.js.map +1 -1
  699. package/dist/tools/create/html.js +3 -2
  700. package/dist/tools/create/html.js.map +1 -1
  701. package/dist/tools/create/icons.d.ts.map +1 -1
  702. package/dist/tools/create/icons.js +2 -1
  703. package/dist/tools/create/icons.js.map +1 -1
  704. package/dist/tools/create/mermaid.js +2 -1
  705. package/dist/tools/create/mermaid.js.map +1 -1
  706. package/dist/tools/create/render.js +1 -1
  707. package/dist/tools/create/svg.js +2 -1
  708. package/dist/tools/create/svg.js.map +1 -1
  709. package/dist/tools/create/vector.js +1 -1
  710. package/dist/tools/design-memory.d.ts +8 -0
  711. package/dist/tools/design-memory.d.ts.map +1 -0
  712. package/dist/tools/design-memory.js +68 -0
  713. package/dist/tools/design-memory.js.map +1 -0
  714. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  715. package/dist/tools/image-ai/generate.js +3 -1
  716. package/dist/tools/image-ai/generate.js.map +1 -1
  717. package/dist/tools/index.d.ts +2 -1
  718. package/dist/tools/index.js +2 -1
  719. package/dist/tools/modify/fonts.d.ts +6 -0
  720. package/dist/tools/modify/fonts.d.ts.map +1 -0
  721. package/dist/tools/modify/fonts.js +27 -0
  722. package/dist/tools/modify/fonts.js.map +1 -0
  723. package/dist/tools/modify/layout.d.ts.map +1 -1
  724. package/dist/tools/modify/layout.js +1 -0
  725. package/dist/tools/modify/layout.js.map +1 -1
  726. package/dist/tools/modify/paint.js +1 -1
  727. package/dist/tools/modify/reactions.d.ts.map +1 -1
  728. package/dist/tools/modify/reactions.js +3 -3
  729. package/dist/tools/modify/reactions.js.map +1 -1
  730. package/dist/tools/modify/text.d.ts.map +1 -1
  731. package/dist/tools/modify/text.js +26 -5
  732. package/dist/tools/modify/text.js.map +1 -1
  733. package/dist/tools/modify/update.d.ts +10 -1
  734. package/dist/tools/modify/update.d.ts.map +1 -1
  735. package/dist/tools/modify/update.js +34 -3
  736. package/dist/tools/modify/update.js.map +1 -1
  737. package/dist/tools/modify.d.ts +2 -1
  738. package/dist/tools/modify.js +2 -1
  739. package/dist/tools/read/fonts.d.ts.map +1 -1
  740. package/dist/tools/read/fonts.js +17 -2
  741. package/dist/tools/read/fonts.js.map +1 -1
  742. package/dist/tools/read/libraries.js +2 -1
  743. package/dist/tools/read/libraries.js.map +1 -1
  744. package/dist/tools/read/nodes.d.ts.map +1 -1
  745. package/dist/tools/read/nodes.js.map +1 -1
  746. package/dist/tools/read/space.d.ts +3 -1
  747. package/dist/tools/read/space.d.ts.map +1 -1
  748. package/dist/tools/read/space.js +4 -3
  749. package/dist/tools/read/space.js.map +1 -1
  750. package/dist/tools/registry/core.d.ts +1 -1
  751. package/dist/tools/registry/core.d.ts.map +1 -1
  752. package/dist/tools/registry/core.js +3 -1
  753. package/dist/tools/registry/core.js.map +1 -1
  754. package/dist/tools/registry/extended.d.ts.map +1 -1
  755. package/dist/tools/registry/extended.js +16 -1
  756. package/dist/tools/registry/extended.js.map +1 -1
  757. package/dist/tools/schema.d.ts +18 -2
  758. package/dist/tools/schema.d.ts.map +1 -1
  759. package/dist/tools/schema.js +1 -1
  760. package/dist/tools/schema.js.map +1 -1
  761. package/dist/tools/stock-photo.js +1 -0
  762. package/dist/tools/stock-photo.js.map +1 -1
  763. package/dist/tools/structure/basic.d.ts.map +1 -1
  764. package/dist/tools/structure/basic.js +1 -0
  765. package/dist/tools/structure/basic.js.map +1 -1
  766. package/dist/tools/structure/batch.d.ts.map +1 -1
  767. package/dist/tools/structure/batch.js +22 -1
  768. package/dist/tools/structure/batch.js.map +1 -1
  769. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  770. package/dist/tools/structure/hierarchy.js +4 -0
  771. package/dist/tools/structure/hierarchy.js.map +1 -1
  772. package/dist/tools/structure/variations.d.ts +8 -0
  773. package/dist/tools/structure/variations.d.ts.map +1 -0
  774. package/dist/tools/structure/variations.js +106 -0
  775. package/dist/tools/structure/variations.js.map +1 -0
  776. package/dist/tools/structure.d.ts +2 -1
  777. package/dist/tools/structure.js +2 -1
  778. package/dist/tools/styles/types.d.ts +2 -4
  779. package/dist/tools/styles/types.d.ts.map +1 -1
  780. package/dist/tools/styles/types.js.map +1 -1
  781. package/dist/tools/vector/boolean.d.ts.map +1 -1
  782. package/dist/tools/vector/boolean.js +4 -0
  783. package/dist/tools/vector/boolean.js.map +1 -1
  784. package/dist/tools/vector/path.d.ts.map +1 -1
  785. package/dist/tools/vector/path.js +39 -7
  786. package/dist/tools/vector/path.js.map +1 -1
  787. package/dist/tools/vector/vectorize.js +1 -0
  788. package/dist/tools/vector/vectorize.js.map +1 -1
  789. package/dist/tools/vector/video.d.ts +6 -0
  790. package/dist/tools/vector/video.d.ts.map +1 -0
  791. package/dist/tools/vector/video.js +133 -0
  792. package/dist/tools/vector/video.js.map +1 -0
  793. package/dist/tools/vector.d.ts +2 -1
  794. package/dist/tools/vector.js +2 -1
  795. package/dist/tools/video-host.d.ts +12 -0
  796. package/dist/tools/video-host.d.ts.map +1 -0
  797. package/dist/tools/video-host.js +19 -0
  798. package/dist/tools/video-host.js.map +1 -0
  799. package/dist/vector/point-transform.d.ts +1 -1
  800. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  801. package/dist/xpath.d.ts +3 -0
  802. package/dist/xpath.d.ts.map +1 -1
  803. package/dist/xpath.js +3 -1
  804. package/dist/xpath.js.map +1 -1
  805. package/package.json +31 -9
  806. package/src/ai/providers.ts +2 -0
  807. package/src/cache/resource.ts +24 -1
  808. package/src/canvas/effects.ts +47 -50
  809. package/src/canvas/fills.ts +19 -15
  810. package/src/canvas/images/adjustments.ts +203 -0
  811. package/src/canvas/images/sampling.ts +88 -0
  812. package/src/canvas/index.ts +1 -0
  813. package/src/canvas/masks.ts +1 -1
  814. package/src/canvas/noise/render.ts +75 -0
  815. package/src/canvas/noise/shader.ts +161 -0
  816. package/src/canvas/noise/table.ts +91 -0
  817. package/src/canvas/noise/tile.ts +94 -0
  818. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  819. package/src/canvas/overlays/index.ts +0 -1
  820. package/src/canvas/overlays/selection.ts +1 -12
  821. package/src/canvas/renderer/fonts.ts +2 -0
  822. package/src/canvas/renderer/lifecycle.ts +6 -0
  823. package/src/canvas/renderer/methods.ts +0 -9
  824. package/src/canvas/renderer/overlay-pass.ts +0 -1
  825. package/src/canvas/renderer/pipeline.ts +19 -2
  826. package/src/canvas/renderer/play-scenes.ts +51 -0
  827. package/src/canvas/renderer/tiles/cache.ts +54 -1
  828. package/src/canvas/renderer/tiles/controller.ts +30 -1
  829. package/src/canvas/renderer/types.ts +18 -3
  830. package/src/canvas/renderer.ts +40 -4
  831. package/src/canvas/scene.ts +65 -9
  832. package/src/canvas/texture.ts +136 -0
  833. package/src/clipboard.ts +23 -10
  834. package/src/constants.ts +6 -0
  835. package/src/design-jsx/index.ts +1 -1
  836. package/src/design-jsx/renderer.ts +1 -1
  837. package/src/design-memory/check.ts +376 -0
  838. package/src/design-memory/describe.ts +77 -0
  839. package/src/design-memory/distil.ts +69 -0
  840. package/src/design-memory/document.ts +80 -0
  841. package/src/design-memory/guard.ts +157 -0
  842. package/src/design-memory/index.ts +8 -0
  843. package/src/design-memory/refusal.ts +90 -0
  844. package/src/design-memory/rules.ts +274 -0
  845. package/src/design-memory/values.ts +179 -0
  846. package/src/editor/bridges/components.ts +2 -0
  847. package/src/editor/clipboard/export.ts +24 -7
  848. package/src/editor/clipboard/snapshot.ts +21 -4
  849. package/src/editor/clipboard.ts +4 -14
  850. package/src/editor/color-space.ts +47 -38
  851. package/src/editor/components/instances.ts +31 -0
  852. package/src/editor/create.ts +39 -71
  853. package/src/editor/design-memory.ts +39 -0
  854. package/src/editor/design-tokens.ts +41 -2
  855. package/src/editor/document-colors.ts +65 -0
  856. package/src/editor/eyedropper.ts +198 -0
  857. package/src/editor/fonts.ts +19 -0
  858. package/src/editor/history/atomic-tool.ts +29 -1
  859. package/src/editor/history/capture.ts +19 -0
  860. package/src/editor/history/document-change.ts +5 -17
  861. package/src/editor/history/edit.ts +16 -2
  862. package/src/editor/history/subtree.ts +13 -2
  863. package/src/editor/index.ts +11 -0
  864. package/src/editor/nudge.ts +1 -1
  865. package/src/editor/pages.ts +40 -29
  866. package/src/editor/play/states.ts +1 -1
  867. package/src/editor/read-only/actions.ts +6 -0
  868. package/src/editor/render-requests.ts +83 -0
  869. package/src/editor/selection/container.ts +24 -1
  870. package/src/editor/selection/navigation.ts +8 -6
  871. package/src/editor/selection/overlays.ts +1 -0
  872. package/src/editor/shapes/with-text.ts +2 -5
  873. package/src/editor/structure/auto-layout-wrap.ts +1 -1
  874. package/src/editor/structure/boolean.ts +1 -3
  875. package/src/editor/structure/group/bounds.ts +1 -5
  876. package/src/editor/structure/outline-stroke.ts +3 -3
  877. package/src/editor/structure/reorder.ts +8 -14
  878. package/src/editor/structure/state.ts +1 -1
  879. package/src/editor/structure.ts +5 -8
  880. package/src/editor/tool-registry.ts +2 -1
  881. package/src/editor/types.ts +8 -1
  882. package/src/editor/variables.ts +74 -2
  883. package/src/editor/variations/create.ts +235 -0
  884. package/src/editor/variations/pick.ts +35 -0
  885. package/src/editor/variations.ts +110 -0
  886. package/src/figma-api/accessors/reactions.ts +11 -1
  887. package/src/figma-api/accessors/text/index.ts +17 -1
  888. package/src/figma-api/accessors/text/opentype.ts +33 -0
  889. package/src/figma-api/accessors/visual.ts +55 -2
  890. package/src/figma-api/compatibility.ts +5 -2
  891. package/src/figma-api/effects.ts +143 -5
  892. package/src/figma-api/fonts/loaded.ts +9 -0
  893. package/src/figma-api/index.ts +35 -0
  894. package/src/figma-api/overrides.ts +295 -3
  895. package/src/figma-api/paints.ts +24 -9
  896. package/src/figma-api/proxy.ts +6 -1
  897. package/src/figma-api/reactions.ts +130 -32
  898. package/src/figma-api/serialization.ts +2 -1
  899. package/src/figma-api/shape-details.ts +50 -0
  900. package/src/figma-api/shape-with-text.ts +2 -5
  901. package/src/figma-api/surface.ts +7 -2
  902. package/src/global.d.ts +31 -0
  903. package/src/icons/svg.ts +3 -1
  904. package/src/io/formats/boolean-path.ts +60 -0
  905. package/src/io/formats/design-tokens/index.ts +21 -0
  906. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  907. package/src/io/formats/design-tokens/project.ts +40 -9
  908. package/src/io/formats/design-tokens/styles.ts +10 -2
  909. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  910. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  911. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  912. package/src/io/formats/drawio/edges.ts +65 -0
  913. package/src/io/formats/drawio/export.ts +37 -14
  914. package/src/io/formats/drawio/index.ts +5 -1
  915. package/src/io/formats/fig/export/patch/index.ts +8 -0
  916. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  917. package/src/io/formats/html/import.ts +9 -1
  918. package/src/io/formats/html/index.ts +14 -7
  919. package/src/io/formats/html/layers.ts +11 -2
  920. package/src/io/formats/html/vectors.ts +8 -2
  921. package/src/io/formats/pdf/document.ts +14 -4
  922. package/src/io/formats/pdf/dom.ts +10 -18
  923. package/src/io/formats/pdf/export.ts +1 -1
  924. package/src/io/formats/pen/imports.ts +5 -6
  925. package/src/io/formats/pen/index.ts +36 -5
  926. package/src/io/formats/raster/adjusted-images.ts +125 -0
  927. package/src/io/formats/raster/headless.ts +3 -3
  928. package/src/io/formats/raster/index.ts +6 -1
  929. package/src/io/formats/raster/pixels.ts +7 -0
  930. package/src/io/formats/raster/render.ts +12 -1
  931. package/src/io/formats/svg/defs.ts +14 -73
  932. package/src/io/formats/svg/effects.ts +131 -0
  933. package/src/io/formats/svg/export.ts +371 -64
  934. package/src/io/formats/svg/filter.ts +47 -0
  935. package/src/io/formats/svg/grain.ts +249 -0
  936. package/src/io/formats/svg/strokes.ts +2 -2
  937. package/src/io/formats/svg/text/layout.ts +13 -3
  938. package/src/io/formats/video/composite.ts +79 -0
  939. package/src/io/formats/video/formats.ts +77 -0
  940. package/src/io/formats/video/gif.ts +65 -0
  941. package/src/io/formats/video/index.ts +30 -0
  942. package/src/io/formats/video/plan.ts +116 -0
  943. package/src/io/formats/video/record.ts +227 -0
  944. package/src/io/formats/video/sink.ts +32 -0
  945. package/src/io/formats/video/size.ts +25 -0
  946. package/src/io/formats/video/webcodecs.ts +89 -0
  947. package/src/io/formats.ts +59 -11
  948. package/src/io/types.ts +29 -10
  949. package/src/layout/apply.ts +87 -21
  950. package/src/layout/auto-layout-handles.ts +396 -0
  951. package/src/layout/derived.ts +14 -0
  952. package/src/layout/grid.ts +33 -9
  953. package/src/layout/mutations.ts +13 -1
  954. package/src/layout/strokes.ts +12 -0
  955. package/src/layout/yoga-helpers.ts +18 -1
  956. package/src/layout.ts +96 -49
  957. package/src/lint/fixes.ts +12 -3
  958. package/src/lint/index.ts +3 -1
  959. package/src/lint/linter.ts +124 -12
  960. package/src/lint/presets.ts +2 -0
  961. package/src/lint/rules/design-memory.ts +97 -0
  962. package/src/lint/rules/effect-style-required.ts +2 -0
  963. package/src/lint/rules/index.ts +6 -1
  964. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  965. package/src/lint/rules/text-style-required.ts +2 -0
  966. package/src/lint/types.ts +40 -0
  967. package/src/node/video.ts +196 -0
  968. package/src/pairdraw-api/design-memory.ts +61 -0
  969. package/src/pairdraw-api/index.ts +81 -0
  970. package/src/pairdraw-api/nodes.ts +38 -0
  971. package/src/pairdraw-api/variations.ts +109 -0
  972. package/src/prototype/easing.ts +37 -0
  973. package/src/prototype/frames.ts +9 -0
  974. package/src/prototype/hit.ts +70 -0
  975. package/src/prototype/index.ts +69 -0
  976. package/src/prototype/pointer.ts +146 -0
  977. package/src/prototype/reactions.ts +178 -0
  978. package/src/prototype/scene.ts +116 -0
  979. package/src/prototype/scenes.ts +256 -0
  980. package/src/prototype/scroll.ts +190 -0
  981. package/src/prototype/session.ts +188 -0
  982. package/src/prototype/smart-animate/animation.ts +267 -0
  983. package/src/prototype/smart-animate/match.ts +85 -0
  984. package/src/prototype/snapshot.ts +60 -0
  985. package/src/prototype/timeline.ts +400 -0
  986. package/src/rpc/index.ts +1 -0
  987. package/src/rpc/read-commands.ts +40 -23
  988. package/src/text/font/faces.ts +22 -0
  989. package/src/text/font/features.ts +27 -0
  990. package/src/text/font/manager.ts +88 -12
  991. package/src/text/index.ts +2 -0
  992. package/src/text/replace-fonts.ts +171 -0
  993. package/src/tools/analyze/responsive/index.ts +264 -0
  994. package/src/tools/analyze.ts +2 -0
  995. package/src/tools/codegen/token-sync.ts +98 -0
  996. package/src/tools/codegen.ts +1 -0
  997. package/src/tools/create/components.ts +4 -0
  998. package/src/tools/create/html.ts +1 -0
  999. package/src/tools/create/icons.ts +1 -0
  1000. package/src/tools/create/mermaid.ts +1 -0
  1001. package/src/tools/create/svg.ts +1 -0
  1002. package/src/tools/design-memory.ts +72 -0
  1003. package/src/tools/image-ai/generate.ts +2 -0
  1004. package/src/tools/index.ts +1 -0
  1005. package/src/tools/modify/fonts.ts +34 -0
  1006. package/src/tools/modify/layout.ts +5 -0
  1007. package/src/tools/modify/reactions.ts +15 -8
  1008. package/src/tools/modify/text.ts +42 -5
  1009. package/src/tools/modify/update.ts +46 -2
  1010. package/src/tools/modify.ts +1 -0
  1011. package/src/tools/read/fonts.ts +24 -2
  1012. package/src/tools/read/libraries.ts +1 -0
  1013. package/src/tools/read/nodes.ts +0 -1
  1014. package/src/tools/read/space.ts +3 -2
  1015. package/src/tools/registry/core.ts +3 -1
  1016. package/src/tools/registry/extended.ts +28 -1
  1017. package/src/tools/schema.ts +28 -4
  1018. package/src/tools/stock-photo.ts +1 -0
  1019. package/src/tools/structure/basic.ts +1 -0
  1020. package/src/tools/structure/batch.ts +34 -1
  1021. package/src/tools/structure/hierarchy.ts +4 -0
  1022. package/src/tools/structure/variations.ts +118 -0
  1023. package/src/tools/structure.ts +2 -0
  1024. package/src/tools/styles/types.ts +3 -4
  1025. package/src/tools/vector/boolean.ts +4 -0
  1026. package/src/tools/vector/path.ts +30 -6
  1027. package/src/tools/vector/vectorize.ts +1 -0
  1028. package/src/tools/vector/video.ts +228 -0
  1029. package/src/tools/vector.ts +1 -0
  1030. package/src/tools/video-host.ts +18 -0
  1031. package/src/xpath.ts +6 -1
@@ -2,8 +2,7 @@ import { EditorContext } from "./types.js";
2
2
  import { LayerType } from "./structure/layer-type.js";
3
3
  import { RenameSelectionOptions, RenameSelectionPreview } from "./structure/rename.js";
4
4
  import "./index.js";
5
- import { BooleanOperation } from "./structure/boolean.js";
6
- import { SceneNode } from "@pairdraw/scene-graph";
5
+ import { BooleanOperation, SceneNode } from "@pairdraw/scene-graph";
7
6
  //#region src/editor/structure.d.ts
8
7
  declare function createStructureActions(ctx: EditorContext): {
9
8
  moveToPage: (pageId: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"structure.d.ts","names":[],"sources":["../../src/editor/structure.ts"],"mappings":";;;;;;;iBA0BgB,uBAAuB,KAAK;EAgId,aAAA;EA+CY,wBAAA,SAAA,2BAAA;EAIP,iBAAA,SAAA;EA8BT,aAAA,YAAM;;;;;;EAvGmB,2BAAA,eAAA,aAAW,WAAa;EAIlC,kBAAA,cAAA;EAIC,kBAAA,eAAA;EAII,sBAAA,eAAA;EAME,wBAAA,eAAA;2CAAA;EA/Gd,gBAAA,mBAAQ;EAuBvB,2BAAA,kEAAiD,eACjD,aAAW,aACb,QAAQ;EAKkB,mBAAA,eAAA;EAIH,gBAAA,eAAA;EAoBD,eAAA,eAAA;EAmCE,iBAAA,eAAA;;;;;;;;EAjGT,aAAA;EA+NA,kBAAA;EACA,kBAAA;EACI,qBAAA,WAAA"}
1
+ {"version":3,"file":"structure.d.ts","names":[],"sources":["../../src/editor/structure.ts"],"mappings":";;;;;;iBAuBgB,uBAAuB,KAAK;EAgId,aAAA;EA+CY,wBAAA,SAAA,2BAAA;EAIP,iBAAA,SAAA;EA8BT,aAAA,YAAM;;;;;;EAvGmB,2BAAA,eAAA,aAAW,WAAa;EAIlC,kBAAA,cAAA;EAIC,kBAAA,eAAA;EAII,sBAAA,eAAA;EAME,wBAAA,eAAA;2CAAA;EA/Gd,gBAAA,mBAAQ;EAuBvB,2BAAA,kEAAiD,eACjD,aAAW,aACb,QAAQ;EAKkB,mBAAA,eAAA;EAIH,gBAAA,eAAA;EAoBD,eAAA,eAAA;EAmCE,iBAAA,eAAA;;;;;;;;EAjGT,aAAA;EA+NA,kBAAA;EACA,kBAAA;EACI,qBAAA,WAAA"}
@@ -128,11 +128,11 @@ function createStructureActions(ctx) {
128
128
  }];
129
129
  }).sort((a, b) => a.index - b.index);
130
130
  if (origins.length === 0) return;
131
- const parentIds = new Set(origins.map((origin) => origin.parentId));
131
+ const parentIds = origins.map((origin) => origin.parentId);
132
132
  const prevSelection = new Set(ctx.state.selectedIds);
133
133
  const move = () => {
134
134
  for (const { id } of origins) ctx.graph.reparentNode(id, pageId);
135
- for (const parentId of parentIds) ctx.runLayoutForNode(parentId);
135
+ ctx.runLayoutForParents(parentIds);
136
136
  ctx.setSelectedIds(/* @__PURE__ */ new Set());
137
137
  };
138
138
  move();
@@ -145,7 +145,7 @@ function createStructureActions(ctx) {
145
145
  ctx.graph.insertChildAt(id, parentId, index);
146
146
  ctx.graph.updateNode(id, place);
147
147
  }
148
- for (const parentId of parentIds) ctx.runLayoutForNode(parentId);
148
+ ctx.runLayoutForParents(parentIds);
149
149
  ctx.setSelectedIds(new Set(prevSelection));
150
150
  }
151
151
  });
@@ -1 +1 @@
1
- {"version":3,"file":"structure.js","names":["wrapSelectionInContainer","wrapSelectionInContainerImpl","wrapInAutoLayout","wrapInAutoLayoutImpl","booleanOperationSelected","booleanOperationSelectedImpl","ungroupSelected","flattenSelected","flattenSelectedImpl","outlineStrokeSelected","outlineStrokeSelectedImpl"],"sources":["../../src/editor/structure.ts"],"sourcesContent":["import { pick } from 'es-toolkit'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { TRANSFORM_FIELDS } from '@pairdraw/scene-graph/fields'\nimport { createsComponentCycle } from '@pairdraw/scene-graph/instances'\nimport { defaultNodeName } from '@pairdraw/scene-graph/node-defaults'\n\nimport { acceptingParent, acceptsChildren, prepareSlotEdits } from '#core/editor/components/slots'\nimport { fitEnclosingGroupsWithUndo } from '#core/editor/structure/group/bounds'\n\nimport { wrapInAutoLayout as wrapInAutoLayoutImpl } from './structure/auto-layout-wrap'\nimport {\n booleanOperationSelected as booleanOperationSelectedImpl,\n type BooleanOperation\n} from './structure/boolean'\nimport { wrapSelectionInContainer as wrapSelectionInContainerImpl } from './structure/container-wrap'\nimport { flattenSelected as flattenSelectedImpl } from './structure/flatten'\nimport { ungroupSelected as ungroupImpl } from './structure/group/ungroup'\nimport { createLayerTypeActions } from './structure/layer-type'\nimport { outlineStrokeSelected as outlineStrokeSelectedImpl } from './structure/outline-stroke'\nimport { previewRenamedNodes, type RenameSelectionOptions } from './structure/rename'\nimport { createStructureReorderActions } from './structure/reorder'\nimport { createStructureStateActions } from './structure/state'\nimport { namedByText } from './text/name'\nimport type { EditorContext } from './types'\n\nexport function createStructureActions(ctx: EditorContext) {\n const reorderActions = createStructureReorderActions(ctx)\n const stateActions = createStructureStateActions(ctx)\n const layerTypeActions = createLayerTypeActions(ctx)\n\n function isTopLevel(parentId: string | null): boolean {\n return !parentId || parentId === ctx.graph.rootId || parentId === ctx.state.currentPageId\n }\n\n /**\n * Moves layers under a new parent; refuses the locked part of an instance, and a layer that\n * would make a component contain itself, as Figma does.\n */\n function reparentNodes(nodeIds: string[], newParentId: string): boolean {\n const parent = ctx.graph.getNode(newParentId)\n // Sections only go into pages and other sections.\n const movable = nodeIds.filter(\n (id) =>\n (ctx.graph.getNode(id)?.type !== 'SECTION' ||\n !parent ||\n parent.type === 'CANVAS' ||\n parent.type === 'SECTION') &&\n !createsComponentCycle(ctx.graph, id, newParentId)\n )\n if (movable.length === 0) return true\n const parents = new Set([newParentId])\n for (const id of movable) {\n const current = ctx.graph.getNode(id)?.parentId\n if (current && current !== newParentId) parents.add(current)\n }\n if (!prepareSlotEdits(ctx, parents)) return false\n for (const id of movable) ctx.graph.reparentNode(id, newParentId)\n return true\n }\n\n function wrapSelectionInContainer(\n containerType: 'GROUP' | 'FRAME' | 'COMPONENT' | 'COMPONENT_SET',\n selectedNodes: SceneNode[],\n extraProps?: Partial<SceneNode>\n ) {\n return wrapSelectionInContainerImpl(ctx, containerType, selectedNodes, extraProps)\n }\n\n function wrapInAutoLayout(selectedNodes: SceneNode[]) {\n return wrapInAutoLayoutImpl(ctx, selectedNodes)\n }\n\n function groupSelected(selectedNodes: SceneNode[]) {\n return wrapSelectionInContainer('GROUP', selectedNodes)\n }\n\n /** How a mask toggles on one layer, as its own undo step. */\n function toggleMask(node: SceneNode): void {\n const next = !node.isMask\n const changes = { isMask: next }\n ctx.graph.updateNode(node.id, changes)\n ctx.undo.push({\n label: next ? 'Use as mask' : 'Remove mask',\n forward: () => ctx.graph.updateNode(node.id, changes),\n inverse: () => ctx.graph.updateNode(node.id, { isMask: !next })\n })\n }\n\n /**\n * Use as mask: one layer toggles its own mask; sibling layers are wrapped in a \"Mask group\"\n * whose bottom layer masks the layers above it, as Figma does. One undo step.\n */\n function maskSelected(selectedNodes: SceneNode[]): boolean {\n if (selectedNodes.length === 0) return false\n if (selectedNodes.length === 1) {\n toggleMask(selectedNodes[0])\n return true\n }\n const parentId = selectedNodes[0]?.parentId\n const parent = parentId ? ctx.graph.getNode(parentId) : undefined\n const selected = new Set(selectedNodes.map((node) => node.id))\n // The page's child order is the stack order, bottom first.\n const stack = parent ? parent.childIds.filter((id) => selected.has(id)) : []\n // Layers under different parents cannot share a group; the first one toggles, as before.\n if (stack.length !== selectedNodes.length) {\n toggleMask(selectedNodes[0])\n return true\n }\n const [bottomId] = stack\n const bottom = ctx.graph.getNode(bottomId)\n if (!bottom) return false\n // A mask already set on the bottom layer comes off, as the menu's Remove mask does.\n if (bottom.isMask) {\n toggleMask(bottom)\n return true\n }\n let grouped = false\n ctx.undo.runBatch('Use as mask', () => {\n const group = wrapSelectionInContainer('GROUP', selectedNodes, { name: 'Mask group' })\n if (!group) return\n grouped = true\n toggleMask(bottom)\n })\n return grouped\n }\n\n /** Figma frames a selection without a fill or clipping, unlike a drawn frame. */\n function frameSelection(selectedNodes: SceneNode[]) {\n return wrapSelectionInContainer('FRAME', selectedNodes)\n }\n\n function booleanOperationSelected(selectedNodes: SceneNode[], operation: BooleanOperation) {\n return booleanOperationSelectedImpl(ctx, selectedNodes, operation)\n }\n\n function ungroupSelected(selectedNode: SceneNode | undefined) {\n ungroupImpl(ctx, selectedNode)\n }\n\n function flattenSelected(selectedNodes: SceneNode[]) {\n return flattenSelectedImpl(ctx, selectedNodes)\n }\n\n function outlineTextSelected(selectedNodes: SceneNode[]) {\n if (selectedNodes.length === 0 || selectedNodes.some((node) => node.type !== 'TEXT'))\n return null\n return flattenSelectedImpl(ctx, selectedNodes, { label: 'Outline text' })\n }\n\n function outlineStrokeSelected(selectedNodes: SceneNode[]) {\n return outlineStrokeSelectedImpl(ctx, selectedNodes)\n }\n\n function moveToPage(pageId: string) {\n const targetPage = ctx.graph.getNode(pageId)\n if (targetPage?.type !== 'CANVAS') return\n // Where each layer was, read before any of them moves: put back in this order, each lands at\n // its own index again.\n const origins = [...ctx.state.selectedIds]\n .flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.id === pageId) return []\n const index = parent.childIds.indexOf(id)\n return [{ id, parentId: parent.id, index, place: pick(node, TRANSFORM_FIELDS) }]\n })\n .sort((a, b) => a.index - b.index)\n if (origins.length === 0) return\n const parentIds = new Set(origins.map((origin) => origin.parentId))\n const prevSelection = new Set(ctx.state.selectedIds)\n const move = () => {\n for (const { id } of origins) ctx.graph.reparentNode(id, pageId)\n for (const parentId of parentIds) ctx.runLayoutForNode(parentId)\n ctx.setSelectedIds(new Set())\n }\n move()\n // Groups the layers left shrink to the rest, or go when empty, in the same undo step.\n ctx.undo.runBatch('Move to page', () => {\n ctx.undo.push({\n label: 'Move to page',\n forward: move,\n inverse: () => {\n for (const { id, parentId, index, place } of origins) {\n ctx.graph.insertChildAt(id, parentId, index)\n ctx.graph.updateNode(id, place)\n }\n for (const parentId of parentIds) ctx.runLayoutForNode(parentId)\n ctx.setSelectedIds(new Set(prevSelection))\n }\n })\n fitEnclosingGroupsWithUndo(ctx, parentIds)\n })\n }\n\n function selectedNodes(): SceneNode[] {\n return [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((node): node is SceneNode => node != null)\n }\n\n function previewRenameSelected(options: RenameSelectionOptions) {\n return previewRenamedNodes(selectedNodes(), options)\n }\n\n function renameSelected(options: RenameSelectionOptions) {\n const nodes = selectedNodes()\n if (nodes.length === 0) return\n const preview = previewRenamedNodes(nodes, options)\n if (preview.error) return\n const before = new Map(\n nodes.map((node) => [node.id, { name: node.name, autoRename: node.autoRename }])\n )\n // A layer named by its text keeps the name it is given, as in Figma.\n const names = new Map(\n nodes.map((node) => [\n node.id,\n {\n name: preview.names.get(node.id) ?? node.name,\n autoRename: namedByText(node) ? false : node.autoRename\n }\n ])\n )\n const applyNames = (values: ReadonlyMap<string, { name: string; autoRename: boolean }>) => {\n for (const [id, next] of values) ctx.graph.updateNode(id, next)\n }\n\n applyNames(names)\n ctx.undo.push({\n label: 'Rename selection',\n forward: () => applyNames(names),\n inverse: () => applyNames(before)\n })\n }\n\n function renameNode(id: string, name: string) {\n const node = ctx.graph.getNode(id)\n if (!node) return\n const previous = { name: node.name, autoRename: node.autoRename }\n const next = name.trim() || defaultNodeName(node.type)\n if (next === previous.name) return\n // A layer named by its text, as a text layer or a sticky note is, keeps the name it is\n // given, as in Figma.\n const renamed = { name: next, autoRename: namedByText(node) ? false : node.autoRename }\n ctx.graph.updateNode(id, renamed)\n ctx.undo.push({\n label: 'Rename',\n forward: () => ctx.graph.updateNode(id, renamed),\n inverse: () => ctx.graph.updateNode(id, previous)\n })\n }\n\n return {\n isTopLevel,\n acceptsChildren: (parentId: string) => acceptsChildren(ctx, parentId),\n acceptingParent: (parentId: string) => acceptingParent(ctx, parentId),\n fitEnclosingGroups: (parentIds: Iterable<string>) => fitEnclosingGroupsWithUndo(ctx, parentIds),\n ...reorderActions,\n reparentNodes,\n wrapSelectionInContainer,\n wrapInAutoLayout,\n groupSelected,\n maskSelected,\n frameSelection,\n ...layerTypeActions,\n booleanOperationSelected,\n ungroupSelected,\n flattenSelected,\n outlineTextSelected,\n outlineStrokeSelected,\n ...stateActions,\n moveToPage,\n previewRenameSelected,\n renameSelected,\n renameNode\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAgB,uBAAuB,KAAoB;CACzD,MAAM,iBAAiB,8BAA8B,GAAG;CACxD,MAAM,eAAe,4BAA4B,GAAG;CACpD,MAAM,mBAAmB,uBAAuB,GAAG;CAEnD,SAAS,WAAW,UAAkC;EACpD,OAAO,CAAC,YAAY,aAAa,IAAI,MAAM,UAAU,aAAa,IAAI,MAAM;CAC9E;;;;;CAMA,SAAS,cAAc,SAAmB,aAA8B;EACtE,MAAM,SAAS,IAAI,MAAM,QAAQ,WAAW;EAE5C,MAAM,UAAU,QAAQ,QACrB,QACE,IAAI,MAAM,QAAQ,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,OAAO;GACP,eAAe,IAAI,MAAM,WAAW,IAAI,OAAO;GAC/C,eAAe,IAAI,MAAM,WAAW,IAAI,QAAQ;EAClD,CAAC;CACH;CAEA,OAAO;EACL;EACA,kBAAkB,aAAqB,gBAAgB,KAAK,QAAQ;EACpE,kBAAkB,aAAqB,gBAAgB,KAAK,QAAQ;EACpE,qBAAqB,cAAgC,2BAA2B,KAAK,SAAS;EAC9F,GAAG;EACH;EACA,0BAAA;EACA,kBAAA;EACA;EACA;EACA;EACA,GAAG;EACH,0BAAA;EACA,iBAAA;EACA,iBAAA;EACA;EACA,uBAAA;EACA,GAAG;EACH;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"structure.js","names":["wrapSelectionInContainer","wrapSelectionInContainerImpl","wrapInAutoLayout","wrapInAutoLayoutImpl","booleanOperationSelected","booleanOperationSelectedImpl","ungroupSelected","flattenSelected","flattenSelectedImpl","outlineStrokeSelected","outlineStrokeSelectedImpl"],"sources":["../../src/editor/structure.ts"],"sourcesContent":["import { pick } from 'es-toolkit'\n\nimport type { BooleanOperation, SceneNode } from '@pairdraw/scene-graph'\nimport { TRANSFORM_FIELDS } from '@pairdraw/scene-graph/fields'\nimport { createsComponentCycle } from '@pairdraw/scene-graph/instances'\nimport { defaultNodeName } from '@pairdraw/scene-graph/node-defaults'\n\nimport { acceptingParent, acceptsChildren, prepareSlotEdits } from '#core/editor/components/slots'\nimport { fitEnclosingGroupsWithUndo } from '#core/editor/structure/group/bounds'\n\nimport { wrapInAutoLayout as wrapInAutoLayoutImpl } from './structure/auto-layout-wrap'\nimport { booleanOperationSelected as booleanOperationSelectedImpl } from './structure/boolean'\nimport { wrapSelectionInContainer as wrapSelectionInContainerImpl } from './structure/container-wrap'\nimport { flattenSelected as flattenSelectedImpl } from './structure/flatten'\nimport { ungroupSelected as ungroupImpl } from './structure/group/ungroup'\nimport { createLayerTypeActions } from './structure/layer-type'\nimport { outlineStrokeSelected as outlineStrokeSelectedImpl } from './structure/outline-stroke'\nimport { previewRenamedNodes, type RenameSelectionOptions } from './structure/rename'\nimport { createStructureReorderActions } from './structure/reorder'\nimport { createStructureStateActions } from './structure/state'\nimport { namedByText } from './text/name'\nimport type { EditorContext } from './types'\n\nexport function createStructureActions(ctx: EditorContext) {\n const reorderActions = createStructureReorderActions(ctx)\n const stateActions = createStructureStateActions(ctx)\n const layerTypeActions = createLayerTypeActions(ctx)\n\n function isTopLevel(parentId: string | null): boolean {\n return !parentId || parentId === ctx.graph.rootId || parentId === ctx.state.currentPageId\n }\n\n /**\n * Moves layers under a new parent; refuses the locked part of an instance, and a layer that\n * would make a component contain itself, as Figma does.\n */\n function reparentNodes(nodeIds: string[], newParentId: string): boolean {\n const parent = ctx.graph.getNode(newParentId)\n // Sections only go into pages and other sections.\n const movable = nodeIds.filter(\n (id) =>\n (ctx.graph.getNode(id)?.type !== 'SECTION' ||\n !parent ||\n parent.type === 'CANVAS' ||\n parent.type === 'SECTION') &&\n !createsComponentCycle(ctx.graph, id, newParentId)\n )\n if (movable.length === 0) return true\n const parents = new Set([newParentId])\n for (const id of movable) {\n const current = ctx.graph.getNode(id)?.parentId\n if (current && current !== newParentId) parents.add(current)\n }\n if (!prepareSlotEdits(ctx, parents)) return false\n for (const id of movable) ctx.graph.reparentNode(id, newParentId)\n return true\n }\n\n function wrapSelectionInContainer(\n containerType: 'GROUP' | 'FRAME' | 'COMPONENT' | 'COMPONENT_SET',\n selectedNodes: SceneNode[],\n extraProps?: Partial<SceneNode>\n ) {\n return wrapSelectionInContainerImpl(ctx, containerType, selectedNodes, extraProps)\n }\n\n function wrapInAutoLayout(selectedNodes: SceneNode[]) {\n return wrapInAutoLayoutImpl(ctx, selectedNodes)\n }\n\n function groupSelected(selectedNodes: SceneNode[]) {\n return wrapSelectionInContainer('GROUP', selectedNodes)\n }\n\n /** How a mask toggles on one layer, as its own undo step. */\n function toggleMask(node: SceneNode): void {\n const next = !node.isMask\n const changes = { isMask: next }\n ctx.graph.updateNode(node.id, changes)\n ctx.undo.push({\n label: next ? 'Use as mask' : 'Remove mask',\n forward: () => ctx.graph.updateNode(node.id, changes),\n inverse: () => ctx.graph.updateNode(node.id, { isMask: !next })\n })\n }\n\n /**\n * Use as mask: one layer toggles its own mask; sibling layers are wrapped in a \"Mask group\"\n * whose bottom layer masks the layers above it, as Figma does. One undo step.\n */\n function maskSelected(selectedNodes: SceneNode[]): boolean {\n if (selectedNodes.length === 0) return false\n if (selectedNodes.length === 1) {\n toggleMask(selectedNodes[0])\n return true\n }\n const parentId = selectedNodes[0]?.parentId\n const parent = parentId ? ctx.graph.getNode(parentId) : undefined\n const selected = new Set(selectedNodes.map((node) => node.id))\n // The page's child order is the stack order, bottom first.\n const stack = parent ? parent.childIds.filter((id) => selected.has(id)) : []\n // Layers under different parents cannot share a group; the first one toggles, as before.\n if (stack.length !== selectedNodes.length) {\n toggleMask(selectedNodes[0])\n return true\n }\n const [bottomId] = stack\n const bottom = ctx.graph.getNode(bottomId)\n if (!bottom) return false\n // A mask already set on the bottom layer comes off, as the menu's Remove mask does.\n if (bottom.isMask) {\n toggleMask(bottom)\n return true\n }\n let grouped = false\n ctx.undo.runBatch('Use as mask', () => {\n const group = wrapSelectionInContainer('GROUP', selectedNodes, { name: 'Mask group' })\n if (!group) return\n grouped = true\n toggleMask(bottom)\n })\n return grouped\n }\n\n /** Figma frames a selection without a fill or clipping, unlike a drawn frame. */\n function frameSelection(selectedNodes: SceneNode[]) {\n return wrapSelectionInContainer('FRAME', selectedNodes)\n }\n\n function booleanOperationSelected(selectedNodes: SceneNode[], operation: BooleanOperation) {\n return booleanOperationSelectedImpl(ctx, selectedNodes, operation)\n }\n\n function ungroupSelected(selectedNode: SceneNode | undefined) {\n ungroupImpl(ctx, selectedNode)\n }\n\n function flattenSelected(selectedNodes: SceneNode[]) {\n return flattenSelectedImpl(ctx, selectedNodes)\n }\n\n function outlineTextSelected(selectedNodes: SceneNode[]) {\n if (selectedNodes.length === 0 || selectedNodes.some((node) => node.type !== 'TEXT'))\n return null\n return flattenSelectedImpl(ctx, selectedNodes, { label: 'Outline text' })\n }\n\n function outlineStrokeSelected(selectedNodes: SceneNode[]) {\n return outlineStrokeSelectedImpl(ctx, selectedNodes)\n }\n\n function moveToPage(pageId: string) {\n const targetPage = ctx.graph.getNode(pageId)\n if (targetPage?.type !== 'CANVAS') return\n // Where each layer was, read before any of them moves: put back in this order, each lands at\n // its own index again.\n const origins = [...ctx.state.selectedIds]\n .flatMap((id) => {\n const node = ctx.graph.getNode(id)\n const parent = node?.parentId ? ctx.graph.getNode(node.parentId) : undefined\n if (!node || !parent || parent.id === pageId) return []\n const index = parent.childIds.indexOf(id)\n return [{ id, parentId: parent.id, index, place: pick(node, TRANSFORM_FIELDS) }]\n })\n .sort((a, b) => a.index - b.index)\n if (origins.length === 0) return\n const parentIds = origins.map((origin) => origin.parentId)\n const prevSelection = new Set(ctx.state.selectedIds)\n const move = () => {\n for (const { id } of origins) ctx.graph.reparentNode(id, pageId)\n ctx.runLayoutForParents(parentIds)\n ctx.setSelectedIds(new Set())\n }\n move()\n // Groups the layers left shrink to the rest, or go when empty, in the same undo step.\n ctx.undo.runBatch('Move to page', () => {\n ctx.undo.push({\n label: 'Move to page',\n forward: move,\n inverse: () => {\n for (const { id, parentId, index, place } of origins) {\n ctx.graph.insertChildAt(id, parentId, index)\n ctx.graph.updateNode(id, place)\n }\n ctx.runLayoutForParents(parentIds)\n ctx.setSelectedIds(new Set(prevSelection))\n }\n })\n fitEnclosingGroupsWithUndo(ctx, parentIds)\n })\n }\n\n function selectedNodes(): SceneNode[] {\n return [...ctx.state.selectedIds]\n .map((id) => ctx.graph.getNode(id))\n .filter((node): node is SceneNode => node != null)\n }\n\n function previewRenameSelected(options: RenameSelectionOptions) {\n return previewRenamedNodes(selectedNodes(), options)\n }\n\n function renameSelected(options: RenameSelectionOptions) {\n const nodes = selectedNodes()\n if (nodes.length === 0) return\n const preview = previewRenamedNodes(nodes, options)\n if (preview.error) return\n const before = new Map(\n nodes.map((node) => [node.id, { name: node.name, autoRename: node.autoRename }])\n )\n // A layer named by its text keeps the name it is given, as in Figma.\n const names = new Map(\n nodes.map((node) => [\n node.id,\n {\n name: preview.names.get(node.id) ?? node.name,\n autoRename: namedByText(node) ? false : node.autoRename\n }\n ])\n )\n const applyNames = (values: ReadonlyMap<string, { name: string; autoRename: boolean }>) => {\n for (const [id, next] of values) ctx.graph.updateNode(id, next)\n }\n\n applyNames(names)\n ctx.undo.push({\n label: 'Rename selection',\n forward: () => applyNames(names),\n inverse: () => applyNames(before)\n })\n }\n\n function renameNode(id: string, name: string) {\n const node = ctx.graph.getNode(id)\n if (!node) return\n const previous = { name: node.name, autoRename: node.autoRename }\n const next = name.trim() || defaultNodeName(node.type)\n if (next === previous.name) return\n // A layer named by its text, as a text layer or a sticky note is, keeps the name it is\n // given, as in Figma.\n const renamed = { name: next, autoRename: namedByText(node) ? false : node.autoRename }\n ctx.graph.updateNode(id, renamed)\n ctx.undo.push({\n label: 'Rename',\n forward: () => ctx.graph.updateNode(id, renamed),\n inverse: () => ctx.graph.updateNode(id, previous)\n })\n }\n\n return {\n isTopLevel,\n acceptsChildren: (parentId: string) => acceptsChildren(ctx, parentId),\n acceptingParent: (parentId: string) => acceptingParent(ctx, parentId),\n fitEnclosingGroups: (parentIds: Iterable<string>) => fitEnclosingGroupsWithUndo(ctx, parentIds),\n ...reorderActions,\n reparentNodes,\n wrapSelectionInContainer,\n wrapInAutoLayout,\n groupSelected,\n maskSelected,\n frameSelection,\n ...layerTypeActions,\n booleanOperationSelected,\n ungroupSelected,\n flattenSelected,\n outlineTextSelected,\n outlineStrokeSelected,\n ...stateActions,\n moveToPage,\n previewRenameSelected,\n renameSelected,\n renameNode\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,SAAgB,uBAAuB,KAAoB;CACzD,MAAM,iBAAiB,8BAA8B,GAAG;CACxD,MAAM,eAAe,4BAA4B,GAAG;CACpD,MAAM,mBAAmB,uBAAuB,GAAG;CAEnD,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,SAAS,MAAM;EAG5B,MAAM,UAAU;GAAE,MAAM;GAAM,YAAY,YAAY,IAAI,IAAI,QAAQ,KAAK;EAAW;EACtF,IAAI,MAAM,WAAW,IAAI,OAAO;EAChC,IAAI,KAAK,KAAK;GACZ,OAAO;GACP,eAAe,IAAI,MAAM,WAAW,IAAI,OAAO;GAC/C,eAAe,IAAI,MAAM,WAAW,IAAI,QAAQ;EAClD,CAAC;CACH;CAEA,OAAO;EACL;EACA,kBAAkB,aAAqB,gBAAgB,KAAK,QAAQ;EACpE,kBAAkB,aAAqB,gBAAgB,KAAK,QAAQ;EACpE,qBAAqB,cAAgC,2BAA2B,KAAK,SAAS;EAC9F,GAAG;EACH;EACA,0BAAA;EACA,kBAAA;EACA;EACA;EACA;EACA,GAAG;EACH,0BAAA;EACA,iBAAA;EACA,iBAAA;EACA;EACA,uBAAA;EACA,GAAG;EACH;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"tool-registry.d.ts","names":[],"sources":["../../src/editor/tool-registry.ts"],"mappings":";;UAEiB;EACf,KAAK;EACL;EACA;EACA,SAAS;;cAGE,cAAc;cAuBd,gBAAgB,QAAQ,eAAe;;;;;cAqBvC,aAAa,YAAY;;cAazB,sBAAsB,QAAQ,eAAe"}
1
+ {"version":3,"file":"tool-registry.d.ts","names":[],"sources":["../../src/editor/tool-registry.ts"],"mappings":";;UAEiB;EACf,KAAK;EACL;EACA;EACA,SAAS;;cAGE,cAAc;cAuBd,gBAAgB,QAAQ,eAAe;;;;;cAsBvC,aAAa,YAAY;;cAazB,sBAAsB,QAAQ,eAAe"}
@@ -76,7 +76,8 @@ const TOOL_SHORTCUTS = {
76
76
  KeyH: "HAND",
77
77
  KeyC: "COMMENT",
78
78
  KeyK: "SCALE",
79
- KeyZ: "ZOOM"
79
+ KeyZ: "ZOOM",
80
+ KeyI: "EYEDROPPER"
80
81
  };
81
82
  /**
82
83
  * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,
@@ -1 +1 @@
1
- {"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE3C;EAAE,KAAK;EAAU,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,UAAU,OAAO;CAAE;CAC3E;EAAE,KAAK;EAAS,OAAO;EAAS,UAAU;EAAK,QAAQ,CAAC,SAAS,SAAS;CAAE;CAC5E;EACE,KAAK;EACL,OAAO;EACP,UAAU;EACV,QAAQ;GAAC;GAAa;GAAQ;GAAW;GAAW;EAAM;CAC5D;CACA;EAAE,KAAK;EAAO,OAAO;EAAO,UAAU;EAAK,QAAQ,CAAC,OAAO,QAAQ;CAAE;CACrE;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;CAAI;CAE5C;EAAE,KAAK;EAAU,OAAO;EAAe,UAAU;CAAG;CAEpD;EAAE,KAAK;EAAmB,OAAO;EAAS,UAAU;CAAG;CAEvD;EAAE,KAAK;EAAa,OAAO;EAAa,UAAU;CAAG;CAErD;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,QAAQ,MAAM;CAAE;CACtE;EAAE,KAAK;EAAW,OAAO;EAAW,UAAU;CAAI;AACpD;AAEA,MAAa,iBAAgD;CAC3D,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;;;;AAMA,MAAa,8BAAiC,IAAI,IAAU;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAsD;CACjE,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR"}
1
+ {"version":3,"file":"tool-registry.js","names":[],"sources":["../../src/editor/tool-registry.ts"],"sourcesContent":["import type { Tool } from './types'\n\nexport interface EditorToolDef {\n key: Tool\n label: string\n shortcut: string\n flyout?: Tool[]\n}\n\nexport const EDITOR_TOOLS: EditorToolDef[] = [\n // Figma keeps Scale (K) in the Move flyout.\n { key: 'SELECT', label: 'Move', shortcut: 'V', flyout: ['SELECT', 'SCALE'] },\n { key: 'FRAME', label: 'Frame', shortcut: 'F', flyout: ['FRAME', 'SECTION'] },\n {\n key: 'RECTANGLE',\n label: 'Rectangle',\n shortcut: 'R',\n flyout: ['RECTANGLE', 'LINE', 'ELLIPSE', 'POLYGON', 'STAR']\n },\n { key: 'PEN', label: 'Pen', shortcut: 'P', flyout: ['PEN', 'PENCIL'] },\n { key: 'TEXT', label: 'Text', shortcut: 'T' },\n // Figma's S is Slice, and FigJam's sticky tool has no key in Figma Design.\n { key: 'STICKY', label: 'Sticky note', shortcut: '' },\n // FigJam's R; here R is the rectangle, as in Figma Design.\n { key: 'SHAPE_WITH_TEXT', label: 'Shape', shortcut: '' },\n // FigJam's X; Figma Design has no connector tool to take a key from.\n { key: 'CONNECTOR', label: 'Connector', shortcut: '' },\n // Zoom is held on Z, as in Figma, or picked here to stay on.\n { key: 'HAND', label: 'Hand', shortcut: 'H', flyout: ['HAND', 'ZOOM'] },\n { key: 'COMMENT', label: 'Comment', shortcut: 'C' }\n]\n\nexport const TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyF: 'FRAME',\n KeyA: 'FRAME',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'RECTANGLE',\n KeyO: 'ELLIPSE',\n KeyL: 'LINE',\n KeyT: 'TEXT',\n KeyP: 'PEN',\n 'Shift+KeyP': 'PENCIL',\n KeyH: 'HAND',\n KeyC: 'COMMENT',\n KeyK: 'SCALE',\n KeyZ: 'ZOOM',\n KeyI: 'EYEDROPPER'\n}\n\n/**\n * The tools a board offers, as FigJam's toolbar does: moving and panning, sticky notes, shapes,\n * connectors, sections, text, and comments, without Figma Design's drawing tools.\n */\nexport const BOARD_TOOLS: ReadonlySet<Tool> = new Set<Tool>([\n 'SELECT',\n 'HAND',\n 'STICKY',\n 'SHAPE_WITH_TEXT',\n 'CONNECTOR',\n 'SECTION',\n 'TEXT',\n 'COMMENT',\n 'ZOOM'\n])\n\n/** A board's tool keys, as in FigJam: S places a sticky note, R a shape, and X a connector. */\nexport const BOARD_TOOL_SHORTCUTS: Partial<Record<string, Tool>> = {\n KeyV: 'SELECT',\n KeyH: 'HAND',\n KeyS: 'STICKY',\n 'Shift+KeyS': 'SECTION',\n KeyR: 'SHAPE_WITH_TEXT',\n KeyX: 'CONNECTOR',\n KeyT: 'TEXT',\n KeyC: 'COMMENT',\n KeyZ: 'ZOOM'\n}\n"],"mappings":";AASA,MAAa,eAAgC;CAE3C;EAAE,KAAK;EAAU,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,UAAU,OAAO;CAAE;CAC3E;EAAE,KAAK;EAAS,OAAO;EAAS,UAAU;EAAK,QAAQ,CAAC,SAAS,SAAS;CAAE;CAC5E;EACE,KAAK;EACL,OAAO;EACP,UAAU;EACV,QAAQ;GAAC;GAAa;GAAQ;GAAW;GAAW;EAAM;CAC5D;CACA;EAAE,KAAK;EAAO,OAAO;EAAO,UAAU;EAAK,QAAQ,CAAC,OAAO,QAAQ;CAAE;CACrE;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;CAAI;CAE5C;EAAE,KAAK;EAAU,OAAO;EAAe,UAAU;CAAG;CAEpD;EAAE,KAAK;EAAmB,OAAO;EAAS,UAAU;CAAG;CAEvD;EAAE,KAAK;EAAa,OAAO;EAAa,UAAU;CAAG;CAErD;EAAE,KAAK;EAAQ,OAAO;EAAQ,UAAU;EAAK,QAAQ,CAAC,QAAQ,MAAM;CAAE;CACtE;EAAE,KAAK;EAAW,OAAO;EAAW,UAAU;CAAI;AACpD;AAEA,MAAa,iBAAgD;CAC3D,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR;;;;;AAMA,MAAa,8BAAiC,IAAI,IAAU;CAC1D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAa,uBAAsD;CACjE,MAAM;CACN,MAAM;CACN,MAAM;CACN,cAAc;CACd,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;AACR"}
@@ -17,7 +17,7 @@ import { CanvasKit } from "canvaskit-wasm";
17
17
  import { DocumentColorSpace, DocumentKind, SceneGraph, SceneGraphEvents, SceneNode, VectorNetwork, VectorSegment, VectorVertex } from "@pairdraw/scene-graph";
18
18
  import { ShapeWithTextType } from "@pairdraw/scene-graph/shape-with-text";
19
19
  import { CanvasGuide } from "@pairdraw/scene-graph/guides";
20
- import { UndoManager } from "@pairdraw/scene-graph/undo";
20
+ import { UndoEntry, UndoManager } from "@pairdraw/scene-graph/undo";
21
21
  import { SceneMutationImpact } from "@pairdraw/scene-graph/mutation-impact";
22
22
  import { Color as Color$1, Rect, Vector } from "@pairdraw/scene-graph/primitives";
23
23
  import { SnapGuide } from "@pairdraw/scene-graph/snap";
@@ -26,7 +26,9 @@ type Tool = 'SELECT' | 'FRAME' | 'SECTION' | 'RECTANGLE' | 'ELLIPSE' | 'LINE' |
26
26
  /** Figma's Z: a click zooms in, ⌥ and a click out, and a drag zooms to the dragged area. */
27
27
  'ZOOM' |
28
28
  /** Figma's K: handles scale layers with their text, strokes, effects, and spacing. */
29
- 'SCALE';
29
+ 'SCALE' |
30
+ /** Figma's I: samples the colour the document shows at the pointer into the selection. */
31
+ 'EYEDROPPER';
30
32
  /** The gradient whose handles the canvas shows while its paint picker is open. */
31
33
  interface GradientEdit {
32
34
  nodeId: string;
@@ -156,6 +158,8 @@ interface EditorViewState {
156
158
  autoLayoutHover: {
157
159
  nodeId: string;
158
160
  kind: 'frame' | 'children' | 'spacing' | 'spacing-value' | 'padding' | 'padding-value';
161
+ /** For a gap: the flow axis whose spacing it edits. */
162
+ axis?: 'primary' | 'counter';
159
163
  index?: number;
160
164
  side?: 'top' | 'right' | 'bottom' | 'left';
161
165
  } | null;
@@ -269,6 +273,8 @@ interface EditorContext {
269
273
  get graph(): SceneGraph;
270
274
  set graph(g: SceneGraph);
271
275
  undo: UndoManager;
276
+ /** Adds a step to the history of a graph that is not the open one, kept aside with it. */
277
+ parkStep: (graph: SceneGraph, entry: UndoEntry) => void;
272
278
  state: EditorState;
273
279
  loadFont: (family: string, style: string, characters?: string, signal?: AbortSignal) => Promise<ArrayBuffer | null>;
274
280
  resolveFigmaClipboardImages: FigmaClipboardImageResolver | null;
@@ -295,6 +301,7 @@ interface EditorContext {
295
301
  setActiveTool: (tool: Tool) => void;
296
302
  setNavigationPhase: (phase: NavigationPhase, inputAt?: number) => void;
297
303
  runLayoutForNode: (id: string) => void;
304
+ runLayoutForParents: (parentIds: Iterable<string>) => void;
298
305
  runMutationWithLayout: <T>(operation: () => T | Promise<T>, fallbackId?: string,
299
306
  /** Runs once the operation is done and before layout, with the layers it touched. */
300
307
  beforeLayout?: (result: T, impact: SceneMutationImpact) => Promise<void> | void) => Promise<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/editor/types.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAsCY;;;;;;UAuBK;EACf;EACA;EACA;;EAEA;;;UAIe;EACf;;EAEA;;;UAIe;EACf;;EAEA;;EAEA,QAAQ;;EAER;;EAEA,SAAS;;UAGM;EACf,YAAY;;EAEZ,mBAAmB;;;;;;EAMnB,cAAc;EACd,kBAAkB;EAClB,qBAAqB;;EAErB;;EAEA,eAAe;;EAEf,YAAY;EACZ,iBAAiB;EACjB;;EAEA,sBAAsB;;EAEtB;EACA,aAAa;;EAEb,iBAAiB;;EAEjB,QAAQ;;EAER;;;;;EAKA;;;;;;UAOe;EACf,SAAS;;EAET;;EAEA,UAAU;IAAQ;IAAe;;;UAGlB;EACf,QAAQ;;EAER;;EAEA;IAAW,OAAO;IAAO;;;UAGV;EACf;EACA,aAAa;EACb,SAAS;EACT,YAAY;EACZ,QAAQ;EACR,iBAAiB;EACjB;EACA;IACE;IACA;IACA;IACA;IACA;IACA;;EAEF;;EAEA;EACA,iBAAiB;EACjB;;EAEA;EACA;IACE,UAAU;IACV,UAAU;IACV,aAAa;IACb,qBAAqB;IACrB;IACA;IACA;IACA,cAAc;IACd,eAAe;IACf,iBAAiB;;EAEnB;EACA;;EAEA,aAAa;EACb;IACE;IACA;IACA;IACA;;EAEF,kBAAkB;;EAElB,iBAAiB;EACjB;EACA,WAAW;EACX;EACA;EACA,YAAY;EACZ;;EAEA;EACA;EACA,gBAAgB;EAChB;EACA;;EAEA,YAAY;;KAGF;UAEK;EACf,OAAO;EACP;EACA;;UAGe,oBAAoB,mBAAmB;UAEvC;EACf;EACA;EACA;;KAGU,+BACV,iBACA,qBACG,QAAQ,oBAAoB;UAEhB,qBAAqB;EACpC,qBAAqB;IAAY;IAAuB;;EACxD,sBAAsB;IAAY;IAAuB;;EACzD,mBAAmB,OAAO;EAC1B,iCAAiC,YAAY;EAC7C;EACA,+BAA+B;E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-1 +1 @@
1
- {"version":3,"file":"variables.d.ts","names":[],"sources":["../../src/editor/variables.ts"],"mappings":";;;;;KAoBY,sBAAsB,KAChC;iBA0Cc,sBAAsB,KAAK;EAQR,mBAAA,OAAA;EAoZA,sBAAA,YAAM,OAAS,QAAQ;EA8BhB,mBAAA,sBAAM,gBAAgB;EAxP/B,oBAAA,YAAM;EAtBG,mBAAA,sBAAM;EAySN,mBAAA,sBAAM;EA5bZ,qBAAA,MAAA,iBAAY;EAIrB,cAAA,eAAM;EAIG,uBAAA,0DAAM;EAIL,wBAAA;EAIc,4BAAA,yBAAM;EAI5B,gBAAA,eAAM;;;;EAgBH,mBAAA,YAAM;EAqBD,gBAAA,YAAA;EAgBL,mBAAA;EAyBC,cAAA,UAAA;EAgBH,iBAAA;EAkFA,iBAAA,YAAM;EAoK5B,sBAAA,YAAM,gBACI,OACP,eAAa;EAjJS,UAAA,sBAAM;EAqBH,aAAA,sBAAM;EA0CN,aAAA,sBAAM,gBAAgB;EAqBlB,iBAAA,sBAAM;EA0BP,gBAAA,sBAAM;EAuBN,gBAAA,sBAAM"}
1
+ {"version":3,"file":"variables.d.ts","names":[],"sources":["../../src/editor/variables.ts"],"mappings":";;;;;KA0BY,sBAAsB,KAChC;iBA0Cc,sBAAsB,KAAK;EAQR,mBAAA,OAAA;EAsdA,sBAAA,YAAM,OAAS,QAAQ;EA8BhB,mBAAA,sBAAM,gBAAgB;EAxP/B,oBAAA,YAAM;EAtBG,mBAAA,sBAAM;EAySN,mBAAA,sBAAM;EA9fZ,qBAAA,MAAA,iBAAY;EAIrB,cAAA,eAAM;EAIG,uBAAA,0DAAM;EAIL,wBAAA;EAIc,4BAAA,yBAAM;EAI5B,gBAAA,eAAM;;;;EAgBH,mBAAA,YAAM;EAqBD,gBAAA,YAAA;EAgBL,mBAAA;EA0CC,cAAA,UAAA;EA8DH,iBAAA;EAqFA,iBAAA,YAAM;EAoK5B,sBAAA,YAAM,gBACI,OACP,eAAa;EAjJS,UAAA,sBAAM;EAqBH,aAAA,sBAAM;EA0CN,aAAA,sBAAM,gBAAgB;EAqBlB,iBAAA,sBAAM;EA0BP,gBAAA,sBAAM;EAuBN,gBAAA,sBAAM"}
@@ -1,10 +1,12 @@
1
1
  import { reconcileVariableLayouts } from "../layout/variables.js";
2
2
  import { loadBoundFonts } from "./text/bound-fonts.js";
3
3
  import { loadBoundIcons } from "./icons.js";
4
- import { tokenExpressionForValue } from "@pairdraw/scene-graph/variables";
4
+ import { tokenExpressionForValue, variableBindingOwner } from "@pairdraw/scene-graph/variables";
5
5
  import { isModeAttributeName } from "@pairdraw/scene-graph";
6
6
  import { isEmptyObject } from "es-toolkit/predicate";
7
7
  import { omit, omitBy } from "es-toolkit/object";
8
+ import { findInstanceAncestor } from "@pairdraw/scene-graph/instances";
9
+ import { cloneInstanceOverrideState } from "@pairdraw/scene-graph/instances/overrides";
8
10
  //#region src/editor/variables.ts
9
11
  /** Every token field, unset ones included, so restoring it also clears what was added. */
10
12
  function tokenFields(variable) {
@@ -127,6 +129,10 @@ function createVariableActions(ctx) {
127
129
  const snapshot = structuredClone(collection);
128
130
  const scope = { variables: snapshot.variableIds };
129
131
  const variables = snapshot.variableIds.map((vid) => ctx.graph.variables.get(vid)).filter((v) => v != null).map((v) => structuredClone(v));
132
+ const bindings = bindingSnapshots(snapshot.variableIds);
133
+ const activeMode = ctx.graph.activeMode.get(id);
134
+ const modeChoices = /* @__PURE__ */ new Map();
135
+ for (const node of ctx.graph.getAllNodes()) if (Object.hasOwn(node.variableModes, id)) modeChoices.set(node.id, node.variableModes[id]);
130
136
  ctx.graph.removeCollection(id);
131
137
  ctx.undo.push({
132
138
  label: "Remove collection",
@@ -137,6 +143,16 @@ function createVariableActions(ctx) {
137
143
  inverse: () => {
138
144
  ctx.graph.addCollection(snapshot);
139
145
  for (const v of variables) ctx.graph.addVariable(v);
146
+ if (activeMode !== void 0) ctx.graph.setActiveMode(id, activeMode);
147
+ for (const [nodeId, modeId] of modeChoices) {
148
+ const node = ctx.graph.getNode(nodeId);
149
+ if (!node) continue;
150
+ ctx.graph.updateNode(nodeId, { variableModes: {
151
+ ...node.variableModes,
152
+ [id]: modeId
153
+ } });
154
+ }
155
+ restoreBindings(bindings);
140
156
  refreshVariables(scope);
141
157
  }
142
158
  });
@@ -157,11 +173,50 @@ function createVariableActions(ctx) {
157
173
  });
158
174
  ctx.requestRefresh();
159
175
  }
176
+ /**
177
+ * The bindings removing these variables strips from layers, and the instance overrides it
178
+ * records, so undo can put both back. A layer keeps the value its variable last gave it.
179
+ */
180
+ function bindingSnapshots(ids) {
181
+ const removed = new Set(ids);
182
+ const snapshots = [];
183
+ for (const node of ctx.graph.getAllNodes()) {
184
+ const entries = Object.entries(node.boundVariables).filter(([, id]) => removed.has(id));
185
+ if (entries.length === 0) continue;
186
+ const owner = variableBindingOwner(ctx.graph, node);
187
+ const nearest = findInstanceAncestor(ctx.graph, node.id);
188
+ snapshots.push({
189
+ nodeId: node.id,
190
+ boundVariables: Object.fromEntries(entries),
191
+ variableBindingScales: Object.fromEntries(entries.map(([field]) => field).filter((field) => field in node.variableBindingScales).map((field) => [field, node.variableBindingScales[field]])),
192
+ owners: new Map([owner, ...nearest ? [nearest] : []].map((item) => [item.id, cloneInstanceOverrideState(item.instanceOverrides)]))
193
+ });
194
+ }
195
+ return snapshots;
196
+ }
197
+ function restoreBindings(snapshots) {
198
+ for (const snapshot of snapshots) {
199
+ for (const [ownerId, state] of snapshot.owners) ctx.graph.updateNode(ownerId, { instanceOverrides: cloneInstanceOverrideState(state) });
200
+ const node = ctx.graph.getNode(snapshot.nodeId);
201
+ if (!node) continue;
202
+ ctx.graph.updateNode(snapshot.nodeId, {
203
+ boundVariables: {
204
+ ...node.boundVariables,
205
+ ...snapshot.boundVariables
206
+ },
207
+ variableBindingScales: {
208
+ ...node.variableBindingScales,
209
+ ...snapshot.variableBindingScales
210
+ }
211
+ });
212
+ }
213
+ }
160
214
  function removeVariable(id) {
161
215
  const variable = ctx.graph.variables.get(id);
162
216
  if (!variable) return;
163
217
  const snapshot = structuredClone(variable);
164
218
  const order = [...ctx.graph.variableCollections.get(variable.collectionId)?.variableIds ?? []];
219
+ const bindings = bindingSnapshots([id]);
165
220
  ctx.graph.removeVariable(id);
166
221
  ctx.undo.push({
167
222
  label: "Remove variable",
@@ -172,6 +227,7 @@ function createVariableActions(ctx) {
172
227
  inverse: () => {
173
228
  ctx.graph.addVariable(structuredClone(snapshot));
174
229
  placeVariables(snapshot.collectionId, order);
230
+ restoreBindings(bindings);
175
231
  refreshVariables({ variables: [id] });
176
232
  }
177
233
  });
@@ -1 +1 @@
1
- {"version":3,"file":"variables.js","names":[],"sources":["../../src/editor/variables.ts"],"sourcesContent":["import { omit, omitBy } from 'es-toolkit/object'\nimport { isEmptyObject } from 'es-toolkit/predicate'\n\nimport {\n isModeAttributeName,\n type TokenExpression,\n type Variable,\n type VariableCollection,\n type VariableType,\n type VariableValue\n} from '@pairdraw/scene-graph'\nimport { tokenExpressionForValue, type BindingScope } from '@pairdraw/scene-graph/variables'\n\nimport { reconcileVariableLayouts } from '#core/layout/variables'\n\nimport { loadBoundIcons } from './icons'\nimport { loadBoundFonts } from './text/bound-fonts'\nimport type { EditorContext } from './types'\n\n/** What a variable means as a design token beyond its values: how CSS and code read it. */\nexport type VariableTokenFields = Pick<\n Variable,\n 'unit' | 'expressions' | 'scopes' | 'codeSyntax' | 'description' | 'hiddenFromPublishing'\n>\n\n/** Every token field, unset ones included, so restoring it also clears what was added. */\nfunction tokenFields(variable: Variable): VariableTokenFields {\n const { unit, expressions, scopes, codeSyntax, description, hiddenFromPublishing } = variable\n return structuredClone({\n unit,\n expressions,\n scopes,\n codeSyntax,\n description,\n hiddenFromPublishing\n })\n}\n\n/** A mode's value with the CSS expression written for it, which the value must keep matching. */\ninterface ModeEntry {\n value: VariableValue | undefined\n expression: TokenExpression | undefined\n}\n\nfunction modeEntry(variable: Variable, modeId: string): ModeEntry {\n return structuredClone({\n value: variable.valuesByMode[modeId],\n expression: variable.expressions?.[modeId]\n })\n}\n\nfunction setModeEntry(variable: Variable, modeId: string, entry: ModeEntry) {\n const { value, expression } = structuredClone(entry)\n const values = omit(variable.valuesByMode, [modeId])\n variable.valuesByMode = value === undefined ? values : { ...values, [modeId]: value }\n const others = omit(variable.expressions ?? {}, [modeId])\n const expressions: Record<string, TokenExpression> = expression\n ? { ...others, [modeId]: expression }\n : others\n if (isEmptyObject(expressions)) delete variable.expressions\n else variable.expressions = expressions\n}\n\nexport function createVariableActions(ctx: EditorContext) {\n /**\n * Re-resolves the layers a change to what variables resolve to can reach: those bound to the\n * changed variables or to variables aliasing them. Every other variable change, such as adding,\n * renaming, reordering, or a token field, changes nothing the canvas draws, so it only refreshes\n * the views and leaves the canvas's recorded pictures in place. Records written into the graph\n * without an editor action, such as a collaborator's, take effect through it.\n */\n function refreshVariables(scope: BindingScope) {\n const changed = reconcileVariableLayouts(ctx.graph, scope)\n loadBoundFonts(ctx, changed)\n void loadBoundIcons(ctx, scope).catch((error: unknown) => {\n console.warn(\n 'Loading a bound icon failed:',\n error instanceof Error ? error.message : String(error)\n )\n })\n ctx.requestRender()\n }\n\n /** Every variable in a collection, the ones a change to its modes can reach. */\n function collectionScope(collectionId: string): BindingScope {\n return { variables: [...(ctx.graph.variableCollections.get(collectionId)?.variableIds ?? [])] }\n }\n\n function getVariablesByType(type: VariableType) {\n return ctx.graph.getVariablesByType(type)\n }\n\n function getVariable(id: string) {\n return ctx.graph.variables.get(id)\n }\n\n function resolveColorVariable(id: string) {\n return ctx.graph.resolveColorVariable(id)\n }\n\n function resolveNumberVariable(id: string) {\n return ctx.graph.resolveNumberVariable(id)\n }\n\n function getVariablesForCollection(collectionId: string) {\n return ctx.graph.getVariablesForCollection(collectionId)\n }\n\n function getCollection(id: string) {\n return ctx.graph.variableCollections.get(id)\n }\n\n function getCollections() {\n return [...ctx.graph.variableCollections.values()]\n }\n\n function getCollectionCount() {\n return ctx.graph.variableCollections.size\n }\n\n function getVariableCount() {\n return ctx.graph.variables.size\n }\n\n function renameCollection(id: string, newName: string) {\n const collection = ctx.graph.variableCollections.get(id)\n if (!collection) return\n const prevName = collection.name\n collection.name = newName\n ctx.undo.push({\n label: 'Rename collection',\n forward: () => {\n const c = ctx.graph.variableCollections.get(id)\n if (c) c.name = newName\n ctx.requestRefresh()\n },\n inverse: () => {\n const c = ctx.graph.variableCollections.get(id)\n if (c) c.name = prevName\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function addCollection(collection: VariableCollection) {\n ctx.graph.addCollection(collection)\n ctx.undo.push({\n label: 'Add collection',\n forward: () => {\n ctx.graph.addCollection(collection)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeCollection(collection.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function removeCollection(id: string) {\n const collection = ctx.graph.variableCollections.get(id)\n if (!collection) return\n const snapshot = structuredClone(collection)\n const scope: BindingScope = { variables: snapshot.variableIds }\n const variables = snapshot.variableIds\n .map((vid) => ctx.graph.variables.get(vid))\n .filter((v): v is Variable => v != null)\n .map((v) => structuredClone(v))\n ctx.graph.removeCollection(id)\n ctx.undo.push({\n label: 'Remove collection',\n forward: () => {\n ctx.graph.removeCollection(id)\n refreshVariables(scope)\n },\n inverse: () => {\n ctx.graph.addCollection(snapshot)\n for (const v of variables) ctx.graph.addVariable(v)\n refreshVariables(scope)\n }\n })\n refreshVariables(scope)\n }\n\n function addVariable(variable: Variable) {\n ctx.graph.addVariable(variable)\n ctx.undo.push({\n label: 'Add variable',\n forward: () => {\n ctx.graph.addVariable(variable)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeVariable(variable.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function removeVariable(id: string) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const snapshot = structuredClone(variable)\n const order = [...(ctx.graph.variableCollections.get(variable.collectionId)?.variableIds ?? [])]\n ctx.graph.removeVariable(id)\n ctx.undo.push({\n label: 'Remove variable',\n forward: () => {\n ctx.graph.removeVariable(id)\n refreshVariables({ variables: [id] })\n },\n // Undo puts the variable back where it was, not at the end of its collection.\n inverse: () => {\n ctx.graph.addVariable(structuredClone(snapshot))\n placeVariables(snapshot.collectionId, order)\n refreshVariables({ variables: [id] })\n }\n })\n refreshVariables({ variables: [id] })\n }\n\n /** Puts a collection's variables in `order`; ids it does not hold are ignored. */\n function placeVariables(collectionId: string, order: readonly string[]) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const held = new Set(collection.variableIds)\n const placed = order.filter((id) => held.has(id))\n const rest = collection.variableIds.filter((id) => !placed.includes(id))\n collection.variableIds = [...placed, ...rest]\n }\n\n /** Reorders a collection's variables in one undo step; the order is what files and lists show. */\n function setVariableOrder(collectionId: string, order: readonly string[]) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const previous = [...collection.variableIds]\n const next = [...order]\n placeVariables(collectionId, next)\n if (previous.join('\\n') === collection.variableIds.join('\\n')) return\n ctx.undo.push({\n label: 'Reorder variables',\n forward: () => {\n placeVariables(collectionId, next)\n ctx.requestRefresh()\n },\n inverse: () => {\n placeVariables(collectionId, previous)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n /** Copies a variable, values and token fields included, right after the original. */\n function duplicateVariable(id: string, name: string): string | undefined {\n const source = ctx.graph.variables.get(id)\n const collection = source && ctx.graph.variableCollections.get(source.collectionId)\n if (!source || !collection) return undefined\n const created = ctx.graph.createVariable(name, source.type, source.collectionId)\n const copy: Variable = { ...structuredClone(source), id: created.id, name }\n ctx.graph.addVariable(copy)\n const before = [...collection.variableIds]\n const order = before.filter((candidate) => candidate !== copy.id)\n order.splice(order.indexOf(id) + 1, 0, copy.id)\n placeVariables(collection.id, order)\n ctx.undo.push({\n label: 'Duplicate variable',\n forward: () => {\n ctx.graph.addVariable(structuredClone(copy))\n placeVariables(collection.id, order)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeVariable(copy.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n return copy.id\n }\n\n function renameVariable(id: string, newName: string) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const prevName = variable.name\n variable.name = newName\n ctx.undo.push({\n label: 'Rename variable',\n forward: () => {\n const v = ctx.graph.variables.get(id)\n if (v) v.name = newName\n ctx.requestRefresh()\n },\n inverse: () => {\n const v = ctx.graph.variables.get(id)\n if (v) v.name = prevName\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function addMode(collectionId: string, name?: string): string | undefined {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return undefined\n const modeName = name ?? `Mode ${collection.modes.length + 1}`\n const modeId = ctx.graph.createMode(collectionId, modeName)\n if (!modeId) return undefined\n ctx.undo.push({\n label: 'Add mode',\n forward: () => {\n ctx.graph.addMode(collectionId, modeId, modeName)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n return modeId\n }\n\n function removeMode(collectionId: string, modeId: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection || collection.modes.length <= 1) return\n const removedMode = collection.modes.find((m) => m.modeId === modeId)\n if (!removedMode) return\n const modeIndex = collection.modes.indexOf(removedMode)\n const savedMode = structuredClone(removedMode)\n const wasDefault = collection.defaultModeId === modeId\n const valueSnapshots = new Map<string, VariableValue>()\n for (const varId of collection.variableIds) {\n const v = ctx.graph.variables.get(varId)\n if (v?.valuesByMode[modeId] !== undefined) {\n valueSnapshots.set(varId, structuredClone(v.valuesByMode[modeId]))\n }\n }\n ctx.graph.removeMode(collectionId, modeId)\n ctx.undo.push({\n label: 'Remove mode',\n forward: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.addMode(collectionId, modeId, savedMode.name)\n const col = ctx.graph.variableCollections.get(collectionId)\n if (col) {\n // The mode comes back as it was, its sort position included, so it keeps its place.\n col.modes = col.modes\n .filter((m) => m.modeId !== modeId)\n .toSpliced(modeIndex, 0, structuredClone(savedMode))\n }\n for (const [varId, value] of valueSnapshots) {\n const v = ctx.graph.variables.get(varId)\n if (v) v.valuesByMode[modeId] = structuredClone(value)\n }\n if (wasDefault) ctx.graph.setDefaultMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n }\n\n function renameMode(collectionId: string, modeId: string, newName: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const mode = collection.modes.find((m) => m.modeId === modeId)\n if (!mode) return\n const prevName = mode.name\n ctx.graph.renameMode(collectionId, modeId, newName)\n ctx.undo.push({\n label: 'Rename mode',\n forward: () => {\n ctx.graph.renameMode(collectionId, modeId, newName)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.renameMode(collectionId, modeId, prevName)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function setDefaultMode(collectionId: string, modeId: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const prevDefault = collection.defaultModeId\n const prevModes = structuredClone(collection.modes)\n ctx.graph.setDefaultMode(collectionId, modeId)\n ctx.undo.push({\n label: 'Set default mode',\n forward: () => {\n ctx.graph.setDefaultMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n // Setting a default moves it first; undo restores the column order too. Look the\n // collection up again: undoing its removal in between restores a copy.\n const current = ctx.graph.variableCollections.get(collectionId)\n if (current) {\n current.modes = structuredClone(prevModes)\n current.defaultModeId = prevDefault\n }\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n }\n\n function duplicateMode(collectionId: string, sourceModeId: string): string | undefined {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return undefined\n const sourceMode = collection.modes.find((m) => m.modeId === sourceModeId)\n if (!sourceMode) return undefined\n const modeName = `${sourceMode.name} copy`\n const modeId = ctx.graph.createMode(collectionId, modeName, sourceModeId)\n if (!modeId) return undefined\n ctx.undo.push({\n label: 'Duplicate mode',\n forward: () => {\n ctx.graph.addMode(collectionId, modeId, modeName, sourceModeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n return modeId\n }\n\n function setActiveMode(collectionId: string, modeId: string) {\n ctx.graph.setActiveMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n\n /**\n * Sets one mode's value. Calls that share a `coalesceKey`, such as the steps of one color picker\n * drag, undo together.\n */\n function updateVariableValue(\n id: string,\n modeId: string,\n value: VariableValue,\n coalesceKey?: string\n ) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const previous = modeEntry(variable, modeId)\n const next: ModeEntry = {\n value: structuredClone(value),\n expression: tokenExpressionForValue(previous.expression, value)\n }\n const apply = (entry: ModeEntry) => {\n const target = ctx.graph.variables.get(id)\n if (target) setModeEntry(target, modeId, entry)\n refreshVariables({ variables: [id] })\n }\n apply(next)\n ctx.undo.push({\n label: 'Update variable value',\n forward: () => apply(next),\n inverse: () => apply(previous),\n coalesceKey\n })\n }\n\n /** Change token fields in one undo step; a field set to `undefined` is cleared. */\n function updateVariableToken(id: string, patch: Partial<VariableTokenFields>) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const previous = tokenFields(variable)\n const next = structuredClone(patch)\n const apply = (values: Partial<VariableTokenFields>) => {\n const target = ctx.graph.variables.get(id)\n if (!target) return\n const { description, ...fields } = structuredClone(values)\n // A cleared field is removed, not kept as a key set to `undefined`.\n for (const key of Object.keys(fields) as Array<keyof typeof fields>) {\n if (fields[key] === undefined) Reflect.deleteProperty(target, key)\n }\n Object.assign(\n target,\n omitBy(fields, (value) => value === undefined)\n )\n // Every variable has a description; clearing it leaves an empty one.\n if ('description' in values) target.description = description ?? ''\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Update variable token',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n /** The selector or query a mode applies under; an empty condition restores the default. */\n function setModeCondition(collectionId: string, modeId: string, condition: string | undefined) {\n const mode = ctx.graph.variableCollections\n .get(collectionId)\n ?.modes.find((candidate) => candidate.modeId === modeId)\n if (!mode) return\n const previous = mode.condition\n const next = condition?.trim() || undefined\n if (next === previous) return\n const apply = (value: string | undefined) => {\n const target = ctx.graph.variableCollections\n .get(collectionId)\n ?.modes.find((candidate) => candidate.modeId === modeId)\n if (target) target.condition = value\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Set mode condition',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n /**\n * Name the attribute manual modes are switched by; an empty name restores the default, and a\n * name no stylesheet can select on leaves the current one.\n */\n function setModeAttribute(collectionId: string, name: string | undefined) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const previous = collection.modeAttribute\n const next = name?.trim() || undefined\n if (next === previous || (next !== undefined && !isModeAttributeName(next))) return\n const apply = (value: string | undefined) => {\n const target = ctx.graph.variableCollections.get(collectionId)\n if (target) target.modeAttribute = value\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Set mode attribute',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n return {\n refreshVariables,\n updateVariableToken,\n setModeCondition,\n duplicateVariable,\n setVariableOrder,\n setModeAttribute,\n getVariablesByType,\n getVariable,\n resolveColorVariable,\n resolveNumberVariable,\n getVariablesForCollection,\n getCollection,\n getCollections,\n getCollectionCount,\n getVariableCount,\n renameCollection,\n addCollection,\n removeCollection,\n addVariable,\n removeVariable,\n renameVariable,\n updateVariableValue,\n addMode,\n removeMode,\n renameMode,\n setDefaultMode,\n duplicateMode,\n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AAK,KAAK,KAAA;EAClC,IAAI,SAAS,UAAU;EACvB,MAAM,SAAS,UAA8B;GAC3C,MAAM,SAAS,IAAI,MAAM,oBACtB,IAAI,YAAY,CAAC,EAChB,MAAM,MAAM,cAAc,UAAU,WAAW,MAAM;GACzD,IAAI,QAAQ,OAAO,YAAY;GAC/B,IAAI,eAAe;EACrB;EACA,MAAM,IAAI;EACV,IAAI,KAAK,KAAK;GACZ,OAAO;GACP,eAAe,MAAM,IAAI;GACzB,eAAe,MAAM,QAAQ;EAC/B,CAAC;CACH;;;;;CAMA,SAAS,iBAAiB,cAAsB,MAA0B;EACxE,MAAM,aAAa,IAAI,MAAM,oBAAoB,IAAI,YAAY;EACjE,IAAI,CAAC,YAAY;EACjB,MAAM,WAAW,WAAW;EAC5B,MAAM,OAAO,MAAM,KAAK,KAAK,KAAA;EAC7B,IAAI,SAAS,YAAa,SAAS,KAAA,KAAa,CAAC,oBAAoB,IAAI,GAAI;EAC7E,MAAM,SAAS,UAA8B;GAC3C,MAAM,SAAS,IAAI,MAAM,oBAAoB,IAAI,YAAY;GAC7D,IAAI,QAAQ,OAAO,gBAAgB;GACnC,IAAI,eAAe;EACrB;EACA,MAAM,IAAI;EACV,IAAI,KAAK,KAAK;GACZ,OAAO;GACP,eAAe,MAAM,IAAI;GACzB,eAAe,MAAM,QAAQ;EAC/B,CAAC;CACH;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"variables.js","names":[],"sources":["../../src/editor/variables.ts"],"sourcesContent":["import { omit, omitBy } from 'es-toolkit/object'\nimport { isEmptyObject } from 'es-toolkit/predicate'\n\nimport {\n isModeAttributeName,\n type TokenExpression,\n type Variable,\n type VariableCollection,\n type VariableType,\n type VariableValue\n} from '@pairdraw/scene-graph'\nimport { findInstanceAncestor } from '@pairdraw/scene-graph/instances'\nimport { cloneInstanceOverrideState } from '@pairdraw/scene-graph/instances/overrides'\nimport {\n tokenExpressionForValue,\n variableBindingOwner,\n type BindingScope\n} from '@pairdraw/scene-graph/variables'\n\nimport { reconcileVariableLayouts } from '#core/layout/variables'\n\nimport { loadBoundIcons } from './icons'\nimport { loadBoundFonts } from './text/bound-fonts'\nimport type { EditorContext } from './types'\n\n/** What a variable means as a design token beyond its values: how CSS and code read it. */\nexport type VariableTokenFields = Pick<\n Variable,\n 'unit' | 'expressions' | 'scopes' | 'codeSyntax' | 'description' | 'hiddenFromPublishing'\n>\n\n/** Every token field, unset ones included, so restoring it also clears what was added. */\nfunction tokenFields(variable: Variable): VariableTokenFields {\n const { unit, expressions, scopes, codeSyntax, description, hiddenFromPublishing } = variable\n return structuredClone({\n unit,\n expressions,\n scopes,\n codeSyntax,\n description,\n hiddenFromPublishing\n })\n}\n\n/** A mode's value with the CSS expression written for it, which the value must keep matching. */\ninterface ModeEntry {\n value: VariableValue | undefined\n expression: TokenExpression | undefined\n}\n\nfunction modeEntry(variable: Variable, modeId: string): ModeEntry {\n return structuredClone({\n value: variable.valuesByMode[modeId],\n expression: variable.expressions?.[modeId]\n })\n}\n\nfunction setModeEntry(variable: Variable, modeId: string, entry: ModeEntry) {\n const { value, expression } = structuredClone(entry)\n const values = omit(variable.valuesByMode, [modeId])\n variable.valuesByMode = value === undefined ? values : { ...values, [modeId]: value }\n const others = omit(variable.expressions ?? {}, [modeId])\n const expressions: Record<string, TokenExpression> = expression\n ? { ...others, [modeId]: expression }\n : others\n if (isEmptyObject(expressions)) delete variable.expressions\n else variable.expressions = expressions\n}\n\nexport function createVariableActions(ctx: EditorContext) {\n /**\n * Re-resolves the layers a change to what variables resolve to can reach: those bound to the\n * changed variables or to variables aliasing them. Every other variable change, such as adding,\n * renaming, reordering, or a token field, changes nothing the canvas draws, so it only refreshes\n * the views and leaves the canvas's recorded pictures in place. Records written into the graph\n * without an editor action, such as a collaborator's, take effect through it.\n */\n function refreshVariables(scope: BindingScope) {\n const changed = reconcileVariableLayouts(ctx.graph, scope)\n loadBoundFonts(ctx, changed)\n void loadBoundIcons(ctx, scope).catch((error: unknown) => {\n console.warn(\n 'Loading a bound icon failed:',\n error instanceof Error ? error.message : String(error)\n )\n })\n ctx.requestRender()\n }\n\n /** Every variable in a collection, the ones a change to its modes can reach. */\n function collectionScope(collectionId: string): BindingScope {\n return { variables: [...(ctx.graph.variableCollections.get(collectionId)?.variableIds ?? [])] }\n }\n\n function getVariablesByType(type: VariableType) {\n return ctx.graph.getVariablesByType(type)\n }\n\n function getVariable(id: string) {\n return ctx.graph.variables.get(id)\n }\n\n function resolveColorVariable(id: string) {\n return ctx.graph.resolveColorVariable(id)\n }\n\n function resolveNumberVariable(id: string) {\n return ctx.graph.resolveNumberVariable(id)\n }\n\n function getVariablesForCollection(collectionId: string) {\n return ctx.graph.getVariablesForCollection(collectionId)\n }\n\n function getCollection(id: string) {\n return ctx.graph.variableCollections.get(id)\n }\n\n function getCollections() {\n return [...ctx.graph.variableCollections.values()]\n }\n\n function getCollectionCount() {\n return ctx.graph.variableCollections.size\n }\n\n function getVariableCount() {\n return ctx.graph.variables.size\n }\n\n function renameCollection(id: string, newName: string) {\n const collection = ctx.graph.variableCollections.get(id)\n if (!collection) return\n const prevName = collection.name\n collection.name = newName\n ctx.undo.push({\n label: 'Rename collection',\n forward: () => {\n const c = ctx.graph.variableCollections.get(id)\n if (c) c.name = newName\n ctx.requestRefresh()\n },\n inverse: () => {\n const c = ctx.graph.variableCollections.get(id)\n if (c) c.name = prevName\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function addCollection(collection: VariableCollection) {\n ctx.graph.addCollection(collection)\n ctx.undo.push({\n label: 'Add collection',\n forward: () => {\n ctx.graph.addCollection(collection)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeCollection(collection.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function removeCollection(id: string) {\n const collection = ctx.graph.variableCollections.get(id)\n if (!collection) return\n const snapshot = structuredClone(collection)\n const scope: BindingScope = { variables: snapshot.variableIds }\n const variables = snapshot.variableIds\n .map((vid) => ctx.graph.variables.get(vid))\n .filter((v): v is Variable => v != null)\n .map((v) => structuredClone(v))\n const bindings = bindingSnapshots(snapshot.variableIds)\n // The mode the collection showed and the one each layer chose, which the removal drops, so\n // undo resolves the restored bindings to the values they had before it.\n const activeMode = ctx.graph.activeMode.get(id)\n const modeChoices = new Map<string, string>()\n for (const node of ctx.graph.getAllNodes()) {\n if (Object.hasOwn(node.variableModes, id)) modeChoices.set(node.id, node.variableModes[id])\n }\n ctx.graph.removeCollection(id)\n ctx.undo.push({\n label: 'Remove collection',\n forward: () => {\n ctx.graph.removeCollection(id)\n refreshVariables(scope)\n },\n inverse: () => {\n ctx.graph.addCollection(snapshot)\n for (const v of variables) ctx.graph.addVariable(v)\n if (activeMode !== undefined) ctx.graph.setActiveMode(id, activeMode)\n for (const [nodeId, modeId] of modeChoices) {\n const node = ctx.graph.getNode(nodeId)\n if (!node) continue\n ctx.graph.updateNode(nodeId, {\n variableModes: { ...node.variableModes, [id]: modeId }\n })\n }\n restoreBindings(bindings)\n refreshVariables(scope)\n }\n })\n refreshVariables(scope)\n }\n\n function addVariable(variable: Variable) {\n ctx.graph.addVariable(variable)\n ctx.undo.push({\n label: 'Add variable',\n forward: () => {\n ctx.graph.addVariable(variable)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeVariable(variable.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n /**\n * The bindings removing these variables strips from layers, and the instance overrides it\n * records, so undo can put both back. A layer keeps the value its variable last gave it.\n */\n function bindingSnapshots(ids: Iterable<string>) {\n const removed = new Set(ids)\n const snapshots = []\n for (const node of ctx.graph.getAllNodes()) {\n const entries = Object.entries(node.boundVariables).filter(([, id]) => removed.has(id))\n if (entries.length === 0) continue\n const owner = variableBindingOwner(ctx.graph, node)\n const nearest = findInstanceAncestor(ctx.graph, node.id)\n snapshots.push({\n nodeId: node.id,\n boundVariables: Object.fromEntries(entries),\n variableBindingScales: Object.fromEntries(\n entries\n .map(([field]) => field)\n .filter((field) => field in node.variableBindingScales)\n .map((field) => [field, node.variableBindingScales[field]])\n ),\n owners: new Map(\n [owner, ...(nearest ? [nearest] : [])].map((item) => [\n item.id,\n cloneInstanceOverrideState(item.instanceOverrides)\n ])\n )\n })\n }\n return snapshots\n }\n\n function restoreBindings(snapshots: ReturnType<typeof bindingSnapshots>) {\n for (const snapshot of snapshots) {\n for (const [ownerId, state] of snapshot.owners) {\n ctx.graph.updateNode(ownerId, { instanceOverrides: cloneInstanceOverrideState(state) })\n }\n const node = ctx.graph.getNode(snapshot.nodeId)\n if (!node) continue\n ctx.graph.updateNode(snapshot.nodeId, {\n boundVariables: { ...node.boundVariables, ...snapshot.boundVariables },\n variableBindingScales: { ...node.variableBindingScales, ...snapshot.variableBindingScales }\n })\n }\n }\n\n function removeVariable(id: string) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const snapshot = structuredClone(variable)\n const order = [...(ctx.graph.variableCollections.get(variable.collectionId)?.variableIds ?? [])]\n const bindings = bindingSnapshots([id])\n ctx.graph.removeVariable(id)\n ctx.undo.push({\n label: 'Remove variable',\n forward: () => {\n ctx.graph.removeVariable(id)\n refreshVariables({ variables: [id] })\n },\n // Undo puts the variable back where it was, not at the end of its collection, with the\n // bindings deleting it stripped.\n inverse: () => {\n ctx.graph.addVariable(structuredClone(snapshot))\n placeVariables(snapshot.collectionId, order)\n restoreBindings(bindings)\n refreshVariables({ variables: [id] })\n }\n })\n refreshVariables({ variables: [id] })\n }\n\n /** Puts a collection's variables in `order`; ids it does not hold are ignored. */\n function placeVariables(collectionId: string, order: readonly string[]) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const held = new Set(collection.variableIds)\n const placed = order.filter((id) => held.has(id))\n const rest = collection.variableIds.filter((id) => !placed.includes(id))\n collection.variableIds = [...placed, ...rest]\n }\n\n /** Reorders a collection's variables in one undo step; the order is what files and lists show. */\n function setVariableOrder(collectionId: string, order: readonly string[]) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const previous = [...collection.variableIds]\n const next = [...order]\n placeVariables(collectionId, next)\n if (previous.join('\\n') === collection.variableIds.join('\\n')) return\n ctx.undo.push({\n label: 'Reorder variables',\n forward: () => {\n placeVariables(collectionId, next)\n ctx.requestRefresh()\n },\n inverse: () => {\n placeVariables(collectionId, previous)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n /** Copies a variable, values and token fields included, right after the original. */\n function duplicateVariable(id: string, name: string): string | undefined {\n const source = ctx.graph.variables.get(id)\n const collection = source && ctx.graph.variableCollections.get(source.collectionId)\n if (!source || !collection) return undefined\n const created = ctx.graph.createVariable(name, source.type, source.collectionId)\n const copy: Variable = { ...structuredClone(source), id: created.id, name }\n ctx.graph.addVariable(copy)\n const before = [...collection.variableIds]\n const order = before.filter((candidate) => candidate !== copy.id)\n order.splice(order.indexOf(id) + 1, 0, copy.id)\n placeVariables(collection.id, order)\n ctx.undo.push({\n label: 'Duplicate variable',\n forward: () => {\n ctx.graph.addVariable(structuredClone(copy))\n placeVariables(collection.id, order)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.removeVariable(copy.id)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n return copy.id\n }\n\n function renameVariable(id: string, newName: string) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const prevName = variable.name\n variable.name = newName\n ctx.undo.push({\n label: 'Rename variable',\n forward: () => {\n const v = ctx.graph.variables.get(id)\n if (v) v.name = newName\n ctx.requestRefresh()\n },\n inverse: () => {\n const v = ctx.graph.variables.get(id)\n if (v) v.name = prevName\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function addMode(collectionId: string, name?: string): string | undefined {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return undefined\n const modeName = name ?? `Mode ${collection.modes.length + 1}`\n const modeId = ctx.graph.createMode(collectionId, modeName)\n if (!modeId) return undefined\n ctx.undo.push({\n label: 'Add mode',\n forward: () => {\n ctx.graph.addMode(collectionId, modeId, modeName)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n return modeId\n }\n\n function removeMode(collectionId: string, modeId: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection || collection.modes.length <= 1) return\n const removedMode = collection.modes.find((m) => m.modeId === modeId)\n if (!removedMode) return\n const modeIndex = collection.modes.indexOf(removedMode)\n const savedMode = structuredClone(removedMode)\n const wasDefault = collection.defaultModeId === modeId\n const valueSnapshots = new Map<string, VariableValue>()\n for (const varId of collection.variableIds) {\n const v = ctx.graph.variables.get(varId)\n if (v?.valuesByMode[modeId] !== undefined) {\n valueSnapshots.set(varId, structuredClone(v.valuesByMode[modeId]))\n }\n }\n ctx.graph.removeMode(collectionId, modeId)\n ctx.undo.push({\n label: 'Remove mode',\n forward: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.addMode(collectionId, modeId, savedMode.name)\n const col = ctx.graph.variableCollections.get(collectionId)\n if (col) {\n // The mode comes back as it was, its sort position included, so it keeps its place.\n col.modes = col.modes\n .filter((m) => m.modeId !== modeId)\n .toSpliced(modeIndex, 0, structuredClone(savedMode))\n }\n for (const [varId, value] of valueSnapshots) {\n const v = ctx.graph.variables.get(varId)\n if (v) v.valuesByMode[modeId] = structuredClone(value)\n }\n if (wasDefault) ctx.graph.setDefaultMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n }\n\n function renameMode(collectionId: string, modeId: string, newName: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const mode = collection.modes.find((m) => m.modeId === modeId)\n if (!mode) return\n const prevName = mode.name\n ctx.graph.renameMode(collectionId, modeId, newName)\n ctx.undo.push({\n label: 'Rename mode',\n forward: () => {\n ctx.graph.renameMode(collectionId, modeId, newName)\n ctx.requestRefresh()\n },\n inverse: () => {\n ctx.graph.renameMode(collectionId, modeId, prevName)\n ctx.requestRefresh()\n }\n })\n ctx.requestRefresh()\n }\n\n function setDefaultMode(collectionId: string, modeId: string) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const prevDefault = collection.defaultModeId\n const prevModes = structuredClone(collection.modes)\n ctx.graph.setDefaultMode(collectionId, modeId)\n ctx.undo.push({\n label: 'Set default mode',\n forward: () => {\n ctx.graph.setDefaultMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n // Setting a default moves it first; undo restores the column order too. Look the\n // collection up again: undoing its removal in between restores a copy.\n const current = ctx.graph.variableCollections.get(collectionId)\n if (current) {\n current.modes = structuredClone(prevModes)\n current.defaultModeId = prevDefault\n }\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n }\n\n function duplicateMode(collectionId: string, sourceModeId: string): string | undefined {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return undefined\n const sourceMode = collection.modes.find((m) => m.modeId === sourceModeId)\n if (!sourceMode) return undefined\n const modeName = `${sourceMode.name} copy`\n const modeId = ctx.graph.createMode(collectionId, modeName, sourceModeId)\n if (!modeId) return undefined\n ctx.undo.push({\n label: 'Duplicate mode',\n forward: () => {\n ctx.graph.addMode(collectionId, modeId, modeName, sourceModeId)\n refreshVariables(collectionScope(collectionId))\n },\n inverse: () => {\n ctx.graph.removeMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n })\n refreshVariables(collectionScope(collectionId))\n return modeId\n }\n\n function setActiveMode(collectionId: string, modeId: string) {\n ctx.graph.setActiveMode(collectionId, modeId)\n refreshVariables(collectionScope(collectionId))\n }\n\n /**\n * Sets one mode's value. Calls that share a `coalesceKey`, such as the steps of one color picker\n * drag, undo together.\n */\n function updateVariableValue(\n id: string,\n modeId: string,\n value: VariableValue,\n coalesceKey?: string\n ) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const previous = modeEntry(variable, modeId)\n const next: ModeEntry = {\n value: structuredClone(value),\n expression: tokenExpressionForValue(previous.expression, value)\n }\n const apply = (entry: ModeEntry) => {\n const target = ctx.graph.variables.get(id)\n if (target) setModeEntry(target, modeId, entry)\n refreshVariables({ variables: [id] })\n }\n apply(next)\n ctx.undo.push({\n label: 'Update variable value',\n forward: () => apply(next),\n inverse: () => apply(previous),\n coalesceKey\n })\n }\n\n /** Change token fields in one undo step; a field set to `undefined` is cleared. */\n function updateVariableToken(id: string, patch: Partial<VariableTokenFields>) {\n const variable = ctx.graph.variables.get(id)\n if (!variable) return\n const previous = tokenFields(variable)\n const next = structuredClone(patch)\n const apply = (values: Partial<VariableTokenFields>) => {\n const target = ctx.graph.variables.get(id)\n if (!target) return\n const { description, ...fields } = structuredClone(values)\n // A cleared field is removed, not kept as a key set to `undefined`.\n for (const key of Object.keys(fields) as Array<keyof typeof fields>) {\n if (fields[key] === undefined) Reflect.deleteProperty(target, key)\n }\n Object.assign(\n target,\n omitBy(fields, (value) => value === undefined)\n )\n // Every variable has a description; clearing it leaves an empty one.\n if ('description' in values) target.description = description ?? ''\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Update variable token',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n /** The selector or query a mode applies under; an empty condition restores the default. */\n function setModeCondition(collectionId: string, modeId: string, condition: string | undefined) {\n const mode = ctx.graph.variableCollections\n .get(collectionId)\n ?.modes.find((candidate) => candidate.modeId === modeId)\n if (!mode) return\n const previous = mode.condition\n const next = condition?.trim() || undefined\n if (next === previous) return\n const apply = (value: string | undefined) => {\n const target = ctx.graph.variableCollections\n .get(collectionId)\n ?.modes.find((candidate) => candidate.modeId === modeId)\n if (target) target.condition = value\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Set mode condition',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n /**\n * Name the attribute manual modes are switched by; an empty name restores the default, and a\n * name no stylesheet can select on leaves the current one.\n */\n function setModeAttribute(collectionId: string, name: string | undefined) {\n const collection = ctx.graph.variableCollections.get(collectionId)\n if (!collection) return\n const previous = collection.modeAttribute\n const next = name?.trim() || undefined\n if (next === previous || (next !== undefined && !isModeAttributeName(next))) return\n const apply = (value: string | undefined) => {\n const target = ctx.graph.variableCollections.get(collectionId)\n if (target) target.modeAttribute = value\n ctx.requestRefresh()\n }\n apply(next)\n ctx.undo.push({\n label: 'Set mode attribute',\n forward: () => apply(next),\n inverse: () => apply(previous)\n })\n }\n\n return {\n refreshVariables,\n updateVariableToken,\n setModeCondition,\n duplicateVariable,\n setVariableOrder,\n setModeAttribute,\n getVariablesByType,\n getVariable,\n resolveColorVariable,\n resolveNumberVariable,\n getVariablesForCollection,\n getCollection,\n getCollections,\n getCollectionCount,\n getVariableCount,\n renameCollection,\n addCollection,\n removeCollection,\n addVariable,\n removeVariable,\n renameVariable,\n updateVariableValue,\n addMode,\n removeMode,\n renameMode,\n setDefaultMode,\n duplicateMode,\n setActiveMode\n }\n}\n"],"mappings":";;;;;;;;;;;AAgCA,SAAS,YAAY,UAAyC;CAC5D,MAAM,EAAE,MAAM,aAAa,QAAQ,YAAY,aAAa,yBAAyB;CACrF,OAAO,gBAAgB;EACrB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAQA,SAAS,UAAU,UAAoB,QAA2B;CAChE,OAAO,gBAAgB;EACrB,OAAO,SAAS,aAAa;EAC7B,YAAY,SAAS,cAAc;CACrC,CAAC;AACH;AAEA,SAAS,aAAa,UAAoB,QAAgB,OAAkB;CAC1E,MAAM,EAAE,OAAO,eAAe,gBAAgB,KAAK;CACnD,MA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
+ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
2
+ //#region src/editor/variations/create.d.ts
3
+ /** Room around the versions inside their section, and between them. */
4
+ declare const VARIATION_SECTION_PADDING = 80;
5
+ declare const VARIATION_GAP = 80;
6
+ interface VariationRequest {
7
+ /** How many versions to make, 1 to {@link VARIATION_MAX_COUNT}. */
8
+ count: number;
9
+ /** What each version tries, named in its layer: `V2 · Calmer palette`. */
10
+ labels?: readonly string[];
11
+ }
12
+ interface CreatedVariations {
13
+ sectionId: string;
14
+ originalId: string;
15
+ /** The versions this request made, in order. */
16
+ versions: SceneNode[];
17
+ }
18
+ /** Why `nodeId` cannot be varied, or null when it can. */
19
+ declare function variationRefusal(graph: SceneGraph, nodeId: string): string | null;
20
+ /**
21
+ * Copies a layer `request.count` times into the section of variations beside it, made the first
22
+ * time, in a row after the versions already there. On a version, it copies that version into
23
+ * its own set. The original is not changed. The caller records the edit as one step.
24
+ */
25
+ declare function createVariations(graph: SceneGraph, nodeId: string, request: VariationRequest): CreatedVariations;
26
+ //#endregion
27
+ export { CreatedVariations, VARIATION_GAP, VARIATION_SECTION_PADDING, VariationRequest, createVariations, variationRefusal };
28
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","names":[],"sources":["../../../src/editor/variations/create.ts"],"mappings":";;;cAsBa;cACA;UAEI;;EAEf;;EAEA;;UAGe;EACf;EACA;;EAEA,UAAU;;;iBA2CI,iBAAiB,OAAO,YAAY;;;;;;iBA0GpC,iBACd,OAAO,YACP,gBACA,SAAS,mBACR"}