@pairdraw/core 0.19.2 → 0.21.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 (1170) 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 +46 -0
  32. package/dist/canvas/noise/shader.d.ts.map +1 -0
  33. package/dist/canvas/noise/shader.js +166 -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 +74 -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/colors.d.ts +20 -5
  49. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  50. package/dist/canvas/renderer/colors.js +48 -42
  51. package/dist/canvas/renderer/colors.js.map +1 -1
  52. package/dist/canvas/renderer/document-surface.d.ts +25 -0
  53. package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
  54. package/dist/canvas/renderer/document-surface.js +46 -0
  55. package/dist/canvas/renderer/document-surface.js.map +1 -0
  56. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  57. package/dist/canvas/renderer/fonts.js +6 -4
  58. package/dist/canvas/renderer/fonts.js.map +1 -1
  59. package/dist/canvas/renderer/lifecycle.d.ts.map +1 -1
  60. package/dist/canvas/renderer/lifecycle.js +10 -3
  61. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  62. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  63. package/dist/canvas/renderer/methods.js +1 -0
  64. package/dist/canvas/renderer/methods.js.map +1 -1
  65. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  66. package/dist/canvas/renderer/pipeline.js +36 -3
  67. package/dist/canvas/renderer/pipeline.js.map +1 -1
  68. package/dist/canvas/renderer/play-scenes.d.ts +13 -0
  69. package/dist/canvas/renderer/play-scenes.d.ts.map +1 -0
  70. package/dist/canvas/renderer/play-scenes.js +40 -0
  71. package/dist/canvas/renderer/play-scenes.js.map +1 -0
  72. package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
  73. package/dist/canvas/renderer/retained-backing.js +2 -1
  74. package/dist/canvas/renderer/retained-backing.js.map +1 -1
  75. package/dist/canvas/renderer/tiles/cache.d.ts +19 -1
  76. package/dist/canvas/renderer/tiles/cache.d.ts.map +1 -1
  77. package/dist/canvas/renderer/tiles/cache.js +32 -1
  78. package/dist/canvas/renderer/tiles/cache.js.map +1 -1
  79. package/dist/canvas/renderer/tiles/controller.d.ts +11 -0
  80. package/dist/canvas/renderer/tiles/controller.d.ts.map +1 -1
  81. package/dist/canvas/renderer/tiles/controller.js +18 -1
  82. package/dist/canvas/renderer/tiles/controller.js.map +1 -1
  83. package/dist/canvas/renderer/tiles/index.d.ts +2 -2
  84. package/dist/canvas/renderer/tiles/planner.d.ts +1 -1
  85. package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
  86. package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
  87. package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
  88. package/dist/canvas/renderer/types.d.ts +18 -3
  89. package/dist/canvas/renderer/types.d.ts.map +1 -1
  90. package/dist/canvas/renderer/visual-bounds.d.ts +1 -1
  91. package/dist/canvas/renderer/visual-bounds.js +1 -1
  92. package/dist/canvas/renderer.d.ts +42 -4
  93. package/dist/canvas/renderer.d.ts.map +1 -1
  94. package/dist/canvas/renderer.js +57 -5
  95. package/dist/canvas/renderer.js.map +1 -1
  96. package/dist/canvas/scene.d.ts +2 -1
  97. package/dist/canvas/scene.d.ts.map +1 -1
  98. package/dist/canvas/scene.js +45 -12
  99. package/dist/canvas/scene.js.map +1 -1
  100. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  101. package/dist/canvas/shaders/effect.js +2 -1
  102. package/dist/canvas/shaders/effect.js.map +1 -1
  103. package/dist/canvas/shadows/shape.d.ts.map +1 -1
  104. package/dist/canvas/shadows/shape.js +4 -2
  105. package/dist/canvas/shadows/shape.js.map +1 -1
  106. package/dist/canvas/shadows/silhouette.js +1 -1
  107. package/dist/canvas/shadows.d.ts.map +1 -1
  108. package/dist/canvas/shadows.js +4 -2
  109. package/dist/canvas/shadows.js.map +1 -1
  110. package/dist/canvas/text/decorations.d.ts +2 -2
  111. package/dist/canvas/text/decorations.d.ts.map +1 -1
  112. package/dist/canvas/text/decorations.js +5 -5
  113. package/dist/canvas/text/decorations.js.map +1 -1
  114. package/dist/canvas/text/index.js +1 -1
  115. package/dist/canvas/text/index.js.map +1 -1
  116. package/dist/canvas/text/paragraph/index.d.ts +2 -2
  117. package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
  118. package/dist/canvas/text/paragraph/index.js +16 -5
  119. package/dist/canvas/text/paragraph/index.js.map +1 -1
  120. package/dist/canvas/text/renderer.d.ts +2 -1
  121. package/dist/canvas/text/renderer.d.ts.map +1 -1
  122. package/dist/canvas/text/shape.js +4 -4
  123. package/dist/canvas/text/shape.js.map +1 -1
  124. package/dist/canvas/texture.d.ts +20 -0
  125. package/dist/canvas/texture.d.ts.map +1 -0
  126. package/dist/canvas/texture.js +101 -0
  127. package/dist/canvas/texture.js.map +1 -0
  128. package/dist/clipboard.js +16 -5
  129. package/dist/clipboard.js.map +1 -1
  130. package/dist/constants.d.ts +5 -1
  131. package/dist/constants.d.ts.map +1 -1
  132. package/dist/constants.js +5 -1
  133. package/dist/constants.js.map +1 -1
  134. package/dist/design-jsx/renderer.d.ts.map +1 -1
  135. package/dist/design-memory/check.d.ts +90 -0
  136. package/dist/design-memory/check.d.ts.map +1 -0
  137. package/dist/design-memory/check.js +281 -0
  138. package/dist/design-memory/check.js.map +1 -0
  139. package/dist/design-memory/describe.d.ts +37 -0
  140. package/dist/design-memory/describe.d.ts.map +1 -0
  141. package/dist/design-memory/describe.js +52 -0
  142. package/dist/design-memory/describe.js.map +1 -0
  143. package/dist/design-memory/distil.d.ts +22 -0
  144. package/dist/design-memory/distil.d.ts.map +1 -0
  145. package/dist/design-memory/distil.js +54 -0
  146. package/dist/design-memory/distil.js.map +1 -0
  147. package/dist/design-memory/document.d.ts +12 -0
  148. package/dist/design-memory/document.d.ts.map +1 -0
  149. package/dist/design-memory/document.js +64 -0
  150. package/dist/design-memory/document.js.map +1 -0
  151. package/dist/design-memory/guard.d.ts +48 -0
  152. package/dist/design-memory/guard.d.ts.map +1 -0
  153. package/dist/design-memory/guard.js +105 -0
  154. package/dist/design-memory/guard.js.map +1 -0
  155. package/dist/design-memory/index.d.ts +9 -0
  156. package/dist/design-memory/index.js +9 -0
  157. package/dist/design-memory/refusal.d.ts +32 -0
  158. package/dist/design-memory/refusal.d.ts.map +1 -0
  159. package/dist/design-memory/refusal.js +68 -0
  160. package/dist/design-memory/refusal.js.map +1 -0
  161. package/dist/design-memory/rules.d.ts +63 -0
  162. package/dist/design-memory/rules.d.ts.map +1 -0
  163. package/dist/design-memory/rules.js +224 -0
  164. package/dist/design-memory/rules.js.map +1 -0
  165. package/dist/design-memory/values.d.ts +28 -0
  166. package/dist/design-memory/values.d.ts.map +1 -0
  167. package/dist/design-memory/values.js +160 -0
  168. package/dist/design-memory/values.js.map +1 -0
  169. package/dist/editor/alignment.js +1 -1
  170. package/dist/editor/bridges/components.d.ts +2 -0
  171. package/dist/editor/bridges/components.d.ts.map +1 -1
  172. package/dist/editor/bridges/components.js +2 -0
  173. package/dist/editor/bridges/components.js.map +1 -1
  174. package/dist/editor/clipboard/assets.d.ts.map +1 -1
  175. package/dist/editor/clipboard/assets.js +3 -3
  176. package/dist/editor/clipboard/assets.js.map +1 -1
  177. package/dist/editor/clipboard/component-matches.d.ts +13 -0
  178. package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
  179. package/dist/editor/clipboard/component-matches.js +50 -0
  180. package/dist/editor/clipboard/component-matches.js.map +1 -0
  181. package/dist/editor/clipboard/dependencies.d.ts +7 -0
  182. package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
  183. package/dist/editor/clipboard/dependencies.js +5 -0
  184. package/dist/editor/clipboard/dependencies.js.map +1 -1
  185. package/dist/editor/clipboard/export.d.ts.map +1 -1
  186. package/dist/editor/clipboard/export.js +16 -2
  187. package/dist/editor/clipboard/export.js.map +1 -1
  188. package/dist/editor/clipboard/placement.d.ts +1 -1
  189. package/dist/editor/clipboard/placement.js +1 -1
  190. package/dist/editor/clipboard.d.ts.map +1 -1
  191. package/dist/editor/clipboard.js +48 -19
  192. package/dist/editor/clipboard.js.map +1 -1
  193. package/dist/editor/components/instances.d.ts +2 -0
  194. package/dist/editor/components/instances.d.ts.map +1 -1
  195. package/dist/editor/components/instances.js +22 -1
  196. package/dist/editor/components/instances.js.map +1 -1
  197. package/dist/editor/components/properties.d.ts.map +1 -1
  198. package/dist/editor/components/properties.js +3 -3
  199. package/dist/editor/components/properties.js.map +1 -1
  200. package/dist/editor/components.d.ts +2 -0
  201. package/dist/editor/components.d.ts.map +1 -1
  202. package/dist/editor/connectors/attach.js +1 -1
  203. package/dist/editor/create.d.ts +26 -2
  204. package/dist/editor/create.d.ts.map +1 -1
  205. package/dist/editor/create.js +16 -60
  206. package/dist/editor/create.js.map +1 -1
  207. package/dist/editor/design-memory.d.ts +11 -0
  208. package/dist/editor/design-memory.d.ts.map +1 -0
  209. package/dist/editor/design-memory.js +40 -0
  210. package/dist/editor/design-memory.js.map +1 -0
  211. package/dist/editor/design-tokens.d.ts +4 -0
  212. package/dist/editor/design-tokens.d.ts.map +1 -1
  213. package/dist/editor/design-tokens.js +30 -1
  214. package/dist/editor/design-tokens.js.map +1 -1
  215. package/dist/editor/document-colors.d.ts +23 -0
  216. package/dist/editor/document-colors.d.ts.map +1 -0
  217. package/dist/editor/document-colors.js +53 -0
  218. package/dist/editor/document-colors.js.map +1 -0
  219. package/dist/editor/eyedropper.d.ts +47 -0
  220. package/dist/editor/eyedropper.d.ts.map +1 -0
  221. package/dist/editor/eyedropper.js +171 -0
  222. package/dist/editor/eyedropper.js.map +1 -0
  223. package/dist/editor/fonts.d.ts +9 -0
  224. package/dist/editor/fonts.d.ts.map +1 -0
  225. package/dist/editor/fonts.js +14 -0
  226. package/dist/editor/fonts.js.map +1 -0
  227. package/dist/editor/history/atomic-tool.d.ts +9 -2
  228. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  229. package/dist/editor/history/atomic-tool.js +9 -2
  230. package/dist/editor/history/atomic-tool.js.map +1 -1
  231. package/dist/editor/history/capture.d.ts +13 -0
  232. package/dist/editor/history/capture.d.ts.map +1 -0
  233. package/dist/editor/history/capture.js +28 -0
  234. package/dist/editor/history/capture.js.map +1 -0
  235. package/dist/editor/history/document-change.d.ts.map +1 -1
  236. package/dist/editor/history/document-change.js +2 -22
  237. package/dist/editor/history/document-change.js.map +1 -1
  238. package/dist/editor/history/edit.d.ts +7 -0
  239. package/dist/editor/history/edit.d.ts.map +1 -1
  240. package/dist/editor/history/edit.js +4 -2
  241. package/dist/editor/history/edit.js.map +1 -1
  242. package/dist/editor/history/subtree.d.ts +9 -0
  243. package/dist/editor/history/subtree.d.ts.map +1 -1
  244. package/dist/editor/history/subtree.js +12 -2
  245. package/dist/editor/history/subtree.js.map +1 -1
  246. package/dist/editor/index.d.ts +4 -2
  247. package/dist/editor/index.js +4 -2
  248. package/dist/editor/pages.d.ts +7 -5
  249. package/dist/editor/pages.d.ts.map +1 -1
  250. package/dist/editor/pages.js +35 -25
  251. package/dist/editor/pages.js.map +1 -1
  252. package/dist/editor/play/states.d.ts +3 -1
  253. package/dist/editor/play/states.d.ts.map +1 -1
  254. package/dist/editor/play/states.js +1 -1
  255. package/dist/editor/play/states.js.map +1 -1
  256. package/dist/editor/read-only/actions.js +4 -0
  257. package/dist/editor/read-only/actions.js.map +1 -1
  258. package/dist/editor/render-requests.d.ts +18 -0
  259. package/dist/editor/render-requests.d.ts.map +1 -0
  260. package/dist/editor/render-requests.js +76 -0
  261. package/dist/editor/render-requests.js.map +1 -0
  262. package/dist/editor/scale/rescale.d.ts +1 -1
  263. package/dist/editor/selection/overlays.d.ts.map +1 -1
  264. package/dist/editor/selection/overlays.js +1 -1
  265. package/dist/editor/selection/overlays.js.map +1 -1
  266. package/dist/editor/selection/read.d.ts +4 -0
  267. package/dist/editor/selection.d.ts +5 -0
  268. package/dist/editor/selection.d.ts.map +1 -1
  269. package/dist/editor/shapes/pencil.js +1 -1
  270. package/dist/editor/structure/state.d.ts.map +1 -1
  271. package/dist/editor/structure/state.js +2 -2
  272. package/dist/editor/structure/state.js.map +1 -1
  273. package/dist/editor/text.d.ts.map +1 -1
  274. package/dist/editor/text.js +2 -2
  275. package/dist/editor/text.js.map +1 -1
  276. package/dist/editor/tool-registry.d.ts.map +1 -1
  277. package/dist/editor/tool-registry.js +2 -1
  278. package/dist/editor/tool-registry.js.map +1 -1
  279. package/dist/editor/types.d.ts +5 -1
  280. package/dist/editor/types.d.ts.map +1 -1
  281. package/dist/editor/variables.js +3 -3
  282. package/dist/editor/variables.js.map +1 -1
  283. package/dist/editor/variations/create.d.ts +28 -0
  284. package/dist/editor/variations/create.d.ts.map +1 -0
  285. package/dist/editor/variations/create.js +176 -0
  286. package/dist/editor/variations/create.js.map +1 -0
  287. package/dist/editor/variations/pick.d.ts +16 -0
  288. package/dist/editor/variations/pick.d.ts.map +1 -0
  289. package/dist/editor/variations/pick.js +23 -0
  290. package/dist/editor/variations/pick.js.map +1 -0
  291. package/dist/editor/variations.d.ts +28 -0
  292. package/dist/editor/variations.d.ts.map +1 -0
  293. package/dist/editor/variations.js +88 -0
  294. package/dist/editor/variations.js.map +1 -0
  295. package/dist/figma-api/accessors/reactions.d.ts.map +1 -1
  296. package/dist/figma-api/accessors/reactions.js +4 -1
  297. package/dist/figma-api/accessors/reactions.js.map +1 -1
  298. package/dist/figma-api/accessors/text/index.js +3 -0
  299. package/dist/figma-api/accessors/text/index.js.map +1 -1
  300. package/dist/figma-api/accessors/text/opentype.d.ts +17 -0
  301. package/dist/figma-api/accessors/text/opentype.d.ts.map +1 -0
  302. package/dist/figma-api/accessors/text/opentype.js +28 -0
  303. package/dist/figma-api/accessors/text/opentype.js.map +1 -0
  304. package/dist/figma-api/accessors/visual.d.ts.map +1 -1
  305. package/dist/figma-api/accessors/visual.js +33 -0
  306. package/dist/figma-api/accessors/visual.js.map +1 -1
  307. package/dist/figma-api/effects.d.ts +79 -3
  308. package/dist/figma-api/effects.d.ts.map +1 -1
  309. package/dist/figma-api/effects.js +150 -9
  310. package/dist/figma-api/effects.js.map +1 -1
  311. package/dist/figma-api/fresh-read.d.ts +15 -0
  312. package/dist/figma-api/fresh-read.d.ts.map +1 -0
  313. package/dist/figma-api/fresh-read.js +54 -0
  314. package/dist/figma-api/fresh-read.js.map +1 -0
  315. package/dist/figma-api/graph-ref.d.ts +9 -0
  316. package/dist/figma-api/graph-ref.d.ts.map +1 -0
  317. package/dist/figma-api/graph-ref.js +14 -0
  318. package/dist/figma-api/graph-ref.js.map +1 -0
  319. package/dist/figma-api/index.d.ts +11 -1
  320. package/dist/figma-api/index.d.ts.map +1 -1
  321. package/dist/figma-api/index.js +16 -4
  322. package/dist/figma-api/index.js.map +1 -1
  323. package/dist/figma-api/overrides.d.ts +13 -1
  324. package/dist/figma-api/overrides.d.ts.map +1 -1
  325. package/dist/figma-api/overrides.js +196 -4
  326. package/dist/figma-api/overrides.js.map +1 -1
  327. package/dist/figma-api/paints.d.ts +3 -3
  328. package/dist/figma-api/paints.d.ts.map +1 -1
  329. package/dist/figma-api/paints.js +14 -4
  330. package/dist/figma-api/paints.js.map +1 -1
  331. package/dist/figma-api/pending-layout.d.ts +3 -3
  332. package/dist/figma-api/pending-layout.d.ts.map +1 -1
  333. package/dist/figma-api/pending-layout.js +7 -3
  334. package/dist/figma-api/pending-layout.js.map +1 -1
  335. package/dist/figma-api/pending-sync.d.ts +1 -1
  336. package/dist/figma-api/pending-sync.d.ts.map +1 -1
  337. package/dist/figma-api/pending-sync.js +3 -1
  338. package/dist/figma-api/pending-sync.js.map +1 -1
  339. package/dist/figma-api/proxy.d.ts +4 -1
  340. package/dist/figma-api/proxy.d.ts.map +1 -1
  341. package/dist/figma-api/proxy.js +2 -1
  342. package/dist/figma-api/proxy.js.map +1 -1
  343. package/dist/figma-api/reactions.d.ts +59 -15
  344. package/dist/figma-api/reactions.d.ts.map +1 -1
  345. package/dist/figma-api/reactions.js +160 -32
  346. package/dist/figma-api/reactions.js.map +1 -1
  347. package/dist/figma-api/render-bounds.js +1 -1
  348. package/dist/figma-api/surface.d.ts +6 -3
  349. package/dist/figma-api/surface.d.ts.map +1 -1
  350. package/dist/figma-api/surface.js +6 -2
  351. package/dist/figma-api/surface.js.map +1 -1
  352. package/dist/figma-api/transform.d.ts +1 -1
  353. package/dist/figma-api/variables/index.d.ts.map +1 -1
  354. package/dist/figma-api/variables/index.js +2 -2
  355. package/dist/figma-api/variables/index.js.map +1 -1
  356. package/dist/geometry/figma.d.ts +1 -1
  357. package/dist/geometry/image-crop.d.ts +1 -1
  358. package/dist/geometry/image-crop.js +1 -1
  359. package/dist/index.d.ts +4 -2
  360. package/dist/index.js +4 -2
  361. package/dist/io/formats/boolean-path.d.ts +19 -0
  362. package/dist/io/formats/boolean-path.d.ts.map +1 -0
  363. package/dist/io/formats/boolean-path.js +47 -0
  364. package/dist/io/formats/boolean-path.js.map +1 -0
  365. package/dist/io/formats/design-tokens/css/known.js +1 -1
  366. package/dist/io/formats/design-tokens/css/known.js.map +1 -1
  367. package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
  368. package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
  369. package/dist/io/formats/design-tokens/css/read.js +11 -5
  370. package/dist/io/formats/design-tokens/css/read.js.map +1 -1
  371. package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
  372. package/dist/io/formats/design-tokens/css/sync.js +17 -4
  373. package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
  374. package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
  375. package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
  376. package/dist/io/formats/design-tokens/css/values.js +24 -8
  377. package/dist/io/formats/design-tokens/css/values.js.map +1 -1
  378. package/dist/io/formats/design-tokens/decode.d.ts +7 -6
  379. package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
  380. package/dist/io/formats/design-tokens/decode.js +14 -13
  381. package/dist/io/formats/design-tokens/decode.js.map +1 -1
  382. package/dist/io/formats/design-tokens/export.js +3 -3
  383. package/dist/io/formats/design-tokens/export.js.map +1 -1
  384. package/dist/io/formats/design-tokens/index.d.ts +4 -1
  385. package/dist/io/formats/design-tokens/index.js +4 -1
  386. package/dist/io/formats/design-tokens/plan/changes.d.ts +5 -3
  387. package/dist/io/formats/design-tokens/plan/changes.d.ts.map +1 -1
  388. package/dist/io/formats/design-tokens/plan/changes.js +1 -1
  389. package/dist/io/formats/design-tokens/plan/changes.js.map +1 -1
  390. package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
  391. package/dist/io/formats/design-tokens/plan/index.js +4 -3
  392. package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
  393. package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
  394. package/dist/io/formats/design-tokens/plan/styles.js +9 -9
  395. package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
  396. package/dist/io/formats/design-tokens/project.d.ts +17 -2
  397. package/dist/io/formats/design-tokens/project.d.ts.map +1 -1
  398. package/dist/io/formats/design-tokens/project.js +29 -8
  399. package/dist/io/formats/design-tokens/project.js.map +1 -1
  400. package/dist/io/formats/design-tokens/styles.d.ts +4 -4
  401. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  402. package/dist/io/formats/design-tokens/styles.js +7 -7
  403. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  404. package/dist/io/formats/design-tokens/sync/apply.d.ts +42 -0
  405. package/dist/io/formats/design-tokens/sync/apply.d.ts.map +1 -0
  406. package/dist/io/formats/design-tokens/sync/apply.js +73 -0
  407. package/dist/io/formats/design-tokens/sync/apply.js.map +1 -0
  408. package/dist/io/formats/design-tokens/sync/drift.d.ts +77 -0
  409. package/dist/io/formats/design-tokens/sync/drift.d.ts.map +1 -0
  410. package/dist/io/formats/design-tokens/sync/drift.js +391 -0
  411. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -0
  412. package/dist/io/formats/design-tokens/sync/files.d.ts +15 -0
  413. package/dist/io/formats/design-tokens/sync/files.d.ts.map +1 -0
  414. package/dist/io/formats/design-tokens/sync/files.js +35 -0
  415. package/dist/io/formats/design-tokens/sync/files.js.map +1 -0
  416. package/dist/io/formats/design-tokens/values.d.ts +10 -5
  417. package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
  418. package/dist/io/formats/design-tokens/values.js +13 -7
  419. package/dist/io/formats/design-tokens/values.js.map +1 -1
  420. package/dist/io/formats/drawio/edges.d.ts +7 -1
  421. package/dist/io/formats/drawio/edges.d.ts.map +1 -1
  422. package/dist/io/formats/drawio/edges.js +54 -1
  423. package/dist/io/formats/drawio/edges.js.map +1 -1
  424. package/dist/io/formats/drawio/export.d.ts.map +1 -1
  425. package/dist/io/formats/drawio/export.js +19 -2
  426. package/dist/io/formats/drawio/export.js.map +1 -1
  427. package/dist/io/formats/drawio/index.js +1 -0
  428. package/dist/io/formats/drawio/index.js.map +1 -1
  429. package/dist/io/formats/drawio/placement.d.ts +1 -1
  430. package/dist/io/formats/drawio/warnings.js +2 -2
  431. package/dist/io/formats/drawio/warnings.js.map +1 -1
  432. package/dist/io/formats/fig/export/index.d.ts.map +1 -1
  433. package/dist/io/formats/fig/export/index.js +15 -3
  434. package/dist/io/formats/fig/export/index.js.map +1 -1
  435. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  436. package/dist/io/formats/fig/export/patch/index.js +7 -1
  437. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  438. package/dist/io/formats/fig/export/setup.d.ts +7 -2
  439. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  440. package/dist/io/formats/fig/export/setup.js +12 -13
  441. package/dist/io/formats/fig/export/setup.js.map +1 -1
  442. package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
  443. package/dist/io/formats/fig/export/variables.js +9 -7
  444. package/dist/io/formats/fig/export/variables.js.map +1 -1
  445. package/dist/io/formats/fig/thumbnail-page.d.ts +3 -4
  446. package/dist/io/formats/fig/thumbnail-page.d.ts.map +1 -1
  447. package/dist/io/formats/fig/thumbnail-page.js.map +1 -1
  448. package/dist/io/formats/html/import.d.ts.map +1 -1
  449. package/dist/io/formats/html/import.js +3 -1
  450. package/dist/io/formats/html/import.js.map +1 -1
  451. package/dist/io/formats/html/index.d.ts +2 -2
  452. package/dist/io/formats/html/index.d.ts.map +1 -1
  453. package/dist/io/formats/html/index.js +6 -4
  454. package/dist/io/formats/html/index.js.map +1 -1
  455. package/dist/io/formats/html/vectors.d.ts +2 -1
  456. package/dist/io/formats/html/vectors.d.ts.map +1 -1
  457. package/dist/io/formats/html/vectors.js +4 -2
  458. package/dist/io/formats/html/vectors.js.map +1 -1
  459. package/dist/io/formats/mermaid/layers.js +2 -2
  460. package/dist/io/formats/mermaid/layers.js.map +1 -1
  461. package/dist/io/formats/pdf/document.d.ts +3 -1
  462. package/dist/io/formats/pdf/document.d.ts.map +1 -1
  463. package/dist/io/formats/pdf/document.js +6 -3
  464. package/dist/io/formats/pdf/document.js.map +1 -1
  465. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  466. package/dist/io/formats/pdf/export.js +1 -0
  467. package/dist/io/formats/pdf/export.js.map +1 -1
  468. package/dist/io/formats/pdf/prepare.d.ts +4 -4
  469. package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
  470. package/dist/io/formats/pdf/prepare.js +2 -2
  471. package/dist/io/formats/pdf/prepare.js.map +1 -1
  472. package/dist/io/formats/pen/imports.d.ts +4 -1
  473. package/dist/io/formats/pen/imports.d.ts.map +1 -1
  474. package/dist/io/formats/pen/imports.js.map +1 -1
  475. package/dist/io/formats/pen/index.d.ts.map +1 -1
  476. package/dist/io/formats/pen/index.js +35 -5
  477. package/dist/io/formats/pen/index.js.map +1 -1
  478. package/dist/io/formats/pptx/export.js +1 -1
  479. package/dist/io/formats/pptx/geometry.d.ts +1 -1
  480. package/dist/io/formats/pptx/style.js +1 -1
  481. package/dist/io/formats/raster/adjusted-images.d.ts +15 -0
  482. package/dist/io/formats/raster/adjusted-images.d.ts.map +1 -0
  483. package/dist/io/formats/raster/adjusted-images.js +118 -0
  484. package/dist/io/formats/raster/adjusted-images.js.map +1 -0
  485. package/dist/io/formats/raster/headless.d.ts +11 -1
  486. package/dist/io/formats/raster/headless.d.ts.map +1 -1
  487. package/dist/io/formats/raster/headless.js +4 -4
  488. package/dist/io/formats/raster/headless.js.map +1 -1
  489. package/dist/io/formats/raster/index.d.ts +2 -2
  490. package/dist/io/formats/raster/pixels.d.ts +7 -1
  491. package/dist/io/formats/raster/pixels.d.ts.map +1 -1
  492. package/dist/io/formats/raster/pixels.js.map +1 -1
  493. package/dist/io/formats/raster/render.d.ts +1 -1
  494. package/dist/io/formats/raster/render.d.ts.map +1 -1
  495. package/dist/io/formats/raster/render.js +13 -4
  496. package/dist/io/formats/raster/render.js.map +1 -1
  497. package/dist/io/formats/svg/defs.d.ts +10 -8
  498. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  499. package/dist/io/formats/svg/defs.js +13 -64
  500. package/dist/io/formats/svg/defs.js.map +1 -1
  501. package/dist/io/formats/svg/effects.d.ts +16 -0
  502. package/dist/io/formats/svg/effects.d.ts.map +1 -0
  503. package/dist/io/formats/svg/effects.js +126 -0
  504. package/dist/io/formats/svg/effects.js.map +1 -0
  505. package/dist/io/formats/svg/export.d.ts +11 -2
  506. package/dist/io/formats/svg/export.d.ts.map +1 -1
  507. package/dist/io/formats/svg/export.js +177 -37
  508. package/dist/io/formats/svg/export.js.map +1 -1
  509. package/dist/io/formats/svg/filter.d.ts +30 -0
  510. package/dist/io/formats/svg/filter.d.ts.map +1 -0
  511. package/dist/io/formats/svg/filter.js +48 -0
  512. package/dist/io/formats/svg/filter.js.map +1 -0
  513. package/dist/io/formats/svg/grain.d.ts +26 -0
  514. package/dist/io/formats/svg/grain.d.ts.map +1 -0
  515. package/dist/io/formats/svg/grain.js +298 -0
  516. package/dist/io/formats/svg/grain.js.map +1 -0
  517. package/dist/io/formats/svg/import.d.ts +4 -2
  518. package/dist/io/formats/svg/import.d.ts.map +1 -1
  519. package/dist/io/formats/svg/import.js +2 -1
  520. package/dist/io/formats/svg/import.js.map +1 -1
  521. package/dist/io/formats/svg/strokes.d.ts +1 -1
  522. package/dist/io/formats/svg/strokes.d.ts.map +1 -1
  523. package/dist/io/formats/svg/strokes.js +1 -2
  524. package/dist/io/formats/svg/strokes.js.map +1 -1
  525. package/dist/io/formats/svg/text/export.d.ts.map +1 -1
  526. package/dist/io/formats/svg/text/export.js +8 -8
  527. package/dist/io/formats/svg/text/export.js.map +1 -1
  528. package/dist/io/formats/svg/text/import.js +1 -1
  529. package/dist/io/formats/svg/text/layout.d.ts +5 -2
  530. package/dist/io/formats/svg/text/layout.d.ts.map +1 -1
  531. package/dist/io/formats/svg/text/layout.js +8 -5
  532. package/dist/io/formats/svg/text/layout.js.map +1 -1
  533. package/dist/io/formats/video/composite.d.ts +18 -0
  534. package/dist/io/formats/video/composite.d.ts.map +1 -0
  535. package/dist/io/formats/video/composite.js +79 -0
  536. package/dist/io/formats/video/composite.js.map +1 -0
  537. package/dist/io/formats/video/formats.d.ts +29 -0
  538. package/dist/io/formats/video/formats.d.ts.map +1 -0
  539. package/dist/io/formats/video/formats.js +43 -0
  540. package/dist/io/formats/video/formats.js.map +1 -0
  541. package/dist/io/formats/video/gif.d.ts +13 -0
  542. package/dist/io/formats/video/gif.d.ts.map +1 -0
  543. package/dist/io/formats/video/gif.js +56 -0
  544. package/dist/io/formats/video/gif.js.map +1 -0
  545. package/dist/io/formats/video/index.d.ts +9 -0
  546. package/dist/io/formats/video/index.js +9 -0
  547. package/dist/io/formats/video/plan.d.ts +64 -0
  548. package/dist/io/formats/video/plan.d.ts.map +1 -0
  549. package/dist/io/formats/video/plan.js +90 -0
  550. package/dist/io/formats/video/plan.js.map +1 -0
  551. package/dist/io/formats/video/record.d.ts +36 -0
  552. package/dist/io/formats/video/record.d.ts.map +1 -0
  553. package/dist/io/formats/video/record.js +154 -0
  554. package/dist/io/formats/video/record.js.map +1 -0
  555. package/dist/io/formats/video/sink.d.ts +29 -0
  556. package/dist/io/formats/video/sink.d.ts.map +1 -0
  557. package/dist/io/formats/video/sink.js +16 -0
  558. package/dist/io/formats/video/sink.js.map +1 -0
  559. package/dist/io/formats/video/size.d.ts +19 -0
  560. package/dist/io/formats/video/size.d.ts.map +1 -0
  561. package/dist/io/formats/video/size.js +26 -0
  562. package/dist/io/formats/video/size.js.map +1 -0
  563. package/dist/io/formats/video/webcodecs.d.ts +18 -0
  564. package/dist/io/formats/video/webcodecs.d.ts.map +1 -0
  565. package/dist/io/formats/video/webcodecs.js +74 -0
  566. package/dist/io/formats/video/webcodecs.js.map +1 -0
  567. package/dist/io/formats.d.ts.map +1 -1
  568. package/dist/io/formats.js +41 -11
  569. package/dist/io/formats.js.map +1 -1
  570. package/dist/io/subgraph.d.ts.map +1 -1
  571. package/dist/io/subgraph.js +1 -1
  572. package/dist/io/subgraph.js.map +1 -1
  573. package/dist/io/types.d.ts +20 -5
  574. package/dist/io/types.d.ts.map +1 -1
  575. package/dist/kiwi/fig/parse/transfer.d.ts +1 -1
  576. package/dist/kiwi/fig/session/options.d.ts +3 -0
  577. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  578. package/dist/kiwi/fig/session/options.js +4 -0
  579. package/dist/kiwi/fig/session/options.js.map +1 -1
  580. package/dist/layout/auto-layout-handles.d.ts +66 -0
  581. package/dist/layout/auto-layout-handles.d.ts.map +1 -0
  582. package/dist/layout/auto-layout-handles.js +291 -0
  583. package/dist/layout/auto-layout-handles.js.map +1 -0
  584. package/dist/layout/yoga-helpers.d.ts +2 -1
  585. package/dist/layout/yoga-helpers.d.ts.map +1 -1
  586. package/dist/layout/yoga-helpers.js +7 -1
  587. package/dist/layout/yoga-helpers.js.map +1 -1
  588. package/dist/layout.d.ts +3 -2
  589. package/dist/layout.d.ts.map +1 -1
  590. package/dist/layout.js +26 -2
  591. package/dist/layout.js.map +1 -1
  592. package/dist/lint/fixes.d.ts.map +1 -1
  593. package/dist/lint/fixes.js +10 -4
  594. package/dist/lint/fixes.js.map +1 -1
  595. package/dist/lint/index.d.ts +3 -2
  596. package/dist/lint/index.js +2 -1
  597. package/dist/lint/linter.d.ts +12 -0
  598. package/dist/lint/linter.d.ts.map +1 -1
  599. package/dist/lint/linter.js +112 -10
  600. package/dist/lint/linter.js.map +1 -1
  601. package/dist/lint/presets.d.ts.map +1 -1
  602. package/dist/lint/presets.js +2 -0
  603. package/dist/lint/presets.js.map +1 -1
  604. package/dist/lint/rules/design-memory.d.ts +15 -0
  605. package/dist/lint/rules/design-memory.d.ts.map +1 -0
  606. package/dist/lint/rules/design-memory.js +90 -0
  607. package/dist/lint/rules/design-memory.js.map +1 -0
  608. package/dist/lint/rules/index.d.ts +6 -5
  609. package/dist/lint/rules/index.d.ts.map +1 -1
  610. package/dist/lint/rules/index.js +6 -2
  611. package/dist/lint/rules/index.js.map +1 -1
  612. package/dist/lint/rules/no-unbound-token-values.d.ts +6 -0
  613. package/dist/lint/rules/no-unbound-token-values.d.ts.map +1 -0
  614. package/dist/lint/rules/no-unbound-token-values.js +79 -0
  615. package/dist/lint/rules/no-unbound-token-values.js.map +1 -0
  616. package/dist/lint/types.d.ts +25 -2
  617. package/dist/lint/types.d.ts.map +1 -1
  618. package/dist/node/video.d.ts +12 -0
  619. package/dist/node/video.d.ts.map +1 -0
  620. package/dist/node/video.js +206 -0
  621. package/dist/node/video.js.map +1 -0
  622. package/dist/pairdraw-api/comments.d.ts +4 -1
  623. package/dist/pairdraw-api/comments.d.ts.map +1 -1
  624. package/dist/pairdraw-api/comments.js +5 -0
  625. package/dist/pairdraw-api/comments.js.map +1 -1
  626. package/dist/pairdraw-api/design-memory.d.ts +19 -0
  627. package/dist/pairdraw-api/design-memory.d.ts.map +1 -0
  628. package/dist/pairdraw-api/design-memory.js +39 -0
  629. package/dist/pairdraw-api/design-memory.js.map +1 -0
  630. package/dist/pairdraw-api/index.d.ts +48 -4
  631. package/dist/pairdraw-api/index.d.ts.map +1 -1
  632. package/dist/pairdraw-api/index.js +59 -6
  633. package/dist/pairdraw-api/index.js.map +1 -1
  634. package/dist/pairdraw-api/nodes.d.ts +13 -2
  635. package/dist/pairdraw-api/nodes.d.ts.map +1 -1
  636. package/dist/pairdraw-api/nodes.js +28 -1
  637. package/dist/pairdraw-api/nodes.js.map +1 -1
  638. package/dist/pairdraw-api/variations.d.ts +48 -0
  639. package/dist/pairdraw-api/variations.d.ts.map +1 -0
  640. package/dist/pairdraw-api/variations.js +76 -0
  641. package/dist/pairdraw-api/variations.js.map +1 -0
  642. package/dist/prototype/easing.d.ts +13 -0
  643. package/dist/prototype/easing.d.ts.map +1 -0
  644. package/dist/prototype/easing.js +36 -0
  645. package/dist/prototype/easing.js.map +1 -0
  646. package/dist/prototype/frames.d.ts +10 -0
  647. package/dist/prototype/frames.d.ts.map +1 -0
  648. package/dist/prototype/frames.js +12 -0
  649. package/dist/prototype/frames.js.map +1 -0
  650. package/dist/prototype/hit.d.ts +17 -0
  651. package/dist/prototype/hit.d.ts.map +1 -0
  652. package/dist/prototype/hit.js +45 -0
  653. package/dist/prototype/hit.js.map +1 -0
  654. package/dist/prototype/index.d.ts +14 -0
  655. package/dist/prototype/index.js +14 -0
  656. package/dist/prototype/pointer.d.ts +63 -0
  657. package/dist/prototype/pointer.d.ts.map +1 -0
  658. package/dist/prototype/pointer.js +104 -0
  659. package/dist/prototype/pointer.js.map +1 -0
  660. package/dist/prototype/reactions.d.ts +45 -0
  661. package/dist/prototype/reactions.d.ts.map +1 -0
  662. package/dist/prototype/reactions.js +122 -0
  663. package/dist/prototype/reactions.js.map +1 -0
  664. package/dist/prototype/scene.d.ts +35 -0
  665. package/dist/prototype/scene.d.ts.map +1 -0
  666. package/dist/prototype/scene.js +86 -0
  667. package/dist/prototype/scene.js.map +1 -0
  668. package/dist/prototype/scenes.d.ts +81 -0
  669. package/dist/prototype/scenes.d.ts.map +1 -0
  670. package/dist/prototype/scenes.js +175 -0
  671. package/dist/prototype/scenes.js.map +1 -0
  672. package/dist/prototype/scroll.d.ts +48 -0
  673. package/dist/prototype/scroll.d.ts.map +1 -0
  674. package/dist/prototype/scroll.js +159 -0
  675. package/dist/prototype/scroll.js.map +1 -0
  676. package/dist/prototype/session.d.ts +71 -0
  677. package/dist/prototype/session.d.ts.map +1 -0
  678. package/dist/prototype/session.js +135 -0
  679. package/dist/prototype/session.js.map +1 -0
  680. package/dist/prototype/smart-animate/animation.d.ts +34 -0
  681. package/dist/prototype/smart-animate/animation.d.ts.map +1 -0
  682. package/dist/prototype/smart-animate/animation.js +212 -0
  683. package/dist/prototype/smart-animate/animation.js.map +1 -0
  684. package/dist/prototype/smart-animate/match.d.ts +24 -0
  685. package/dist/prototype/smart-animate/match.d.ts.map +1 -0
  686. package/dist/prototype/smart-animate/match.js +72 -0
  687. package/dist/prototype/smart-animate/match.js.map +1 -0
  688. package/dist/prototype/snapshot.d.ts +19 -0
  689. package/dist/prototype/snapshot.d.ts.map +1 -0
  690. package/dist/prototype/snapshot.js +56 -0
  691. package/dist/prototype/snapshot.js.map +1 -0
  692. package/dist/prototype/timeline.d.ts +132 -0
  693. package/dist/prototype/timeline.d.ts.map +1 -0
  694. package/dist/prototype/timeline.js +260 -0
  695. package/dist/prototype/timeline.js.map +1 -0
  696. package/dist/rpc/analyze-commands.js +1 -1
  697. package/dist/rpc/read-commands.d.ts +2 -2
  698. package/dist/rpc/read-commands.js +2 -2
  699. package/dist/rpc/read-commands.js.map +1 -1
  700. package/dist/rpc/variables-command.js +2 -2
  701. package/dist/rpc/variables-command.js.map +1 -1
  702. package/dist/text/font/features.d.ts +9 -0
  703. package/dist/text/font/features.d.ts.map +1 -0
  704. package/dist/text/font/features.js +27 -0
  705. package/dist/text/font/features.js.map +1 -0
  706. package/dist/text/font/manager.d.ts +12 -0
  707. package/dist/text/font/manager.d.ts.map +1 -1
  708. package/dist/text/font/manager.js +60 -1
  709. package/dist/text/font/manager.js.map +1 -1
  710. package/dist/text/font/provider.d.ts +15 -0
  711. package/dist/text/font/provider.d.ts.map +1 -0
  712. package/dist/text/font/provider.js +18 -0
  713. package/dist/text/font/provider.js.map +1 -0
  714. package/dist/text/font/readiness.d.ts +32 -0
  715. package/dist/text/font/readiness.d.ts.map +1 -0
  716. package/dist/text/font/{status.js → readiness.js} +8 -4
  717. package/dist/text/font/readiness.js.map +1 -0
  718. package/dist/text/index.d.ts +12 -9
  719. package/dist/text/index.js +6 -3
  720. package/dist/text/prepare.d.ts +9 -4
  721. package/dist/text/prepare.d.ts.map +1 -1
  722. package/dist/text/prepare.js +9 -4
  723. package/dist/text/prepare.js.map +1 -1
  724. package/dist/text/replace-fonts.d.ts +41 -0
  725. package/dist/text/replace-fonts.d.ts.map +1 -0
  726. package/dist/text/replace-fonts.js +121 -0
  727. package/dist/text/replace-fonts.js.map +1 -0
  728. package/dist/tools/analyze/colors.js +1 -1
  729. package/dist/tools/analyze/responsive/index.d.ts +15 -0
  730. package/dist/tools/analyze/responsive/index.d.ts.map +1 -0
  731. package/dist/tools/analyze/responsive/index.js +192 -0
  732. package/dist/tools/analyze/responsive/index.js.map +1 -0
  733. package/dist/tools/analyze/responsive/widths.d.ts +27 -0
  734. package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
  735. package/dist/tools/analyze/responsive/widths.js +49 -0
  736. package/dist/tools/analyze/responsive/widths.js.map +1 -0
  737. package/dist/tools/analyze.d.ts +3 -1
  738. package/dist/tools/analyze.js +3 -1
  739. package/dist/tools/codegen/token-sync.d.ts +7 -0
  740. package/dist/tools/codegen/token-sync.d.ts.map +1 -0
  741. package/dist/tools/codegen/token-sync.js +85 -0
  742. package/dist/tools/codegen/token-sync.js.map +1 -0
  743. package/dist/tools/codegen/tokens.d.ts +1 -1
  744. package/dist/tools/codegen/tokens.d.ts.map +1 -1
  745. package/dist/tools/codegen/tokens.js +2 -2
  746. package/dist/tools/codegen/tokens.js.map +1 -1
  747. package/dist/tools/codegen.d.ts +2 -1
  748. package/dist/tools/codegen.js +2 -1
  749. package/dist/tools/comments.d.ts.map +1 -1
  750. package/dist/tools/comments.js +2 -2
  751. package/dist/tools/comments.js.map +1 -1
  752. package/dist/tools/component-catalog.d.ts.map +1 -1
  753. package/dist/tools/component-catalog.js +5 -3
  754. package/dist/tools/component-catalog.js.map +1 -1
  755. package/dist/tools/create/components.d.ts.map +1 -1
  756. package/dist/tools/create/components.js +4 -0
  757. package/dist/tools/create/components.js.map +1 -1
  758. package/dist/tools/create/html.d.ts.map +1 -1
  759. package/dist/tools/create/html.js +2 -3
  760. package/dist/tools/create/html.js.map +1 -1
  761. package/dist/tools/create/icons.d.ts.map +1 -1
  762. package/dist/tools/create/icons.js +2 -1
  763. package/dist/tools/create/icons.js.map +1 -1
  764. package/dist/tools/create/mermaid.js +1 -0
  765. package/dist/tools/create/mermaid.js.map +1 -1
  766. package/dist/tools/create/svg.js +5 -1
  767. package/dist/tools/create/svg.js.map +1 -1
  768. package/dist/tools/create/vector.js +2 -2
  769. package/dist/tools/create/vector.js.map +1 -1
  770. package/dist/tools/css/shorthand.d.ts +20 -0
  771. package/dist/tools/css/shorthand.d.ts.map +1 -0
  772. package/dist/tools/css/shorthand.js +54 -0
  773. package/dist/tools/css/shorthand.js.map +1 -0
  774. package/dist/tools/describe/index.js +2 -2
  775. package/dist/tools/describe/index.js.map +1 -1
  776. package/dist/tools/describe/issues.js +1 -1
  777. package/dist/tools/design-memory.d.ts +8 -0
  778. package/dist/tools/design-memory.d.ts.map +1 -0
  779. package/dist/tools/design-memory.js +68 -0
  780. package/dist/tools/design-memory.js.map +1 -0
  781. package/dist/tools/html-host.d.ts.map +1 -1
  782. package/dist/tools/html-host.js +5 -3
  783. package/dist/tools/html-host.js.map +1 -1
  784. package/dist/tools/image-ai/apply.d.ts.map +1 -1
  785. package/dist/tools/image-ai/apply.js +1 -3
  786. package/dist/tools/image-ai/apply.js.map +1 -1
  787. package/dist/tools/image-ai/generate.d.ts.map +1 -1
  788. package/dist/tools/image-ai/generate.js +2 -0
  789. package/dist/tools/image-ai/generate.js.map +1 -1
  790. package/dist/tools/image-ai/service.d.ts.map +1 -1
  791. package/dist/tools/image-ai/service.js +5 -3
  792. package/dist/tools/image-ai/service.js.map +1 -1
  793. package/dist/tools/index.d.ts +3 -1
  794. package/dist/tools/index.js +3 -1
  795. package/dist/tools/modify/effects.js +1 -1
  796. package/dist/tools/modify/effects.js.map +1 -1
  797. package/dist/tools/modify/fonts.d.ts +6 -0
  798. package/dist/tools/modify/fonts.d.ts.map +1 -0
  799. package/dist/tools/modify/fonts.js +27 -0
  800. package/dist/tools/modify/fonts.js.map +1 -0
  801. package/dist/tools/modify/geometry.d.ts.map +1 -1
  802. package/dist/tools/modify/geometry.js +14 -3
  803. package/dist/tools/modify/geometry.js.map +1 -1
  804. package/dist/tools/modify/layout.d.ts.map +1 -1
  805. package/dist/tools/modify/layout.js +35 -8
  806. package/dist/tools/modify/layout.js.map +1 -1
  807. package/dist/tools/modify/matching.d.ts.map +1 -1
  808. package/dist/tools/modify/matching.js +10 -10
  809. package/dist/tools/modify/matching.js.map +1 -1
  810. package/dist/tools/modify/paint.d.ts.map +1 -1
  811. package/dist/tools/modify/paint.js +56 -4
  812. package/dist/tools/modify/paint.js.map +1 -1
  813. package/dist/tools/modify/reactions.d.ts.map +1 -1
  814. package/dist/tools/modify/reactions.js +2 -2
  815. package/dist/tools/modify/reactions.js.map +1 -1
  816. package/dist/tools/modify/text.d.ts.map +1 -1
  817. package/dist/tools/modify/text.js +29 -8
  818. package/dist/tools/modify/text.js.map +1 -1
  819. package/dist/tools/modify/update.d.ts +10 -1
  820. package/dist/tools/modify/update.d.ts.map +1 -1
  821. package/dist/tools/modify/update.js +34 -3
  822. package/dist/tools/modify/update.js.map +1 -1
  823. package/dist/tools/modify.d.ts +2 -1
  824. package/dist/tools/modify.js +2 -1
  825. package/dist/tools/prompts/codegen.js +1 -1
  826. package/dist/tools/prompts/codegen.js.map +1 -1
  827. package/dist/tools/read/css.d.ts +14 -0
  828. package/dist/tools/read/css.d.ts.map +1 -0
  829. package/dist/tools/read/css.js +306 -0
  830. package/dist/tools/read/css.js.map +1 -0
  831. package/dist/tools/read/fonts.d.ts.map +1 -1
  832. package/dist/tools/read/fonts.js +17 -2
  833. package/dist/tools/read/fonts.js.map +1 -1
  834. package/dist/tools/read/libraries.js +1 -0
  835. package/dist/tools/read/libraries.js.map +1 -1
  836. package/dist/tools/read/reactions.js +1 -1
  837. package/dist/tools/read/reactions.js.map +1 -1
  838. package/dist/tools/read/space.d.ts +3 -1
  839. package/dist/tools/read/space.d.ts.map +1 -1
  840. package/dist/tools/read/space.js +4 -5
  841. package/dist/tools/read/space.js.map +1 -1
  842. package/dist/tools/read.d.ts +2 -1
  843. package/dist/tools/read.js +2 -1
  844. package/dist/tools/registry/core.d.ts +1 -1
  845. package/dist/tools/registry/core.d.ts.map +1 -1
  846. package/dist/tools/registry/core.js +5 -1
  847. package/dist/tools/registry/core.js.map +1 -1
  848. package/dist/tools/registry/extended.d.ts.map +1 -1
  849. package/dist/tools/registry/extended.js +16 -1
  850. package/dist/tools/registry/extended.js.map +1 -1
  851. package/dist/tools/schema.d.ts +24 -6
  852. package/dist/tools/schema.d.ts.map +1 -1
  853. package/dist/tools/schema.js +10 -6
  854. package/dist/tools/schema.js.map +1 -1
  855. package/dist/tools/script/host.d.ts.map +1 -1
  856. package/dist/tools/script/host.js +5 -3
  857. package/dist/tools/script/host.js.map +1 -1
  858. package/dist/tools/stock-photo.js +1 -0
  859. package/dist/tools/stock-photo.js.map +1 -1
  860. package/dist/tools/structure/basic.d.ts.map +1 -1
  861. package/dist/tools/structure/basic.js +1 -0
  862. package/dist/tools/structure/basic.js.map +1 -1
  863. package/dist/tools/structure/batch.d.ts.map +1 -1
  864. package/dist/tools/structure/batch.js +8 -1
  865. package/dist/tools/structure/batch.js.map +1 -1
  866. package/dist/tools/structure/hierarchy.d.ts.map +1 -1
  867. package/dist/tools/structure/hierarchy.js +4 -0
  868. package/dist/tools/structure/hierarchy.js.map +1 -1
  869. package/dist/tools/structure/variations.d.ts +8 -0
  870. package/dist/tools/structure/variations.d.ts.map +1 -0
  871. package/dist/tools/structure/variations.js +106 -0
  872. package/dist/tools/structure/variations.js.map +1 -0
  873. package/dist/tools/structure.d.ts +2 -1
  874. package/dist/tools/structure.js +2 -1
  875. package/dist/tools/styles/types.d.ts +2 -4
  876. package/dist/tools/styles/types.d.ts.map +1 -1
  877. package/dist/tools/styles/types.js.map +1 -1
  878. package/dist/tools/variables/collections.js +1 -1
  879. package/dist/tools/variables/collections.js.map +1 -1
  880. package/dist/tools/variables/values.d.ts.map +1 -1
  881. package/dist/tools/variables/values.js +4 -4
  882. package/dist/tools/variables/values.js.map +1 -1
  883. package/dist/tools/vector/boolean.d.ts.map +1 -1
  884. package/dist/tools/vector/boolean.js +4 -0
  885. package/dist/tools/vector/boolean.js.map +1 -1
  886. package/dist/tools/vector/vectorize.d.ts.map +1 -1
  887. package/dist/tools/vector/vectorize.js +7 -4
  888. package/dist/tools/vector/vectorize.js.map +1 -1
  889. package/dist/tools/vector/video.d.ts +6 -0
  890. package/dist/tools/vector/video.d.ts.map +1 -0
  891. package/dist/tools/vector/video.js +133 -0
  892. package/dist/tools/vector/video.js.map +1 -0
  893. package/dist/tools/vector.d.ts +2 -1
  894. package/dist/tools/vector.js +2 -1
  895. package/dist/tools/video-host.d.ts +12 -0
  896. package/dist/tools/video-host.d.ts.map +1 -0
  897. package/dist/tools/video-host.js +21 -0
  898. package/dist/tools/video-host.js.map +1 -0
  899. package/dist/vector/point-transform.d.ts +1 -1
  900. package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
  901. package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
  902. package/dist/vector/vectorize/svg/gradients.js +5 -5
  903. package/dist/vector/vectorize/svg/gradients.js.map +1 -1
  904. package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
  905. package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
  906. package/dist/vector/vectorize/svg/to-vectors.js +13 -12
  907. package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
  908. package/package.json +31 -9
  909. package/src/ai/providers.ts +2 -0
  910. package/src/cache/resource.ts +24 -1
  911. package/src/canvas/effects.ts +47 -50
  912. package/src/canvas/fills.ts +19 -15
  913. package/src/canvas/images/adjustments.ts +203 -0
  914. package/src/canvas/images/sampling.ts +88 -0
  915. package/src/canvas/index.ts +1 -0
  916. package/src/canvas/masks.ts +1 -1
  917. package/src/canvas/noise/render.ts +75 -0
  918. package/src/canvas/noise/shader.ts +169 -0
  919. package/src/canvas/noise/table.ts +91 -0
  920. package/src/canvas/noise/tile.ts +95 -0
  921. package/src/canvas/overlays/auto-layout-hover.ts +47 -65
  922. package/src/canvas/renderer/colors.ts +76 -50
  923. package/src/canvas/renderer/document-surface.ts +53 -0
  924. package/src/canvas/renderer/fonts.ts +6 -4
  925. package/src/canvas/renderer/lifecycle.ts +10 -4
  926. package/src/canvas/renderer/methods.ts +1 -0
  927. package/src/canvas/renderer/pipeline.ts +40 -4
  928. package/src/canvas/renderer/play-scenes.ts +51 -0
  929. package/src/canvas/renderer/retained-backing.ts +2 -1
  930. package/src/canvas/renderer/tiles/cache.ts +54 -1
  931. package/src/canvas/renderer/tiles/controller.ts +30 -1
  932. package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
  933. package/src/canvas/renderer/types.ts +18 -2
  934. package/src/canvas/renderer.ts +76 -14
  935. package/src/canvas/scene.ts +69 -12
  936. package/src/canvas/shaders/effect.ts +2 -1
  937. package/src/canvas/shadows/shape.ts +4 -2
  938. package/src/canvas/shadows.ts +5 -2
  939. package/src/canvas/text/decorations.ts +15 -5
  940. package/src/canvas/text/index.ts +9 -1
  941. package/src/canvas/text/paragraph/index.ts +16 -6
  942. package/src/canvas/text/renderer.ts +2 -1
  943. package/src/canvas/text/shape.ts +4 -4
  944. package/src/canvas/texture.ts +137 -0
  945. package/src/clipboard.ts +23 -10
  946. package/src/constants.ts +6 -0
  947. package/src/design-memory/check.ts +376 -0
  948. package/src/design-memory/describe.ts +77 -0
  949. package/src/design-memory/distil.ts +69 -0
  950. package/src/design-memory/document.ts +80 -0
  951. package/src/design-memory/guard.ts +157 -0
  952. package/src/design-memory/index.ts +8 -0
  953. package/src/design-memory/refusal.ts +90 -0
  954. package/src/design-memory/rules.ts +274 -0
  955. package/src/design-memory/values.ts +179 -0
  956. package/src/editor/bridges/components.ts +2 -0
  957. package/src/editor/clipboard/assets.ts +6 -2
  958. package/src/editor/clipboard/component-matches.ts +65 -0
  959. package/src/editor/clipboard/dependencies.ts +22 -1
  960. package/src/editor/clipboard/export.ts +24 -7
  961. package/src/editor/clipboard.ts +74 -20
  962. package/src/editor/components/instances.ts +31 -0
  963. package/src/editor/components/properties.ts +3 -2
  964. package/src/editor/create.ts +25 -69
  965. package/src/editor/design-memory.ts +39 -0
  966. package/src/editor/design-tokens.ts +41 -2
  967. package/src/editor/document-colors.ts +65 -0
  968. package/src/editor/eyedropper.ts +208 -0
  969. package/src/editor/fonts.ts +19 -0
  970. package/src/editor/history/atomic-tool.ts +32 -3
  971. package/src/editor/history/capture.ts +19 -0
  972. package/src/editor/history/document-change.ts +5 -17
  973. package/src/editor/history/edit.ts +11 -1
  974. package/src/editor/history/subtree.ts +13 -2
  975. package/src/editor/index.ts +11 -0
  976. package/src/editor/pages.ts +40 -29
  977. package/src/editor/play/states.ts +1 -1
  978. package/src/editor/read-only/actions.ts +4 -0
  979. package/src/editor/render-requests.ts +83 -0
  980. package/src/editor/selection/overlays.ts +1 -0
  981. package/src/editor/structure/state.ts +2 -1
  982. package/src/editor/text.ts +2 -1
  983. package/src/editor/tool-registry.ts +2 -1
  984. package/src/editor/types.ts +4 -0
  985. package/src/editor/variables.ts +3 -3
  986. package/src/editor/variations/create.ts +235 -0
  987. package/src/editor/variations/pick.ts +35 -0
  988. package/src/editor/variations.ts +110 -0
  989. package/src/figma-api/accessors/reactions.ts +11 -1
  990. package/src/figma-api/accessors/text/index.ts +7 -0
  991. package/src/figma-api/accessors/text/opentype.ts +33 -0
  992. package/src/figma-api/accessors/visual.ts +55 -2
  993. package/src/figma-api/compatibility.ts +5 -2
  994. package/src/figma-api/effects.ts +143 -5
  995. package/src/figma-api/fresh-read.ts +57 -0
  996. package/src/figma-api/graph-ref.ts +13 -0
  997. package/src/figma-api/index.ts +22 -4
  998. package/src/figma-api/overrides.ts +295 -3
  999. package/src/figma-api/paints.ts +24 -9
  1000. package/src/figma-api/pending-layout.ts +7 -3
  1001. package/src/figma-api/pending-sync.ts +4 -1
  1002. package/src/figma-api/proxy.ts +8 -2
  1003. package/src/figma-api/reactions.ts +212 -33
  1004. package/src/figma-api/surface.ts +6 -2
  1005. package/src/figma-api/variables/index.ts +5 -4
  1006. package/src/global.d.ts +26 -0
  1007. package/src/io/formats/boolean-path.ts +60 -0
  1008. package/src/io/formats/design-tokens/css/known.ts +1 -1
  1009. package/src/io/formats/design-tokens/css/read.ts +20 -7
  1010. package/src/io/formats/design-tokens/css/sync.ts +9 -4
  1011. package/src/io/formats/design-tokens/css/values.ts +37 -9
  1012. package/src/io/formats/design-tokens/decode.ts +17 -12
  1013. package/src/io/formats/design-tokens/export.ts +3 -3
  1014. package/src/io/formats/design-tokens/index.ts +21 -0
  1015. package/src/io/formats/design-tokens/plan/changes.ts +4 -1
  1016. package/src/io/formats/design-tokens/plan/index.ts +6 -5
  1017. package/src/io/formats/design-tokens/plan/styles.ts +37 -10
  1018. package/src/io/formats/design-tokens/project.ts +40 -9
  1019. package/src/io/formats/design-tokens/styles.ts +20 -9
  1020. package/src/io/formats/design-tokens/sync/apply.ts +130 -0
  1021. package/src/io/formats/design-tokens/sync/drift.ts +589 -0
  1022. package/src/io/formats/design-tokens/sync/files.ts +40 -0
  1023. package/src/io/formats/design-tokens/values.ts +15 -8
  1024. package/src/io/formats/drawio/edges.ts +65 -0
  1025. package/src/io/formats/drawio/export.ts +37 -14
  1026. package/src/io/formats/drawio/index.ts +2 -0
  1027. package/src/io/formats/drawio/warnings.ts +2 -2
  1028. package/src/io/formats/fig/export/index.ts +36 -3
  1029. package/src/io/formats/fig/export/patch/index.ts +12 -1
  1030. package/src/io/formats/fig/export/setup.ts +25 -15
  1031. package/src/io/formats/fig/export/variables.ts +17 -6
  1032. package/src/io/formats/fig/thumbnail-page.ts +4 -4
  1033. package/src/io/formats/html/import.ts +9 -1
  1034. package/src/io/formats/html/index.ts +14 -7
  1035. package/src/io/formats/html/vectors.ts +9 -2
  1036. package/src/io/formats/mermaid/layers.ts +2 -2
  1037. package/src/io/formats/pdf/document.ts +14 -4
  1038. package/src/io/formats/pdf/export.ts +1 -0
  1039. package/src/io/formats/pdf/prepare.ts +6 -6
  1040. package/src/io/formats/pen/imports.ts +5 -6
  1041. package/src/io/formats/pen/index.ts +41 -7
  1042. package/src/io/formats/raster/adjusted-images.ts +125 -0
  1043. package/src/io/formats/raster/headless.ts +3 -3
  1044. package/src/io/formats/raster/index.ts +6 -1
  1045. package/src/io/formats/raster/pixels.ts +7 -0
  1046. package/src/io/formats/raster/render.ts +24 -5
  1047. package/src/io/formats/svg/defs.ts +24 -80
  1048. package/src/io/formats/svg/effects.ts +131 -0
  1049. package/src/io/formats/svg/export.ts +295 -49
  1050. package/src/io/formats/svg/filter.ts +57 -0
  1051. package/src/io/formats/svg/grain.ts +249 -0
  1052. package/src/io/formats/svg/import.ts +6 -3
  1053. package/src/io/formats/svg/strokes.ts +2 -2
  1054. package/src/io/formats/svg/text/export.ts +10 -8
  1055. package/src/io/formats/svg/text/layout.ts +15 -5
  1056. package/src/io/formats/video/composite.ts +79 -0
  1057. package/src/io/formats/video/formats.ts +77 -0
  1058. package/src/io/formats/video/gif.ts +65 -0
  1059. package/src/io/formats/video/index.ts +30 -0
  1060. package/src/io/formats/video/plan.ts +116 -0
  1061. package/src/io/formats/video/record.ts +227 -0
  1062. package/src/io/formats/video/sink.ts +32 -0
  1063. package/src/io/formats/video/size.ts +25 -0
  1064. package/src/io/formats/video/webcodecs.ts +89 -0
  1065. package/src/io/formats.ts +66 -11
  1066. package/src/io/subgraph.ts +4 -1
  1067. package/src/io/types.ts +29 -10
  1068. package/src/kiwi/fig/session/options.ts +4 -1
  1069. package/src/layout/auto-layout-handles.ts +396 -0
  1070. package/src/layout/yoga-helpers.ts +8 -0
  1071. package/src/layout.ts +49 -1
  1072. package/src/lint/fixes.ts +12 -3
  1073. package/src/lint/index.ts +3 -1
  1074. package/src/lint/linter.ts +108 -11
  1075. package/src/lint/presets.ts +2 -0
  1076. package/src/lint/rules/design-memory.ts +97 -0
  1077. package/src/lint/rules/index.ts +6 -1
  1078. package/src/lint/rules/no-unbound-token-values.ts +73 -0
  1079. package/src/lint/types.ts +32 -0
  1080. package/src/node/video.ts +196 -0
  1081. package/src/pairdraw-api/comments.ts +6 -0
  1082. package/src/pairdraw-api/design-memory.ts +61 -0
  1083. package/src/pairdraw-api/index.ts +88 -9
  1084. package/src/pairdraw-api/nodes.ts +38 -0
  1085. package/src/pairdraw-api/variations.ts +109 -0
  1086. package/src/prototype/easing.ts +37 -0
  1087. package/src/prototype/frames.ts +9 -0
  1088. package/src/prototype/hit.ts +70 -0
  1089. package/src/prototype/index.ts +69 -0
  1090. package/src/prototype/pointer.ts +146 -0
  1091. package/src/prototype/reactions.ts +178 -0
  1092. package/src/prototype/scene.ts +116 -0
  1093. package/src/prototype/scenes.ts +256 -0
  1094. package/src/prototype/scroll.ts +190 -0
  1095. package/src/prototype/session.ts +188 -0
  1096. package/src/prototype/smart-animate/animation.ts +267 -0
  1097. package/src/prototype/smart-animate/match.ts +85 -0
  1098. package/src/prototype/snapshot.ts +60 -0
  1099. package/src/prototype/timeline.ts +400 -0
  1100. package/src/rpc/read-commands.ts +4 -4
  1101. package/src/rpc/variables-command.ts +2 -2
  1102. package/src/text/font/features.ts +27 -0
  1103. package/src/text/font/manager.ts +79 -1
  1104. package/src/text/font/provider.ts +26 -0
  1105. package/src/text/font/{status.ts → readiness.ts} +13 -9
  1106. package/src/text/index.ts +4 -1
  1107. package/src/text/prepare.ts +9 -4
  1108. package/src/text/replace-fonts.ts +171 -0
  1109. package/src/tools/analyze/responsive/index.ts +257 -0
  1110. package/src/tools/analyze/responsive/widths.ts +63 -0
  1111. package/src/tools/analyze.ts +4 -0
  1112. package/src/tools/codegen/token-sync.ts +98 -0
  1113. package/src/tools/codegen/tokens.ts +4 -2
  1114. package/src/tools/codegen.ts +1 -0
  1115. package/src/tools/comments.ts +6 -4
  1116. package/src/tools/component-catalog.ts +5 -3
  1117. package/src/tools/create/components.ts +4 -0
  1118. package/src/tools/create/html.ts +1 -3
  1119. package/src/tools/create/icons.ts +2 -1
  1120. package/src/tools/create/mermaid.ts +1 -0
  1121. package/src/tools/create/svg.ts +5 -1
  1122. package/src/tools/create/vector.ts +2 -2
  1123. package/src/tools/css/shorthand.ts +64 -0
  1124. package/src/tools/describe/index.ts +2 -8
  1125. package/src/tools/design-memory.ts +72 -0
  1126. package/src/tools/html-host.ts +5 -3
  1127. package/src/tools/image-ai/apply.ts +0 -2
  1128. package/src/tools/image-ai/generate.ts +2 -0
  1129. package/src/tools/image-ai/service.ts +5 -3
  1130. package/src/tools/index.ts +3 -0
  1131. package/src/tools/modify/effects.ts +1 -1
  1132. package/src/tools/modify/fonts.ts +34 -0
  1133. package/src/tools/modify/geometry.ts +16 -3
  1134. package/src/tools/modify/layout.ts +47 -13
  1135. package/src/tools/modify/matching.ts +14 -11
  1136. package/src/tools/modify/paint.ts +85 -5
  1137. package/src/tools/modify/reactions.ts +16 -8
  1138. package/src/tools/modify/text.ts +56 -15
  1139. package/src/tools/modify/update.ts +46 -2
  1140. package/src/tools/modify.ts +1 -0
  1141. package/src/tools/prompts/codegen.md +2 -1
  1142. package/src/tools/read/css.ts +365 -0
  1143. package/src/tools/read/fonts.ts +24 -2
  1144. package/src/tools/read/libraries.ts +1 -0
  1145. package/src/tools/read/reactions.ts +3 -2
  1146. package/src/tools/read/space.ts +3 -4
  1147. package/src/tools/read.ts +1 -0
  1148. package/src/tools/registry/core.ts +5 -2
  1149. package/src/tools/registry/extended.ts +28 -1
  1150. package/src/tools/schema.ts +42 -9
  1151. package/src/tools/script/host.ts +6 -3
  1152. package/src/tools/stock-photo.ts +1 -0
  1153. package/src/tools/structure/basic.ts +1 -0
  1154. package/src/tools/structure/batch.ts +12 -1
  1155. package/src/tools/structure/hierarchy.ts +4 -0
  1156. package/src/tools/structure/variations.ts +118 -0
  1157. package/src/tools/structure.ts +2 -0
  1158. package/src/tools/styles/types.ts +3 -4
  1159. package/src/tools/variables/collections.ts +1 -1
  1160. package/src/tools/variables/values.ts +16 -5
  1161. package/src/tools/vector/boolean.ts +4 -0
  1162. package/src/tools/vector/vectorize.ts +11 -4
  1163. package/src/tools/vector/video.ts +228 -0
  1164. package/src/tools/vector.ts +1 -0
  1165. package/src/tools/video-host.ts +20 -0
  1166. package/src/vector/vectorize/svg/gradients.ts +8 -5
  1167. package/src/vector/vectorize/svg/to-vectors.ts +48 -14
  1168. package/dist/text/font/status.d.ts +0 -28
  1169. package/dist/text/font/status.d.ts.map +0 -1
  1170. package/dist/text/font/status.js.map +0 -1
@@ -0,0 +1,122 @@
1
+ import { generateId } from "@pairdraw/scene-graph";
2
+ import { isEqual, omit } from "es-toolkit";
3
+ import { findInstanceAncestor, instanceMainComponent, walkInstanceSources } from "@pairdraw/scene-graph/instances";
4
+ //#region src/prototype/reactions.ts
5
+ /** Whether two reactions do the same thing, whatever their ids. */
6
+ function sameReaction(a, b) {
7
+ return isEqual(omit(a, ["id"]), omit(b, ["id"]));
8
+ }
9
+ /**
10
+ * The reactions play runs on a layer. An instance runs its main component's, so an interaction
11
+ * set once on a variant works on every instance of it, and the instance's own reactions replace
12
+ * the main's of the same trigger, as in Figma. A reaction an instance holds under one of its
13
+ * main's ids is Figma's copy of it, which gives way to the main's as edited. Any other layer runs
14
+ * its own.
15
+ */
16
+ function effectiveReactions(graph, node) {
17
+ return reactionsWithInherited(node, inheritedReactions(graph, node));
18
+ }
19
+ /**
20
+ * A layer's reactions with the ones it inherits: the inherited reactions run unless the layer
21
+ * overrides their trigger. Figma's copy of a main's interaction keeps the main's id; the main's
22
+ * own, as edited, runs.
23
+ */
24
+ function reactionsWithInherited(node, inherited) {
25
+ if (inherited.length === 0) return node.prototypeReactions;
26
+ const own = node.prototypeReactions.filter((reaction) => !inherited.some((main) => main.id === reaction.id));
27
+ return [...own, ...inherited.filter((reaction) => !own.some((mine) => mine.trigger.type === reaction.trigger.type))];
28
+ }
29
+ /**
30
+ * The reactions a layer takes from its component: an instance root from the component it shows,
31
+ * a layer inside an instance from the component layer it was copied from.
32
+ */
33
+ function inheritedReactions(graph, node) {
34
+ if (node.type === "INSTANCE") return instanceMainComponent(graph, node)?.prototypeReactions ?? [];
35
+ const source = componentLayer(graph, node);
36
+ return source && source.id !== node.id ? source.prototypeReactions : [];
37
+ }
38
+ /**
39
+ * The component layer a copy stands for, followed through nested instances to the main that
40
+ * finally holds it. A nested copy points at the layer one level up, not at the main's layer.
41
+ */
42
+ function componentLayer(graph, node) {
43
+ return followComponentLayer(graph, node, (instance, copyId) => copiedSource(graph, instance, copyId));
44
+ }
45
+ /**
46
+ * A resolver for the component layers copies stand for, which reads each instance's copy-to-main
47
+ * map once. Arm many layers of one frame with it instead of calling `componentLayer` per layer,
48
+ * which searches an instance for every copy.
49
+ */
50
+ function componentLayerResolver(graph) {
51
+ const sourcesByInstance = /* @__PURE__ */ new Map();
52
+ const resolved = /* @__PURE__ */ new Map();
53
+ const sourcesOf = (instance) => {
54
+ const cached = sourcesByInstance.get(instance.id);
55
+ if (cached) return cached;
56
+ const sources = /* @__PURE__ */ new Map();
57
+ walkInstanceSources(graph, instance, (source, copy) => {
58
+ sources.set(copy.id, source);
59
+ return true;
60
+ }, true);
61
+ sourcesByInstance.set(instance.id, sources);
62
+ return sources;
63
+ };
64
+ return (node) => {
65
+ if (resolved.has(node.id)) return resolved.get(node.id);
66
+ const layer = followComponentLayer(graph, node, (instance, copyId) => sourcesOf(instance).get(copyId));
67
+ resolved.set(node.id, layer);
68
+ return layer;
69
+ };
70
+ }
71
+ /** Walks a copy up to its main layer, one instance at a time, using `sourceOf` to map each step. */
72
+ function followComponentLayer(graph, node, sourceOf) {
73
+ const seen = /* @__PURE__ */ new Set();
74
+ let current = node;
75
+ for (;;) {
76
+ if (seen.has(current.id)) return void 0;
77
+ seen.add(current.id);
78
+ const owner = current.parentId ? findInstanceAncestor(graph, current.parentId) : void 0;
79
+ if (!owner) return current;
80
+ if (!instanceMainComponent(graph, owner)) return void 0;
81
+ const source = sourceOf(owner, current.id);
82
+ if (!source || source.id === current.id) return void 0;
83
+ current = source;
84
+ }
85
+ }
86
+ /** The component layer that an instance's copy of `copyId` stands for. */
87
+ function copiedSource(graph, instance, copyId) {
88
+ let source;
89
+ walkInstanceSources(graph, instance, (candidate, copy) => {
90
+ if (copy.id !== copyId) return true;
91
+ source = candidate;
92
+ return false;
93
+ }, true);
94
+ return source;
95
+ }
96
+ /**
97
+ * The instance's own reactions without the copies of `previousMain`'s: those under one of its ids,
98
+ * or equal to one. Figma writes a main component's interactions onto each instance too; once play
99
+ * shows another variant, those copies would keep running the old variant's interactions over the
100
+ * new one's.
101
+ */
102
+ function withoutInheritedCopies(own, previousMain) {
103
+ const inherited = previousMain?.prototypeReactions ?? [];
104
+ return own.filter((reaction) => !inherited.some((main) => main.id === reaction.id || sameReaction(main, reaction)));
105
+ }
106
+ /**
107
+ * The reaction an instance keeps after an edit. Figma's copy of a main's interaction keeps the
108
+ * main's id, which play reads as the main's; edited to do something else, it takes an id of its
109
+ * own and becomes the instance's override, which play runs.
110
+ */
111
+ function asInstanceEdit(reaction, inherited) {
112
+ const main = inherited.find((candidate) => candidate.id === reaction.id);
113
+ if (!main || sameReaction(main, reaction)) return reaction;
114
+ return {
115
+ ...reaction,
116
+ id: generateId()
117
+ };
118
+ }
119
+ //#endregion
120
+ export { asInstanceEdit, componentLayer, componentLayerResolver, effectiveReactions, reactionsWithInherited, sameReaction, withoutInheritedCopies };
121
+
122
+ //# sourceMappingURL=reactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactions.js","names":[],"sources":["../../src/prototype/reactions.ts"],"sourcesContent":["import { isEqual, omit } from 'es-toolkit'\n\nimport {\n generateId,\n type PrototypeReaction,\n type SceneGraph,\n type SceneNode\n} from '@pairdraw/scene-graph'\nimport {\n findInstanceAncestor,\n instanceMainComponent,\n walkInstanceSources\n} from '@pairdraw/scene-graph/instances'\n\n/** Whether two reactions do the same thing, whatever their ids. */\nexport function sameReaction(a: PrototypeReaction, b: PrototypeReaction): boolean {\n return isEqual(omit(a, ['id']), omit(b, ['id']))\n}\n\n/**\n * The reactions play runs on a layer. An instance runs its main component's, so an interaction\n * set once on a variant works on every instance of it, and the instance's own reactions replace\n * the main's of the same trigger, as in Figma. A reaction an instance holds under one of its\n * main's ids is Figma's copy of it, which gives way to the main's as edited. Any other layer runs\n * its own.\n */\nexport function effectiveReactions(graph: SceneGraph, node: SceneNode): PrototypeReaction[] {\n return reactionsWithInherited(node, inheritedReactions(graph, node))\n}\n\n/**\n * A layer's reactions with the ones it inherits: the inherited reactions run unless the layer\n * overrides their trigger. Figma's copy of a main's interaction keeps the main's id; the main's\n * own, as edited, runs.\n */\nexport function reactionsWithInherited(\n node: SceneNode,\n inherited: readonly PrototypeReaction[]\n): PrototypeReaction[] {\n if (inherited.length === 0) return node.prototypeReactions\n const own = node.prototypeReactions.filter(\n (reaction) => !inherited.some((main) => main.id === reaction.id)\n )\n return [\n ...own,\n ...inherited.filter(\n (reaction) => !own.some((mine) => mine.trigger.type === reaction.trigger.type)\n )\n ]\n}\n\n/**\n * The reactions a layer takes from its component: an instance root from the component it shows,\n * a layer inside an instance from the component layer it was copied from.\n */\nfunction inheritedReactions(graph: SceneGraph, node: SceneNode): PrototypeReaction[] {\n if (node.type === 'INSTANCE') {\n return instanceMainComponent(graph, node)?.prototypeReactions ?? []\n }\n const source = componentLayer(graph, node)\n return source && source.id !== node.id ? source.prototypeReactions : []\n}\n\n/**\n * The component layer a copy stands for, followed through nested instances to the main that\n * finally holds it. A nested copy points at the layer one level up, not at the main's layer.\n */\nexport function componentLayer(graph: SceneGraph, node: SceneNode): SceneNode | undefined {\n return followComponentLayer(graph, node, (instance, copyId) =>\n copiedSource(graph, instance, copyId)\n )\n}\n\n/**\n * A resolver for the component layers copies stand for, which reads each instance's copy-to-main\n * map once. Arm many layers of one frame with it instead of calling `componentLayer` per layer,\n * which searches an instance for every copy.\n */\nexport function componentLayerResolver(\n graph: SceneGraph\n): (node: SceneNode) => SceneNode | undefined {\n const sourcesByInstance = new Map<string, Map<string, SceneNode>>()\n const resolved = new Map<string, SceneNode | undefined>()\n const sourcesOf = (instance: SceneNode): Map<string, SceneNode> => {\n const cached = sourcesByInstance.get(instance.id)\n if (cached) return cached\n const sources = new Map<string, SceneNode>()\n walkInstanceSources(\n graph,\n instance,\n (source, copy) => {\n sources.set(copy.id, source)\n return true\n },\n true\n )\n sourcesByInstance.set(instance.id, sources)\n return sources\n }\n return (node) => {\n if (resolved.has(node.id)) return resolved.get(node.id)\n const layer = followComponentLayer(graph, node, (instance, copyId) =>\n sourcesOf(instance).get(copyId)\n )\n resolved.set(node.id, layer)\n return layer\n }\n}\n\n/** Walks a copy up to its main layer, one instance at a time, using `sourceOf` to map each step. */\nfunction followComponentLayer(\n graph: SceneGraph,\n node: SceneNode,\n sourceOf: (instance: SceneNode, copyId: string) => SceneNode | undefined\n): SceneNode | undefined {\n const seen = new Set<string>()\n let current = node\n for (;;) {\n if (seen.has(current.id)) return undefined\n seen.add(current.id)\n const owner = current.parentId ? findInstanceAncestor(graph, current.parentId) : undefined\n if (!owner) return current\n if (!instanceMainComponent(graph, owner)) return undefined\n const source = sourceOf(owner, current.id)\n if (!source || source.id === current.id) return undefined\n current = source\n }\n}\n\n/** The component layer that an instance's copy of `copyId` stands for. */\nfunction copiedSource(\n graph: SceneGraph,\n instance: SceneNode,\n copyId: string\n): SceneNode | undefined {\n let source: SceneNode | undefined\n walkInstanceSources(\n graph,\n instance,\n (candidate, copy) => {\n if (copy.id !== copyId) return true\n source = candidate\n return false\n },\n true\n )\n return source\n}\n\n/**\n * The instance's own reactions without the copies of `previousMain`'s: those under one of its ids,\n * or equal to one. Figma writes a main component's interactions onto each instance too; once play\n * shows another variant, those copies would keep running the old variant's interactions over the\n * new one's.\n */\nexport function withoutInheritedCopies(\n own: readonly PrototypeReaction[],\n previousMain: SceneNode | undefined\n): PrototypeReaction[] {\n const inherited = previousMain?.prototypeReactions ?? []\n return own.filter(\n (reaction) => !inherited.some((main) => main.id === reaction.id || sameReaction(main, reaction))\n )\n}\n\n/**\n * The reaction an instance keeps after an edit. Figma's copy of a main's interaction keeps the\n * main's id, which play reads as the main's; edited to do something else, it takes an id of its\n * own and becomes the instance's override, which play runs.\n */\nexport function asInstanceEdit(\n reaction: PrototypeReaction,\n inherited: readonly PrototypeReaction[]\n): PrototypeReaction {\n const main = inherited.find((candidate) => candidate.id === reaction.id)\n if (!main || sameReaction(main, reaction)) return reaction\n return { ...reaction, id: generateId() }\n}\n"],"mappings":";;;;;AAeA,SAAgB,aAAa,GAAsB,GAA+B;CAChF,OAAO,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;AACjD;;;;;;;;AASA,SAAgB,mBAAmB,OAAmB,MAAsC;CAC1F,OAAO,uBAAuB,MAAM,mBAAmB,OAAO,IAAI,CAAC;AACrE;;;;;;AAOA,SAAgB,uBACd,MACA,WACqB;CACrB,IAAI,UAAU,WAAW,GAAG,OAAO,KAAK;CACxC,MAAM,MAAM,KAAK,mBAAmB,QACjC,aAAa,CAAC,UAAU,MAAM,SAAS,KAAK,OAAO,SAAS,EAAE,CACjE;CACA,OAAO,CACL,GAAG,KACH,GAAG,UAAU,QACV,aAAa,CAAC,IAAI,MAAM,SAAS,KAAK,QAAQ,SAAS,SAAS,QAAQ,IAAI,CAC/E,CACF;AACF;;;;;AAMA,SAAS,mBAAmB,OAAmB,MAAsC;CACnF,IAAI,KAAK,SAAS,YAChB,OAAO,sBAAsB,OAAO,IAAI,CAAC,EAAE,sBAAsB,CAAC;CAEpE,MAAM,SAAS,eAAe,OAAO,IAAI;CACzC,OAAO,UAAU,OAAO,OAAO,KAAK,KAAK,OAAO,qBAAqB,CAAC;AACxE;;;;;AAMA,SAAgB,eAAe,OAAmB,MAAwC;CACxF,OAAO,qBAAqB,OAAO,OAAO,UAAU,WAClD,aAAa,OAAO,UAAU,MAAM,CACtC;AACF;;;;;;AAOA,SAAgB,uBACd,OAC4C;CAC5C,MAAM,oCAAoB,IAAI,IAAoC;CAClE,MAAM,2BAAW,IAAI,IAAmC;CACxD,MAAM,aAAa,aAAgD;EACjE,MAAM,SAAS,kBAAkB,IAAI,SAAS,EAAE;EAChD,IAAI,QAAQ,OAAO;EACnB,MAAM,0BAAU,IAAI,IAAuB;EAC3C,oBACE,OACA,WACC,QAAQ,SAAS;GAChB,QAAQ,IAAI,KAAK,IAAI,MAAM;GAC3B,OAAO;EACT,GACA,IACF;EACA,kBAAkB,IAAI,SAAS,IAAI,OAAO;EAC1C,OAAO;CACT;CACA,QAAQ,SAAS;EACf,IAAI,SAAS,IAAI,KAAK,EAAE,GAAG,OAAO,SAAS,IAAI,KAAK,EAAE;EACtD,MAAM,QAAQ,qBAAqB,OAAO,OAAO,UAAU,WACzD,UAAU,QAAQ,CAAC,CAAC,IAAI,MAAM,CAChC;EACA,SAAS,IAAI,KAAK,IAAI,KAAK;EAC3B,OAAO;CACT;AACF;;AAGA,SAAS,qBACP,OACA,MACA,UACuB;CACvB,MAAM,uBAAO,IAAI,IAAY;CAC7B,IAAI,UAAU;CACd,SAAS;EACP,IAAI,KAAK,IAAI,QAAQ,EAAE,GAAG,OAAO,KAAA;EACjC,KAAK,IAAI,QAAQ,EAAE;EACnB,MAAM,QAAQ,QAAQ,WAAW,qBAAqB,OAAO,QAAQ,QAAQ,IAAI,KAAA;EACjF,IAAI,CAAC,OAAO,OAAO;EACnB,IAAI,CAAC,sBAAsB,OAAO,KAAK,GAAG,OAAO,KAAA;EACjD,MAAM,SAAS,SAAS,OAAO,QAAQ,EAAE;EACzC,IAAI,CAAC,UAAU,OAAO,OAAO,QAAQ,IAAI,OAAO,KAAA;EAChD,UAAU;CACZ;AACF;;AAGA,SAAS,aACP,OACA,UACA,QACuB;CACvB,IAAI;CACJ,oBACE,OACA,WACC,WAAW,SAAS;EACnB,IAAI,KAAK,OAAO,QAAQ,OAAO;EAC/B,SAAS;EACT,OAAO;CACT,GACA,IACF;CACA,OAAO;AACT;;;;;;;AAQA,SAAgB,uBACd,KACA,cACqB;CACrB,MAAM,YAAY,cAAc,sBAAsB,CAAC;CACvD,OAAO,IAAI,QACR,aAAa,CAAC,UAAU,MAAM,SAAS,KAAK,OAAO,SAAS,MAAM,aAAa,MAAM,QAAQ,CAAC,CACjG;AACF;;;;;;AAOA,SAAgB,eACd,UACA,WACmB;CACnB,MAAM,OAAO,UAAU,MAAM,cAAc,UAAU,OAAO,SAAS,EAAE;CACvE,IAAI,CAAC,QAAQ,aAAa,MAAM,QAAQ,GAAG,OAAO;CAClD,OAAO;EAAE,GAAG;EAAU,IAAI,WAAW;CAAE;AACzC"}
@@ -0,0 +1,35 @@
1
+ import { RenderedPlayScene } from "../canvas/renderer/types.js";
2
+ import { SceneGraph } from "@pairdraw/scene-graph";
3
+ //#region src/prototype/scene.d.ts
4
+ /**
5
+ * What the canvas draws in place of a top-level frame while play changed it: the frame's private
6
+ * copy, a count that grows with every change, and the layers the changes touched, whose cached
7
+ * drawings are stale. The renderer's own name for the same view.
8
+ */
9
+ type PlaySceneView = RenderedPlayScene;
10
+ /** One Change to: the instance it switched, in the frame it sits in, and the two variants. */
11
+ interface PlayChange {
12
+ rootId: string;
13
+ instanceId: string;
14
+ from: string;
15
+ to: string;
16
+ }
17
+ interface PlayScene extends PlaySceneView {
18
+ /**
19
+ * Shows `variantId` on the instance a Change to from `sourceId` switches: the source or its
20
+ * nearest instance ancestor that shows a variant of that set. Null when there is none, or it
21
+ * already shows the variant.
22
+ */
23
+ changeTo(sourceId: string, variantId: string): PlayChange | null;
24
+ }
25
+ /** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */
26
+ declare function changeTarget(graph: SceneGraph, rootId: string, sourceId: string, variantId: string): string | null;
27
+ /**
28
+ * A top-level frame as play shows it once an interaction changed it: a private copy of the frame,
29
+ * with every variant its instances can switch to, that the document, undo, autosave, and
30
+ * collaborators never see.
31
+ */
32
+ declare function createPlayScene(design: SceneGraph, rootId: string): PlayScene;
33
+ //#endregion
34
+ export { PlayChange, PlayScene, PlaySceneView, changeTarget, createPlayScene };
35
+ //# sourceMappingURL=scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.d.ts","names":[],"sources":["../../src/prototype/scene.ts"],"mappings":";;;;;;;;KAgBY,gBAAgB;;UAGX;EACf;EACA;EACA;EACA;;UAGe,kBAAkB;;;;;;EAMjC,SAAS,kBAAkB,oBAAoB;;;iBAIjC,aACd,OAAO,YACP,gBACA,kBACA;;;;;;iBA6Bc,gBAAgB,QAAQ,YAAY,iBAAiB"}
@@ -0,0 +1,86 @@
1
+ import { extractPageContext, findPageId } from "../io/subgraph.js";
2
+ import { computeAllLayouts, computeLayout } from "../layout.js";
3
+ import { reflow } from "../editor/play/states.js";
4
+ import { withoutInheritedCopies } from "./reactions.js";
5
+ import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
6
+ import { variantInstanceFor } from "@pairdraw/scene-graph/components";
7
+ //#region src/prototype/scene.ts
8
+ /** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */
9
+ function changeTarget(graph, rootId, sourceId, variantId) {
10
+ const variant = graph.getNode(variantId);
11
+ if (variant?.type !== "COMPONENT" || !variant.parentId) return null;
12
+ const instance = variantInstanceFor(graph, sourceId, variant.parentId);
13
+ if (!instance || !graph.isDescendant(instance.id, rootId)) return null;
14
+ return instanceMainComponent(graph, instance)?.id === variantId ? null : instance.id;
15
+ }
16
+ /**
17
+ * Lays out a switched instance, then each auto layout around it up to the frame, as an edit lays
18
+ * out the layer it changed and the auto layouts that hug it; the rest of the frame keeps its
19
+ * layout.
20
+ */
21
+ function layOutAround(graph, instanceId, rootId) {
22
+ reflow(graph, instanceId);
23
+ computeAllLayouts(graph, instanceId);
24
+ let current = graph.getNode(instanceId);
25
+ while (current && current.id !== rootId && current.parentId) {
26
+ current = graph.getNode(current.parentId);
27
+ if (current && current.layoutMode !== "NONE") computeLayout(graph, current.id);
28
+ }
29
+ }
30
+ /**
31
+ * A top-level frame as play shows it once an interaction changed it: a private copy of the frame,
32
+ * with every variant its instances can switch to, that the document, undo, autosave, and
33
+ * collaborators never see.
34
+ */
35
+ function createPlayScene(design, rootId) {
36
+ const pageId = findPageId(design, rootId) ?? design.rootId;
37
+ const graph = extractPageContext(design, pageId, [rootId], {
38
+ componentSets: true,
39
+ shareTables: true
40
+ });
41
+ const touched = /* @__PURE__ */ new Set();
42
+ let revision = 0;
43
+ function touch(id) {
44
+ touched.add(id);
45
+ }
46
+ return {
47
+ graph,
48
+ touched,
49
+ get revision() {
50
+ return revision;
51
+ },
52
+ changeTo(sourceId, variantId) {
53
+ const instanceId = changeTarget(graph, rootId, sourceId, variantId);
54
+ const instance = instanceId ? graph.getNode(instanceId) : void 0;
55
+ const previous = instance && instanceMainComponent(graph, instance);
56
+ if (!instance || !previous) return null;
57
+ const stop = graph.onNodeEvents({
58
+ created: (node) => touch(node.id),
59
+ updated: touch,
60
+ deleted: touch
61
+ });
62
+ try {
63
+ graph.swapInstanceComponent(instance.id, variantId, { keepName: true });
64
+ graph.updateNode(instance.id, { prototypeReactions: withoutInheritedCopies(instance.prototypeReactions, previous) });
65
+ layOutAround(graph, instance.id, rootId);
66
+ } finally {
67
+ stop();
68
+ }
69
+ graph.closest(instance.id, (node) => {
70
+ touch(node.id);
71
+ return node.id === rootId;
72
+ });
73
+ revision += 1;
74
+ return {
75
+ rootId,
76
+ instanceId: instance.id,
77
+ from: previous.id,
78
+ to: variantId
79
+ };
80
+ }
81
+ };
82
+ }
83
+ //#endregion
84
+ export { changeTarget, createPlayScene };
85
+
86
+ //# sourceMappingURL=scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.js","names":[],"sources":["../../src/prototype/scene.ts"],"sourcesContent":["import type { SceneGraph } from '@pairdraw/scene-graph'\nimport { variantInstanceFor } from '@pairdraw/scene-graph/components'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\n\nimport type { RenderedPlayScene } from '#core/canvas/renderer/types'\nimport { reflow } from '#core/editor/play/states'\nimport { extractPageContext, findPageId } from '#core/io/subgraph'\nimport { computeAllLayouts, computeLayout } from '#core/layout'\n\nimport { withoutInheritedCopies } from './reactions'\n\n/**\n * What the canvas draws in place of a top-level frame while play changed it: the frame's private\n * copy, a count that grows with every change, and the layers the changes touched, whose cached\n * drawings are stale. The renderer's own name for the same view.\n */\nexport type PlaySceneView = RenderedPlayScene\n\n/** One Change to: the instance it switched, in the frame it sits in, and the two variants. */\nexport interface PlayChange {\n rootId: string\n instanceId: string\n from: string\n to: string\n}\n\nexport interface PlayScene extends PlaySceneView {\n /**\n * Shows `variantId` on the instance a Change to from `sourceId` switches: the source or its\n * nearest instance ancestor that shows a variant of that set. Null when there is none, or it\n * already shows the variant.\n */\n changeTo(sourceId: string, variantId: string): PlayChange | null\n}\n\n/** The instance a Change to from `sourceId` to `variantId` switches inside `rootId`, if any. */\nexport function changeTarget(\n graph: SceneGraph,\n rootId: string,\n sourceId: string,\n variantId: string\n): string | null {\n const variant = graph.getNode(variantId)\n if (variant?.type !== 'COMPONENT' || !variant.parentId) return null\n const instance = variantInstanceFor(graph, sourceId, variant.parentId)\n if (!instance || !graph.isDescendant(instance.id, rootId)) return null\n return instanceMainComponent(graph, instance)?.id === variantId ? null : instance.id\n}\n\n/**\n * Lays out a switched instance, then each auto layout around it up to the frame, as an edit lays\n * out the layer it changed and the auto layouts that hug it; the rest of the frame keeps its\n * layout.\n */\nfunction layOutAround(graph: SceneGraph, instanceId: string, rootId: string): void {\n reflow(graph, instanceId)\n computeAllLayouts(graph, instanceId)\n let current = graph.getNode(instanceId)\n while (current && current.id !== rootId && current.parentId) {\n current = graph.getNode(current.parentId)\n if (current && current.layoutMode !== 'NONE') computeLayout(graph, current.id)\n }\n}\n\n/**\n * A top-level frame as play shows it once an interaction changed it: a private copy of the frame,\n * with every variant its instances can switch to, that the document, undo, autosave, and\n * collaborators never see.\n */\nexport function createPlayScene(design: SceneGraph, rootId: string): PlayScene {\n const pageId = findPageId(design, rootId) ?? design.rootId\n const graph = extractPageContext(design, pageId, [rootId], {\n componentSets: true,\n shareTables: true\n })\n const touched = new Set<string>()\n let revision = 0\n\n function touch(id: string): void {\n touched.add(id)\n }\n\n return {\n graph,\n touched,\n get revision() {\n return revision\n },\n changeTo(sourceId, variantId) {\n const instanceId = changeTarget(graph, rootId, sourceId, variantId)\n const instance = instanceId ? graph.getNode(instanceId) : undefined\n const previous = instance && instanceMainComponent(graph, instance)\n if (!instance || !previous) return null\n const stop = graph.onNodeEvents({\n created: (node) => touch(node.id),\n updated: touch,\n deleted: touch\n })\n try {\n graph.swapInstanceComponent(instance.id, variantId, { keepName: true })\n graph.updateNode(instance.id, {\n prototypeReactions: withoutInheritedCopies(instance.prototypeReactions, previous)\n })\n layOutAround(graph, instance.id, rootId)\n } finally {\n stop()\n }\n graph.closest(instance.id, (node) => {\n touch(node.id)\n return node.id === rootId\n })\n revision += 1\n return { rootId, instanceId: instance.id, from: previous.id, to: variantId }\n }\n }\n}\n"],"mappings":";;;;;;;;AAoCA,SAAgB,aACd,OACA,QACA,UACA,WACe;CACf,MAAM,UAAU,MAAM,QAAQ,SAAS;CACvC,IAAI,SAAS,SAAS,eAAe,CAAC,QAAQ,UAAU,OAAO;CAC/D,MAAM,WAAW,mBAAmB,OAAO,UAAU,QAAQ,QAAQ;CACrE,IAAI,CAAC,YAAY,CAAC,MAAM,aAAa,SAAS,IAAI,MAAM,GAAG,OAAO;CAClE,OAAO,sBAAsB,OAAO,QAAQ,CAAC,EAAE,OAAO,YAAY,OAAO,SAAS;AACpF;;;;;;AAOA,SAAS,aAAa,OAAmB,YAAoB,QAAsB;CACjF,OAAO,OAAO,UAAU;CACxB,kBAAkB,OAAO,UAAU;CACnC,IAAI,UAAU,MAAM,QAAQ,UAAU;CACtC,OAAO,WAAW,QAAQ,OAAO,UAAU,QAAQ,UAAU;EAC3D,UAAU,MAAM,QAAQ,QAAQ,QAAQ;EACxC,IAAI,WAAW,QAAQ,eAAe,QAAQ,cAAc,OAAO,QAAQ,EAAE;CAC/E;AACF;;;;;;AAOA,SAAgB,gBAAgB,QAAoB,QAA2B;CAC7E,MAAM,SAAS,WAAW,QAAQ,MAAM,KAAK,OAAO;CACpD,MAAM,QAAQ,mBAAmB,QAAQ,QAAQ,CAAC,MAAM,GAAG;EACzD,eAAe;EACf,aAAa;CACf,CAAC;CACD,MAAM,0BAAU,IAAI,IAAY;CAChC,IAAI,WAAW;CAEf,SAAS,MAAM,IAAkB;EAC/B,QAAQ,IAAI,EAAE;CAChB;CAEA,OAAO;EACL;EACA;EACA,IAAI,WAAW;GACb,OAAO;EACT;EACA,SAAS,UAAU,WAAW;GAC5B,MAAM,aAAa,aAAa,OAAO,QAAQ,UAAU,SAAS;GAClE,MAAM,WAAW,aAAa,MAAM,QAAQ,UAAU,IAAI,KAAA;GAC1D,MAAM,WAAW,YAAY,sBAAsB,OAAO,QAAQ;GAClE,IAAI,CAAC,YAAY,CAAC,UAAU,OAAO;GACnC,MAAM,OAAO,MAAM,aAAa;IAC9B,UAAU,SAAS,MAAM,KAAK,EAAE;IAChC,SAAS;IACT,SAAS;GACX,CAAC;GACD,IAAI;IACF,MAAM,sBAAsB,SAAS,IAAI,WAAW,EAAE,UAAU,KAAK,CAAC;IACtE,MAAM,WAAW,SAAS,IAAI,EAC5B,oBAAoB,uBAAuB,SAAS,oBAAoB,QAAQ,EAClF,CAAC;IACD,aAAa,OAAO,SAAS,IAAI,MAAM;GACzC,UAAU;IACR,KAAK;GACP;GACA,MAAM,QAAQ,SAAS,KAAK,SAAS;IACnC,MAAM,KAAK,EAAE;IACb,OAAO,KAAK,OAAO;GACrB,CAAC;GACD,YAAY;GACZ,OAAO;IAAE;IAAQ,YAAY,SAAS;IAAI,MAAM,SAAS;IAAI,IAAI;GAAU;EAC7E;CACF;AACF"}
@@ -0,0 +1,81 @@
1
+ import { PlayChange, PlaySceneView } from "./scene.js";
2
+ import { ScrollChange } from "./scroll.js";
3
+ import { PlayClick, PlaySession } from "./session.js";
4
+ import { SmartAnimation } from "./smart-animate/animation.js";
5
+ import { PlayRevert } from "./pointer.js";
6
+ import { PrototypeAction, SceneGraph } from "@pairdraw/scene-graph";
7
+ import { Vector } from "@pairdraw/scene-graph/primitives";
8
+ //#region src/prototype/scenes.d.ts
9
+ /** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */
10
+ declare const PLAY_SCENE_LIMIT = 4;
11
+ /**
12
+ * An After delay reaction the layers a frame shows add: the layer it runs from, which is an
13
+ * instance or a copy inside one, the main component or layer it stands for, whose reaction it is,
14
+ * the reaction, its action, and the delay in milliseconds.
15
+ */
16
+ interface PlayTimeout {
17
+ sourceId: string;
18
+ /** The main component an instance shows, or the main layer a copy stands for. */
19
+ variantId: string;
20
+ reactionId: string;
21
+ action: PrototypeAction;
22
+ delayMs: number;
23
+ }
24
+ /**
25
+ * What a reaction did: the session after it, and the Change to it made, if it made one. A Scroll
26
+ * to also says which frames it scrolled, for an animation to step between, and where the layer it
27
+ * scrolled to is drawn now, for a screen that scrolls by panning to bring into view.
28
+ */
29
+ interface PlayStep {
30
+ session: PlaySession;
31
+ changed: PlayChange | null;
32
+ scrolled?: ScrollChange[];
33
+ reveal?: Vector | null;
34
+ /**
35
+ * A Smart animate Change to's animation from the frame as it was to its copy as it is now, for
36
+ * the player to run over the transition's duration; the copy shows the change at once.
37
+ */
38
+ animation?: SmartAnimation;
39
+ }
40
+ /**
41
+ * The frames play changed, each kept as a private copy so the document never changes. Frames move
42
+ * through the session as before; a Change to switches an instance on its frame's copy, which is
43
+ * made at the first change, so a prototype without one copies nothing.
44
+ */
45
+ interface PlayScenes {
46
+ /** The graph play reads a top-level frame from: its copy once changed, else the document. */
47
+ graphFor(rootId: string): SceneGraph;
48
+ /** The changed frames the canvas draws from their copies, by frame id. */
49
+ readonly views: ReadonlyMap<string, PlaySceneView>;
50
+ /** How far play scrolled each frame that scrolls, by frame id. */
51
+ readonly scroll: ReadonlyMap<string, Vector>;
52
+ /**
53
+ * Scrolls the frames along `path`, a pointer's path in `rootId`, innermost first, and returns
54
+ * what none of them could take, for the canvas to pan by.
55
+ */
56
+ scrollBy(rootId: string, path: readonly string[], dx: number, dy: number): Vector;
57
+ /** Sets one frame's offset, as an animated Scroll to steps it toward where it ends. */
58
+ setScroll(id: string, offset: Vector): void;
59
+ /** Runs a reaction of a layer in `rootId`, the shown frame unless a timer names another. */
60
+ run(session: PlaySession, click: PlayClick, rootId?: string): PlayStep;
61
+ /**
62
+ * Undoes a While hovering or While pressing reaction, unless play moved on from what it did: an
63
+ * instance that shows another variant by now, or an overlay or frame no longer shown.
64
+ */
65
+ revert(session: PlaySession, revert: PlayRevert): PlayStep;
66
+ /**
67
+ * The After delay reactions of the instances `rootId` shows and of the copies inside them, by
68
+ * the variants and main layers they stand for now.
69
+ */
70
+ instanceTimeouts(rootId: string): PlayTimeout[];
71
+ /**
72
+ * Drops the copies of frames that hold any of these document layers, after an edit to them:
73
+ * the frame's own layers and the variants its copy holds.
74
+ */
75
+ forget(nodeIds: Iterable<string>): void;
76
+ clear(): void;
77
+ }
78
+ declare function createPlayScenes(getDocument: () => SceneGraph, limit?: number): PlayScenes;
79
+ //#endregion
80
+ export { PLAY_SCENE_LIMIT, PlayScenes, PlayStep, PlayTimeout, createPlayScenes };
81
+ //# sourceMappingURL=scenes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenes.d.ts","names":[],"sources":["../../src/prototype/scenes.ts"],"mappings":";;;;;;;;;cA8Ba;;;;;;UAOI;EACf;;EAEA;EACA;EACA,QAAQ;EACR;;;;;;;UAQe;EACf,SAAS;EACT,SAAS;EACT,WAAW;EACX,SAAS;;;;;EAKT,YAAY;;;;;;;UAQG;;EAEf,SAAS,iBAAiB;;WAEjB,OAAO,oBAAoB;;WAE3B,QAAQ,oBAAoB;;;;;EAKrC,SAAS,gBAAgB,yBAAyB,YAAY,aAAa;;EAE3E,UAAU,YAAY,QAAQ;;EAE9B,IAAI,SAAS,aAAa,OAAO,WAAW,kBAAkB;;;;;EAK9D,OAAO,SAAS,aAAa,QAAQ,aAAa;;;;;EAKlD,iBAAiB,iBAAiB;;;;;EAKlC,OAAO,SAAS;EAChB;;iBAGc,iBACd,mBAAmB,YACnB,iBACC"}
@@ -0,0 +1,175 @@
1
+ import { extractPageContext, findPageId } from "../io/subgraph.js";
2
+ import { clampScroll, scrollAlong, scrollIntoView } from "./scroll.js";
3
+ import { componentLayerResolver, reactionsWithInherited } from "./reactions.js";
4
+ import { primaryAction, shownFrame, step } from "./session.js";
5
+ import { changeTarget, createPlayScene } from "./scene.js";
6
+ import { createSmartAnimation } from "./smart-animate/animation.js";
7
+ import { instanceMainComponent } from "@pairdraw/scene-graph/instances";
8
+ //#region src/prototype/scenes.ts
9
+ /** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */
10
+ const PLAY_SCENE_LIMIT = 4;
11
+ function createPlayScenes(getDocument, limit = 4) {
12
+ const scenes = /* @__PURE__ */ new Map();
13
+ const scroll = /* @__PURE__ */ new Map();
14
+ function graphFor(rootId) {
15
+ return scenes.get(rootId)?.graph ?? getDocument();
16
+ }
17
+ /**
18
+ * The frame as play shows it before a change: the document while play has not changed it, else
19
+ * a copy of play's copy, which the change is about to edit in place.
20
+ */
21
+ function frameBefore(rootId) {
22
+ const scene = scenes.get(rootId);
23
+ if (!scene) return {
24
+ graph: getDocument(),
25
+ rootId
26
+ };
27
+ const pageId = findPageId(scene.graph, rootId) ?? scene.graph.rootId;
28
+ return {
29
+ graph: extractPageContext(scene.graph, pageId, [rootId], { shareTables: true }),
30
+ rootId
31
+ };
32
+ }
33
+ /**
34
+ * Runs a Change to on `rootId`'s copy, and with a Smart animate transition the animation from the
35
+ * frame as it was.
36
+ */
37
+ function changeWith(rootId, sourceId, variantId, transition) {
38
+ const from = transition?.type === "SMART_ANIMATE" && transition.duration > 0 && changeTarget(graphFor(rootId), rootId, sourceId, variantId) ? frameBefore(rootId) : null;
39
+ const changed = changeIn(rootId, sourceId, variantId);
40
+ if (!changed || !from) return { changed };
41
+ const to = {
42
+ graph: graphFor(rootId),
43
+ rootId
44
+ };
45
+ return {
46
+ changed,
47
+ animation: createSmartAnimation(from, to, transition?.easing)
48
+ };
49
+ }
50
+ function changeIn(rootId, sourceId, variantId) {
51
+ if (!changeTarget(graphFor(rootId), rootId, sourceId, variantId)) return null;
52
+ const scene = scenes.get(rootId) ?? createPlayScene(getDocument(), rootId);
53
+ const change = scene.changeTo(sourceId, variantId);
54
+ scenes.delete(rootId);
55
+ scenes.set(rootId, scene);
56
+ for (const oldest of scenes.keys()) {
57
+ if (scenes.size <= limit) break;
58
+ scenes.delete(oldest);
59
+ }
60
+ if (change) clampScroll(scene.graph, scroll);
61
+ return change;
62
+ }
63
+ return {
64
+ graphFor,
65
+ views: scenes,
66
+ scroll,
67
+ scrollBy(rootId, path, dx, dy) {
68
+ return scrollAlong(graphFor(rootId), scroll, path, dx, dy);
69
+ },
70
+ setScroll(id, offset) {
71
+ scroll.set(id, offset);
72
+ },
73
+ run(session, { sourceId, action }, rootId = shownFrame(session)) {
74
+ if (action.type === "NODE" && action.navigation === "CHANGE_TO") {
75
+ if (!action.nodeId) return {
76
+ session,
77
+ changed: null
78
+ };
79
+ return {
80
+ session,
81
+ ...changeWith(rootId, sourceId, action.nodeId, action.transition)
82
+ };
83
+ }
84
+ if (action.type === "NODE" && action.navigation === "SCROLL_TO") {
85
+ if (!action.nodeId) return {
86
+ session,
87
+ changed: null,
88
+ scrolled: [],
89
+ reveal: null
90
+ };
91
+ return {
92
+ session,
93
+ changed: null,
94
+ ...scrollIntoView(graphFor(rootId), scroll, rootId, action.nodeId)
95
+ };
96
+ }
97
+ return {
98
+ session: step(getDocument(), session, action),
99
+ changed: null
100
+ };
101
+ },
102
+ revert(session, revert) {
103
+ if (revert.kind === "change") {
104
+ const graph = graphFor(revert.rootId);
105
+ const instance = graph.getNode(revert.instanceId);
106
+ if (!instance || instanceMainComponent(graph, instance)?.id !== revert.to) return {
107
+ session,
108
+ changed: null
109
+ };
110
+ const { rootId, instanceId, from, transition } = revert;
111
+ return {
112
+ session,
113
+ ...changeWith(rootId, instanceId, from, transition)
114
+ };
115
+ }
116
+ if (!(revert.kind === "overlay" ? session.overlays.at(-1) === revert.frameId : session.frameId === revert.frameId)) return {
117
+ session,
118
+ changed: null
119
+ };
120
+ const action = { type: revert.kind === "overlay" ? "CLOSE" : "BACK" };
121
+ return {
122
+ session: step(getDocument(), session, action),
123
+ changed: null
124
+ };
125
+ },
126
+ instanceTimeouts(rootId) {
127
+ const graph = graphFor(rootId);
128
+ const timeouts = [];
129
+ const sourceOf = componentLayerResolver(graph);
130
+ const collect = (node, variantId, inherited) => {
131
+ for (const reaction of reactionsWithInherited(node, inherited)) {
132
+ const action = reaction.trigger.type === "AFTER_TIMEOUT" && primaryAction(reaction);
133
+ if (!action) continue;
134
+ timeouts.push({
135
+ sourceId: node.id,
136
+ variantId,
137
+ reactionId: reaction.id,
138
+ action,
139
+ delayMs: reaction.trigger.delay * 1e3
140
+ });
141
+ }
142
+ };
143
+ const visit = (id) => {
144
+ for (const child of graph.getChildren(id)) {
145
+ if (child.type === "INSTANCE") {
146
+ const main = instanceMainComponent(graph, child);
147
+ if (main) collect(child, main.id, main.prototypeReactions);
148
+ } else {
149
+ const source = sourceOf(child);
150
+ if (source && source.id !== child.id) collect(child, source.id, source.prototypeReactions);
151
+ }
152
+ visit(child.id);
153
+ }
154
+ };
155
+ visit(rootId);
156
+ return timeouts;
157
+ },
158
+ forget(nodeIds) {
159
+ const design = getDocument();
160
+ for (const id of nodeIds) for (const [rootId, scene] of scenes) {
161
+ const copied = scene.graph.getNode(id);
162
+ const held = copied !== void 0 && copied.type !== "CANVAS" && id !== scene.graph.rootId;
163
+ if (design.isDescendant(id, rootId) || held) scenes.delete(rootId);
164
+ }
165
+ },
166
+ clear() {
167
+ scenes.clear();
168
+ scroll.clear();
169
+ }
170
+ };
171
+ }
172
+ //#endregion
173
+ export { PLAY_SCENE_LIMIT, createPlayScenes };
174
+
175
+ //# sourceMappingURL=scenes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scenes.js","names":[],"sources":["../../src/prototype/scenes.ts"],"sourcesContent":["import type {\n PrototypeAction,\n PrototypeReaction,\n PrototypeTransition,\n SceneGraph,\n SceneNode\n} from '@pairdraw/scene-graph'\nimport { instanceMainComponent } from '@pairdraw/scene-graph/instances'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\nimport { extractPageContext, findPageId } from '#core/io/subgraph'\n\nimport type { PlayRevert } from './pointer'\nimport { componentLayerResolver, reactionsWithInherited } from './reactions'\nimport {\n changeTarget,\n createPlayScene,\n type PlayChange,\n type PlayScene,\n type PlaySceneView\n} from './scene'\nimport { clampScroll, scrollAlong, scrollIntoView, type ScrollChange } from './scroll'\nimport { primaryAction, shownFrame, step, type PlayClick, type PlaySession } from './session'\nimport {\n createSmartAnimation,\n type PlayFrame,\n type SmartAnimation\n} from './smart-animate/animation'\n\n/** How many changed frames play keeps; a frame dropped beyond them starts again as designed. */\nexport const PLAY_SCENE_LIMIT = 4\n\n/**\n * An After delay reaction the layers a frame shows add: the layer it runs from, which is an\n * instance or a copy inside one, the main component or layer it stands for, whose reaction it is,\n * the reaction, its action, and the delay in milliseconds.\n */\nexport interface PlayTimeout {\n sourceId: string\n /** The main component an instance shows, or the main layer a copy stands for. */\n variantId: string\n reactionId: string\n action: PrototypeAction\n delayMs: number\n}\n\n/**\n * What a reaction did: the session after it, and the Change to it made, if it made one. A Scroll\n * to also says which frames it scrolled, for an animation to step between, and where the layer it\n * scrolled to is drawn now, for a screen that scrolls by panning to bring into view.\n */\nexport interface PlayStep {\n session: PlaySession\n changed: PlayChange | null\n scrolled?: ScrollChange[]\n reveal?: Vector | null\n /**\n * A Smart animate Change to's animation from the frame as it was to its copy as it is now, for\n * the player to run over the transition's duration; the copy shows the change at once.\n */\n animation?: SmartAnimation\n}\n\n/**\n * The frames play changed, each kept as a private copy so the document never changes. Frames move\n * through the session as before; a Change to switches an instance on its frame's copy, which is\n * made at the first change, so a prototype without one copies nothing.\n */\nexport interface PlayScenes {\n /** The graph play reads a top-level frame from: its copy once changed, else the document. */\n graphFor(rootId: string): SceneGraph\n /** The changed frames the canvas draws from their copies, by frame id. */\n readonly views: ReadonlyMap<string, PlaySceneView>\n /** How far play scrolled each frame that scrolls, by frame id. */\n readonly scroll: ReadonlyMap<string, Vector>\n /**\n * Scrolls the frames along `path`, a pointer's path in `rootId`, innermost first, and returns\n * what none of them could take, for the canvas to pan by.\n */\n scrollBy(rootId: string, path: readonly string[], dx: number, dy: number): Vector\n /** Sets one frame's offset, as an animated Scroll to steps it toward where it ends. */\n setScroll(id: string, offset: Vector): void\n /** Runs a reaction of a layer in `rootId`, the shown frame unless a timer names another. */\n run(session: PlaySession, click: PlayClick, rootId?: string): PlayStep\n /**\n * Undoes a While hovering or While pressing reaction, unless play moved on from what it did: an\n * instance that shows another variant by now, or an overlay or frame no longer shown.\n */\n revert(session: PlaySession, revert: PlayRevert): PlayStep\n /**\n * The After delay reactions of the instances `rootId` shows and of the copies inside them, by\n * the variants and main layers they stand for now.\n */\n instanceTimeouts(rootId: string): PlayTimeout[]\n /**\n * Drops the copies of frames that hold any of these document layers, after an edit to them:\n * the frame's own layers and the variants its copy holds.\n */\n forget(nodeIds: Iterable<string>): void\n clear(): void\n}\n\nexport function createPlayScenes(\n getDocument: () => SceneGraph,\n limit = PLAY_SCENE_LIMIT\n): PlayScenes {\n // Insertion order is use order: a frame changed again moves to the end, and the first goes.\n const scenes = new Map<string, PlayScene>()\n const scroll = new Map<string, Vector>()\n\n function graphFor(rootId: string): SceneGraph {\n return scenes.get(rootId)?.graph ?? getDocument()\n }\n\n /**\n * The frame as play shows it before a change: the document while play has not changed it, else\n * a copy of play's copy, which the change is about to edit in place.\n */\n function frameBefore(rootId: string): PlayFrame {\n const scene = scenes.get(rootId)\n if (!scene) return { graph: getDocument(), rootId }\n const pageId = findPageId(scene.graph, rootId) ?? scene.graph.rootId\n return {\n graph: extractPageContext(scene.graph, pageId, [rootId], { shareTables: true }),\n rootId\n }\n }\n\n /**\n * Runs a Change to on `rootId`'s copy, and with a Smart animate transition the animation from the\n * frame as it was.\n */\n function changeWith(\n rootId: string,\n sourceId: string,\n variantId: string,\n transition: PrototypeTransition | null\n ): Pick<PlayStep, 'changed' | 'animation'> {\n const smart = transition?.type === 'SMART_ANIMATE' && transition.duration > 0\n const before = smart && changeTarget(graphFor(rootId), rootId, sourceId, variantId)\n const from = before ? frameBefore(rootId) : null\n const changed = changeIn(rootId, sourceId, variantId)\n if (!changed || !from) return { changed }\n const to = { graph: graphFor(rootId), rootId }\n return { changed, animation: createSmartAnimation(from, to, transition?.easing) }\n }\n\n function changeIn(rootId: string, sourceId: string, variantId: string): PlayChange | null {\n // Checked on what play shows now, so a Change to that cannot run copies nothing.\n if (!changeTarget(graphFor(rootId), rootId, sourceId, variantId)) return null\n const scene = scenes.get(rootId) ?? createPlayScene(getDocument(), rootId)\n const change = scene.changeTo(sourceId, variantId)\n scenes.delete(rootId)\n scenes.set(rootId, scene)\n for (const oldest of scenes.keys()) {\n if (scenes.size <= limit) break\n scenes.delete(oldest)\n }\n // What the switched instance holds may be shorter now than a frame scrolled past.\n if (change) clampScroll(scene.graph, scroll)\n return change\n }\n\n return {\n graphFor,\n views: scenes,\n scroll,\n scrollBy(rootId, path, dx, dy) {\n return scrollAlong(graphFor(rootId), scroll, path, dx, dy)\n },\n setScroll(id, offset) {\n scroll.set(id, offset)\n },\n run(session, { sourceId, action }, rootId = shownFrame(session)) {\n if (action.type === 'NODE' && action.navigation === 'CHANGE_TO') {\n if (!action.nodeId) return { session, changed: null }\n return { session, ...changeWith(rootId, sourceId, action.nodeId, action.transition) }\n }\n if (action.type === 'NODE' && action.navigation === 'SCROLL_TO') {\n if (!action.nodeId) return { session, changed: null, scrolled: [], reveal: null }\n const moved = scrollIntoView(graphFor(rootId), scroll, rootId, action.nodeId)\n return { session, changed: null, ...moved }\n }\n return { session: step(getDocument(), session, action), changed: null }\n },\n revert(session, revert) {\n if (revert.kind === 'change') {\n const graph = graphFor(revert.rootId)\n const instance = graph.getNode(revert.instanceId)\n if (!instance || instanceMainComponent(graph, instance)?.id !== revert.to) {\n return { session, changed: null }\n }\n const { rootId, instanceId, from, transition } = revert\n return { session, ...changeWith(rootId, instanceId, from, transition) }\n }\n const shown =\n revert.kind === 'overlay'\n ? session.overlays.at(-1) === revert.frameId\n : session.frameId === revert.frameId\n if (!shown) return { session, changed: null }\n const action = { type: revert.kind === 'overlay' ? 'CLOSE' : 'BACK' } as const\n return { session: step(getDocument(), session, action), changed: null }\n },\n instanceTimeouts(rootId) {\n const graph = graphFor(rootId)\n const timeouts: PlayTimeout[] = []\n const sourceOf = componentLayerResolver(graph)\n const collect = (node: SceneNode, variantId: string, inherited: PrototypeReaction[]) => {\n for (const reaction of reactionsWithInherited(node, inherited)) {\n const action = reaction.trigger.type === 'AFTER_TIMEOUT' && primaryAction(reaction)\n if (!action) continue\n timeouts.push({\n sourceId: node.id,\n variantId,\n reactionId: reaction.id,\n action,\n delayMs: reaction.trigger.delay * 1000\n })\n }\n }\n const visit = (id: string) => {\n for (const child of graph.getChildren(id)) {\n if (child.type === 'INSTANCE') {\n const main = instanceMainComponent(graph, child)\n if (main) collect(child, main.id, main.prototypeReactions)\n } else {\n // A plain copy inherits its main layer's After delay; the resolver reads each\n // instance's copy map once, so arming costs one search per instance, not per copy.\n const source = sourceOf(child)\n if (source && source.id !== child.id)\n collect(child, source.id, source.prototypeReactions)\n }\n visit(child.id)\n }\n }\n visit(rootId)\n return timeouts\n },\n forget(nodeIds) {\n const design = getDocument()\n for (const id of nodeIds) {\n for (const [rootId, scene] of scenes) {\n // The copy holds the frame and every variant its instances switch to, wherever they\n // are, under the page and document it copied, which an edit elsewhere touches too.\n const copied = scene.graph.getNode(id)\n const held = copied !== undefined && copied.type !== 'CANVAS' && id !== scene.graph.rootId\n if (design.isDescendant(id, rootId) || held) scenes.delete(rootId)\n }\n }\n },\n clear() {\n scenes.clear()\n scroll.clear()\n }\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,48 @@
1
+ import { SceneGraph, SceneNode } from "@pairdraw/scene-graph";
2
+ import { Vector } from "@pairdraw/scene-graph/primitives";
3
+ //#region src/prototype/scroll.d.ts
4
+ /**
5
+ * Whether play scrolls a frame's content inside it: a frame, component, or instance with overflow
6
+ * scrolling that clips, as Figma needs for a frame inside another. A rotated one does not scroll.
7
+ */
8
+ declare function scrollsInPlay(node: SceneNode): boolean;
9
+ /**
10
+ * How far play may scroll a frame's content, along the axes it scrolls: how far its visible
11
+ * layers reach past its edge, with an auto layout's trailing padding, as Figma scrolls to it.
12
+ */
13
+ declare function scrollRange(graph: SceneGraph, nodeId: string): Vector;
14
+ /**
15
+ * Scrolls the frames along `path`, innermost first, by as much as each can move, and passes the
16
+ * rest outward, as a browser chains a scroll. Returns what none of them could take.
17
+ */
18
+ declare function scrollAlong(graph: SceneGraph, scroll: Map<string, Vector>, path: readonly string[], dx: number, dy: number): Vector;
19
+ /** Keeps every offset within its frame's range, after a change resized what the frame holds. */
20
+ declare function clampScroll(graph: SceneGraph, scroll: Map<string, Vector>): void;
21
+ /** One frame a Scroll to moved, from and to its offsets, for an animation to step between. */
22
+ interface ScrollChange {
23
+ id: string;
24
+ from: Vector;
25
+ to: Vector;
26
+ }
27
+ /**
28
+ * Scrolls every frame around `targetId` inside `rootId`, innermost first, so the layer meets each
29
+ * one's top left as far as it can scroll, as Figma's Scroll to does. Returns the frames it moved,
30
+ * and where the layer is now drawn, for a screen that scrolls by panning to bring into view.
31
+ */
32
+ declare function scrollIntoView(graph: SceneGraph, scroll: Map<string, Vector>, rootId: string, targetId: string): {
33
+ scrolled: ScrollChange[];
34
+ reveal: Vector | null;
35
+ };
36
+ declare function scrollShiftX(node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>, scroll: Vector | undefined): number;
37
+ declare function scrollShiftY(node: Pick<SceneNode, 'scrollBehavior' | 'x' | 'y'>, scroll: Vector | undefined): number;
38
+ /**
39
+ * The children of a frame play scrolled, in the order they draw: the layers that scroll with the
40
+ * content first, then the fixed and sticky ones above them, as Figma lifts fixed children over the
41
+ * scrolling content. Each group keeps its layer order. A mask and the layers it masks are never
42
+ * lifted, so a mask run stays together; without an offset, or with nothing to lift, the order is
43
+ * the one given.
44
+ */
45
+ declare function liftedChildIds(graph: SceneGraph, childIds: readonly string[], scroll: Vector | undefined): readonly string[];
46
+ //#endregion
47
+ export { ScrollChange, clampScroll, liftedChildIds, scrollAlong, scrollIntoView, scrollRange, scrollShiftX, scrollShiftY, scrollsInPlay };
48
+ //# sourceMappingURL=scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.d.ts","names":[],"sources":["../../src/prototype/scroll.ts"],"mappings":";;;;;;;iBAYgB,cAAc,MAAM;;;;;iBAapB,YAAY,OAAO,YAAY,iBAAiB;;;;;iBAyBhD,YACd,OAAO,YACP,QAAQ,YAAY,SACpB,yBACA,YACA,aACC;;iBAoBa,YAAY,OAAO,YAAY,QAAQ,YAAY;;UASlD;EACf;EACA,MAAM;EACN,IAAI;;;;;;;iBAQU,eACd,OAAO,YACP,QAAQ,YAAY,SACpB,gBACA;EACG,UAAU;EAAgB,QAAQ;;iBA2CvB,aACd,MAAM,KAAK,0CACX,QAAQ;iBAKM,aACd,MAAM,KAAK,0CACX,QAAQ;;;;;;;;iBAYM,eACd,OAAO,YACP,6BACA,QAAQ"}