@pairdraw/core 0.20.0 → 0.21.1

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 (539) hide show
  1. package/dist/canvas/noise/render.js +1 -1
  2. package/dist/canvas/noise/render.js.map +1 -1
  3. package/dist/canvas/noise/shader.d.ts +6 -3
  4. package/dist/canvas/noise/shader.d.ts.map +1 -1
  5. package/dist/canvas/noise/shader.js +12 -7
  6. package/dist/canvas/noise/shader.js.map +1 -1
  7. package/dist/canvas/noise/tile.d.ts.map +1 -1
  8. package/dist/canvas/noise/tile.js +2 -1
  9. package/dist/canvas/noise/tile.js.map +1 -1
  10. package/dist/canvas/renderer/colors.d.ts +20 -5
  11. package/dist/canvas/renderer/colors.d.ts.map +1 -1
  12. package/dist/canvas/renderer/colors.js +48 -42
  13. package/dist/canvas/renderer/colors.js.map +1 -1
  14. package/dist/canvas/renderer/document-surface.d.ts +25 -0
  15. package/dist/canvas/renderer/document-surface.d.ts.map +1 -0
  16. package/dist/canvas/renderer/document-surface.js +46 -0
  17. package/dist/canvas/renderer/document-surface.js.map +1 -0
  18. package/dist/canvas/renderer/fonts.d.ts.map +1 -1
  19. package/dist/canvas/renderer/fonts.js +6 -4
  20. package/dist/canvas/renderer/fonts.js.map +1 -1
  21. package/dist/canvas/renderer/lifecycle.js +4 -3
  22. package/dist/canvas/renderer/lifecycle.js.map +1 -1
  23. package/dist/canvas/renderer/methods.d.ts.map +1 -1
  24. package/dist/canvas/renderer/methods.js +1 -0
  25. package/dist/canvas/renderer/methods.js.map +1 -1
  26. package/dist/canvas/renderer/pipeline.d.ts.map +1 -1
  27. package/dist/canvas/renderer/pipeline.js +23 -2
  28. package/dist/canvas/renderer/pipeline.js.map +1 -1
  29. package/dist/canvas/renderer/retained-backing.d.ts.map +1 -1
  30. package/dist/canvas/renderer/retained-backing.js +2 -1
  31. package/dist/canvas/renderer/retained-backing.js.map +1 -1
  32. package/dist/canvas/renderer/tiles/surface-pool.d.ts.map +1 -1
  33. package/dist/canvas/renderer/tiles/surface-pool.js +2 -7
  34. package/dist/canvas/renderer/tiles/surface-pool.js.map +1 -1
  35. package/dist/canvas/renderer.d.ts +20 -2
  36. package/dist/canvas/renderer.d.ts.map +1 -1
  37. package/dist/canvas/renderer.js +28 -4
  38. package/dist/canvas/renderer.js.map +1 -1
  39. package/dist/canvas/scene.d.ts.map +1 -1
  40. package/dist/canvas/scene.js +4 -3
  41. package/dist/canvas/scene.js.map +1 -1
  42. package/dist/canvas/shaders/compile.d.ts +3 -1
  43. package/dist/canvas/shaders/compile.d.ts.map +1 -1
  44. package/dist/canvas/shaders/compile.js +12 -3
  45. package/dist/canvas/shaders/compile.js.map +1 -1
  46. package/dist/canvas/shaders/draw.d.ts.map +1 -1
  47. package/dist/canvas/shaders/draw.js +10 -3
  48. package/dist/canvas/shaders/draw.js.map +1 -1
  49. package/dist/canvas/shaders/effect.d.ts.map +1 -1
  50. package/dist/canvas/shaders/effect.js +8 -17
  51. package/dist/canvas/shaders/effect.js.map +1 -1
  52. package/dist/canvas/shadows/shape.d.ts.map +1 -1
  53. package/dist/canvas/shadows/shape.js +4 -2
  54. package/dist/canvas/shadows/shape.js.map +1 -1
  55. package/dist/canvas/shadows.d.ts.map +1 -1
  56. package/dist/canvas/shadows.js +4 -2
  57. package/dist/canvas/shadows.js.map +1 -1
  58. package/dist/canvas/text/decorations.d.ts +2 -2
  59. package/dist/canvas/text/decorations.d.ts.map +1 -1
  60. package/dist/canvas/text/decorations.js +5 -5
  61. package/dist/canvas/text/decorations.js.map +1 -1
  62. package/dist/canvas/text/index.js +1 -1
  63. package/dist/canvas/text/index.js.map +1 -1
  64. package/dist/canvas/text/paragraph/index.d.ts +2 -2
  65. package/dist/canvas/text/paragraph/index.d.ts.map +1 -1
  66. package/dist/canvas/text/paragraph/index.js +16 -5
  67. package/dist/canvas/text/paragraph/index.js.map +1 -1
  68. package/dist/canvas/text/renderer.d.ts +2 -1
  69. package/dist/canvas/text/renderer.d.ts.map +1 -1
  70. package/dist/canvas/text/shape.js +4 -4
  71. package/dist/canvas/text/shape.js.map +1 -1
  72. package/dist/canvas/texture.d.ts.map +1 -1
  73. package/dist/canvas/texture.js +2 -1
  74. package/dist/canvas/texture.js.map +1 -1
  75. package/dist/design-memory/rules.js +1 -1
  76. package/dist/editor/clipboard/assets.d.ts.map +1 -1
  77. package/dist/editor/clipboard/assets.js +2 -2
  78. package/dist/editor/clipboard/assets.js.map +1 -1
  79. package/dist/editor/clipboard/component-matches.d.ts +13 -0
  80. package/dist/editor/clipboard/component-matches.d.ts.map +1 -0
  81. package/dist/editor/clipboard/component-matches.js +50 -0
  82. package/dist/editor/clipboard/component-matches.js.map +1 -0
  83. package/dist/editor/clipboard/dependencies.d.ts +7 -0
  84. package/dist/editor/clipboard/dependencies.d.ts.map +1 -1
  85. package/dist/editor/clipboard/dependencies.js +5 -0
  86. package/dist/editor/clipboard/dependencies.js.map +1 -1
  87. package/dist/editor/clipboard/export.js +2 -2
  88. package/dist/editor/clipboard/export.js.map +1 -1
  89. package/dist/editor/clipboard.d.ts.map +1 -1
  90. package/dist/editor/clipboard.js +48 -19
  91. package/dist/editor/clipboard.js.map +1 -1
  92. package/dist/editor/components/properties.d.ts.map +1 -1
  93. package/dist/editor/components/properties.js +3 -3
  94. package/dist/editor/components/properties.js.map +1 -1
  95. package/dist/editor/eyedropper.d.ts +1 -1
  96. package/dist/editor/eyedropper.d.ts.map +1 -1
  97. package/dist/editor/eyedropper.js +6 -3
  98. package/dist/editor/eyedropper.js.map +1 -1
  99. package/dist/editor/history/atomic-tool.d.ts.map +1 -1
  100. package/dist/editor/history/atomic-tool.js +3 -2
  101. package/dist/editor/history/atomic-tool.js.map +1 -1
  102. package/dist/editor/shapes/pencil.js +1 -1
  103. package/dist/editor/structure/state.d.ts.map +1 -1
  104. package/dist/editor/structure/state.js +2 -2
  105. package/dist/editor/structure/state.js.map +1 -1
  106. package/dist/editor/text.d.ts.map +1 -1
  107. package/dist/editor/text.js +2 -2
  108. package/dist/editor/text.js.map +1 -1
  109. package/dist/editor/variables.js +3 -3
  110. package/dist/editor/variables.js.map +1 -1
  111. package/dist/figma-api/fresh-read.d.ts +15 -0
  112. package/dist/figma-api/fresh-read.d.ts.map +1 -0
  113. package/dist/figma-api/fresh-read.js +54 -0
  114. package/dist/figma-api/fresh-read.js.map +1 -0
  115. package/dist/figma-api/graph-ref.d.ts +9 -0
  116. package/dist/figma-api/graph-ref.d.ts.map +1 -0
  117. package/dist/figma-api/graph-ref.js +14 -0
  118. package/dist/figma-api/graph-ref.js.map +1 -0
  119. package/dist/figma-api/index.d.ts +6 -1
  120. package/dist/figma-api/index.d.ts.map +1 -1
  121. package/dist/figma-api/index.js +12 -5
  122. package/dist/figma-api/index.js.map +1 -1
  123. package/dist/figma-api/pending-layout.d.ts +3 -3
  124. package/dist/figma-api/pending-layout.d.ts.map +1 -1
  125. package/dist/figma-api/pending-layout.js +7 -3
  126. package/dist/figma-api/pending-layout.js.map +1 -1
  127. package/dist/figma-api/pending-sync.d.ts +1 -1
  128. package/dist/figma-api/pending-sync.d.ts.map +1 -1
  129. package/dist/figma-api/pending-sync.js +3 -1
  130. package/dist/figma-api/pending-sync.js.map +1 -1
  131. package/dist/figma-api/proxy.d.ts.map +1 -1
  132. package/dist/figma-api/proxy.js +3 -2
  133. package/dist/figma-api/proxy.js.map +1 -1
  134. package/dist/figma-api/reactions.d.ts +20 -4
  135. package/dist/figma-api/reactions.d.ts.map +1 -1
  136. package/dist/figma-api/reactions.js +49 -3
  137. package/dist/figma-api/reactions.js.map +1 -1
  138. package/dist/figma-api/variables/index.d.ts.map +1 -1
  139. package/dist/figma-api/variables/index.js +2 -2
  140. package/dist/figma-api/variables/index.js.map +1 -1
  141. package/dist/io/formats/design-tokens/css/known.js +1 -1
  142. package/dist/io/formats/design-tokens/css/known.js.map +1 -1
  143. package/dist/io/formats/design-tokens/css/read.d.ts +3 -1
  144. package/dist/io/formats/design-tokens/css/read.d.ts.map +1 -1
  145. package/dist/io/formats/design-tokens/css/read.js +11 -5
  146. package/dist/io/formats/design-tokens/css/read.js.map +1 -1
  147. package/dist/io/formats/design-tokens/css/sync.d.ts.map +1 -1
  148. package/dist/io/formats/design-tokens/css/sync.js +17 -4
  149. package/dist/io/formats/design-tokens/css/sync.js.map +1 -1
  150. package/dist/io/formats/design-tokens/css/values.d.ts +6 -5
  151. package/dist/io/formats/design-tokens/css/values.d.ts.map +1 -1
  152. package/dist/io/formats/design-tokens/css/values.js +24 -8
  153. package/dist/io/formats/design-tokens/css/values.js.map +1 -1
  154. package/dist/io/formats/design-tokens/decode.d.ts +7 -6
  155. package/dist/io/formats/design-tokens/decode.d.ts.map +1 -1
  156. package/dist/io/formats/design-tokens/decode.js +13 -12
  157. package/dist/io/formats/design-tokens/decode.js.map +1 -1
  158. package/dist/io/formats/design-tokens/export.js +3 -3
  159. package/dist/io/formats/design-tokens/export.js.map +1 -1
  160. package/dist/io/formats/design-tokens/plan/index.d.ts.map +1 -1
  161. package/dist/io/formats/design-tokens/plan/index.js +4 -3
  162. package/dist/io/formats/design-tokens/plan/index.js.map +1 -1
  163. package/dist/io/formats/design-tokens/plan/styles.d.ts.map +1 -1
  164. package/dist/io/formats/design-tokens/plan/styles.js +9 -9
  165. package/dist/io/formats/design-tokens/plan/styles.js.map +1 -1
  166. package/dist/io/formats/design-tokens/styles.d.ts +4 -4
  167. package/dist/io/formats/design-tokens/styles.d.ts.map +1 -1
  168. package/dist/io/formats/design-tokens/styles.js +7 -7
  169. package/dist/io/formats/design-tokens/styles.js.map +1 -1
  170. package/dist/io/formats/design-tokens/sync/drift.js +2 -2
  171. package/dist/io/formats/design-tokens/sync/drift.js.map +1 -1
  172. package/dist/io/formats/design-tokens/values.d.ts +10 -5
  173. package/dist/io/formats/design-tokens/values.d.ts.map +1 -1
  174. package/dist/io/formats/design-tokens/values.js +13 -7
  175. package/dist/io/formats/design-tokens/values.js.map +1 -1
  176. package/dist/io/formats/drawio/label.js +1 -1
  177. package/dist/io/formats/drawio/paint.js +1 -1
  178. package/dist/io/formats/drawio/warnings.d.ts +17 -2
  179. package/dist/io/formats/drawio/warnings.d.ts.map +1 -1
  180. package/dist/io/formats/drawio/warnings.js +15 -8
  181. package/dist/io/formats/drawio/warnings.js.map +1 -1
  182. package/dist/io/formats/fig/export/index.d.ts.map +1 -1
  183. package/dist/io/formats/fig/export/index.js +15 -3
  184. package/dist/io/formats/fig/export/index.js.map +1 -1
  185. package/dist/io/formats/fig/export/patch/index.d.ts.map +1 -1
  186. package/dist/io/formats/fig/export/patch/index.js +2 -1
  187. package/dist/io/formats/fig/export/patch/index.js.map +1 -1
  188. package/dist/io/formats/fig/export/setup.d.ts +7 -2
  189. package/dist/io/formats/fig/export/setup.d.ts.map +1 -1
  190. package/dist/io/formats/fig/export/setup.js +12 -13
  191. package/dist/io/formats/fig/export/setup.js.map +1 -1
  192. package/dist/io/formats/fig/export/variables.d.ts.map +1 -1
  193. package/dist/io/formats/fig/export/variables.js +9 -7
  194. package/dist/io/formats/fig/export/variables.js.map +1 -1
  195. package/dist/io/formats/html/index.d.ts +1 -0
  196. package/dist/io/formats/html/index.d.ts.map +1 -1
  197. package/dist/io/formats/html/index.js +5 -3
  198. package/dist/io/formats/html/index.js.map +1 -1
  199. package/dist/io/formats/html/vectors.js +1 -0
  200. package/dist/io/formats/html/vectors.js.map +1 -1
  201. package/dist/io/formats/mermaid/layers.js +2 -2
  202. package/dist/io/formats/mermaid/layers.js.map +1 -1
  203. package/dist/io/formats/mermaid/styles.js +1 -1
  204. package/dist/io/formats/pdf/export.d.ts.map +1 -1
  205. package/dist/io/formats/pdf/export.js +1 -0
  206. package/dist/io/formats/pdf/export.js.map +1 -1
  207. package/dist/io/formats/pdf/prepare.d.ts +4 -4
  208. package/dist/io/formats/pdf/prepare.d.ts.map +1 -1
  209. package/dist/io/formats/pdf/prepare.js +2 -2
  210. package/dist/io/formats/pdf/prepare.js.map +1 -1
  211. package/dist/io/formats/pen/index.d.ts.map +1 -1
  212. package/dist/io/formats/pen/index.js +13 -2
  213. package/dist/io/formats/pen/index.js.map +1 -1
  214. package/dist/io/formats/pptx/style.js +1 -1
  215. package/dist/io/formats/raster/render.d.ts +1 -1
  216. package/dist/io/formats/raster/render.d.ts.map +1 -1
  217. package/dist/io/formats/raster/render.js +9 -4
  218. package/dist/io/formats/raster/render.js.map +1 -1
  219. package/dist/io/formats/svg/defs.d.ts +6 -3
  220. package/dist/io/formats/svg/defs.d.ts.map +1 -1
  221. package/dist/io/formats/svg/defs.js +12 -11
  222. package/dist/io/formats/svg/defs.js.map +1 -1
  223. package/dist/io/formats/svg/effects.js +2 -2
  224. package/dist/io/formats/svg/effects.js.map +1 -1
  225. package/dist/io/formats/svg/export.d.ts +5 -2
  226. package/dist/io/formats/svg/export.d.ts.map +1 -1
  227. package/dist/io/formats/svg/export.js +4 -2
  228. package/dist/io/formats/svg/export.js.map +1 -1
  229. package/dist/io/formats/svg/filter.d.ts +4 -1
  230. package/dist/io/formats/svg/filter.d.ts.map +1 -1
  231. package/dist/io/formats/svg/filter.js +6 -2
  232. package/dist/io/formats/svg/filter.js.map +1 -1
  233. package/dist/io/formats/svg/grain.js +1 -1
  234. package/dist/io/formats/svg/grain.js.map +1 -1
  235. package/dist/io/formats/svg/import.d.ts +4 -2
  236. package/dist/io/formats/svg/import.d.ts.map +1 -1
  237. package/dist/io/formats/svg/import.js +2 -1
  238. package/dist/io/formats/svg/import.js.map +1 -1
  239. package/dist/io/formats/svg/text/export.d.ts.map +1 -1
  240. package/dist/io/formats/svg/text/export.js +8 -8
  241. package/dist/io/formats/svg/text/export.js.map +1 -1
  242. package/dist/io/formats/svg/text/layout.js +2 -2
  243. package/dist/io/formats/svg/text/layout.js.map +1 -1
  244. package/dist/io/formats.d.ts.map +1 -1
  245. package/dist/io/formats.js +11 -4
  246. package/dist/io/formats.js.map +1 -1
  247. package/dist/io/index.d.ts +2 -2
  248. package/dist/io/subgraph.d.ts.map +1 -1
  249. package/dist/io/subgraph.js +1 -1
  250. package/dist/io/subgraph.js.map +1 -1
  251. package/dist/io/types.d.ts +12 -3
  252. package/dist/io/types.d.ts.map +1 -1
  253. package/dist/kiwi/fig/session/options.d.ts +3 -0
  254. package/dist/kiwi/fig/session/options.d.ts.map +1 -1
  255. package/dist/kiwi/fig/session/options.js +4 -0
  256. package/dist/kiwi/fig/session/options.js.map +1 -1
  257. package/dist/layout/yoga-helpers.d.ts +2 -1
  258. package/dist/layout/yoga-helpers.d.ts.map +1 -1
  259. package/dist/layout/yoga-helpers.js +7 -1
  260. package/dist/layout/yoga-helpers.js.map +1 -1
  261. package/dist/layout.js +24 -1
  262. package/dist/layout.js.map +1 -1
  263. package/dist/lint/fixes.js +1 -1
  264. package/dist/lint/linter.js +2 -2
  265. package/dist/lint/linter.js.map +1 -1
  266. package/dist/pairdraw-api/comments.d.ts +4 -1
  267. package/dist/pairdraw-api/comments.d.ts.map +1 -1
  268. package/dist/pairdraw-api/comments.js +5 -0
  269. package/dist/pairdraw-api/comments.js.map +1 -1
  270. package/dist/pairdraw-api/index.d.ts +3 -3
  271. package/dist/pairdraw-api/index.d.ts.map +1 -1
  272. package/dist/pairdraw-api/index.js +5 -5
  273. package/dist/pairdraw-api/index.js.map +1 -1
  274. package/dist/pairdraw-api/nodes.d.ts +1 -1
  275. package/dist/prototype/scene.js +1 -1
  276. package/dist/rpc/analyze-commands.js +1 -1
  277. package/dist/rpc/read-commands.d.ts +2 -2
  278. package/dist/rpc/read-commands.js +3 -3
  279. package/dist/rpc/read-commands.js.map +1 -1
  280. package/dist/rpc/variables-command.js +2 -2
  281. package/dist/rpc/variables-command.js.map +1 -1
  282. package/dist/text/font/provider.d.ts +15 -0
  283. package/dist/text/font/provider.d.ts.map +1 -0
  284. package/dist/text/font/provider.js +18 -0
  285. package/dist/text/font/provider.js.map +1 -0
  286. package/dist/text/font/readiness.d.ts +32 -0
  287. package/dist/text/font/readiness.d.ts.map +1 -0
  288. package/dist/text/font/{status.js → readiness.js} +8 -4
  289. package/dist/text/font/readiness.js.map +1 -0
  290. package/dist/text/index.d.ts +4 -3
  291. package/dist/text/index.js +4 -3
  292. package/dist/text/prepare.d.ts +9 -4
  293. package/dist/text/prepare.d.ts.map +1 -1
  294. package/dist/text/prepare.js +9 -4
  295. package/dist/text/prepare.js.map +1 -1
  296. package/dist/tools/analyze/colors.js +1 -1
  297. package/dist/tools/analyze/responsive/index.js +7 -18
  298. package/dist/tools/analyze/responsive/index.js.map +1 -1
  299. package/dist/tools/analyze/responsive/widths.d.ts +27 -0
  300. package/dist/tools/analyze/responsive/widths.d.ts.map +1 -0
  301. package/dist/tools/analyze/responsive/widths.js +49 -0
  302. package/dist/tools/analyze/responsive/widths.js.map +1 -0
  303. package/dist/tools/analyze.d.ts +2 -1
  304. package/dist/tools/analyze.js +2 -1
  305. package/dist/tools/codegen/tokens.d.ts.map +1 -1
  306. package/dist/tools/codegen/tokens.js +2 -2
  307. package/dist/tools/codegen/tokens.js.map +1 -1
  308. package/dist/tools/comments.d.ts.map +1 -1
  309. package/dist/tools/comments.js +2 -2
  310. package/dist/tools/comments.js.map +1 -1
  311. package/dist/tools/component-catalog.d.ts.map +1 -1
  312. package/dist/tools/component-catalog.js +5 -3
  313. package/dist/tools/component-catalog.js.map +1 -1
  314. package/dist/tools/create/basic.js +1 -1
  315. package/dist/tools/create/behaviours.js +1 -1
  316. package/dist/tools/create/html.d.ts.map +1 -1
  317. package/dist/tools/create/html.js +1 -3
  318. package/dist/tools/create/html.js.map +1 -1
  319. package/dist/tools/create/icons.js +2 -2
  320. package/dist/tools/create/icons.js.map +1 -1
  321. package/dist/tools/create/mermaid.js +1 -1
  322. package/dist/tools/create/render.js +1 -1
  323. package/dist/tools/create/svg.js +5 -2
  324. package/dist/tools/create/svg.js.map +1 -1
  325. package/dist/tools/create/vector.js +3 -3
  326. package/dist/tools/create/vector.js.map +1 -1
  327. package/dist/tools/css/shorthand.d.ts +20 -0
  328. package/dist/tools/css/shorthand.d.ts.map +1 -0
  329. package/dist/tools/css/shorthand.js +54 -0
  330. package/dist/tools/css/shorthand.js.map +1 -0
  331. package/dist/tools/describe/index.js +2 -2
  332. package/dist/tools/describe/index.js.map +1 -1
  333. package/dist/tools/describe/issues.js +1 -1
  334. package/dist/tools/html-host.d.ts.map +1 -1
  335. package/dist/tools/html-host.js +5 -3
  336. package/dist/tools/html-host.js.map +1 -1
  337. package/dist/tools/image-ai/apply.d.ts.map +1 -1
  338. package/dist/tools/image-ai/apply.js +1 -3
  339. package/dist/tools/image-ai/apply.js.map +1 -1
  340. package/dist/tools/image-ai/generate.js +1 -1
  341. package/dist/tools/image-ai/service.d.ts.map +1 -1
  342. package/dist/tools/image-ai/service.js +5 -3
  343. package/dist/tools/image-ai/service.js.map +1 -1
  344. package/dist/tools/index.d.ts +2 -1
  345. package/dist/tools/index.js +2 -1
  346. package/dist/tools/modify/effects.js +1 -1
  347. package/dist/tools/modify/effects.js.map +1 -1
  348. package/dist/tools/modify/geometry.d.ts.map +1 -1
  349. package/dist/tools/modify/geometry.js +14 -3
  350. package/dist/tools/modify/geometry.js.map +1 -1
  351. package/dist/tools/modify/layout.d.ts.map +1 -1
  352. package/dist/tools/modify/layout.js +35 -8
  353. package/dist/tools/modify/layout.js.map +1 -1
  354. package/dist/tools/modify/matching.d.ts.map +1 -1
  355. package/dist/tools/modify/matching.js +10 -10
  356. package/dist/tools/modify/matching.js.map +1 -1
  357. package/dist/tools/modify/paint.d.ts.map +1 -1
  358. package/dist/tools/modify/paint.js +57 -5
  359. package/dist/tools/modify/paint.js.map +1 -1
  360. package/dist/tools/modify/reactions.d.ts.map +1 -1
  361. package/dist/tools/modify/reactions.js +2 -2
  362. package/dist/tools/modify/reactions.js.map +1 -1
  363. package/dist/tools/modify/text.d.ts.map +1 -1
  364. package/dist/tools/modify/text.js +3 -3
  365. package/dist/tools/modify/text.js.map +1 -1
  366. package/dist/tools/prompts/codegen.js +1 -1
  367. package/dist/tools/prompts/codegen.js.map +1 -1
  368. package/dist/tools/read/css.d.ts +14 -0
  369. package/dist/tools/read/css.d.ts.map +1 -0
  370. package/dist/tools/read/css.js +306 -0
  371. package/dist/tools/read/css.js.map +1 -0
  372. package/dist/tools/read/libraries.js +1 -1
  373. package/dist/tools/read/reactions.js +1 -1
  374. package/dist/tools/read/reactions.js.map +1 -1
  375. package/dist/tools/read/space.d.ts.map +1 -1
  376. package/dist/tools/read/space.js +0 -2
  377. package/dist/tools/read/space.js.map +1 -1
  378. package/dist/tools/read.d.ts +2 -1
  379. package/dist/tools/read.js +2 -1
  380. package/dist/tools/registry/core.d.ts +1 -1
  381. package/dist/tools/registry/core.js +3 -1
  382. package/dist/tools/registry/core.js.map +1 -1
  383. package/dist/tools/schema.d.ts +6 -4
  384. package/dist/tools/schema.d.ts.map +1 -1
  385. package/dist/tools/schema.js +9 -5
  386. package/dist/tools/schema.js.map +1 -1
  387. package/dist/tools/script/host.d.ts.map +1 -1
  388. package/dist/tools/script/host.js +5 -3
  389. package/dist/tools/script/host.js.map +1 -1
  390. package/dist/tools/variables/collections.js +1 -1
  391. package/dist/tools/variables/collections.js.map +1 -1
  392. package/dist/tools/variables/values.d.ts.map +1 -1
  393. package/dist/tools/variables/values.js +4 -4
  394. package/dist/tools/variables/values.js.map +1 -1
  395. package/dist/tools/vector/vectorize.d.ts.map +1 -1
  396. package/dist/tools/vector/vectorize.js +6 -4
  397. package/dist/tools/vector/vectorize.js.map +1 -1
  398. package/dist/tools/video-host.d.ts.map +1 -1
  399. package/dist/tools/video-host.js +5 -3
  400. package/dist/tools/video-host.js.map +1 -1
  401. package/dist/vector/vectorize/svg/gradients.d.ts +2 -2
  402. package/dist/vector/vectorize/svg/gradients.d.ts.map +1 -1
  403. package/dist/vector/vectorize/svg/gradients.js +5 -5
  404. package/dist/vector/vectorize/svg/gradients.js.map +1 -1
  405. package/dist/vector/vectorize/svg/to-vectors.d.ts +3 -1
  406. package/dist/vector/vectorize/svg/to-vectors.d.ts.map +1 -1
  407. package/dist/vector/vectorize/svg/to-vectors.js +13 -12
  408. package/dist/vector/vectorize/svg/to-vectors.js.map +1 -1
  409. package/package.json +9 -9
  410. package/src/canvas/noise/render.ts +1 -1
  411. package/src/canvas/noise/shader.ts +13 -5
  412. package/src/canvas/noise/tile.ts +2 -1
  413. package/src/canvas/renderer/colors.ts +76 -50
  414. package/src/canvas/renderer/document-surface.ts +53 -0
  415. package/src/canvas/renderer/fonts.ts +6 -4
  416. package/src/canvas/renderer/lifecycle.ts +4 -4
  417. package/src/canvas/renderer/methods.ts +1 -0
  418. package/src/canvas/renderer/pipeline.ts +21 -3
  419. package/src/canvas/renderer/retained-backing.ts +2 -1
  420. package/src/canvas/renderer/tiles/surface-pool.ts +9 -7
  421. package/src/canvas/renderer.ts +36 -11
  422. package/src/canvas/scene.ts +4 -3
  423. package/src/canvas/shaders/compile.ts +14 -3
  424. package/src/canvas/shaders/draw.ts +11 -4
  425. package/src/canvas/shaders/effect.ts +8 -19
  426. package/src/canvas/shadows/shape.ts +4 -2
  427. package/src/canvas/shadows.ts +5 -2
  428. package/src/canvas/text/decorations.ts +15 -5
  429. package/src/canvas/text/index.ts +9 -1
  430. package/src/canvas/text/paragraph/index.ts +16 -6
  431. package/src/canvas/text/renderer.ts +2 -1
  432. package/src/canvas/text/shape.ts +4 -4
  433. package/src/canvas/texture.ts +2 -1
  434. package/src/editor/clipboard/assets.ts +6 -2
  435. package/src/editor/clipboard/component-matches.ts +65 -0
  436. package/src/editor/clipboard/dependencies.ts +22 -1
  437. package/src/editor/clipboard/export.ts +2 -2
  438. package/src/editor/clipboard.ts +74 -20
  439. package/src/editor/components/properties.ts +3 -2
  440. package/src/editor/eyedropper.ts +14 -4
  441. package/src/editor/history/atomic-tool.ts +3 -2
  442. package/src/editor/structure/state.ts +2 -1
  443. package/src/editor/text.ts +2 -1
  444. package/src/editor/variables.ts +3 -3
  445. package/src/figma-api/fresh-read.ts +57 -0
  446. package/src/figma-api/graph-ref.ts +13 -0
  447. package/src/figma-api/index.ts +12 -4
  448. package/src/figma-api/pending-layout.ts +7 -3
  449. package/src/figma-api/pending-sync.ts +4 -1
  450. package/src/figma-api/proxy.ts +2 -1
  451. package/src/figma-api/reactions.ts +91 -10
  452. package/src/figma-api/variables/index.ts +5 -4
  453. package/src/io/formats/design-tokens/css/known.ts +1 -1
  454. package/src/io/formats/design-tokens/css/read.ts +20 -7
  455. package/src/io/formats/design-tokens/css/sync.ts +9 -4
  456. package/src/io/formats/design-tokens/css/values.ts +37 -9
  457. package/src/io/formats/design-tokens/decode.ts +17 -12
  458. package/src/io/formats/design-tokens/export.ts +3 -3
  459. package/src/io/formats/design-tokens/plan/index.ts +6 -5
  460. package/src/io/formats/design-tokens/plan/styles.ts +37 -10
  461. package/src/io/formats/design-tokens/styles.ts +10 -7
  462. package/src/io/formats/design-tokens/sync/drift.ts +6 -4
  463. package/src/io/formats/design-tokens/values.ts +15 -8
  464. package/src/io/formats/drawio/warnings.ts +28 -9
  465. package/src/io/formats/fig/export/index.ts +36 -3
  466. package/src/io/formats/fig/export/patch/index.ts +4 -1
  467. package/src/io/formats/fig/export/setup.ts +25 -15
  468. package/src/io/formats/fig/export/variables.ts +17 -6
  469. package/src/io/formats/html/index.ts +9 -3
  470. package/src/io/formats/html/vectors.ts +1 -0
  471. package/src/io/formats/mermaid/layers.ts +2 -2
  472. package/src/io/formats/pdf/export.ts +1 -0
  473. package/src/io/formats/pdf/prepare.ts +6 -6
  474. package/src/io/formats/pen/index.ts +15 -4
  475. package/src/io/formats/raster/render.ts +12 -4
  476. package/src/io/formats/svg/defs.ts +26 -14
  477. package/src/io/formats/svg/effects.ts +2 -2
  478. package/src/io/formats/svg/export.ts +17 -3
  479. package/src/io/formats/svg/filter.ts +12 -2
  480. package/src/io/formats/svg/grain.ts +1 -1
  481. package/src/io/formats/svg/import.ts +6 -3
  482. package/src/io/formats/svg/text/export.ts +10 -8
  483. package/src/io/formats/svg/text/layout.ts +2 -2
  484. package/src/io/formats.ts +18 -5
  485. package/src/io/index.ts +1 -0
  486. package/src/io/subgraph.ts +4 -1
  487. package/src/io/types.ts +10 -0
  488. package/src/kiwi/fig/session/options.ts +4 -1
  489. package/src/layout/yoga-helpers.ts +8 -0
  490. package/src/layout.ts +47 -1
  491. package/src/lint/linter.ts +1 -1
  492. package/src/pairdraw-api/comments.ts +6 -0
  493. package/src/pairdraw-api/index.ts +7 -9
  494. package/src/rpc/read-commands.ts +4 -4
  495. package/src/rpc/variables-command.ts +2 -2
  496. package/src/text/font/provider.ts +26 -0
  497. package/src/text/font/{status.ts → readiness.ts} +13 -9
  498. package/src/text/index.ts +2 -1
  499. package/src/text/prepare.ts +9 -4
  500. package/src/tools/analyze/responsive/index.ts +8 -15
  501. package/src/tools/analyze/responsive/widths.ts +63 -0
  502. package/src/tools/analyze.ts +2 -0
  503. package/src/tools/codegen/tokens.ts +4 -2
  504. package/src/tools/comments.ts +6 -4
  505. package/src/tools/component-catalog.ts +5 -3
  506. package/src/tools/create/html.ts +0 -3
  507. package/src/tools/create/icons.ts +1 -1
  508. package/src/tools/create/svg.ts +4 -1
  509. package/src/tools/create/vector.ts +2 -2
  510. package/src/tools/css/shorthand.ts +64 -0
  511. package/src/tools/describe/index.ts +2 -8
  512. package/src/tools/html-host.ts +5 -3
  513. package/src/tools/image-ai/apply.ts +0 -2
  514. package/src/tools/image-ai/service.ts +5 -3
  515. package/src/tools/index.ts +2 -0
  516. package/src/tools/modify/effects.ts +1 -1
  517. package/src/tools/modify/geometry.ts +16 -3
  518. package/src/tools/modify/layout.ts +47 -13
  519. package/src/tools/modify/matching.ts +14 -11
  520. package/src/tools/modify/paint.ts +85 -5
  521. package/src/tools/modify/reactions.ts +3 -2
  522. package/src/tools/modify/text.ts +15 -11
  523. package/src/tools/prompts/codegen.md +2 -1
  524. package/src/tools/read/css.ts +365 -0
  525. package/src/tools/read/reactions.ts +3 -2
  526. package/src/tools/read/space.ts +0 -2
  527. package/src/tools/read.ts +1 -0
  528. package/src/tools/registry/core.ts +3 -2
  529. package/src/tools/schema.ts +14 -5
  530. package/src/tools/script/host.ts +6 -3
  531. package/src/tools/variables/collections.ts +1 -1
  532. package/src/tools/variables/values.ts +16 -5
  533. package/src/tools/vector/vectorize.ts +10 -4
  534. package/src/tools/video-host.ts +5 -3
  535. package/src/vector/vectorize/svg/gradients.ts +8 -5
  536. package/src/vector/vectorize/svg/to-vectors.ts +48 -14
  537. package/dist/text/font/status.d.ts +0 -28
  538. package/dist/text/font/status.d.ts.map +0 -1
  539. package/dist/text/font/status.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import type { ColorProfile } from '@pairdraw/scene-graph'
1
2
  import type { Color } from '@pairdraw/scene-graph/primitives'
2
3
 
3
4
  import { formatColor, type SVGExportContext } from './defs'
@@ -7,8 +8,12 @@ import { svg, type SVGNode } from './node'
7
8
  * A flood's colour, opaque: its alpha goes in `flood-opacity`, which a Display P3 colour would
8
9
  * otherwise carry a second time.
9
10
  */
10
- export function floodColor(color: Color, colorSpace: SVGExportContext['colorSpace']): string {
11
- return formatColor({ ...color, a: 1 }, 1, colorSpace)
11
+ export function floodColor(
12
+ color: Color,
13
+ colorSpace: SVGExportContext['colorSpace'],
14
+ documentColorSpace: ColorProfile = 'srgb'
15
+ ): string {
16
+ return formatColor({ ...color, a: 1 }, 1, colorSpace, documentColorSpace)
12
17
  }
13
18
 
14
19
  /** An SVG filter's primitives as they are added, each naming its result uniquely. */
@@ -35,6 +40,11 @@ export class FilterBuilder {
35
40
  return this.ctx.colorSpace
36
41
  }
37
42
 
43
+ /** The document's profile, where its stored colors are. */
44
+ get documentColorSpace(): ColorProfile {
45
+ return this.ctx.documentColorSpace
46
+ }
47
+
38
48
  /** A new result name, unique in this filter. */
39
49
  result(name: string): string {
40
50
  this.count += 1
@@ -95,7 +95,7 @@ export function noiseFilter(filter: FilterBuilder, effect: NoiseEffect, input: s
95
95
  filter.push('feComposite', { in: band, in2: input, operator: 'in', result: clipped })
96
96
  const flood = filter.result('noiseFlood')
97
97
  filter.push('feFlood', {
98
- 'flood-color': floodColor(color, filter.colorSpace),
98
+ 'flood-color': floodColor(color, filter.colorSpace, filter.documentColorSpace),
99
99
  'flood-opacity': round(color.a),
100
100
  result: flood
101
101
  })
@@ -1,6 +1,6 @@
1
1
  import { groupBy } from 'es-toolkit/array'
2
2
 
3
- import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'
3
+ import type { DocumentColorSpace, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
4
4
  import { WHITE } from '@pairdraw/scene-graph/constants'
5
5
  import { fitEnclosingGroups } from '@pairdraw/scene-graph/group-bounds'
6
6
  import type { Size } from '@pairdraw/scene-graph/primitives'
@@ -31,6 +31,8 @@ export type SVGImportData = SVGVectorizeResult &
31
31
  export interface SVGImportOptions {
32
32
  name?: string
33
33
  defaultColor?: string
34
+ /** The profile a color that names its own space is read into. */
35
+ profile?: DocumentColorSpace
34
36
  x?: number
35
37
  y?: number
36
38
  /** Keep the frame of an SVG that draws nothing, as `figma.createNodeFromSvg` does. */
@@ -40,7 +42,7 @@ export interface SVGImportOptions {
40
42
  /** The layers SVG markup draws, or null when it does not parse as SVG. */
41
43
  export function prepareSVGImport(
42
44
  source: string,
43
- options: Pick<SVGImportOptions, 'defaultColor'> = {}
45
+ options: Pick<SVGImportOptions, 'defaultColor' | 'profile'> = {}
44
46
  ): SVGImportData | null {
45
47
  if (!parseSVGDocument(source)) return null
46
48
  const sized = parseSVGSize(source, { width: 0, height: 0 }).width > 0
@@ -50,7 +52,8 @@ export function prepareSVGImport(
50
52
  { width, height },
51
53
  {
52
54
  defaultColor: options.defaultColor,
53
- preserveAspectRatio: true
55
+ preserveAspectRatio: true,
56
+ profile: options.profile
54
57
  }
55
58
  ) ?? { paths: [], texts: [], contentBounds: { x: 0, y: 0, width: 0, height: 0 } }
56
59
  return { width, height, name: svgRootId(source), sized, ...vectorized }
@@ -1,4 +1,4 @@
1
- import type { CharacterStyleOverride, SceneNode } from '@pairdraw/scene-graph'
1
+ import type { CharacterStyleOverride, ColorProfile, SceneNode } from '@pairdraw/scene-graph'
2
2
  import { parseFontStyle } from '@pairdraw/scene-graph/font-style'
3
3
  import { textLengthPixels } from '@pairdraw/scene-graph/text'
4
4
  import { resolveNodeTextDirection } from '@pairdraw/scene-graph/text/direction'
@@ -26,6 +26,7 @@ import { textFontFace } from '#core/text/requirements/collect'
26
26
  function styleOverrideToTspanAttrs(
27
27
  style: CharacterStyleOverride,
28
28
  colorSpace: 'srgb' | 'display-p3',
29
+ documentSpace: ColorProfile,
29
30
  parentFillOpacity: number | undefined,
30
31
  node: Pick<SceneNode, 'fontSize' | 'letterSpacing'>
31
32
  ): Record<string, string | number | undefined> {
@@ -54,9 +55,9 @@ function styleOverrideToTspanAttrs(
54
55
  // Paragraphs and saved glyphs draw a run at color.a * opacity. Shapes paint opacity alone.
55
56
  const alpha = round(visibleFill.color.a * visibleFill.opacity)
56
57
  if (colorSpace === 'display-p3') {
57
- attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace)
58
+ attrs.fill = formatColor({ ...visibleFill.color, a: 1 }, alpha, colorSpace, documentSpace)
58
59
  } else {
59
- attrs.fill = formatColor(visibleFill.color, 1, colorSpace)
60
+ attrs.fill = formatColor(visibleFill.color, 1, colorSpace, documentSpace)
60
61
  if (alpha < 1) attrs['fill-opacity'] = alpha
61
62
  }
62
63
  // `fill-opacity` inherits, so an opaque run has to cover a translucent parent.
@@ -105,12 +106,13 @@ function spanFontAttrs(
105
106
  */
106
107
  function textStrokeAttrs(
107
108
  node: SceneNode,
108
- colorSpace: 'srgb' | 'display-p3'
109
+ colorSpace: 'srgb' | 'display-p3',
110
+ documentSpace: ColorProfile = 'srgb'
109
111
  ): Record<string, string | number | undefined> {
110
112
  const stroke = node.strokes.find((candidate) => candidate.visible)
111
113
  if (!stroke) return {}
112
114
  const attrs: Record<string, string | number | undefined> = {
113
- stroke: formatSolidColor(stroke.color, 1, colorSpace),
115
+ stroke: formatSolidColor(stroke.color, 1, colorSpace, documentSpace),
114
116
  'stroke-width': round(stroke.weight * (stroke.align === 'OUTSIDE' ? 2 : 1))
115
117
  }
116
118
  if (stroke.opacity < 1) attrs['stroke-opacity'] = round(stroke.opacity)
@@ -202,7 +204,7 @@ export function renderTextNode(
202
204
  ctx: SVGExportContext,
203
205
  fillOpacity?: number
204
206
  ): SVGNode {
205
- const { colorSpace, textLayout, fontAlias } = ctx
207
+ const { colorSpace, documentColorSpace: documentSpace, textLayout, fontAlias } = ctx
206
208
  const direction = resolveNodeTextDirection(node)
207
209
  const lines = textLayout ? textLayout(node) : null
208
210
  const laidOut = lines && lines.length > 0 ? lines : null
@@ -224,11 +226,11 @@ export function renderTextNode(
224
226
  'text-anchor': laidOut ? undefined : textAnchorForNode(node, direction),
225
227
  'text-decoration': textDecoration,
226
228
  'letter-spacing': letterSpacing ? round(letterSpacing) : undefined,
227
- ...textStrokeAttrs(node, colorSpace),
229
+ ...textStrokeAttrs(node, colorSpace, documentSpace),
228
230
  ...(fontAlias ? aliasedFontAttrs(fontRequest(node), fontAlias) : {})
229
231
  }
230
232
  const spanAttrs = (style: CharacterStyleOverride, fallback?: SVGFallbackFace) => ({
231
- ...styleOverrideToTspanAttrs(style, colorSpace, fillOpacity, node),
233
+ ...styleOverrideToTspanAttrs(style, colorSpace, documentSpace, fillOpacity, node),
232
234
  ...spanFontAttrs(node, style, fallback, fontAlias)
233
235
  })
234
236
 
@@ -6,7 +6,7 @@ import type { SkiaRenderer } from '#core/canvas/renderer'
6
6
  import { withPDFTextLayout } from '#core/io/formats/pdf/prepare'
7
7
  import { bakeAdjustedImages, hasAdjustedImagePaints } from '#core/io/formats/raster/adjusted-images'
8
8
  import { renderNodesToSVG, type SVGExportOptions } from '#core/io/formats/svg/export'
9
- import { prepareGraphFonts } from '#core/text/prepare'
9
+ import { resolveFontReadiness } from '#core/text/prepare'
10
10
 
11
11
  /**
12
12
  * Layers as SVG with their text set as the canvas sets it: the fonts it draws with loaded, each
@@ -22,7 +22,7 @@ export async function renderNodesToLaidOutSVG(
22
22
  canvasKit?: CanvasKit,
23
23
  renderer?: SkiaRenderer
24
24
  ): Promise<string | null> {
25
- await prepareGraphFonts(graph, nodeIds)
25
+ await resolveFontReadiness(graph, nodeIds)
26
26
  const baked = hasAdjustedImagePaints(graph, nodeIds)
27
27
  ? await bakeAdjustedImages(graph, nodeIds, canvasKit, renderer)
28
28
  : graph
package/src/io/formats.ts CHANGED
@@ -314,14 +314,20 @@ export const mermaidFormat: IOFormatAdapter<'mermaid'> = {
314
314
  async function writeDrawIO(graph: SceneGraph, target: DrawIOExportTarget): Promise<ExportResult> {
315
315
  const { writeDrawIOFile } = await import('@pairdraw/drawio')
316
316
  const { sceneGraphToDrawIO } = await import('./formats/drawio')
317
- const { drawioDroppedWarnings } = await import('./formats/drawio/warnings')
318
- return {
317
+ const { drawioWriteWarnings, drawioWriteWarningText } = await import('./formats/drawio/warnings')
318
+ const warningDetails = drawioWriteWarnings(graph)
319
+ const written: ExportResult = {
319
320
  format: 'drawio',
320
321
  mimeType: 'application/vnd.jgraph.mxfile',
321
322
  extension: 'drawio',
322
323
  data: writeDrawIOFile(sceneGraphToDrawIO(graph, target)),
323
- encoding: 'utf8',
324
- warnings: drawioDroppedWarnings(graph)
324
+ encoding: 'utf8'
325
+ }
326
+ if (warningDetails.length === 0) return written
327
+ return {
328
+ ...written,
329
+ warnings: warningDetails.map(drawioWriteWarningText),
330
+ warningDetails
325
331
  }
326
332
  }
327
333
 
@@ -351,7 +357,14 @@ export const svgFormat: IOFormatAdapter<'svg'> = {
351
357
  request.graph,
352
358
  target.pageId,
353
359
  target.nodeIds,
354
- { ...options, booleanPath },
360
+ {
361
+ ...options,
362
+ // An export writes the profile the document is stored in, so a Display P3 color keeps its
363
+ // gamut; a caller may still ask for sRGB. PDF and thumbnails render SVG themselves and
364
+ // stay sRGB, as their formats expect.
365
+ colorSpace: options?.colorSpace ?? request.graph.documentColorSpace,
366
+ booleanPath
367
+ },
355
368
  context?.canvasKit,
356
369
  context?.renderer
357
370
  )
package/src/io/index.ts CHANGED
@@ -35,6 +35,7 @@ export type {
35
35
  ExportRequest,
36
36
  ExportAsset,
37
37
  ExportResult,
38
+ WriteDocumentWarning,
38
39
  HTMLExportOptions,
39
40
  PDFFormatExportOptions,
40
41
  IOContext,
@@ -138,7 +138,10 @@ function copyReferencedTables(source: SceneGraph, graph: SceneGraph): void {
138
138
  variableIds: []
139
139
  })
140
140
  }
141
- graph.variableCollections.get(collection.id)?.variableIds.push(variableId)
141
+ // A collection lists its live variables; a deleted one is copied out of the list (addVariable).
142
+ if (!variable.deleted) {
143
+ graph.variableCollections.get(collection.id)?.variableIds.push(variableId)
144
+ }
142
145
  }
143
146
  }
144
147
 
package/src/io/types.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import type { CanvasKit } from 'canvaskit-wasm'
2
2
 
3
3
  import type { TailwindStylesheetLoader } from '@pairdraw/dom-css/export'
4
+ import type { PenWriteWarning } from '@pairdraw/pen'
4
5
  import type { SceneGraph } from '@pairdraw/scene-graph'
5
6
  import type { RenderColorSpace } from '@pairdraw/scene-graph/color'
6
7
 
7
8
  import type { SkiaRenderer } from '#core/canvas'
8
9
  import type { IconProvider } from '#core/icons'
9
10
 
11
+ import type { DrawioWriteWarning } from './formats/drawio/warnings'
10
12
  import type { RasterExportFormat } from './formats/raster'
11
13
 
12
14
  export type IOFormatRole = 'native-document' | 'interchange-document' | 'derived-export'
@@ -154,8 +156,16 @@ export interface ExportResult {
154
156
  assets?: ExportAsset[]
155
157
  /** What the format could not hold, such as the variables draw.io has no model for. */
156
158
  warnings?: string[]
159
+ /** The same facts as kinds, for a host that shows them in its own language. */
160
+ warningDetails?: WriteDocumentWarning[]
157
161
  }
158
162
 
163
+ /**
164
+ * What a writer could not put in its file, as facts: the pen and draw.io writers name their own
165
+ * kinds, and a host translates them instead of printing the English `warnings` sentences.
166
+ */
167
+ export type WriteDocumentWarning = PenWriteWarning | DrawioWriteWarning
168
+
159
169
  export interface HTMLExportOptions {
160
170
  html?: 'fragment' | 'standalone'
161
171
  style?: 'inline' | 'tailwind'
@@ -13,6 +13,7 @@ export type FigReaderDiagnostic =
13
13
  }
14
14
  | { kind: 'component'; diagnostic: Parameters<Handler<'onMissingComponent'>>[0] }
15
15
  | { kind: 'slot-content'; diagnostic: Parameters<Handler<'onMissingSlotContent'>>[0] }
16
+ | { kind: 'variable-type'; diagnostic: Parameters<Handler<'onUnsupportedVariableType'>>[0] }
16
17
 
17
18
  /** Each sink's entries, so a record reported again is not listed twice. */
18
19
  const reported = new WeakMap<FigReaderDiagnostic[], Set<string>>()
@@ -50,6 +51,8 @@ export function readerSessionOptions(sink: FigReaderDiagnostic[]): DocumentAssem
50
51
  onUnsupportedVariableExpression: (diagnostic) =>
51
52
  report(sink, { kind: 'variable-expression', diagnostic }),
52
53
  onMissingComponent: (diagnostic) => report(sink, { kind: 'component', diagnostic }),
53
- onMissingSlotContent: (diagnostic) => report(sink, { kind: 'slot-content', diagnostic })
54
+ onMissingSlotContent: (diagnostic) => report(sink, { kind: 'slot-content', diagnostic }),
55
+ onUnsupportedVariableType: (resource) =>
56
+ report(sink, { kind: 'variable-type', diagnostic: resource })
54
57
  }
55
58
  }
@@ -25,8 +25,16 @@ export function liveYogaNodeCount(): number {
25
25
  return liveYogaNodes
26
26
  }
27
27
 
28
+ /** Yoga nodes created since the process started, which tests read to see a pass build what it places. */
29
+ let yogaNodeCreations = 0
30
+
31
+ export function yogaNodeCreationCount(): number {
32
+ return yogaNodeCreations
33
+ }
34
+
28
35
  export function createYogaNode(): YogaNode {
29
36
  liveYogaNodes += 1
37
+ yogaNodeCreations += 1
30
38
  return Yoga.Node.create(yogaConfig)
31
39
  }
32
40
 
package/src/layout.ts CHANGED
@@ -36,7 +36,7 @@ export {
36
36
  } from './layout/text-measurement'
37
37
  import type { LayoutSizing, SceneGraph, SceneNode } from '@pairdraw/scene-graph'
38
38
  import { connectorSublayers, layoutConnector } from '@pairdraw/scene-graph/connectors'
39
- import { layoutSizing } from '@pairdraw/scene-graph/layout'
39
+ import { enforcedAspectRatio, layoutSizing } from '@pairdraw/scene-graph/layout'
40
40
 
41
41
  import { fitShapeWithTextFrame } from './layout/shape-with-text'
42
42
  import {
@@ -376,6 +376,47 @@ function configureAutoLayoutChildSizing(
376
376
  else setMainAxisSizing(yogaChild, 'height', heightSizing, child.height, child.layoutGrow)
377
377
  }
378
378
 
379
+ /**
380
+ * Whether the parent's pass places this child from the size it holds: neither its content nor the
381
+ * parent decides its size, so its own cells keep their places while the parent moves it.
382
+ */
383
+ function placesFromSize(
384
+ child: SceneNode,
385
+ parent: SceneNode,
386
+ widthSizing: LayoutSizing,
387
+ heightSizing: LayoutSizing
388
+ ): boolean {
389
+ return (
390
+ widthSizing === 'FIXED' &&
391
+ heightSizing === 'FIXED' &&
392
+ child.layoutGrow === 0 &&
393
+ parent.counterAxisAlign !== 'BASELINE' &&
394
+ child.layoutAlignSelf !== 'BASELINE' &&
395
+ enforcedAspectRatio(child) === null &&
396
+ child.minWidth === null &&
397
+ child.maxWidth === null &&
398
+ child.minHeight === null &&
399
+ child.maxHeight === null
400
+ )
401
+ }
402
+
403
+ /**
404
+ * Refuses a chain deeper than Yoga can lay out, for the subtrees a pass places from their size and
405
+ * does not build: the same refusal, without the Yoga nodes.
406
+ */
407
+ function assertLayoutDepth(graph: SceneGraph, frame: SceneNode, depth: number): void {
408
+ if (depth > MAX_LAYOUT_DEPTH) {
409
+ throw new RangeError(
410
+ `Layers nest more than ${MAX_LAYOUT_DEPTH} auto-layout frames deep, which the layout engine cannot lay out.`
411
+ )
412
+ }
413
+ for (const child of graph.getChildren(frame.id)) {
414
+ if (child.layoutMode === 'NONE' || !child.visible) continue
415
+ if (child.layoutPositioning === 'ABSOLUTE') continue
416
+ assertLayoutDepth(graph, child, depth + 1)
417
+ }
418
+ }
419
+
379
420
  function configureChildAsAutoLayout(
380
421
  yogaChild: YogaNode,
381
422
  child: SceneNode,
@@ -410,6 +451,11 @@ function configureChildAsAutoLayout(
410
451
  return
411
452
  }
412
453
 
454
+ if (placesFromSize(child, parent, widthSizing, heightSizing)) {
455
+ assertLayoutDepth(graph, child, depth + 1)
456
+ return
457
+ }
458
+
413
459
  configureFlexContainer(yogaChild, child, direction)
414
460
  const heldAxis = heldHugAxis(graph, child)
415
461
  if (heldAxis === 'width' && widthSizing === 'HUG') yogaChild.setWidth(child.width)
@@ -334,7 +334,7 @@ function describeVariables(graph: SceneGraph): LintVariables {
334
334
  const counts = { COLOR: 0, FLOAT: 0, STRING: 0, BOOLEAN: 0 }
335
335
  const colorsByHex = new Map<string, { id: string; name: string }>()
336
336
  const numbersByField = new Map<TokenNumberField, Map<number, { id: string; name: string }[]>>()
337
- for (const variable of graph.variables.values()) {
337
+ for (const variable of graph.getLiveVariables()) {
338
338
  counts[variable.type]++
339
339
  if (variable.type === 'FLOAT') {
340
340
  const namespace = variableNamespace(variable)
@@ -111,6 +111,11 @@ export class CommentHandle {
111
111
  return commentPosition(this.graph, this.thread)
112
112
  }
113
113
 
114
+ /** The area the person circled, in canvas units relative to the pin; null for a clicked pin. */
115
+ get region(): CommentThread['region'] {
116
+ return this.thread.region ?? null
117
+ }
118
+
114
119
  get replies(): { id: string; author: string; text: string; createdAt: string }[] {
115
120
  return liveReplies(this.thread).map(({ id, author, text, createdAt }) => ({
116
121
  id,
@@ -151,6 +156,7 @@ export class CommentHandle {
151
156
  page: this.page,
152
157
  node: this.node,
153
158
  position: this.position,
159
+ region: this.region,
154
160
  replies: this.replies
155
161
  }
156
162
  }
@@ -17,7 +17,7 @@ import {
17
17
  import { exposeInstanceSwap } from '#core/figma-api/components'
18
18
  import type { FigmaAPI, FigmaNodeProxy } from '#core/figma-api/index'
19
19
  import { writeVariableValue } from '#core/figma-api/variables'
20
- import { documentFontStatus, type DocumentFontStatus } from '#core/text/font/status'
20
+ import { readFontReadiness, type FontReadiness } from '#core/text/font/readiness'
21
21
 
22
22
  import {
23
23
  getBehaviour,
@@ -90,15 +90,13 @@ export class PairdrawAPI {
90
90
  modeName?: string
91
91
  ): VariableLiteral {
92
92
  const graph = this.figma.graph
93
- const collections = [...graph.variableCollections.values()].filter(
94
- (item) => item.name === collectionName
95
- )
93
+ const collections = graph.getLiveCollections().filter((item) => item.name === collectionName)
96
94
  const collection = collections.at(0)
97
95
  if (!collection || collections.length !== 1)
98
96
  throw new Error(`Unknown or ambiguous collection: ${collectionName}`)
99
- const variables = [...graph.variables.values()].filter(
100
- (item) => item.collectionId === collection.id && item.name === variableName
101
- )
97
+ const variables = graph
98
+ .getLiveVariables()
99
+ .filter((item) => item.collectionId === collection.id && item.name === variableName)
102
100
  const variable = variables.at(0)
103
101
  if (!variable || variables.length !== 1)
104
102
  throw new Error(`Unknown or ambiguous variable: ${variableName}`)
@@ -266,8 +264,8 @@ export class PairdrawAPI {
266
264
  * Whether the current page's fonts are faithfully available: requested faces, where each
267
265
  * loaded from, substitutions, why an installed face could not load, and the layers affected.
268
266
  */
269
- getFontStatus(): DocumentFontStatus {
270
- return documentFontStatus(this.figma.graph, this.figma.currentPageId)
267
+ getFontStatus(): FontReadiness {
268
+ return readFontReadiness(this.figma.graph, this.figma.currentPageId)
271
269
  }
272
270
 
273
271
  /** A fill's OkHCL color, which the color picker keeps beside its RGB, or null. */
@@ -4,8 +4,8 @@ import type { BooleanOperation, MaskType, SceneGraph, SceneNode } from '@pairdra
4
4
 
5
5
  import { shapeDetailFields } from '#core/figma-api/shape-details'
6
6
  import { ELLIPSIS } from '#core/text/ellipsis'
7
- import type { DocumentFontStatus } from '#core/text/font/status'
8
- import { prepareGraphFonts } from '#core/text/prepare'
7
+ import type { FontReadiness } from '#core/text/font/readiness'
8
+ import { resolveFontReadiness } from '#core/text/prepare'
9
9
  import { queryByXPath } from '#core/xpath'
10
10
 
11
11
  import type { RPCCommand } from './types'
@@ -104,11 +104,11 @@ export const infoCommand: RPCCommand<void, InfoResult> = {
104
104
  }
105
105
  }
106
106
 
107
- export const fontStatusCommand: RPCCommand<void, DocumentFontStatus> = {
107
+ export const fontStatusCommand: RPCCommand<void, FontReadiness> = {
108
108
  name: 'font-status',
109
109
  execute: async (graph) => {
110
110
  const pageIds = graph.getPages().map((page) => page.id)
111
- return prepareGraphFonts(graph, pageIds.length > 0 ? pageIds : [graph.rootId])
111
+ return resolveFontReadiness(graph, pageIds.length > 0 ? pageIds : [graph.rootId])
112
112
  }
113
113
  }
114
114
 
@@ -63,7 +63,7 @@ export const variablesCommand: RPCCommand<VariablesArgs, VariablesResult> = {
63
63
 
64
64
  const result: VariablesResult = { collections: [], totalVariables: 0, totalCollections: 0 }
65
65
 
66
- for (const coll of graph.variableCollections.values()) {
66
+ for (const coll of graph.getLiveCollections()) {
67
67
  if (collFilter && !coll.name.toLowerCase().includes(collFilter)) continue
68
68
 
69
69
  const collVars = graph
@@ -120,7 +120,7 @@ async function designTokenFiles(graph: SceneGraph): Promise<TokensResult> {
120
120
  const { files, issues } = exportDesignTokens(graph)
121
121
  return {
122
122
  css: '',
123
- tokenCount: graph.variables.size,
123
+ tokenCount: graph.getLiveVariables().length,
124
124
  issues: issues.map(designTokenIssueMessage),
125
125
  files
126
126
  }
@@ -0,0 +1,26 @@
1
+ import type { CanvasKit, TypefaceFontProvider } from 'canvaskit-wasm'
2
+
3
+ import { fontManager } from './manager'
4
+
5
+ /**
6
+ * A share of the font provider `canvasKit` draws from. Every renderer and shaper holds one for as
7
+ * long as it reads text, so a face registered by one is shaped by all of them, and the last share
8
+ * given back deletes the provider. Releasing twice is safe and does nothing the second time.
9
+ */
10
+ export interface FontProviderLease {
11
+ readonly provider: TypefaceFontProvider
12
+ release(): void
13
+ }
14
+
15
+ export function leaseFontProvider(canvasKit: CanvasKit): FontProviderLease {
16
+ const provider = fontManager.acquireProvider(canvasKit)
17
+ let held = true
18
+ return {
19
+ provider,
20
+ release() {
21
+ if (!held) return
22
+ held = false
23
+ fontManager.releaseProvider(provider)
24
+ }
25
+ }
26
+ }
@@ -5,15 +5,15 @@ import { fontManager, type FontManager } from '#core/text/font/manager'
5
5
  import { collectNamedNodeFontFaces } from '#core/text/font/names'
6
6
  import type { FontLoadedSource, FontUnavailableReason } from '#core/text/font/sources'
7
7
 
8
- export type FontFaceStatus = 'available' | 'substituted' | 'unresolved'
8
+ export type FontReadinessStatus = 'available' | 'substituted' | 'unresolved'
9
9
 
10
- export interface DocumentFontFaceStatus {
10
+ export interface FontFaceReadiness {
11
11
  family: string
12
12
  /** The style the font manager loads the face as. */
13
13
  style: string
14
14
  /** The face's name, as its text names it ("Book", "Semi Bold"). */
15
15
  name: string
16
- status: FontFaceStatus
16
+ status: FontReadinessStatus
17
17
  source: FontLoadedSource | null
18
18
  substituteFamily: string | null
19
19
  /** Why the requested face could not be loaded, when the host reported a reason. */
@@ -22,10 +22,10 @@ export interface DocumentFontFaceStatus {
22
22
  nodeNames: string[]
23
23
  }
24
24
 
25
- export interface DocumentFontStatus {
25
+ export interface FontReadiness {
26
26
  faithful: boolean
27
- faces: DocumentFontFaceStatus[]
28
- issues: DocumentFontFaceStatus[]
27
+ faces: FontFaceReadiness[]
28
+ issues: FontFaceReadiness[]
29
29
  }
30
30
 
31
31
  interface MutableFontFaceUse {
@@ -72,7 +72,7 @@ function collectFaceUses(graph: SceneGraph, rootIds: readonly string[]): Mutable
72
72
  return [...uses.values()]
73
73
  }
74
74
 
75
- function faceStatus(use: MutableFontFaceUse, manager: FontManager): DocumentFontFaceStatus {
75
+ function faceStatus(use: MutableFontFaceUse, manager: FontManager): FontFaceReadiness {
76
76
  const exactSource = manager.loadedFontSource(use.family, use.style)
77
77
  if (exactSource) {
78
78
  return {
@@ -116,11 +116,15 @@ function faceStatus(use: MutableFontFaceUse, manager: FontManager): DocumentFont
116
116
  }
117
117
  }
118
118
 
119
- export function documentFontStatus(
119
+ /**
120
+ * What the fonts loaded now can draw: a face reads `unresolved` until something loads it, so a
121
+ * caller that needs the truth for a document asks {@link resolveFontReadiness} instead.
122
+ */
123
+ export function readFontReadiness(
120
124
  graph: SceneGraph,
121
125
  rootIds: string | readonly string[],
122
126
  manager: FontManager = fontManager
123
- ): DocumentFontStatus {
127
+ ): FontReadiness {
124
128
  const roots = typeof rootIds === 'string' ? [rootIds] : rootIds
125
129
  const faces = collectFaceUses(graph, roots)
126
130
  .map((use) => faceStatus(use, manager))
package/src/text/index.ts CHANGED
@@ -8,7 +8,8 @@ export * from './font/sources'
8
8
  export * from './font/style'
9
9
  export * from './font/variation'
10
10
  export * from './font/woff2'
11
- export * from './font/status'
11
+ export * from './font/provider'
12
+ export * from './font/readiness'
12
13
  export * from './font/document'
13
14
  export { setHarfBuzzSubsetLocator, type HarfBuzzSubsetLocator } from './font/harfbuzz'
14
15
  export * from './fallbacks'
@@ -16,7 +16,7 @@ import { collectGraphFontRequirements, collectNodeFontFaces } from '#core/text/r
16
16
  import { missingGraphFontScripts } from '#core/text/requirements/resolved'
17
17
  import { fontFaceDemand, fontResolver } from '#core/text/resolver'
18
18
 
19
- import { documentFontStatus, type DocumentFontStatus } from './font/status'
19
+ import { readFontReadiness, type FontReadiness } from './font/readiness'
20
20
 
21
21
  /**
22
22
  * The characters of a text its layout falls back to the emoji metrics font for: ones that may be
@@ -59,14 +59,19 @@ async function settleUnavailableFonts(
59
59
  }
60
60
  }
61
61
 
62
- export async function prepareGraphFonts(
62
+ /**
63
+ * The one readiness read a caller needs: loads every face the document under `nodeIds` asks for,
64
+ * then reports what it can draw with. {@link readFontReadiness} reports the loaded state without
65
+ * loading, for a caller that only mirrors it in the UI.
66
+ */
67
+ export async function resolveFontReadiness(
63
68
  graph: SceneGraph,
64
69
  nodeIds: readonly string[],
65
70
  /** Characters a writer draws besides the text's own, which the fonts must map too. */
66
71
  extraCharacters = '',
67
72
  /** An output that draws once and cannot wait for a face to arrive; see `settleUnavailableFonts`. */
68
73
  { settleUnavailable = false }: { settleUnavailable?: boolean } = {}
69
- ): Promise<DocumentFontStatus> {
74
+ ): Promise<FontReadiness> {
70
75
  const collected = collectGraphFontRequirements(graph, nodeIds)
71
76
  const requirements = extraCharacters
72
77
  ? {
@@ -118,5 +123,5 @@ export async function prepareGraphFonts(
118
123
  requirements.nodes.map(laidOutEmojiCharacters).join('')
119
124
  if (emoji && !canDrawPlatformEmoji())
120
125
  await fontManager.loadRemoteFont(NOTO_COLOR_EMOJI_FAMILY, 'Regular', emoji)
121
- return documentFontStatus(graph, nodeIds)
126
+ return readFontReadiness(graph, nodeIds)
122
127
  }