@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,94 @@
1
+ import { intrinsicSize } from "../../../svg-import/structure/image.js";
2
+ import { field } from "../fields.js";
3
+ import { markImageCrop, markTile } from "../carry.js";
4
+ /** The MIME type of PNG, JPEG, GIF and WebP bytes, read from their first bytes; `undefined` for anything else. */
5
+ export function sniffImageMimeType(bytes) {
6
+ const starts = (offset, text) => bytes.length >= offset + text.length && [...text].every((char, i) => bytes[offset + i] === char.charCodeAt(0));
7
+ if (starts(0, "\x89PNG\r\n\x1a\n"))
8
+ return "image/png";
9
+ if (starts(0, "\xff\xd8\xff"))
10
+ return "image/jpeg";
11
+ if (starts(0, "GIF87a") || starts(0, "GIF89a"))
12
+ return "image/gif";
13
+ if (starts(0, "RIFF") && starts(8, "WEBP"))
14
+ return "image/webp";
15
+ return undefined;
16
+ }
17
+ export function hexText(bytes) {
18
+ return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
19
+ }
20
+ /**
21
+ * Figma's `imageScaleMode` as a Taco fit. Kiwi leaves out an enum field at its
22
+ * first value, so an absent mode is STRETCH (Figma's "Crop"). The crop
23
+ * matrix maps layer UVs to image UVs and is carried for the adapter.
24
+ */
25
+ function imageFit(paint, at) {
26
+ const mode = field(paint, "imageScaleMode", "string", at) ?? "STRETCH";
27
+ if (mode === "FILL")
28
+ return { fit: "cover" };
29
+ if (mode === "FIT")
30
+ return { fit: "contain" };
31
+ if (mode === "STRETCH") {
32
+ const m = field(paint, "transform", "object", at);
33
+ if (m === undefined)
34
+ return { fit: "fill" };
35
+ const crop = [m["m00"] ?? 1, m["m10"] ?? 0, m["m01"] ?? 0, m["m11"] ?? 1, m["m02"] ?? 0, m["m12"] ?? 0];
36
+ if (!crop.every(Number.isFinite))
37
+ return { fit: "fill", approximated: "the image crop matrix is invalid" };
38
+ const identity = [1, 0, 0, 1, 0, 0];
39
+ return crop.some((entry, i) => entry !== identity[i]) ? { fit: "fill", crop: crop } : { fit: "fill" };
40
+ }
41
+ if (mode === "TILE") {
42
+ const scale = field(paint, "scale", "number", at) ?? 1;
43
+ // Moondraft patch (../carry.ts): the tile and its scale are carried; Taco's own paint stays cover.
44
+ return { fit: "cover", tile: scale };
45
+ }
46
+ return { fit: "cover", approximated: `image scale mode ${mode} has no Taco equivalent; the image covers the box` };
47
+ }
48
+ /**
49
+ * A Figma IMAGE paint as a Taco image paint whose asset the host supplied
50
+ * (`FigmaImportOptions.images`), or a reason it is left out. `null` means it
51
+ * is left out for a reason already reported for the same image. Rotation
52
+ * and image adjustments (`paintFilter`, `filterColorAdjust`) are reported, not kept.
53
+ */
54
+ export function imagePaint(paint, at, label, walk, fill) {
55
+ const image = field(paint, "image", "object", at);
56
+ const hash = image?.["hash"];
57
+ if (!(hash instanceof Uint8Array) || hash.length === 0)
58
+ return "the image paint has no image hash";
59
+ const width = field(paint, "originalImageWidth", "number", at);
60
+ const height = field(paint, "originalImageHeight", "number", at);
61
+ const asset = walk.image(hexText(hash), width !== undefined && height !== undefined ? { width, height } : undefined);
62
+ if (asset === null || typeof asset === "string")
63
+ return asset;
64
+ const { fit, approximated, tile, crop } = imageFit(paint, at);
65
+ if (approximated)
66
+ walk.report("approximated", `${label}: ${approximated}`);
67
+ const rotation = field(paint, "rotation", "number", at) ?? 0;
68
+ if (rotation % 360 !== 0)
69
+ walk.report("approximated", `${label}: the image rotation of ${String(rotation)} degrees is not kept`);
70
+ // Kiwi has two adjustment fields (`paintFilter` and the older struct
71
+ // `filterColorAdjust`); the plugin API calls them `filters`.
72
+ const adjusted = new Set();
73
+ for (const name of ["paintFilter", "filterColorAdjust", "filters"]) {
74
+ const filters = field(paint, name, "object", at);
75
+ for (const [key, value] of Object.entries(filters ?? {})) {
76
+ if (typeof value === "number" && value !== 0)
77
+ adjusted.add(key);
78
+ }
79
+ }
80
+ if (adjusted.size > 0)
81
+ walk.report("approximated", `${label}: the image adjustments (${[...adjusted].join(", ")}) are not kept`);
82
+ const imaged = { kind: "image", assetId: asset.id, ...(fit !== "cover" ? { fit } : {}) };
83
+ if (tile !== undefined)
84
+ markTile(imaged, tile);
85
+ if (crop && fill) {
86
+ const size = intrinsicSize(asset.mimeType, asset.bytes);
87
+ const w = size?.width || width || asset.width, h = size?.height || height || asset.height;
88
+ const aspect = w && h && w > 0 && h > 0 ? w / h : undefined;
89
+ markImageCrop(imaged, { matrix: crop, ...(aspect && { aspect }) });
90
+ }
91
+ else if (crop)
92
+ walk.report("approximated", `${label}: the image crop is not kept; the whole image is stretched to the box`);
93
+ return imaged;
94
+ }
@@ -0,0 +1,33 @@
1
+ import type { FrameNode, FramedNodeBase, NodeResizing, SceneNode, StackAutoLayout, TextNode } from "../../../model/index.ts";
2
+ import { type FigmaObject } from "../fields.ts";
3
+ import type { FigmaImportReportKind } from "../types.ts";
4
+ type Report = (kind: FigmaImportReportKind, reason: string) => void;
5
+ /**
6
+ * A Figma HORIZONTAL or VERTICAL auto layout as a Taco stack, or `undefined`
7
+ * for free layout. The walk turns the stack off again unless every child in
8
+ * the flow was imported and is visible (see `stackBlocker`). An absent
9
+ * `stackPrimarySizing` hugs and an absent `stackCounterSizing` is fixed, as
10
+ * measured on real Figma files.
11
+ */
12
+ export declare function stackLayoutOf(change: FigmaObject, report: Report): StackAutoLayout | undefined;
13
+ /** `minSize` and `maxSize` as Taco size limits; Figma writes 0 for an unset limit. */
14
+ export declare function sizeLimitsOf(change: FigmaObject): NodeResizing;
15
+ /**
16
+ * The fields a child of a Figma stack gets in Taco: "Ignore auto layout"
17
+ * (`stackPositioning` ABSOLUTE) becomes `layoutPositioning`, a primary-axis
18
+ * grow becomes Fill on the main axis and `stackChildAlignSelf` STRETCH Fill on
19
+ * the cross axis. Taco has no grow weights, so any grow above 0 fills. A
20
+ * flow child loses its constraints, taken off `node` itself, as they apply
21
+ * only to absolute children.
22
+ * Upright, unlocked groups and paths in a non-wrapping stack carry Fill in
23
+ * metadata for the adapter. A line fills only its width, as its height is always 0.
24
+ *
25
+ * Figma keeps one sizing per axis, and Fill wins over the child's own Hug: a
26
+ * frame that hugs an axis, or text that sizes it to its content, shows the
27
+ * filled size there (setting Fill in Figma turns the frame's sizing to fixed
28
+ * and the text's resizing to fixed). Taco refuses a node that both fills and
29
+ * sizes to its content, so such a child gets the fill and a fixed size on that
30
+ * axis instead, and the report says so.
31
+ */
32
+ export declare function stackChildFields(change: FigmaObject, vertical: boolean, wraps: boolean, node: SceneNode, report: Report): Pick<FramedNodeBase, "layoutPositioning" | "resizing"> & Partial<Pick<TextNode, "autoResize" | "wrap"> & Pick<FrameNode, "layout">>;
33
+ export {};
@@ -0,0 +1,187 @@
1
+ import { getVectorNetworkBounds } from "../../../model/index.js";
2
+ import { carry, clearConstraints } from "../carry.js";
3
+ import { isObject } from "../fields.js";
4
+ /**
5
+ * A finite number field, or `undefined`. Figma writes NaN in some stack
6
+ * fields it does not use (seen in `stackCounterSpacing`), so a value that is
7
+ * not a finite number counts as absent instead of refusing the message.
8
+ */
9
+ function numberField(change, name) {
10
+ const value = change[name];
11
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
12
+ }
13
+ /** Looks up an enum name in `table`; `undefined` when absent, `null` when Taco has no match. */
14
+ function enumField(change, name, table) {
15
+ const value = change[name];
16
+ if (value === undefined)
17
+ return undefined;
18
+ return typeof value === "string" && Object.hasOwn(table, value) ? table[value] : null;
19
+ }
20
+ /**
21
+ * Figma's file stores the "Space between" spacing mode as SPACE_EVENLY as
22
+ * well as SPACE_BETWEEN; Figma has no space-evenly mode. Both place the first
23
+ * child at the start padding and the last at the end padding, as the child
24
+ * positions saved in real files show, so both import as `space-between`.
25
+ */
26
+ const JUSTIFY = {
27
+ MIN: "start", CENTER: "center", MAX: "end", SPACE_BETWEEN: "space-between", SPACE_EVENLY: "space-between",
28
+ };
29
+ const ALIGN = { MIN: "start", CENTER: "center", MAX: "end" };
30
+ const SIZING = { FIXED: "fixed", RESIZE_TO_FIT: "hug", RESIZE_TO_FIT_WITH_IMPLICIT_SIZE: "hug" };
31
+ /**
32
+ * A Figma HORIZONTAL or VERTICAL auto layout as a Taco stack, or `undefined`
33
+ * for free layout. The walk turns the stack off again unless every child in
34
+ * the flow was imported and is visible (see `stackBlocker`). An absent
35
+ * `stackPrimarySizing` hugs and an absent `stackCounterSizing` is fixed, as
36
+ * measured on real Figma files.
37
+ */
38
+ export function stackLayoutOf(change, report) {
39
+ const mode = change["stackMode"];
40
+ if (mode === "GRID") {
41
+ report("property-left-out", "grid auto layout is not imported yet; children keep their positions");
42
+ return undefined;
43
+ }
44
+ if (mode !== "HORIZONTAL" && mode !== "VERTICAL")
45
+ return undefined;
46
+ const vertical = mode === "VERTICAL";
47
+ const justify = enumField(change, "stackPrimaryAlignItems", JUSTIFY);
48
+ if (justify === null)
49
+ report("property-left-out", `stackPrimaryAlignItems ${String(change["stackPrimaryAlignItems"])} is not imported; children pack from the start`);
50
+ const align = enumField(change, "stackCounterAlignItems", ALIGN);
51
+ if (align === null)
52
+ report("approximated", `stackCounterAlignItems ${String(change["stackCounterAlignItems"])} is imported as start`);
53
+ const primary = enumField(change, "stackPrimarySizing", SIZING) ?? "hug";
54
+ const counter = enumField(change, "stackCounterSizing", SIZING) ?? "fixed";
55
+ // Figma's file omits a padding field that is 0, on every side: a missing
56
+ // `stackPaddingRight` or `stackPaddingBottom` is 0, not a copy of the left or
57
+ // top padding. Only the legacy single `stackPadding` stands in for all four.
58
+ const all = numberField(change, "stackPadding") ?? 0;
59
+ const left = numberField(change, "stackHorizontalPadding") ?? all;
60
+ const top = numberField(change, "stackVerticalPadding") ?? all;
61
+ const wrapGap = numberField(change, "stackCounterSpacing");
62
+ return {
63
+ kind: vertical ? "vertical" : "horizontal",
64
+ gap: numberField(change, "stackSpacing") ?? 0,
65
+ padding: { left, right: numberField(change, "stackPaddingRight") ?? all, top, bottom: numberField(change, "stackPaddingBottom") ?? all },
66
+ align: align ?? "start",
67
+ justify: justify ?? "start",
68
+ ...(change["stackWrap"] === "WRAP"
69
+ ? { wrap: true, ...(wrapGap === undefined ? {} : { wrapGap }), ...(change["stackCounterAlignContent"] === "SPACE_BETWEEN" ? { alignContent: "space-between" } : {}) }
70
+ : {}),
71
+ widthSizing: vertical ? counter : primary,
72
+ heightSizing: vertical ? primary : counter,
73
+ };
74
+ }
75
+ /** `minSize` and `maxSize` as Taco size limits; Figma writes 0 for an unset limit. */
76
+ export function sizeLimitsOf(change) {
77
+ const limit = (name, axis) => {
78
+ const box = change[name];
79
+ const value = isObject(box) && isObject(box["value"]) ? numberField(box["value"], axis) : undefined;
80
+ return value !== undefined && value > 0 ? value : undefined;
81
+ };
82
+ const entries = [
83
+ ["minWidth", limit("minSize", "x")], ["maxWidth", limit("maxSize", "x")],
84
+ ["minHeight", limit("minSize", "y")], ["maxHeight", limit("maxSize", "y")],
85
+ ];
86
+ return Object.fromEntries(entries.filter(([, value]) => value !== undefined));
87
+ }
88
+ /**
89
+ * The fields a child of a Figma stack gets in Taco: "Ignore auto layout"
90
+ * (`stackPositioning` ABSOLUTE) becomes `layoutPositioning`, a primary-axis
91
+ * grow becomes Fill on the main axis and `stackChildAlignSelf` STRETCH Fill on
92
+ * the cross axis. Taco has no grow weights, so any grow above 0 fills. A
93
+ * flow child loses its constraints, taken off `node` itself, as they apply
94
+ * only to absolute children.
95
+ * Upright, unlocked groups and paths in a non-wrapping stack carry Fill in
96
+ * metadata for the adapter. A line fills only its width, as its height is always 0.
97
+ *
98
+ * Figma keeps one sizing per axis, and Fill wins over the child's own Hug: a
99
+ * frame that hugs an axis, or text that sizes it to its content, shows the
100
+ * filled size there (setting Fill in Figma turns the frame's sizing to fixed
101
+ * and the text's resizing to fixed). Taco refuses a node that both fills and
102
+ * sizes to its content, so such a child gets the fill and a fixed size on that
103
+ * axis instead, and the report says so.
104
+ */
105
+ export function stackChildFields(change, vertical, wraps, node, report) {
106
+ if (change["stackPositioning"] === "ABSOLUTE")
107
+ return { layoutPositioning: "absolute" };
108
+ // Constraints act on a flow child neither in Figma nor in Taco, so the child keeps none.
109
+ clearConstraints(node);
110
+ const grow = numberField(change, "stackChildPrimaryGrow") ?? 0;
111
+ const alignSelf = change["stackChildAlignSelf"];
112
+ const stretch = alignSelf === "STRETCH";
113
+ if (alignSelf !== undefined && alignSelf !== "AUTO" && !stretch) {
114
+ report("property-left-out", `stackChildAlignSelf ${String(alignSelf)} is not imported; the child follows the frame's alignment`);
115
+ }
116
+ const fillMain = grow > 0;
117
+ const line = node.type === "shape" && node.shape === "line";
118
+ const fillHeight = vertical ? fillMain : stretch;
119
+ if (fillHeight && line) {
120
+ report("approximated", `${vertical ? `stackChildPrimaryGrow ${String(grow)}` : "stackChildAlignSelf STRETCH"} is not imported as Fill on the height; a line's height is always 0`);
121
+ }
122
+ const fill = {
123
+ ...((vertical ? stretch : fillMain) ? { width: "fill" } : {}),
124
+ ...(fillHeight && !line ? { height: "fill" } : {}),
125
+ };
126
+ if (fill.width === undefined && fill.height === undefined)
127
+ return {};
128
+ const carried = node.type === "group" || (node.type === "shape" && node.shape === "path");
129
+ if (carried) {
130
+ const turned = node.type === "group" ? Math.abs(node.rotation ?? 0) > 1e-4 :
131
+ Math.abs(node.transform[1]) > 1e-6 || Math.abs(node.transform[2]) > 1e-6 ||
132
+ (node.transform[0] < 0 && node.transform[3] < 0);
133
+ const reason = wraps ? "wrapping stacks require line sizing and breaks to agree" :
134
+ turned ? "rotated geometry needs fill sizing in parent axes" :
135
+ node.aspectRatioLocked ? "aspect-locked fill needs to preserve the ratio across both axes" : undefined;
136
+ if (reason) {
137
+ report("property-left-out", `${node.type === "group" ? "group" : "path"} Fill is left out: ${reason}`);
138
+ return {};
139
+ }
140
+ if (node.type === "shape") {
141
+ // A flat outline cannot grow by scaling on its empty axis. Let other fill
142
+ // children share that space, and keep any fill along the outline itself.
143
+ const bounds = getVectorNetworkBounds(node.vectorNetwork, node.transform);
144
+ for (const axis of ["width", "height"]) {
145
+ if (fill[axis] && !bounds?.[axis]) {
146
+ delete fill[axis];
147
+ report("property-left-out", `path Fill is left out on the ${axis} because its outline has zero extent there`);
148
+ }
149
+ }
150
+ if (!fill.width && !fill.height)
151
+ return {};
152
+ }
153
+ }
154
+ if ((vertical ? fill.height : fill.width) && grow !== 1) {
155
+ report("approximated", `stackChildPrimaryGrow ${String(grow)} is imported as Fill; Taco has no grow weights`);
156
+ }
157
+ if (carried) {
158
+ const limits = node.type === "shape" ? sizeLimitsOf(change) : {};
159
+ carry(node, { fillSizing: { ...limits, ...fill } });
160
+ return {};
161
+ }
162
+ const resizing = "resizing" in node ? node.resizing : undefined;
163
+ return { resizing: { ...resizing, ...fill }, ...fixedWhereFilled(node, fill, report) };
164
+ }
165
+ /** The text resizing or frame sizing that lets `node` fill the axes `fill` names, as Figma shows it. */
166
+ function fixedWhereFilled(node, fill, report) {
167
+ const fillWidth = fill.width === "fill";
168
+ const fillHeight = fill.height === "fill";
169
+ if (node.type === "text") {
170
+ const autoResize = fillHeight ? "none" : fillWidth && node.autoResize === "width-and-height" ? "height" : node.autoResize;
171
+ if (autoResize === node.autoResize)
172
+ return {};
173
+ const axes = fillHeight ? "height" : "width";
174
+ report("approximated", `text that sizes its ${axes} to its content fills its ${axes} in its auto layout parent; it is imported with ${autoResize === "none" ? "a fixed size" : "auto height"}, as Figma shows it`);
175
+ return { autoResize, ...(node.autoResize === "width-and-height" ? { wrap: "word" } : {}) };
176
+ }
177
+ if (node.type !== "frame" || node.layout.kind === "absolute")
178
+ return {};
179
+ const layout = node.layout;
180
+ const width = fillWidth && layout.widthSizing === "hug";
181
+ const height = fillHeight && layout.heightSizing === "hug";
182
+ if (!width && !height)
183
+ return {};
184
+ const axes = width && height ? "width and height" : width ? "width" : "height";
185
+ report("approximated", `a frame that hugs its ${axes} fills it in its auto layout parent; it is imported with a fixed ${axes}, as Figma shows it`);
186
+ return { layout: { ...layout, ...(width ? { widthSizing: "fixed" } : {}), ...(height ? { heightSizing: "fixed" } : {}) } };
187
+ }
@@ -0,0 +1,11 @@
1
+ import type { FigmaNodeConverter } from "../walk.ts";
2
+ /**
3
+ * A Figma LINE as a Taco path of one segment from (0, 0) to (size.x, 0) in
4
+ * the node's own space, placed by its `transform` as `convertVector` places
5
+ * a VECTOR. A LINE of length 0 or with no strokes is still imported, as
6
+ * Figma keeps it; one with no length (`size.x`) is left out. Both ends take
7
+ * the node's `strokeCap`. Figma draws a LINE's stroke centred whatever its
8
+ * `strokeAlign`, so the strokes are centred. A LINE that fills its auto
9
+ * layout parent becomes a Taco line instead (`lineWhereItFills`).
10
+ */
11
+ export declare const convertLine: FigmaNodeConverter;
@@ -0,0 +1,40 @@
1
+ import { getVectorNetworkBounds, vectorSegmentId, vectorVertexId } from "../../../model/index.js";
2
+ import { field } from "../fields.js";
3
+ import { nodeEffects } from "./effects.js";
4
+ import { layerBase } from "./shared.js";
5
+ import { lineWhereItFills, pathStrokes, pathTransform } from "./vector.js";
6
+ /**
7
+ * A Figma LINE as a Taco path of one segment from (0, 0) to (size.x, 0) in
8
+ * the node's own space, placed by its `transform` as `convertVector` places
9
+ * a VECTOR. A LINE of length 0 or with no strokes is still imported, as
10
+ * Figma keeps it; one with no length (`size.x`) is left out. Both ends take
11
+ * the node's `strokeCap`. Figma draws a LINE's stroke centred whatever its
12
+ * `strokeAlign`, so the strokes are centred. A LINE that fills its auto
13
+ * layout parent becomes a Taco line instead (`lineWhereItFills`).
14
+ */
15
+ export const convertLine = (node, walk) => {
16
+ const where = `node ${node.id}`;
17
+ const transform = pathTransform(node, walk);
18
+ if (transform === null)
19
+ return null;
20
+ const size = field(node.change, "size", "object", where);
21
+ const length = size && field(size, "x", "number", `${where} size`);
22
+ if (length === undefined) {
23
+ walk.report("node-left-out", "the node has no length");
24
+ return null;
25
+ }
26
+ const start = vectorVertexId("v0"), end = vectorVertexId("v1");
27
+ const network = {
28
+ vertices: [{ id: start, x: 0, y: 0 }, { id: end, x: length, y: 0 }],
29
+ segments: [{ id: vectorSegmentId("s0"), kind: "line", start, end }],
30
+ regions: [],
31
+ };
32
+ const base = layerBase(node, walk, "Line", true);
33
+ const { strokes: aligned, cap } = pathStrokes(node, walk, getVectorNetworkBounds(network) ?? undefined);
34
+ const strokes = aligned.map((stroke) => ({ ...stroke, position: "center" }));
35
+ const path = {
36
+ ...base, type: "shape", shape: "path", vectorNetwork: network, transform,
37
+ style: { ...(strokes.length > 0 ? { strokes } : {}), ...nodeEffects(node, walk) }, startCap: cap, endCap: cap,
38
+ };
39
+ return lineWhereItFills(path, node.change);
40
+ };
@@ -0,0 +1,3 @@
1
+ import type { FigmaNodeConverter } from "../walk.ts";
2
+ /** A plain or rounded Figma rectangle as a Taco rectangle. */
3
+ export declare const convertRectangle: FigmaNodeConverter;
@@ -0,0 +1,11 @@
1
+ import { drawnAsPlainRectangle, nodeEffects } from "./effects.js";
2
+ import { framedBase, visualStyle } from "./shared.js";
3
+ /** A plain or rounded Figma rectangle as a Taco rectangle. */
4
+ export const convertRectangle = (node, walk) => {
5
+ const base = framedBase(node, walk, "Rectangle", true);
6
+ if (base === null)
7
+ return null;
8
+ const visual = visualStyle(node, walk);
9
+ const rectangle = { ...base, type: "shape", shape: "rectangle", style: { ...visual, ...nodeEffects(node, walk, drawnAsPlainRectangle(visual, false)) } };
10
+ return rectangle;
11
+ };
@@ -0,0 +1,8 @@
1
+ import type { FigmaNodeConverter } from "../walk.ts";
2
+ /**
3
+ * A Figma SECTION as a Taco frame with free layout. Sections never clip
4
+ * their content in Figma, so `clipContent` is false and `frameMaskDisabled`
5
+ * is ignored. `sectionContentsHidden` (collapsed contents) is reported.
6
+ * Moondraft imports section status from the original Figma nodes.
7
+ */
8
+ export declare const convertSection: FigmaNodeConverter;
@@ -0,0 +1,29 @@
1
+ import { field } from "../fields.js";
2
+ import { drawnAsPlainRectangle, nodeEffects } from "./effects.js";
3
+ import { framedBase, visualStyle } from "./shared.js";
4
+ /**
5
+ * A Figma SECTION as a Taco frame with free layout. Sections never clip
6
+ * their content in Figma, so `clipContent` is false and `frameMaskDisabled`
7
+ * is ignored. `sectionContentsHidden` (collapsed contents) is reported.
8
+ * Moondraft imports section status from the original Figma nodes.
9
+ */
10
+ export const convertSection = (node, walk) => {
11
+ const where = `node ${node.id}`;
12
+ if (field(node.change, "sectionContentsHidden", "boolean", where) === true) {
13
+ walk.report("property-left-out", "sectionContentsHidden is not imported; the contents are shown");
14
+ }
15
+ const base = framedBase(node, walk, "Section", true);
16
+ if (base === null)
17
+ return null;
18
+ const visual = visualStyle(node, walk);
19
+ const style = { ...visual, ...nodeEffects(node, walk, drawnAsPlainRectangle(visual, true)) };
20
+ const frame = {
21
+ ...base,
22
+ type: "frame",
23
+ children: walk.convertChildren(),
24
+ layout: { kind: "absolute" },
25
+ clipContent: false,
26
+ ...(Object.keys(style).length > 0 ? { style } : {}),
27
+ };
28
+ return frame;
29
+ };
@@ -0,0 +1,71 @@
1
+ import { type BlendMode, type FramedNodeBase, type NodeBase, type Paint, type DashCap, type ResizeConstraints, type Stroke, type VisualStyle } from "../../../model/index.ts";
2
+ import type { StrokeCap } from "../../../model/types.ts";
3
+ import { type FigmaObject } from "../fields.ts";
4
+ import { type PaintBounds } from "./gradient.ts";
5
+ import type { FigmaTreeNode } from "../tree.ts";
6
+ import type { NodeWalk } from "../walk.ts";
7
+ /**
8
+ * A Figma blend mode enum name as a Taco blend mode: `undefined` for
9
+ * `NORMAL` and `PASS_THROUGH` (Taco's default), `null` when Taco has no such
10
+ * mode (`LINEAR_BURN`, `LINEAR_DODGE`).
11
+ */
12
+ export declare function blendModeOf(value: string): BlendMode | undefined | null;
13
+ export declare function readNumbers<K extends string>(object: FigmaObject, keys: readonly K[], where: string): Record<K, number> | null;
14
+ /** `#rrggbb`, or `#rrggbbaa` when alpha is below 1, from Figma's 0..1 channels. */
15
+ export declare function hexColor(color: Record<"r" | "g" | "b" | "a", number>): string;
16
+ /**
17
+ * The fields every Taco layer shares (id, name, visibility, lock, opacity and
18
+ * blend mode, the mask flag, the aspect ratio lock and resize constraints, see `constraintsOf`).
19
+ * Reports a blend mode Taco lacks, a mask that is not an alpha mask and, unless the
20
+ * caller imports them (`effectsImported`), effects, which are not imported yet.
21
+ */
22
+ export declare function layerBase(node: FigmaTreeNode, walk: NodeWalk, defaultName: string, effectsImported?: boolean): NodeBase;
23
+ /**
24
+ * Figma's `horizontalConstraint` and `verticalConstraint` as Taco
25
+ * `constraints`, or `undefined` when both are MIN (or absent), Taco's
26
+ * default. A value Taco has no match for (such as FIXED_MIN) is reported and
27
+ * read as MIN. They are taken off again where they do not apply: from a
28
+ * group (carried in its metadata) by `convertGroup`, from a child in an auto layout flow by
29
+ * `stackChildFields`, and from a layer in a section (directly or through
30
+ * groups) by the walk, as Figma applies none when a section is resized.
31
+ */
32
+ export declare function constraintsOf(change: FigmaObject, report: NodeWalk["report"]): ResizeConstraints | undefined;
33
+ /** A node's size and transform numbers, or `null` when either is incomplete, so `framedBase` leaves the node out. */
34
+ export declare function frameGeometry(node: FigmaTreeNode): {
35
+ sides: Record<"x" | "y", number>;
36
+ m: Record<"m00" | "m01" | "m02" | "m10" | "m11" | "m12", number>;
37
+ } | null;
38
+ /**
39
+ * The fields every framed Taco node shares, or `null` after reporting why
40
+ * the node is left out. Figma's `transform` maps the node's local space to
41
+ * its parent's (x' = m00 x + m01 y + m02, y' = m10 x + m11 y + m12); Taco
42
+ * keeps the unrotated frame plus a rotation about its center, clockwise in
43
+ * degrees, and a horizontal flip when the matrix mirrors.
44
+ */
45
+ export declare function framedBase(node: FigmaTreeNode, walk: NodeWalk, defaultName: string, effectsImported?: boolean): FramedNodeBase | null;
46
+ /**
47
+ * The solid, gradient and image paints of the node's `fillPaints` or `strokePaints`
48
+ * list, named `fill` or `stroke` in report entries; other paint types are
49
+ * reported and left out. A node that names a fill or stroke style takes the
50
+ * style's paints (`styleBackedList`). `node` may also be a style override entry, with `id`
51
+ * saying where it is; its `change` must then carry the node's `size` for gradients.
52
+ * Figma places a gradient on the node's box (`size`); `box`, in node pixels,
53
+ * is the box the renderer places it on instead when that differs, such as a
54
+ * vector region's bounds.
55
+ */
56
+ export declare function nodePaints(node: Pick<FigmaTreeNode, "id" | "change">, walk: NodeWalk, list: "fillPaints" | "strokePaints", box?: PaintBounds, source?: readonly unknown[]): Paint[];
57
+ /** Figma's `strokeCap` names Taco has, as path ends and dash ends alike. */
58
+ export declare const STROKE_CAPS: Readonly<Record<string, DashCap>>;
59
+ /** Figma's vector endpoint styles, including heads that dashes cannot use. */
60
+ export declare function endCapOf(value: unknown): StrokeCap | undefined;
61
+ /**
62
+ * Stroke paints with the node's weight, alignment, join, miter limit and
63
+ * dashes, gradients placed on `box` (the node's box when left out). Kiwi
64
+ * leaves out an enum field at its first value, so an absent `strokeAlign` is
65
+ * CENTER, an absent `strokeJoin` MITER and an absent `strokeCap` NONE.
66
+ * `sides` reads Figma's separate side weights, which only rectangles and
67
+ * frames have. A dashed stroke's dash ends follow `strokeCap`, as in Figma.
68
+ */
69
+ export declare function nodeStrokes(node: FigmaTreeNode, walk: NodeWalk, box?: PaintBounds, sides?: boolean): Stroke[];
70
+ /** Solid, gradient and image fills and strokes and corners as a Taco style; other paint types are reported and left out. */
71
+ export declare function visualStyle(node: FigmaTreeNode, walk: NodeWalk): VisualStyle;