@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
@@ -0,0 +1,391 @@
1
+ import { defaultTokenImportOptions, planTokenImport } from "../plan/index.js";
2
+ import { plannedValue } from "../plan/changes.js";
3
+ import { compact } from "es-toolkit/array";
4
+ import { colorToHex8 } from "@pairdraw/scene-graph/color";
5
+ import { isEmptyObject } from "es-toolkit/predicate";
6
+ import { parseCSSName } from "@pairdraw/dom-css/export";
7
+ //#region src/io/formats/design-tokens/sync/drift.ts
8
+ /** Drift a person decides: the canvas changed or deleted the token, or both sides changed it. */
9
+ function driftNeedsChoice(drift) {
10
+ return drift.kind === "canvas" || drift.kind === "conflict" || drift.kind === "deleted";
11
+ }
12
+ /** Drift that needs nobody's choice: the code changed alone, or added the token. */
13
+ function followsCode(drift) {
14
+ return drift.kind === "code" || drift.kind === "added";
15
+ }
16
+ function roundNumber(value) {
17
+ return Math.round(value * 1e4) / 1e4;
18
+ }
19
+ /**
20
+ * A value as sync compares it: colors to 8-bit channels, numbers to four decimals, aliases by
21
+ * target, and a CSS expression by its text, whatever number an engine computed for it.
22
+ */
23
+ function tokenValueSignature(value, expression) {
24
+ if (expression) return `=${expression.replaceAll(/\s+/g, " ").trim()}`;
25
+ if (value === void 0) return "";
26
+ if (typeof value === "number") return String(roundNumber(value));
27
+ if (typeof value === "string") return JSON.stringify(value);
28
+ if (typeof value === "boolean") return String(value);
29
+ if ("aliasId" in value) return `@${value.aliasId}`;
30
+ if ("r" in value) return colorToHex8(value);
31
+ return JSON.stringify(value);
32
+ }
33
+ function describeValue(graph, value, expression) {
34
+ if (expression) return expression;
35
+ if (value === void 0) return "";
36
+ if (typeof value === "number") return String(roundNumber(value));
37
+ if (typeof value === "string") return value;
38
+ if (typeof value === "boolean") return String(value);
39
+ if ("aliasId" in value) return `{${graph.variables.get(value.aliasId)?.name ?? value.aliasId}}`;
40
+ if ("r" in value) return colorToHex8(value);
41
+ return JSON.stringify(value);
42
+ }
43
+ /** The code's value for a planned mode, with an alias to a variable the import adds named. */
44
+ function codeValue(plan, value) {
45
+ const resolved = plannedValue(plan, value);
46
+ if (resolved !== void 0 || value.kind !== "alias" || value.target.kind !== "planned") return { value: resolved };
47
+ const { collection, variable } = value.target;
48
+ return {
49
+ value: void 0,
50
+ added: plan.collections[collection]?.variables[variable]?.name
51
+ };
52
+ }
53
+ function codeSignature(plan, value, expression) {
54
+ const code = codeValue(plan, value);
55
+ return code.added === void 0 ? tokenValueSignature(code.value, expression) : `@+${code.added}`;
56
+ }
57
+ function describeCode(graph, plan, value, expression) {
58
+ const code = codeValue(plan, value);
59
+ return code.added === void 0 ? describeValue(graph, code.value, expression) : `{${code.added}}`;
60
+ }
61
+ function positionKey(collection, variable, mode) {
62
+ return mode === void 0 ? `${collection}:${variable}` : `${collection}:${variable}:${mode}`;
63
+ }
64
+ /** How a sync names a token across syncs: its collection and its name there. */
65
+ function tokenKey(collection, variable) {
66
+ return `${collection}/${variable}`;
67
+ }
68
+ /**
69
+ * The token a planned variable is in code. A token that states the code naming it, as a
70
+ * stylesheet's `var(--brand)` does, is named by that rather than by the variable's current name:
71
+ * a variable renamed on the canvas is still the code's `brand` on the next sync.
72
+ */
73
+ function plannedTokenKey(collection, planned) {
74
+ const codeName = parseCSSName(planned.codeSyntax?.WEB);
75
+ return tokenKey(collection.name, codeName ?? planned.name);
76
+ }
77
+ function syncPlan(graph, bundle) {
78
+ const options = {
79
+ ...defaultTokenImportOptions(graph, bundle),
80
+ styles: false
81
+ };
82
+ return planTokenImport(graph, bundle, options);
83
+ }
84
+ function driftKind(base, code, canvas) {
85
+ if (base === canvas) return "code";
86
+ if (base === code) return "canvas";
87
+ return "conflict";
88
+ }
89
+ function prepareBundle(graph, bundle) {
90
+ const plan = syncPlan(graph, bundle);
91
+ const prepared = {
92
+ plan,
93
+ positions: [],
94
+ added: [],
95
+ inCode: /* @__PURE__ */ new Set(),
96
+ names: /* @__PURE__ */ new Set()
97
+ };
98
+ plan.collections.forEach((collection, c) => {
99
+ collection.variables.forEach((planned, v) => {
100
+ prepared.names.add(planned.name);
101
+ const variable = planned.existingId ? graph.variables.get(planned.existingId) : void 0;
102
+ if (!variable) {
103
+ const at = planned.values.findIndex((value) => value !== void 0);
104
+ const first = planned.values.at(at);
105
+ prepared.added.push({
106
+ at: positionKey(c, v),
107
+ drift: {
108
+ kind: "added",
109
+ collection: collection.name,
110
+ variable: planned.name,
111
+ variableId: null,
112
+ mode: null,
113
+ modeId: null,
114
+ code: first && describeCode(graph, plan, first, planned.expressions[at])
115
+ }
116
+ });
117
+ return;
118
+ }
119
+ prepared.inCode.add(variable.id);
120
+ planned.values.forEach((value, m) => {
121
+ const target = collection.modes.at(m)?.target;
122
+ if (!value || !target) return;
123
+ const expression = planned.expressions[m];
124
+ const entry = {
125
+ collection: collection.name,
126
+ variable: variable.name,
127
+ variableId: variable.id,
128
+ mode: collection.modes[m].name,
129
+ code: describeCode(graph, plan, value, expression)
130
+ };
131
+ if (target.kind === "new") {
132
+ prepared.added.push({ drift: {
133
+ ...entry,
134
+ kind: "added",
135
+ modeId: null
136
+ } });
137
+ return;
138
+ }
139
+ prepared.positions.push({
140
+ key: positionKey(c, v, m),
141
+ variableId: variable.id,
142
+ modeId: target.modeId,
143
+ collection: collection.name,
144
+ variable: variable.name,
145
+ mode: collection.modes[m].name,
146
+ code: codeSignature(plan, value, expression),
147
+ codeText: entry.code
148
+ });
149
+ });
150
+ });
151
+ });
152
+ return prepared;
153
+ }
154
+ function canvasCache(graph) {
155
+ const seen = /* @__PURE__ */ new Map();
156
+ return { get(variable, modeId) {
157
+ const value = variable.valuesByMode[modeId];
158
+ const css = variable.expressions?.[modeId]?.css;
159
+ const key = `${variable.id}:${modeId}`;
160
+ const cached = seen.get(key);
161
+ if (cached && seen.has(key) && cached.value === value && cached.css === css) return cached;
162
+ const entry = {
163
+ value,
164
+ css,
165
+ signature: tokenValueSignature(value, css),
166
+ text: describeValue(graph, value, css)
167
+ };
168
+ seen.set(key, entry);
169
+ return entry;
170
+ } };
171
+ }
172
+ /** The id a deleted variable had, where the last sync recorded the token under this name. */
173
+ function deletedIds(graph, base) {
174
+ const ids = /* @__PURE__ */ new Map();
175
+ for (const [id, key] of Object.entries(base?.names ?? {})) if (!graph.variables.has(id)) ids.set(key, id);
176
+ return ids;
177
+ }
178
+ function classifyBundle(graph, prepared, base, canvas) {
179
+ const drift = [];
180
+ const decisions = /* @__PURE__ */ new Map();
181
+ const deleted = deletedIds(graph, base);
182
+ for (const { drift: entry, at } of prepared.added) {
183
+ const id = entry.variableId === null ? deleted.get(tokenKey(entry.collection, entry.variable)) : void 0;
184
+ const found = id ? {
185
+ ...entry,
186
+ kind: "deleted",
187
+ variableId: id
188
+ } : entry;
189
+ if (at) decisions.set(at, found);
190
+ if (id && isEmptyObject(base?.snapshot[id] ?? { kept: true })) continue;
191
+ drift.push(found);
192
+ }
193
+ for (const position of prepared.positions) {
194
+ const variable = graph.variables.get(position.variableId);
195
+ if (!variable) continue;
196
+ const current = canvas.get(variable, position.modeId);
197
+ if (current.signature === position.code) continue;
198
+ const found = {
199
+ kind: driftKind(base?.snapshot[position.variableId]?.[position.modeId], position.code, current.signature),
200
+ collection: position.collection,
201
+ variable: position.variable,
202
+ variableId: position.variableId,
203
+ mode: position.mode,
204
+ modeId: position.modeId,
205
+ code: position.codeText,
206
+ canvas: current.text
207
+ };
208
+ drift.push(found);
209
+ decisions.set(position.key, found);
210
+ }
211
+ return {
212
+ drift,
213
+ decisions
214
+ };
215
+ }
216
+ /**
217
+ * The import that brings one file in for the decisions made: values that match, or whose canvas
218
+ * side is kept, are left alone, and a variable deleted on the canvas is not made again.
219
+ */
220
+ function bundleImport(graph, plan, decisions, useCode) {
221
+ const next = structuredClone(plan);
222
+ const dropped = /* @__PURE__ */ new Set();
223
+ next.collections.forEach((collection, c) => {
224
+ collection.variables.forEach((planned, v) => {
225
+ const variable = planned.existingId ? graph.variables.get(planned.existingId) : void 0;
226
+ if (!variable) {
227
+ const decision = decisions.get(positionKey(c, v));
228
+ if (decision?.kind === "deleted" && !useCode(decision)) dropped.add(positionKey(c, v));
229
+ return;
230
+ }
231
+ collection.modes.forEach((mode, m) => {
232
+ if (mode.target.kind !== "existing") return;
233
+ const decision = decisions.get(positionKey(c, v, m));
234
+ if (decision && (decision.kind === "code" || useCode(decision))) return;
235
+ planned.values[m] = void 0;
236
+ planned.expressions[m] = variable.expressions?.[mode.target.modeId]?.css;
237
+ });
238
+ });
239
+ });
240
+ return dropped.size > 0 ? withoutVariables(next, dropped) : next;
241
+ }
242
+ /** A plan without some of the variables it adds; aliases to them are left out too. */
243
+ function withoutVariables(plan, dropped) {
244
+ const moved = /* @__PURE__ */ new Map();
245
+ for (const [c, collection] of plan.collections.entries()) {
246
+ let kept = 0;
247
+ for (const v of collection.variables.keys()) if (!dropped.has(positionKey(c, v))) moved.set(positionKey(c, v), kept++);
248
+ }
249
+ for (const [c, collection] of plan.collections.entries()) {
250
+ collection.variables = collection.variables.filter((_, v) => !dropped.has(positionKey(c, v)));
251
+ for (const variable of collection.variables) variable.values = variable.values.map((value) => {
252
+ if (value?.kind !== "alias" || value.target.kind !== "planned") return value;
253
+ const index = moved.get(positionKey(value.target.collection, value.target.variable));
254
+ return index === void 0 ? void 0 : {
255
+ kind: "alias",
256
+ target: {
257
+ ...value.target,
258
+ variable: index
259
+ }
260
+ };
261
+ });
262
+ }
263
+ return plan;
264
+ }
265
+ /**
266
+ * Compares linked code, read into one token bundle per file, with the canvas, and plans bringing
267
+ * it in. Collections and modes match by name and variables by name within them, as an import
268
+ * does. Without a snapshot nobody knows which side changed, so every difference is a conflict.
269
+ */
270
+ function planTokenSync(graph, bundles, base) {
271
+ const prepared = bundles.map((bundle) => prepareBundle(graph, bundle));
272
+ const canvas = canvasCache(graph);
273
+ const classified = prepared.map((bundle) => classifyBundle(graph, bundle, base, canvas));
274
+ const drift = [...classified.flatMap((entry) => entry.drift), ...goneFromCode(graph, prepared, base)];
275
+ return {
276
+ drift,
277
+ resolve(choose = () => void 0) {
278
+ const choices = new Map(drift.map((entry) => [entry, choose(entry)]));
279
+ const useCode = (entry) => choices.get(entry) === "code";
280
+ return {
281
+ plans: prepared.map((bundle, index) => bundleImport(graph, bundle.plan, classified[index].decisions, useCode)),
282
+ applied: drift.filter((entry) => followsCode(entry) || entry.kind !== "missing" && useCode(entry)).length,
283
+ undecided: drift.filter((entry) => !followsCode(entry) && !choices.get(entry))
284
+ };
285
+ }
286
+ };
287
+ }
288
+ /**
289
+ * Variables the last sync took from the code that no file declares now. A token counts as in
290
+ * code when any file declares its name, so light and dark values split across two stylesheets
291
+ * do not make each other's variables look gone.
292
+ */
293
+ function goneFromCode(graph, prepared, base) {
294
+ const drift = [];
295
+ for (const variableId of Object.keys(base?.snapshot ?? {})) {
296
+ const variable = graph.variables.get(variableId);
297
+ if (!variable || prepared.some((bundle) => bundle.inCode.has(variableId))) continue;
298
+ if (prepared.some((bundle) => bundle.names.has(variable.name))) continue;
299
+ drift.push(missingDrift(graph, variable));
300
+ }
301
+ return drift;
302
+ }
303
+ /**
304
+ * Drift against the canvas as it is whenever asked, for a view that follows edits: the code is
305
+ * read and planned once, and a value unchanged since the last call is not compared again.
306
+ */
307
+ function trackTokenDrift(graph, bundles, base) {
308
+ const prepared = bundles.map((bundle) => prepareBundle(graph, bundle));
309
+ const canvas = canvasCache(graph);
310
+ return () => [...prepared.flatMap((bundle) => classifyBundle(graph, bundle, base, canvas).drift), ...goneFromCode(graph, prepared, base)];
311
+ }
312
+ function missingDrift(graph, variable) {
313
+ return {
314
+ kind: "missing",
315
+ collection: graph.variableCollections.get(variable.collectionId)?.name ?? "",
316
+ variable: variable.name,
317
+ variableId: variable.id,
318
+ mode: null,
319
+ modeId: null
320
+ };
321
+ }
322
+ /** What the code's plans hold for the variables they match, mode by mode, files adding up. */
323
+ function codeSnapshot(plans, snapshot, names) {
324
+ for (const plan of plans) for (const collection of plan.collections) for (const planned of collection.variables) {
325
+ if (!planned.existingId) continue;
326
+ const modes = Object.hasOwn(snapshot, planned.existingId) ? snapshot[planned.existingId] : {};
327
+ planned.values.forEach((value, m) => {
328
+ const target = collection.modes.at(m)?.target;
329
+ if (!value || target?.kind !== "existing") return;
330
+ modes[target.modeId] = codeSignature(plan, value, planned.expressions[m]);
331
+ });
332
+ snapshot[planned.existingId] = modes;
333
+ names[planned.existingId] = plannedTokenKey(collection, planned);
334
+ }
335
+ }
336
+ /**
337
+ * A variable deleted on the canvas that the code still has stays recorded: with its last values
338
+ * while nobody decided, and with none once it was kept deleted, so it is not made again.
339
+ */
340
+ function keepDeleted(graph, plans, previous, waiting, record) {
341
+ const declared = new Set(plans.flatMap((plan) => plan.collections.flatMap((collection) => collection.variables.map((planned) => plannedTokenKey(collection, planned)))));
342
+ const current = new Set(Object.values(record.names));
343
+ for (const [id, key] of Object.entries(previous.names ?? {})) {
344
+ if (graph.variables.has(id) || current.has(key) || !declared.has(key)) continue;
345
+ record.names[id] = key;
346
+ record.snapshot[id] = waiting.has(id) && Object.hasOwn(previous.snapshot, id) ? { ...previous.snapshot[id] } : {};
347
+ }
348
+ }
349
+ /** Drift left undecided keeps what the last sync recorded for it. */
350
+ function keepUndecided(previous, undecided, record) {
351
+ const before = previous.snapshot;
352
+ for (const { variableId, modeId } of undecided) {
353
+ if (!variableId) continue;
354
+ const kept = Object.hasOwn(before, variableId) ? before[variableId] : void 0;
355
+ if (!modeId) {
356
+ if (kept) record.snapshot[variableId] = { ...kept };
357
+ const name = previous.names?.[variableId];
358
+ if (name) record.names[variableId] = name;
359
+ continue;
360
+ }
361
+ const modes = Object.hasOwn(record.snapshot, variableId) ? record.snapshot[variableId] : {};
362
+ if (kept && Object.hasOwn(kept, modeId)) modes[modeId] = kept[modeId];
363
+ else Reflect.deleteProperty(modes, modeId);
364
+ record.snapshot[variableId] = modes;
365
+ }
366
+ }
367
+ /**
368
+ * What the code holds now for the variables it matches, and the token each one is, to compare
369
+ * later syncs against. Files that set different modes of one variable add up. Drift left
370
+ * undecided keeps what `previous` had, so the next sync still sees both changes.
371
+ */
372
+ function tokenSnapshot(graph, bundles, previous = { snapshot: {} }, undecided = []) {
373
+ const record = {
374
+ snapshot: {},
375
+ names: {},
376
+ modes: modeNames(graph)
377
+ };
378
+ const plans = bundles.map((bundle) => syncPlan(graph, bundle));
379
+ codeSnapshot(plans, record.snapshot, record.names);
380
+ keepDeleted(graph, plans, previous, new Set(compact(undecided.map((entry) => entry.variableId))), record);
381
+ keepUndecided(previous, undecided, record);
382
+ return record;
383
+ }
384
+ /** Every collection's modes by id and name, to find them again when a format reassigns ids. */
385
+ function modeNames(graph) {
386
+ return Object.fromEntries([...graph.variableCollections.values()].map((collection) => [collection.name, Object.fromEntries(collection.modes.map((mode) => [mode.modeId, mode.name]))]));
387
+ }
388
+ //#endregion
389
+ export { driftNeedsChoice, planTokenSync, tokenSnapshot, tokenValueSignature, trackTokenDrift };
390
+
391
+ //# sourceMappingURL=drift.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift.js","names":[],"sources":["../../../../../src/io/formats/design-tokens/sync/drift.ts"],"sourcesContent":["import { compact } from 'es-toolkit/array'\nimport { isEmptyObject } from 'es-toolkit/predicate'\n\nimport { parseCSSName } from '@pairdraw/dom-css/export'\nimport type { SceneGraph, Variable, VariableValue } from '@pairdraw/scene-graph'\nimport { colorToHex8 } from '@pairdraw/scene-graph/color'\nimport type { TokenSource } from '@pairdraw/scene-graph/token-sources'\n\nimport {\n defaultTokenImportOptions,\n planTokenImport,\n type PlannedCollection,\n type PlannedValue,\n type PlannedVariable,\n type TokenImportPlan\n} from '#core/io/formats/design-tokens/plan'\nimport { plannedValue } from '#core/io/formats/design-tokens/plan/changes'\nimport type { DesignTokenBundle } from '#core/io/formats/design-tokens/read'\n\n/** What linked code held at the last sync, and the token each variable then was. */\nexport type TokenSyncBase = Pick<TokenSource, 'snapshot' | 'names' | 'modes'>\n\n/**\n * How a token differs between linked code and the canvas, against what the code held at the last\n * sync: changed in code only, on the canvas only, on both, new in code, no longer in code, or\n * deleted on the canvas while the code still has it.\n */\nexport type TokenDriftKind = 'code' | 'canvas' | 'conflict' | 'added' | 'missing' | 'deleted'\n\nexport interface TokenDrift {\n kind: TokenDriftKind\n collection: string\n variable: string\n /** Null for a variable the code adds; a deleted variable keeps the id it had. */\n variableId: string | null\n /** Null where the whole variable is added, gone, or deleted. */\n mode: string | null\n modeId: string | null\n /** The value as the code writes it, for people to read. */\n code?: string\n /** The value the canvas holds, for people to read. */\n canvas?: string\n}\n\n/** Which side a person keeps for a token that changed on the canvas, on both, or left the code. */\nexport type TokenSyncChoice = 'code' | 'canvas'\n\nexport interface TokenSyncResolution {\n /**\n * The imports that bring the code in, one per file, to apply in order. Values that already\n * match are left alone, and nothing is deleted: a token gone from code keeps its variable.\n */\n plans: TokenImportPlan[]\n /** How many tokens the imports write: those changed or added only in code, and those chosen. */\n applied: number\n /** Drift nobody chose a side for, which the next sync reports again. */\n undecided: TokenDrift[]\n}\n\nexport interface TokenSync {\n /** In the order of the code's files, collections, and tokens; tokens gone from code last. */\n drift: TokenDrift[]\n /**\n * Changes made only in code and tokens new in code always come in. A token changed or deleted\n * on the canvas, or changed on both sides, takes the code only where `choose` picks the code;\n * one gone from code stops being reported once a side is picked for it.\n */\n resolve(choose?: (drift: TokenDrift) => TokenSyncChoice | undefined): TokenSyncResolution\n}\n\n/** Drift a person decides: the canvas changed or deleted the token, or both sides changed it. */\nexport function driftNeedsChoice(drift: TokenDrift): boolean {\n return drift.kind === 'canvas' || drift.kind === 'conflict' || drift.kind === 'deleted'\n}\n\n/** Drift that needs nobody's choice: the code changed alone, or added the token. */\nfunction followsCode(drift: TokenDrift): boolean {\n return drift.kind === 'code' || drift.kind === 'added'\n}\n\nfunction roundNumber(value: number): number {\n // `.fig` stores numbers as float32, so a saved 0.1 must still read as 0.1.\n return Math.round(value * 1e4) / 1e4\n}\n\n/**\n * A value as sync compares it: colors to 8-bit channels, numbers to four decimals, aliases by\n * target, and a CSS expression by its text, whatever number an engine computed for it.\n */\nexport function tokenValueSignature(value: VariableValue | undefined, expression?: string): string {\n if (expression) return `=${expression.replaceAll(/\\s+/g, ' ').trim()}`\n if (value === undefined) return ''\n if (typeof value === 'number') return String(roundNumber(value))\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'boolean') return String(value)\n if ('aliasId' in value) return `@${value.aliasId}`\n if ('r' in value) return colorToHex8(value)\n return JSON.stringify(value)\n}\n\nfunction describeValue(\n graph: SceneGraph,\n value: VariableValue | undefined,\n expression?: string\n): string {\n if (expression) return expression\n if (value === undefined) return ''\n if (typeof value === 'number') return String(roundNumber(value))\n if (typeof value === 'string') return value\n if (typeof value === 'boolean') return String(value)\n if ('aliasId' in value) return `{${graph.variables.get(value.aliasId)?.name ?? value.aliasId}}`\n if ('r' in value) return colorToHex8(value)\n return JSON.stringify(value)\n}\n\n/** The code's value for a planned mode, with an alias to a variable the import adds named. */\nfunction codeValue(plan: TokenImportPlan, value: PlannedValue) {\n const resolved = plannedValue(plan, value)\n if (resolved !== undefined || value.kind !== 'alias' || value.target.kind !== 'planned')\n return { value: resolved }\n const { collection, variable } = value.target\n return { value: undefined, added: plan.collections[collection]?.variables[variable]?.name }\n}\n\nfunction codeSignature(plan: TokenImportPlan, value: PlannedValue, expression?: string) {\n const code = codeValue(plan, value)\n return code.added === undefined ? tokenValueSignature(code.value, expression) : `@+${code.added}`\n}\n\nfunction describeCode(\n graph: SceneGraph,\n plan: TokenImportPlan,\n value: PlannedValue,\n expression?: string\n) {\n const code = codeValue(plan, value)\n return code.added === undefined ? describeValue(graph, code.value, expression) : `{${code.added}}`\n}\n\nfunction positionKey(collection: number, variable: number, mode?: number): string {\n return mode === undefined ? `${collection}:${variable}` : `${collection}:${variable}:${mode}`\n}\n\n/** How a sync names a token across syncs: its collection and its name there. */\nfunction tokenKey(collection: string, variable: string): string {\n return `${collection}/${variable}`\n}\n\n/**\n * The token a planned variable is in code. A token that states the code naming it, as a\n * stylesheet's `var(--brand)` does, is named by that rather than by the variable's current name:\n * a variable renamed on the canvas is still the code's `brand` on the next sync.\n */\nfunction plannedTokenKey(collection: PlannedCollection, planned: PlannedVariable): string {\n const codeName = parseCSSName(planned.codeSyntax?.WEB)\n return tokenKey(collection.name, codeName ?? planned.name)\n}\n\nfunction syncPlan(graph: SceneGraph, bundle: DesignTokenBundle): TokenImportPlan {\n const options = { ...defaultTokenImportOptions(graph, bundle), styles: false }\n return planTokenImport(graph, bundle, options)\n}\n\nfunction driftKind(base: string | undefined, code: string, canvas: string): TokenDriftKind {\n if (base === canvas) return 'code'\n if (base === code) return 'canvas'\n return 'conflict'\n}\n\n/** A variable and mode the code sets, with the code's value as sync compares it. */\ninterface Position {\n key: string\n variableId: string\n modeId: string\n collection: string\n variable: string\n mode: string\n code: string\n codeText: string\n}\n\n/** One file's plan, read once, and what in it never depends on the canvas's values. */\ninterface PreparedBundle {\n plan: TokenImportPlan\n positions: Position[]\n /** Variables and modes the code adds, by plan position for whole variables. */\n added: Array<{ drift: TokenDrift; at?: string }>\n inCode: Set<string>\n /** Token names the file declares, in any collection. */\n names: Set<string>\n}\n\nfunction prepareBundle(graph: SceneGraph, bundle: DesignTokenBundle): PreparedBundle {\n const plan = syncPlan(graph, bundle)\n const prepared: PreparedBundle = {\n plan,\n positions: [],\n added: [],\n inCode: new Set(),\n names: new Set()\n }\n plan.collections.forEach((collection, c) => {\n collection.variables.forEach((planned, v) => {\n prepared.names.add(planned.name)\n const variable = planned.existingId ? graph.variables.get(planned.existingId) : undefined\n if (!variable) {\n const at = planned.values.findIndex((value) => value !== undefined)\n const first = planned.values.at(at)\n prepared.added.push({\n at: positionKey(c, v),\n drift: {\n kind: 'added',\n collection: collection.name,\n variable: planned.name,\n variableId: null,\n mode: null,\n modeId: null,\n code: first && describeCode(graph, plan, first, planned.expressions[at])\n }\n })\n return\n }\n prepared.inCode.add(variable.id)\n planned.values.forEach((value, m) => {\n const target = collection.modes.at(m)?.target\n if (!value || !target) return\n const expression = planned.expressions[m]\n const entry = {\n collection: collection.name,\n variable: variable.name,\n variableId: variable.id,\n mode: collection.modes[m].name,\n code: describeCode(graph, plan, value, expression)\n }\n if (target.kind === 'new') {\n prepared.added.push({ drift: { ...entry, kind: 'added', modeId: null } })\n return\n }\n prepared.positions.push({\n key: positionKey(c, v, m),\n variableId: variable.id,\n modeId: target.modeId,\n collection: collection.name,\n variable: variable.name,\n mode: collection.modes[m].name,\n code: codeSignature(plan, value, expression),\n codeText: entry.code\n })\n })\n })\n })\n return prepared\n}\n\n/** The canvas side of a position as sync compares it, recomputed only when its value changed. */\ninterface CanvasCache {\n get(variable: Variable, modeId: string): { signature: string; text: string }\n}\n\nfunction canvasCache(graph: SceneGraph): CanvasCache {\n const seen = new Map<\n string,\n { value: unknown; css: string | undefined; signature: string; text: string }\n >()\n return {\n get(variable, modeId) {\n const value = variable.valuesByMode[modeId]\n const css = variable.expressions?.[modeId]?.css\n const key = `${variable.id}:${modeId}`\n const cached = seen.get(key)\n // Values are replaced, not edited in place, so the same value means nothing changed. A\n // value that is missing (undefined) is cached as such, so the entry must exist to match.\n if (cached && seen.has(key) && cached.value === value && cached.css === css) return cached\n const entry = {\n value,\n css,\n signature: tokenValueSignature(value, css),\n text: describeValue(graph, value, css)\n }\n seen.set(key, entry)\n return entry\n }\n }\n}\n\n/** The id a deleted variable had, where the last sync recorded the token under this name. */\nfunction deletedIds(graph: SceneGraph, base: TokenSyncBase | undefined): Map<string, string> {\n const ids = new Map<string, string>()\n for (const [id, key] of Object.entries(base?.names ?? {}))\n if (!graph.variables.has(id)) ids.set(key, id)\n return ids\n}\n\ninterface Classified {\n drift: TokenDrift[]\n /** Drift by plan position, for the import that follows. */\n decisions: Map<string, TokenDrift>\n}\n\nfunction classifyBundle(\n graph: SceneGraph,\n prepared: PreparedBundle,\n base: TokenSyncBase | undefined,\n canvas: CanvasCache\n): Classified {\n const drift: TokenDrift[] = []\n const decisions = new Map<string, TokenDrift>()\n const deleted = deletedIds(graph, base)\n for (const { drift: entry, at } of prepared.added) {\n const id =\n entry.variableId === null\n ? deleted.get(tokenKey(entry.collection, entry.variable))\n : undefined\n const found: TokenDrift = id ? { ...entry, kind: 'deleted', variableId: id } : entry\n if (at) decisions.set(at, found)\n // Kept deleted at an earlier sync: it stays deleted, and is not reported again.\n if (id && isEmptyObject(base?.snapshot[id] ?? { kept: true })) continue\n drift.push(found)\n }\n for (const position of prepared.positions) {\n const variable = graph.variables.get(position.variableId)\n if (!variable) continue\n const current = canvas.get(variable, position.modeId)\n if (current.signature === position.code) continue\n const found: TokenDrift = {\n kind: driftKind(\n base?.snapshot[position.variableId]?.[position.modeId],\n position.code,\n current.signature\n ),\n collection: position.collection,\n variable: position.variable,\n variableId: position.variableId,\n mode: position.mode,\n modeId: position.modeId,\n code: position.codeText,\n canvas: current.text\n }\n drift.push(found)\n decisions.set(position.key, found)\n }\n return { drift, decisions }\n}\n\n/**\n * The import that brings one file in for the decisions made: values that match, or whose canvas\n * side is kept, are left alone, and a variable deleted on the canvas is not made again.\n */\nfunction bundleImport(\n graph: SceneGraph,\n plan: TokenImportPlan,\n decisions: ReadonlyMap<string, TokenDrift>,\n useCode: (drift: TokenDrift) => boolean\n): TokenImportPlan {\n const next = structuredClone(plan)\n const dropped = new Set<string>()\n next.collections.forEach((collection, c) => {\n collection.variables.forEach((planned, v) => {\n const variable = planned.existingId ? graph.variables.get(planned.existingId) : undefined\n if (!variable) {\n const decision = decisions.get(positionKey(c, v))\n if (decision?.kind === 'deleted' && !useCode(decision)) dropped.add(positionKey(c, v))\n return\n }\n collection.modes.forEach((mode, m) => {\n if (mode.target.kind !== 'existing') return\n const decision = decisions.get(positionKey(c, v, m))\n if (decision && (decision.kind === 'code' || useCode(decision))) return\n planned.values[m] = undefined\n // A value kept keeps its own expression, which the import writes back as it is.\n planned.expressions[m] = variable.expressions?.[mode.target.modeId]?.css\n })\n })\n })\n return dropped.size > 0 ? withoutVariables(next, dropped) : next\n}\n\n/** A plan without some of the variables it adds; aliases to them are left out too. */\nfunction withoutVariables(plan: TokenImportPlan, dropped: ReadonlySet<string>): TokenImportPlan {\n const moved = new Map<string, number>()\n for (const [c, collection] of plan.collections.entries()) {\n let kept = 0\n for (const v of collection.variables.keys())\n if (!dropped.has(positionKey(c, v))) moved.set(positionKey(c, v), kept++)\n }\n for (const [c, collection] of plan.collections.entries()) {\n collection.variables = collection.variables.filter((_, v) => !dropped.has(positionKey(c, v)))\n for (const variable of collection.variables) {\n variable.values = variable.values.map((value) => {\n if (value?.kind !== 'alias' || value.target.kind !== 'planned') return value\n const index = moved.get(positionKey(value.target.collection, value.target.variable))\n return index === undefined\n ? undefined\n : { kind: 'alias', target: { ...value.target, variable: index } }\n })\n }\n }\n return plan\n}\n\n/**\n * Compares linked code, read into one token bundle per file, with the canvas, and plans bringing\n * it in. Collections and modes match by name and variables by name within them, as an import\n * does. Without a snapshot nobody knows which side changed, so every difference is a conflict.\n */\nexport function planTokenSync(\n graph: SceneGraph,\n bundles: readonly DesignTokenBundle[],\n base?: TokenSyncBase\n): TokenSync {\n const prepared = bundles.map((bundle) => prepareBundle(graph, bundle))\n const canvas = canvasCache(graph)\n const classified = prepared.map((bundle) => classifyBundle(graph, bundle, base, canvas))\n const drift = [\n ...classified.flatMap((entry) => entry.drift),\n ...goneFromCode(graph, prepared, base)\n ]\n return {\n drift,\n resolve(choose = () => undefined) {\n const choices = new Map(drift.map((entry) => [entry, choose(entry)]))\n const useCode = (entry: TokenDrift) => choices.get(entry) === 'code'\n return {\n plans: prepared.map((bundle, index) =>\n bundleImport(graph, bundle.plan, classified[index].decisions, useCode)\n ),\n applied: drift.filter(\n (entry) => followsCode(entry) || (entry.kind !== 'missing' && useCode(entry))\n ).length,\n undecided: drift.filter((entry) => !followsCode(entry) && !choices.get(entry))\n }\n }\n }\n}\n\n/**\n * Variables the last sync took from the code that no file declares now. A token counts as in\n * code when any file declares its name, so light and dark values split across two stylesheets\n * do not make each other's variables look gone.\n */\nfunction goneFromCode(\n graph: SceneGraph,\n prepared: readonly PreparedBundle[],\n base: TokenSyncBase | undefined\n): TokenDrift[] {\n const drift: TokenDrift[] = []\n for (const variableId of Object.keys(base?.snapshot ?? {})) {\n const variable = graph.variables.get(variableId)\n if (!variable || prepared.some((bundle) => bundle.inCode.has(variableId))) continue\n if (prepared.some((bundle) => bundle.names.has(variable.name))) continue\n drift.push(missingDrift(graph, variable))\n }\n return drift\n}\n\n/**\n * Drift against the canvas as it is whenever asked, for a view that follows edits: the code is\n * read and planned once, and a value unchanged since the last call is not compared again.\n */\nexport function trackTokenDrift(\n graph: SceneGraph,\n bundles: readonly DesignTokenBundle[],\n base?: TokenSyncBase\n): () => TokenDrift[] {\n const prepared = bundles.map((bundle) => prepareBundle(graph, bundle))\n const canvas = canvasCache(graph)\n return () => [\n ...prepared.flatMap((bundle) => classifyBundle(graph, bundle, base, canvas).drift),\n ...goneFromCode(graph, prepared, base)\n ]\n}\n\nfunction missingDrift(graph: SceneGraph, variable: Variable): TokenDrift {\n return {\n kind: 'missing',\n collection: graph.variableCollections.get(variable.collectionId)?.name ?? '',\n variable: variable.name,\n variableId: variable.id,\n mode: null,\n modeId: null\n }\n}\n\ntype Snapshot = Record<string, Record<string, string>>\ntype Names = Record<string, string>\n\n/** What the code's plans hold for the variables they match, mode by mode, files adding up. */\nfunction codeSnapshot(plans: readonly TokenImportPlan[], snapshot: Snapshot, names: Names) {\n for (const plan of plans) {\n for (const collection of plan.collections) {\n for (const planned of collection.variables) {\n if (!planned.existingId) continue\n const modes = Object.hasOwn(snapshot, planned.existingId)\n ? snapshot[planned.existingId]\n : {}\n planned.values.forEach((value, m) => {\n const target = collection.modes.at(m)?.target\n if (!value || target?.kind !== 'existing') return\n modes[target.modeId] = codeSignature(plan, value, planned.expressions[m])\n })\n snapshot[planned.existingId] = modes\n names[planned.existingId] = plannedTokenKey(collection, planned)\n }\n }\n }\n}\n\n/**\n * A variable deleted on the canvas that the code still has stays recorded: with its last values\n * while nobody decided, and with none once it was kept deleted, so it is not made again.\n */\nfunction keepDeleted(\n graph: SceneGraph,\n plans: readonly TokenImportPlan[],\n previous: TokenSyncBase,\n waiting: ReadonlySet<string>,\n record: { snapshot: Snapshot; names: Names }\n) {\n const declared = new Set(\n plans.flatMap((plan) =>\n plan.collections.flatMap((collection) =>\n collection.variables.map((planned) => plannedTokenKey(collection, planned))\n )\n )\n )\n const current = new Set(Object.values(record.names))\n for (const [id, key] of Object.entries(previous.names ?? {})) {\n if (graph.variables.has(id) || current.has(key) || !declared.has(key)) continue\n record.names[id] = key\n record.snapshot[id] =\n waiting.has(id) && Object.hasOwn(previous.snapshot, id) ? { ...previous.snapshot[id] } : {}\n }\n}\n\n/** Drift left undecided keeps what the last sync recorded for it. */\nfunction keepUndecided(\n previous: TokenSyncBase,\n undecided: readonly TokenDrift[],\n record: { snapshot: Snapshot; names: Names }\n) {\n const before = previous.snapshot\n for (const { variableId, modeId } of undecided) {\n if (!variableId) continue\n const kept = Object.hasOwn(before, variableId) ? before[variableId] : undefined\n if (!modeId) {\n // Gone from code or deleted on the canvas: it stays recorded, and so stays reported.\n if (kept) record.snapshot[variableId] = { ...kept }\n const name = previous.names?.[variableId]\n if (name) record.names[variableId] = name\n continue\n }\n const modes = Object.hasOwn(record.snapshot, variableId) ? record.snapshot[variableId] : {}\n if (kept && Object.hasOwn(kept, modeId)) modes[modeId] = kept[modeId]\n else Reflect.deleteProperty(modes, modeId)\n record.snapshot[variableId] = modes\n }\n}\n\n/**\n * What the code holds now for the variables it matches, and the token each one is, to compare\n * later syncs against. Files that set different modes of one variable add up. Drift left\n * undecided keeps what `previous` had, so the next sync still sees both changes.\n */\nexport function tokenSnapshot(\n graph: SceneGraph,\n bundles: readonly DesignTokenBundle[],\n previous: TokenSyncBase = { snapshot: {} },\n undecided: readonly TokenDrift[] = []\n): Required<TokenSyncBase> {\n const record = { snapshot: {} as Snapshot, names: {} as Names, modes: modeNames(graph) }\n const plans = bundles.map((bundle) => syncPlan(graph, bundle))\n codeSnapshot(plans, record.snapshot, record.names)\n const waiting = new Set(compact(undecided.map((entry) => entry.variableId)))\n keepDeleted(graph, plans, previous, waiting, record)\n keepUndecided(previous, undecided, record)\n return record\n}\n\n/** Every collection's modes by id and name, to find them again when a format reassigns ids. */\nfunction modeNames(graph: SceneGraph): Record<string, Record<string, string>> {\n return Object.fromEntries(\n [...graph.variableCollections.values()].map((collection) => [\n collection.name,\n Object.fromEntries(collection.modes.map((mode) => [mode.modeId, mode.name]))\n ])\n )\n}\n"],"mappings":";;;;;;;;AAuEA,SAAgB,iBAAiB,OAA4B;CAC3D,OAAO,MAAM,SAAS,YAAY,MAAM,SAAS,cAAc,MAAM,SAAS;AAChF;;AAGA,SAAS,YAAY,OAA4B;CAC/C,OAAO,MAAM,SAAS,UAAU,MAAM,SAAS;AACjD;AAEA,SAAS,YAAY,OAAuB;CAE1C,OAAO,KAAK,MAAM,QAAQ,GAAG,IAAI;AACnC;;;;;AAMA,SAAgB,oBAAoB,OAAkC,YAA6B;CACjG,IAAI,YAAY,OAAO,IAAI,WAAW,WAAW,QAAQ,GAAG,CAAC,CAAC,KAAK;CACnE,IAAI,UAAU,KA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QAAQ;GAEX,IAAI,MAAM,OAAO,SAAS,cAAc,EAAE,GAAG,KAAK;GAClD,MAAM,OAAO,SAAS,QAAQ;GAC9B,IAAI,MAAM,OAAO,MAAM,cAAc;GACrC;EACF;EACA,MAAM,QAAQ,OAAO,OAAO,OAAO,UAAU,UAAU,IAAI,OAAO,SAAS,cAAc,CAAC;EAC1F,IAAI,QAAQ,OAAO,OAAO,MAAM,MAAM,GAAG,MAAM,UAAU,KAAK;OACzD,QAAQ,eAAe,OAAO,MAAM;EACzC,OAAO,SAAS,cAAc;CAChC;AACF;;;;;;AAOA,SAAgB,cACd,OACA,SACA,WAA0B,EAAE,UAAU,CAAC,EAAE,GACzC,YAAmC,CAAC,GACX;CACzB,MAAM,SAAS;EAAE,UAAU,CAAC;EAAe,OAAO,CAAC;EAAY,OAAO,UAAU,KAAK;CAAE;CACvF,MAAM,QAAQ,QAAQ,KAAK,WAAW,SAAS,OAAO,MAAM,CAAC;CAC7D,aAAa,OAAO,OAAO,UAAU,OAAO,KAAK;CAEjD,YAAY,OAAO,OAAO,UAAU,IADhB,IAAI,QAAQ,UAAU,KAAK,UAAU,MAAM,UAAU,CAAC,CAChC,GAAG,MAAM;CACnD,cAAc,UAAU,WAAW,MAAM;CACzC,OAAO;AACT;;AAGA,SAAS,UAAU,OAA2D;CAC5E,OAAO,OAAO,YACZ,CAAC,GAAG,MAAM,oBAAoB,OAAO,CAAC,CAAC,CAAC,KAAK,eAAe,CAC1D,WAAW,MACX,OAAO,YAAY,WAAW,MAAM,KAAK,SAAS,CAAC,KAAK,QAAQ,KAAK,IAAI,CAAC,CAAC,CAC7E,CAAC,CACH;AACF"}
@@ -0,0 +1,15 @@
1
+ import { DesignTokenBundle, DesignTokenSourceFile } from "../read.js";
2
+ import { DesignSystemIssue } from "../project.js";
3
+ import { SceneGraph } from "@pairdraw/scene-graph";
4
+ //#region src/io/formats/design-tokens/sync/files.d.ts
5
+ /**
6
+ * Linked code read into token bundles against the document as it is now: one per stylesheet,
7
+ * picked as a project folder import picks them, and one for all DTCG token files together.
8
+ */
9
+ declare function readTokenSourceFiles(graph: SceneGraph, files: readonly DesignTokenSourceFile[]): {
10
+ bundles: DesignTokenBundle[];
11
+ issues: DesignSystemIssue[];
12
+ };
13
+ //#endregion
14
+ export { readTokenSourceFiles };
15
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","names":[],"sources":["../../../../../src/io/formats/design-tokens/sync/files.ts"],"mappings":";;;;;;;;iBA0BgB,qBACd,OAAO,YACP,gBAAgB;EACb,SAAS;EAAqB,QAAQ"}
@@ -0,0 +1,35 @@
1
+ import { designSystemStylesheets, readDesignSystemStylesheet } from "../project.js";
2
+ import { readDesignTokens } from "../read.js";
3
+ import { partition } from "es-toolkit/array";
4
+ import { posix } from "pathe";
5
+ //#region src/io/formats/design-tokens/sync/files.ts
6
+ /** Stylesheets and the shadcn/ui manifest that names one; every other file is DTCG tokens. */
7
+ function isStylesheetSide(path) {
8
+ const name = posix.basename(path);
9
+ return name.endsWith(".css") || name === "components.json";
10
+ }
11
+ /**
12
+ * Linked code read into token bundles against the document as it is now: one per stylesheet,
13
+ * picked as a project folder import picks them, and one for all DTCG token files together.
14
+ */
15
+ function readTokenSourceFiles(graph, files) {
16
+ const [css, tokens] = partition(files, (file) => isStylesheetSide(file.path));
17
+ const { stylesheets, issues } = designSystemStylesheets({
18
+ files: css,
19
+ issues: []
20
+ });
21
+ const bundles = stylesheets.map((file) => readDesignSystemStylesheet(graph, file, issues));
22
+ if (tokens.length > 0) {
23
+ const bundle = readDesignTokens(tokens);
24
+ issues.push(...bundle.issues);
25
+ bundles.push(bundle);
26
+ }
27
+ return {
28
+ bundles,
29
+ issues
30
+ };
31
+ }
32
+ //#endregion
33
+ export { readTokenSourceFiles };
34
+
35
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","names":[],"sources":["../../../../../src/io/formats/design-tokens/sync/files.ts"],"sourcesContent":["import { partition } from 'es-toolkit/array'\nimport { posix } from 'pathe'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport {\n designSystemStylesheets,\n readDesignSystemStylesheet,\n type DesignSystemIssue\n} from '#core/io/formats/design-tokens/project'\nimport {\n readDesignTokens,\n type DesignTokenBundle,\n type DesignTokenSourceFile\n} from '#core/io/formats/design-tokens/read'\n\n/** Stylesheets and the shadcn/ui manifest that names one; every other file is DTCG tokens. */\nfunction isStylesheetSide(path: string): boolean {\n const name = posix.basename(path)\n return name.endsWith('.css') || name === 'components.json'\n}\n\n/**\n * Linked code read into token bundles against the document as it is now: one per stylesheet,\n * picked as a project folder import picks them, and one for all DTCG token files together.\n */\nexport function readTokenSourceFiles(\n graph: SceneGraph,\n files: readonly DesignTokenSourceFile[]\n): { bundles: DesignTokenBundle[]; issues: DesignSystemIssue[] } {\n const [css, tokens] = partition(files, (file) => isStylesheetSide(file.path))\n const { stylesheets, issues } = designSystemStylesheets({ files: css, issues: [] })\n const bundles = stylesheets.map((file) => readDesignSystemStylesheet(graph, file, issues))\n if (tokens.length > 0) {\n const bundle = readDesignTokens(tokens)\n issues.push(...bundle.issues)\n bundles.push(bundle)\n }\n return { bundles, issues }\n}\n"],"mappings":";;;;;;AAiBA,SAAS,iBAAiB,MAAuB;CAC/C,MAAM,OAAO,MAAM,SAAS,IAAI;CAChC,OAAO,KAAK,SAAS,MAAM,KAAK,SAAS;AAC3C;;;;;AAMA,SAAgB,qBACd,OACA,OAC+D;CAC/D,MAAM,CAAC,KAAK,UAAU,UAAU,QAAQ,SAAS,iBAAiB,KAAK,IAAI,CAAC;CAC5E,MAAM,EAAE,aAAa,WAAW,wBAAwB;EAAE,OAAO;EAAK,QAAQ,CAAC;CAAE,CAAC;CAClF,MAAM,UAAU,YAAY,KAAK,SAAS,2BAA2B,OAAO,MAAM,MAAM,CAAC;CACzF,IAAI,OAAO,SAAS,GAAG;EACrB,MAAM,SAAS,iBAAiB,MAAM;EACtC,OAAO,KAAK,GAAG,OAAO,MAAM;EAC5B,QAAQ,KAAK,MAAM;CACrB;CACA,OAAO;EAAE;EAAS;CAAO;AAC3B"}
@@ -24,6 +24,12 @@ declare function createEdge(graph: SceneGraph, parentId: string, edge: DrawIOCel
24
24
  * back for the caller to draw as text.
25
25
  */
26
26
  declare function bindEdge(graph: SceneGraph, { connector, edge, labels }: PendingEdge, layerOf: (cellId: string) => string | undefined): DrawIOCell[];
27
+ /**
28
+ * The edge cell a connector was read from, while nothing shaping it has been edited since: its
29
+ * own route, its line and label, or an end's layer and the layers that place it. Null once any
30
+ * of those changed, so the writer routes the connector from its live state.
31
+ */
32
+ declare function keptEdge(graph: SceneGraph, connector: SceneNode): NonNullable<SceneNode['source']['drawio']> | null;
27
33
  //#endregion
28
- export { PendingEdge, bindEdge, createEdge, labelPositionOf };
34
+ export { PendingEdge, bindEdge, createEdge, keptEdge, labelPositionOf };
29
35
  //# sourceMappingURL=edges.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edges.d.ts","names":[],"sources":["../../../../src/io/formats/drawio/edges.ts"],"mappings":";;;;;;;iBA6EgB,gBAAgB,YAAY;;UAU3B;EACf,WAAW;EACX,MAAM;;EAEN,QAAQ;;;;;;iBAOM,WACd,OAAO,YACP,kBACA,MAAM,YACN,QAAQ,eACP;;;;;;iBAyGa,SACd,OAAO,cACL,WAAW,MAAM,UAAU,aAC7B,UAAU,wCACT"}
1
+ {"version":3,"file":"edges.d.ts","names":[],"sources":["../../../../src/io/formats/drawio/edges.ts"],"mappings":";;;;;;;iBA6EgB,gBAAgB,YAAY;;UAU3B;EACf,WAAW;EACX,MAAM;;EAEN,QAAQ;;;;;;iBAOM,WACd,OAAO,YACP,kBACA,MAAM,YACN,QAAQ,eACP;;;;;;iBAyGa,SACd,OAAO,cACL,WAAW,MAAM,UAAU,aAC7B,UAAU,wCACT;;;;;;iBAoDa,SACd,OAAO,YACP,WAAW,YACV,YAAY"}
@@ -175,9 +175,62 @@ function bindEdge(graph, { connector, edge, labels }, layerOf) {
175
175
  }
176
176
  layoutConnector(graph, connector);
177
177
  bendConnectorThrough(graph, connector, edge.geometry.points);
178
+ rememberEdge(graph, connector, edge);
178
179
  return extra;
179
180
  }
181
+ /**
182
+ * Keeps the edge cell a connector was read from on its source metadata, so a write can return
183
+ * the route and style the author set while nothing about the connector was edited.
184
+ */
185
+ function rememberEdge(graph, connector, edge) {
186
+ const live = graph.getNode(connector.id);
187
+ if (!live) return;
188
+ live.source.drawio = {
189
+ styleNames: [...edge.style.names],
190
+ styleValues: { ...edge.style.values },
191
+ labelX: edge.geometry.x,
192
+ points: edge.geometry.points.map((point) => ({ ...point })),
193
+ sourcePoint: edge.geometry.sourcePoint ? { ...edge.geometry.sourcePoint } : null,
194
+ targetPoint: edge.geometry.targetPoint ? { ...edge.geometry.targetPoint } : null
195
+ };
196
+ }
197
+ /**
198
+ * The edge cell a connector was read from, while nothing shaping it has been edited since: its
199
+ * own route, its line and label, or an end's layer and the layers that place it. Null once any
200
+ * of those changed, so the writer routes the connector from its live state.
201
+ */
202
+ function keptEdge(graph, connector) {
203
+ const kept = connector.source.drawio;
204
+ if (!kept) return null;
205
+ const parts = connectorSublayers(graph, connector);
206
+ if (!parts) return null;
207
+ const appearsEdited = (node) => node.source.editedFields.some((field) => !isDerivedField(field) && !isPlacementField(field));
208
+ if (appearsEdited(connector) || appearsEdited(parts.line) || appearsEdited(parts.label)) return null;
209
+ for (const endpoint of [connector.connectorStart, connector.connectorEnd]) {
210
+ let layer = endpoint?.nodeId ? graph.getNode(endpoint.nodeId) : void 0;
211
+ while (layer && layer.type !== "CANVAS") {
212
+ if (layer.source.editedFields.some((field) => !isDerivedField(field))) return null;
213
+ layer = layer.parentId ? graph.getNode(layer.parentId) : void 0;
214
+ }
215
+ }
216
+ return kept;
217
+ }
218
+ /** Fields the layout pass computes; writing them is not an edit of the document. */
219
+ function isDerivedField(field) {
220
+ return field.startsWith("derived") || field === "textPicture";
221
+ }
222
+ /** A part's box, placed by its connector rather than set by hand. */
223
+ const PLACEMENT_FIELDS = {
224
+ x: true,
225
+ y: true,
226
+ width: true,
227
+ height: true,
228
+ rotation: true
229
+ };
230
+ function isPlacementField(field) {
231
+ return Object.hasOwn(PLACEMENT_FIELDS, field);
232
+ }
180
233
  //#endregion
181
- export { bindEdge, createEdge, labelPositionOf };
234
+ export { bindEdge, createEdge, keptEdge, labelPositionOf };
182
235
 
183
236
  //# sourceMappingURL=edges.js.map