@pairdraw/core 0.19.2 → 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 (847) 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/sampling.d.ts +13 -0
  20. package/dist/canvas/images/sampling.d.ts.map +1 -0
  21. package/dist/canvas/images/sampling.js +49 -0
  22. package/dist/canvas/images/sampling.js.map +1 -0
  23. package/dist/canvas/index.d.ts +2 -2
  24. package/dist/canvas/masks.d.ts +1 -1
  25. package/dist/canvas/masks.d.ts.map +1 -1
  26. package/dist/canvas/masks.js.map +1 -1
  27. package/dist/canvas/noise/render.d.ts +15 -0
  28. package/dist/canvas/noise/render.d.ts.map +1 -0
  29. package/dist/canvas/noise/render.js +56 -0
  30. package/dist/canvas/noise/render.js.map +1 -0
  31. package/dist/canvas/noise/shader.d.ts +43 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +161 -0
  34. package/dist/canvas/noise/shader.js.map +1 -0
  35. package/dist/canvas/noise/table.d.ts +13 -0
  36. package/dist/canvas/noise/table.d.ts.map +1 -0
  37. package/dist/canvas/noise/table.js +408 -0
  38. package/dist/canvas/noise/table.js.map +1 -0
  39. package/dist/canvas/noise/tile.d.ts +22 -0
  40. package/dist/canvas/noise/tile.d.ts.map +1 -0
  41. package/dist/canvas/noise/tile.js +73 -0
  42. package/dist/canvas/noise/tile.js.map +1 -0
  43. package/dist/canvas/outline-stroke.js +1 -1
  44. package/dist/canvas/overlays/auto-layout-hover.d.ts.map +1 -1
  45. package/dist/canvas/overlays/auto-layout-hover.js +31 -71
  46. package/dist/canvas/overlays/auto-layout-hover.js.map +1 -1
  47. package/dist/canvas/renderer/chunks/index.d.ts +1 -1
  48. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  49. package/dist/canvas/renderer/lifecycle.js +6 -0
  50. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  51. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  52. package/dist/canvas/renderer/pipeline.js +13 -1
  53. package/dist/canvas/renderer/pipeline.js.map +1 -1
  54. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  55. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  56. package/dist/canvas/renderer/play-scenes.js +40 -0
  57. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  58. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  59. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  60. package/dist/canvas/renderer/tiles/cache.js +32 -1
  61. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  62. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  63. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  64. package/dist/canvas/renderer/tiles/controller.js +18 -1
  65. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  66. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  67. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  68. package/dist/canvas/renderer/types.d.ts +18 -3
  69. package/dist/canvas/renderer/types.d.ts.map +1 -1
  70. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  71. package/dist/canvas/renderer/visual-bounds.js +1 -1
  72. package/dist/canvas/renderer.d.ts +22 -2
  73. package/dist/canvas/renderer.d.ts.map +1 -1
  74. package/dist/canvas/renderer.js +29 -1
  75. package/dist/canvas/renderer.js.map +1 -1
  76. package/dist/canvas/scene.d.ts +2 -1
  77. package/dist/canvas/scene.d.ts.map +1 -1
  78. package/dist/canvas/scene.js +41 -9
  79. package/dist/canvas/scene.js.map +1 -1
  80. package/dist/canvas/shadows/silhouette.js +1 -1
  81. package/dist/canvas/texture.d.ts +20 -0
  82. package/dist/canvas/texture.d.ts.map +1 -0
  83. package/dist/canvas/texture.js +100 -0
  84. package/dist/canvas/texture.js.map +1 -0
  85. package/dist/clipboard.js +16 -5
  86. package/dist/clipboard.js.map +1 -1
  87. package/dist/constants.d.ts +5 -1
  88. package/dist/constants.d.ts.map +1 -1
  89. package/dist/constants.js +5 -1
  90. package/dist/constants.js.map +1 -1
  91. package/dist/design-jsx/renderer.d.ts.map +1 -1
  92. package/dist/design-memory/check.d.ts +90 -0
  93. package/dist/design-memory/check.d.ts.map +1 -0
  94. package/dist/design-memory/check.js +281 -0
  95. package/dist/design-memory/check.js.map +1 -0
  96. package/dist/design-memory/describe.d.ts +37 -0
  97. package/dist/design-memory/describe.d.ts.map +1 -0
  98. package/dist/design-memory/describe.js +52 -0
  99. package/dist/design-memory/describe.js.map +1 -0
  100. package/dist/design-memory/distil.d.ts +22 -0
  101. package/dist/design-memory/distil.d.ts.map +1 -0
  102. package/dist/design-memory/distil.js +54 -0
  103. package/dist/design-memory/distil.js.map +1 -0
  104. package/dist/design-memory/document.d.ts +12 -0
  105. package/dist/design-memory/document.d.ts.map +1 -0
  106. package/dist/design-memory/document.js +64 -0
  107. package/dist/design-memory/document.js.map +1 -0
  108. package/dist/design-memory/guard.d.ts +48 -0
  109. package/dist/design-memory/guard.d.ts.map +1 -0
  110. package/dist/design-memory/guard.js +105 -0
  111. package/dist/design-memory/guard.js.map +1 -0
  112. package/dist/design-memory/index.d.ts +9 -0
  113. package/dist/design-memory/index.js +9 -0
  114. package/dist/design-memory/refusal.d.ts +32 -0
  115. package/dist/design-memory/refusal.d.ts.map +1 -0
  116. package/dist/design-memory/refusal.js +68 -0
  117. package/dist/design-memory/refusal.js.map +1 -0
  118. package/dist/design-memory/rules.d.ts +63 -0
  119. package/dist/design-memory/rules.d.ts.map +1 -0
  120. package/dist/design-memory/rules.js +224 -0
  121. package/dist/design-memory/rules.js.map +1 -0
  122. package/dist/design-memory/values.d.ts +28 -0
  123. package/dist/design-memory/values.d.ts.map +1 -0
  124. package/dist/design-memory/values.js +160 -0
  125. package/dist/design-memory/values.js.map +1 -0
  126. package/dist/editor/alignment.js +1 -1
  127. package/dist/editor/bridges/components.d.ts +2 -0
  128. package/dist/editor/bridges/components.d.ts.map +1 -1
  129. package/dist/editor/bridges/components.js +2 -0
  130. package/dist/editor/bridges/components.js.map +1 -1
  131. package/dist/editor/bridges/undo.d.ts +1 -1
  132. package/dist/editor/clipboard/assets.js +1 -1
  133. package/dist/editor/clipboard/export.d.ts.map +1 -1
  134. package/dist/editor/clipboard/export.js +16 -2
  135. package/dist/editor/clipboard/export.js.map +1 -1
  136. package/dist/editor/clipboard/placement.d.ts +1 -1
  137. package/dist/editor/clipboard/placement.js +1 -1
  138. package/dist/editor/components/instances.d.ts +2 -0
  139. package/dist/editor/components/instances.d.ts.map +1 -1
  140. package/dist/editor/components/instances.js +22 -1
  141. package/dist/editor/components/instances.js.map +1 -1
  142. package/dist/editor/components.d.ts +2 -0
  143. package/dist/editor/components.d.ts.map +1 -1
  144. package/dist/editor/connectors/attach.js +1 -1
  145. package/dist/editor/create.d.ts +27 -3
  146. package/dist/editor/create.d.ts.map +1 -1
  147. package/dist/editor/create.js +16 -60
  148. package/dist/editor/create.js.map +1 -1
  149. package/dist/editor/design-memory.d.ts +11 -0
  150. package/dist/editor/design-memory.d.ts.map +1 -0
  151. package/dist/editor/design-memory.js +40 -0
  152. package/dist/editor/design-memory.js.map +1 -0
  153. package/dist/editor/design-tokens.d.ts +4 -0
  154. package/dist/editor/design-tokens.d.ts.map +1 -1
  155. package/dist/editor/design-tokens.js +30 -1
  156. package/dist/editor/design-tokens.js.map +1 -1
  157. package/dist/editor/document-colors.d.ts +23 -0
  158. package/dist/editor/document-colors.d.ts.map +1 -0
  159. package/dist/editor/document-colors.js +53 -0
  160. package/dist/editor/document-colors.js.map +1 -0
  161. package/dist/editor/eyedropper.d.ts +47 -0
  162. package/dist/editor/eyedropper.d.ts.map +1 -0
  163. package/dist/editor/eyedropper.js +168 -0
  164. package/dist/editor/eyedropper.js.map +1 -0
  165. package/dist/editor/fonts.d.ts +9 -0
  166. package/dist/editor/fonts.d.ts.map +1 -0
  167. package/dist/editor/fonts.js +14 -0
  168. package/dist/editor/fonts.js.map +1 -0
  169. package/dist/editor/history/atomic-tool.d.ts +9 -2
  170. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  171. package/dist/editor/history/atomic-tool.js +6 -0
  172. package/dist/editor/history/atomic-tool.js.map +1 -1
  173. package/dist/editor/history/capture.d.ts +13 -0
  174. package/dist/editor/history/capture.d.ts.map +1 -0
  175. package/dist/editor/history/capture.js +28 -0
  176. package/dist/editor/history/capture.js.map +1 -0
  177. package/dist/editor/history/document-change.d.ts.map +1 -1
  178. package/dist/editor/history/document-change.js +2 -22
  179. package/dist/editor/history/document-change.js.map +1 -1
  180. package/dist/editor/history/edit.d.ts +7 -0
  181. package/dist/editor/history/edit.d.ts.map +1 -1
  182. package/dist/editor/history/edit.js +4 -2
  183. package/dist/editor/history/edit.js.map +1 -1
  184. package/dist/editor/history/subtree.d.ts +9 -0
  185. package/dist/editor/history/subtree.d.ts.map +1 -1
  186. package/dist/editor/history/subtree.js +12 -2
  187. package/dist/editor/history/subtree.js.map +1 -1
  188. package/dist/editor/index.d.ts +4 -2
  189. package/dist/editor/index.js +4 -2
  190. package/dist/editor/pages.d.ts +7 -5
  191. package/dist/editor/pages.d.ts.map +1 -1
  192. package/dist/editor/pages.js +35 -25
  193. package/dist/editor/pages.js.map +1 -1
  194. package/dist/editor/play/states.d.ts +3 -1
  195. package/dist/editor/play/states.d.ts.map +1 -1
  196. package/dist/editor/play/states.js +1 -1
  197. package/dist/editor/play/states.js.map +1 -1
  198. package/dist/editor/read-only/actions.js +4 -0
  199. package/dist/editor/read-only/actions.js.map +1 -1
  200. package/dist/editor/render-requests.d.ts +18 -0
  201. package/dist/editor/render-requests.d.ts.map +1 -0
  202. package/dist/editor/render-requests.js +76 -0
  203. package/dist/editor/render-requests.js.map +1 -0
  204. package/dist/editor/scale/rescale.d.ts +1 -1
  205. package/dist/editor/selection/overlays.d.ts.map +1 -1
  206. package/dist/editor/selection/overlays.js +1 -1
  207. package/dist/editor/selection/overlays.js.map +1 -1
  208. package/dist/editor/selection/read.d.ts +4 -0
  209. package/dist/editor/selection.d.ts +5 -0
  210. package/dist/editor/selection.d.ts.map +1 -1
  211. package/dist/editor/tool-registry.d.ts.map +1 -1
  212. package/dist/editor/tool-registry.js +2 -1
  213. package/dist/editor/tool-registry.js.map +1 -1
  214. package/dist/editor/types.d.ts +5 -1
  215. package/dist/editor/types.d.ts.map +1 -1
  216. package/dist/editor/variations/create.d.ts +28 -0
  217. package/dist/editor/variations/create.d.ts.map +1 -0
  218. package/dist/editor/variations/create.js +176 -0
  219. package/dist/editor/variations/create.js.map +1 -0
  220. package/dist/editor/variations/pick.d.ts +16 -0
  221. package/dist/editor/variations/pick.d.ts.map +1 -0
  222. package/dist/editor/variations/pick.js +23 -0
  223. package/dist/editor/variations/pick.js.map +1 -0
  224. package/dist/editor/variations.d.ts +28 -0
  225. package/dist/editor/variations.d.ts.map +1 -0
  226. package/dist/editor/variations.js +88 -0
  227. package/dist/editor/variations.js.map +1 -0
  228. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  229. package/dist/figma-api/accessors/reactions.js +4 -1
  230. package/dist/figma-api/accessors/reactions.js.map +1 -1
  231. package/dist/figma-api/accessors/text/index.js +3 -0
  232. package/dist/figma-api/accessors/text/index.js.map +1 -1
  233. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  234. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  235. package/dist/figma-api/accessors/text/opentype.js +28 -0
  236. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  237. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  238. package/dist/figma-api/accessors/visual.js +33 -0
  239. package/dist/figma-api/accessors/visual.js.map +1 -1
  240. package/dist/figma-api/effects.d.ts +79 -3
  241. package/dist/figma-api/effects.d.ts.map +1 -1
  242. package/dist/figma-api/effects.js +150 -9
  243. package/dist/figma-api/effects.js.map +1 -1
  244. package/dist/figma-api/index.d.ts +5 -0
  245. package/dist/figma-api/index.d.ts.map +1 -1
  246. package/dist/figma-api/index.js +6 -1
  247. package/dist/figma-api/index.js.map +1 -1
  248. package/dist/figma-api/overrides.d.ts +13 -1
  249. package/dist/figma-api/overrides.d.ts.map +1 -1
  250. package/dist/figma-api/overrides.js +196 -4
  251. package/dist/figma-api/overrides.js.map +1 -1
  252. package/dist/figma-api/paints.d.ts +3 -3
  253. package/dist/figma-api/paints.d.ts.map +1 -1
  254. package/dist/figma-api/paints.js +14 -4
  255. package/dist/figma-api/paints.js.map +1 -1
  256. package/dist/figma-api/proxy.d.ts +4 -1
  257. package/dist/figma-api/proxy.d.ts.map +1 -1
  258. package/dist/figma-api/proxy.js +1 -1
  259. package/dist/figma-api/proxy.js.map +1 -1
  260. package/dist/figma-api/reactions.d.ts +41 -13
  261. package/dist/figma-api/reactions.d.ts.map +1 -1
  262. package/dist/figma-api/reactions.js +113 -31
  263. package/dist/figma-api/reactions.js.map +1 -1
  264. package/dist/figma-api/render-bounds.js +1 -1
  265. package/dist/figma-api/surface.d.ts +6 -3
  266. package/dist/figma-api/surface.d.ts.map +1 -1
  267. package/dist/figma-api/surface.js +6 -2
  268. package/dist/figma-api/surface.js.map +1 -1
  269. package/dist/figma-api/transform.d.ts +1 -1
  270. package/dist/geometry/figma.d.ts +1 -1
  271. package/dist/geometry/image-crop.d.ts +1 -1
  272. package/dist/geometry/image-crop.js +1 -1
  273. package/dist/index.d.ts +4 -2
  274. package/dist/index.js +4 -2
  275. package/dist/io/formats/boolean-path.d.ts +19 -0
  276. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  277. package/dist/io/formats/boolean-path.js +47 -0
  278. package/dist/io/formats/boolean-path.js.map +1 -0
  279. package/dist/io/formats/design-tokens/decode.js +1 -1
  280. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  281. package/dist/io/formats/design-tokens/index.js +4 -1
  282. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  283. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  284. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  285. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  286. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  287. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  288. package/dist/io/formats/design-tokens/project.js +29 -8
  289. package/dist/io/formats/design-tokens/project.js.map +1 -1
  290. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  291. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  292. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  293. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  294. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  295. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  296. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  297. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  298. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  299. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  300. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  301. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  302. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  303. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  304. package/dist/io/formats/drawio/edges.d.ts +7 -1
  305. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  306. package/dist/io/formats/drawio/edges.js +54 -1
  307. package/dist/io/formats/drawio/edges.js.map +1 -1
  308. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  309. package/dist/io/formats/drawio/export.js +19 -2
  310. package/dist/io/formats/drawio/export.js.map +1 -1
  311. package/dist/io/formats/drawio/index.js +1 -0
  312. package/dist/io/formats/drawio/index.js.map +1 -1
  313. package/dist/io/formats/drawio/label.js +1 -1
  314. package/dist/io/formats/drawio/paint.js +1 -1
  315. package/dist/io/formats/drawio/placement.d.ts +1 -1
  316. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  317. package/dist/io/formats/fig/export/patch/index.js +5 -0
  318. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  319. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  320. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  321. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  322. package/dist/io/formats/html/import.d.ts.map +1 -1
  323. package/dist/io/formats/html/import.js +3 -1
  324. package/dist/io/formats/html/import.js.map +1 -1
  325. package/dist/io/formats/html/index.d.ts +2 -2
  326. package/dist/io/formats/html/index.d.ts.map +1 -1
  327. package/dist/io/formats/html/index.js +6 -4
  328. package/dist/io/formats/html/index.js.map +1 -1
  329. package/dist/io/formats/html/vectors.d.ts +2 -1
  330. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  331. package/dist/io/formats/html/vectors.js +3 -2
  332. package/dist/io/formats/html/vectors.js.map +1 -1
  333. package/dist/io/formats/mermaid/styles.js +1 -1
  334. package/dist/io/formats/pdf/document.d.ts +3 -1
  335. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  336. package/dist/io/formats/pdf/document.js +6 -3
  337. package/dist/io/formats/pdf/document.js.map +1 -1
  338. package/dist/io/formats/pdf/prepare.d.ts +1 -1
  339. package/dist/io/formats/pen/imports.d.ts +4 -1
  340. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  341. package/dist/io/formats/pen/imports.js.map +1 -1
  342. package/dist/io/formats/pen/index.d.ts.map +1 -1
  343. package/dist/io/formats/pen/index.js +31 -3
  344. package/dist/io/formats/pen/index.js.map +1 -1
  345. package/dist/io/formats/pptx/export.js +1 -1
  346. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  347. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  348. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  349. package/dist/io/formats/raster/adjusted-images.js +118 -0
  350. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  351. package/dist/io/formats/raster/headless.d.ts +11 -1
  352. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  353. package/dist/io/formats/raster/headless.js +4 -4
  354. package/dist/io/formats/raster/headless.js.map +1 -1
  355. package/dist/io/formats/raster/index.d.ts +2 -2
  356. package/dist/io/formats/raster/pixels.d.ts +7 -1
  357. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  358. package/dist/io/formats/raster/pixels.js.map +1 -1
  359. package/dist/io/formats/raster/render.d.ts.map +1 -1
  360. package/dist/io/formats/raster/render.js +4 -0
  361. package/dist/io/formats/raster/render.js.map +1 -1
  362. package/dist/io/formats/svg/defs.d.ts +5 -6
  363. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  364. package/dist/io/formats/svg/defs.js +1 -53
  365. package/dist/io/formats/svg/defs.js.map +1 -1
  366. package/dist/io/formats/svg/effects.d.ts +16 -0
  367. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  368. package/dist/io/formats/svg/effects.js +126 -0
  369. package/dist/io/formats/svg/effects.js.map +1 -0
  370. package/dist/io/formats/svg/export.d.ts +7 -1
  371. package/dist/io/formats/svg/export.d.ts.map +1 -1
  372. package/dist/io/formats/svg/export.js +174 -36
  373. package/dist/io/formats/svg/export.js.map +1 -1
  374. package/dist/io/formats/svg/filter.d.ts +27 -0
  375. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  376. package/dist/io/formats/svg/filter.js +44 -0
  377. package/dist/io/formats/svg/filter.js.map +1 -0
  378. package/dist/io/formats/svg/grain.d.ts +26 -0
  379. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  380. package/dist/io/formats/svg/grain.js +298 -0
  381. package/dist/io/formats/svg/grain.js.map +1 -0
  382. package/dist/io/formats/svg/strokes.d.ts +1 -1
  383. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  384. package/dist/io/formats/svg/strokes.js +1 -2
  385. package/dist/io/formats/svg/strokes.js.map +1 -1
  386. package/dist/io/formats/svg/text/import.js +1 -1
  387. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  388. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  389. package/dist/io/formats/svg/text/layout.js +6 -3
  390. package/dist/io/formats/svg/text/layout.js.map +1 -1
  391. package/dist/io/formats/video/composite.d.ts +18 -0
  392. package/dist/io/formats/video/composite.d.ts.map +1 -0
  393. package/dist/io/formats/video/composite.js +79 -0
  394. package/dist/io/formats/video/composite.js.map +1 -0
  395. package/dist/io/formats/video/formats.d.ts +29 -0
  396. package/dist/io/formats/video/formats.d.ts.map +1 -0
  397. package/dist/io/formats/video/formats.js +43 -0
  398. package/dist/io/formats/video/formats.js.map +1 -0
  399. package/dist/io/formats/video/gif.d.ts +13 -0
  400. package/dist/io/formats/video/gif.d.ts.map +1 -0
  401. package/dist/io/formats/video/gif.js +56 -0
  402. package/dist/io/formats/video/gif.js.map +1 -0
  403. package/dist/io/formats/video/index.d.ts +9 -0
  404. package/dist/io/formats/video/index.js +9 -0
  405. package/dist/io/formats/video/plan.d.ts +64 -0
  406. package/dist/io/formats/video/plan.d.ts.map +1 -0
  407. package/dist/io/formats/video/plan.js +90 -0
  408. package/dist/io/formats/video/plan.js.map +1 -0
  409. package/dist/io/formats/video/record.d.ts +36 -0
  410. package/dist/io/formats/video/record.d.ts.map +1 -0
  411. package/dist/io/formats/video/record.js +154 -0
  412. package/dist/io/formats/video/record.js.map +1 -0
  413. package/dist/io/formats/video/sink.d.ts +29 -0
  414. package/dist/io/formats/video/sink.d.ts.map +1 -0
  415. package/dist/io/formats/video/sink.js +16 -0
  416. package/dist/io/formats/video/sink.js.map +1 -0
  417. package/dist/io/formats/video/size.d.ts +19 -0
  418. package/dist/io/formats/video/size.d.ts.map +1 -0
  419. package/dist/io/formats/video/size.js +26 -0
  420. package/dist/io/formats/video/size.js.map +1 -0
  421. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  422. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  423. package/dist/io/formats/video/webcodecs.js +74 -0
  424. package/dist/io/formats/video/webcodecs.js.map +1 -0
  425. package/dist/io/formats.d.ts.map +1 -1
  426. package/dist/io/formats.js +40 -11
  427. package/dist/io/formats.js.map +1 -1
  428. package/dist/io/types.d.ts +19 -4
  429. package/dist/io/types.d.ts.map +1 -1
  430. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  431. package/dist/layout/auto-layout-handles.d.ts +66 -0
  432. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  433. package/dist/layout/auto-layout-handles.js +291 -0
  434. package/dist/layout/auto-layout-handles.js.map +1 -0
  435. package/dist/layout.d.ts +3 -2
  436. package/dist/layout.d.ts.map +1 -1
  437. package/dist/layout.js +2 -1
  438. package/dist/layout.js.map +1 -1
  439. package/dist/lint/fixes.d.ts.map +1 -1
  440. package/dist/lint/fixes.js +9 -3
  441. package/dist/lint/fixes.js.map +1 -1
  442. package/dist/lint/index.d.ts +3 -2
  443. package/dist/lint/index.js +2 -1
  444. package/dist/lint/linter.d.ts +12 -0
  445. package/dist/lint/linter.d.ts.map +1 -1
  446. package/dist/lint/linter.js +110 -8
  447. package/dist/lint/linter.js.map +1 -1
  448. package/dist/lint/presets.d.ts.map +1 -1
  449. package/dist/lint/presets.js +2 -0
  450. package/dist/lint/presets.js.map +1 -1
  451. package/dist/lint/rules/design-memory.d.ts +15 -0
  452. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  453. package/dist/lint/rules/design-memory.js +90 -0
  454. package/dist/lint/rules/design-memory.js.map +1 -0
  455. package/dist/lint/rules/index.d.ts +6 -5
  456. package/dist/lint/rules/index.d.ts.map +1 -1
  457. package/dist/lint/rules/index.js +6 -2
  458. package/dist/lint/rules/index.js.map +1 -1
  459. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  460. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  461. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  462. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  463. package/dist/lint/types.d.ts +25 -2
  464. package/dist/lint/types.d.ts.map +1 -1
  465. package/dist/node/video.d.ts +12 -0
  466. package/dist/node/video.d.ts.map +1 -0
  467. package/dist/node/video.js +206 -0
  468. package/dist/node/video.js.map +1 -0
  469. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  470. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  471. package/dist/pairdraw-api/design-memory.js +39 -0
  472. package/dist/pairdraw-api/design-memory.js.map +1 -0
  473. package/dist/pairdraw-api/index.d.ts +45 -1
  474. package/dist/pairdraw-api/index.d.ts.map +1 -1
  475. package/dist/pairdraw-api/index.js +55 -2
  476. package/dist/pairdraw-api/index.js.map +1 -1
  477. package/dist/pairdraw-api/nodes.d.ts +12 -1
  478. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  479. package/dist/pairdraw-api/nodes.js +28 -1
  480. package/dist/pairdraw-api/nodes.js.map +1 -1
  481. package/dist/pairdraw-api/variations.d.ts +48 -0
  482. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  483. package/dist/pairdraw-api/variations.js +76 -0
  484. package/dist/pairdraw-api/variations.js.map +1 -0
  485. package/dist/prototype/easing.d.ts +13 -0
  486. package/dist/prototype/easing.d.ts.map +1 -0
  487. package/dist/prototype/easing.js +36 -0
  488. package/dist/prototype/easing.js.map +1 -0
  489. package/dist/prototype/frames.d.ts +10 -0
  490. package/dist/prototype/frames.d.ts.map +1 -0
  491. package/dist/prototype/frames.js +12 -0
  492. package/dist/prototype/frames.js.map +1 -0
  493. package/dist/prototype/hit.d.ts +17 -0
  494. package/dist/prototype/hit.d.ts.map +1 -0
  495. package/dist/prototype/hit.js +45 -0
  496. package/dist/prototype/hit.js.map +1 -0
  497. package/dist/prototype/index.d.ts +14 -0
  498. package/dist/prototype/index.js +14 -0
  499. package/dist/prototype/pointer.d.ts +63 -0
  500. package/dist/prototype/pointer.d.ts.map +1 -0
  501. package/dist/prototype/pointer.js +104 -0
  502. package/dist/prototype/pointer.js.map +1 -0
  503. package/dist/prototype/reactions.d.ts +45 -0
  504. package/dist/prototype/reactions.d.ts.map +1 -0
  505. package/dist/prototype/reactions.js +122 -0
  506. package/dist/prototype/reactions.js.map +1 -0
  507. package/dist/prototype/scene.d.ts +35 -0
  508. package/dist/prototype/scene.d.ts.map +1 -0
  509. package/dist/prototype/scene.js +86 -0
  510. package/dist/prototype/scene.js.map +1 -0
  511. package/dist/prototype/scenes.d.ts +81 -0
  512. package/dist/prototype/scenes.d.ts.map +1 -0
  513. package/dist/prototype/scenes.js +175 -0
  514. package/dist/prototype/scenes.js.map +1 -0
  515. package/dist/prototype/scroll.d.ts +48 -0
  516. package/dist/prototype/scroll.d.ts.map +1 -0
  517. package/dist/prototype/scroll.js +159 -0
  518. package/dist/prototype/scroll.js.map +1 -0
  519. package/dist/prototype/session.d.ts +71 -0
  520. package/dist/prototype/session.d.ts.map +1 -0
  521. package/dist/prototype/session.js +135 -0
  522. package/dist/prototype/session.js.map +1 -0
  523. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  524. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  525. package/dist/prototype/smart-animate/animation.js +212 -0
  526. package/dist/prototype/smart-animate/animation.js.map +1 -0
  527. package/dist/prototype/smart-animate/match.d.ts +24 -0
  528. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  529. package/dist/prototype/smart-animate/match.js +72 -0
  530. package/dist/prototype/smart-animate/match.js.map +1 -0
  531. package/dist/prototype/snapshot.d.ts +19 -0
  532. package/dist/prototype/snapshot.d.ts.map +1 -0
  533. package/dist/prototype/snapshot.js +56 -0
  534. package/dist/prototype/snapshot.js.map +1 -0
  535. package/dist/prototype/timeline.d.ts +132 -0
  536. package/dist/prototype/timeline.d.ts.map +1 -0
  537. package/dist/prototype/timeline.js +260 -0
  538. package/dist/prototype/timeline.js.map +1 -0
  539. package/dist/rpc/read-commands.js +1 -1
  540. package/dist/text/font/features.d.ts +9 -0
  541. package/dist/text/font/features.d.ts.map +1 -0
  542. package/dist/text/font/features.js +27 -0
  543. package/dist/text/font/features.js.map +1 -0
  544. package/dist/text/font/manager.d.ts +12 -0
  545. package/dist/text/font/manager.d.ts.map +1 -1
  546. package/dist/text/font/manager.js +60 -1
  547. package/dist/text/font/manager.js.map +1 -1
  548. package/dist/text/index.d.ts +10 -8
  549. package/dist/text/index.js +3 -1
  550. package/dist/text/replace-fonts.d.ts +41 -0
  551. package/dist/text/replace-fonts.d.ts.map +1 -0
  552. package/dist/text/replace-fonts.js +121 -0
  553. package/dist/text/replace-fonts.js.map +1 -0
  554. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  555. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  556. package/dist/tools/analyze/responsive/index.js +203 -0
  557. package/dist/tools/analyze/responsive/index.js.map +1 -0
  558. package/dist/tools/analyze.d.ts +2 -1
  559. package/dist/tools/analyze.js +2 -1
  560. package/dist/tools/codegen/token-sync.d.ts +7 -0
  561. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  562. package/dist/tools/codegen/token-sync.js +85 -0
  563. package/dist/tools/codegen/token-sync.js.map +1 -0
  564. package/dist/tools/codegen/tokens.d.ts +1 -1
  565. package/dist/tools/codegen.d.ts +2 -1
  566. package/dist/tools/codegen.js +2 -1
  567. package/dist/tools/create/basic.js +1 -1
  568. package/dist/tools/create/behaviours.js +1 -1
  569. package/dist/tools/create/components.d.ts.map +1 -1
  570. package/dist/tools/create/components.js +4 -0
  571. package/dist/tools/create/components.js.map +1 -1
  572. package/dist/tools/create/html.js +3 -2
  573. package/dist/tools/create/html.js.map +1 -1
  574. package/dist/tools/create/icons.d.ts.map +1 -1
  575. package/dist/tools/create/icons.js +2 -1
  576. package/dist/tools/create/icons.js.map +1 -1
  577. package/dist/tools/create/mermaid.js +2 -1
  578. package/dist/tools/create/mermaid.js.map +1 -1
  579. package/dist/tools/create/render.js +1 -1
  580. package/dist/tools/create/svg.js +2 -1
  581. package/dist/tools/create/svg.js.map +1 -1
  582. package/dist/tools/create/vector.js +1 -1
  583. package/dist/tools/design-memory.d.ts +8 -0
  584. package/dist/tools/design-memory.d.ts.map +1 -0
  585. package/dist/tools/design-memory.js +68 -0
  586. package/dist/tools/design-memory.js.map +1 -0
  587. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  588. package/dist/tools/image-ai/generate.js +3 -1
  589. package/dist/tools/image-ai/generate.js.map +1 -1
  590. package/dist/tools/index.d.ts +2 -1
  591. package/dist/tools/index.js +2 -1
  592. package/dist/tools/modify/fonts.d.ts +6 -0
  593. package/dist/tools/modify/fonts.d.ts.map +1 -0
  594. package/dist/tools/modify/fonts.js +27 -0
  595. package/dist/tools/modify/fonts.js.map +1 -0
  596. package/dist/tools/modify/paint.js +1 -1
  597. package/dist/tools/modify/reactions.d.ts.map +1 -1
  598. package/dist/tools/modify/reactions.js +3 -3
  599. package/dist/tools/modify/reactions.js.map +1 -1
  600. package/dist/tools/modify/text.d.ts.map +1 -1
  601. package/dist/tools/modify/text.js +26 -5
  602. package/dist/tools/modify/text.js.map +1 -1
  603. package/dist/tools/modify/update.d.ts +10 -1
  604. package/dist/tools/modify/update.d.ts.map +1 -1
  605. package/dist/tools/modify/update.js +34 -3
  606. package/dist/tools/modify/update.js.map +1 -1
  607. package/dist/tools/modify.d.ts +2 -1
  608. package/dist/tools/modify.js +2 -1
  609. package/dist/tools/read/fonts.d.ts.map +1 -1
  610. package/dist/tools/read/fonts.js +17 -2
  611. package/dist/tools/read/fonts.js.map +1 -1
  612. package/dist/tools/read/libraries.js +2 -1
  613. package/dist/tools/read/libraries.js.map +1 -1
  614. package/dist/tools/read/space.d.ts +3 -1
  615. package/dist/tools/read/space.d.ts.map +1 -1
  616. package/dist/tools/read/space.js +4 -3
  617. package/dist/tools/read/space.js.map +1 -1
  618. package/dist/tools/registry/core.d.ts +1 -1
  619. package/dist/tools/registry/core.d.ts.map +1 -1
  620. package/dist/tools/registry/core.js +3 -1
  621. package/dist/tools/registry/core.js.map +1 -1
  622. package/dist/tools/registry/extended.d.ts.map +1 -1
  623. package/dist/tools/registry/extended.js +16 -1
  624. package/dist/tools/registry/extended.js.map +1 -1
  625. package/dist/tools/schema.d.ts +18 -2
  626. package/dist/tools/schema.d.ts.map +1 -1
  627. package/dist/tools/schema.js +1 -1
  628. package/dist/tools/schema.js.map +1 -1
  629. package/dist/tools/stock-photo.js +1 -0
  630. package/dist/tools/stock-photo.js.map +1 -1
  631. package/dist/tools/structure/basic.d.ts.map +1 -1
  632. package/dist/tools/structure/basic.js +1 -0
  633. package/dist/tools/structure/basic.js.map +1 -1
  634. package/dist/tools/structure/batch.d.ts.map +1 -1
  635. package/dist/tools/structure/batch.js +8 -1
  636. package/dist/tools/structure/batch.js.map +1 -1
  637. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  638. package/dist/tools/structure/hierarchy.js +4 -0
  639. package/dist/tools/structure/hierarchy.js.map +1 -1
  640. package/dist/tools/structure/variations.d.ts +8 -0
  641. package/dist/tools/structure/variations.d.ts.map +1 -0
  642. package/dist/tools/structure/variations.js +106 -0
  643. package/dist/tools/structure/variations.js.map +1 -0
  644. package/dist/tools/structure.d.ts +2 -1
  645. package/dist/tools/structure.js +2 -1
  646. package/dist/tools/styles/types.d.ts +2 -4
  647. package/dist/tools/styles/types.d.ts.map +1 -1
  648. package/dist/tools/styles/types.js.map +1 -1
  649. package/dist/tools/vector/boolean.d.ts.map +1 -1
  650. package/dist/tools/vector/boolean.js +4 -0
  651. package/dist/tools/vector/boolean.js.map +1 -1
  652. package/dist/tools/vector/vectorize.js +1 -0
  653. package/dist/tools/vector/vectorize.js.map +1 -1
  654. package/dist/tools/vector/video.d.ts +6 -0
  655. package/dist/tools/vector/video.d.ts.map +1 -0
  656. package/dist/tools/vector/video.js +133 -0
  657. package/dist/tools/vector/video.js.map +1 -0
  658. package/dist/tools/vector.d.ts +2 -1
  659. package/dist/tools/vector.js +2 -1
  660. package/dist/tools/video-host.d.ts +12 -0
  661. package/dist/tools/video-host.d.ts.map +1 -0
  662. package/dist/tools/video-host.js +19 -0
  663. package/dist/tools/video-host.js.map +1 -0
  664. package/dist/vector/point-transform.d.ts +1 -1
  665. package/dist/vector/vectorize/svg/to-vectors.d.ts +1 -1
  666. package/package.json +31 -9
  667. package/src/ai/providers.ts +2 -0
  668. package/src/cache/resource.ts +24 -1
  669. package/src/canvas/effects.ts +47 -50
  670. package/src/canvas/fills.ts +19 -15
  671. package/src/canvas/images/adjustments.ts +203 -0
  672. package/src/canvas/images/sampling.ts +88 -0
  673. package/src/canvas/index.ts +1 -0
  674. package/src/canvas/masks.ts +1 -1
  675. package/src/canvas/noise/render.ts +75 -0
  676. package/src/canvas/noise/shader.ts +161 -0
  677. package/src/canvas/noise/table.ts +91 -0
  678. package/src/canvas/noise/tile.ts +94 -0
  679. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  680. package/src/canvas/renderer/lifecycle.ts +6 -0
  681. package/src/canvas/renderer/pipeline.ts +19 -1
  682. package/src/canvas/renderer/play-scenes.ts +51 -0
  683. package/src/canvas/renderer/tiles/cache.ts +54 -1
  684. package/src/canvas/renderer/tiles/controller.ts +30 -1
  685. package/src/canvas/renderer/types.ts +18 -2
  686. package/src/canvas/renderer.ts +40 -3
  687. package/src/canvas/scene.ts +65 -9
  688. package/src/canvas/texture.ts +136 -0
  689. package/src/clipboard.ts +23 -10
  690. package/src/constants.ts +6 -0
  691. package/src/design-memory/check.ts +376 -0
  692. package/src/design-memory/describe.ts +77 -0
  693. package/src/design-memory/distil.ts +69 -0
  694. package/src/design-memory/document.ts +80 -0
  695. package/src/design-memory/guard.ts +157 -0
  696. package/src/design-memory/index.ts +8 -0
  697. package/src/design-memory/refusal.ts +90 -0
  698. package/src/design-memory/rules.ts +274 -0
  699. package/src/design-memory/values.ts +179 -0
  700. package/src/editor/bridges/components.ts +2 -0
  701. package/src/editor/clipboard/export.ts +24 -7
  702. package/src/editor/components/instances.ts +31 -0
  703. package/src/editor/create.ts +25 -69
  704. package/src/editor/design-memory.ts +39 -0
  705. package/src/editor/design-tokens.ts +41 -2
  706. package/src/editor/document-colors.ts +65 -0
  707. package/src/editor/eyedropper.ts +198 -0
  708. package/src/editor/fonts.ts +19 -0
  709. package/src/editor/history/atomic-tool.ts +29 -1
  710. package/src/editor/history/capture.ts +19 -0
  711. package/src/editor/history/document-change.ts +5 -17
  712. package/src/editor/history/edit.ts +11 -1
  713. package/src/editor/history/subtree.ts +13 -2
  714. package/src/editor/index.ts +11 -0
  715. package/src/editor/pages.ts +40 -29
  716. package/src/editor/play/states.ts +1 -1
  717. package/src/editor/read-only/actions.ts +4 -0
  718. package/src/editor/render-requests.ts +83 -0
  719. package/src/editor/selection/overlays.ts +1 -0
  720. package/src/editor/tool-registry.ts +2 -1
  721. package/src/editor/types.ts +4 -0
  722. package/src/editor/variations/create.ts +235 -0
  723. package/src/editor/variations/pick.ts +35 -0
  724. package/src/editor/variations.ts +110 -0
  725. package/src/figma-api/accessors/reactions.ts +11 -1
  726. package/src/figma-api/accessors/text/index.ts +7 -0
  727. package/src/figma-api/accessors/text/opentype.ts +33 -0
  728. package/src/figma-api/accessors/visual.ts +55 -2
  729. package/src/figma-api/compatibility.ts +5 -2
  730. package/src/figma-api/effects.ts +143 -5
  731. package/src/figma-api/index.ts +10 -0
  732. package/src/figma-api/overrides.ts +295 -3
  733. package/src/figma-api/paints.ts +24 -9
  734. package/src/figma-api/proxy.ts +6 -1
  735. package/src/figma-api/reactions.ts +130 -32
  736. package/src/figma-api/surface.ts +6 -2
  737. package/src/global.d.ts +26 -0
  738. package/src/io/formats/boolean-path.ts +60 -0
  739. package/src/io/formats/design-tokens/index.ts +21 -0
  740. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  741. package/src/io/formats/design-tokens/project.ts +40 -9
  742. package/src/io/formats/design-tokens/styles.ts +10 -2
  743. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  744. package/src/io/formats/design-tokens/sync/drift.ts +587 -0
  745. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  746. package/src/io/formats/drawio/edges.ts +65 -0
  747. package/src/io/formats/drawio/export.ts +37 -14
  748. package/src/io/formats/drawio/index.ts +2 -0
  749. package/src/io/formats/fig/export/patch/index.ts +8 -0
  750. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  751. package/src/io/formats/html/import.ts +9 -1
  752. package/src/io/formats/html/index.ts +14 -7
  753. package/src/io/formats/html/vectors.ts +8 -2
  754. package/src/io/formats/pdf/document.ts +14 -4
  755. package/src/io/formats/pen/imports.ts +5 -6
  756. package/src/io/formats/pen/index.ts +36 -5
  757. package/src/io/formats/raster/adjusted-images.ts +125 -0
  758. package/src/io/formats/raster/headless.ts +3 -3
  759. package/src/io/formats/raster/index.ts +6 -1
  760. package/src/io/formats/raster/pixels.ts +7 -0
  761. package/src/io/formats/raster/render.ts +12 -1
  762. package/src/io/formats/svg/defs.ts +4 -72
  763. package/src/io/formats/svg/effects.ts +131 -0
  764. package/src/io/formats/svg/export.ts +278 -46
  765. package/src/io/formats/svg/filter.ts +47 -0
  766. package/src/io/formats/svg/grain.ts +249 -0
  767. package/src/io/formats/svg/strokes.ts +2 -2
  768. package/src/io/formats/svg/text/layout.ts +13 -3
  769. package/src/io/formats/video/composite.ts +79 -0
  770. package/src/io/formats/video/formats.ts +77 -0
  771. package/src/io/formats/video/gif.ts +65 -0
  772. package/src/io/formats/video/index.ts +30 -0
  773. package/src/io/formats/video/plan.ts +116 -0
  774. package/src/io/formats/video/record.ts +227 -0
  775. package/src/io/formats/video/sink.ts +32 -0
  776. package/src/io/formats/video/size.ts +25 -0
  777. package/src/io/formats/video/webcodecs.ts +89 -0
  778. package/src/io/formats.ts +59 -11
  779. package/src/io/types.ts +29 -10
  780. package/src/layout/auto-layout-handles.ts +396 -0
  781. package/src/layout.ts +2 -0
  782. package/src/lint/fixes.ts +12 -3
  783. package/src/lint/index.ts +3 -1
  784. package/src/lint/linter.ts +107 -10
  785. package/src/lint/presets.ts +2 -0
  786. package/src/lint/rules/design-memory.ts +97 -0
  787. package/src/lint/rules/index.ts +6 -1
  788. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  789. package/src/lint/types.ts +32 -0
  790. package/src/node/video.ts +196 -0
  791. package/src/pairdraw-api/design-memory.ts +61 -0
  792. package/src/pairdraw-api/index.ts +81 -0
  793. package/src/pairdraw-api/nodes.ts +38 -0
  794. package/src/pairdraw-api/variations.ts +109 -0
  795. package/src/prototype/easing.ts +37 -0
  796. package/src/prototype/frames.ts +9 -0
  797. package/src/prototype/hit.ts +70 -0
  798. package/src/prototype/index.ts +69 -0
  799. package/src/prototype/pointer.ts +146 -0
  800. package/src/prototype/reactions.ts +178 -0
  801. package/src/prototype/scene.ts +116 -0
  802. package/src/prototype/scenes.ts +256 -0
  803. package/src/prototype/scroll.ts +190 -0
  804. package/src/prototype/session.ts +188 -0
  805. package/src/prototype/smart-animate/animation.ts +267 -0
  806. package/src/prototype/smart-animate/match.ts +85 -0
  807. package/src/prototype/snapshot.ts +60 -0
  808. package/src/prototype/timeline.ts +400 -0
  809. package/src/text/font/features.ts +27 -0
  810. package/src/text/font/manager.ts +79 -1
  811. package/src/text/index.ts +2 -0
  812. package/src/text/replace-fonts.ts +171 -0
  813. package/src/tools/analyze/responsive/index.ts +264 -0
  814. package/src/tools/analyze.ts +2 -0
  815. package/src/tools/codegen/token-sync.ts +98 -0
  816. package/src/tools/codegen.ts +1 -0
  817. package/src/tools/create/components.ts +4 -0
  818. package/src/tools/create/html.ts +1 -0
  819. package/src/tools/create/icons.ts +1 -0
  820. package/src/tools/create/mermaid.ts +1 -0
  821. package/src/tools/create/svg.ts +1 -0
  822. package/src/tools/design-memory.ts +72 -0
  823. package/src/tools/image-ai/generate.ts +2 -0
  824. package/src/tools/index.ts +1 -0
  825. package/src/tools/modify/fonts.ts +34 -0
  826. package/src/tools/modify/reactions.ts +15 -8
  827. package/src/tools/modify/text.ts +42 -5
  828. package/src/tools/modify/update.ts +46 -2
  829. package/src/tools/modify.ts +1 -0
  830. package/src/tools/read/fonts.ts +24 -2
  831. package/src/tools/read/libraries.ts +1 -0
  832. package/src/tools/read/space.ts +3 -2
  833. package/src/tools/registry/core.ts +3 -1
  834. package/src/tools/registry/extended.ts +28 -1
  835. package/src/tools/schema.ts +28 -4
  836. package/src/tools/stock-photo.ts +1 -0
  837. package/src/tools/structure/basic.ts +1 -0
  838. package/src/tools/structure/batch.ts +12 -1
  839. package/src/tools/structure/hierarchy.ts +4 -0
  840. package/src/tools/structure/variations.ts +118 -0
  841. package/src/tools/structure.ts +2 -0
  842. package/src/tools/styles/types.ts +3 -4
  843. package/src/tools/vector/boolean.ts +4 -0
  844. package/src/tools/vector/vectorize.ts +1 -0
  845. package/src/tools/vector/video.ts +228 -0
  846. package/src/tools/vector.ts +1 -0
  847. package/src/tools/video-host.ts +18 -0
@@ -0,0 +1,52 @@
1
+ import { currentDesignRules } from "./document.js";
2
+ import { cachedDesignMemory } from "@pairdraw/scene-graph/design-memory";
3
+ //#region src/design-memory/describe.ts
4
+ /** How many allowed values of a group a report lists by default. */
5
+ const LISTED_VALUES = 64;
6
+ /** The document's memory with its allowed values resolved; null when it has none. */
7
+ function describeDesignMemory(graph, limit = LISTED_VALUES) {
8
+ const memory = cachedDesignMemory(graph);
9
+ if (!memory) return null;
10
+ const rules = currentDesignRules(graph, memory);
11
+ const group = (name) => {
12
+ const { enforce, fromSystem, allowed } = rules[name];
13
+ return {
14
+ enforce,
15
+ fromSystem,
16
+ allowed: allowed.slice(0, limit).map(({ value, name: source }) => ({
17
+ value,
18
+ name: source
19
+ })),
20
+ more: Math.max(0, allowed.length - limit)
21
+ };
22
+ };
23
+ return {
24
+ groups: {
25
+ colors: group("colors"),
26
+ fonts: group("fonts"),
27
+ fontSizes: group("fontSizes"),
28
+ spacing: group("spacing"),
29
+ radius: group("radius")
30
+ },
31
+ decisions: memory.decisions.map(({ id, text, author }) => ({
32
+ id,
33
+ text,
34
+ author
35
+ })),
36
+ examples: memory.examples.map(({ nodeId }) => {
37
+ const node = graph.getNode(nodeId);
38
+ const page = node ? graph.getNode(graph.pageOf(node.id) ?? "") : void 0;
39
+ return {
40
+ id: nodeId,
41
+ name: node?.name ?? null,
42
+ page: page?.name ?? null,
43
+ width: node?.width ?? null,
44
+ height: node?.height ?? null
45
+ };
46
+ })
47
+ };
48
+ }
49
+ //#endregion
50
+ export { describeDesignMemory };
51
+
52
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe.js","names":[],"sources":["../../src/design-memory/describe.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n cachedDesignMemory,\n type DesignDecisionAuthor,\n type DesignMemoryEnforcement,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { currentDesignRules } from './document'\n\n/** How many allowed values of a group a report lists by default. */\nconst LISTED_VALUES = 64\n\nexport interface DesignGroupReport {\n enforce: DesignMemoryEnforcement\n /** Whether the document's variables and styles count. */\n fromSystem: boolean\n allowed: { value: string | number; name: string | null }[]\n /** Allowed values past the listed ones. */\n more: number\n}\n\nexport interface DesignExampleReport {\n id: string\n /** Null for a layer the document no longer has. */\n name: string | null\n page: string | null\n width: number | null\n height: number | null\n}\n\n/** A document's design memory as agents, the CLI and the chat read it. */\nexport interface DesignMemoryReport {\n groups: Record<DesignMemoryGroup, DesignGroupReport>\n decisions: { id: string; text: string; author: DesignDecisionAuthor }[]\n examples: DesignExampleReport[]\n}\n\n/** The document's memory with its allowed values resolved; null when it has none. */\nexport function describeDesignMemory(\n graph: SceneGraph,\n limit = LISTED_VALUES\n): DesignMemoryReport | null {\n const memory = cachedDesignMemory(graph)\n if (!memory) return null\n const rules = currentDesignRules(graph, memory)\n const group = (name: DesignMemoryGroup): DesignGroupReport => {\n const { enforce, fromSystem, allowed } = rules[name]\n return {\n enforce,\n fromSystem,\n allowed: allowed.slice(0, limit).map(({ value, name: source }) => ({ value, name: source })),\n more: Math.max(0, allowed.length - limit)\n }\n }\n return {\n groups: {\n colors: group('colors'),\n fonts: group('fonts'),\n fontSizes: group('fontSizes'),\n spacing: group('spacing'),\n radius: group('radius')\n },\n decisions: memory.decisions.map(({ id, text, author }) => ({ id, text, author })),\n examples: memory.examples.map(({ nodeId }) => {\n const node = graph.getNode(nodeId)\n const page = node ? graph.getNode(graph.pageOf(node.id) ?? '') : undefined\n return {\n id: nodeId,\n name: node?.name ?? null,\n page: page?.name ?? null,\n width: node?.width ?? null,\n height: node?.height ?? null\n }\n })\n }\n}\n"],"mappings":";;;;AAWA,MAAM,gBAAgB;;AA4BtB,SAAgB,qBACd,OACA,QAAQ,eACmB;CAC3B,MAAM,SAAS,mBAAmB,KAAK;CACvC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,QAAQ,mBAAmB,OAAO,MAAM;CAC9C,MAAM,SAAS,SAA+C;EAC5D,MAAM,EAAE,SAAS,YAAY,YAAY,MAAM;EAC/C,OAAO;GACL;GACA;GACA,SAAS,QAAQ,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,EAAE,OAAO,MAAM,cAAc;IAAE;IAAO,MAAM;GAAO,EAAE;GAC3F,MAAM,KAAK,IAAI,GAAG,QAAQ,SAAS,KAAK;EAC1C;CACF;CACA,OAAO;EACL,QAAQ;GACN,QAAQ,MAAM,QAAQ;GACtB,OAAO,MAAM,OAAO;GACpB,WAAW,MAAM,WAAW;GAC5B,SAAS,MAAM,SAAS;GACxB,QAAQ,MAAM,QAAQ;EACxB;EACA,WAAW,OAAO,UAAU,KAAK,EAAE,IAAI,MAAM,cAAc;GAAE;GAAI;GAAM;EAAO,EAAE;EAChF,UAAU,OAAO,SAAS,KAAK,EAAE,aAAa;GAC5C,MAAM,OAAO,MAAM,QAAQ,MAAM;GACjC,MAAM,OAAO,OAAO,MAAM,QAAQ,MAAM,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,KAAA;GACjE,OAAO;IACL,IAAI;IACJ,MAAM,MAAM,QAAQ;IACpB,MAAM,MAAM,QAAQ;IACpB,OAAO,MAAM,SAAS;IACtB,QAAQ,MAAM,UAAU;GAC1B;EACF,CAAC;CACH;AACF"}
@@ -0,0 +1,22 @@
1
+ import { SceneGraph } from "@pairdraw/scene-graph";
2
+ import { DesignMemory, DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
3
+ //#region src/design-memory/distil.d.ts
4
+ /** A value the layers use, how often, and whether a variable or style already gives it. */
5
+ interface DistilledValue {
6
+ value: string | number;
7
+ count: number;
8
+ /** Given by a variable or a style, so the document's system already allows it. */
9
+ fromSystem: boolean;
10
+ }
11
+ type DistilledValues = Record<DesignMemoryGroup, DistilledValue[]>;
12
+ /**
13
+ * The values the layers under `rootIds` use, most used first, as rules to learn: colors,
14
+ * fonts, font sizes, spacing and radii, each once. Instances count as the component they show,
15
+ * so a component placed fifty times is not fifty votes.
16
+ */
17
+ declare function distilDesignValues(graph: SceneGraph, rootIds: readonly string[]): DistilledValues;
18
+ /** Whether a distilled value is worth proposing: used more than once, and not already allowed. */
19
+ declare function proposesValue(memory: DesignMemory | null, group: DesignMemoryGroup, value: DistilledValue): boolean;
20
+ //#endregion
21
+ export { DistilledValue, DistilledValues, distilDesignValues, proposesValue };
22
+ //# sourceMappingURL=distil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distil.d.ts","names":[],"sources":["../../src/design-memory/distil.ts"],"mappings":";;;;UAUiB;EACf;EACA;;EAEA;;KAGU,kBAAkB,OAAO,mBAAmB;;;;;;iBAUxC,mBAAmB,OAAO,YAAY,6BAA6B;;iBAiCnE,cACd,QAAQ,qBACR,OAAO,mBACP,OAAO"}
@@ -0,0 +1,54 @@
1
+ import { designValues } from "./values.js";
2
+ import { DESIGN_MEMORY_GROUPS } from "@pairdraw/scene-graph/design-memory";
3
+ //#region src/design-memory/distil.ts
4
+ /** How many layers one distil reads, so learning from a whole document stays quick. */
5
+ const MAX_LAYERS = 2e4;
6
+ /**
7
+ * The values the layers under `rootIds` use, most used first, as rules to learn: colors,
8
+ * fonts, font sizes, spacing and radii, each once. Instances count as the component they show,
9
+ * so a component placed fifty times is not fifty votes.
10
+ */
11
+ function distilDesignValues(graph, rootIds) {
12
+ const tallies = /* @__PURE__ */ new Map();
13
+ const pending = [...rootIds];
14
+ let visited = 0;
15
+ while (pending.length > 0 && visited < MAX_LAYERS) {
16
+ const id = pending.pop();
17
+ const node = id === void 0 ? void 0 : graph.getNode(id);
18
+ if (!node || !node.visible) continue;
19
+ visited++;
20
+ for (const value of designValues(node)) {
21
+ const key = `${value.group}:${typeof value.value === "string" ? value.value.toLowerCase() : value.value}`;
22
+ const tally = tallies.get(key);
23
+ if (tally) {
24
+ tally.count++;
25
+ tally.fromSystem ||= value.fromSystem;
26
+ } else tallies.set(key, {
27
+ group: value.group,
28
+ value: value.value,
29
+ count: 1,
30
+ fromSystem: value.fromSystem
31
+ });
32
+ }
33
+ if (node.type !== "INSTANCE") pending.push(...node.childIds);
34
+ }
35
+ const result = {
36
+ colors: [],
37
+ fonts: [],
38
+ fontSizes: [],
39
+ spacing: [],
40
+ radius: []
41
+ };
42
+ for (const { group, ...value } of tallies.values()) result[group].push(value);
43
+ for (const group of DESIGN_MEMORY_GROUPS) result[group].sort((a, b) => b.count - a.count);
44
+ return result;
45
+ }
46
+ /** Whether a distilled value is worth proposing: used more than once, and not already allowed. */
47
+ function proposesValue(memory, group, value) {
48
+ if (value.count < 2) return false;
49
+ return !(memory?.[group].values ?? []).includes(value.value);
50
+ }
51
+ //#endregion
52
+ export { distilDesignValues, proposesValue };
53
+
54
+ //# sourceMappingURL=distil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distil.js","names":[],"sources":["../../src/design-memory/distil.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport {\n DESIGN_MEMORY_GROUPS,\n type DesignMemory,\n type DesignMemoryGroup\n} from '@pairdraw/scene-graph/design-memory'\n\nimport { designValues } from './values'\n\n/** A value the layers use, how often, and whether a variable or style already gives it. */\nexport interface DistilledValue {\n value: string | number\n count: number\n /** Given by a variable or a style, so the document's system already allows it. */\n fromSystem: boolean\n}\n\nexport type DistilledValues = Record<DesignMemoryGroup, DistilledValue[]>\n\n/** How many layers one distil reads, so learning from a whole document stays quick. */\nconst MAX_LAYERS = 20_000\n\n/**\n * The values the layers under `rootIds` use, most used first, as rules to learn: colors,\n * fonts, font sizes, spacing and radii, each once. Instances count as the component they show,\n * so a component placed fifty times is not fifty votes.\n */\nexport function distilDesignValues(graph: SceneGraph, rootIds: readonly string[]): DistilledValues {\n const tallies = new Map<string, DistilledValue & { group: DesignMemoryGroup }>()\n const pending = [...rootIds]\n let visited = 0\n while (pending.length > 0 && visited < MAX_LAYERS) {\n const id = pending.pop()\n const node = id === undefined ? undefined : graph.getNode(id)\n if (!node || !node.visible) continue\n visited++\n for (const value of designValues(node)) {\n const key = `${value.group}:${typeof value.value === 'string' ? value.value.toLowerCase() : value.value}`\n const tally = tallies.get(key)\n if (tally) {\n tally.count++\n tally.fromSystem ||= value.fromSystem\n } else {\n tallies.set(key, {\n group: value.group,\n value: value.value,\n count: 1,\n fromSystem: value.fromSystem\n })\n }\n }\n if (node.type !== 'INSTANCE') pending.push(...node.childIds)\n }\n const result: DistilledValues = { colors: [], fonts: [], fontSizes: [], spacing: [], radius: [] }\n for (const { group, ...value } of tallies.values()) result[group].push(value)\n for (const group of DESIGN_MEMORY_GROUPS) result[group].sort((a, b) => b.count - a.count)\n return result\n}\n\n/** Whether a distilled value is worth proposing: used more than once, and not already allowed. */\nexport function proposesValue(\n memory: DesignMemory | null,\n group: DesignMemoryGroup,\n value: DistilledValue\n): boolean {\n if (value.count < 2) return false\n const values: readonly (string | number)[] = memory?.[group].values ?? []\n return !values.includes(value.value)\n}\n"],"mappings":";;;;AAoBA,MAAM,aAAa;;;;;;AAOnB,SAAgB,mBAAmB,OAAmB,SAA6C;CACjG,MAAM,0BAAU,IAAI,IAA2D;CAC/E,MAAM,UAAU,CAAC,GAAG,OAAO;CAC3B,IAAI,UAAU;CACd,OAAO,QAAQ,SAAS,KAAK,UAAU,YAAY;EACjD,MAAM,KAAK,QAAQ,IAAI;EACvB,MAAM,OAAO,OAAO,KAAA,IAAY,KAAA,IAAY,MAAM,QAAQ,EAAE;EAC5D,IAAI,CAAC,QAAQ,CAAC,KAAK,SAAS;EAC5B;EACA,KAAK,MAAM,SAAS,aAAa,IAAI,GAAG;GACtC,MAAM,MAAM,GAAG,MAAM,MAAM,GAAG,OAAO,MAAM,UAAU,WAAW,MAAM,MAAM,YAAY,IAAI,MAAM;GAClG,MAAM,QAAQ,QAAQ,IAAI,GAAG;GAC7B,IAAI,OAAO;IACT,MAAM;IACN,MAAM,eAAe,MAAM;GAC7B,OACE,QAAQ,IAAI,KAAK;IACf,OAAO,MAAM;IACb,OAAO,MAAM;IACb,OAAO;IACP,YAAY,MAAM;GACpB,CAAC;EAEL;EACA,IAAI,KAAK,SAAS,YAAY,QAAQ,KAAK,GAAG,KAAK,QAAQ;CAC7D;CACA,MAAM,SAA0B;EAAE,QAAQ,CAAC;EAAG,OAAO,CAAC;EAAG,WAAW,CAAC;EAAG,SAAS,CAAC;EAAG,QAAQ,CAAC;CAAE;CAChG,KAAK,MAAM,EAAE,OAAO,GAAG,WAAW,QAAQ,OAAO,GAAG,OAAO,MAAM,CAAC,KAAK,KAAK;CAC5E,KAAK,MAAM,SAAS,sBAAsB,OAAO,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,KAAK;CACxF,OAAO;AACT;;AAGA,SAAgB,cACd,QACA,OACA,OACS;CACT,IAAI,MAAM,QAAQ,GAAG,OAAO;CAE5B,OAAO,EADsC,SAAS,MAAM,CAAC,UAAU,CAAC,EAAA,CACzD,SAAS,MAAM,KAAK;AACrC"}
@@ -0,0 +1,12 @@
1
+ import { DesignRules } from "./rules.js";
2
+ import { SceneGraph } from "@pairdraw/scene-graph";
3
+ import { DesignMemory } from "@pairdraw/scene-graph/design-memory";
4
+ //#region src/design-memory/document.d.ts
5
+ /**
6
+ * The memory's rules resolved against the document as it is now, reused while the memory, the
7
+ * style layers and the variables have not changed since they were last resolved.
8
+ */
9
+ declare function currentDesignRules(graph: SceneGraph, memory: DesignMemory): DesignRules;
10
+ //#endregion
11
+ export { currentDesignRules };
12
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","names":[],"sources":["../../src/design-memory/document.ts"],"mappings":";;;;;;;;iBAiEgB,mBAAmB,OAAO,YAAY,QAAQ,eAAe"}
@@ -0,0 +1,64 @@
1
+ import { isStyleNode, resolveDesignRules } from "./rules.js";
2
+ //#region src/design-memory/document.ts
3
+ const states = /* @__PURE__ */ new WeakMap();
4
+ function stateOf(graph) {
5
+ const known = states.get(graph);
6
+ if (known) return known;
7
+ const state = {
8
+ styleIds: /* @__PURE__ */ new Set(),
9
+ styleVersion: 0,
10
+ rules: null
11
+ };
12
+ for (const node of graph.getAllNodes()) if (isStyleNode(node)) state.styleIds.add(node.id);
13
+ const touched = (id) => {
14
+ const node = graph.getNode(id);
15
+ const isStyle = node !== void 0 && isStyleNode(node);
16
+ if (!isStyle && !state.styleIds.has(id)) return;
17
+ if (isStyle) state.styleIds.add(id);
18
+ else state.styleIds.delete(id);
19
+ state.styleVersion++;
20
+ };
21
+ graph.onNodeEvents({
22
+ created: (node) => touched(node.id),
23
+ updated: (id) => touched(id),
24
+ deleted: (id) => touched(id)
25
+ });
26
+ states.set(graph, state);
27
+ return state;
28
+ }
29
+ /** Every reference a variable's values could change through, in a fixed order. */
30
+ function variableFingerprint(graph) {
31
+ const refs = [];
32
+ for (const variable of graph.variables.values()) {
33
+ refs.push(variable, variable.type, variable.scopes?.join(","), variable.valuesByMode);
34
+ for (const value of Object.values(variable.valuesByMode)) refs.push(value);
35
+ }
36
+ for (const collection of graph.variableCollections.values()) refs.push(collection.modes);
37
+ return refs;
38
+ }
39
+ function sameRefs(left, right) {
40
+ return left.length === right.length && left.every((value, index) => value === right[index]);
41
+ }
42
+ /**
43
+ * The memory's rules resolved against the document as it is now, reused while the memory, the
44
+ * style layers and the variables have not changed since they were last resolved.
45
+ */
46
+ function currentDesignRules(graph, memory) {
47
+ const state = stateOf(graph);
48
+ const variables = variableFingerprint(graph);
49
+ const cached = state.rules;
50
+ if (cached?.memory === memory && cached.styleVersion === state.styleVersion && sameRefs(cached.variables, variables)) return cached.rules;
51
+ const styles = [...state.styleIds].flatMap((id) => graph.getNode(id) ?? []);
52
+ const rules = resolveDesignRules(graph, memory, styles);
53
+ state.rules = {
54
+ memory,
55
+ styleVersion: state.styleVersion,
56
+ variables,
57
+ rules
58
+ };
59
+ return rules;
60
+ }
61
+ //#endregion
62
+ export { currentDesignRules };
63
+
64
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","names":[],"sources":["../../src/design-memory/document.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport type { DesignMemory } from '@pairdraw/scene-graph/design-memory'\n\nimport { isStyleNode, resolveDesignRules, type DesignRules } from './rules'\n\n/**\n * What one document keeps for its design memory between checks, kept current by the graph's\n * node events, so a check never walks the whole document: the layers that define shared styles,\n * whose values join the system, and the rules last resolved, reused while the memory, those\n * styles and the variables are as they were.\n */\ninterface DocumentDesignState {\n styleIds: Set<string>\n styleVersion: number\n rules: {\n memory: DesignMemory\n styleVersion: number\n variables: unknown[]\n rules: DesignRules\n } | null\n}\n\nconst states = new WeakMap<SceneGraph, DocumentDesignState>()\n\nfunction stateOf(graph: SceneGraph): DocumentDesignState {\n const known = states.get(graph)\n if (known) return known\n const state: DocumentDesignState = { styleIds: new Set(), styleVersion: 0, rules: null }\n for (const node of graph.getAllNodes()) if (isStyleNode(node)) state.styleIds.add(node.id)\n const touched = (id: string) => {\n const node = graph.getNode(id)\n const isStyle = node !== undefined && isStyleNode(node)\n if (!isStyle && !state.styleIds.has(id)) return\n if (isStyle) state.styleIds.add(id)\n else state.styleIds.delete(id)\n state.styleVersion++\n }\n graph.onNodeEvents({\n created: (node) => touched(node.id),\n updated: (id) => touched(id),\n deleted: (id) => touched(id)\n })\n states.set(graph, state)\n return state\n}\n\n/** Every reference a variable's values could change through, in a fixed order. */\nfunction variableFingerprint(graph: SceneGraph): unknown[] {\n const refs: unknown[] = []\n for (const variable of graph.variables.values()) {\n refs.push(variable, variable.type, variable.scopes?.join(','), variable.valuesByMode)\n for (const value of Object.values(variable.valuesByMode)) refs.push(value)\n }\n for (const collection of graph.variableCollections.values()) refs.push(collection.modes)\n return refs\n}\n\nfunction sameRefs(left: readonly unknown[], right: readonly unknown[]): boolean {\n return left.length === right.length && left.every((value, index) => value === right[index])\n}\n\n/**\n * The memory's rules resolved against the document as it is now, reused while the memory, the\n * style layers and the variables have not changed since they were last resolved.\n */\nexport function currentDesignRules(graph: SceneGraph, memory: DesignMemory): DesignRules {\n const state = stateOf(graph)\n const variables = variableFingerprint(graph)\n const cached = state.rules\n if (\n cached?.memory === memory &&\n cached.styleVersion === state.styleVersion &&\n sameRefs(cached.variables, variables)\n )\n return cached.rules\n const styles = [...state.styleIds].flatMap((id) => graph.getNode(id) ?? [])\n const rules = resolveDesignRules(graph, memory, styles)\n state.rules = { memory, styleVersion: state.styleVersion, variables, rules }\n return rules\n}\n"],"mappings":";;AAsBA,MAAM,yBAAS,IAAI,QAAyC;AAE5D,SAAS,QAAQ,OAAwC;CACvD,MAAM,QAAQ,OAAO,IAAI,KAAK;CAC9B,IAAI,OAAO,OAAO;CAClB,MAAM,QAA6B;EAAE,0BAAU,IAAI,IAAI;EAAG,cAAc;EAAG,OAAO;CAAK;CACvF,KAAK,MAAM,QAAQ,MAAM,YAAY,GAAG,IAAI,YAAY,IAAI,GAAG,MAAM,SAAS,IAAI,KAAK,EAAE;CACzF,MAAM,WAAW,OAAe;EAC9B,MAAM,OAAO,MAAM,QAAQ,EAAE;EAC7B,MAAM,UAAU,SAAS,KAAA,KAAa,YAAY,IAAI;EACtD,IAAI,CAAC,WAAW,CAAC,MAAM,SAAS,IAAI,EAAE,GAAG;EACzC,IAAI,SAAS,MAAM,SAAS,IAAI,EAAE;OAC7B,MAAM,SAAS,OAAO,EAAE;EAC7B,MAAM;CACR;CACA,MAAM,aAAa;EACjB,UAAU,SAAS,QAAQ,KAAK,EAAE;EAClC,UAAU,OAAO,QAAQ,EAAE;EAC3B,UAAU,OAAO,QAAQ,EAAE;CAC7B,CAAC;CACD,OAAO,IAAI,OAAO,KAAK;CACvB,OAAO;AACT;;AAGA,SAAS,oBAAoB,OAA8B;CACzD,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,YAAY,MAAM,UAAU,OAAO,GAAG;EAC/C,KAAK,KAAK,UAAU,SAAS,MAAM,SAAS,QAAQ,KAAK,GAAG,GAAG,SAAS,YAAY;EACpF,KAAK,MAAM,SAAS,OAAO,OAAO,SAAS,YAAY,GAAG,KAAK,KAAK,KAAK;CAC3E;CACA,KAAK,MAAM,cAAc,MAAM,oBAAoB,OAAO,GAAG,KAAK,KAAK,WAAW,KAAK;CACvF,OAAO;AACT;AAEA,SAAS,SAAS,MAA0B,OAAoC;CAC9E,OAAO,KAAK,WAAW,MAAM,UAAU,KAAK,OAAO,OAAO,UAAU,UAAU,MAAM,MAAM;AAC5F;;;;;AAMA,SAAgB,mBAAmB,OAAmB,QAAmC;CACvF,MAAM,QAAQ,QAAQ,KAAK;CAC3B,MAAM,YAAY,oBAAoB,KAAK;CAC3C,MAAM,SAAS,MAAM;CACrB,IACE,QAAQ,WAAW,UACnB,OAAO,iBAAiB,MAAM,gBAC9B,SAAS,OAAO,WAAW,SAAS,GAEpC,OAAO,OAAO;CAChB,MAAM,SAAS,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,SAAS,OAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,CAAC;CAC1E,MAAM,QAAQ,mBAAmB,OAAO,QAAQ,MAAM;CACtD,MAAM,QAAQ;EAAE;EAAQ,cAAc,MAAM;EAAc;EAAW;CAAM;CAC3E,OAAO;AACT"}
@@ -0,0 +1,48 @@
1
+ import { DesignViolation } from "./check.js";
2
+ import { FieldChanges } from "../editor/history/diff.js";
3
+ import { DocumentChange } from "../editor/history/document-change.js";
4
+ import { ToolDef } from "../tools/schema.js";
5
+ import { SceneGraph, SceneNode, Variable } from "@pairdraw/scene-graph";
6
+ //#region src/design-memory/guard.d.ts
7
+ /**
8
+ * Checks one agent call's edit against the document's design memory, at the moment the edit is
9
+ * recorded, so a refused edit is put back before anyone sees it.
10
+ */
11
+ interface DesignGuard {
12
+ /** For an edit recorded as a document change. */
13
+ verifyChange: (change: DocumentChange) => Error | null;
14
+ /** For an atomic tool's property transaction. */
15
+ verifyFields: (nodes: readonly FieldChanges<SceneNode>[], variables?: readonly FieldChanges<Variable>[]) => Error | null;
16
+ /**
17
+ * The call's result with what the memory warned about, and any refusal the edit could not be
18
+ * put back for, as `design_memory`; the result itself when there was none.
19
+ */
20
+ annotate: (result: unknown) => unknown;
21
+ /** What the memory warned about, or null when nothing; `annotate` attaches the same. */
22
+ report: () => DesignMemoryWarnings | null;
23
+ }
24
+ /** The warnings a call that went through carries. */
25
+ interface DesignMemoryWarnings {
26
+ warnings: string;
27
+ violations: DesignViolation[];
28
+ }
29
+ /** How a call answers to the memory: an agent's is refused, a person's only warned. */
30
+ type DesignMemoryMode = 'refuse' | 'warn';
31
+ /** What a guard knows about the call it watches. */
32
+ interface DesignGuardOptions {
33
+ /** The tool's `content`: `imported` only warns, `copied` vouches for its source layers. */
34
+ content?: ToolDef['content'];
35
+ /** The call's arguments, which name the layers a copying call reads. */
36
+ args?: Record<string, unknown>;
37
+ /** `warn` for a call a person made, such as a CLI command, which is never undone. */
38
+ mode?: DesignMemoryMode;
39
+ }
40
+ /**
41
+ * A guard for one call, made just before it runs: it keeps the memory and its rules as they are
42
+ * then, so nothing the call does, to the memory or to the variables and styles, changes what it
43
+ * is judged by. A person's call (`mode: 'warn'`) is never undone and may change the memory.
44
+ */
45
+ declare function createDesignGuard(graph: SceneGraph, options?: DesignGuardOptions): DesignGuard;
46
+ //#endregion
47
+ export { DesignGuard, DesignGuardOptions, DesignMemoryMode, DesignMemoryWarnings, createDesignGuard };
48
+ //# sourceMappingURL=guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.d.ts","names":[],"sources":["../../src/design-memory/guard.ts"],"mappings":";;;;;;;;;;UAqBiB;;EAEf,eAAe,QAAQ,mBAAmB;;EAE1C,eACE,gBAAgB,aAAa,cAC7B,qBAAqB,aAAa,gBAC/B;;;;;EAKL,WAAW;;EAEX,cAAc;;;UAIC;EACf;EACA,YAAY;;;KAIF;;UAkBK;;EAEf,UAAU;;EAEV,OAAO;;EAEP,OAAO;;;;;;;iBAeO,kBACd,OAAO,YACP,UAAS,qBACR"}
@@ -0,0 +1,105 @@
1
+ import { currentDesignRules } from "./document.js";
2
+ import { checkDesignEdit } from "./check.js";
3
+ import { DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, describeDesignWarnings } from "./refusal.js";
4
+ import { isEqual } from "es-toolkit";
5
+ import { DESIGN_MEMORY_GROUPS, cachedDesignMemory } from "@pairdraw/scene-graph/design-memory";
6
+ //#region src/design-memory/guard.ts
7
+ /**
8
+ * The changes an agent may make to the memory itself: append decisions of its own and pin or
9
+ * unpin examples. What the memory allows, how it is enforced, and the person's decisions stay.
10
+ */
11
+ function permittedMemoryChange(before, after) {
12
+ if (before === after) return true;
13
+ if (!before || !after) return false;
14
+ if (!DESIGN_MEMORY_GROUPS.every((group) => isEqual(before[group], after[group]))) return false;
15
+ const kept = before.decisions.every((decision, index) => isEqual(decision, after.decisions[index]));
16
+ const added = after.decisions.slice(before.decisions.length);
17
+ return kept && added.every((decision) => decision.author === "agent");
18
+ }
19
+ /** The layers a copying call names: its `id`, `ids`, or `component_id`. */
20
+ function copiedSources(args = {}) {
21
+ return [
22
+ args.id,
23
+ args.component_id,
24
+ ...Array.isArray(args.ids) ? args.ids : []
25
+ ].filter((id) => typeof id === "string");
26
+ }
27
+ /**
28
+ * A guard for one call, made just before it runs: it keeps the memory and its rules as they are
29
+ * then, so nothing the call does, to the memory or to the variables and styles, changes what it
30
+ * is judged by. A person's call (`mode: 'warn'`) is never undone and may change the memory.
31
+ */
32
+ function createDesignGuard(graph, options = {}) {
33
+ const person = options.mode === "warn";
34
+ const before = cachedDesignMemory(graph);
35
+ const rules = before ? currentDesignRules(graph, before) : null;
36
+ const checkOptions = {
37
+ warnOnly: options.content === "imported" || person,
38
+ rules: rules ?? void 0,
39
+ copiedFrom: options.content === "copied" || options.content === "merged" ? copiedSources(options.args) : void 0,
40
+ merged: options.content === "merged"
41
+ };
42
+ const warnings = [];
43
+ let refused = [];
44
+ const verify = (edit) => {
45
+ if (!person && !permittedMemoryChange(before, cachedDesignMemory(graph))) return new DesignMemoryRefusalError([], rules ?? void 0, MEMORY_CHANGE_REFUSED);
46
+ if (!before) return null;
47
+ const findings = checkDesignEdit(graph, edit, checkOptions);
48
+ if (!findings) return null;
49
+ warnings.push(...findings.warnings);
50
+ refused = findings.refused;
51
+ return refused.length > 0 ? new DesignMemoryRefusalError(refused, rules ?? void 0) : null;
52
+ };
53
+ /**
54
+ * What the memory warned about. A call that returned normally kept its changes, so a refusal
55
+ * recorded on the way could not put it back, as when someone else wrote to the document.
56
+ */
57
+ const report = () => {
58
+ const kept = refused;
59
+ if (warnings.length === 0 && kept.length === 0) return null;
60
+ const violations = [...kept.map((violation) => ({
61
+ ...violation,
62
+ severity: "warn"
63
+ })), ...warnings];
64
+ return {
65
+ warnings: (kept.length ? "The edit broke the design memory but could not be undone because the document changed meanwhile; fix these values.\n" : "") + describeDesignWarnings(violations, rules ?? void 0),
66
+ violations
67
+ };
68
+ };
69
+ return {
70
+ verifyChange: (change) => verify({
71
+ created: change.created,
72
+ updated: change.updated.flatMap((update) => update.fields ? [update.fields] : []),
73
+ deleted: change.deleted,
74
+ variables: change.variables.flatMap(({ id, before: previous, after }) => after ? [{
75
+ id,
76
+ before: previous
77
+ }] : [])
78
+ }),
79
+ verifyFields: (nodes, variables = []) => verify({
80
+ created: [],
81
+ updated: nodes,
82
+ variables: variables.map(({ id, before: previous }) => ({
83
+ id,
84
+ before: previous
85
+ }))
86
+ }),
87
+ report,
88
+ annotate: (result) => {
89
+ const design_memory = report();
90
+ if (!design_memory) return result;
91
+ if (result && typeof result === "object" && !Array.isArray(result)) return {
92
+ ...result,
93
+ design_memory
94
+ };
95
+ return {
96
+ result,
97
+ design_memory
98
+ };
99
+ }
100
+ };
101
+ }
102
+ //#endregion
103
+ export { createDesignGuard };
104
+
105
+ //# sourceMappingURL=guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.js","names":[],"sources":["../../src/design-memory/guard.ts"],"sourcesContent":["import { isEqual } from 'es-toolkit'\n\nimport type { SceneGraph, SceneNode, Variable } from '@pairdraw/scene-graph'\nimport {\n cachedDesignMemory,\n DESIGN_MEMORY_GROUPS,\n type DesignMemory\n} from '@pairdraw/scene-graph/design-memory'\n\nimport type { FieldChanges } from '#core/editor/history/diff'\nimport type { DocumentChange } from '#core/editor/history/document-change'\nimport type { ToolDef } from '#core/tools/schema'\n\nimport { checkDesignEdit, type DesignEdit, type DesignViolation } from './check'\nimport { currentDesignRules } from './document'\nimport { describeDesignWarnings, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED } from './refusal'\n\n/**\n * Checks one agent call's edit against the document's design memory, at the moment the edit is\n * recorded, so a refused edit is put back before anyone sees it.\n */\nexport interface DesignGuard {\n /** For an edit recorded as a document change. */\n verifyChange: (change: DocumentChange) => Error | null\n /** For an atomic tool's property transaction. */\n verifyFields: (\n nodes: readonly FieldChanges<SceneNode>[],\n variables?: readonly FieldChanges<Variable>[]\n ) => Error | null\n /**\n * The call's result with what the memory warned about, and any refusal the edit could not be\n * put back for, as `design_memory`; the result itself when there was none.\n */\n annotate: (result: unknown) => unknown\n /** What the memory warned about, or null when nothing; `annotate` attaches the same. */\n report: () => DesignMemoryWarnings | null\n}\n\n/** The warnings a call that went through carries. */\nexport interface DesignMemoryWarnings {\n warnings: string\n violations: DesignViolation[]\n}\n\n/** How a call answers to the memory: an agent's is refused, a person's only warned. */\nexport type DesignMemoryMode = 'refuse' | 'warn'\n\n/**\n * The changes an agent may make to the memory itself: append decisions of its own and pin or\n * unpin examples. What the memory allows, how it is enforced, and the person's decisions stay.\n */\nfunction permittedMemoryChange(before: DesignMemory | null, after: DesignMemory | null): boolean {\n if (before === after) return true\n if (!before || !after) return false\n if (!DESIGN_MEMORY_GROUPS.every((group) => isEqual(before[group], after[group]))) return false\n const kept = before.decisions.every((decision, index) =>\n isEqual(decision, after.decisions[index])\n )\n const added = after.decisions.slice(before.decisions.length)\n return kept && added.every((decision) => decision.author === 'agent')\n}\n\n/** What a guard knows about the call it watches. */\nexport interface DesignGuardOptions {\n /** The tool's `content`: `imported` only warns, `copied` vouches for its source layers. */\n content?: ToolDef['content']\n /** The call's arguments, which name the layers a copying call reads. */\n args?: Record<string, unknown>\n /** `warn` for a call a person made, such as a CLI command, which is never undone. */\n mode?: DesignMemoryMode\n}\n\n/** The layers a copying call names: its `id`, `ids`, or `component_id`. */\nfunction copiedSources(args: Record<string, unknown> = {}): string[] {\n return [args.id, args.component_id, ...(Array.isArray(args.ids) ? args.ids : [])].filter(\n (id): id is string => typeof id === 'string'\n )\n}\n\n/**\n * A guard for one call, made just before it runs: it keeps the memory and its rules as they are\n * then, so nothing the call does, to the memory or to the variables and styles, changes what it\n * is judged by. A person's call (`mode: 'warn'`) is never undone and may change the memory.\n */\nexport function createDesignGuard(\n graph: SceneGraph,\n options: DesignGuardOptions = {}\n): DesignGuard {\n const person = options.mode === 'warn'\n const before = cachedDesignMemory(graph)\n const rules = before ? currentDesignRules(graph, before) : null\n const checkOptions = {\n warnOnly: options.content === 'imported' || person,\n rules: rules ?? undefined,\n copiedFrom:\n options.content === 'copied' || options.content === 'merged'\n ? copiedSources(options.args)\n : undefined,\n merged: options.content === 'merged'\n }\n const warnings: DesignViolation[] = []\n let refused: DesignViolation[] = []\n\n const verify = (edit: DesignEdit): Error | null => {\n if (!person && !permittedMemoryChange(before, cachedDesignMemory(graph)))\n return new DesignMemoryRefusalError([], rules ?? undefined, MEMORY_CHANGE_REFUSED)\n if (!before) return null\n const findings = checkDesignEdit(graph, edit, checkOptions)\n if (!findings) return null\n warnings.push(...findings.warnings)\n refused = findings.refused\n return refused.length > 0 ? new DesignMemoryRefusalError(refused, rules ?? undefined) : null\n }\n\n /**\n * What the memory warned about. A call that returned normally kept its changes, so a refusal\n * recorded on the way could not put it back, as when someone else wrote to the document.\n */\n const report = (): DesignMemoryWarnings | null => {\n const kept = refused\n if (warnings.length === 0 && kept.length === 0) return null\n const violations = [\n ...kept.map((violation) => ({ ...violation, severity: 'warn' as const })),\n ...warnings\n ]\n const note = kept.length\n ? 'The edit broke the design memory but could not be undone because the document changed meanwhile; fix these values.\\n'\n : ''\n return { warnings: note + describeDesignWarnings(violations, rules ?? undefined), violations }\n }\n\n return {\n verifyChange: (change) =>\n verify({\n created: change.created,\n updated: change.updated.flatMap((update) => (update.fields ? [update.fields] : [])),\n deleted: change.deleted,\n variables: change.variables.flatMap(({ id, before: previous, after }) =>\n after ? [{ id, before: previous }] : []\n )\n }),\n verifyFields: (nodes, variables = []) =>\n verify({\n created: [],\n updated: nodes,\n variables: variables.map(({ id, before: previous }) => ({ id, before: previous }))\n }),\n report,\n annotate: (result) => {\n const design_memory = report()\n if (!design_memory) return result\n if (result && typeof result === 'object' && !Array.isArray(result))\n return { ...result, design_memory }\n return { result, design_memory }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAmDA,SAAS,sBAAsB,QAA6B,OAAqC;CAC/F,IAAI,WAAW,OAAO,OAAO;CAC7B,IAAI,CAAC,UAAU,CAAC,OAAO,OAAO;CAC9B,IAAI,CAAC,qBAAqB,OAAO,UAAU,QAAQ,OAAO,QAAQ,MAAM,MAAM,CAAC,GAAG,OAAO;CACzF,MAAM,OAAO,OAAO,UAAU,OAAO,UAAU,UAC7C,QAAQ,UAAU,MAAM,UAAU,MAAM,CAC1C;CACA,MAAM,QAAQ,MAAM,UAAU,MAAM,OAAO,UAAU,MAAM;CAC3D,OAAO,QAAQ,MAAM,OAAO,aAAa,SAAS,WAAW,OAAO;AACtE;;AAaA,SAAS,cAAc,OAAgC,CAAC,GAAa;CACnE,OAAO;EAAC,KAAK;EAAI,KAAK;EAAc,GAAI,MAAM,QAAQ,KAAK,GAAG,IAAI,KAAK,MAAM,CAAC;CAAE,CAAC,CAAC,QAC/E,OAAqB,OAAO,OAAO,QACtC;AACF;;;;;;AAOA,SAAgB,kBACd,OACA,UAA8B,CAAC,GAClB;CACb,MAAM,SAAS,QAAQ,SAAS;CAChC,MAAM,SAAS,mBAAmB,KAAK;CACvC,MAAM,QAAQ,SAAS,mBAAmB,OAAO,MAAM,IAAI;CAC3D,MAAM,eAAe;EACnB,UAAU,QAAQ,YAAY,cAAc;EAC5C,OAAO,SAAS,KAAA;EAChB,YACE,QAAQ,YAAY,YAAY,QAAQ,YAAY,WAChD,cAAc,QAAQ,IAAI,IAC1B,KAAA;EACN,QAAQ,QAAQ,YAAY;CAC9B;CACA,MAAM,WAA8B,CAAC;CACrC,IAAI,UAA6B,CAAC;CAElC,MAAM,UAAU,SAAmC;EACjD,IAAI,CAAC,UAAU,CAAC,sBAAsB,QAAQ,mBAAmB,KAAK,CAAC,GACrE,OAAO,IAAI,yBAAyB,CAAC,GAAG,SAAS,KAAA,GAAW,qBAAqB;EACnF,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,WAAW,gBAAgB,OAAO,MAAM,YAAY;EAC1D,IAAI,CAAC,UAAU,OAAO;EACtB,SAAS,KAAK,GAAG,SAAS,QAAQ;EAClC,UAAU,SAAS;EACnB,OAAO,QAAQ,SAAS,IAAI,IAAI,yBAAyB,SAAS,SAAS,KAAA,CAAS,IAAI;CAC1F;;;;;CAMA,MAAM,eAA4C;EAChD,MAAM,OAAO;EACb,IAAI,SAAS,WAAW,KAAK,KAAK,WAAW,GAAG,OAAO;EACvD,MAAM,aAAa,CACjB,GAAG,KAAK,KAAK,eAAe;GAAE,GAAG;GAAW,UAAU;EAAgB,EAAE,GACxE,GAAG,QACL;EAIA,OAAO;GAAE,WAHI,KAAK,SACd,yHACA,MACsB,uBAAuB,YAAY,SAAS,KAAA,CAAS;GAAG;EAAW;CAC/F;CAEA,OAAO;EACL,eAAe,WACb,OAAO;GACL,SAAS,OAAO;GAChB,SAAS,OAAO,QAAQ,SAAS,WAAY,OAAO,SAAS,CAAC,OAAO,MAAM,IAAI,CAAC,CAAE;GAClF,SAAS,OAAO;GAChB,WAAW,OAAO,UAAU,SAAS,EAAE,IAAI,QAAQ,UAAU,YAC3D,QAAQ,CAAC;IAAE;IAAI,QAAQ;GAAS,CAAC,IAAI,CAAC,CACxC;EACF,CAAC;EACH,eAAe,OAAO,YAAY,CAAC,MACjC,OAAO;GACL,SAAS,CAAC;GACV,SAAS;GACT,WAAW,UAAU,KAAK,EAAE,IAAI,QAAQ,gBAAgB;IAAE;IAAI,QAAQ;GAAS,EAAE;EACnF,CAAC;EACH;EACA,WAAW,WAAW;GACpB,MAAM,gBAAgB,OAAO;GAC7B,IAAI,CAAC,eAAe,OAAO;GAC3B,IAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,GAC/D,OAAO;IAAE,GAAG;IAAQ;GAAc;GACpC,OAAO;IAAE;IAAQ;GAAc;EACjC;CACF;AACF"}
@@ -0,0 +1,9 @@
1
+ import { AllowedValue, COLOR_TOLERANCE, DesignGroupRules, DesignRules, NUMBER_TOLERANCE, SystemValue, isColor, isStyleNode, nearestColor, nearestNumber, resolveDesignRules, styleValues, variableValues } from "./rules.js";
2
+ import { DesignCheckOptions, DesignEdit, DesignFindings, DesignValueVerdict, DesignViolation, checkDesignEdit, checkDesignValues, designViolations } from "./check.js";
3
+ import { DesignExampleReport, DesignGroupReport, DesignMemoryReport, describeDesignMemory } from "./describe.js";
4
+ import { DistilledValue, DistilledValues, distilDesignValues, proposesValue } from "./distil.js";
5
+ import { currentDesignRules } from "./document.js";
6
+ import { DesignGuard, DesignGuardOptions, DesignMemoryMode, DesignMemoryWarnings, createDesignGuard } from "./guard.js";
7
+ import { DESIGN_VALUE_NOUNS, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, describeDesignViolation, describeDesignWarnings } from "./refusal.js";
8
+ import { DesignValue, copiedValueKey, designValueKey, designValues } from "./values.js";
9
+ export { AllowedValue, COLOR_TOLERANCE, DESIGN_VALUE_NOUNS, DesignCheckOptions, DesignEdit, DesignExampleReport, DesignFindings, DesignGroupReport, DesignGroupRules, DesignGuard, DesignGuardOptions, DesignMemoryMode, DesignMemoryRefusalError, DesignMemoryReport, DesignMemoryWarnings, DesignRules, DesignValue, DesignValueVerdict, DesignViolation, DistilledValue, DistilledValues, MEMORY_CHANGE_REFUSED, NUMBER_TOLERANCE, SystemValue, checkDesignEdit, checkDesignValues, copiedValueKey, createDesignGuard, currentDesignRules, describeDesignMemory, describeDesignViolation, describeDesignWarnings, designValueKey, designValues, designViolations, distilDesignValues, isColor, isStyleNode, nearestColor, nearestNumber, proposesValue, resolveDesignRules, styleValues, variableValues };
@@ -0,0 +1,9 @@
1
+ import { COLOR_TOLERANCE, NUMBER_TOLERANCE, isColor, isStyleNode, nearestColor, nearestNumber, resolveDesignRules, styleValues, variableValues } from "./rules.js";
2
+ import { currentDesignRules } from "./document.js";
3
+ import { copiedValueKey, designValueKey, designValues } from "./values.js";
4
+ import { checkDesignEdit, checkDesignValues, designViolations } from "./check.js";
5
+ import { describeDesignMemory } from "./describe.js";
6
+ import { distilDesignValues, proposesValue } from "./distil.js";
7
+ import { DESIGN_VALUE_NOUNS, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, describeDesignViolation, describeDesignWarnings } from "./refusal.js";
8
+ import { createDesignGuard } from "./guard.js";
9
+ export { COLOR_TOLERANCE, DESIGN_VALUE_NOUNS, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, NUMBER_TOLERANCE, checkDesignEdit, checkDesignValues, copiedValueKey, createDesignGuard, currentDesignRules, describeDesignMemory, describeDesignViolation, describeDesignWarnings, designValueKey, designValues, designViolations, distilDesignValues, isColor, isStyleNode, nearestColor, nearestNumber, proposesValue, resolveDesignRules, styleValues, variableValues };
@@ -0,0 +1,32 @@
1
+ import { DesignRules } from "./rules.js";
2
+ import { DesignViolation } from "./check.js";
3
+ import { DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
4
+ //#region src/design-memory/refusal.d.ts
5
+ /** What one value of each group is called in messages. */
6
+ declare const DESIGN_VALUE_NOUNS: Record<DesignMemoryGroup, string>;
7
+ /** One violation as a line an agent can act on. */
8
+ declare function describeDesignViolation(violation: DesignViolation, rules?: DesignRules): string;
9
+ /**
10
+ * An agent's edit undone because it used values the document's design memory does not allow.
11
+ * Its message stands on its own for any client: what broke the memory, the closest allowed
12
+ * values, and what to do instead.
13
+ */
14
+ declare class DesignMemoryRefusalError extends Error {
15
+ readonly violations: readonly DesignViolation[];
16
+ name: string;
17
+ constructor(violations: readonly DesignViolation[], rules?: DesignRules, message?: string);
18
+ /** The failed call's result, with the violations for interfaces that offer to allow them. */
19
+ toResult(): {
20
+ error: string;
21
+ design_memory: {
22
+ refused: readonly DesignViolation[];
23
+ };
24
+ };
25
+ }
26
+ /** Why an agent's change to the memory itself was undone. */
27
+ declare const MEMORY_CHANGE_REFUSED: string;
28
+ /** Warnings an edit that went through carries in its result. */
29
+ declare function describeDesignWarnings(violations: readonly DesignViolation[], rules?: DesignRules): string;
30
+ //#endregion
31
+ export { DESIGN_VALUE_NOUNS, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, describeDesignViolation, describeDesignWarnings };
32
+ //# sourceMappingURL=refusal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.d.ts","names":[],"sources":["../../src/design-memory/refusal.ts"],"mappings":";;;;;cAWa,oBAAoB,OAAO;;iBAuBxB,wBAAwB,WAAW,iBAAiB,QAAQ;;;;;;cAyB/D,iCAAiC;WAIjC,qBAAqB;EAHvB;EAGE,YAAA,qBAAqB,mBAC9B,QAAQ,aACR;;EAQF;IAAc;IAAe;MAAiB,kBAAkB;;;;;cAMrD;;iBAKG,uBACd,qBAAqB,mBACrB,QAAQ"}
@@ -0,0 +1,68 @@
1
+ //#region src/design-memory/refusal.ts
2
+ /** How many violations a message names before it counts the rest. */
3
+ const NAMED_VIOLATIONS = 8;
4
+ /** How many allowed fonts a message lists. */
5
+ const LISTED_FONTS = 8;
6
+ /** What one value of each group is called in messages. */
7
+ const DESIGN_VALUE_NOUNS = {
8
+ colors: "color",
9
+ fonts: "font",
10
+ fontSizes: "font size",
11
+ spacing: "spacing",
12
+ radius: "corner radius"
13
+ };
14
+ function quote(value) {
15
+ return typeof value === "number" ? `${value}` : `"${value}"`;
16
+ }
17
+ function describeNearest(violation) {
18
+ const { nearest } = violation;
19
+ if (!nearest) return "";
20
+ return ` — nearest allowed: ${nearest.name ? `"${nearest.name}" ${nearest.value}` : `${nearest.value}`}${nearest.variableId ? ` (bind variable ${nearest.variableId} to ${violation.path})` : ""}`;
21
+ }
22
+ /** One violation as a line an agent can act on. */
23
+ function describeDesignViolation(violation, rules) {
24
+ const where = `"${violation.nodeName}" (${violation.nodeId}) ${violation.path}`;
25
+ const noun = DESIGN_VALUE_NOUNS[violation.group];
26
+ let line = `${where} ${quote(violation.value)} is not an allowed ${noun}${describeNearest(violation)}`;
27
+ if (violation.group === "fonts" && rules) {
28
+ const fonts = rules.fonts.allowed.slice(0, LISTED_FONTS).map((font) => font.value);
29
+ if (fonts.length > 0) line += ` — allowed: ${fonts.join(", ")}`;
30
+ }
31
+ return line;
32
+ }
33
+ function describeAll(violations, rules) {
34
+ const lines = violations.slice(0, NAMED_VIOLATIONS).map((violation) => describeDesignViolation(violation, rules));
35
+ const more = violations.length - NAMED_VIOLATIONS;
36
+ if (more > 0) lines.push(`+${more} more`);
37
+ return lines.join("\n");
38
+ }
39
+ /**
40
+ * An agent's edit undone because it used values the document's design memory does not allow.
41
+ * Its message stands on its own for any client: what broke the memory, the closest allowed
42
+ * values, and what to do instead.
43
+ */
44
+ var DesignMemoryRefusalError = class extends Error {
45
+ violations;
46
+ name = "DesignMemoryRefusalError";
47
+ constructor(violations, rules, message = `Refused by the document's design memory; nothing was changed.\n${describeAll(violations, rules)}\nUse only allowed values (get_design_memory lists them, check_design_values checks yours). To propose a new value, write it down with record_design_decision; the person adds it with Allow.`) {
48
+ super(message);
49
+ this.violations = violations;
50
+ }
51
+ /** The failed call's result, with the violations for interfaces that offer to allow them. */
52
+ toResult() {
53
+ return {
54
+ error: this.message,
55
+ design_memory: { refused: this.violations }
56
+ };
57
+ }
58
+ };
59
+ /** Why an agent's change to the memory itself was undone. */
60
+ const MEMORY_CHANGE_REFUSED = "Refused: agents cannot change, switch off or remove the document's design memory; nothing was changed. Write decisions down and pin examples with record_design_decision; the person changes what the memory allows.";
61
+ /** Warnings an edit that went through carries in its result. */
62
+ function describeDesignWarnings(violations, rules) {
63
+ return `The edit used values the document's design memory warns about; prefer allowed values.\n${describeAll(violations, rules)}`;
64
+ }
65
+ //#endregion
66
+ export { DESIGN_VALUE_NOUNS, DesignMemoryRefusalError, MEMORY_CHANGE_REFUSED, describeDesignViolation, describeDesignWarnings };
67
+
68
+ //# sourceMappingURL=refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.js","names":[],"sources":["../../src/design-memory/refusal.ts"],"sourcesContent":["import type { DesignMemoryGroup } from '@pairdraw/scene-graph/design-memory'\n\nimport type { DesignViolation } from './check'\nimport type { DesignRules } from './rules'\n\n/** How many violations a message names before it counts the rest. */\nconst NAMED_VIOLATIONS = 8\n/** How many allowed fonts a message lists. */\nconst LISTED_FONTS = 8\n\n/** What one value of each group is called in messages. */\nexport const DESIGN_VALUE_NOUNS: Record<DesignMemoryGroup, string> = {\n colors: 'color',\n fonts: 'font',\n fontSizes: 'font size',\n spacing: 'spacing',\n radius: 'corner radius'\n}\n\nfunction quote(value: string | number): string {\n return typeof value === 'number' ? `${value}` : `\"${value}\"`\n}\n\nfunction describeNearest(violation: DesignViolation): string {\n const { nearest } = violation\n if (!nearest) return ''\n const named = nearest.name ? `\"${nearest.name}\" ${nearest.value}` : `${nearest.value}`\n const bind = nearest.variableId\n ? ` (bind variable ${nearest.variableId} to ${violation.path})`\n : ''\n return ` — nearest allowed: ${named}${bind}`\n}\n\n/** One violation as a line an agent can act on. */\nexport function describeDesignViolation(violation: DesignViolation, rules?: DesignRules): string {\n const where = `\"${violation.nodeName}\" (${violation.nodeId}) ${violation.path}`\n const noun = DESIGN_VALUE_NOUNS[violation.group]\n let line = `${where} ${quote(violation.value)} is not an allowed ${noun}${describeNearest(violation)}`\n if (violation.group === 'fonts' && rules) {\n const fonts = rules.fonts.allowed.slice(0, LISTED_FONTS).map((font) => font.value)\n if (fonts.length > 0) line += ` — allowed: ${fonts.join(', ')}`\n }\n return line\n}\n\nfunction describeAll(violations: readonly DesignViolation[], rules?: DesignRules): string {\n const lines = violations\n .slice(0, NAMED_VIOLATIONS)\n .map((violation) => describeDesignViolation(violation, rules))\n const more = violations.length - NAMED_VIOLATIONS\n if (more > 0) lines.push(`+${more} more`)\n return lines.join('\\n')\n}\n\n/**\n * An agent's edit undone because it used values the document's design memory does not allow.\n * Its message stands on its own for any client: what broke the memory, the closest allowed\n * values, and what to do instead.\n */\nexport class DesignMemoryRefusalError extends Error {\n override name = 'DesignMemoryRefusalError'\n\n constructor(\n readonly violations: readonly DesignViolation[],\n rules?: DesignRules,\n message = `Refused by the document's design memory; nothing was changed.\\n${describeAll(violations, rules)}\\n` +\n 'Use only allowed values (get_design_memory lists them, check_design_values checks yours). ' +\n 'To propose a new value, write it down with record_design_decision; the person adds it with Allow.'\n ) {\n super(message)\n }\n\n /** The failed call's result, with the violations for interfaces that offer to allow them. */\n toResult(): { error: string; design_memory: { refused: readonly DesignViolation[] } } {\n return { error: this.message, design_memory: { refused: this.violations } }\n }\n}\n\n/** Why an agent's change to the memory itself was undone. */\nexport const MEMORY_CHANGE_REFUSED =\n \"Refused: agents cannot change, switch off or remove the document's design memory; nothing was changed. \" +\n 'Write decisions down and pin examples with record_design_decision; the person changes what the memory allows.'\n\n/** Warnings an edit that went through carries in its result. */\nexport function describeDesignWarnings(\n violations: readonly DesignViolation[],\n rules?: DesignRules\n): string {\n return `The edit used values the document's design memory warns about; prefer allowed values.\\n${describeAll(violations, rules)}`\n}\n"],"mappings":";;AAMA,MAAM,mBAAmB;;AAEzB,MAAM,eAAe;;AAGrB,MAAa,qBAAwD;CACnE,QAAQ;CACR,OAAO;CACP,WAAW;CACX,SAAS;CACT,QAAQ;AACV;AAEA,SAAS,MAAM,OAAgC;CAC7C,OAAO,OAAO,UAAU,WAAW,GAAG,UAAU,IAAI,MAAM;AAC5D;AAEA,SAAS,gBAAgB,WAAoC;CAC3D,MAAM,EAAE,YAAY;CACpB,IAAI,CAAC,SAAS,OAAO;CAKrB,OAAO,uBAJO,QAAQ,OAAO,IAAI,QAAQ,KAAK,IAAI,QAAQ,UAAU,GAAG,QAAQ,UAClE,QAAQ,aACjB,mBAAmB,QAAQ,WAAW,MAAM,UAAU,KAAK,KAC3D;AAEN;;AAGA,SAAgB,wBAAwB,WAA4B,OAA6B;CAC/F,MAAM,QAAQ,IAAI,UAAU,SAAS,KAAK,UAAU,OAAO,IAAI,UAAU;CACzE,MAAM,OAAO,mBAAmB,UAAU;CAC1C,IAAI,OAAO,GAAG,MAAM,GAAG,MAAM,UAAU,KAAK,EAAE,qBAAqB,OAAO,gBAAgB,SAAS;CACnG,IAAI,UAAU,UAAU,WAAW,OAAO;EACxC,MAAM,QAAQ,MAAM,MAAM,QAAQ,MAAM,GAAG,YAAY,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK;EACjF,IAAI,MAAM,SAAS,GAAG,QAAQ,eAAe,MAAM,KAAK,IAAI;CAC9D;CACA,OAAO;AACT;AAEA,SAAS,YAAY,YAAwC,OAA6B;CACxF,MAAM,QAAQ,WACX,MAAM,GAAG,gBAAgB,CAAC,CAC1B,KAAK,cAAc,wBAAwB,WAAW,KAAK,CAAC;CAC/D,MAAM,OAAO,WAAW,SAAS;CACjC,IAAI,OAAO,GAAG,MAAM,KAAK,IAAI,KAAK,MAAM;CACxC,OAAO,MAAM,KAAK,IAAI;AACxB;;;;;;AAOA,IAAa,2BAAb,cAA8C,MAAM;CAIvC;CAHX,OAAgB;CAEhB,YACE,YACA,OACA,UAAU,kEAAkE,YAAY,YAAY,KAAK,EAAE,gMAG3G;EACA,MAAM,OAAO;EANJ,KAAA,aAAA;CAOX;;CAGA,WAAsF;EACpF,OAAO;GAAE,OAAO,KAAK;GAAS,eAAe,EAAE,SAAS,KAAK,WAAW;EAAE;CAC5E;AACF;;AAGA,MAAa,wBACX;;AAIF,SAAgB,uBACd,YACA,OACQ;CACR,OAAO,0FAA0F,YAAY,YAAY,KAAK;AAChI"}
@@ -0,0 +1,63 @@
1
+ import { SceneGraph, SceneNode, Variable } from "@pairdraw/scene-graph";
2
+ import { DesignMemory, DesignMemoryEnforcement, DesignMemoryGroup } from "@pairdraw/scene-graph/design-memory";
3
+ import { Color } from "@pairdraw/scene-graph/primitives";
4
+ //#region src/design-memory/rules.d.ts
5
+ /** One value a group allows, with the variable or style that gives it, when one does. */
6
+ interface AllowedValue<T> {
7
+ value: T;
8
+ /** The variable's or style's name; null for a value the person added. */
9
+ name: string | null;
10
+ /** The variable that holds it, which a fix binds; null for a style's or the person's. */
11
+ variableId: string | null;
12
+ }
13
+ interface DesignGroupRules<T> {
14
+ /** `off` too for a group with nothing to allow, which never refuses everything. */
15
+ enforce: DesignMemoryEnforcement;
16
+ fromSystem: boolean;
17
+ allowed: AllowedValue<T>[];
18
+ }
19
+ /** A document's memory with each group's allowed values resolved from the document. */
20
+ interface DesignRules {
21
+ memory: DesignMemory;
22
+ colors: DesignGroupRules<string>;
23
+ fonts: DesignGroupRules<string>;
24
+ fontSizes: DesignGroupRules<number>;
25
+ spacing: DesignGroupRules<number>;
26
+ radius: DesignGroupRules<number>;
27
+ }
28
+ /** How far apart in OKLab two colors may be and still count as one: about a just-noticeable difference. */
29
+ declare const COLOR_TOLERANCE = 0.02;
30
+ /** How far apart two numbers may be and still count as one, for rounding noise. */
31
+ declare const NUMBER_TOLERANCE = 0.01;
32
+ /** Whether a variable's value is a color. */
33
+ declare function isColor(value: unknown): value is Color;
34
+ /** A value a variable or a style gives a group of the memory. */
35
+ interface SystemValue {
36
+ group: DesignMemoryGroup;
37
+ value: string | number;
38
+ }
39
+ /**
40
+ * The values a variable gives the memory, in every mode of its collection: a color variable's
41
+ * colors, a font family variable's families, and a number scoped to font sizes, gaps or corner
42
+ * radii. A number for every scope is in no group.
43
+ */
44
+ declare function variableValues(graph: SceneGraph, variable: Variable): SystemValue[];
45
+ /** The values a fill, stroke or text style gives the memory, kept on the layer that defines it. */
46
+ declare function styleValues(node: SceneNode): SystemValue[];
47
+ /** Whether a layer defines a shared style, whose values join the system. */
48
+ declare function isStyleNode(node: SceneNode): boolean;
49
+ /**
50
+ * The memory's rules with the document's variables and styles resolved into each group. Style
51
+ * layers are found by walking the document unless `styleNodes` lists them.
52
+ */
53
+ declare function resolveDesignRules(graph: SceneGraph, memory: DesignMemory, styleNodes?: Iterable<SceneNode>): DesignRules;
54
+ /** The allowed color closest to `hex`, with how far it is. */
55
+ declare function nearestColor(rules: DesignGroupRules<string>, hex: string): {
56
+ allowed: AllowedValue<string>;
57
+ distance: number;
58
+ } | null;
59
+ /** The allowed number closest to `value`. */
60
+ declare function nearestNumber(rules: DesignGroupRules<number>, value: number): AllowedValue<number> | null;
61
+ //#endregion
62
+ export { AllowedValue, COLOR_TOLERANCE, DesignGroupRules, DesignRules, NUMBER_TOLERANCE, SystemValue, isColor, isStyleNode, nearestColor, nearestNumber, resolveDesignRules, styleValues, variableValues };
63
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","names":[],"sources":["../../src/design-memory/rules.ts"],"mappings":";;;;;UAeiB,aAAa;EAC5B,OAAO;;EAEP;;EAEA;;UAGe,iBAAiB;;EAEhC,SAAS;EACT;EACA,SAAS,aAAa;;;UAIP;EACf,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,WAAW;EACX,SAAS;EACT,QAAQ;;;cAIG;;cAEA;;iBA2BG,QAAQ,iBAAiB,SAAS;;UAKjC;EACf,OAAO;EACP;;;;;;;iBAQc,eAAe,OAAO,YAAY,UAAU,WAAW;;iBAgCvD,YAAY,MAAM,YAAY;;iBAW9B,YAAY,MAAM;;;;;iBAkDlB,mBACd,OAAO,YACP,QAAQ,cACR,aAAY,SAAS,aACpB;;iBA6Da,aACd,OAAO,0BACP;EACG,SAAS;EAAsB;;;iBAmBpB,cACd,OAAO,0BACP,gBACC"}