@moondraft/import 0.0.0-stage → 0.2.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 (337) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +34 -0
  3. package/README.md +36 -2
  4. package/SOURCE.md +394 -0
  5. package/dist/adapter/convert.d.ts +144 -0
  6. package/dist/adapter/convert.js +2811 -0
  7. package/dist/adapter/figma-descriptions.d.ts +7 -0
  8. package/dist/adapter/figma-descriptions.js +34 -0
  9. package/dist/adapter/figma-grids.d.ts +12 -0
  10. package/dist/adapter/figma-grids.js +175 -0
  11. package/dist/adapter/figma-handoff.d.ts +12 -0
  12. package/dist/adapter/figma-handoff.js +167 -0
  13. package/dist/adapter/figma-hyperlinks.d.ts +13 -0
  14. package/dist/adapter/figma-hyperlinks.js +77 -0
  15. package/dist/adapter/figma.d.ts +12 -0
  16. package/dist/adapter/figma.js +40 -0
  17. package/dist/adapter/file-components.d.ts +20 -0
  18. package/dist/adapter/file-components.js +352 -0
  19. package/dist/adapter/file-resources.d.ts +29 -0
  20. package/dist/adapter/file-resources.js +851 -0
  21. package/dist/adapter/image-crop.d.ts +18 -0
  22. package/dist/adapter/image-crop.js +30 -0
  23. package/dist/adapter/index.d.ts +6 -0
  24. package/dist/adapter/index.js +9 -0
  25. package/dist/adapter/link.d.ts +49 -0
  26. package/dist/adapter/link.js +892 -0
  27. package/dist/adapter/payload.d.ts +31 -0
  28. package/dist/adapter/payload.js +78 -0
  29. package/dist/adapter/shapes.d.ts +31 -0
  30. package/dist/adapter/shapes.js +75 -0
  31. package/dist/adapter/variables.d.ts +45 -0
  32. package/dist/adapter/variables.js +106 -0
  33. package/dist/figma-file.d.ts +38 -0
  34. package/dist/figma-file.js +97 -0
  35. package/dist/figma-worker.d.ts +11 -0
  36. package/dist/figma-worker.js +12 -0
  37. package/dist/figma.d.ts +26 -0
  38. package/dist/figma.js +230 -0
  39. package/dist/index.d.ts +29 -0
  40. package/dist/index.js +50 -0
  41. package/dist/report.d.ts +42 -0
  42. package/dist/report.js +142 -0
  43. package/dist/serialize.d.ts +7 -0
  44. package/dist/serialize.js +79 -0
  45. package/dist/svg.d.ts +33 -0
  46. package/dist/svg.js +44 -0
  47. package/dist/syntax.d.ts +8 -0
  48. package/dist/syntax.js +19 -0
  49. package/dist/taco/figma-import/clipboard.d.ts +25 -0
  50. package/dist/taco/figma-import/clipboard.js +87 -0
  51. package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
  52. package/dist/taco/figma-import/clipboardSize.js +107 -0
  53. package/dist/taco/figma-import/container/compression.d.ts +9 -0
  54. package/dist/taco/figma-import/container/compression.js +174 -0
  55. package/dist/taco/figma-import/container/error.d.ts +15 -0
  56. package/dist/taco/figma-import/container/error.js +19 -0
  57. package/dist/taco/figma-import/container/kiwiContainer.d.ts +41 -0
  58. package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
  59. package/dist/taco/figma-import/container/limits.d.ts +22 -0
  60. package/dist/taco/figma-import/container/limits.js +22 -0
  61. package/dist/taco/figma-import/container/zip.d.ts +14 -0
  62. package/dist/taco/figma-import/container/zip.js +154 -0
  63. package/dist/taco/figma-import/figFile.d.ts +34 -0
  64. package/dist/taco/figma-import/figFile.js +91 -0
  65. package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
  66. package/dist/taco/figma-import/figFileDocument.js +100 -0
  67. package/dist/taco/figma-import/import/blobs.d.ts +10 -0
  68. package/dist/taco/figma-import/import/blobs.js +23 -0
  69. package/dist/taco/figma-import/import/carry.d.ts +24 -0
  70. package/dist/taco/figma-import/import/carry.js +66 -0
  71. package/dist/taco/figma-import/import/componentProps.d.ts +90 -0
  72. package/dist/taco/figma-import/import/componentProps.js +329 -0
  73. package/dist/taco/figma-import/import/componentSets.d.ts +85 -0
  74. package/dist/taco/figma-import/import/componentSets.js +647 -0
  75. package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
  76. package/dist/taco/figma-import/import/converters/effects.js +127 -0
  77. package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
  78. package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
  79. package/dist/taco/figma-import/import/converters/exportSettings.d.ts +4 -0
  80. package/dist/taco/figma-import/import/converters/exportSettings.js +49 -0
  81. package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
  82. package/dist/taco/figma-import/import/converters/frame.js +63 -0
  83. package/dist/taco/figma-import/import/converters/gradient.d.ts +74 -0
  84. package/dist/taco/figma-import/import/converters/gradient.js +108 -0
  85. package/dist/taco/figma-import/import/converters/group.d.ts +19 -0
  86. package/dist/taco/figma-import/import/converters/group.js +30 -0
  87. package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
  88. package/dist/taco/figma-import/import/converters/image.js +94 -0
  89. package/dist/taco/figma-import/import/converters/layout.d.ts +33 -0
  90. package/dist/taco/figma-import/import/converters/layout.js +187 -0
  91. package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
  92. package/dist/taco/figma-import/import/converters/line.js +40 -0
  93. package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
  94. package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
  95. package/dist/taco/figma-import/import/converters/section.d.ts +8 -0
  96. package/dist/taco/figma-import/import/converters/section.js +29 -0
  97. package/dist/taco/figma-import/import/converters/shared.d.ts +71 -0
  98. package/dist/taco/figma-import/import/converters/shared.js +372 -0
  99. package/dist/taco/figma-import/import/converters/text.d.ts +54 -0
  100. package/dist/taco/figma-import/import/converters/text.js +707 -0
  101. package/dist/taco/figma-import/import/converters/vector.d.ts +105 -0
  102. package/dist/taco/figma-import/import/converters/vector.js +609 -0
  103. package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +114 -0
  104. package/dist/taco/figma-import/import/converters/vectorNetwork.js +503 -0
  105. package/dist/taco/figma-import/import/fields.d.ts +15 -0
  106. package/dist/taco/figma-import/import/fields.js +29 -0
  107. package/dist/taco/figma-import/import/instances.d.ts +184 -0
  108. package/dist/taco/figma-import/import/instances.js +1530 -0
  109. package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
  110. package/dist/taco/figma-import/import/nestingCycles.js +488 -0
  111. package/dist/taco/figma-import/import/slots.d.ts +56 -0
  112. package/dist/taco/figma-import/import/slots.js +96 -0
  113. package/dist/taco/figma-import/import/styles.d.ts +48 -0
  114. package/dist/taco/figma-import/import/styles.js +48 -0
  115. package/dist/taco/figma-import/import/tree.d.ts +66 -0
  116. package/dist/taco/figma-import/import/tree.js +194 -0
  117. package/dist/taco/figma-import/import/types.d.ts +232 -0
  118. package/dist/taco/figma-import/import/types.js +33 -0
  119. package/dist/taco/figma-import/import/variables.d.ts +137 -0
  120. package/dist/taco/figma-import/import/variables.js +769 -0
  121. package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
  122. package/dist/taco/figma-import/import/variantTrees.js +520 -0
  123. package/dist/taco/figma-import/import/walk.d.ts +207 -0
  124. package/dist/taco/figma-import/import/walk.js +1464 -0
  125. package/dist/taco/figma-import/index.d.ts +22 -0
  126. package/dist/taco/figma-import/index.js +13 -0
  127. package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
  128. package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
  129. package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
  130. package/dist/taco/figma-import/kiwi/error.js +29 -0
  131. package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
  132. package/dist/taco/figma-import/kiwi/limits.js +18 -0
  133. package/dist/taco/figma-import/kiwi/message.d.ts +12 -0
  134. package/dist/taco/figma-import/kiwi/message.js +147 -0
  135. package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
  136. package/dist/taco/figma-import/kiwi/schema.js +206 -0
  137. package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
  138. package/dist/taco/figma-import/kiwi/types.js +18 -0
  139. package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
  140. package/dist/taco/model/agent-hidden-fields.js +29 -0
  141. package/dist/taco/model/asset-users.d.ts +23 -0
  142. package/dist/taco/model/asset-users.js +128 -0
  143. package/dist/taco/model/auto-layout-lines.d.ts +32 -0
  144. package/dist/taco/model/auto-layout-lines.js +70 -0
  145. package/dist/taco/model/codec.d.ts +444 -0
  146. package/dist/taco/model/codec.js +5665 -0
  147. package/dist/taco/model/color.d.ts +11 -0
  148. package/dist/taco/model/color.js +61 -0
  149. package/dist/taco/model/comment-operations.d.ts +102 -0
  150. package/dist/taco/model/comment-operations.js +227 -0
  151. package/dist/taco/model/component-evaluation.d.ts +96 -0
  152. package/dist/taco/model/component-evaluation.js +555 -0
  153. package/dist/taco/model/component-expressions.d.ts +242 -0
  154. package/dist/taco/model/component-expressions.js +1082 -0
  155. package/dist/taco/model/component-properties.d.ts +111 -0
  156. package/dist/taco/model/component-properties.js +339 -0
  157. package/dist/taco/model/component-samples.d.ts +83 -0
  158. package/dist/taco/model/component-samples.js +290 -0
  159. package/dist/taco/model/component-validity.d.ts +85 -0
  160. package/dist/taco/model/component-validity.js +397 -0
  161. package/dist/taco/model/components.d.ts +155 -0
  162. package/dist/taco/model/components.js +505 -0
  163. package/dist/taco/model/connector-ends.d.ts +20 -0
  164. package/dist/taco/model/connector-ends.js +188 -0
  165. package/dist/taco/model/connector-geometry.d.ts +74 -0
  166. package/dist/taco/model/connector-geometry.js +293 -0
  167. package/dist/taco/model/corner-radii.d.ts +26 -0
  168. package/dist/taco/model/corner-radii.js +47 -0
  169. package/dist/taco/model/derivations.d.ts +81 -0
  170. package/dist/taco/model/derivations.js +151 -0
  171. package/dist/taco/model/export-settings.d.ts +53 -0
  172. package/dist/taco/model/export-settings.js +156 -0
  173. package/dist/taco/model/expressions/ast.d.ts +153 -0
  174. package/dist/taco/model/expressions/ast.js +6 -0
  175. package/dist/taco/model/expressions/cache.d.ts +23 -0
  176. package/dist/taco/model/expressions/cache.js +43 -0
  177. package/dist/taco/model/expressions/check.d.ts +72 -0
  178. package/dist/taco/model/expressions/check.js +517 -0
  179. package/dist/taco/model/expressions/completion.d.ts +61 -0
  180. package/dist/taco/model/expressions/completion.js +421 -0
  181. package/dist/taco/model/expressions/evaluate.d.ts +32 -0
  182. package/dist/taco/model/expressions/evaluate.js +519 -0
  183. package/dist/taco/model/expressions/forms.d.ts +84 -0
  184. package/dist/taco/model/expressions/forms.js +200 -0
  185. package/dist/taco/model/expressions/index.d.ts +14 -0
  186. package/dist/taco/model/expressions/index.js +17 -0
  187. package/dist/taco/model/expressions/lexer.d.ts +42 -0
  188. package/dist/taco/model/expressions/lexer.js +213 -0
  189. package/dist/taco/model/expressions/library.d.ts +33 -0
  190. package/dist/taco/model/expressions/library.js +117 -0
  191. package/dist/taco/model/expressions/names.d.ts +43 -0
  192. package/dist/taco/model/expressions/names.js +99 -0
  193. package/dist/taco/model/expressions/parser.d.ts +15 -0
  194. package/dist/taco/model/expressions/parser.js +438 -0
  195. package/dist/taco/model/expressions/rename.d.ts +34 -0
  196. package/dist/taco/model/expressions/rename.js +46 -0
  197. package/dist/taco/model/expressions/source.d.ts +15 -0
  198. package/dist/taco/model/expressions/source.js +161 -0
  199. package/dist/taco/model/expressions/types.d.ts +119 -0
  200. package/dist/taco/model/expressions/types.js +102 -0
  201. package/dist/taco/model/expressions/values.d.ts +97 -0
  202. package/dist/taco/model/expressions/values.js +160 -0
  203. package/dist/taco/model/geometry-limits.d.ts +16 -0
  204. package/dist/taco/model/geometry-limits.js +67 -0
  205. package/dist/taco/model/geometry.d.ts +47 -0
  206. package/dist/taco/model/geometry.js +193 -0
  207. package/dist/taco/model/group-bounds.d.ts +38 -0
  208. package/dist/taco/model/group-bounds.js +144 -0
  209. package/dist/taco/model/id-table.d.ts +37 -0
  210. package/dist/taco/model/id-table.js +80 -0
  211. package/dist/taco/model/index.d.ts +25 -0
  212. package/dist/taco/model/index.js +27 -0
  213. package/dist/taco/model/instance-resolver.d.ts +376 -0
  214. package/dist/taco/model/instance-resolver.js +1778 -0
  215. package/dist/taco/model/layer-syntax.d.ts +340 -0
  216. package/dist/taco/model/layer-syntax.js +3506 -0
  217. package/dist/taco/model/layout/constraints.d.ts +84 -0
  218. package/dist/taco/model/layout/constraints.js +445 -0
  219. package/dist/taco/model/layout/frame-layout.d.ts +46 -0
  220. package/dist/taco/model/layout/frame-layout.js +618 -0
  221. package/dist/taco/model/layout/node-sizing.d.ts +163 -0
  222. package/dist/taco/model/layout/node-sizing.js +486 -0
  223. package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
  224. package/dist/taco/model/legacy-connector-caps.js +70 -0
  225. package/dist/taco/model/linear-call.d.ts +48 -0
  226. package/dist/taco/model/linear-call.js +58 -0
  227. package/dist/taco/model/new-nodes.d.ts +145 -0
  228. package/dist/taco/model/new-nodes.js +277 -0
  229. package/dist/taco/model/node-builder.d.ts +449 -0
  230. package/dist/taco/model/node-builder.js +2294 -0
  231. package/dist/taco/model/node-table-watch.d.ts +36 -0
  232. package/dist/taco/model/node-table-watch.js +63 -0
  233. package/dist/taco/model/node-transform.d.ts +39 -0
  234. package/dist/taco/model/node-transform.js +79 -0
  235. package/dist/taco/model/node-users-index.d.ts +10 -0
  236. package/dist/taco/model/node-users-index.js +82 -0
  237. package/dist/taco/model/operation-references.d.ts +80 -0
  238. package/dist/taco/model/operation-references.js +399 -0
  239. package/dist/taco/model/operations.d.ts +610 -0
  240. package/dist/taco/model/operations.js +2882 -0
  241. package/dist/taco/model/overlay-table.d.ts +71 -0
  242. package/dist/taco/model/overlay-table.js +171 -0
  243. package/dist/taco/model/override-remap.d.ts +69 -0
  244. package/dist/taco/model/override-remap.js +230 -0
  245. package/dist/taco/model/parent-table.d.ts +53 -0
  246. package/dist/taco/model/parent-table.js +193 -0
  247. package/dist/taco/model/problem-collector.d.ts +27 -0
  248. package/dist/taco/model/problem-collector.js +101 -0
  249. package/dist/taco/model/sha256.d.ts +10 -0
  250. package/dist/taco/model/sha256.js +79 -0
  251. package/dist/taco/model/shape-geometry.d.ts +96 -0
  252. package/dist/taco/model/shape-geometry.js +368 -0
  253. package/dist/taco/model/shared-node-table.d.ts +97 -0
  254. package/dist/taco/model/shared-node-table.js +546 -0
  255. package/dist/taco/model/slots.d.ts +113 -0
  256. package/dist/taco/model/slots.js +281 -0
  257. package/dist/taco/model/stroke-settings.d.ts +37 -0
  258. package/dist/taco/model/stroke-settings.js +90 -0
  259. package/dist/taco/model/svg-path-import.d.ts +89 -0
  260. package/dist/taco/model/svg-path-import.js +219 -0
  261. package/dist/taco/model/text-measurement.d.ts +142 -0
  262. package/dist/taco/model/text-measurement.js +846 -0
  263. package/dist/taco/model/text-reads.d.ts +66 -0
  264. package/dist/taco/model/text-reads.js +128 -0
  265. package/dist/taco/model/text-sizer.d.ts +358 -0
  266. package/dist/taco/model/text-sizer.js +996 -0
  267. package/dist/taco/model/theme-users.d.ts +59 -0
  268. package/dist/taco/model/theme-users.js +312 -0
  269. package/dist/taco/model/thumbnail.d.ts +15 -0
  270. package/dist/taco/model/thumbnail.js +34 -0
  271. package/dist/taco/model/types.d.ts +2369 -0
  272. package/dist/taco/model/types.js +366 -0
  273. package/dist/taco/model/unknown-property.d.ts +5 -0
  274. package/dist/taco/model/unknown-property.js +7 -0
  275. package/dist/taco/model/validated-documents.d.ts +22 -0
  276. package/dist/taco/model/validated-documents.js +22 -0
  277. package/dist/taco/model/variable-modes.d.ts +61 -0
  278. package/dist/taco/model/variable-modes.js +438 -0
  279. package/dist/taco/model/variable-references.d.ts +54 -0
  280. package/dist/taco/model/variable-references.js +183 -0
  281. package/dist/taco/model/variables.d.ts +24 -0
  282. package/dist/taco/model/variables.js +151 -0
  283. package/dist/taco/model/vector-network.d.ts +34 -0
  284. package/dist/taco/model/vector-network.js +411 -0
  285. package/dist/taco/svg-import/import-svg.d.ts +36 -0
  286. package/dist/taco/svg-import/import-svg.js +729 -0
  287. package/dist/taco/svg-import/index.d.ts +3 -0
  288. package/dist/taco/svg-import/index.js +3 -0
  289. package/dist/taco/svg-import/limits/limits.d.ts +79 -0
  290. package/dist/taco/svg-import/limits/limits.js +160 -0
  291. package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
  292. package/dist/taco/svg-import/paint/gradients.js +429 -0
  293. package/dist/taco/svg-import/paint/paint.d.ts +32 -0
  294. package/dist/taco/svg-import/paint/paint.js +162 -0
  295. package/dist/taco/svg-import/paths/paths.d.ts +58 -0
  296. package/dist/taco/svg-import/paths/paths.js +205 -0
  297. package/dist/taco/svg-import/public-types.d.ts +279 -0
  298. package/dist/taco/svg-import/public-types.js +56 -0
  299. package/dist/taco/svg-import/report/report.d.ts +44 -0
  300. package/dist/taco/svg-import/report/report.js +79 -0
  301. package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
  302. package/dist/taco/svg-import/reuse/reuse.js +840 -0
  303. package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
  304. package/dist/taco/svg-import/shapes/shapes.js +386 -0
  305. package/dist/taco/svg-import/structure/effects.d.ts +26 -0
  306. package/dist/taco/svg-import/structure/effects.js +618 -0
  307. package/dist/taco/svg-import/structure/image.d.ts +24 -0
  308. package/dist/taco/svg-import/structure/image.js +495 -0
  309. package/dist/taco/svg-import/structure/walk.d.ts +85 -0
  310. package/dist/taco/svg-import/structure/walk.js +544 -0
  311. package/dist/taco/svg-import/style/color.d.ts +40 -0
  312. package/dist/taco/svg-import/style/color.js +275 -0
  313. package/dist/taco/svg-import/style/computed.d.ts +214 -0
  314. package/dist/taco/svg-import/style/computed.js +1534 -0
  315. package/dist/taco/svg-import/style/css.d.ts +127 -0
  316. package/dist/taco/svg-import/style/css.js +541 -0
  317. package/dist/taco/svg-import/style/media.d.ts +25 -0
  318. package/dist/taco/svg-import/style/media.js +307 -0
  319. package/dist/taco/svg-import/style/properties.d.ts +43 -0
  320. package/dist/taco/svg-import/style/properties.js +135 -0
  321. package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
  322. package/dist/taco/svg-import/style/selector-reach.js +169 -0
  323. package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
  324. package/dist/taco/svg-import/style/selector-validity.js +307 -0
  325. package/dist/taco/svg-import/text/text.d.ts +29 -0
  326. package/dist/taco/svg-import/text/text.js +545 -0
  327. package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
  328. package/dist/taco/svg-import/transform/matrix.js +229 -0
  329. package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
  330. package/dist/taco/svg-import/tree/element-data.js +155 -0
  331. package/dist/taco/svg-import/tree/elements.d.ts +36 -0
  332. package/dist/taco/svg-import/tree/elements.js +121 -0
  333. package/dist/taco/svg-import/units/length.d.ts +43 -0
  334. package/dist/taco/svg-import/units/length.js +125 -0
  335. package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
  336. package/dist/taco/svg-import/units/viewbox.js +77 -0
  337. package/package.json +55 -4
@@ -0,0 +1,2369 @@
1
+ import type { DocumentOperation } from "./operations.ts";
2
+ /** A `major.minor.patch` version string, such as `"0.14.0"`. */
3
+ export type SemanticVersion = `${number}.${number}.${number}`;
4
+ /**
5
+ * A document schema version. Current documents use a `SemanticVersion`; the
6
+ * number form is only read from legacy files saved before version `0.0.0`.
7
+ */
8
+ export type DocumentSchemaVersion = number | SemanticVersion;
9
+ /**
10
+ * The schema version this package reads and writes. `deserializeDocument`
11
+ * migrates older documents to it, and `assertDocument` rejects any other
12
+ * version.
13
+ */
14
+ export declare const CURRENT_DOCUMENT_SCHEMA_VERSION: "0.44.0";
15
+ /** Canonical upper bound; retained text also carries one primary font asset. */
16
+ export declare const MAX_TEXT_FONT_FALLBACK_ASSETS = 4095;
17
+ type Brand<Value, Name extends string> = Value & {
18
+ readonly __brand: Name;
19
+ };
20
+ /**
21
+ * Branded string IDs. Each is a plain string at run time, but the brand keeps
22
+ * one kind of ID from being passed where another is expected. Make one with
23
+ * the matching constructor, such as `nodeId`, which rejects an empty string.
24
+ */
25
+ export type DocumentId = Brand<string, "DocumentId">;
26
+ /** The ID of a `Page`. */
27
+ export type PageId = Brand<string, "PageId">;
28
+ /** The ID of a `SceneNode`. */
29
+ export type NodeId = Brand<string, "NodeId">;
30
+ /** The ID of an `Asset`. */
31
+ export type AssetId = Brand<string, "AssetId">;
32
+ /** The ID of a `NodeStyle` in `DocumentTheme.nodeStyles`. */
33
+ export type NodeStyleId = Brand<string, "NodeStyleId">;
34
+ /** The ID of a `TextStyle` in `DocumentTheme.textStyles`. */
35
+ export type TextStyleId = Brand<string, "TextStyleId">;
36
+ /** The ID of a `CodeStyle` in `DocumentTheme.codeStyles`. */
37
+ export type CodeStyleId = Brand<string, "CodeStyleId">;
38
+ /** The ID of a `VariableCollection`. */
39
+ export type VariableCollectionId = Brand<string, "VariableCollectionId">;
40
+ /** The ID of a `VariableMode` within its collection. */
41
+ export type VariableModeId = Brand<string, "VariableModeId">;
42
+ /** The ID of a `VariableDefinition`. */
43
+ export type VariableId = Brand<string, "VariableId">;
44
+ /** The ID of a `CommitRecord` in a `DocumentStore`. */
45
+ export type CommitId = Brand<string, "CommitId">;
46
+ /**
47
+ * The ID of a `ComponentDefinition`, its key in `DesignDocument.components`.
48
+ * @since 0.23.0
49
+ */
50
+ export type ComponentId = Brand<string, "ComponentId">;
51
+ /**
52
+ * The stable ID of a component property (`ComponentPropertyDefinition.id`),
53
+ * unique within its component. It never changes, so instance values keyed by
54
+ * it survive a rename.
55
+ * @since 0.24.0
56
+ */
57
+ export type ComponentPropertyId = Brand<string, "ComponentPropertyId">;
58
+ /**
59
+ * The ID of a `VectorVertex`.
60
+ * @since 0.2.0
61
+ */
62
+ export type VectorVertexId = Brand<string, "VectorVertexId">;
63
+ /**
64
+ * The ID of a `VectorSegment`.
65
+ * @since 0.2.0
66
+ */
67
+ export type VectorSegmentId = Brand<string, "VectorSegmentId">;
68
+ /**
69
+ * The ID of a `VectorHandle`.
70
+ * @since 0.2.0
71
+ */
72
+ export type VectorHandleId = Brand<string, "VectorHandleId">;
73
+ /**
74
+ * The ID of a `VectorRegion`.
75
+ * @since 0.2.0
76
+ */
77
+ export type VectorRegionId = Brand<string, "VectorRegionId">;
78
+ /**
79
+ * A four-character OpenType feature or axis tag. Make one with `openTypeTag`.
80
+ * @since 0.2.0
81
+ */
82
+ export type OpenTypeTag = Brand<string, "OpenTypeTag">;
83
+ /** Brands a string as a `DocumentId`. Throws a `TypeError` for an empty string. */
84
+ export declare const documentId: (value: string) => DocumentId;
85
+ /** Brands a string as a `PageId`. Throws a `TypeError` for an empty string. */
86
+ export declare const pageId: (value: string) => PageId;
87
+ /** Brands a string as a `NodeId`. Throws a `TypeError` for an empty string. */
88
+ export declare const nodeId: (value: string) => NodeId;
89
+ /** Brands a string as an `AssetId`. Throws a `TypeError` for an empty string. */
90
+ export declare const assetId: (value: string) => AssetId;
91
+ /** Brands a string as a `NodeStyleId`. Throws a `TypeError` for an empty string. */
92
+ export declare const nodeStyleId: (value: string) => NodeStyleId;
93
+ /** Brands a string as a `TextStyleId`. Throws a `TypeError` for an empty string. */
94
+ export declare const textStyleId: (value: string) => TextStyleId;
95
+ /** Brands a string as a `CodeStyleId`. Throws a `TypeError` for an empty string. */
96
+ export declare const codeStyleId: (value: string) => CodeStyleId;
97
+ /** Brands a string as a `VariableCollectionId`. Throws a `TypeError` for an empty string. */
98
+ export declare const variableCollectionId: (value: string) => VariableCollectionId;
99
+ /** Brands a string as a `VariableModeId`. Throws a `TypeError` for an empty string. */
100
+ export declare const variableModeId: (value: string) => VariableModeId;
101
+ /** Brands a string as a `VariableId`. Throws a `TypeError` for an empty string. */
102
+ export declare const variableId: (value: string) => VariableId;
103
+ /** Brands a string as a `CommitId`. Throws a `TypeError` for an empty string. */
104
+ export declare const commitId: (value: string) => CommitId;
105
+ /**
106
+ * Brands a string as a `ComponentId`. Throws a `TypeError` for an empty string.
107
+ * @since 0.23.0
108
+ */
109
+ export declare const componentId: (value: string) => ComponentId;
110
+ /**
111
+ * Brands a string as a `ComponentPropertyId`. Throws a `TypeError` for an empty string.
112
+ * @since 0.24.0
113
+ */
114
+ export declare const componentPropertyId: (value: string) => ComponentPropertyId;
115
+ /** Brands a string as a `VectorVertexId`. Throws a `TypeError` for an empty string. */
116
+ export declare const vectorVertexId: (value: string) => VectorVertexId;
117
+ /** Brands a string as a `VectorSegmentId`. Throws a `TypeError` for an empty string. */
118
+ export declare const vectorSegmentId: (value: string) => VectorSegmentId;
119
+ /** Brands a string as a `VectorHandleId`. Throws a `TypeError` for an empty string. */
120
+ export declare const vectorHandleId: (value: string) => VectorHandleId;
121
+ /** Brands a string as a `VectorRegionId`. Throws a `TypeError` for an empty string. */
122
+ export declare const vectorRegionId: (value: string) => VectorRegionId;
123
+ /** OpenType feature and variation tags are exactly four printable ASCII bytes. */
124
+ export declare function openTypeTag(value: string): OpenTypeTag;
125
+ /** A JSON scalar: string, finite number, boolean, or `null`. */
126
+ export type JsonPrimitive = string | number | boolean | null;
127
+ /** Any JSON value. Used for the free-form `metadata` fields. */
128
+ export type JsonValue = JsonPrimitive | readonly JsonValue[] | {
129
+ readonly [key: string]: JsonValue;
130
+ };
131
+ /** An axis-aligned rectangle; `x` and `y` are its top-left corner. */
132
+ export interface Rect {
133
+ readonly x: number;
134
+ readonly y: number;
135
+ readonly width: number;
136
+ readonly height: number;
137
+ }
138
+ /**
139
+ * An SVG-style affine matrix `[a, b, c, d, e, f]`. It maps a point (x, y) to
140
+ * (a*x + c*y + e, b*x + d*y + f), which is the 3×3 matrix product
141
+ *
142
+ * $$
143
+ * \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} =
144
+ * \begin{bmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{bmatrix}
145
+ * \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}
146
+ * $$
147
+ */
148
+ export type TransformMatrix = readonly [
149
+ a: number,
150
+ b: number,
151
+ c: number,
152
+ d: number,
153
+ e: number,
154
+ f: number
155
+ ];
156
+ /**
157
+ * Fields every paint shares, as in Figma's `Paint`: whether it shows and how
158
+ * it blends with the paints below it on the same layer.
159
+ * @since 0.18.0
160
+ */
161
+ export interface PaintVisibility {
162
+ /**
163
+ * False hides the paint without removing it, like the eye button in
164
+ * Figma's fill and stroke lists. Defaults to true.
165
+ * @since 0.18.0
166
+ */
167
+ readonly visible?: boolean;
168
+ /**
169
+ * How the paint blends with the paints below it on the same layer: the
170
+ * fills under a fill, or the fills and strokes under a stroke. Uses the
171
+ * same modes as a node's `blendMode`. Defaults to `"normal"`.
172
+ * @since 0.18.0
173
+ */
174
+ readonly blendMode?: BlendMode;
175
+ }
176
+ export interface SolidPaint extends PaintVisibility {
177
+ readonly kind: "solid";
178
+ readonly color: string;
179
+ readonly opacity?: number;
180
+ }
181
+ export interface GradientStop {
182
+ readonly offset: number;
183
+ readonly color: string;
184
+ }
185
+ /** A linear paint with endpoints in the local paint box. */
186
+ export interface LinearGradientPaint extends PaintVisibility {
187
+ readonly kind: "linear-gradient";
188
+ readonly stops: readonly GradientStop[];
189
+ readonly opacity?: number;
190
+ /** Start in fractions of the local paint box. */
191
+ readonly from: PaintAnchor;
192
+ /** End in fractions of the local paint box. */
193
+ readonly to: PaintAnchor;
194
+ }
195
+ /**
196
+ * A point in the painted shape's bounds, as fractions of its width and height.
197
+ * @since 0.6.0
198
+ */
199
+ export interface PaintAnchor {
200
+ readonly x: number;
201
+ readonly y: number;
202
+ }
203
+ /**
204
+ * A gradient that spreads outward from a center point.
205
+ * @since 0.6.0
206
+ */
207
+ export interface RadialGradientPaint extends PaintVisibility {
208
+ readonly kind: "radial-gradient";
209
+ /** Defaults to the center of the bounds. */
210
+ readonly center?: PaintAnchor;
211
+ /** Ellipse radii as fractions of the bounds; defaults to half the width and height. */
212
+ readonly radius?: PaintAnchor;
213
+ readonly stops: readonly GradientStop[];
214
+ readonly opacity?: number;
215
+ }
216
+ /**
217
+ * A gradient that sweeps around a center point.
218
+ * @since 0.6.0
219
+ */
220
+ export interface AngularGradientPaint extends PaintVisibility {
221
+ readonly kind: "angular-gradient";
222
+ /** Defaults to the center of the bounds. */
223
+ readonly center?: PaintAnchor;
224
+ /** Start angle in degrees, clockwise from the positive x axis; defaults to 0. */
225
+ readonly angle?: number;
226
+ readonly stops: readonly GradientStop[];
227
+ readonly opacity?: number;
228
+ }
229
+ /**
230
+ * How an image paint is scaled into the painted shape's bounds.
231
+ * @since 0.6.0
232
+ */
233
+ export type ImagePaintFit = "contain" | "cover" | "fill";
234
+ /**
235
+ * Paints an image asset.
236
+ * @since 0.6.0
237
+ */
238
+ export interface ImagePaint extends PaintVisibility {
239
+ readonly kind: "image";
240
+ readonly assetId: AssetId;
241
+ /** Defaults to cover. */
242
+ readonly fit?: ImagePaintFit;
243
+ readonly opacity?: number;
244
+ }
245
+ export type GradientPaint = LinearGradientPaint | RadialGradientPaint | AngularGradientPaint;
246
+ export type Paint = SolidPaint | GradientPaint | ImagePaint;
247
+ /**
248
+ * Which side of the outline a stroke is drawn on.
249
+ * @since 0.0.1
250
+ */
251
+ export type StrokePosition = "center" | "inside" | "outside";
252
+ /**
253
+ * Stroke weights for the four sides of a rectangle or frame. Unlike Figma,
254
+ * which keeps one set of side weights per node, each stroke in
255
+ * `VisualStyle.strokes` carries its own.
256
+ * @since 0.17.0
257
+ */
258
+ export interface StrokeSides {
259
+ readonly top: number;
260
+ readonly right: number;
261
+ readonly bottom: number;
262
+ readonly left: number;
263
+ }
264
+ export interface Stroke {
265
+ readonly paint: Paint;
266
+ /**
267
+ * The weight of every side. With `sides`, the editor keeps it at the
268
+ * largest side weight.
269
+ */
270
+ readonly width: number;
271
+ readonly dash?: readonly number[];
272
+ /**
273
+ * Defaults to center when omitted by an older operation or document.
274
+ * @since 0.0.1
275
+ */
276
+ readonly position?: StrokePosition;
277
+ /**
278
+ * Separate weights for the top, right, bottom and left sides, replacing
279
+ * `width` on rectangles and frames. Other shapes, connectors and code
280
+ * blocks ignore it. A side of weight 0 paints nothing, and the corners
281
+ * between sides of different weights follow the shape's corners.
282
+ * @since 0.17.0
283
+ */
284
+ readonly sides?: StrokeSides;
285
+ /**
286
+ * How the stroke turns a corner where two segments meet, as Figma's
287
+ * `strokeJoin`. Omitted keeps what the layer drew before 0.22.0: round on
288
+ * paths, ellipses, polygons, stars, lines and connectors, and on
289
+ * rectangles drawn as paths (rounded or with gradient, image or several
290
+ * fills); miter on frames, other rectangles and code blocks. See
291
+ * `defaultStrokeJoin`. Rectangles and frames with side weights ignore it.
292
+ * @since 0.22.0
293
+ */
294
+ readonly join?: StrokeJoin;
295
+ /**
296
+ * The miter angle in degrees, as Figma's "Miter angle" (the REST API's
297
+ * `strokeMiterAngle`): a miter join whose corner is sharper than this is
298
+ * drawn beveled. Only a miter join uses it. It is more than 0 and at most
299
+ * 180; omitted is `DEFAULT_STROKE_MITER_ANGLE`, Figma's default of about
300
+ * 28.96 degrees, which is a miter limit of 4 (limit = 1 / sin(angle / 2)).
301
+ * @since 0.22.0
302
+ */
303
+ readonly miterAngle?: number;
304
+ /**
305
+ * The ends of every dash of a dashed stroke, as Figma's "Dash cap". None
306
+ * stops a dash flat; round and square extend it by half the stroke width.
307
+ * Omitted keeps what the layer drew before 0.22.0: round on the layers
308
+ * whose join defaults to round, none on the others (see `defaultDashCap`).
309
+ * A solid stroke ignores it, except at the open ends of a path that does
310
+ * not use its own end points (see `PathNode.startCap`): those are drawn
311
+ * with the dash ends of a stroke that names its join, miter angle or dash
312
+ * ends, unless the path gives them its own plain end.
313
+ * @since 0.22.0
314
+ */
315
+ readonly dashCap?: DashCap;
316
+ }
317
+ /**
318
+ * The stroke joins, as Figma names them (`MITER`, `BEVEL`, `ROUND`).
319
+ * @since 0.22.0
320
+ */
321
+ export declare const STROKE_JOINS: readonly ["miter", "bevel", "round"];
322
+ /** How a stroke's corners join: sharp (miter), cut off (bevel) or round. */
323
+ export type StrokeJoin = (typeof STROKE_JOINS)[number];
324
+ /**
325
+ * The ends of each dash of a dashed stroke, as in Figma's Dash cap menu.
326
+ * @since 0.22.0
327
+ */
328
+ export declare const DASH_CAPS: readonly ["none", "round", "square"];
329
+ /** How each dash of a dashed stroke ends: flat at the dash (none), round or square. */
330
+ export type DashCap = (typeof DASH_CAPS)[number];
331
+ /**
332
+ * Figma's default miter angle in degrees, 2 * asin(1 / 4): the angle at which
333
+ * a miter limit of 4 bevels.
334
+ * @since 0.22.0
335
+ */
336
+ export declare const DEFAULT_STROKE_MITER_ANGLE: number;
337
+ /**
338
+ * A drop shadow paints behind the node; an inner shadow paints inside it.
339
+ * @since 0.7.0
340
+ */
341
+ export type ShadowKind = "drop" | "inner";
342
+ export interface Shadow {
343
+ /**
344
+ * Defaults to a drop shadow when omitted by an older document.
345
+ * @since 0.7.0
346
+ */
347
+ readonly kind?: ShadowKind;
348
+ readonly x: number;
349
+ readonly y: number;
350
+ readonly blur: number;
351
+ readonly spread: number;
352
+ readonly color: string;
353
+ }
354
+ /**
355
+ * Separate radii for the four corners of a rectangle or frame, as in Figma's
356
+ * `topLeftRadius`, `topRightRadius`, `bottomRightRadius` and
357
+ * `bottomLeftRadius`. Each is a non-negative number of units; the renderer
358
+ * limits each one to half the shorter side, the same limit as a uniform
359
+ * radius, so neighbouring corners never overlap.
360
+ * @since 0.16.0
361
+ */
362
+ export interface CornerRadii {
363
+ readonly topLeft: number;
364
+ readonly topRight: number;
365
+ readonly bottomRight: number;
366
+ readonly bottomLeft: number;
367
+ }
368
+ export interface VisualStyle {
369
+ readonly styleId?: NodeStyleId;
370
+ readonly fills?: readonly Paint[];
371
+ /**
372
+ * Ordered strokes painted after the fills, first entry at the bottom.
373
+ * @since 0.5.0
374
+ */
375
+ readonly strokes?: readonly Stroke[];
376
+ /**
377
+ * One radius for every corner. Rectangles and frames use `cornerRadii`
378
+ * instead when it is present; polygons, stars and paths round every vertex
379
+ * with it.
380
+ */
381
+ readonly cornerRadius?: number;
382
+ /**
383
+ * Independent corner radii for rectangles and frames. When present it
384
+ * replaces `cornerRadius` on those nodes; other shapes ignore it. The editor
385
+ * clears `cornerRadius` when it writes this field, so one of the two
386
+ * describes the corners.
387
+ * @since 0.16.0
388
+ */
389
+ readonly cornerRadii?: CornerRadii;
390
+ /**
391
+ * Corner smoothing from 0 (circular corners) to 1 (fully continuous
392
+ * curvature), as in Figma. It only changes corners that have a radius, and
393
+ * each smoothed corner consumes up to `(1 + smoothing) * radius` of edge.
394
+ *
395
+ * For a rectangle, the renderer first limits the radius $r$ and smoothing
396
+ * $s$ to the budget $B = \tfrac12 \min(w, h)$, then works out how much of
397
+ * each edge the corner uses:
398
+ *
399
+ * $$
400
+ * r' = \min(r, B), \qquad
401
+ * s' = \min\bigl(s, \max(0, B / r' - 1)\bigr), \qquad
402
+ * p = \min\bigl((1 + s')\,r',\ B\bigr)
403
+ * $$
404
+ *
405
+ * Walking into the corner, a cubic curve eases off the edge, a circular arc
406
+ * of radius $r'$ turns through $90(1 - s')$ degrees, and a mirrored cubic
407
+ * eases onto the next edge. With $\beta = 45 s'$ degrees, the arc covers
408
+ * $\ell$ along each edge and the cubic control distances are
409
+ *
410
+ * $$
411
+ * \ell = \sqrt{2}\, r' \sin\!\Bigl(\frac{90(1 - s')}{2}\Bigr), \quad
412
+ * c = r' \tan\!\Bigl(\frac{\beta}{2}\Bigr) \cos\beta, \quad
413
+ * d = c \tan\beta, \quad
414
+ * b = \frac{p - \ell - c - d}{3}, \quad
415
+ * a = 2b
416
+ * $$
417
+ *
418
+ * so $a + b + c + d + \ell = p$. At $s' = 0$ this is a plain quarter circle.
419
+ * @since 0.9.0
420
+ */
421
+ readonly cornerSmoothing?: number;
422
+ readonly shadows?: readonly Shadow[];
423
+ /**
424
+ * Gaussian blur radius applied to the node and its descendants as one layer.
425
+ * @since 0.7.0
426
+ */
427
+ readonly layerBlur?: number;
428
+ /**
429
+ * Gaussian blur radius applied to whatever lies behind the node's shape.
430
+ * @since 0.7.0
431
+ */
432
+ readonly backgroundBlur?: number;
433
+ }
434
+ export interface NodeStyle extends Omit<VisualStyle, "styleId"> {
435
+ readonly name: string;
436
+ }
437
+ export interface TextStyle {
438
+ readonly name: string;
439
+ readonly fontFamily: string;
440
+ /** Original face style name, when present in the source. */
441
+ readonly fontStyle?: string;
442
+ readonly fontAssetId?: AssetId;
443
+ /** Ordered embedded font assets tried after `fontAssetId`. */
444
+ readonly fontFallbackAssetIds?: readonly AssetId[];
445
+ /** Canonically-cased BCP 47 language tag used for shaping and line breaking. */
446
+ readonly language?: string;
447
+ readonly fontSize: number;
448
+ readonly fontWeight: number;
449
+ readonly lineHeight: number;
450
+ readonly letterSpacing?: number;
451
+ readonly color: string;
452
+ readonly italic?: boolean;
453
+ readonly underline?: boolean;
454
+ /**
455
+ * Draws a line through the text.
456
+ * @since 0.2.0
457
+ */
458
+ readonly strikethrough?: boolean;
459
+ /**
460
+ * Explicit deviations from a font's OpenType feature defaults.
461
+ * @since 0.2.0
462
+ */
463
+ readonly openTypeFeatures?: Readonly<Record<string, boolean | number>>;
464
+ /**
465
+ * Explicit variable-font axis coordinates keyed by four-byte OpenType tag.
466
+ * @since 0.2.0
467
+ */
468
+ readonly fontVariations?: Readonly<Record<string, number>>;
469
+ }
470
+ /**
471
+ * Direct text formatting authored on one run or list marker.
472
+ *
473
+ * Font resources need explicit clearing semantics because omitting an override
474
+ * inherits the selected theme style. A `null` primary clears an inherited
475
+ * `fontAssetId`, while an empty fallback list clears inherited fallbacks.
476
+ * @since 0.2.1
477
+ */
478
+ export type TextStyleOverrides = Partial<Omit<TextStyle, "name" | "fontAssetId" | "fontFallbackAssetIds">> & {
479
+ readonly fontAssetId?: AssetId | null;
480
+ readonly fontFallbackAssetIds?: readonly AssetId[];
481
+ };
482
+ /** Provides palette colors and the typography defaults used for new code nodes. */
483
+ export interface CodeStyle {
484
+ readonly name: string;
485
+ readonly fontFamily: string;
486
+ readonly fontAssetId?: AssetId;
487
+ readonly fontSize: number;
488
+ readonly lineHeight: number;
489
+ /**
490
+ * Extra space added between characters.
491
+ * @since 0.1.2
492
+ */
493
+ readonly letterSpacing?: number;
494
+ readonly background: string;
495
+ readonly foreground: string;
496
+ readonly syntax: Readonly<Record<string, string>>;
497
+ }
498
+ export type VariableProperty = "visibility" | "opacity" | "width" | "height" | "cornerRadius" | "fillColor" | "strokeColor" | "strokeWidth" | "gap"
499
+ /** @since 0.15.0 */
500
+ | "wrapGap" | "columnGap" | "rowGap" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "fontFamily" | "fontSize" | "fontWeight" | "lineHeight" | "letterSpacing" | "textColor";
501
+ export type VariableType = "color" | "number" | "string" | "boolean";
502
+ export type VariableValue = string | number | boolean;
503
+ interface VariableDefinitionBase<Type extends VariableType, Value extends VariableValue> {
504
+ readonly name: string;
505
+ readonly type: Type;
506
+ readonly values: Readonly<Record<string, Value>>;
507
+ /** Omitting scopes makes the variable available to every compatible property. */
508
+ readonly scopes?: readonly VariableProperty[];
509
+ }
510
+ export type VariableDefinition = VariableDefinitionBase<"color", string> | VariableDefinitionBase<"number", number> | VariableDefinitionBase<"string", string> | VariableDefinitionBase<"boolean", boolean>;
511
+ export interface VariableMode {
512
+ readonly name: string;
513
+ }
514
+ export interface VariableCollection {
515
+ readonly name: string;
516
+ readonly defaultModeId: VariableModeId;
517
+ /**
518
+ * The mode this document shows where no page or layer chooses one (see
519
+ * `VariableModes`). It defaults to `defaultModeId` when omitted.
520
+ */
521
+ readonly activeModeId?: VariableModeId;
522
+ readonly modeOrder: readonly VariableModeId[];
523
+ readonly modes: Readonly<Record<string, VariableMode>>;
524
+ readonly variables: Readonly<Record<string, VariableDefinition>>;
525
+ }
526
+ export type VariableBindings = Readonly<Partial<Record<VariableProperty, VariableId>>>;
527
+ /** The variable properties a group can bind: all but its size. */
528
+ export type GroupVariableProperty = Exclude<VariableProperty, "width" | "height">;
529
+ /**
530
+ * A group's variable bindings. A group's size is always computed from its
531
+ * layers, so a group never binds `width` or `height`.
532
+ */
533
+ export type GroupVariableBindings = Readonly<Partial<Record<GroupVariableProperty, VariableId>> & {
534
+ readonly width?: never;
535
+ readonly height?: never;
536
+ }>;
537
+ /**
538
+ * A variable mode per collection, keyed by collection ID. A collection left
539
+ * out is Auto: the layer takes the mode of its parent, up to the page, and a
540
+ * page without one uses the collection's `activeModeId` (else its
541
+ * `defaultModeId`). Omitted when empty.
542
+ * @since 0.26.0
543
+ */
544
+ export type VariableModes = Readonly<Record<string, VariableModeId>>;
545
+ /**
546
+ * The document's shared styles, named colors and variables. Nodes refer to
547
+ * them by ID and may keep direct overrides on top.
548
+ */
549
+ export interface DocumentTheme {
550
+ /** The text style used by runs that name none. */
551
+ readonly defaultTextStyleId: TextStyleId;
552
+ /** The code style used by code nodes that name none. */
553
+ readonly defaultCodeStyleId: CodeStyleId;
554
+ /** Named colors, keyed by name. */
555
+ readonly colors: Readonly<Record<string, string>>;
556
+ readonly nodeStyles: Readonly<Record<string, NodeStyle>>;
557
+ readonly textStyles: Readonly<Record<string, TextStyle>>;
558
+ readonly codeStyles: Readonly<Record<string, CodeStyle>>;
559
+ /** Variable collections stored in this document. Libraries shared between documents are intentionally out of scope. */
560
+ readonly variableCollections?: Readonly<Record<string, VariableCollection>>;
561
+ }
562
+ export interface AbsoluteLayout {
563
+ readonly kind: "absolute";
564
+ }
565
+ export interface LayoutPadding {
566
+ readonly top: number;
567
+ readonly right: number;
568
+ readonly bottom: number;
569
+ readonly left: number;
570
+ }
571
+ /**
572
+ * How an auto layout frame sizes itself on one axis: keep its stored size, or
573
+ * hug its content. Filling the parent is set on the child instead, with
574
+ * `FramedNodeBase.resizing`.
575
+ */
576
+ export type LayoutSizing = "fixed" | "hug";
577
+ /**
578
+ * The frame's own sizing. Size limits moved to `FramedNodeBase.resizing` in
579
+ * 0.15.0.
580
+ */
581
+ export interface AutoLayoutConstraints {
582
+ /**
583
+ * `"hug"` sizes the frame to its content on this axis. In a stack, a child
584
+ * that fills the same axis makes the frame keep its stored size instead,
585
+ * as Figma stops hugging in that case. A grid keeps hugging: its Fill
586
+ * children take their cell, whose size comes from the other children.
587
+ */
588
+ readonly widthSizing: LayoutSizing;
589
+ readonly heightSizing: LayoutSizing;
590
+ }
591
+ /**
592
+ * A row (`"horizontal"`) or column (`"vertical"`) auto layout. The main axis
593
+ * runs along the stack; the cross axis runs across it.
594
+ */
595
+ export interface StackAutoLayout extends AutoLayoutConstraints {
596
+ readonly kind: "vertical" | "horizontal";
597
+ /** Space between children on the main axis. */
598
+ readonly gap: number;
599
+ readonly padding: LayoutPadding;
600
+ /**
601
+ * Where children sit on the cross axis within their line. A child stretches
602
+ * across the line with a cross-axis Fill in `FramedNodeBase.resizing`.
603
+ * Schema 0.15.0 removed the frame-wide `"stretch"`.
604
+ */
605
+ readonly align: "start" | "center" | "end";
606
+ /**
607
+ * How children are spread on the main axis within each line. The `space-*`
608
+ * values replace `gap` with an automatic gap that is never negative:
609
+ * `space-between` puts all free space between children (a single child sits
610
+ * at the start), `space-around` puts half a gap before the first and after
611
+ * the last child, and `space-evenly` puts a whole gap there (both centre a
612
+ * single child). When children overflow, all three pack from the start.
613
+ * Schema 0.15.0 added `"space-around"` and `"space-evenly"`.
614
+ */
615
+ readonly justify: "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly";
616
+ /**
617
+ * Moves children that do not fit onto new lines: rows for a horizontal
618
+ * stack, columns for a vertical one. Omitted means a single line.
619
+ * @since 0.15.0
620
+ */
621
+ readonly wrap?: boolean;
622
+ /**
623
+ * Space between wrapped lines. Omitted means the same as `gap`. Kept, but
624
+ * unused, while `wrap` is off.
625
+ * @since 0.15.0
626
+ */
627
+ readonly wrapGap?: number;
628
+ /**
629
+ * How wrapped lines share the cross axis. `"auto"` (the default) packs the
630
+ * lines by `align`, or shares the free space equally between lines when
631
+ * every child fills the cross axis; `"space-between"` spreads the lines
632
+ * with an automatic gap that is never negative. Kept, but unused, while
633
+ * `wrap` is off.
634
+ * @since 0.15.0
635
+ */
636
+ readonly alignContent?: "auto" | "space-between";
637
+ }
638
+ export interface GridAutoLayout extends AutoLayoutConstraints {
639
+ readonly kind: "grid";
640
+ readonly columns: number;
641
+ readonly columnGap: number;
642
+ readonly rowGap: number;
643
+ readonly padding: LayoutPadding;
644
+ }
645
+ export type AutoLayout = StackAutoLayout | GridAutoLayout;
646
+ export type Layout = AbsoluteLayout | AutoLayout;
647
+ /**
648
+ * Separable and non-separable compositing modes, in CSS `mix-blend-mode` terms.
649
+ * @since 0.8.0
650
+ */
651
+ export declare const BLEND_MODES: readonly ["normal", "darken", "multiply", "color-burn", "lighten", "screen", "color-dodge", "overlay", "soft-light", "hard-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"];
652
+ export type BlendMode = (typeof BLEND_MODES)[number];
653
+ /**
654
+ * File formats a layer can export to.
655
+ * @since 0.14.0
656
+ */
657
+ export declare const EXPORT_FORMATS: readonly ["png", "jpeg", "svg", "pdf"];
658
+ export type ExportFormat = (typeof EXPORT_FORMATS)[number];
659
+ /**
660
+ * The output size of a raster export: a multiplier of the layer's size, or a
661
+ * fixed pixel width or height with the other side kept in proportion.
662
+ * @since 0.14.0
663
+ */
664
+ export type ExportConstraint = {
665
+ readonly type: "scale";
666
+ readonly value: number;
667
+ } | {
668
+ readonly type: "width";
669
+ readonly value: number;
670
+ } | {
671
+ readonly type: "height";
672
+ readonly value: number;
673
+ };
674
+ /**
675
+ * JPEG compression level, or the raster resolution of PDF effects.
676
+ * @since 0.14.0
677
+ */
678
+ export declare const EXPORT_QUALITIES: readonly ["low", "medium", "high"];
679
+ export type ExportQuality = (typeof EXPORT_QUALITIES)[number];
680
+ /**
681
+ * "detailed" samples images bicubically; "basic" uses the nearest pixel.
682
+ * @since 0.14.0
683
+ */
684
+ export declare const EXPORT_RESAMPLINGS: readonly ["detailed", "basic"];
685
+ export type ExportResampling = (typeof EXPORT_RESAMPLINGS)[number];
686
+ /**
687
+ * One row of a layer's Export section. Every field is always stored so a row
688
+ * keeps its values when its format changes; a field that does not apply to
689
+ * the current format is ignored when exporting.
690
+ * @since 0.14.0
691
+ */
692
+ export interface ExportSetting {
693
+ readonly format: ExportFormat;
694
+ /** PNG and JPEG only; SVG and PDF always export at 1x. */
695
+ readonly constraint: ExportConstraint;
696
+ /** Added to the file name after the layer name; may be empty. */
697
+ readonly suffix: string;
698
+ /** JPEG and PDF only. */
699
+ readonly quality: ExportQuality;
700
+ /** PNG, JPEG and PDF only. */
701
+ readonly resampling: ExportResampling;
702
+ /**
703
+ * PNG, JPEG and SVG only. When `true` only the layer and its children are
704
+ * drawn; when `false` every visible layer inside the layer's bounds is drawn.
705
+ */
706
+ readonly ignoreOverlappingLayers: boolean;
707
+ /** SVG only: gives drawn elements "id" attributes made from layer names. */
708
+ readonly includeIdAttribute: boolean;
709
+ }
710
+ /** Fields every `SceneNode` has. */
711
+ export interface NodeBase {
712
+ /** Matches the node's key in `DesignDocument.nodes`. */
713
+ readonly id: NodeId;
714
+ /** The layer name. Must not be empty. */
715
+ readonly name: string;
716
+ readonly visible: boolean;
717
+ /** Protects the node from edits on the editor canvas. */
718
+ readonly locked: boolean;
719
+ /** From 0 (transparent) to 1 (opaque). */
720
+ readonly opacity: number;
721
+ /**
722
+ * How the node composites onto what lies behind it; normal when omitted.
723
+ * @since 0.8.0
724
+ */
725
+ readonly blendMode?: BlendMode;
726
+ /**
727
+ * A mask hides its later siblings outside its own painted alpha and paints
728
+ * nothing itself. A hidden mask masks nothing.
729
+ * @since 0.8.0
730
+ */
731
+ readonly mask?: boolean;
732
+ /**
733
+ * Keeps width and height proportional when the node is resized.
734
+ * @since 0.1.1
735
+ */
736
+ readonly aspectRatioLocked?: boolean;
737
+ /**
738
+ * The locked aspect ratio, width over height, that auto layout keeps when
739
+ * the node stretches across a row or column. Read only while
740
+ * `aspectRatioLocked` is true; without it, auto layout keeps the node's
741
+ * stored size.
742
+ * @since 0.39.0
743
+ */
744
+ readonly aspectRatio?: number;
745
+ /** Properties whose values come from theme variables. */
746
+ readonly variableBindings?: VariableBindings;
747
+ /**
748
+ * The node's Export section rows, in order. Omitted when empty.
749
+ * @since 0.14.0
750
+ */
751
+ readonly exportSettings?: readonly ExportSetting[];
752
+ /**
753
+ * Computed fields: expression source text keyed by field, for nodes under a
754
+ * component root only (see `ComputableField` and `computableFieldsOf`). The
755
+ * plain field keeps the base value, which the expression reads as
756
+ * `stored` and which is shown when the expression does not check. A field
757
+ * holds a variable binding or an expression, never both. Omitted when
758
+ * empty.
759
+ * @since 0.24.0
760
+ */
761
+ readonly expressions?: NodeExpressions;
762
+ /**
763
+ * A boolean expression; when it is false the layer and its sublayers are
764
+ * left out of every instance. Only on layers under a component root, never
765
+ * on the root itself. An expression that does not check counts as no
766
+ * condition.
767
+ * @since 0.24.0
768
+ */
769
+ readonly condition?: string;
770
+ /**
771
+ * How the layer follows its frame when the frame is resized (see
772
+ * `ResizeConstraints`). Omitted means Left and Top: the layer keeps its
773
+ * position and size. Used for children of frames without auto layout and
774
+ * for absolute children of auto layout frames; ignored elsewhere. Never on
775
+ * a group: constraints set on a group are set on its layers, as in Figma.
776
+ * @since 0.25.0
777
+ */
778
+ readonly constraints?: ResizeConstraints;
779
+ /**
780
+ * `"absolute"` takes a child of an auto layout frame out of the flow, like
781
+ * Figma's "Ignore auto layout": the layout neither moves it nor counts it
782
+ * when hugging, and it follows the frame's size changes by its
783
+ * `constraints`. Ignored when the parent has no auto layout.
784
+ * @since 0.25.0
785
+ */
786
+ readonly layoutPositioning?: "absolute";
787
+ /**
788
+ * The mode this layer and its sublayers use for each variable collection
789
+ * (see `VariableModes`). A collection left out is Auto: the layer inherits
790
+ * the mode from its parent. On an instance, the modes apply to the
791
+ * component's layers, so two instances of one component can show two modes.
792
+ * @since 0.26.0
793
+ */
794
+ readonly variableModes?: VariableModes;
795
+ /**
796
+ * The ID of the library layer this layer was copied from, in the library
797
+ * document, set when layers are inserted from a library. A copy of the
798
+ * layer (duplicate, copy and paste) keeps it, so it still names that
799
+ * library layer. Updating library components matches a layer to the newer
800
+ * library's layer with this ID first. Not checked against this document's
801
+ * layers.
802
+ * @since 0.42.0
803
+ */
804
+ readonly libraryLayerId?: string;
805
+ /** Free-form JSON data kept with the node. The model does not read it. */
806
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
807
+ }
808
+ /**
809
+ * How a layer's horizontal position and width follow its frame's width.
810
+ * `"left"`, `"right"` and `"center"` keep the width and the distance to the
811
+ * left edge, the right edge or the center line; `"left-right"` keeps both
812
+ * distances, so the width changes with the frame; `"scale"` keeps the layer's
813
+ * position and width as shares of the frame's width.
814
+ * @since 0.25.0
815
+ */
816
+ export type HorizontalConstraint = "left" | "right" | "left-right" | "center" | "scale";
817
+ /**
818
+ * How a layer's vertical position and height follow its frame's height; the
819
+ * vertical counterpart of `HorizontalConstraint`.
820
+ * @since 0.25.0
821
+ */
822
+ export type VerticalConstraint = "top" | "bottom" | "top-bottom" | "center" | "scale";
823
+ /**
824
+ * A layer's resize constraints, Figma's five options on each axis. They act
825
+ * on the layer's axis-aligned bounds in its frame (see `constrainChildren`).
826
+ * @since 0.25.0
827
+ */
828
+ export interface ResizeConstraints {
829
+ readonly horizontal: HorizontalConstraint;
830
+ readonly vertical: VerticalConstraint;
831
+ }
832
+ /**
833
+ * Fields of every node placed by a rectangle: all kinds except `PathNode`,
834
+ * which uses a transform matrix instead.
835
+ */
836
+ export interface FramedNodeBase extends NodeBase {
837
+ /**
838
+ * Position and unrotated size, in the parent's coordinate system (relative
839
+ * to the parent's frame's top-left corner).
840
+ */
841
+ readonly frame: Rect;
842
+ /** Degrees, clockwise on screen, about the frame's center. */
843
+ readonly rotation: number;
844
+ /** Mirrors the rendered node around its local horizontal center. */
845
+ readonly flipX?: boolean;
846
+ /**
847
+ * Mirrors the rendered node around its local vertical center.
848
+ *
849
+ * Together, `frame`, `rotation` and the flips place a local point
850
+ * $\mathbf{p}$ (origin at the frame's top-left corner) in the parent as
851
+ *
852
+ * $$
853
+ * \mathbf{p}_\text{parent} = \begin{bmatrix} x + w/2 \\ y + h/2 \end{bmatrix}
854
+ * + R_\theta F \left(\mathbf{p} - \begin{bmatrix} w/2 \\ h/2 \end{bmatrix}\right),
855
+ * \quad
856
+ * R_\theta = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix},
857
+ * \quad
858
+ * F = \begin{bmatrix} \pm 1 & 0 \\ 0 & \pm 1 \end{bmatrix}
859
+ * $$
860
+ *
861
+ * where $\theta$ is `rotation` in radians and $F$ has $-1$ on the axis of
862
+ * each flip that is set. The flip happens first, then the rotation.
863
+ */
864
+ readonly flipY?: boolean;
865
+ /**
866
+ * Fill sizing and size limits. Omitted when empty.
867
+ * @since 0.15.0
868
+ */
869
+ readonly resizing?: NodeResizing;
870
+ }
871
+ /**
872
+ * How auto layout may size a node beyond its stored frame.
873
+ *
874
+ * `width` or `height` set to `"fill"` makes a child of a stack or grid auto
875
+ * layout take the space its parent gives it on that axis: the Fill children
876
+ * of one line share the line's free main-axis space equally, a cross-axis
877
+ * Fill takes the line's cross size, and a grid child fills its cell. The flag
878
+ * has no effect outside an auto layout, on rotated nodes, on groups and on
879
+ * connectors. A node cannot fill an axis on which it hugs its own content
880
+ * (an auto layout frame's `"hug"` sizing, or a text or code node's
881
+ * `autoResize`).
882
+ *
883
+ * The limits bound the size auto layout gives the node: a Fill child's
884
+ * share, and an auto layout frame's own Hug or Fixed size.
885
+ * @since 0.15.0
886
+ */
887
+ export interface NodeResizing {
888
+ readonly width?: "fill";
889
+ readonly height?: "fill";
890
+ readonly minWidth?: number;
891
+ readonly maxWidth?: number;
892
+ readonly minHeight?: number;
893
+ readonly maxHeight?: number;
894
+ }
895
+ /**
896
+ * A ruler guide: an editor-only straight line used to position objects. The
897
+ * renderer never paints it, so it never appears in exports.
898
+ * @since 0.11.0
899
+ */
900
+ export interface Guide {
901
+ /** "x" is a vertical line at x = offset; "y" is a horizontal line at y = offset. */
902
+ readonly axis: "x" | "y";
903
+ /**
904
+ * Position along the axis in document units, relative to whatever holds the
905
+ * guide: the page origin for a page guide, or the frame's top-left corner
906
+ * for a frame guide.
907
+ */
908
+ readonly offset: number;
909
+ }
910
+ /**
911
+ * A container with its own size, fills, strokes and effects, and optionally
912
+ * an auto layout. Each page's root is a frame or group; a page root never
913
+ * clips.
914
+ */
915
+ export interface FrameNode extends FramedNodeBase {
916
+ /** The size children are authored against, when it differs per computed variant. Defaults to the stored frame size. */
917
+ readonly constraintSize?: {
918
+ readonly width: number;
919
+ readonly height: number;
920
+ };
921
+ readonly type: "frame";
922
+ /** Child node IDs in paint order: the first child is at the back. */
923
+ readonly children: readonly NodeId[];
924
+ /** How children are positioned: freely, or by a stack or grid auto layout. */
925
+ readonly layout: Layout;
926
+ readonly style?: VisualStyle;
927
+ /** Hides the parts of children that fall outside the frame. */
928
+ readonly clipContent?: boolean;
929
+ /**
930
+ * Ruler guides that belong to this frame and move with it. The editor shows
931
+ * them only on top-level frames that are neither rotated nor flipped.
932
+ * Omitted when empty.
933
+ * @since 0.11.0
934
+ */
935
+ readonly guides?: readonly Guide[];
936
+ /**
937
+ * Makes this frame a slot frame: the place where instances show their
938
+ * content for the component's slot property with this ID. Valid only on a
939
+ * frame inside a component that is not the component's root, not on a
940
+ * grid frame, and not inside another slot frame's default content in the
941
+ * same component. A binding to a property that is missing or not a slot is
942
+ * ignored. Several frames (one per variant branch) may bind the same slot.
943
+ * @since 0.37.0
944
+ */
945
+ readonly slot?: ComponentPropertyId;
946
+ /**
947
+ * Marks a slot host: the stored frame that holds one instance's content
948
+ * for one slot, listed in that instance's `slots`. Its `children` are the
949
+ * content. The host itself is not drawn; its `frame`, rotation, flips and
950
+ * `layout` are written by the component cascade only, to follow the slot
951
+ * frame. Its only parent is the instance that lists it.
952
+ * @since 0.37.0
953
+ */
954
+ readonly slotHost?: true;
955
+ }
956
+ /**
957
+ * A container with no size of its own: its frame is always fitted to the
958
+ * union of its children's bounds (see `fitGroupToChildren`). A group whose
959
+ * last child is removed by `applyOperations` is removed too.
960
+ */
961
+ export interface GroupNode extends FramedNodeBase {
962
+ readonly type: "group";
963
+ /**
964
+ * Properties whose values come from theme variables. A group's size is
965
+ * computed from its layers, so it cannot bind `width` or `height`.
966
+ */
967
+ readonly variableBindings?: GroupVariableBindings;
968
+ /** Child node IDs in paint order: the first child is at the back. */
969
+ readonly children: readonly NodeId[];
970
+ readonly clipContent?: boolean;
971
+ }
972
+ /** A span of text sharing one style. */
973
+ export interface TextRun {
974
+ readonly text: string;
975
+ /** A web address or a target GUID to resolve when adapting a Figma document. */
976
+ readonly hyperlink?: {
977
+ readonly kind: "url";
978
+ readonly url: string;
979
+ } | {
980
+ readonly kind: "target";
981
+ readonly guid: string;
982
+ };
983
+ /** The theme text style; the theme's `defaultTextStyleId` when omitted. */
984
+ readonly styleId?: TextStyleId;
985
+ /** Direct formatting on top of the style. */
986
+ readonly overrides?: TextStyleOverrides;
987
+ }
988
+ /** The bullet or number shown before a list paragraph, and how it is styled. */
989
+ export interface TextListMarker {
990
+ /** Custom marker text; must not be empty when given. */
991
+ readonly text?: string;
992
+ readonly styleId?: TextStyleId;
993
+ readonly overrides?: TextStyleOverrides;
994
+ /** Space between the marker and the paragraph text. Non-negative. */
995
+ readonly gap?: number;
996
+ }
997
+ /** One paragraph of a `TextNode`: its runs plus paragraph-level layout. */
998
+ export interface TextParagraph {
999
+ readonly runs: readonly TextRun[];
1000
+ /** Auto resolves direction from paragraph content when omitted or set explicitly. */
1001
+ readonly direction?: "auto" | "ltr" | "rtl";
1002
+ readonly align?: "left" | "center" | "right" | "justify";
1003
+ readonly spacingBefore?: number;
1004
+ readonly spacingAfter?: number;
1005
+ readonly indent?: {
1006
+ readonly left: number;
1007
+ readonly right: number;
1008
+ readonly firstLine: number;
1009
+ };
1010
+ /** Makes the paragraph a list item. */
1011
+ readonly list?: {
1012
+ readonly kind: "ordered" | "unordered";
1013
+ /** Nesting depth, a non-negative whole number. */
1014
+ readonly level: number;
1015
+ /** First number of an ordered list, 1 or more. Not allowed on unordered lists. */
1016
+ readonly start?: number;
1017
+ readonly marker?: TextListMarker;
1018
+ };
1019
+ }
1020
+ /** A text box made of styled paragraphs. */
1021
+ export interface TextNode extends FramedNodeBase {
1022
+ readonly type: "text";
1023
+ readonly paragraphs: readonly TextParagraph[];
1024
+ /** Where the text sits in the frame when the frame is taller than the text. */
1025
+ readonly verticalAlign: "top" | "middle" | "bottom";
1026
+ /** Whether text that does not fit the frame is cut off or still drawn. */
1027
+ readonly overflow: "clip" | "visible";
1028
+ /**
1029
+ * `none` keeps both frame dimensions fixed, `height` keeps the width and
1030
+ * lets the height follow the text, and `width-and-height` lets both follow.
1031
+ */
1032
+ readonly autoResize: "none" | "height" | "width-and-height";
1033
+ /** Where long lines may break: never, between words, or between any characters. */
1034
+ readonly wrap: "none" | "word" | "character";
1035
+ /**
1036
+ * The space between paragraphs: the space above every paragraph but the
1037
+ * first that has no `spacingBefore` of its own. Non-negative; 0 when left
1038
+ * out. A paragraph added later, such as by typing a line break, gets it too.
1039
+ * @since 0.40.0
1040
+ */
1041
+ readonly paragraphSpacing?: number;
1042
+ /** The most lines drawn, a positive integer; every line when left out. */
1043
+ readonly maxLines?: number;
1044
+ /** `ellipsis` ends the last drawn line with an ellipsis when `maxLines` hides lines. */
1045
+ readonly truncate?: "ellipsis";
1046
+ }
1047
+ /** Nodes that hold editable rich text. Currently only `TextNode`. */
1048
+ export type TextualNode = TextNode;
1049
+ /** A marked range of a `CodeNode`'s source. */
1050
+ export interface CodeDecoration {
1051
+ /** Start offset into `source`, in UTF-16 code units. */
1052
+ readonly from: number;
1053
+ /** End offset (exclusive), from `from` up to the source length. */
1054
+ readonly to: number;
1055
+ readonly kind: "emphasis" | "addition" | "deletion" | "annotation";
1056
+ readonly label?: string;
1057
+ }
1058
+ /**
1059
+ * A block of source code. Syntax highlighting is worked out when rendering;
1060
+ * only the raw source is stored.
1061
+ */
1062
+ export interface CodeNode extends FramedNodeBase {
1063
+ readonly type: "code";
1064
+ readonly source: string;
1065
+ /** The language identifier used for highlighting. Must not be empty. */
1066
+ readonly language: string;
1067
+ /** Applied uniformly to the full source rather than to individual text runs. */
1068
+ readonly fontFamily: string;
1069
+ /** Applied uniformly to the full source rather than to individual text runs. Positive. */
1070
+ readonly fontSize: number;
1071
+ /** The theme code style; the theme's `defaultCodeStyleId` when omitted. */
1072
+ readonly codeStyleId?: CodeStyleId;
1073
+ /** Values that replace the code style's for this node only. */
1074
+ readonly codeStyleOverrides?: Partial<Pick<CodeStyle, "lineHeight" | "letterSpacing" | "background" | "foreground" | "syntax">>;
1075
+ /** False hides line numbers, `true` starts at one, and a number sets the first line. */
1076
+ readonly lineNumbers: boolean | number;
1077
+ /**
1078
+ * Same meaning as `TextNode.autoResize`.
1079
+ * @since 0.1.3
1080
+ */
1081
+ readonly autoResize: "none" | "height" | "width-and-height";
1082
+ /** Wraps long source lines to the frame width. */
1083
+ readonly wordWrap: boolean;
1084
+ /**
1085
+ * A stroke drawn around the code block.
1086
+ * @since 0.1.4
1087
+ */
1088
+ readonly stroke?: Stroke;
1089
+ readonly decorations: readonly CodeDecoration[];
1090
+ }
1091
+ /** A rectangle filling its frame; `VisualStyle.cornerRadius` rounds it. */
1092
+ export interface RectangleNode extends FramedNodeBase {
1093
+ readonly type: "shape";
1094
+ readonly shape: "rectangle";
1095
+ readonly style: VisualStyle;
1096
+ }
1097
+ /**
1098
+ * Turns an ellipse into an arc, pie or ring, as Figma's arc data does. Angles
1099
+ * are degrees measured clockwise from the positive x axis on the ellipse's
1100
+ * parametric angle. The sweep runs from the starting to the ending angle and
1101
+ * is at most one full turn in either direction.
1102
+ * @since 0.12.0
1103
+ */
1104
+ export interface EllipseArc {
1105
+ readonly startingAngle: number;
1106
+ readonly endingAngle: number;
1107
+ /** Inner radius as a fraction of the outer radius, from 0 (a pie) to below 1 (a ring). */
1108
+ readonly innerRadius: number;
1109
+ }
1110
+ /** An ellipse filling its frame, or an arc, pie or ring of one. */
1111
+ export interface EllipseNode extends FramedNodeBase {
1112
+ readonly type: "shape";
1113
+ readonly shape: "ellipse";
1114
+ readonly style: VisualStyle;
1115
+ /**
1116
+ * Omitted draws the whole ellipse.
1117
+ * @since 0.12.0
1118
+ */
1119
+ readonly arc?: EllipseArc;
1120
+ }
1121
+ /**
1122
+ * Figma's polygon and star point counts.
1123
+ * @since 0.12.0
1124
+ */
1125
+ export declare const MIN_SHAPE_POINT_COUNT = 3;
1126
+ export declare const MAX_SHAPE_POINT_COUNT = 60;
1127
+ /**
1128
+ * A regular polygon whose points are scaled to fill the frame, first point at
1129
+ * the top center, as Figma draws it.
1130
+ * @since 0.12.0
1131
+ */
1132
+ export interface PolygonNode extends FramedNodeBase {
1133
+ readonly type: "shape";
1134
+ readonly shape: "polygon";
1135
+ /** Whole number of corners from 3 to 60. */
1136
+ readonly pointCount: number;
1137
+ readonly style: VisualStyle;
1138
+ }
1139
+ /**
1140
+ * A star whose outer and inner points are scaled to fill the frame.
1141
+ * @since 0.12.0
1142
+ */
1143
+ export interface StarNode extends FramedNodeBase {
1144
+ readonly type: "shape";
1145
+ readonly shape: "star";
1146
+ /** Whole number of outer points from 3 to 60. */
1147
+ readonly pointCount: number;
1148
+ /** Inner point distance as a fraction of the outer radius, from 0 to 1. */
1149
+ readonly innerRadius: number;
1150
+ readonly style: VisualStyle;
1151
+ }
1152
+ /**
1153
+ * Stroke end caps as Figma names them. None ends the stroke flat at the
1154
+ * endpoint; round and square extend it by half the stroke width; the arrow
1155
+ * caps draw a head in the stroke's paint whose size follows the stroke width.
1156
+ * Lines and connectors share these end styles and draw them the same way.
1157
+ * Heads are always solid, even on a dashed stroke.
1158
+ * @since 0.12.0
1159
+ */
1160
+ export declare const STROKE_CAPS: readonly ["none", "round", "square", "line-arrow", "triangle-arrow", "reversed-triangle", "circle-arrow", "diamond-arrow"];
1161
+ export type StrokeCap = (typeof STROKE_CAPS)[number];
1162
+ /**
1163
+ * A single straight stroke. Like Figma, the frame has zero height: the line
1164
+ * runs from the frame's local (0, 0) to (width, 0), and rotation turns it
1165
+ * about the frame center. An arrow is a line with an arrow cap.
1166
+ * @since 0.12.0
1167
+ */
1168
+ export interface LineNode extends FramedNodeBase {
1169
+ readonly type: "shape";
1170
+ readonly shape: "line";
1171
+ readonly style: VisualStyle;
1172
+ readonly startCap: StrokeCap;
1173
+ readonly endCap: StrokeCap;
1174
+ }
1175
+ /**
1176
+ * A point in a `VectorNetwork`, in network coordinates.
1177
+ * @since 0.2.0
1178
+ */
1179
+ export interface VectorVertex {
1180
+ readonly id: VectorVertexId;
1181
+ readonly x: number;
1182
+ readonly y: number;
1183
+ /**
1184
+ * Corner radius at this vertex, overriding the node style's corner radius.
1185
+ * Only a vertex joining exactly two segments rounds; the renderer clamps the
1186
+ * radius to half of the shorter adjacent segment.
1187
+ * @since 0.10.0
1188
+ */
1189
+ readonly cornerRadius?: number;
1190
+ }
1191
+ export interface VectorHandle {
1192
+ readonly id: VectorHandleId;
1193
+ /** Horizontal control-point offset relative to the segment endpoint. */
1194
+ readonly dx: number;
1195
+ /** Vertical control-point offset relative to the segment endpoint. */
1196
+ readonly dy: number;
1197
+ }
1198
+ /**
1199
+ * Couples two endpoint handles that meet at one vertex. Pairwise constraints
1200
+ * let branched networks describe independent smooth continuations without
1201
+ * assigning one ambiguous smoothing mode to the whole vertex.
1202
+ */
1203
+ export interface VectorTangentConstraint {
1204
+ readonly vertexId: VectorVertexId;
1205
+ readonly handleIds: readonly [VectorHandleId, VectorHandleId];
1206
+ /** Keep only the angle mirrored, or mirror both angle and handle length. */
1207
+ readonly mode: "angle" | "angle-and-length";
1208
+ }
1209
+ interface VectorSegmentBase {
1210
+ readonly id: VectorSegmentId;
1211
+ readonly start: VectorVertexId;
1212
+ readonly end: VectorVertexId;
1213
+ }
1214
+ export interface VectorLineSegment extends VectorSegmentBase {
1215
+ readonly kind: "line";
1216
+ }
1217
+ export interface VectorCubicSegment extends VectorSegmentBase {
1218
+ readonly kind: "cubic";
1219
+ readonly startHandle: VectorHandle;
1220
+ readonly endHandle: VectorHandle;
1221
+ }
1222
+ /**
1223
+ * Compatibility geometry for exact migration and SVG interchange. The editor
1224
+ * initially creates and directly edits line and cubic segments only.
1225
+ */
1226
+ export interface VectorEllipticalArcSegment extends VectorSegmentBase {
1227
+ readonly kind: "elliptical-arc";
1228
+ readonly radiusX: number;
1229
+ readonly radiusY: number;
1230
+ readonly xAxisRotation: number;
1231
+ readonly largeArc: boolean;
1232
+ readonly sweep: boolean;
1233
+ }
1234
+ /**
1235
+ * An edge between two vertices of a `VectorNetwork`.
1236
+ * @since 0.2.0
1237
+ */
1238
+ export type VectorSegment = VectorLineSegment | VectorCubicSegment | VectorEllipticalArcSegment;
1239
+ export interface VectorSegmentReference {
1240
+ readonly segmentId: VectorSegmentId;
1241
+ readonly direction: "forward" | "reverse";
1242
+ }
1243
+ export interface VectorRegionLoop {
1244
+ readonly segments: readonly VectorSegmentReference[];
1245
+ /**
1246
+ * Closes an open chain for filling without adding or stroking another edge,
1247
+ * matching SVG's implicit fill closure for open subpaths.
1248
+ */
1249
+ readonly implicitClose?: true;
1250
+ }
1251
+ /**
1252
+ * A filled area of a `VectorNetwork`, bounded by loops of segments.
1253
+ * @since 0.2.0
1254
+ */
1255
+ export interface VectorRegion {
1256
+ readonly id: VectorRegionId;
1257
+ readonly windingRule: "nonzero" | "evenodd";
1258
+ readonly loops: readonly VectorRegionLoop[];
1259
+ /** Omitted inherits the path's resolved fills; an empty array disables fill. */
1260
+ readonly fills?: readonly Paint[];
1261
+ }
1262
+ /**
1263
+ * The vertices, segments and filled regions that make up a path's shape.
1264
+ * @since 0.2.0
1265
+ */
1266
+ export interface VectorNetwork {
1267
+ readonly vertices: readonly VectorVertex[];
1268
+ readonly segments: readonly VectorSegment[];
1269
+ /** Omitted is equivalent to an empty constraint list. */
1270
+ readonly constraints?: readonly VectorTangentConstraint[];
1271
+ /** Ordered from back to front for painting. */
1272
+ readonly regions: readonly VectorRegion[];
1273
+ }
1274
+ /**
1275
+ * An editable vector shape. Unlike the other shapes it has no frame or
1276
+ * rotation: `transform` places the network in the parent, and its bounds are
1277
+ * derived from the transformed network (see `getNodeBounds`).
1278
+ */
1279
+ export interface PathNode extends NodeBase {
1280
+ readonly type: "shape";
1281
+ readonly shape: "path";
1282
+ /**
1283
+ * The path's geometry.
1284
+ * @since 0.2.0
1285
+ */
1286
+ readonly vectorNetwork: VectorNetwork;
1287
+ /** Maps network coordinates into the parent's coordinate system. */
1288
+ readonly transform: TransformMatrix;
1289
+ readonly style: VisualStyle;
1290
+ /**
1291
+ * The end points of an open path whose segments form one chain, each in
1292
+ * order from the end of the one before (see `openPathChainEnds`): the start
1293
+ * cap sits on the first segment's start and the end cap on the last
1294
+ * segment's end, the same styles a line has. Omitted is round, which every
1295
+ * path drew before 0.22.0. A path with an inside or outside stroke ignores
1296
+ * them, and so does a closed path. A path with branches or several chains
1297
+ * draws them only when both name the same plain end (`none`, `round` or
1298
+ * `square`): every open end of its centered strokes without dashes then
1299
+ * draws it, and its inside and outside strokes ignore it.
1300
+ * @since 0.22.0
1301
+ */
1302
+ readonly startCap?: StrokeCap;
1303
+ /** @since 0.22.0 */
1304
+ readonly endCap?: StrokeCap;
1305
+ }
1306
+ /** Every node with `type: "shape"`, told apart by its `shape` field. */
1307
+ export type ShapeNode = RectangleNode | EllipseNode | PolygonNode | StarNode | LineNode | PathNode;
1308
+ /** How an image or video fills its frame, as in CSS `object-fit`. */
1309
+ export type MediaFit = "contain" | "cover" | "fill";
1310
+ /** A placed image. The pixels live in an `ImageAsset`. */
1311
+ export interface ImageNode extends FramedNodeBase {
1312
+ readonly type: "image";
1313
+ /** Must name an asset of kind `image`. */
1314
+ readonly assetId: AssetId;
1315
+ readonly fit: MediaFit;
1316
+ /** The part of the source image to show, in source pixels. */
1317
+ readonly crop?: Rect;
1318
+ /** Alternative text for accessibility; may be empty. */
1319
+ readonly alt: string;
1320
+ }
1321
+ /** A placed video. The file lives in a `VideoAsset`. */
1322
+ export interface VideoNode extends FramedNodeBase {
1323
+ readonly type: "video";
1324
+ /** Must name an asset of kind `video`. */
1325
+ readonly assetId: AssetId;
1326
+ readonly fit: MediaFit;
1327
+ /** The part of the video frame to show, in source pixels. */
1328
+ readonly crop?: Rect;
1329
+ /** Alternative text for accessibility; may be empty. */
1330
+ readonly alt: string;
1331
+ }
1332
+ /**
1333
+ * A side of a layer that an attached connector end is pinned to.
1334
+ *
1335
+ * @since 0.20.0
1336
+ */
1337
+ export type ConnectorSide = "top" | "right" | "bottom" | "left";
1338
+ /**
1339
+ * A key point on a shape's outline that an attached connector end is pinned
1340
+ * to, found from the shape's geometry each time the connector is drawn, so
1341
+ * the end follows the shape when it moves, resizes or changes its points.
1342
+ *
1343
+ * - `vertex`: corner `index` of the outline, counted as `polygonPoints` and
1344
+ * `starPoints` list them (clockwise from the top point; a star's outer tips
1345
+ * are the even indices). On an ellipse arc, vertex 0 is where the arc
1346
+ * starts and vertex 1 where it ends, on the outer rim.
1347
+ * - `edge`: the middle of the outline's edge from vertex `index` to the next.
1348
+ *
1349
+ * An index the shape does not have (for example after a polygon loses
1350
+ * points), or an anchor on a layer without such points, leaves the end
1351
+ * automatic, as if it had no anchor.
1352
+ *
1353
+ * @since 0.20.0
1354
+ */
1355
+ export interface ConnectorAnchor {
1356
+ readonly kind: "vertex" | "edge";
1357
+ /** A whole number from 0. */
1358
+ readonly index: number;
1359
+ }
1360
+ /**
1361
+ * One end of a `ConnectorNode`.
1362
+ *
1363
+ * An end with `nodeId` attaches to that layer, and the page compiler places
1364
+ * it from the layer's frame each time, so it follows the layer when the layer
1365
+ * moves or resizes. Where on the layer it goes is set by at most one of:
1366
+ *
1367
+ * - `side`: the middle of that side, and an elbow connector leaves the layer
1368
+ * at a right angle to it. Figma calls this a magnet (`TOP`, `RIGHT`,
1369
+ * `BOTTOM` or `LEFT` in the plugin API's
1370
+ * `ConnectorEndpointConnectedWithMagnet`). On an ellipse, polygon or star
1371
+ * the end is where the shape's outline meets the line from its centre
1372
+ * toward that side, so it sits on the drawn shape.
1373
+ * - `anchor`: a corner or edge middle of a polygon, star or ellipse arc
1374
+ * (`ConnectorAnchor`); the end leaves along the outline's outward
1375
+ * direction there.
1376
+ * - `point`: a fixed point on the layer, as FigJam places an end dropped with
1377
+ * Command or Ctrl held (`ConnectorEndpointConnectedWithPosition`). Figma
1378
+ * stores it in the layer's pixels; here it is a fraction of the layer's
1379
+ * width and height, so the point keeps its place when the layer resizes.
1380
+ *
1381
+ * With none of them (Figma's `AUTO` magnet), the end goes where the layer's
1382
+ * outline faces the other end. `x` and `y` are the end's position in the
1383
+ * connector's frame; for an attached end they record where it was last
1384
+ * placed and are replaced when the connector is drawn.
1385
+ */
1386
+ export interface ConnectorEndpoint {
1387
+ /** The node this end attaches to. It must be on the same page as the connector. */
1388
+ readonly nodeId?: NodeId;
1389
+ readonly x: number;
1390
+ readonly y: number;
1391
+ /**
1392
+ * The side of the attached layer this end is pinned to. Needs `nodeId`,
1393
+ * and cannot be set together with `point` or `anchor`.
1394
+ *
1395
+ * @since 0.20.0
1396
+ */
1397
+ readonly side?: ConnectorSide;
1398
+ /**
1399
+ * The key point on the attached shape's outline this end is pinned to.
1400
+ * Needs `nodeId`, and cannot be set together with `side` or `point`.
1401
+ *
1402
+ * @since 0.20.0
1403
+ */
1404
+ readonly anchor?: ConnectorAnchor;
1405
+ /**
1406
+ * The point on the attached layer this end is fixed to, as fractions of the
1407
+ * layer's width (`x`) and height (`y`) from its top-left corner: `{ x: 1,
1408
+ * y: 0.5 }` is the middle of the right side. Each fraction is between 0
1409
+ * and 1. Needs `nodeId`, and cannot be set together with `side` or
1410
+ * `anchor`.
1411
+ *
1412
+ * @since 0.20.0
1413
+ */
1414
+ readonly point?: {
1415
+ readonly x: number;
1416
+ readonly y: number;
1417
+ };
1418
+ }
1419
+ /** A stroked line or arrow between two points, each optionally attached to a node. */
1420
+ export interface ConnectorNode extends FramedNodeBase {
1421
+ readonly type: "connector";
1422
+ readonly start: ConnectorEndpoint;
1423
+ readonly end: ConnectorEndpoint;
1424
+ readonly routing: "straight" | "elbow" | "curve";
1425
+ readonly stroke: Stroke;
1426
+ /**
1427
+ * The end styles, the same set a line has (`STROKE_CAPS`). Before 0.20.0 a
1428
+ * connector had only `"none"`, `"arrow"` and `"dot"`; loading an older
1429
+ * document turns `"arrow"` into `"triangle-arrow"` and `"dot"` into
1430
+ * `"circle-arrow"`.
1431
+ *
1432
+ * @since 0.20.0 the full `StrokeCap` set
1433
+ */
1434
+ readonly startCap: StrokeCap;
1435
+ readonly endCap: StrokeCap;
1436
+ /**
1437
+ * How far, in pixels, each bend of an elbow connector is rounded, as
1438
+ * Figma's `ConnectorNode.cornerRadius`. A bend never rounds past half of
1439
+ * either part of the line it joins, so a short part keeps a smaller curve.
1440
+ * The ends and end styles are not rounded. Straight and curved connectors
1441
+ * have no bends and ignore it. Missing means 0: sharp bends. Not negative.
1442
+ *
1443
+ * @since 0.21.0
1444
+ */
1445
+ readonly cornerRadius?: number;
1446
+ /**
1447
+ * How far each rounded bend of an elbow connector eases into the line,
1448
+ * from 0 (a circular arc) to 1 (a continuous curve), the same fraction as a
1449
+ * rectangle's `NodeVisualStyle.cornerSmoothing` and drawn the same way. A
1450
+ * smoothed bend takes up to `(1 + cornerSmoothing) * cornerRadius` of each
1451
+ * part of the line it joins, capped at half of the shorter part, which also
1452
+ * caps the smoothing. It has no effect without a corner radius, or on
1453
+ * straight and curved connectors. Figma's `ConnectorNode` has no smoothing;
1454
+ * this extends it. Missing means 0.
1455
+ *
1456
+ * @since 0.21.0
1457
+ */
1458
+ readonly cornerSmoothing?: number;
1459
+ }
1460
+ /**
1461
+ * A reusable layer tree, stored once per document and shown in the Assets
1462
+ * panel, never on a page. Its layers live in `DesignDocument.nodes` under
1463
+ * `rootId`, so every node operation, undo and validation works on them
1464
+ * unchanged. Instances (`InstanceNode`) show it on pages.
1465
+ * @since 0.23.0
1466
+ */
1467
+ export interface ComponentDefinition {
1468
+ /** Matches the key in `DesignDocument.components`. */
1469
+ readonly id: ComponentId;
1470
+ /**
1471
+ * A stable identity separate from `id`, a UUID string, unique in the
1472
+ * document. Paste between documents and, later, libraries match components
1473
+ * by key, so a component edited after a paste is still recognised as the
1474
+ * same component. It never changes.
1475
+ */
1476
+ readonly key: string;
1477
+ /** Shown in the Assets panel. Must not be empty. */
1478
+ readonly name: string;
1479
+ /** Optional free text shown in the Assets panel. */
1480
+ readonly description?: string;
1481
+ /**
1482
+ * The root of the component's layer tree: always a frame with no parent
1483
+ * that no page uses. Its `frame.x` and `frame.y` are 0; its width and
1484
+ * height are the natural size, which is the size shown in the component
1485
+ * view. Its `layout` sizing (Hug or Fixed) is the size behaviour every
1486
+ * instance starts with; see `LayerOverride.sizing`.
1487
+ */
1488
+ readonly rootId: NodeId;
1489
+ /**
1490
+ * The component's properties, in the order the instance section lists
1491
+ * them. IDs and names are unique within the component. Omitted when empty.
1492
+ * @since 0.24.0
1493
+ */
1494
+ readonly properties?: readonly ComponentPropertyDefinition[];
1495
+ /**
1496
+ * Which combinations of the enum and boolean properties an instance may
1497
+ * take: a boolean expression that reads only those properties, as
1498
+ * `not (Disabled == .True and Hover == .True)`. The defaults must be a
1499
+ * valid combination. An edit that sets an instance's values to a
1500
+ * combination it is false for is refused; the properties panel offers an
1501
+ * option only when some valid combination has it, and moves the other
1502
+ * properties to the nearest valid combination (`nearestValidCombination`).
1503
+ * Omitted, every combination is valid.
1504
+ * @since 0.35.0
1505
+ */
1506
+ readonly validity?: string;
1507
+ /** Free-form JSON data kept with the component. The model does not read it. */
1508
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
1509
+ }
1510
+ /**
1511
+ * The kinds of component property, as `ComponentPropertyDefinition.kind`.
1512
+ * `"slot"` was added in 0.37.0.
1513
+ * @since 0.24.0
1514
+ */
1515
+ export declare const COMPONENT_PROPERTY_KINDS: readonly ["boolean", "number", "text", "enum", "color", "instance", "slot"];
1516
+ /** One of `COMPONENT_PROPERTY_KINDS`. @since 0.24.0 */
1517
+ export type ComponentPropertyKind = (typeof COMPONENT_PROPERTY_KINDS)[number];
1518
+ /**
1519
+ * The unit of a number property: `"none"` reads as a `number` in
1520
+ * expressions, `"px"` as a `length`, `"%"` as a `percent` and `"deg"` as an
1521
+ * `angle`.
1522
+ * @since 0.24.0
1523
+ */
1524
+ export declare const COMPONENT_NUMBER_UNITS: readonly ["none", "px", "%", "deg"];
1525
+ /** One of `COMPONENT_NUMBER_UNITS`. @since 0.24.0 */
1526
+ export type ComponentNumberUnit = (typeof COMPONENT_NUMBER_UNITS)[number];
1527
+ /**
1528
+ * Fields every component property has.
1529
+ * @since 0.24.0
1530
+ */
1531
+ export interface ComponentPropertyBase<Kind extends ComponentPropertyKind> {
1532
+ /** Stable and never shown; instance values are keyed by it. */
1533
+ readonly id: ComponentPropertyId;
1534
+ readonly kind: Kind;
1535
+ /**
1536
+ * The name the panel shows and expressions read the property by, stored
1537
+ * as written in NFC and unique in the component after NFC. Not empty and
1538
+ * without control, line break or bidirectional formatting characters
1539
+ * (U+202A to U+202E, U+2066 to U+2069). A name made or renamed is at most
1540
+ * 256 code points; an older document may hold a longer identifier. Since
1541
+ * 0.34.0 it need not be an identifier: an expression writes `大` or
1542
+ * `size` bare and any other name in backticks, `` `Primary / Hover` ``.
1543
+ */
1544
+ readonly name: string;
1545
+ readonly description?: string;
1546
+ }
1547
+ /**
1548
+ * One option of an enum property. The ID is stable; the name is what the
1549
+ * panel shows and expressions write after the dot (`.large`, `.大`, or in
1550
+ * backticks where it is not an identifier, `` .`Primary / Hover` ``), with
1551
+ * the same rules as a property's name, unique within the property.
1552
+ * @since 0.24.0
1553
+ */
1554
+ export interface ComponentPropertyOption {
1555
+ readonly id: string;
1556
+ readonly name: string;
1557
+ }
1558
+ /**
1559
+ * A named, typed input on a component. Each instance chooses a value for it
1560
+ * in `InstanceNode.propertyValues`, or leaves the default.
1561
+ * @since 0.24.0
1562
+ */
1563
+ export type ComponentPropertyDefinition = (ComponentPropertyBase<"boolean"> & {
1564
+ readonly defaultValue: boolean;
1565
+ }) | (ComponentPropertyBase<"number"> & {
1566
+ readonly unit: ComponentNumberUnit;
1567
+ readonly defaultValue: number;
1568
+ readonly min?: number;
1569
+ readonly max?: number;
1570
+ /** Greater than 0. */
1571
+ readonly step?: number;
1572
+ }) | (ComponentPropertyBase<"text"> & {
1573
+ /** Plain text; applied to a text layer it replaces the content and keeps the first run's style. */
1574
+ readonly defaultValue: string;
1575
+ readonly multiline?: boolean;
1576
+ }) | (ComponentPropertyBase<"enum"> & {
1577
+ /** In display order; at least one. */
1578
+ readonly options: readonly ComponentPropertyOption[];
1579
+ /** An option ID. */
1580
+ readonly defaultValue: string;
1581
+ }) | (ComponentPropertyBase<"color"> & {
1582
+ /** `#rrggbb` or `#rrggbbaa`. */
1583
+ readonly defaultValue: string;
1584
+ }) | (ComponentPropertyBase<"instance"> & {
1585
+ readonly defaultValue: ComponentId;
1586
+ /** Components the picker shows first. */
1587
+ readonly preferred?: readonly ComponentId[];
1588
+ }) | SlotComponentProperty;
1589
+ /**
1590
+ * A slot: a place in the component where each instance can put its own
1591
+ * layers. The frames bound to it (`FrameNode.slot`) are the slot frames; their
1592
+ * own children are the default content. An instance that fills the slot
1593
+ * stores its content in a slot host frame (`FrameNode.slotHost`) listed in
1594
+ * `InstanceNode.slots`. A slot has no `defaultValue`, cannot be read in
1595
+ * expressions, and has no value in `InstanceNode.propertyValues`.
1596
+ * @since 0.37.0
1597
+ */
1598
+ export type SlotComponentProperty = ComponentPropertyBase<"slot"> & {
1599
+ /**
1600
+ * Components the "Add instances" picker shows first.
1601
+ * @since 0.37.0
1602
+ */
1603
+ readonly preferred?: readonly ComponentId[];
1604
+ /**
1605
+ * When true, the picker offers only the `preferred` components.
1606
+ * @since 0.37.0
1607
+ */
1608
+ readonly preferredOnly?: boolean;
1609
+ /**
1610
+ * The fewest layers the content should hold. A whole number, at least 0.
1611
+ * @since 0.37.0
1612
+ */
1613
+ readonly minChildren?: number;
1614
+ /**
1615
+ * The most layers the content should hold. A whole number, at least 0 and
1616
+ * at least `minChildren`.
1617
+ * @since 0.37.0
1618
+ */
1619
+ readonly maxChildren?: number;
1620
+ /**
1621
+ * When true, a layer added to the slot is set to fill the slot frame's
1622
+ * cross axis.
1623
+ * @since 0.37.0
1624
+ */
1625
+ readonly fillCrossAxisOnInsert?: boolean;
1626
+ /**
1627
+ * When true, a new instance shows the slot empty instead of the default
1628
+ * content.
1629
+ * @since 0.37.0
1630
+ */
1631
+ readonly displayEmptyByDefault?: boolean;
1632
+ };
1633
+ /**
1634
+ * A component property that instances give a value to: every kind but
1635
+ * `"slot"`. Only these are read in expressions and stored in
1636
+ * `InstanceNode.propertyValues`.
1637
+ * @since 0.37.0
1638
+ */
1639
+ export type ValuedComponentPropertyDefinition = Exclude<ComponentPropertyDefinition, SlotComponentProperty>;
1640
+ /**
1641
+ * True when instances give `property` a value, so it has a `defaultValue`
1642
+ * and can be read in expressions: every kind but `"slot"`.
1643
+ * @since 0.37.0
1644
+ */
1645
+ export declare const isValuedComponentProperty: (property: ComponentPropertyDefinition) => property is ValuedComponentPropertyDefinition;
1646
+ /**
1647
+ * A value an instance sets for a property: a boolean, a number, a string
1648
+ * (text), an option ID (enum), a colour string or a component ID (instance
1649
+ * swap). A value that does not fit the property's current kind is ignored,
1650
+ * as is a value for a property the component no longer has.
1651
+ * @since 0.24.0
1652
+ */
1653
+ export type ComponentPropertyValue = boolean | number | string;
1654
+ /**
1655
+ * Property values keyed by `ComponentPropertyId`. Missing means the default.
1656
+ * @since 0.24.0
1657
+ */
1658
+ export type ComponentPropertyValues = Readonly<Record<string, ComponentPropertyValue>>;
1659
+ /**
1660
+ * The layer fields that can hold an expression. Which ones apply depends on
1661
+ * the node type (see `computableFieldsOf`); `propertyValues.<property id>`
1662
+ * computes a nested instance's property value.
1663
+ * @since 0.24.0
1664
+ */
1665
+ export declare const COMPUTABLE_FIELDS: readonly ["x", "y", "rotation", "transform", "clipContent", "paragraphSpacing", "lineHeightMultiplier", "constraintSize", "resizing.width", "resizing.height", "layout.widthSizing", "layout.heightSizing", "constraints.horizontal", "constraints.vertical", "startCap", "endCap", "visible", "opacity", "fills", "strokes", "effects", "cornerRadius", "cornerRadii", "cornerSmoothing", "width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "gap", "wrapGap", "columnGap", "rowGap", "padding", "direction", "align", "justify", "wrap", "characters", "fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "textColor", "textStyle", "componentId"];
1666
+ /** A field that can hold an expression: a `COMPUTABLE_FIELDS` name or `propertyValues.<property id>`. @since 0.24.0 */
1667
+ export type ComputableField = (typeof COMPUTABLE_FIELDS)[number] | `propertyValues.${string}`;
1668
+ /**
1669
+ * Expression source text keyed by computed field.
1670
+ * @since 0.24.0
1671
+ */
1672
+ export type NodeExpressions = Readonly<Partial<Record<ComputableField, string>>>;
1673
+ /**
1674
+ * The character that joins the IDs in a layer path and a virtual node ID.
1675
+ * Stored node IDs never contain it.
1676
+ * @since 0.23.0
1677
+ */
1678
+ export declare const LAYER_PATH_SEPARATOR = ";";
1679
+ /**
1680
+ * Which axes of a layer inside an instance hug their content or keep a fixed
1681
+ * size, replacing the component frame's `layout.widthSizing` and
1682
+ * `layout.heightSizing`. Under the component root's path it is the
1683
+ * instance's own size behaviour: resizing an instance on the canvas stores
1684
+ * `"fixed"` on that axis, and Reset size removes the entry, so the instance
1685
+ * follows the component root again. `"fill"` (since 0.41.0) makes a frame
1686
+ * layer fill its parent's auto layout on that axis in this instance, as
1687
+ * `resizing` Fill does, whatever its own layout; a Hug axis of its own then
1688
+ * keeps the size it is given. Under the component root's path Fill has no
1689
+ * effect: an instance fills its parent through its own `resizing`, like any
1690
+ * framed node.
1691
+ * @since 0.23.0
1692
+ */
1693
+ export interface LayerSizingOverride {
1694
+ readonly width?: "hug" | "fixed" | "fill";
1695
+ readonly height?: "hug" | "fixed" | "fill";
1696
+ }
1697
+ /**
1698
+ * The padding one instance gives an auto layout frame of its component (or
1699
+ * its own root), side by side: a side set here replaces the frame's padding
1700
+ * on that side, and its variable binding, in that instance; a side left out
1701
+ * follows the component.
1702
+ * @since 0.38.0
1703
+ */
1704
+ export type LayerPaddingOverride = Partial<LayoutPadding>;
1705
+ /**
1706
+ * Variable bindings an instance stores for one layer, keyed by property. A
1707
+ * variable ID binds the property in that instance; `null` removes the
1708
+ * component's binding for that property in that instance and leaves the
1709
+ * plain value (the layer's, or the override's) in force.
1710
+ * @since 0.23.0
1711
+ */
1712
+ export type LayerOverrideVariableBindings = Readonly<Partial<Record<VariableProperty, VariableId | null>>>;
1713
+ /**
1714
+ * The changes one instance makes to one layer of its component, stored in
1715
+ * `InstanceNode.overrides` under the layer's path. Every field replaces the
1716
+ * layer's resolved value as a whole (`padding` side by side, `textStyle` member by member); a field that is
1717
+ * absent follows the component. Structure (layers, geometry of inner
1718
+ * layers, masks, blend modes) is not overridable: that needs an edit to the
1719
+ * component, or Detach.
1720
+ *
1721
+ * Precedence for one field of one layer, decided per field:
1722
+ *
1723
+ * 1. A variable ID in `variableBindings` for the field's property: the
1724
+ * variable's value wins.
1725
+ * 2. Otherwise a plain value in this override for the field (or `null` in
1726
+ * `variableBindings` for its property): the override value wins, and the
1727
+ * component layer's own binding for that property is ignored in this
1728
+ * instance. Overriding a field therefore never gets repainted by the
1729
+ * component's binding.
1730
+ * 3. Otherwise the component layer's own binding, then its stored value.
1731
+ *
1732
+ * When instances nest, the override stored on the outer instance wins over
1733
+ * the one stored on the nested instance node inside the component, which
1734
+ * wins over the component's value, again field by field.
1735
+ * @since 0.23.0
1736
+ */
1737
+ export interface LayerOverride {
1738
+ /** Variant-dependent overrides, evaluated in the named component's property environment, before the plain fields. */
1739
+ readonly conditional?: readonly {
1740
+ readonly componentId: ComponentId;
1741
+ readonly condition: string;
1742
+ readonly value: LayerOverride;
1743
+ }[];
1744
+ readonly visible?: boolean;
1745
+ /** From 0 (transparent) to 1 (opaque). */
1746
+ readonly opacity?: number;
1747
+ /**
1748
+ * The layer's name in this instance, never empty.
1749
+ * @since 0.33.0
1750
+ */
1751
+ readonly name?: string;
1752
+ /**
1753
+ * Text layers: the whole text as plain characters, paragraphs separated by
1754
+ * `"\n"`. Every character takes the style of the component's first run,
1755
+ * so a component font change still reaches an instance that only changed
1756
+ * its label. Not allowed together with `paragraphs`.
1757
+ */
1758
+ readonly characters?: string;
1759
+ /**
1760
+ * Text layers: the whole content with styled runs, stored only when the
1761
+ * user styles part of the text differently from the rest. Not allowed
1762
+ * together with `characters`.
1763
+ */
1764
+ readonly paragraphs?: readonly TextParagraph[];
1765
+ /**
1766
+ * Text layers: the theme text style every run takes instead of its own;
1767
+ * `null` clears the runs' style IDs so they use the theme default.
1768
+ */
1769
+ readonly textStyleId?: TextStyleId | null;
1770
+ /**
1771
+ * Text layers: direct formatting (font, size, weight, line height, letter
1772
+ * spacing, colour and the rest) applied on top of every run's style.
1773
+ */
1774
+ readonly textStyle?: TextStyleOverrides;
1775
+ /**
1776
+ * Text layers: the alignment every paragraph takes, applied on top of the
1777
+ * text the layer shows (the component's, a text property's, or this
1778
+ * override's `characters` or `paragraphs`). An instance that only aligns
1779
+ * its text differently stores this alone, so it keeps showing the
1780
+ * component's text and any later change to it.
1781
+ * @since 0.36.0
1782
+ */
1783
+ readonly textAlign?: TextParagraph["align"];
1784
+ /** Text: the layer's `maxLines`; `null` takes the component's away. */
1785
+ readonly maxLines?: number | null;
1786
+ /** Text: the layer's `truncate`; `null` takes the component's away. */
1787
+ readonly truncate?: "ellipsis" | null;
1788
+ /** Frames and shapes: the node style to use; `null` clears the layer's. */
1789
+ readonly styleId?: NodeStyleId | null;
1790
+ readonly fills?: readonly Paint[];
1791
+ readonly strokes?: readonly Stroke[];
1792
+ readonly shadows?: readonly Shadow[];
1793
+ readonly layerBlur?: number;
1794
+ readonly backgroundBlur?: number;
1795
+ /** Image layers: the image asset to show instead. */
1796
+ readonly imageAssetId?: AssetId;
1797
+ /** Nested instance layers: the component to show instead (a swap). */
1798
+ readonly componentId?: ComponentId;
1799
+ readonly clipContent?: boolean;
1800
+ readonly cornerSmoothing?: number;
1801
+ /** Per-member stack settings. Padding sides and sizing axes have their own overrides. */
1802
+ readonly layout?: Partial<Omit<StackAutoLayout, "kind" | "padding" | "widthSizing" | "heightSizing">> & {
1803
+ readonly kind?: "absolute" | "horizontal" | "vertical";
1804
+ };
1805
+ /** Frame layers, and the component root for the instance's own size. */
1806
+ readonly sizing?: LayerSizingOverride;
1807
+ /**
1808
+ * Auto layout frame layers, and the component root for the instance's own
1809
+ * padding: the sides this instance pads differently.
1810
+ * @since 0.38.0
1811
+ */
1812
+ readonly padding?: LayerPaddingOverride;
1813
+ readonly variableBindings?: LayerOverrideVariableBindings;
1814
+ /**
1815
+ * Nested instance layers: property values keyed by property ID, each
1816
+ * replacing the value the nested instance has in the component (stored or
1817
+ * computed). Overrides are constants, never expressions.
1818
+ * @since 0.24.0
1819
+ */
1820
+ readonly propertyValues?: ComponentPropertyValues;
1821
+ }
1822
+ /**
1823
+ * One use of a component on a page, or inside another component. It stores a
1824
+ * reference and its overrides; its layers are derived when the page is
1825
+ * compiled (see `resolveInstance`) and get virtual IDs
1826
+ * `<instance id>;<layer path>` (see `parseVirtualNodeId`).
1827
+ *
1828
+ * The instance has no `children`; `isContainerNode` is false for it. Its
1829
+ * `NodeBase` fields apply to the whole instance, like a frame's, and its
1830
+ * `frame`, `rotation`, flips and `resizing` place it like any framed node.
1831
+ * `frame` holds the resolved size, so geometry, selection and snapping code
1832
+ * works without the resolver; `applyOperations` keeps hugging axes equal to
1833
+ * the resolved size (from step 1.2). The instance's own paints come from the
1834
+ * component root and are overridden under the component root's path.
1835
+ * @since 0.23.0
1836
+ */
1837
+ export interface InstanceNode extends FramedNodeBase {
1838
+ readonly type: "instance";
1839
+ readonly componentId: ComponentId;
1840
+ /**
1841
+ * Changes to the component's layers, keyed by layer path: the component
1842
+ * node IDs from the component root down to the layer, joined by `;`,
1843
+ * without the instance ID. Omitted when empty. A key naming a node the
1844
+ * component no longer has is allowed and has no effect.
1845
+ */
1846
+ readonly overrides?: Readonly<Record<string, LayerOverride>>;
1847
+ /**
1848
+ * The instance's values for the component's properties, keyed by property
1849
+ * ID. Missing means the default; a value equal to the default is still
1850
+ * kept, so Reset is what makes the instance follow the default again.
1851
+ * Omitted when empty.
1852
+ * @since 0.24.0
1853
+ */
1854
+ readonly propertyValues?: ComponentPropertyValues;
1855
+ /**
1856
+ * The slots this instance fills, as slot host frame IDs (see
1857
+ * `FrameNode.slotHost`). The outer key is the `layerPathKey` of a nested
1858
+ * instance's layer path for that instance's slots, or `""` for this
1859
+ * instance's own slots; the inner key is the slot property ID. A slot
1860
+ * without an entry shows its default content. The instance is the only
1861
+ * parent of each host it lists. Omitted when empty.
1862
+ * @since 0.37.0
1863
+ */
1864
+ readonly slots?: InstanceSlots;
1865
+ /**
1866
+ * Present on an instance of a library component that was adjusted inside
1867
+ * this document (a prototype): the adjustments themselves are the
1868
+ * instance's `overrides`, so a library update re-applies them. Holds the
1869
+ * adjustments a library update could not apply. Omitted on every other
1870
+ * instance. See `prototypeAdjustments`.
1871
+ * @since 0.43.0
1872
+ */
1873
+ readonly adjustments?: InstanceAdjustments;
1874
+ }
1875
+ /**
1876
+ * The record on an instance adjusted inside a prototype
1877
+ * (`InstanceNode.adjustments`). An empty record marks the instance.
1878
+ * @since 0.43.0
1879
+ */
1880
+ export interface InstanceAdjustments {
1881
+ /**
1882
+ * Adjustments a library update could not apply, because the layer or the
1883
+ * property they change is gone, keyed by the layer path they were made on
1884
+ * (as an override key; the layers named may no longer exist). Kept apart
1885
+ * from `overrides`, so drawing and layout never apply them; a later update
1886
+ * that brings the layer or property back makes them overrides again.
1887
+ * Omitted when empty.
1888
+ */
1889
+ readonly conflicts?: Readonly<Record<string, AdjustmentConflict>>;
1890
+ }
1891
+ /**
1892
+ * Adjustments to one layer that a library update could not apply. At least
1893
+ * one of `override` and `properties` is present.
1894
+ * @since 0.43.0
1895
+ */
1896
+ export interface AdjustmentConflict {
1897
+ /** The layer's name when the adjustment became a conflict. */
1898
+ readonly layerName: string;
1899
+ /**
1900
+ * The library layer each layer of the path came from
1901
+ * (`NodeBase.libraryLayerId`), keyed by the layer's ID in the path; a
1902
+ * layer that recorded none is left out. Lets a later update find the
1903
+ * layers again under other IDs. Omitted when empty.
1904
+ */
1905
+ readonly libraryLayerIds?: Readonly<Record<string, string>>;
1906
+ /** The override fields whose layer is gone, without `propertyValues`. */
1907
+ readonly override?: LayerOverride;
1908
+ /** Property values of a nested instance whose property is gone or no longer takes the value, by property ID. */
1909
+ readonly properties?: Readonly<Record<string, AdjustmentConflictProperty>>;
1910
+ }
1911
+ /**
1912
+ * One property value kept by an `AdjustmentConflict`.
1913
+ * @since 0.43.0
1914
+ */
1915
+ export interface AdjustmentConflictProperty {
1916
+ /** The property's name when the value became a conflict. */
1917
+ readonly name: string;
1918
+ readonly value: ComponentPropertyValue;
1919
+ }
1920
+ /**
1921
+ * Slot host IDs keyed by nested instance path key (`""` for the instance's
1922
+ * own slots), then by slot property ID. See `InstanceNode.slots`.
1923
+ * @since 0.37.0
1924
+ */
1925
+ export type InstanceSlots = Readonly<Record<string, Readonly<Record<ComponentPropertyId, NodeId>>>>;
1926
+ /** Nodes that have `children`. Test with `isContainerNode`. */
1927
+ export type ContainerNode = FrameNode | GroupNode;
1928
+ /**
1929
+ * Any node in a page's tree, told apart by its `type` field. Nodes live in
1930
+ * the flat `DesignDocument.nodes` map; containers list their children by ID
1931
+ * and parents are not stored.
1932
+ */
1933
+ export type SceneNode = FrameNode | GroupNode | TextNode | CodeNode | ShapeNode | ImageNode | VideoNode | ConnectorNode | InstanceNode;
1934
+ /**
1935
+ * One page of the document. A page is an unbounded canvas: its root
1936
+ * container never clips, so top-level nodes may lie anywhere, and the root's
1937
+ * frame only records the visible extent (see `pageRootFrame`).
1938
+ */
1939
+ export interface Page {
1940
+ /** Matches the page's key in `DesignDocument.pages`. */
1941
+ readonly id: PageId;
1942
+ /** Must not be empty. */
1943
+ readonly name: string;
1944
+ /** The page's root node: a frame or group with no parent. */
1945
+ readonly rootId: NodeId;
1946
+ /**
1947
+ * Ruler guides on the page's canvas, in page coordinates. Omitted when empty.
1948
+ * @since 0.11.0
1949
+ */
1950
+ readonly guides?: readonly Guide[];
1951
+ /**
1952
+ * The page's mode per variable collection. Layers set to Auto inherit it;
1953
+ * a collection left out uses the collection's `activeModeId`.
1954
+ * @since 0.26.0
1955
+ */
1956
+ readonly variableModes?: VariableModes;
1957
+ /**
1958
+ * The colour of the canvas around the page's layers, as six hexadecimal
1959
+ * digits after `#` (`#rrggbb`, either letter case). It is opaque: there is
1960
+ * no alpha. Omitted means the editor's own default canvas colour.
1961
+ * @since 0.28.0
1962
+ */
1963
+ readonly canvasBackground?: string;
1964
+ /**
1965
+ * Short labels for the page, in the order they are shown. An editor shows
1966
+ * each one beside the page's name. Each tag is non-empty text of at most
1967
+ * `MAX_PAGE_TAG_LENGTH` (32) characters with no white space at its start or
1968
+ * end, no tag appears twice, and a page has at most `MAX_PAGE_TAGS` (8).
1969
+ * Anything else is rejected, never shortened. Omitted means no tags; an
1970
+ * empty list must be omitted.
1971
+ * @since 0.29.0
1972
+ */
1973
+ readonly tags?: readonly string[];
1974
+ /**
1975
+ * `false` on a page that must not be deleted: a change that removes the
1976
+ * page is refused with a `PageNotRemovableError` (see
1977
+ * `nonRemovablePagesRemovedBy`). Omitted means the page can be deleted,
1978
+ * which is the default; `true` is never stored and must be omitted. Read
1979
+ * it with `isPageRemovable`.
1980
+ * @since 0.29.0
1981
+ */
1982
+ readonly removable?: false;
1983
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
1984
+ }
1985
+ /**
1986
+ * The most tags a page can hold in `Page.tags`.
1987
+ * @since 0.29.0
1988
+ */
1989
+ export declare const MAX_PAGE_TAGS = 8;
1990
+ /**
1991
+ * The most characters (UTF-16 code units, as `String.length` counts) one tag
1992
+ * in `Page.tags` can have.
1993
+ * @since 0.29.0
1994
+ */
1995
+ export declare const MAX_PAGE_TAG_LENGTH = 32;
1996
+ /**
1997
+ * Says what is wrong with `value` as a page's `Page.tags`, or `null` when a
1998
+ * page can hold it: a list of 1 to `MAX_PAGE_TAGS` different tags, each
1999
+ * non-empty text of at most `MAX_PAGE_TAG_LENGTH` characters with no white
2000
+ * space at its start or end.
2001
+ * @since 0.29.0
2002
+ */
2003
+ export declare function pageTagsProblem(value: unknown): string | null;
2004
+ /**
2005
+ * Whether the page can be deleted: true unless its `removable` is `false`.
2006
+ * @since 0.29.0
2007
+ */
2008
+ export declare function isPageRemovable(page: Pick<Page, "removable">): boolean;
2009
+ /**
2010
+ * The page with `tags` as its tags, in the form a document stores: an empty
2011
+ * list leaves the field out. It does not check the tags; `pageTagsProblem`
2012
+ * does, and so does every edit of a document.
2013
+ * @since 0.29.0
2014
+ */
2015
+ export declare function withPageTags(page: Page, tags: readonly string[]): Page;
2016
+ /**
2017
+ * The page made removable or not, in the form a document stores: a
2018
+ * removable page leaves the field out.
2019
+ * @since 0.29.0
2020
+ */
2021
+ export declare function withPageRemovable(page: Page, removable: boolean): Page;
2022
+ /**
2023
+ * Whether `value` is a colour a page can hold in `Page.canvasBackground`:
2024
+ * `#` and six hexadecimal digits.
2025
+ * @since 0.28.0
2026
+ */
2027
+ export declare function isPageCanvasBackground(value: unknown): value is string;
2028
+ /** Where an asset's bytes come from: a URL, or data stored in the document. */
2029
+ export type AssetSource = {
2030
+ readonly kind: "url";
2031
+ readonly url: string;
2032
+ } | {
2033
+ readonly kind: "data";
2034
+ readonly data: string;
2035
+ };
2036
+ /** An image file used by `ImageNode` and `ImagePaint`. */
2037
+ export interface ImageAsset {
2038
+ /** Matches the asset's key in `DesignDocument.assets`. */
2039
+ readonly id: AssetId;
2040
+ readonly kind: "image";
2041
+ readonly mimeType: string;
2042
+ readonly source: AssetSource;
2043
+ /** Intrinsic width in pixels, when known. */
2044
+ readonly width?: number;
2045
+ /** Intrinsic height in pixels, when known. */
2046
+ readonly height?: number;
2047
+ }
2048
+ /** A video file used by `VideoNode`. */
2049
+ export interface VideoAsset {
2050
+ /** Matches the asset's key in `DesignDocument.assets`. */
2051
+ readonly id: AssetId;
2052
+ readonly kind: "video";
2053
+ readonly mimeType: string;
2054
+ readonly source: AssetSource;
2055
+ /** Intrinsic width in pixels, when known. */
2056
+ readonly width?: number;
2057
+ /** Intrinsic height in pixels, when known. */
2058
+ readonly height?: number;
2059
+ }
2060
+ /**
2061
+ * A font family served by Google Fonts as many small WOFF2 files, each
2062
+ * covering part of Unicode (declared by `unicode-range` in the Google Fonts
2063
+ * CSS). The app keeps the list of files for each built-in family and loads
2064
+ * only the files that contain characters the document uses.
2065
+ * @since 0.13.0
2066
+ */
2067
+ export interface GoogleFontsSource {
2068
+ readonly kind: "google-fonts";
2069
+ /** The Google Fonts family name, such as "Noto Sans SC". */
2070
+ readonly family: string;
2071
+ }
2072
+ /**
2073
+ * A font installed on the computer of the person who chose it, read through
2074
+ * the browser's Local Font Access API (`window.queryLocalFonts()`). The
2075
+ * document names the font but does not carry its file, so the list of fonts
2076
+ * installed on a computer never enters a document; only the fonts that its
2077
+ * text uses are named. On a computer where the font is not installed, the
2078
+ * app shows the text as using a missing font.
2079
+ * @since 0.19.0
2080
+ */
2081
+ export interface LocalFontSource {
2082
+ readonly kind: "local";
2083
+ /** The installed family name, such as "Helvetica Neue". */
2084
+ readonly family: string;
2085
+ /** The face's PostScript name, which identifies it among installed fonts. */
2086
+ readonly postScriptName: string;
2087
+ /** The installed style name, such as "Bold Italic". */
2088
+ readonly styleName: string;
2089
+ /**
2090
+ * SHA-256 of the face's font file, as 64 lowercase hexadecimal digits.
2091
+ * An installed face with the same PostScript name but other bytes is a
2092
+ * different version of the font, which can lay text out differently.
2093
+ */
2094
+ readonly sha256: string;
2095
+ }
2096
+ /**
2097
+ * A font named the way a web page names it: a CSS `font-family` list, with
2098
+ * the weight and style on the `FontAsset`, and optionally the stylesheet
2099
+ * whose `@font-face` rules serve it. The document carries no font file and
2100
+ * no hash of one: font services cut their files again over time, so a stored
2101
+ * hash would report a different version where nothing meaningful changed.
2102
+ * Where the font cannot be loaded, the app draws the text with a stand-in
2103
+ * font and says so on the text.
2104
+ * @since 0.30.0
2105
+ */
2106
+ export interface WebFontSource {
2107
+ readonly kind: "web";
2108
+ /**
2109
+ * CSS font-family names in priority order, without quotes, such as
2110
+ * `["Helvetica", "sans-serif"]`. From 1 to `WEB_FONT_SOURCE_LIMITS.families`
2111
+ * names; each is trimmed, not empty, at most
2112
+ * `WEB_FONT_SOURCE_LIMITS.familyLength` characters, and has no comma,
2113
+ * quote character or control character (such as a tab or a line break).
2114
+ * No two names are the same when letter case is ignored.
2115
+ * Generic names such as "sans-serif" are allowed. The first name is the
2116
+ * asset's `family`.
2117
+ */
2118
+ readonly families: readonly string[];
2119
+ /**
2120
+ * The `https:` address of a CSS file with `@font-face` rules for these
2121
+ * families, without a user name or password and at most
2122
+ * `WEB_FONT_SOURCE_LIMITS.stylesheetUrlLength` characters. Absent when
2123
+ * the document only names the families and there is nothing to download.
2124
+ */
2125
+ readonly stylesheetUrl?: string;
2126
+ }
2127
+ /**
2128
+ * The size limits of a `WebFontSource`.
2129
+ * @since 0.30.0
2130
+ */
2131
+ export declare const WEB_FONT_SOURCE_LIMITS: Readonly<{
2132
+ /** The most names `families` may hold. */
2133
+ readonly families: 32;
2134
+ /** The most characters one family name may have. */
2135
+ readonly familyLength: 200;
2136
+ /** The most characters `stylesheetUrl` may have. */
2137
+ readonly stylesheetUrlLength: 2048;
2138
+ }>;
2139
+ /**
2140
+ * Where a font's files come from.
2141
+ * @since 0.13.0
2142
+ */
2143
+ export type FontAssetSource = AssetSource | GoogleFontsSource | LocalFontSource | WebFontSource;
2144
+ /**
2145
+ * One font face, referenced by `TextStyle.fontAssetId`,
2146
+ * `TextStyle.fontFallbackAssetIds` and `CodeStyle.fontAssetId`.
2147
+ */
2148
+ export interface FontAsset {
2149
+ /** Matches the asset's key in `DesignDocument.assets`. */
2150
+ readonly id: AssetId;
2151
+ readonly kind: "font";
2152
+ /**
2153
+ * Must be `font/woff2` when the source is Google Fonts or a web font
2154
+ * (the real file type is read from the bytes), and `font/ttf` or
2155
+ * `font/otf` when the source is a local font.
2156
+ */
2157
+ readonly mimeType: string;
2158
+ readonly source: FontAssetSource;
2159
+ /** For a web font source, the first name of `source.families`. */
2160
+ readonly family: string;
2161
+ /** From 1 to 1000, as in CSS `font-weight`. */
2162
+ readonly weight: number;
2163
+ readonly style: "normal" | "italic" | "oblique";
2164
+ }
2165
+ /** A file stored in `DesignDocument.assets`, told apart by its `kind` field. */
2166
+ export type Asset = ImageAsset | VideoAsset | FontAsset;
2167
+ /**
2168
+ * Who wrote a comment message: a person or an agent. `id` identifies the
2169
+ * author to the host; `displayName` is what the editor shows.
2170
+ * @since 0.31.0
2171
+ */
2172
+ export interface CommentAuthor {
2173
+ readonly kind: "person" | "agent";
2174
+ readonly id: string;
2175
+ readonly displayName: string;
2176
+ }
2177
+ /**
2178
+ * Where a comment thread is pinned. A `"point"` anchor has a rectangle of
2179
+ * zero width and height at the pinned point; a `"region"` anchor covers the
2180
+ * rectangle a person drew. `attachedNodeId` names the layer the anchor is
2181
+ * pinned to, so it moves with that layer.
2182
+ *
2183
+ * Without `attachedNodeId`, `rect` is in page coordinates. With it, `rect`
2184
+ * is in that layer's local coordinates, and the editor places it on the
2185
+ * page through the layer's transform. `attachedNodeId` is not checked
2186
+ * against `nodes`: deleting the layer keeps the thread, but the editor
2187
+ * does not show its anchor while the layer is missing.
2188
+ * @since 0.31.0
2189
+ */
2190
+ export interface CommentAnchor {
2191
+ readonly kind: "point" | "region";
2192
+ readonly rect: Rect;
2193
+ readonly attachedNodeId?: NodeId;
2194
+ }
2195
+ /** One message in a comment thread. `createdAt` is milliseconds since 1970 (`Date.now()`). @since 0.31.0 */
2196
+ export interface CommentMessage {
2197
+ readonly id: string;
2198
+ readonly author: CommentAuthor;
2199
+ readonly body: string;
2200
+ readonly createdAt: number;
2201
+ }
2202
+ /** What an agent is doing for a thread that was addressed to it. @since 0.31.0 */
2203
+ export type CommentAgentStatus = "reading" | "editing" | "done";
2204
+ /**
2205
+ * A short record of one piece of agent work on a thread: what it was asked,
2206
+ * the history commits it made, why, what it learned and what is still open.
2207
+ * `createdAt` is milliseconds since 1970.
2208
+ * @since 0.31.0
2209
+ */
2210
+ export interface CommentThreadDigest {
2211
+ readonly id: string;
2212
+ readonly createdAt: number;
2213
+ readonly asked: string;
2214
+ readonly changedCommits: readonly string[];
2215
+ readonly reasons: string;
2216
+ readonly learned: readonly string[];
2217
+ readonly openItems: readonly string[];
2218
+ }
2219
+ /**
2220
+ * Everything one agent reply's edit wrote, as it was right after the edit,
2221
+ * by kind and ID: `null` for a layer, page, asset or component the edit
2222
+ * removed. `pageOrder`, `title`, `theme` and `metadata` are there only when
2223
+ * the edit changed them; `metadata` is `null` when the edit removed the
2224
+ * document's metadata.
2225
+ * @since 0.32.0
2226
+ */
2227
+ export interface CommentEditAfterValues {
2228
+ readonly nodes: Readonly<Record<NodeId, SceneNode | null>>;
2229
+ readonly pages: Readonly<Record<PageId, Page | null>>;
2230
+ readonly assets: Readonly<Record<AssetId, Asset | null>>;
2231
+ readonly components: Readonly<Record<ComponentId, ComponentDefinition | null>>;
2232
+ readonly pageOrder?: readonly PageId[];
2233
+ readonly title?: string;
2234
+ readonly theme?: DocumentTheme;
2235
+ readonly metadata?: Readonly<Record<string, JsonValue>> | null;
2236
+ }
2237
+ /**
2238
+ * One agent reply's design edit, kept with its thread so the reply can be
2239
+ * reverted and its layers shown, also after the document is loaded again.
2240
+ *
2241
+ * `operations` are the edit as it was applied to the document, and
2242
+ * `inverseOperations` undo it. Both are design operations only: a comment
2243
+ * operation is never part of a record. `after` holds everything the edit
2244
+ * wrote (layers, pages, the page order, assets, components, the title, the
2245
+ * theme and the metadata) as it was right after the edit. A revert is
2246
+ * checked against the latest document with these put back, so anything
2247
+ * someone changed since the reply is found. Whether the edit was reverted
2248
+ * is not stored: it is read from the document. `createdAt` is milliseconds
2249
+ * since 1970.
2250
+ *
2251
+ * `replyCommentIds` are the IDs of the thread messages the agent posted with
2252
+ * the edit, in order, or none when it wrote no text. Each ID is chosen when
2253
+ * the record is made, before its message is posted, so a message that was
2254
+ * never posted (the reply was stopped or failed after its edits were applied)
2255
+ * is named here but is not in the thread.
2256
+ * @since 0.32.0
2257
+ */
2258
+ export interface CommentEditRecord {
2259
+ readonly id: string;
2260
+ readonly createdAt: number;
2261
+ readonly replyCommentIds: readonly string[];
2262
+ readonly operations: readonly DocumentOperation[];
2263
+ readonly inverseOperations: readonly DocumentOperation[];
2264
+ readonly after: CommentEditAfterValues;
2265
+ }
2266
+ /**
2267
+ * A comment thread on a page. It starts with one message; people and agents
2268
+ * reply to it. `pageId` is not checked against `pages`: deleting the page
2269
+ * keeps the thread.
2270
+ *
2271
+ * `addressedToAgent` is true when the thread asks an agent to take part.
2272
+ * `agentSession` is an opaque value the host keeps for the agent's side;
2273
+ * the editor never reads it. `agentStatus` is what the agent is doing now.
2274
+ * `digests` records the agent's finished work, oldest first.
2275
+ * `editRecords` holds the design edits of the agent's replies, oldest first
2276
+ * (since 0.32.0). Each record's ID is used once in the whole document.
2277
+ * @since 0.31.0
2278
+ */
2279
+ export interface CommentThread {
2280
+ readonly id: string;
2281
+ readonly pageId: PageId;
2282
+ readonly anchor: CommentAnchor;
2283
+ readonly messages: readonly CommentMessage[];
2284
+ readonly resolved: boolean;
2285
+ readonly addressedToAgent: boolean;
2286
+ readonly agentSession?: string;
2287
+ readonly agentStatus?: CommentAgentStatus;
2288
+ readonly digests: readonly CommentThreadDigest[];
2289
+ /** @since 0.32.0 */
2290
+ readonly editRecords: readonly CommentEditRecord[];
2291
+ }
2292
+ /**
2293
+ * The stored shape of a document at `CURRENT_DOCUMENT_SCHEMA_VERSION`.
2294
+ * Use the `DesignDocument` alias in code.
2295
+ *
2296
+ * The data is normalized into flat maps keyed by ID. `assertDocument` checks
2297
+ * that every page root exists, every node is reachable from exactly one page
2298
+ * and has at most one parent, there are no cycles, and that style, variable,
2299
+ * connector, media-node and font references resolve. (`ImagePaint.assetId`
2300
+ * is not checked against the asset map.)
2301
+ */
2302
+ export interface DesignDocumentV1 {
2303
+ readonly schemaVersion: typeof CURRENT_DOCUMENT_SCHEMA_VERSION;
2304
+ readonly id: DocumentId;
2305
+ readonly title: string;
2306
+ /** Every page ID exactly once, in display order. */
2307
+ readonly pageOrder: readonly PageId[];
2308
+ readonly pages: Readonly<Record<string, Page>>;
2309
+ /** Every node on every page, keyed by `NodeId`. */
2310
+ readonly nodes: Readonly<Record<string, SceneNode>>;
2311
+ /** Images, videos and fonts, keyed by `AssetId`. */
2312
+ readonly assets: Readonly<Record<string, Asset>>;
2313
+ readonly theme: DocumentTheme;
2314
+ /**
2315
+ * Reusable layer trees, keyed by `ComponentId`. Omitted when empty. Each
2316
+ * component's layers live in `nodes` under its `rootId`, on no page.
2317
+ * @since 0.23.0
2318
+ */
2319
+ readonly components?: Readonly<Record<string, ComponentDefinition>>;
2320
+ /**
2321
+ * Comment threads, in the order they were opened. Comments are not drawn
2322
+ * by the renderer and do not change any layer.
2323
+ * @since 0.31.0
2324
+ */
2325
+ readonly commentThreads: readonly CommentThread[];
2326
+ /** Free-form JSON data kept with the document. The model does not read it. */
2327
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
2328
+ /**
2329
+ * The top-level frame set as the file's thumbnail ("Set as thumbnail"), as
2330
+ * in Figma. Omitted when none is set. It may name a layer that is no
2331
+ * longer a top-level frame (the frame was removed or moved into another
2332
+ * one); the file then has the default thumbnail. See `thumbnailFrameOf`.
2333
+ * @since 0.44.0
2334
+ */
2335
+ readonly thumbnailNodeId?: NodeId;
2336
+ }
2337
+ /**
2338
+ * A Taco Design document. Values returned by this package are deeply frozen;
2339
+ * change one with `applyOperations` or through a `DocumentStore`.
2340
+ */
2341
+ export type DesignDocument = DesignDocumentV1;
2342
+ /** True for frames and groups, the nodes that have `children`. */
2343
+ export declare const isContainerNode: (node: SceneNode) => node is ContainerNode;
2344
+ /**
2345
+ * The IDs of the stored nodes that `node` owns directly: the nodes whose
2346
+ * parent it is in the document's tree. Every walk of "the subtree this node
2347
+ * owns" (parent tables, reachability and subtree checks, copying, removing,
2348
+ * moving to a page, collecting a subtree's nodes) goes through this, so the
2349
+ * tree has one definition of ownership.
2350
+ *
2351
+ * A container owns its `children`, in order. An instance owns the slot host
2352
+ * frames listed in its `slots` map, ordered by the nested instance's path key
2353
+ * and then by slot property ID (both sorted by code unit), so a host has the
2354
+ * instance as its parent although the instance has no `children`. Every other
2355
+ * node owns nothing.
2356
+ *
2357
+ * Use `isContainerNode` instead for questions about laying out or holding
2358
+ * `children`: sizing, drop targets, insert and move targets, z-order.
2359
+ */
2360
+ export declare const ownedChildIds: (node: SceneNode) => readonly NodeId[];
2361
+ /**
2362
+ * The host IDs in `slots`, ordered by path key and then by property ID. The
2363
+ * result is cached when `slots` is frozen, as stored documents are, so
2364
+ * repeated walks over one instance do not sort again.
2365
+ */
2366
+ export declare const slotHostIdsOf: (slots: InstanceSlots) => readonly NodeId[];
2367
+ /** True for nodes that hold rich text (`TextNode`). */
2368
+ export declare const isTextualNode: (node: SceneNode) => node is TextualNode;
2369
+ export {};