@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 — 2026-11-27
4
+
5
+ ### Highlights
6
+
7
+ - Imports keep text hyperlinks, OpenType features, layout grids, per-layer export settings and variable scopes.
8
+ - Instance overrides resolve through nested swaps, and imports of large Figma files are faster and use less memory.
9
+
10
+ ### Added
11
+
12
+ - Import text hyperlinks, OpenType feature toggles and variants, text truncation and line limits, and text colour
13
+ bindings and paint-style links.
14
+ - Import frame layout grids and grid styles, per-layer export settings, boolean operations, page dividers, canvas
15
+ stacking, image fill crops, flipped instances, legacy rectangles, variable font axes and handoff metadata.
16
+ - Keep variable scopes, code syntax and descriptions, independent stroke-side and corner bindings, vector region
17
+ fills, and caps on every open vector end. Open vector networks are filled.
18
+ - Instances keep overrides for clipping, corner smoothing and auto layout.
19
+
20
+ ### Changed
21
+
22
+ - The peer dependency on `@moondraft/editor` is now `>=0.4.0 <0.5.0`. Install the editor 0.4.0 or later in the
23
+ 0.4 line.
24
+ - Import reports group repeated entries.
25
+ - Large Figma imports run in about half the time and use less memory.
26
+
27
+ ### Fixed
28
+
29
+ - Import angle-based linear gradients again, and prop overrides only on nested instances.
30
+ - Resolve overrides through nested instance swaps and report swaps that the nesting check rejects.
31
+
32
+ ## 0.1.0
33
+
34
+ - Import SVG files and markup, and Figma clipboard content, as editable layers.
35
+ - Import saved Figma design files with public pages, components, variant sets, component properties, variables, modes, shared styles and images.
36
+ - Report conversion losses and requested font faces. Saved Figma design files support progress and cancellation.
package/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ @moondraft/editor licence
2
+
3
+ Copyright (c) 2026 Luyu Cheng. All rights reserved.
4
+
5
+ 1. Grant. Subject to the terms below, you are granted a non-exclusive,
6
+ non-transferable, revocable licence to install the unmodified package from
7
+ the npm registry and to use it as a dependency of your own applications.
8
+
9
+ 2. Restrictions. You may not:
10
+ (a) redistribute the package, or any of its files, on their own (shipping
11
+ them inside the build of your own application is permitted);
12
+ (b) modify, decompile, disassemble or reverse engineer the WebAssembly
13
+ module (scene_renderer.wasm) or its loader, except that bundlers,
14
+ minifiers and other build tools may copy, rename and transform the
15
+ package's files as part of building your own application;
16
+ (c) extract the package or any part of it to build a competing editor or
17
+ renderer;
18
+ (d) sublicense the package or any rights in it.
19
+
20
+ 3. No warranty. THE PACKAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+
24
+ 4. Limitation of liability. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
25
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ PACKAGE OR THE USE OR OTHER DEALINGS IN THE PACKAGE.
28
+
29
+ 5. Termination. This licence ends automatically if you breach any of its
30
+ terms. On termination you must stop using the package and delete all
31
+ copies of it.
32
+
33
+ 6. Other licences. For any use not covered here, open an issue or contact the
34
+ author.
package/README.md CHANGED
@@ -1,3 +1,37 @@
1
- # Temporary Holding Version
1
+ # @moondraft/import
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Editable SVG and Figma import for Moondraft. This package uses the public API of `@moondraft/editor` 0.3.
4
+
5
+ ```sh
6
+ npm install @moondraft/editor@0.3 @moondraft/import@0.1
7
+ ```
8
+
9
+ Register the importers when you create your browser editor. Use your canvas container and your app's font provider. Pass a `.fig` file from a picker to append its pages.
10
+
11
+ ```ts
12
+ import { createEditor } from '@moondraft/editor'
13
+ import { figmaImporter, svgImporter } from '@moondraft/import'
14
+
15
+ const editor = createEditor({ container, fonts, importers: [svgImporter(), figmaImporter()] })
16
+ await editor.ready
17
+
18
+ const result = await editor.import(file, { as: 'pages' })
19
+ console.log(result?.report)
20
+ ```
21
+
22
+ SVG markup, SVG files and Figma clipboard HTML produce layer payloads. A saved Figma design file produces a document with its public pages, shared components and image assets. Use `editor.import(file, { as: 'document' })` to open it directly.
23
+
24
+ To convert a saved Figma design in Node, save this as `convert.mjs` and run `node convert.mjs` beside `design.fig`.
25
+
26
+ ```js
27
+ import { readFile, writeFile } from 'node:fs/promises'
28
+ import { openFigmaFile, serializeImportDocument } from '@moondraft/import'
29
+
30
+ const { document, report } = await openFigmaFile(await readFile('design.fig'))
31
+ await writeFile('design.json', serializeImportDocument(document))
32
+ console.log(report)
33
+ ```
34
+
35
+ In Node, `runImport` from `@moondraft/editor/core` can also select a registered importer. Supply `svgImporter({ parseSvg })` with an XML parser that returns the SVG root element. Host importers can use `payloadFromSyntax(text)` to create paste payloads from the agent build tool's layer syntax.
36
+
37
+ See [CHANGELOG.md](CHANGELOG.md) for releases, [SOURCE.md](SOURCE.md) for reader provenance and [LICENSE](LICENSE) for licensing.
package/SOURCE.md ADDED
@@ -0,0 +1,394 @@
1
+ # Where this package's code comes from
2
+
3
+ `src/taco/` and `test/taco/` are copies of the user's own taco importers. They are not edited here except for the
4
+ mechanical rewrites and the local patches listed below. Fix things in taco and sync, or add a patch and log it here.
5
+
6
+ ## Source
7
+
8
+ - Repository: taco-slides (`/Volumes/Blobs/Foreman/taco-slides/main`), `packages/svg-import`, `packages/figma-import`
9
+ and `packages/model`. Their `package.json` `repository` fields point to `github.com/chengluyu/design-core`.
10
+ - Package version: **0.25.1** (all three). Model schema version 0.44.0.
11
+ - Source commit: **b67cd597088c2ebc67f9a1abfcb659e023203b75** (`main`), synced 2026-11-18.
12
+ - The source has no LICENSE file. It is the user's own code, copied with their consent (see `docs/import-plan.md`,
13
+ "Licensing and provenance"). The copied readers are distributed under the license in `LICENSE` with the owner’s consent.
14
+
15
+ ## What is copied
16
+
17
+ | From (under `packages/`) | To (under `packages/import/`) |
18
+ | --- | --- |
19
+ | `svg-import/src` | `src/taco/svg-import` |
20
+ | `figma-import/src` | `src/taco/figma-import` |
21
+ | `svg-import/test` (with `samples/`) | `test/taco/svg-import` |
22
+ | `figma-import/test` | `test/taco/figma-import` |
23
+ | `model/src`: only the files reachable from what the importers and their tests use | `src/taco/model` |
24
+ | `model/THIRD_PARTY_NOTICES.md` | `src/taco/model/THIRD_PARTY_NOTICES.md` |
25
+
26
+ At this commit the model part is 71 of the model's 109 source files (40,583 lines). It includes every file reached by
27
+ any import, type-only ones too, because `tsc` needs them. The model's own `index.ts` and tests are not copied.
28
+
29
+ Not copied: `dist/`, `api-report.txt`, the READMEs, figma-import's `tools/` (browser measurement scripts) and the
30
+ taco `tsconfig.json` files.
31
+
32
+ ## Sync
33
+
34
+ ```sh
35
+ node packages/import/scripts/sync-taco.mjs [taco-packages-dir]
36
+ ```
37
+
38
+ The script deletes `src/taco` and `test/taco`, copies the files again, makes the rewrites below and then applies
39
+ `patches/*.patch` in sorted filename order with `git apply`. On an unchanged source the tree comes out the same as
40
+ before. If a patch no longer applies, the sync stops there. Update the patch and this log.
41
+
42
+ At merge time, give each new patch the next free number after the last patch on `main` and update this log.
43
+ Before merging, run the sync in a clean checkout against the pinned source commit. The replay must succeed and
44
+ reproduce the checked-in `src/taco/` and `test/taco/` byte for byte, with no missing or extra files.
45
+
46
+ ### Mechanical rewrites (made by the script, not patches)
47
+
48
+ 1. Relative specifiers `"./x.js"` and `"../x.js"` become `.ts`. Node runs the sources directly, and `tsc`
49
+ (`rewriteRelativeImportExtensions`) writes `.js` back.
50
+ 2. `"@taco-design/model"` becomes a relative path to `src/taco/model/index.ts`. That file is generated: it
51
+ re-exports the 156 model symbols that the importers and their tests name, from the model files that define them.
52
+ Only named imports and re-exports are supported, and the script stops on anything else.
53
+ 3. In the tests, `"../src/..."` points at `src/taco/<importer>/...`.
54
+ 4. In svg-import's tests, sample paths written for `dist/test/*.js` (`fileURLToPath(import.meta.url)), "..", "..",
55
+ "test", "samples"`) point at the `samples/` folder copied next to the tests.
56
+
57
+ ## Local patches
58
+
59
+ Quoted patch numbers in copied test markers retain the numbers used when those tests were written.
60
+
61
+ ### `patches/0001-parameter-properties-as-fields.patch`
62
+
63
+ This repo compiles with `erasableSyntaxOnly`, and Node's type stripping refuses TypeScript parameter properties
64
+ (`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`, TS1294). Each one is rewritten by hand as a declared field and an assignment in
65
+ the constructor. The behaviour is the same: the same fields, assigned before the rest of the constructor body (in
66
+ `extends Error` classes, just after `super`). Optional parameters become fields typed `T | undefined` that are
67
+ always assigned, as a parameter property would be. The 36 parameters, in 19 classes:
68
+
69
+ | File | Class | Fields |
70
+ | --- | --- | --- |
71
+ | `src/taco/figma-import/container/compression.ts` | `OutputCollector` | `format`, `offset`, `maxBytes` |
72
+ | `src/taco/figma-import/import/converters/vector.ts` | `GeometryRefused` | `problem` |
73
+ | `src/taco/figma-import/import/converters/vectorNetwork.ts` | `NetworkRefused` | `problem` |
74
+ | `src/taco/model/codec.ts` | `ModelError` | `code`, `path` |
75
+ | `src/taco/model/component-expressions.ts` | `NodeEdits` | `document` |
76
+ | `src/taco/model/component-validity.ts` | `CombinationSearch` | `component` |
77
+ | `src/taco/model/expressions/check.ts` | `Checker` | `environment` |
78
+ | `src/taco/model/expressions/evaluate.ts` | `Evaluator` | `environment` |
79
+ | `src/taco/model/expressions/parser.ts` | `Parser` | `tokens` |
80
+ | `src/taco/model/layer-syntax.ts` | `LayerSyntaxError` | `missingLayerId` |
81
+ | `src/taco/model/new-nodes.ts` | `InstanceBuildError` | `kind`, `componentId`, `propertyId` |
82
+ | `src/taco/model/node-builder.ts` | `NodeBuildError` | `kind`, `line`, `column`, `call`, `accepted` |
83
+ | `src/taco/model/node-builder.ts` | `ShortArgumentError`, `ComponentCallError` | `argument`; `at` |
84
+ | `src/taco/model/operations.ts` | `BatchParents` | `nodes`, `readBase` |
85
+ | `src/taco/model/operations.ts` | `PageNotRemovableError` | `pages` |
86
+ | `src/taco/model/parent-table.ts` | `DerivedParents` | `base`, `differences`, `depth` |
87
+ | `test/taco/svg-import/xml.ts` | `XmlElementNode` | `qname`, `localName`, `namespaceURI`, `nsScope`, `attributes`, `startPos` |
88
+ | `test/taco/svg-import/xml.ts` | `Scanner` | `source` |
89
+
90
+ The plan counted 37 sites over the whole model: 32 in the model and 5 in figma-import. 24 of the model's are in the
91
+ copied files, so 29 in the sources. The test helper `xml.ts` adds 7 that the plan's count missed: they only fail
92
+ when Node strips the tests, which taco compiles instead.
93
+
94
+ ### `patches/0002-figma-carries.patch`
95
+
96
+ What Figma has, Moondraft draws and taco's model has no field for. figma-import now carries it in the layer's
97
+ `metadata.figma` (any JSON, which the model keeps), and the adapter (`src/adapter/convert.ts`) reads it. The new file
98
+ `src/taco/figma-import/import/carry.ts` holds the helpers and describes each key. Taco's own output is unchanged
99
+ apart from this metadata.
100
+
101
+ | What | Where | Carried as | Report change |
102
+ | --- | --- | --- | --- |
103
+ | A drop shadow with `showShadowBehindNode` | `converters/effects.ts` marks the shadow; `walk.ts` writes the marks after each converter | `shadowBehind: [index in style.shadows]` (the adapter knocks out the other drop shadows, as Figma does) | "Figma hides the shadow behind the node's see-through fill; Taco shows it" is gone: Moondraft hides it |
104
+ | An image fill with `imageScaleMode` TILE | `converters/image.ts` marks the paint; `converters/shared.ts` moves the mark to the placed copy | `tiles: [[index in style.fills, scale]]` (the paint stays cover) | "tiling at scale N has no Taco equivalent" is gone |
105
+ | An outline mask (`maskType` OUTLINE or `maskIsOutline`) | `converters/shared.ts` (`layerBase`) | `maskType: "vector"` | "the outline mask is imported as an alpha mask" is gone; a luminance mask is still reported |
106
+ | STAR and REGULAR_POLYGON | `walk.ts` converter table; `convertStarOrPolygon` in `converters/vector.ts` converts it as a VECTOR (its `fillGeometry` or `vectorData`) | `shape: { type: "star", count, ratio, width, height }` or `{ type: "polygon", count, width, height }` (`ratio` is `starInnerScale`, default 0.382; the box is the node's `size`) | They were left out ("not imported yet") |
107
+
108
+ `hasOpaqueFill` in `effects.ts` is removed with the report that used it. In `variantTrees.ts`, `metadata` does not
109
+ split a layer when variants are merged into one component (the merged layer keeps the first variant's): on the
110
+ HeroUI kit file, differing carries split 4 layers before this.
111
+
112
+ Changed expectations in the copied tests, each marked "Moondraft patch 0002":
113
+
114
+ - `convert-effects.test.ts`: a drop shadow behind no fill or a see-through fill reports nothing; a new test checks
115
+ `shadowBehind`.
116
+ - `convert-image-fill.test.ts`: the TILE row reports nothing; a new test checks `tiles`.
117
+ - `convert-group.test.ts`: the two outline mask rows report nothing and check `maskType`.
118
+ - `convert-vector.test.ts`: new tests for STAR and REGULAR_POLYGON.
119
+ - `variant-trees.test.ts`: a new test for metadata in a variant merge.
120
+ - `convert-auto-layout.test.ts`, `convert-frame-rect.test.ts`, `convert-group.test.ts`, `tree.test.ts`: the node type
121
+ with no converter is now STICKY (a FigJam type) instead of STAR.
122
+
123
+ ### `patches/0003-importer-placements.patch`
124
+
125
+ The sync script applies these five local changes after the earlier patches.
126
+
127
+ | File | Reason |
128
+ | --- | --- |
129
+ | `src/taco/figma-import/import/types.ts` | Expose the reader's root selection mode and component placements to the adapter. |
130
+ | `src/taco/figma-import/import/walk.ts` | Return that mode and associate on-page component placements with their definitions. |
131
+ | `src/taco/svg-import/shapes/shapes.ts` | Export the rectangular frame placement helper for nested viewports. |
132
+ | `src/taco/svg-import/structure/walk.ts` | Build nested SVGs as clipping viewports and carry the remaining skew or reflection to the adapter for child geometry. |
133
+ | `test/taco/svg-import/rules-report.test.ts` | Remove the expectation that nested SVG is unsupported. |
134
+
135
+ ### `patches/0004-affine-svg-raster-images.patch`
136
+
137
+ The SVG reader uses an image-filled rectangular path when an invertible transform skews a raster image or
138
+ would change its aspect-ratio fit. The path and its paint share the image's original rectangle and transform.
139
+
140
+ ### `patches/0005-linear-gradient-endpoints.patch`
141
+
142
+ The SVG and Figma linear-gradient converters retain the original stops and unit-box endpoints for on-canvas editing. Under a shear, the axis follows the transformed gradient normal in local pixels. Layer gradients require both endpoints. For flat SVG geometry the importer preserves the gradient slope and offset along the surviving axis. A flat shape perpendicular to the gradient takes the colour sampled at its position. Layer syntax resolves an authored CSS angle when the owning layer supplies its paint box. The gradient expectations in the copied tests use the endpoint representation.
143
+
144
+ ### `patches/0006-portable-font-style.patch`
145
+
146
+ Carry the original Figma face style name through the intermediate text style and its codec into editor text palettes.
147
+
148
+ ### `patches/0007-native-figma-file.patch`
149
+
150
+ The saved-file adapter reads each original variant tree, property declaration, variable alias and style definition before conversion to literals. The reader carries the source paint and effect indexes, font-size bindings and authored override paths needed to associate those definitions with their native layer fields. The reader checks reachable variable values for copied paint alpha and valid text metrics. An explicit instance paint also replaces its inherited style reference. Unpublished resources reuse the model’s synchronous SHA-256 implementation, extended to accept file bytes. Clipboard imports continue to use the literal reader.
151
+
152
+ ### `patches/0008-report-noise.patch`
153
+
154
+ Fewer repeated report entries from component property defs. A deleted def (Figma keeps an id alone, or an id that
155
+ points at a removed set def) is skipped without a report instead of being reported as an unknown property type. A
156
+ def's dropped preferred values are reported for the first symbol that reads it only, not again for each variant of
157
+ its set: `propertiesOf` takes a set of reported defs that the walk shares across symbols. Two tests in the copied
158
+ `convert-instance.test.ts` cover this, each marked "Moondraft patch 0007".
159
+
160
+ ### `patches/0009-text-truncation.patch`
161
+
162
+ Figma's ending truncation becomes the text's `truncate: "ellipsis"`, and its line limit `maxLines`. A fixed-size box without a limit ends at the lines its height holds. Instance overrides carry both; `null` takes the component's away. The intermediate text node and layer override gain the two optional fields, which the codec checks and the instance resolver applies.
163
+
164
+
165
+ ### `patches/0010-repeated-collection-names.patch`
166
+
167
+ The native file reader keeps the Figma name of each variable collection, even when two collections share one. Native
168
+ records name a collection by its id, as Figma does, so numbering the second one ("Theme 2") only changed its name on
169
+ export and round trip. The literal reader still numbers a repeated name, because its `var('collection/name')`
170
+ expressions need distinct names. `test/editor-hook.test.ts` covers two same-name collections with bound layers.
171
+
172
+ ### `patches/0011-live-boolean-groups.patch`
173
+
174
+ A Figma `BOOLEAN_OPERATION` that Moondraft's boolean group can stand for (`liveBooleanOf` in `converters/vector.ts`:
175
+ union, subtract, intersect or exclude; a transform that only moves and turns; not filling its auto layout parent, and in
176
+ an auto layout flow only where its operands fill its box; shown operands that are shapes, nested boolean operations or
177
+ groups of those; regions not painted apart) becomes a frame holding its operands, which the walk imports as layers. The
178
+ frame carries its operation and the `fillGeometry` outline (in its own space) in `metadata.figma.boolean`, which also
179
+ splits clipboard variants (`variantTrees.ts`);
180
+ the adapter (`src/adapter/convert.ts`) makes it a boolean group whose first result is that outline. "In an auto layout
181
+ flow" means placed by a horizontal or vertical stack the walk imported (a grid imports as absolute), and a nested
182
+ boolean operation counts with its operands' box, as the adapter fits it. One with no outline is kept live anyway (the
183
+ renderer cuts its result); in a flow where its operands do not fill its box it carries `fixedBox`, and the adapter puts
184
+ it in a plain frame of its own box. Any other is
185
+ flattened as before, and its report line gives the reason. Changed expectations in `convert-vector.test.ts` and
186
+ `convert-instance.test.ts` are marked "Moondraft patch 0010".
187
+
188
+ ### `patches/0012-vector-stroke-caps.patch`
189
+
190
+ The Figma vector reader carries a map of cap overrides by open vertex ID in `metadata.figma.vectorStrokeCaps`.
191
+ An open vertex uses its own override, then the override on its incident segment, then the node's cap. The
192
+ reader still reports unknown cap values and style overrides without an open endpoint. A horizontal vector
193
+ that becomes a stretchable line keeps each override on its original end. Clipboard variant merging keeps
194
+ different override maps on separate layers. Vector arrowheads use the existing endpoint cap types and Figma's
195
+ dash cap stays separate.
196
+
197
+ ### `patches/0013-strokes-in-layout.patch`
198
+
199
+ Horizontal and vertical Figma frames with `bordersTakeSpace` carry `metadata.figma.strokesIncluded`. The adapter
200
+ sets `layoutData.layout.strokesIncluded` so inside stroke widths affect child placement and sizing. Clipboard variants
201
+ keep distinct layers when the setting differs.
202
+
203
+ ### `patches/0014-first-on-top.patch`
204
+
205
+ The Figma reader carries `stackReverseZIndex: true` on imported horizontal and vertical stacks as
206
+ `metadata.figma.firstOnTop`. Clipboard variant merges keep frames with different stacking separate. The adapter
207
+ writes the editor's `firstOnTop` frame property and preserves child order. A stack that falls back to free layout
208
+ still reports the omitted stacking setting.
209
+
210
+ ### `patches/0015-resized-instance-layout.patch`
211
+
212
+ The saved-file reader carries `derivedSymbolData` boxes for resized instances of free-layout components. It resolves
213
+ layer paths through nested instances, uses the authored or component value for an omitted size or transform, and
214
+ adjusts local transforms when the reader fits groups. The native adapter places the layers at those boxes, and the
215
+ linker stores the differences as existing geometry overrides where it can link the instance.
216
+
217
+ ### `patches/0016-figma-handoff-metadata.patch`
218
+
219
+ Expose the reader's original node relationships to the clipboard adapter. The adapter uses them for both file
220
+ and clipboard import to store Figma annotations, measurements and development status in `data.figma`. Clipboard
221
+ variant merges keep layers with handoff metadata distinct, and copies inside hidden mains keep their source
222
+ instance IDs. Active layer status takes precedence over the canvas map. The adapter reports metadata omitted from
223
+ skipped subtrees, and the reader reports active annotations and measurements in instance overrides, including
224
+ overrides of the instance root.
225
+
226
+ ### `patches/0017-group-and-vector-fill.patch`
227
+
228
+ The Figma reader carries main-axis grow and cross-axis stretch on non-rotated, aspect-unlocked groups and
229
+ paths in non-wrapping stacks, together with the size limits of paths that fill, as `metadata.figma.fillSizing`.
230
+ The adapter maps them to the editor's `layoutData.resizing`. The reader reports other requested group and path fill.
231
+ Groups carry their own resize constraints as `metadata.figma.groupConstraints` where constraints apply,
232
+ and the adapter writes them to `layoutData.constraints`. Clipboard variants with different carried sizing
233
+ or constraints keep distinct layers. A path with zero extent on a requested axis keeps its size on that
234
+ axis and the reader reports the omission. Its other axis can still fill. The adapter keeps a small positive
235
+ minimum on group fill axes so scale-constrained children can recover after a stack collapses.
236
+
237
+ ### `patches/0018-image-fill-crops.patch`
238
+
239
+ The Figma reader carries non-identity STRETCH image-fill matrices on the imported paints. The crop travels with each
240
+ paint through instance overrides, and clipboard variants with different cropped fills retain distinct layers. The
241
+ adapter inverts the layer-to-image mapping and writes the editor's existing image paint transform. It uses stretch
242
+ for crop axes that scale equally relative to the box and cover for crops that retain the image's aspect ratio.
243
+ The importer reports crops the paint transform cannot represent, such as reflections and shears.
244
+
245
+ ### `patches/0019-nested-instance-swaps.patch`
246
+
247
+ The Figma reader follows explicit swaps authored by enclosing instances when resolving an override path. It uses the
248
+ outermost applicable swap and follows swap property assignments on the replacement. If rejecting a swap changes
249
+ a dependent path, the reader checks any newly exposed swap edges for cycles. Unresolved entries are
250
+ counted individually. The report distinguishes missing source GUIDs or override keys from paths that have no layer
251
+ in the shown component, and identifies nested slot assignments that lack an imported declaration or bound frame.
252
+ The reader retains swap assignments that a different variant can bind. After rejecting a swap that changes which
253
+ slot hosts a component owns, it checks the refreshed nesting edges before accepting the remaining swaps.
254
+
255
+ ### `patches/0020-vector-region-fills.patch`
256
+
257
+ Resolve the style IDs of vector network regions and fallback `fillGeometry` paths through the vector style table.
258
+ Keep explicit empty paint lists and inherit the layer's fills when a region has no override. Region gradients use
259
+ the region bounds, while inherited gradients use the combined path bounds. The adapter keeps the editable network
260
+ and writes its own paints to `Region.fills`, including image tiling carried on the paints.
261
+
262
+ ### `patches/0021-fill-open-vector-networks.patch`
263
+
264
+ For a filled Figma vector network with no stored regions, the reader walks its segments into subpaths, ending
265
+ each chain where it reaches a junction or an endpoint. The subpaths share one nonzero fill region. Open loops
266
+ use the existing `implicitClose` flag so the fill closes without adding a segment to the stroke. Synthetic
267
+ tests cover separate subpaths, a cubic, and chains meeting at a junction.
268
+
269
+ ### `patches/0022-legacy-rectangles.patch`
270
+
271
+ The Figma reader sends legacy `RECTANGLE` nodes through the same editable rectangle converter as `ROUNDED_RECTANGLE`.
272
+
273
+ ### `patches/0023-frame-layout-grids.patch`
274
+
275
+ The Figma reader keeps grid style definitions available for lookup by GUID or library key. It skips them when
276
+ walking layers and recognizes grid-bearing frames in the group heuristic. Clipboard variants retain distinct
277
+ grid-bearing layers. The adapter writes each frame's guides to `layoutGrids` and reports shared grid styles
278
+ when it inlines their grids onto frames.
279
+
280
+ ### `patches/0024-reduce-import-allocations.patch`
281
+
282
+ The Kiwi decoder sizes short arrays up front and checks duplicate message fields against the record it is building.
283
+ Saved-file conversion reuses component computations while releasing each resolved occurrence tree after use.
284
+ Style and variable lookups retain their indexes without keeping the reader’s image callback and temporary tables alive.
285
+ The synchronous SHA-256 fallback reads full blocks from the input and allocates only the final padding blocks.
286
+
287
+ ### `patches/0025-stable-fill-layout.patch`
288
+
289
+ The file reader retains explicit vector sizes from instance layout when the imported path fills its stack.
290
+ It resolves each stored path through component swaps and checks fill eligibility after the stack is finalized.
291
+ The adapter holds conflicting stored allocations and lays out the remaining siblings. For groups it enables
292
+ a fill axis only when the children scale to its fitted bounds, with a minimum large enough to preserve
293
+ smaller paths through collapse. A multi-paint path and its painted regions scale together when their opacity wrapper resizes.
294
+
295
+ ### `patches/0026-vector-region-fill-review.patch`
296
+
297
+ Resolve and bound the combined region paint lists and gradient stops before converting any of them. If the
298
+ renderer limit is exceeded, keep the network, inherit the layer paints, and report the fallback. Detached
299
+ styles without a fill list also inherit. Outline styles report unused fields. Clipboard variants compare region
300
+ image placements, and the adapter keeps region-only assets, places crops using the stored layer size and
301
+ the combined region bounds, and isolates opacity for translucent paths with multiple authored regions.
302
+
303
+ ### `patches/0027-stored-fill-allocations.patch`
304
+
305
+ The file reader tracks explicit group and vector fill sizes separately from free-layout geometry. The adapter
306
+ uses these sizes in the placing instance’s scale and reconciles enclosing stacks before their descendants.
307
+
308
+ ### `patches/0028-variable-descriptions.patch`
309
+
310
+ Remove the Figma reader's loss report for variable descriptions. The saved-file adapter reads the description from
311
+ the original variable record, alongside the component, variant set and style descriptions.
312
+
313
+ ### `patches/0029-reduce-file-import-work.patch`
314
+
315
+ The Kiwi reader lets the file adapter compact each root array record immediately after decoding it.
316
+ Vector paint bounds are measured when a gradient needs them. The instance resolver can return
317
+ content, overrides and slot selections
318
+ before layout for the saved-file adapter, which computes its own geometry.
319
+
320
+ ### `patches/0030-figma-export-settings.patch`
321
+
322
+ Read ordered Figma export presets into the layer's `exportSettings` list for file and clipboard import. An instance
323
+ keeps its own presets, including ones stored on its root override. Report preset changes and clears on inherited
324
+ layers, which the editor's instance override schema cannot express.
325
+
326
+ ### `patches/0031-figma-variable-scopes.patch`
327
+
328
+ Skip the scope omission report for native saved-file imports. The adapter reads scopes and platform code syntax
329
+ from the original variable records. The reader still uses scopes to convert opacity units and reports scope
330
+ omissions in its literal import path.
331
+
332
+ ### `patches/0032-text-colour-variables.patch`
333
+
334
+ The saved-file reader identifies the variable on the solid paint drawn by each text run and retains
335
+ independent paint opacity. The adapter uses this provenance when building the native palette.
336
+
337
+ ### `patches/0033-figma-opentype-features.patch`
338
+
339
+ Read Figma's OpenType toggle lists and typography switches into each run's `openTypeFeatures`.
340
+ The reader keeps them on shared typography and instance overrides. An empty run override clears
341
+ inherited settings. The editor adapter converts the settings to numeric feature values for shaping.
342
+
343
+ ### `patches/0034-text-hyperlinks.patch`
344
+
345
+ Carry URL and GUID links on Figma text runs. Range overrides can replace or clear a layer link. Text component
346
+ assignments preserve inherited links on ranges without a hyperlink field and write explicit clears. A paint
347
+ override supplies the palette for links on assigned text. Evaluating
348
+ an unchanged characters property keeps the source's linked ranges. The adapter accepts HTTP, HTTPS and mailto
349
+ URLs. File and clipboard import resolve pending GUIDs to native layers and pages. The public page converter
350
+ omits and reports GUID destinations when it lacks the Figma source lookup. A saved instance that inherits its
351
+ text palette follows the main’s links and colour bindings. The importer reports each omitted instance link
352
+ override. An instance with an explicit paint keeps the links in its imported palette.
353
+
354
+ ### `patches/0035-text-paint-styles.patch`
355
+
356
+ The saved-file reader carries the fill style GUID of each text run through conversion. An explicit
357
+ range paint replaces the layer's style. Paint styles authored by an instance override are marked so
358
+ the native adapter can keep the resolved colour and report the lost link.
359
+
360
+ ### `patches/0036-independent-edge-bindings.patch`
361
+
362
+ The saved-file adapter reads independent corner radius and stroke side bindings from the source records.
363
+ The vendored reader leaves those fields to the adapter, including groups previously collapsed into a
364
+ single binding. The literal reader retains its existing handling.
365
+
366
+ ### `patches/0037-instance-frame-overrides.patch`
367
+
368
+ The Figma reader keeps per-instance clipping, corner smoothing and stack settings on the affected
369
+ component layer or root. The vendored resolver composes the layout members across nested instances.
370
+
371
+ ## Code and data from elsewhere
372
+
373
+ - **VS Code themes (MIT).** taco's model adapts the Code - OSS `2026-dark` / `2026-light` colour themes in `code.ts`.
374
+ `code.ts` is not in the copied part of the model at this commit, but its notice is copied anyway
375
+ (`src/taco/model/THIRD_PARTY_NOTICES.md`), so that a later sync which reaches it is already covered.
376
+ - **Kiwi reader (MIT).** `src/taco/figma-import/kiwi/byteReader.ts` mirrors the `ByteBuffer` in evanw/kiwi's
377
+ `js/bb.ts` (https://github.com/evanw/kiwi, MIT, Evan Wallace), as its header says. The investigation found no
378
+ copied code, only the same structure. It is attributed here.
379
+ - **grida.** Comments in figma-import cite grida's `grida-canvas-io-figma` by file and line, as references for how it
380
+ reads Kiwi. No grida code is copied. Check grida's licence before copying any.
381
+ - **Test fixtures** (`test/taco/svg-import/samples/`):
382
+ - `golden/material-home.svg`: the Material Icons "home" icon, Google, **Apache-2.0**;
383
+ - `golden/lucide-arrow-right.svg`: the Lucide "arrow-right" icon, **ISC** (Lucide Contributors);
384
+ - `golden/inkscape-drawing.svg`, `golden/figma-illustration.svg`, the numbered samples and
385
+ `dark-mode-styles.svg`: the author's own;
386
+ - figma-import's fixtures are synthetic Kiwi messages built in code (`figmaMessages.ts`, `kiwiEncoder.ts`).
387
+ Real Figma clipboard captures and the HeroUI kit stay outside the repo.
388
+
389
+ ## Running
390
+
391
+ - `tsc -b packages/import` type-checks the copied sources (also part of `npm run typecheck`). The tests are not
392
+ type-checked: they need Node's types, which this repo does not install.
393
+ - `npm run test:import` runs the copied tests (svg-import 1,418 and figma-import 755, about 25 s). It is not part of
394
+ `npm test`.
@@ -0,0 +1,144 @@
1
+ import { type DocumentJSON, type TextStyle } from '@moondraft/editor/schema';
2
+ import type { StoredFigmaBox } from '../taco/figma-import/import/instances.ts';
3
+ import { type LinkCounts } from './link.ts';
4
+ /** A taco document as JSON (schemaVersion 0.44.0): pages, nodes, components, theme and assets, read loosely. */
5
+ export interface TacoDocument {
6
+ /** Page IDs in display order. */
7
+ pageOrder: string[];
8
+ /** Page metadata by page ID. */
9
+ pages: Record<string, {
10
+ /** Display name of the page. */
11
+ name: string;
12
+ /** ID of the node containing this page's layers. */
13
+ rootId: string;
14
+ }>;
15
+ /** Source layer records by ID. */
16
+ nodes: Record<string, any>;
17
+ /** Source component definitions by ID. */
18
+ components: Record<string, any>;
19
+ /** Placement layer IDs by component ID. */
20
+ componentPlacements?: Readonly<Record<string, string>>;
21
+ /** Direct file aliases by variable and mode, used to resolve plain text overrides. */
22
+ variableAliases?: ReadonlyMap<string, ReadonlyMap<string, string>>;
23
+ /** Stored Figma boxes by instance ID and layer path, for saved files. */
24
+ instanceBoxes?: ReadonlyMap<string, ReadonlyMap<string, StoredFigmaBox>>;
25
+ /** Sizes saved for flow children, in the placing instance's coordinates. */
26
+ instanceFillSizes?: ReadonlyMap<string, ReadonlyMap<string, StoredFigmaBox>>;
27
+ /** Source image assets by ID. */
28
+ assets?: Record<string, any>;
29
+ /** Theme metadata used to resolve variables and modes. */
30
+ theme?: any;
31
+ /** Additional source document fields. */
32
+ [key: string]: unknown;
33
+ }
34
+ /** Settings for converting Taco records to Moondraft records. */
35
+ export interface ConvertOptions {
36
+ /** Link expanded instances to their mains (link.ts). Default true. */
37
+ link?: boolean;
38
+ /** Without linking: keep the markers link.ts reads (instanceOf, mainOf, setOf, variant), for a later link pass
39
+ * (tools/host_doc/regenerate.mjs supplements and settles such a page first). Default false. */
40
+ markers?: boolean;
41
+ /** The HeroUI kit's export fixes: tall Input instances top-aligned, and buttons squared in an attached group (see
42
+ * topAlignTallInput and squareJoined). The kit's Figma export drops the overrides these restore. Default false. */
43
+ kitFixes?: boolean;
44
+ /** The document's `source` header (the source file's name). */
45
+ source?: string;
46
+ /** Receives the original reader IDs of expanded instance roots, keyed by converted model ID.
47
+ * @internal
48
+ */
49
+ instanceSources?: Map<string, string>;
50
+ /**
51
+ * Resolves the URL for an imported image. Defaults to `assets/<id>.<ext>`.
52
+ * @param id - Imported asset ID.
53
+ * @param asset - Image type, size and base64 data.
54
+ * @returns Image URL to store in the document.
55
+ */
56
+ assetSrc?: (id: string, asset: {
57
+ mimeType: string;
58
+ width?: number;
59
+ height?: number;
60
+ source: {
61
+ data: string;
62
+ };
63
+ }) => string;
64
+ }
65
+ /** An image asset the document uses: its `src` in the document, and its bytes (base64) and type. */
66
+ export interface AssetFile {
67
+ /** Asset ID referenced by the converted layers. */
68
+ id: string;
69
+ /** Image URL written to the document. */
70
+ src: string;
71
+ /** MIME type of the image bytes. */
72
+ mimeType: string;
73
+ /** Image bytes encoded as base64. */
74
+ data: string;
75
+ }
76
+ /** Conversion diagnostics and image files used by the result. */
77
+ export interface ConvertReport {
78
+ /** What was dropped or not evaluated, by kind. */
79
+ dropped: Map<string, number>;
80
+ /** Why the expressions and conditions counted in dropped (`expression not applied: <field>`, `override condition
81
+ * not evaluated`) were not applied: taco's message or the converter's reason, by message. */
82
+ expressionErrors: Map<string, number>;
83
+ /** What was converted with a rule worth counting, by kind. */
84
+ notes: Map<string, number>;
85
+ /** Notes that describe a change from the source, by kind. */
86
+ approximations: Map<string, number>;
87
+ /** Text runs by font weight. */
88
+ weights: Map<number, number>;
89
+ /** The deepest instance nesting met. */
90
+ depth: number;
91
+ /** Link counts (null when not linked). */
92
+ links: LinkCounts | null;
93
+ /** Affected layer IDs indexed by report kind and description. */
94
+ layerIds: Map<string, string[]>;
95
+ /** The image assets the document uses. */
96
+ assets: AssetFile[];
97
+ }
98
+ /** Converts a reader colour to the RGBA precision used by imported paints.
99
+ * @param hex - Source hex colour or expression colour.
100
+ * @returns Normalized channels, or null for a non-colour value.
101
+ * @internal
102
+ */
103
+ export declare function rgba(hex: any): [number, number, number, number] | null;
104
+ /** Converts reader typography to a native palette entry.
105
+ * @param s - Resolved source run style.
106
+ * @returns Native face, metrics, decoration and colour.
107
+ * @internal
108
+ */
109
+ export declare function runStyle(s: any): TextStyle;
110
+ /**
111
+ * Converts one page of a Taco document to Moondraft records.
112
+ * @param doc - Source document.
113
+ * @param pageRef - Page name or zero-based index.
114
+ * @param options - Conversion settings.
115
+ * @returns Converted document and report.
116
+ */
117
+ export declare function toDocument(doc: TacoDocument, pageRef: string | number, options?: ConvertOptions): {
118
+ /** Moondraft document containing the converted page. */
119
+ doc: DocumentJSON;
120
+ /** Conversion diagnostics and the page's image assets. */
121
+ report: ConvertReport;
122
+ };
123
+ /** Converts the clipboard selection for the Figma adapter's subsequent GUID resolution pass. @internal */
124
+ export declare function figmaClipboardPage(doc: TacoDocument, instanceSources: Map<string, string>): {
125
+ doc: DocumentJSON;
126
+ report: ConvertReport;
127
+ };
128
+ /** Converts all file pages and keeps the appearance of each linked occurrence.
129
+ * @param doc - Source document.
130
+ * @param options - Asset and conversion settings.
131
+ * @returns Linked document, conversion report, pre-link literals and nested boolean assignments.
132
+ * @internal
133
+ */
134
+ export declare function allPages(doc: TacoDocument, options: ConvertOptions): {
135
+ omittedLinks: Map<string, Set<string>>;
136
+ expanded: Map<string, any>;
137
+ nestedBooleans: Map<string, NestedBooleanAssignments>;
138
+ doc: DocumentJSON;
139
+ report: ConvertReport;
140
+ };
141
+ export interface NestedBooleanAssignments {
142
+ componentId: string;
143
+ values: Record<string, boolean>;
144
+ }