@moondraft/import 0.0.0-stage → 0.1.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 (323) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +34 -0
  3. package/README.md +36 -2
  4. package/SOURCE.md +169 -0
  5. package/dist/adapter/convert.d.ts +122 -0
  6. package/dist/adapter/convert.js +2302 -0
  7. package/dist/adapter/figma.d.ts +9 -0
  8. package/dist/adapter/figma.js +30 -0
  9. package/dist/adapter/file-components.d.ts +14 -0
  10. package/dist/adapter/file-components.js +262 -0
  11. package/dist/adapter/file-resources.d.ts +29 -0
  12. package/dist/adapter/file-resources.js +562 -0
  13. package/dist/adapter/index.d.ts +6 -0
  14. package/dist/adapter/index.js +9 -0
  15. package/dist/adapter/link.d.ts +45 -0
  16. package/dist/adapter/link.js +688 -0
  17. package/dist/adapter/payload.d.ts +31 -0
  18. package/dist/adapter/payload.js +78 -0
  19. package/dist/adapter/shapes.d.ts +31 -0
  20. package/dist/adapter/shapes.js +75 -0
  21. package/dist/adapter/variables.d.ts +44 -0
  22. package/dist/adapter/variables.js +103 -0
  23. package/dist/figma-file.d.ts +38 -0
  24. package/dist/figma-file.js +97 -0
  25. package/dist/figma-worker.d.ts +11 -0
  26. package/dist/figma-worker.js +12 -0
  27. package/dist/figma.d.ts +26 -0
  28. package/dist/figma.js +96 -0
  29. package/dist/index.d.ts +28 -0
  30. package/dist/index.js +49 -0
  31. package/dist/report.d.ts +15 -0
  32. package/dist/report.js +69 -0
  33. package/dist/svg.d.ts +33 -0
  34. package/dist/svg.js +44 -0
  35. package/dist/syntax.d.ts +8 -0
  36. package/dist/syntax.js +19 -0
  37. package/dist/taco/figma-import/clipboard.d.ts +25 -0
  38. package/dist/taco/figma-import/clipboard.js +87 -0
  39. package/dist/taco/figma-import/clipboardSize.d.ts +31 -0
  40. package/dist/taco/figma-import/clipboardSize.js +107 -0
  41. package/dist/taco/figma-import/container/compression.d.ts +9 -0
  42. package/dist/taco/figma-import/container/compression.js +174 -0
  43. package/dist/taco/figma-import/container/error.d.ts +15 -0
  44. package/dist/taco/figma-import/container/error.js +19 -0
  45. package/dist/taco/figma-import/container/kiwiContainer.d.ts +38 -0
  46. package/dist/taco/figma-import/container/kiwiContainer.js +61 -0
  47. package/dist/taco/figma-import/container/limits.d.ts +22 -0
  48. package/dist/taco/figma-import/container/limits.js +22 -0
  49. package/dist/taco/figma-import/container/zip.d.ts +14 -0
  50. package/dist/taco/figma-import/container/zip.js +154 -0
  51. package/dist/taco/figma-import/figFile.d.ts +34 -0
  52. package/dist/taco/figma-import/figFile.js +91 -0
  53. package/dist/taco/figma-import/figFileDocument.d.ts +25 -0
  54. package/dist/taco/figma-import/figFileDocument.js +100 -0
  55. package/dist/taco/figma-import/import/blobs.d.ts +10 -0
  56. package/dist/taco/figma-import/import/blobs.js +23 -0
  57. package/dist/taco/figma-import/import/carry.d.ts +11 -0
  58. package/dist/taco/figma-import/import/carry.js +33 -0
  59. package/dist/taco/figma-import/import/componentProps.d.ts +84 -0
  60. package/dist/taco/figma-import/import/componentProps.js +313 -0
  61. package/dist/taco/figma-import/import/componentSets.d.ts +83 -0
  62. package/dist/taco/figma-import/import/componentSets.js +647 -0
  63. package/dist/taco/figma-import/import/converters/effects.d.ts +31 -0
  64. package/dist/taco/figma-import/import/converters/effects.js +127 -0
  65. package/dist/taco/figma-import/import/converters/ellipse.d.ts +7 -0
  66. package/dist/taco/figma-import/import/converters/ellipse.js +54 -0
  67. package/dist/taco/figma-import/import/converters/frame.d.ts +21 -0
  68. package/dist/taco/figma-import/import/converters/frame.js +55 -0
  69. package/dist/taco/figma-import/import/converters/gradient.d.ts +72 -0
  70. package/dist/taco/figma-import/import/converters/gradient.js +106 -0
  71. package/dist/taco/figma-import/import/converters/group.d.ts +21 -0
  72. package/dist/taco/figma-import/import/converters/group.js +39 -0
  73. package/dist/taco/figma-import/import/converters/image.d.ts +13 -0
  74. package/dist/taco/figma-import/import/converters/image.js +83 -0
  75. package/dist/taco/figma-import/import/converters/layout.d.ts +34 -0
  76. package/dist/taco/figma-import/import/converters/layout.js +168 -0
  77. package/dist/taco/figma-import/import/converters/line.d.ts +11 -0
  78. package/dist/taco/figma-import/import/converters/line.js +40 -0
  79. package/dist/taco/figma-import/import/converters/rectangle.d.ts +3 -0
  80. package/dist/taco/figma-import/import/converters/rectangle.js +11 -0
  81. package/dist/taco/figma-import/import/converters/section.d.ts +9 -0
  82. package/dist/taco/figma-import/import/converters/section.js +35 -0
  83. package/dist/taco/figma-import/import/converters/shared.d.ts +68 -0
  84. package/dist/taco/figma-import/import/converters/shared.js +362 -0
  85. package/dist/taco/figma-import/import/converters/text.d.ts +41 -0
  86. package/dist/taco/figma-import/import/converters/text.js +576 -0
  87. package/dist/taco/figma-import/import/converters/vector.d.ts +84 -0
  88. package/dist/taco/figma-import/import/converters/vector.js +468 -0
  89. package/dist/taco/figma-import/import/converters/vectorNetwork.d.ts +98 -0
  90. package/dist/taco/figma-import/import/converters/vectorNetwork.js +385 -0
  91. package/dist/taco/figma-import/import/fields.d.ts +15 -0
  92. package/dist/taco/figma-import/import/fields.js +29 -0
  93. package/dist/taco/figma-import/import/instances.d.ts +163 -0
  94. package/dist/taco/figma-import/import/instances.js +1323 -0
  95. package/dist/taco/figma-import/import/nestingCycles.d.ts +86 -0
  96. package/dist/taco/figma-import/import/nestingCycles.js +488 -0
  97. package/dist/taco/figma-import/import/slots.d.ts +56 -0
  98. package/dist/taco/figma-import/import/slots.js +96 -0
  99. package/dist/taco/figma-import/import/styles.d.ts +46 -0
  100. package/dist/taco/figma-import/import/styles.js +42 -0
  101. package/dist/taco/figma-import/import/tree.d.ts +66 -0
  102. package/dist/taco/figma-import/import/tree.js +194 -0
  103. package/dist/taco/figma-import/import/types.d.ts +232 -0
  104. package/dist/taco/figma-import/import/types.js +33 -0
  105. package/dist/taco/figma-import/import/variables.d.ts +136 -0
  106. package/dist/taco/figma-import/import/variables.js +762 -0
  107. package/dist/taco/figma-import/import/variantTrees.d.ts +20 -0
  108. package/dist/taco/figma-import/import/variantTrees.js +480 -0
  109. package/dist/taco/figma-import/import/walk.d.ts +159 -0
  110. package/dist/taco/figma-import/import/walk.js +1297 -0
  111. package/dist/taco/figma-import/index.d.ts +22 -0
  112. package/dist/taco/figma-import/index.js +13 -0
  113. package/dist/taco/figma-import/kiwi/byteReader.d.ts +37 -0
  114. package/dist/taco/figma-import/kiwi/byteReader.js +151 -0
  115. package/dist/taco/figma-import/kiwi/error.d.ts +14 -0
  116. package/dist/taco/figma-import/kiwi/error.js +29 -0
  117. package/dist/taco/figma-import/kiwi/limits.d.ts +18 -0
  118. package/dist/taco/figma-import/kiwi/limits.js +18 -0
  119. package/dist/taco/figma-import/kiwi/message.d.ts +10 -0
  120. package/dist/taco/figma-import/kiwi/message.js +145 -0
  121. package/dist/taco/figma-import/kiwi/schema.d.ts +42 -0
  122. package/dist/taco/figma-import/kiwi/schema.js +206 -0
  123. package/dist/taco/figma-import/kiwi/types.d.ts +46 -0
  124. package/dist/taco/figma-import/kiwi/types.js +18 -0
  125. package/dist/taco/model/agent-hidden-fields.d.ts +20 -0
  126. package/dist/taco/model/agent-hidden-fields.js +29 -0
  127. package/dist/taco/model/asset-users.d.ts +23 -0
  128. package/dist/taco/model/asset-users.js +128 -0
  129. package/dist/taco/model/auto-layout-lines.d.ts +32 -0
  130. package/dist/taco/model/auto-layout-lines.js +70 -0
  131. package/dist/taco/model/codec.d.ts +444 -0
  132. package/dist/taco/model/codec.js +5635 -0
  133. package/dist/taco/model/color.d.ts +11 -0
  134. package/dist/taco/model/color.js +61 -0
  135. package/dist/taco/model/comment-operations.d.ts +102 -0
  136. package/dist/taco/model/comment-operations.js +227 -0
  137. package/dist/taco/model/component-evaluation.d.ts +94 -0
  138. package/dist/taco/model/component-evaluation.js +548 -0
  139. package/dist/taco/model/component-expressions.d.ts +242 -0
  140. package/dist/taco/model/component-expressions.js +1082 -0
  141. package/dist/taco/model/component-properties.d.ts +111 -0
  142. package/dist/taco/model/component-properties.js +339 -0
  143. package/dist/taco/model/component-samples.d.ts +83 -0
  144. package/dist/taco/model/component-samples.js +290 -0
  145. package/dist/taco/model/component-validity.d.ts +85 -0
  146. package/dist/taco/model/component-validity.js +397 -0
  147. package/dist/taco/model/components.d.ts +155 -0
  148. package/dist/taco/model/components.js +505 -0
  149. package/dist/taco/model/connector-ends.d.ts +20 -0
  150. package/dist/taco/model/connector-ends.js +188 -0
  151. package/dist/taco/model/connector-geometry.d.ts +74 -0
  152. package/dist/taco/model/connector-geometry.js +293 -0
  153. package/dist/taco/model/corner-radii.d.ts +26 -0
  154. package/dist/taco/model/corner-radii.js +47 -0
  155. package/dist/taco/model/derivations.d.ts +81 -0
  156. package/dist/taco/model/derivations.js +151 -0
  157. package/dist/taco/model/export-settings.d.ts +53 -0
  158. package/dist/taco/model/export-settings.js +156 -0
  159. package/dist/taco/model/expressions/ast.d.ts +153 -0
  160. package/dist/taco/model/expressions/ast.js +6 -0
  161. package/dist/taco/model/expressions/cache.d.ts +23 -0
  162. package/dist/taco/model/expressions/cache.js +43 -0
  163. package/dist/taco/model/expressions/check.d.ts +72 -0
  164. package/dist/taco/model/expressions/check.js +517 -0
  165. package/dist/taco/model/expressions/completion.d.ts +61 -0
  166. package/dist/taco/model/expressions/completion.js +421 -0
  167. package/dist/taco/model/expressions/evaluate.d.ts +32 -0
  168. package/dist/taco/model/expressions/evaluate.js +519 -0
  169. package/dist/taco/model/expressions/forms.d.ts +84 -0
  170. package/dist/taco/model/expressions/forms.js +200 -0
  171. package/dist/taco/model/expressions/index.d.ts +14 -0
  172. package/dist/taco/model/expressions/index.js +17 -0
  173. package/dist/taco/model/expressions/lexer.d.ts +42 -0
  174. package/dist/taco/model/expressions/lexer.js +213 -0
  175. package/dist/taco/model/expressions/library.d.ts +33 -0
  176. package/dist/taco/model/expressions/library.js +117 -0
  177. package/dist/taco/model/expressions/names.d.ts +43 -0
  178. package/dist/taco/model/expressions/names.js +99 -0
  179. package/dist/taco/model/expressions/parser.d.ts +15 -0
  180. package/dist/taco/model/expressions/parser.js +438 -0
  181. package/dist/taco/model/expressions/rename.d.ts +34 -0
  182. package/dist/taco/model/expressions/rename.js +46 -0
  183. package/dist/taco/model/expressions/source.d.ts +15 -0
  184. package/dist/taco/model/expressions/source.js +161 -0
  185. package/dist/taco/model/expressions/types.d.ts +119 -0
  186. package/dist/taco/model/expressions/types.js +102 -0
  187. package/dist/taco/model/expressions/values.d.ts +97 -0
  188. package/dist/taco/model/expressions/values.js +160 -0
  189. package/dist/taco/model/geometry-limits.d.ts +16 -0
  190. package/dist/taco/model/geometry-limits.js +67 -0
  191. package/dist/taco/model/geometry.d.ts +47 -0
  192. package/dist/taco/model/geometry.js +193 -0
  193. package/dist/taco/model/group-bounds.d.ts +38 -0
  194. package/dist/taco/model/group-bounds.js +144 -0
  195. package/dist/taco/model/id-table.d.ts +37 -0
  196. package/dist/taco/model/id-table.js +80 -0
  197. package/dist/taco/model/index.d.ts +25 -0
  198. package/dist/taco/model/index.js +27 -0
  199. package/dist/taco/model/instance-resolver.d.ts +372 -0
  200. package/dist/taco/model/instance-resolver.js +1748 -0
  201. package/dist/taco/model/layer-syntax.d.ts +340 -0
  202. package/dist/taco/model/layer-syntax.js +3506 -0
  203. package/dist/taco/model/layout/constraints.d.ts +84 -0
  204. package/dist/taco/model/layout/constraints.js +445 -0
  205. package/dist/taco/model/layout/frame-layout.d.ts +46 -0
  206. package/dist/taco/model/layout/frame-layout.js +618 -0
  207. package/dist/taco/model/layout/node-sizing.d.ts +163 -0
  208. package/dist/taco/model/layout/node-sizing.js +486 -0
  209. package/dist/taco/model/legacy-connector-caps.d.ts +15 -0
  210. package/dist/taco/model/legacy-connector-caps.js +70 -0
  211. package/dist/taco/model/linear-call.d.ts +48 -0
  212. package/dist/taco/model/linear-call.js +58 -0
  213. package/dist/taco/model/new-nodes.d.ts +145 -0
  214. package/dist/taco/model/new-nodes.js +277 -0
  215. package/dist/taco/model/node-builder.d.ts +449 -0
  216. package/dist/taco/model/node-builder.js +2294 -0
  217. package/dist/taco/model/node-table-watch.d.ts +36 -0
  218. package/dist/taco/model/node-table-watch.js +63 -0
  219. package/dist/taco/model/node-transform.d.ts +39 -0
  220. package/dist/taco/model/node-transform.js +79 -0
  221. package/dist/taco/model/node-users-index.d.ts +10 -0
  222. package/dist/taco/model/node-users-index.js +82 -0
  223. package/dist/taco/model/operation-references.d.ts +80 -0
  224. package/dist/taco/model/operation-references.js +399 -0
  225. package/dist/taco/model/operations.d.ts +610 -0
  226. package/dist/taco/model/operations.js +2882 -0
  227. package/dist/taco/model/overlay-table.d.ts +71 -0
  228. package/dist/taco/model/overlay-table.js +171 -0
  229. package/dist/taco/model/override-remap.d.ts +69 -0
  230. package/dist/taco/model/override-remap.js +230 -0
  231. package/dist/taco/model/parent-table.d.ts +53 -0
  232. package/dist/taco/model/parent-table.js +193 -0
  233. package/dist/taco/model/problem-collector.d.ts +27 -0
  234. package/dist/taco/model/problem-collector.js +101 -0
  235. package/dist/taco/model/sha256.d.ts +10 -0
  236. package/dist/taco/model/sha256.js +74 -0
  237. package/dist/taco/model/shape-geometry.d.ts +96 -0
  238. package/dist/taco/model/shape-geometry.js +368 -0
  239. package/dist/taco/model/shared-node-table.d.ts +97 -0
  240. package/dist/taco/model/shared-node-table.js +546 -0
  241. package/dist/taco/model/slots.d.ts +113 -0
  242. package/dist/taco/model/slots.js +281 -0
  243. package/dist/taco/model/stroke-settings.d.ts +37 -0
  244. package/dist/taco/model/stroke-settings.js +90 -0
  245. package/dist/taco/model/svg-path-import.d.ts +89 -0
  246. package/dist/taco/model/svg-path-import.js +219 -0
  247. package/dist/taco/model/text-measurement.d.ts +142 -0
  248. package/dist/taco/model/text-measurement.js +846 -0
  249. package/dist/taco/model/text-reads.d.ts +66 -0
  250. package/dist/taco/model/text-reads.js +128 -0
  251. package/dist/taco/model/text-sizer.d.ts +358 -0
  252. package/dist/taco/model/text-sizer.js +996 -0
  253. package/dist/taco/model/theme-users.d.ts +59 -0
  254. package/dist/taco/model/theme-users.js +312 -0
  255. package/dist/taco/model/thumbnail.d.ts +15 -0
  256. package/dist/taco/model/thumbnail.js +34 -0
  257. package/dist/taco/model/types.d.ts +2347 -0
  258. package/dist/taco/model/types.js +366 -0
  259. package/dist/taco/model/unknown-property.d.ts +5 -0
  260. package/dist/taco/model/unknown-property.js +7 -0
  261. package/dist/taco/model/validated-documents.d.ts +22 -0
  262. package/dist/taco/model/validated-documents.js +22 -0
  263. package/dist/taco/model/variable-modes.d.ts +61 -0
  264. package/dist/taco/model/variable-modes.js +438 -0
  265. package/dist/taco/model/variable-references.d.ts +54 -0
  266. package/dist/taco/model/variable-references.js +183 -0
  267. package/dist/taco/model/variables.d.ts +24 -0
  268. package/dist/taco/model/variables.js +151 -0
  269. package/dist/taco/model/vector-network.d.ts +34 -0
  270. package/dist/taco/model/vector-network.js +411 -0
  271. package/dist/taco/svg-import/import-svg.d.ts +36 -0
  272. package/dist/taco/svg-import/import-svg.js +729 -0
  273. package/dist/taco/svg-import/index.d.ts +3 -0
  274. package/dist/taco/svg-import/index.js +3 -0
  275. package/dist/taco/svg-import/limits/limits.d.ts +79 -0
  276. package/dist/taco/svg-import/limits/limits.js +160 -0
  277. package/dist/taco/svg-import/paint/gradients.d.ts +64 -0
  278. package/dist/taco/svg-import/paint/gradients.js +429 -0
  279. package/dist/taco/svg-import/paint/paint.d.ts +32 -0
  280. package/dist/taco/svg-import/paint/paint.js +162 -0
  281. package/dist/taco/svg-import/paths/paths.d.ts +58 -0
  282. package/dist/taco/svg-import/paths/paths.js +205 -0
  283. package/dist/taco/svg-import/public-types.d.ts +279 -0
  284. package/dist/taco/svg-import/public-types.js +56 -0
  285. package/dist/taco/svg-import/report/report.d.ts +44 -0
  286. package/dist/taco/svg-import/report/report.js +79 -0
  287. package/dist/taco/svg-import/reuse/reuse.d.ts +99 -0
  288. package/dist/taco/svg-import/reuse/reuse.js +840 -0
  289. package/dist/taco/svg-import/shapes/shapes.d.ts +35 -0
  290. package/dist/taco/svg-import/shapes/shapes.js +386 -0
  291. package/dist/taco/svg-import/structure/effects.d.ts +26 -0
  292. package/dist/taco/svg-import/structure/effects.js +618 -0
  293. package/dist/taco/svg-import/structure/image.d.ts +24 -0
  294. package/dist/taco/svg-import/structure/image.js +495 -0
  295. package/dist/taco/svg-import/structure/walk.d.ts +85 -0
  296. package/dist/taco/svg-import/structure/walk.js +544 -0
  297. package/dist/taco/svg-import/style/color.d.ts +40 -0
  298. package/dist/taco/svg-import/style/color.js +275 -0
  299. package/dist/taco/svg-import/style/computed.d.ts +214 -0
  300. package/dist/taco/svg-import/style/computed.js +1534 -0
  301. package/dist/taco/svg-import/style/css.d.ts +127 -0
  302. package/dist/taco/svg-import/style/css.js +541 -0
  303. package/dist/taco/svg-import/style/media.d.ts +25 -0
  304. package/dist/taco/svg-import/style/media.js +307 -0
  305. package/dist/taco/svg-import/style/properties.d.ts +43 -0
  306. package/dist/taco/svg-import/style/properties.js +135 -0
  307. package/dist/taco/svg-import/style/selector-reach.d.ts +30 -0
  308. package/dist/taco/svg-import/style/selector-reach.js +169 -0
  309. package/dist/taco/svg-import/style/selector-validity.d.ts +14 -0
  310. package/dist/taco/svg-import/style/selector-validity.js +307 -0
  311. package/dist/taco/svg-import/text/text.d.ts +29 -0
  312. package/dist/taco/svg-import/text/text.js +545 -0
  313. package/dist/taco/svg-import/transform/matrix.d.ts +111 -0
  314. package/dist/taco/svg-import/transform/matrix.js +229 -0
  315. package/dist/taco/svg-import/tree/element-data.d.ts +52 -0
  316. package/dist/taco/svg-import/tree/element-data.js +155 -0
  317. package/dist/taco/svg-import/tree/elements.d.ts +36 -0
  318. package/dist/taco/svg-import/tree/elements.js +121 -0
  319. package/dist/taco/svg-import/units/length.d.ts +43 -0
  320. package/dist/taco/svg-import/units/length.js +125 -0
  321. package/dist/taco/svg-import/units/viewbox.d.ts +35 -0
  322. package/dist/taco/svg-import/units/viewbox.js +77 -0
  323. package/package.json +54 -4
@@ -0,0 +1,27 @@
1
+ // Generated by packages/import/scripts/sync-taco.mjs: the part of @taco-design/model's public index that the copied
2
+ // importers and their tests use. Do not edit; run the sync script instead.
3
+ export { assertSceneNode, checkSceneNode, deserializeDocument, ModelError } from "./codec.js";
4
+ export { paragraphsFromCharacters } from "./component-evaluation.js";
5
+ export { componentExpressionEnvironment, componentValueEnvironment, computableFieldType, storedFieldValue, variableExpressionType, variablesByExpressionName } from "./component-expressions.js";
6
+ export { computableFieldsOf, variablePropertiesOfField } from "./component-properties.js";
7
+ export { plainInstanceSample } from "./component-samples.js";
8
+ export { isValidVariantCombination } from "./component-validity.js";
9
+ export { componentNestingGraph, findComponentCycle, layerPathKey, parseLayerPath } from "./components.js";
10
+ export { checkExpressionSource, evaluateExpression, EXPRESSION_NAME_MAX_LENGTH, EXPRESSION_SOURCE_LIMIT, EXPRESSION_TYPES, expressionNameProblem, expressionValuesEqual, expressionValueSource, formatExpressionName, formatExpressionString, normalizeExpressionName, parseExpression, writeValueTable } from "./expressions/index.js";
11
+ export { getNodeBounds, getPathBounds, getVectorNetworkBounds } from "./geometry.js";
12
+ export { buildParentMap, fitAllGroups, fitGroupToChildren } from "./group-bounds.js";
13
+ export { entryOf } from "./id-table.js";
14
+ export { PROPERTIES_DROPPED_BY_FIELD, resolveInstance, TEXT_STYLE_PROPERTIES } from "./instance-resolver.js";
15
+ export { planLayerEdit } from "./layer-syntax.js";
16
+ export { constrainChildren } from "./layout/constraints.js";
17
+ export { layoutFrameTree } from "./layout/frame-layout.js";
18
+ export { multiplyTransforms, nodeLocalTransform, transformIsInvertible } from "./node-transform.js";
19
+ export { applyOperations } from "./operations.js";
20
+ export { isWholeEllipseArc } from "./shape-geometry.js";
21
+ export { miterAngleFromLimit } from "./stroke-settings.js";
22
+ export { pathNodeFromSvgPath } from "./svg-path-import.js";
23
+ export { paragraphSpaceAbove, resolveTextStyle, splitCssFontFamilies } from "./text-measurement.js";
24
+ export { BLEND_MODES, codeStyleId, componentId, componentPropertyId, CURRENT_DOCUMENT_SCHEMA_VERSION, DEFAULT_STROKE_MITER_ANGLE, documentId, nodeId, ownedChildIds, pageId, textStyleId, vectorHandleId, vectorRegionId, vectorSegmentId, vectorVertexId } from "./types.js";
25
+ export { applyVariableBindings } from "./variable-modes.js";
26
+ export { listVariablesForProperty, nodeSupportsVariableProperty, VARIABLE_PROPERTY_TYPES } from "./variables.js";
27
+ export { vectorRegionToSvgPathData } from "./vector-network.js";
@@ -0,0 +1,372 @@
1
+ import { type ComponentExpressionError } from "./component-evaluation.ts";
2
+ import { type ComponentId, type ComponentPropertyId, type ComponentPropertyValues, type DesignDocument, type CodeNode, type InstanceNode, type LayerOverride, type LayoutPadding, type NodeId, type SceneNode, type TextNode, type TextParagraph, type VariableModes, type VariableProperty } from "./types.ts";
3
+ /**
4
+ * The stored instance a resolved layer stands for, set on the root layer
5
+ * and on every nested instance layer.
6
+ * @since 0.23.0
7
+ */
8
+ export interface ResolvedLayerInstance {
9
+ /** The stored `InstanceNode`: the outer instance, or a nested one inside a component. */
10
+ readonly instanceId: NodeId;
11
+ /** The component shown, after any swap by an outer override. */
12
+ readonly componentId: ComponentId;
13
+ /**
14
+ * The instance node as resolved: swapped, with outer overrides and the
15
+ * enclosing component's computed fields (its own `propertyValues`
16
+ * included) applied. The component view draws a nested instance from it.
17
+ * @since 0.26.0
18
+ */
19
+ readonly node: InstanceNode;
20
+ /**
21
+ * The property values the component is resolved with: the stored
22
+ * instance's own, or for a nested instance its outer override, else its
23
+ * expression over the outer properties, else its stored value. Absent
24
+ * when none is set (every property at its default).
25
+ * @since 0.26.0
26
+ */
27
+ readonly propertyValues?: ComponentPropertyValues;
28
+ }
29
+ /**
30
+ * One derived layer of a resolved instance. `node` is the component node
31
+ * with the instance's overrides applied (by the precedence on
32
+ * `LayerOverride`) and its `frame` laid out for the instance's size, so the
33
+ * compiler compiles it exactly as it compiles a stored node, with
34
+ * `virtualId` as the render node ID.
35
+ *
36
+ * - `node.id` equals `virtualId`, and a container's `children` list holds
37
+ * the virtual IDs of `children`, in paint order.
38
+ * - `path` names the nested instance nodes passed through and then the
39
+ * layer itself; frames passed through inside one component are left out,
40
+ * as component roots are, since node IDs are unique in the document.
41
+ * - The root layer stands for the instance itself: its `virtualId` is the
42
+ * instance's own ID, its `path` is `[component root ID]` (the override key
43
+ * for the instance's paints and size), and its `node` is a `FrameNode`
44
+ * carrying the instance's `NodeBase` fields, `frame`, `rotation`, flips
45
+ * and `resizing`, with the component root's `layout`, `style` and
46
+ * `clipContent` (overrides applied). `instance` names the stored instance.
47
+ * A nested instance layer's `path` is the path to the nested instance
48
+ * node, which is also its override key on the outer instance for its
49
+ * paints and sizing, as `editTargetFor` writes it.
50
+ * - A nested instance inside the component is expanded the same way: its
51
+ * `node` is a `FrameNode` built like the root layer (the nested instance
52
+ * node's placement and `NodeBase` fields, after the outer overrides, with
53
+ * the nested component root's `layout`, `style` and `clipContent`),
54
+ * `instance` gives the nested instance and the component it shows after
55
+ * any swap, and `children` are the nested component's layers, whose paths
56
+ * continue through it.
57
+ * @since 0.23.0
58
+ */
59
+ export interface ResolvedLayer {
60
+ readonly virtualId: NodeId;
61
+ /** The component node this layer is derived from. */
62
+ readonly sourceNodeId: NodeId;
63
+ /** The layer path inside the outermost instance; see `VirtualNodeId.path`. */
64
+ readonly path: readonly NodeId[];
65
+ readonly node: SceneNode;
66
+ readonly children: readonly ResolvedLayer[];
67
+ /** Present on the root layer and on nested instance layers. */
68
+ readonly instance?: ResolvedLayerInstance;
69
+ /**
70
+ * The variable modes the layer inherits from its parent layer, as
71
+ * `inheritedVariableModes` gives them for a stored node; the layer's own
72
+ * choices (an instance's, for the root and nested instance layers) are
73
+ * not included. Present on the layers of a resolved instance.
74
+ * @since 0.26.0
75
+ */
76
+ readonly inheritedVariableModes?: VariableModes;
77
+ /**
78
+ * The variable modes in effect at the layer, which its bound fields read.
79
+ * Present on the layers of a resolved instance.
80
+ * @since 0.26.0
81
+ */
82
+ readonly variableModes?: VariableModes;
83
+ /**
84
+ * Present on a slot frame layer (a frame bound to a slot property that
85
+ * exists): the slot property, the `layerPathKey` of the nested instance
86
+ * path the slot belongs to inside the outermost instance (`""` for the
87
+ * outermost instance's own slot), which is the key an outer fill is stored
88
+ * under in `InstanceNode.slots`, and the host whose content the layer
89
+ * shows. Without `hostId` the layer shows the default content.
90
+ * @since 0.37.0
91
+ */
92
+ readonly slot?: ResolvedLayerSlot;
93
+ /**
94
+ * On each top-level layer of a slot's content: the slot host that holds
95
+ * it. The content of a stored instance's slot keeps its stored IDs as
96
+ * `virtualId`.
97
+ * @since 0.37.0
98
+ */
99
+ readonly slotHostId?: NodeId;
100
+ /**
101
+ * On the layers of an instance inside slot content (its root layer and
102
+ * the layers derived from its component): that stored instance, which
103
+ * `path` and `slot.pathKey` are relative to and whose `overrides` and
104
+ * `slots` they key. Absent on every other layer, whose `path` is relative
105
+ * to the instance resolved (or, on a stored content layer, is its own ID).
106
+ * @since 0.37.0
107
+ */
108
+ readonly pathInstanceId?: NodeId;
109
+ }
110
+ /**
111
+ * The slot a slot frame layer stands for; see `ResolvedLayer.slot`.
112
+ * @since 0.37.0
113
+ */
114
+ export interface ResolvedLayerSlot {
115
+ readonly propertyId: ComponentPropertyId;
116
+ readonly pathKey: string;
117
+ readonly hostId?: NodeId;
118
+ }
119
+ /**
120
+ * What `resolveInstance` returns: the instance's derived layer tree.
121
+ * @since 0.23.0
122
+ */
123
+ export interface ResolvedInstance {
124
+ readonly instanceId: NodeId;
125
+ readonly componentId: ComponentId;
126
+ /** The layer standing for the instance itself; see `ResolvedLayer`. */
127
+ readonly root: ResolvedLayer;
128
+ /** Every resolved layer by virtual ID, the root under the instance ID. */
129
+ readonly layers: ReadonlyMap<NodeId, ResolvedLayer>;
130
+ /**
131
+ * The components this instance draws, its own first, then every nested
132
+ * one after swaps, without repeats. A change to any of them changes the
133
+ * result.
134
+ */
135
+ readonly componentIds: readonly ComponentId[];
136
+ /**
137
+ * Computed values this instance's property values make invalid, such as
138
+ * a font family with no font in the document, for every component it
139
+ * draws; each such field shows its stored value.
140
+ * @since 0.25.0
141
+ */
142
+ readonly expressionErrors: readonly ComponentExpressionError[];
143
+ }
144
+ /**
145
+ * Resolved trees kept between calls so a component is resolved once for all
146
+ * its instances (design 4.3). One cache belongs to one document line; call
147
+ * `clear` when the document is replaced.
148
+ *
149
+ * A component's version rises when any node in its own layer tree is a new
150
+ * object, and goes back to an earlier one when a document shows that earlier
151
+ * tree again; an entry is reused only while every component it draws keeps
152
+ * its version and the theme and assets are the same objects. An instance
153
+ * entry also needs the instance node itself to be the same object, or one
154
+ * with the same fields, and no drawn text size it read to have changed.
155
+ * @since 0.23.0
156
+ */
157
+ export interface InstanceResolveCache {
158
+ clear(): void;
159
+ /**
160
+ * How many `resolveInstance` and `resolveComponent` calls were served from
161
+ * the cache, and how many times a component's conditions and computed
162
+ * fields were evaluated (`evaluations`, since 0.25.0): once per component,
163
+ * component version, variables and property values with defaults filled
164
+ * in, however many instances share them. `contentReads` (since 0.37.0)
165
+ * counts the stored slot content nodes read to check that a cached
166
+ * instance's content is unchanged, which happens only after a document
167
+ * that no recorded edit made from the last one (a load). `treeReads`
168
+ * (since 0.38.0) counts the component layer trees read to find which
169
+ * components a new node table changed: only the trees holding a node the
170
+ * edits since the last document changed, or every tree after a load.
171
+ */
172
+ readonly stats: {
173
+ readonly hits: number;
174
+ readonly misses: number;
175
+ readonly evaluations: number;
176
+ readonly contentReads: number;
177
+ readonly treeReads: number;
178
+ };
179
+ }
180
+ /** @since 0.23.0 */
181
+ export interface ResolveInstanceOptions {
182
+ readonly cache?: InstanceResolveCache;
183
+ /**
184
+ * The variable modes the instance inherits from its parent, as
185
+ * `inheritedVariableModes` returns them. Read from the document when
186
+ * omitted; the page compiler passes them as it walks the page.
187
+ * @since 0.26.0
188
+ */
189
+ readonly variableModes?: VariableModes;
190
+ }
191
+ /**
192
+ * Tells `cache` that the slot content of `instanceIds` changed in a node
193
+ * record that is written in place: the content of a slot each owns, or of a
194
+ * slot inside that content. A new record object is read from the edits that
195
+ * made it, but a write to the record the cache already read is not seen, so
196
+ * code that writes slot hosts or content into a working record calls this
197
+ * with every owner up the chain (`slotOwnersOf`).
198
+ * @since 0.37.0
199
+ */
200
+ export declare function noteSlotContentChanged(cache: InstanceResolveCache, instanceIds: Iterable<NodeId>): void;
201
+ /**
202
+ * Tells `cache` that the layer trees of `componentIds` changed in a node
203
+ * record that is written in place. The cache notices a new record object by
204
+ * itself, but not a write to the record it already read, so code that lays
205
+ * out a working record calls this after each write to a component's layers.
206
+ */
207
+ export declare function noteComponentTreesChanged(cache: InstanceResolveCache, componentIds: Iterable<ComponentId>): void;
208
+ /**
209
+ * Whether a drawn text size that `result`, an instance `resolveInstance`
210
+ * resolved with a cache, read may have changed since the drawn text sizes
211
+ * version `version` (`getDrawnTextSizesVersion`). True when the sizes it
212
+ * read are not known (resolved without a cache, or before any size was
213
+ * drawn) or the sizer no longer lists its changes that far back; false when
214
+ * no size was recorded since, or none it read changed. A caller that keeps
215
+ * resolved instances re-resolves only those for which this is true.
216
+ * @since 0.37.0
217
+ */
218
+ export declare function resolvedTextSizesChangedSince(document: DesignDocument, result: ResolvedInstance, version: number): boolean;
219
+ /** Makes an `InstanceResolveCache` to pass to `resolveInstance`. */
220
+ export declare function createInstanceResolveCache(): InstanceResolveCache;
221
+ /**
222
+ * The cache that everything resolving the open document's instances shares:
223
+ * the layout cascade, the page compiler, the accessibility tree, the
224
+ * selection and the text font scan. Entries are kept by instance node object
225
+ * and checked against the document they are read for, so the stored document
226
+ * and the laid-out one each hit their own, and the instances both share are
227
+ * resolved once for all of them. The host clears it when another document is
228
+ * opened.
229
+ * @since 0.37.0
230
+ */
231
+ export declare function sharedInstanceResolveCache(): InstanceResolveCache;
232
+ /**
233
+ * Tells `cache` that `working` holds the node entries of `base` at every ID
234
+ * but `changedNodeIds`, for a document built outside recorded edits (the
235
+ * cascade's view of its working record). The cache then reads again only the
236
+ * component trees holding one of those nodes when it moves between `working`
237
+ * and documents linked to `base`, instead of every tree. Later writes into
238
+ * `working` in place are told with `noteComponentTreesChanged`.
239
+ * @since 0.37.0
240
+ */
241
+ export declare function noteWorkingDocument(cache: InstanceResolveCache, working: DesignDocument, base: DesignDocument, changedNodeIds: Iterable<NodeId>): void;
242
+ /**
243
+ * The expressions and conditions on `componentId`'s layers that do not parse
244
+ * or check, in tree order. Each is left out when the component is resolved:
245
+ * the field shows its stored value, and a condition counts as no condition
246
+ * (design 8.5). After them come the computed values the default property
247
+ * values make invalid, such as a font family with no font in the document,
248
+ * which show their stored value too. A nested component's errors are listed
249
+ * under its own ID.
250
+ * @since 0.25.0
251
+ */
252
+ export declare function componentExpressionErrors(document: DesignDocument, componentId: ComponentId, options?: ResolveInstanceOptions): readonly ComponentExpressionError[];
253
+ /** Which variable properties a plain override value replaces (design 3.5, rule 2). */
254
+ export declare const PROPERTIES_DROPPED_BY_FIELD: Readonly<Partial<Record<keyof LayerOverride, readonly VariableProperty[]>>>;
255
+ /** The variable property each side of a `padding` override replaces: a side drops only its own binding. */
256
+ export declare const PADDING_PROPERTIES: Readonly<Record<keyof LayoutPadding, VariableProperty>>;
257
+ /** The variable property each `textStyle` override member replaces: a member drops only its own binding. */
258
+ export declare const TEXT_STYLE_PROPERTIES: Readonly<Record<string, VariableProperty>>;
259
+ /**
260
+ * `paragraphs` as an instance draws them under an override: its `textStyleId` (null takes the style away) and its
261
+ * `textStyle` over every run, the `textStyle` over each run's own overrides. List markers are left as they are.
262
+ */
263
+ export declare function restyledParagraphs(paragraphs: readonly TextParagraph[], override: Pick<LayerOverride, "textStyleId" | "textStyle">): readonly TextParagraph[];
264
+ /**
265
+ * Whether an instance was resized away from its component's size, which a
266
+ * swap keeps (as in Figma). An axis on which the component root hugs, after
267
+ * the instance's own sizing override and Fill, does not count: its size
268
+ * follows the content, so a longer label is not a resize.
269
+ */
270
+ export declare function resizedAwayFromComponent(document: DesignDocument, instance: InstanceNode): boolean;
271
+ /**
272
+ * One text or code layer of a stored instance, as `instanceTextLayers` gives
273
+ * it; the fields are those of `ResolvedLayer`.
274
+ * @since 0.37.0
275
+ */
276
+ export interface ResolvedTextLayer {
277
+ readonly virtualId: NodeId;
278
+ readonly sourceNodeId: NodeId;
279
+ readonly path: readonly NodeId[];
280
+ readonly node: TextNode | CodeNode;
281
+ readonly pathInstanceId?: NodeId;
282
+ }
283
+ /**
284
+ * The text and code layers of the stored instance `instanceId`, in the
285
+ * order `resolveInstance` lists its layers, with the words, styles and fonts
286
+ * it gives them, but without layout: no auto layout, constraint or group
287
+ * fitting runs and no text is measured, so each keeps the frame its
288
+ * component stores, an overridden or computed text that sizes itself too.
289
+ * The instance's other layers are not built. For readers of words and
290
+ * fonts, such as a document's font scan, that must not measure text. A
291
+ * cache may be shared with `resolveInstance`; the components computed
292
+ * without measuring are kept apart in it.
293
+ *
294
+ * Throws as `resolveInstance` does.
295
+ * @since 0.37.0
296
+ */
297
+ export declare function instanceTextLayers(document: DesignDocument, instanceId: NodeId, options?: ResolveInstanceOptions): readonly ResolvedTextLayer[];
298
+ /**
299
+ * Every component a resolved instance's rendering goes through, each once: those it draws (its own, then each
300
+ * nested one after overrides, property values, their defaults and swaps) and those whose trees refused a computed
301
+ * swap in it. A change to any of them can change what the instance shows.
302
+ */
303
+ export declare function resolvedInstanceComponents(result: ResolvedInstance): ComponentId[];
304
+ /**
305
+ * Derives the layers an instance shows: virtual IDs, overrides applied by
306
+ * precedence, nested instances expanded, and the component root's auto
307
+ * layout run for the instance's size and overridden text. A hugging axis
308
+ * takes its natural size, whatever the stored frame says; a fixed axis and
309
+ * an axis the instance fills keep the stored size.
310
+ *
311
+ * With component properties (design 8.6, since 0.25.0), each component in
312
+ * the instance is resolved in this order: conditions leave layers out (with
313
+ * their sublayers, taking no space in auto layout), computed fields are
314
+ * evaluated for the instance's property values and written into the model
315
+ * fields, overrides go on top (an override wins over a computed value), and
316
+ * then layout runs. A nested instance's property values are its outer
317
+ * override, else its expression over the outer properties, else its stored
318
+ * value, else the nested component's default. An expression that does not
319
+ * check is skipped (see `componentExpressionErrors`). A resized instance
320
+ * places the root's children by their constraints (`constrainChildren`):
321
+ * every child of a root without auto layout, and the absolute children of
322
+ * an auto layout root.
323
+ *
324
+ * Throws a `ModelError` with code `INVALID_TREE` when `instanceId` is not
325
+ * an instance node or its component is missing.
326
+ * @since 0.23.0
327
+ */
328
+ export declare function resolveInstance(document: DesignDocument, instanceId: NodeId, options?: ResolveInstanceOptions): ResolvedInstance;
329
+ /**
330
+ * Derives the component view: the component's own layer tree at its natural
331
+ * size with no overrides, as `ResolvedLayer`s whose `virtualId`s are the
332
+ * stored node IDs. Isolation mode draws it; a nested instance inside it is
333
+ * expanded as in `resolveInstance`, under its own stored ID. A component
334
+ * with properties or expressions shows its default values (design 8.9):
335
+ * conditions and computed fields are evaluated with the defaults, and its
336
+ * auto layout frames are laid out again.
337
+ * @since 0.23.0
338
+ */
339
+ export declare function resolveComponent(document: DesignDocument, componentId: ComponentId, options?: ResolveInstanceOptions): ResolvedLayer;
340
+ /**
341
+ * The size an instance takes on each axis it hugs, from its resolved root.
342
+ * `undefined` on an axis the instance keeps as stored (Fixed, Fill, or a
343
+ * component root without auto layout).
344
+ * @since 0.23.0
345
+ */
346
+ export declare function huggedInstanceSize(document: DesignDocument, instanceId: NodeId, options?: ResolveInstanceOptions): {
347
+ readonly width?: number;
348
+ readonly height?: number;
349
+ };
350
+ /** The `huggedInstanceSize` of an instance already resolved. */
351
+ export declare function huggedSizeOf(resolved: ResolvedInstance): {
352
+ readonly width?: number;
353
+ readonly height?: number;
354
+ };
355
+ /**
356
+ * Every node the renderer draws, for code that scans the document for the
357
+ * fonts, characters or assets its text uses: the stored nodes (page layers
358
+ * and component layers, but no slot host and no slot content), then the layers of every stored instance outside
359
+ * slot content as
360
+ * `resolveInstance` derives them, with the instance's overrides, property
361
+ * values and nested instances applied and the virtual ID as `id`. Text or a
362
+ * font that exists only in an override is found here and nowhere in
363
+ * `document.nodes`. An instance that cannot be resolved (a missing component
364
+ * or a nesting cycle) adds no layers; the compiler reports that itself.
365
+ * Slot content is listed once, as the layers of the instance that draws it
366
+ * (since 0.37.0), so content its instance does not draw, such as dormant
367
+ * content whose slot frame a condition leaves out, is not listed.
368
+ * The same document object gives the same array, and unchanged instances
369
+ * give the same layer objects, so per-node caches keyed by object stay warm.
370
+ * @since 0.26.0
371
+ */
372
+ export declare function drawnNodes(document: DesignDocument): readonly SceneNode[];