figma-inspect-cli 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 (430) hide show
  1. package/README.md +156 -0
  2. package/dist/bin/figma-inspect.d.ts +3 -0
  3. package/dist/bin/figma-inspect.d.ts.map +1 -0
  4. package/dist/bin/figma-inspect.js +19 -0
  5. package/dist/bin/figma-inspect.js.map +1 -0
  6. package/dist/cli/errors.d.ts +3 -0
  7. package/dist/cli/errors.d.ts.map +1 -0
  8. package/dist/cli/errors.js +3 -0
  9. package/dist/cli/errors.js.map +1 -0
  10. package/dist/cli/export-component-set.d.ts +21 -0
  11. package/dist/cli/export-component-set.d.ts.map +1 -0
  12. package/dist/cli/export-component-set.js +173 -0
  13. package/dist/cli/export-component-set.js.map +1 -0
  14. package/dist/cli/export-contract.d.ts +20 -0
  15. package/dist/cli/export-contract.d.ts.map +1 -0
  16. package/dist/cli/export-contract.js +48 -0
  17. package/dist/cli/export-contract.js.map +1 -0
  18. package/dist/cli/export-node-contract.d.ts +17 -0
  19. package/dist/cli/export-node-contract.d.ts.map +1 -0
  20. package/dist/cli/export-node-contract.js +93 -0
  21. package/dist/cli/export-node-contract.js.map +1 -0
  22. package/dist/cli/export-result.d.ts +17 -0
  23. package/dist/cli/export-result.d.ts.map +1 -0
  24. package/dist/cli/export-result.js +22 -0
  25. package/dist/cli/export-result.js.map +1 -0
  26. package/dist/cli/export-team-index.d.ts +18 -0
  27. package/dist/cli/export-team-index.d.ts.map +1 -0
  28. package/dist/cli/export-team-index.js +121 -0
  29. package/dist/cli/export-team-index.js.map +1 -0
  30. package/dist/cli/index.d.ts +3 -0
  31. package/dist/cli/index.d.ts.map +1 -0
  32. package/dist/cli/index.js +3 -0
  33. package/dist/cli/index.js.map +1 -0
  34. package/dist/cli/output.d.ts +13 -0
  35. package/dist/cli/output.d.ts.map +1 -0
  36. package/dist/cli/output.js +26 -0
  37. package/dist/cli/output.js.map +1 -0
  38. package/dist/cli/parse-args.d.ts +3 -0
  39. package/dist/cli/parse-args.d.ts.map +1 -0
  40. package/dist/cli/parse-args.js +790 -0
  41. package/dist/cli/parse-args.js.map +1 -0
  42. package/dist/cli/run-cli.d.ts +3 -0
  43. package/dist/cli/run-cli.d.ts.map +1 -0
  44. package/dist/cli/run-cli.js +416 -0
  45. package/dist/cli/run-cli.js.map +1 -0
  46. package/dist/cli/types.d.ts +114 -0
  47. package/dist/cli/types.d.ts.map +1 -0
  48. package/dist/cli/types.js +2 -0
  49. package/dist/cli/types.js.map +1 -0
  50. package/dist/cli/usage.d.ts +2 -0
  51. package/dist/cli/usage.d.ts.map +1 -0
  52. package/dist/cli/usage.js +75 -0
  53. package/dist/cli/usage.js.map +1 -0
  54. package/dist/figma-api/cache/cached-request.d.ts +8 -0
  55. package/dist/figma-api/cache/cached-request.d.ts.map +1 -0
  56. package/dist/figma-api/cache/cached-request.js +100 -0
  57. package/dist/figma-api/cache/cached-request.js.map +1 -0
  58. package/dist/figma-api/cache/constants.d.ts +5 -0
  59. package/dist/figma-api/cache/constants.d.ts.map +1 -0
  60. package/dist/figma-api/cache/constants.js +5 -0
  61. package/dist/figma-api/cache/constants.js.map +1 -0
  62. package/dist/figma-api/cache/extract-metadata.d.ts +3 -0
  63. package/dist/figma-api/cache/extract-metadata.d.ts.map +1 -0
  64. package/dist/figma-api/cache/extract-metadata.js +13 -0
  65. package/dist/figma-api/cache/extract-metadata.js.map +1 -0
  66. package/dist/figma-api/cache/index.d.ts +3 -0
  67. package/dist/figma-api/cache/index.d.ts.map +1 -0
  68. package/dist/figma-api/cache/index.js +3 -0
  69. package/dist/figma-api/cache/index.js.map +1 -0
  70. package/dist/figma-api/cache/store.d.ts +10 -0
  71. package/dist/figma-api/cache/store.d.ts.map +1 -0
  72. package/dist/figma-api/cache/store.js +53 -0
  73. package/dist/figma-api/cache/store.js.map +1 -0
  74. package/dist/figma-api/cache/types.d.ts +20 -0
  75. package/dist/figma-api/cache/types.d.ts.map +1 -0
  76. package/dist/figma-api/cache/types.js +2 -0
  77. package/dist/figma-api/cache/types.js.map +1 -0
  78. package/dist/figma-api/cache/url.d.ts +5 -0
  79. package/dist/figma-api/cache/url.d.ts.map +1 -0
  80. package/dist/figma-api/cache/url.js +20 -0
  81. package/dist/figma-api/cache/url.js.map +1 -0
  82. package/dist/figma-api/constants.d.ts +2 -0
  83. package/dist/figma-api/constants.d.ts.map +1 -0
  84. package/dist/figma-api/constants.js +2 -0
  85. package/dist/figma-api/constants.js.map +1 -0
  86. package/dist/figma-api/fetch-with-retry.d.ts +2 -0
  87. package/dist/figma-api/fetch-with-retry.d.ts.map +1 -0
  88. package/dist/figma-api/fetch-with-retry.js +48 -0
  89. package/dist/figma-api/fetch-with-retry.js.map +1 -0
  90. package/dist/figma-api/figma-api-error.d.ts +4 -0
  91. package/dist/figma-api/figma-api-error.d.ts.map +1 -0
  92. package/dist/figma-api/figma-api-error.js +7 -0
  93. package/dist/figma-api/figma-api-error.js.map +1 -0
  94. package/dist/figma-api/figma-request.d.ts +2 -0
  95. package/dist/figma-api/figma-request.d.ts.map +1 -0
  96. package/dist/figma-api/figma-request.js +21 -0
  97. package/dist/figma-api/figma-request.js.map +1 -0
  98. package/dist/figma-api/format-figma-error.d.ts +2 -0
  99. package/dist/figma-api/format-figma-error.d.ts.map +1 -0
  100. package/dist/figma-api/format-figma-error.js +24 -0
  101. package/dist/figma-api/format-figma-error.js.map +1 -0
  102. package/dist/figma-api/get-component-set.d.ts +4 -0
  103. package/dist/figma-api/get-component-set.d.ts.map +1 -0
  104. package/dist/figma-api/get-component-set.js +8 -0
  105. package/dist/figma-api/get-component-set.js.map +1 -0
  106. package/dist/figma-api/get-file-images.d.ts +4 -0
  107. package/dist/figma-api/get-file-images.d.ts.map +1 -0
  108. package/dist/figma-api/get-file-images.js +45 -0
  109. package/dist/figma-api/get-file-images.js.map +1 -0
  110. package/dist/figma-api/get-file-node.d.ts +3 -0
  111. package/dist/figma-api/get-file-node.d.ts.map +1 -0
  112. package/dist/figma-api/get-file-node.js +8 -0
  113. package/dist/figma-api/get-file-node.js.map +1 -0
  114. package/dist/figma-api/get-file.d.ts +3 -0
  115. package/dist/figma-api/get-file.d.ts.map +1 -0
  116. package/dist/figma-api/get-file.js +6 -0
  117. package/dist/figma-api/get-file.js.map +1 -0
  118. package/dist/figma-api/index.d.ts +11 -0
  119. package/dist/figma-api/index.d.ts.map +1 -0
  120. package/dist/figma-api/index.js +11 -0
  121. package/dist/figma-api/index.js.map +1 -0
  122. package/dist/figma-api/list-file-component-sets.d.ts +4 -0
  123. package/dist/figma-api/list-file-component-sets.d.ts.map +1 -0
  124. package/dist/figma-api/list-file-component-sets.js +8 -0
  125. package/dist/figma-api/list-file-component-sets.js.map +1 -0
  126. package/dist/figma-api/list-file-components.d.ts +5 -0
  127. package/dist/figma-api/list-file-components.d.ts.map +1 -0
  128. package/dist/figma-api/list-file-components.js +13 -0
  129. package/dist/figma-api/list-file-components.js.map +1 -0
  130. package/dist/figma-api/list-file-pages.d.ts +4 -0
  131. package/dist/figma-api/list-file-pages.d.ts.map +1 -0
  132. package/dist/figma-api/list-file-pages.js +10 -0
  133. package/dist/figma-api/list-file-pages.js.map +1 -0
  134. package/dist/figma-api/list-project-files.d.ts +4 -0
  135. package/dist/figma-api/list-project-files.d.ts.map +1 -0
  136. package/dist/figma-api/list-project-files.js +8 -0
  137. package/dist/figma-api/list-project-files.js.map +1 -0
  138. package/dist/figma-api/list-team-component-sets.d.ts +4 -0
  139. package/dist/figma-api/list-team-component-sets.d.ts.map +1 -0
  140. package/dist/figma-api/list-team-component-sets.js +19 -0
  141. package/dist/figma-api/list-team-component-sets.js.map +1 -0
  142. package/dist/figma-api/list-team-project-files.d.ts +4 -0
  143. package/dist/figma-api/list-team-project-files.d.ts.map +1 -0
  144. package/dist/figma-api/list-team-project-files.js +19 -0
  145. package/dist/figma-api/list-team-project-files.js.map +1 -0
  146. package/dist/figma-api/list-team-projects.d.ts +4 -0
  147. package/dist/figma-api/list-team-projects.d.ts.map +1 -0
  148. package/dist/figma-api/list-team-projects.js +8 -0
  149. package/dist/figma-api/list-team-projects.js.map +1 -0
  150. package/dist/figma-api/schemas.d.ts +95 -0
  151. package/dist/figma-api/schemas.d.ts.map +1 -0
  152. package/dist/figma-api/schemas.js +154 -0
  153. package/dist/figma-api/schemas.js.map +1 -0
  154. package/dist/figma-api/types.d.ts +60 -0
  155. package/dist/figma-api/types.d.ts.map +1 -0
  156. package/dist/figma-api/types.js +2 -0
  157. package/dist/figma-api/types.js.map +1 -0
  158. package/dist/inspect/component-set-context.d.ts +11 -0
  159. package/dist/inspect/component-set-context.d.ts.map +1 -0
  160. package/dist/inspect/component-set-context.js +71 -0
  161. package/dist/inspect/component-set-context.js.map +1 -0
  162. package/dist/inspect/component-set-lookup.d.ts +6 -0
  163. package/dist/inspect/component-set-lookup.d.ts.map +1 -0
  164. package/dist/inspect/component-set-lookup.js +40 -0
  165. package/dist/inspect/component-set-lookup.js.map +1 -0
  166. package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts +3 -0
  167. package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts.map +1 -0
  168. package/dist/inspect/component-set-pseudocode/asset-backed-contract.js +34 -0
  169. package/dist/inspect/component-set-pseudocode/asset-backed-contract.js.map +1 -0
  170. package/dist/inspect/component-set-pseudocode/assets-contract.d.ts +9 -0
  171. package/dist/inspect/component-set-pseudocode/assets-contract.d.ts.map +1 -0
  172. package/dist/inspect/component-set-pseudocode/assets-contract.js +4 -0
  173. package/dist/inspect/component-set-pseudocode/assets-contract.js.map +1 -0
  174. package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts +17 -0
  175. package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts.map +1 -0
  176. package/dist/inspect/component-set-pseudocode/baseline-contract.js +67 -0
  177. package/dist/inspect/component-set-pseudocode/baseline-contract.js.map +1 -0
  178. package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts +24 -0
  179. package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts.map +1 -0
  180. package/dist/inspect/component-set-pseudocode/build-pseudocode.js +83 -0
  181. package/dist/inspect/component-set-pseudocode/build-pseudocode.js.map +1 -0
  182. package/dist/inspect/component-set-pseudocode/index.d.ts +2 -0
  183. package/dist/inspect/component-set-pseudocode/index.d.ts.map +1 -0
  184. package/dist/inspect/component-set-pseudocode/index.js +2 -0
  185. package/dist/inspect/component-set-pseudocode/index.js.map +1 -0
  186. package/dist/inspect/component-set-pseudocode/infer.d.ts +4 -0
  187. package/dist/inspect/component-set-pseudocode/infer.d.ts.map +1 -0
  188. package/dist/inspect/component-set-pseudocode/infer.js +426 -0
  189. package/dist/inspect/component-set-pseudocode/infer.js.map +1 -0
  190. package/dist/inspect/component-set-pseudocode/meta-contract.d.ts +27 -0
  191. package/dist/inspect/component-set-pseudocode/meta-contract.d.ts.map +1 -0
  192. package/dist/inspect/component-set-pseudocode/meta-contract.js +136 -0
  193. package/dist/inspect/component-set-pseudocode/meta-contract.js.map +1 -0
  194. package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts +14 -0
  195. package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts.map +1 -0
  196. package/dist/inspect/component-set-pseudocode/slim-node-guards.js +28 -0
  197. package/dist/inspect/component-set-pseudocode/slim-node-guards.js.map +1 -0
  198. package/dist/inspect/component-set-pseudocode/structure-contract.d.ts +71 -0
  199. package/dist/inspect/component-set-pseudocode/structure-contract.d.ts.map +1 -0
  200. package/dist/inspect/component-set-pseudocode/structure-contract.js +281 -0
  201. package/dist/inspect/component-set-pseudocode/structure-contract.js.map +1 -0
  202. package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts +3 -0
  203. package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts.map +1 -0
  204. package/dist/inspect/component-set-pseudocode/structure-dsl.js +170 -0
  205. package/dist/inspect/component-set-pseudocode/structure-dsl.js.map +1 -0
  206. package/dist/inspect/component-set-pseudocode/types.d.ts +44 -0
  207. package/dist/inspect/component-set-pseudocode/types.d.ts.map +1 -0
  208. package/dist/inspect/component-set-pseudocode/types.js +2 -0
  209. package/dist/inspect/component-set-pseudocode/types.js.map +1 -0
  210. package/dist/inspect/component-set-pseudocode/universal.d.ts +14 -0
  211. package/dist/inspect/component-set-pseudocode/universal.d.ts.map +1 -0
  212. package/dist/inspect/component-set-pseudocode/universal.js +393 -0
  213. package/dist/inspect/component-set-pseudocode/universal.js.map +1 -0
  214. package/dist/inspect/component-set-spec/bound-variables.d.ts +14 -0
  215. package/dist/inspect/component-set-spec/bound-variables.d.ts.map +1 -0
  216. package/dist/inspect/component-set-spec/bound-variables.js +53 -0
  217. package/dist/inspect/component-set-spec/bound-variables.js.map +1 -0
  218. package/dist/inspect/component-set-spec/build-spec.d.ts +9 -0
  219. package/dist/inspect/component-set-spec/build-spec.d.ts.map +1 -0
  220. package/dist/inspect/component-set-spec/build-spec.js +102 -0
  221. package/dist/inspect/component-set-spec/build-spec.js.map +1 -0
  222. package/dist/inspect/component-set-spec/compact-spec.d.ts +3 -0
  223. package/dist/inspect/component-set-spec/compact-spec.d.ts.map +1 -0
  224. package/dist/inspect/component-set-spec/compact-spec.js +357 -0
  225. package/dist/inspect/component-set-spec/compact-spec.js.map +1 -0
  226. package/dist/inspect/component-set-spec/extract-slots.d.ts +5 -0
  227. package/dist/inspect/component-set-spec/extract-slots.d.ts.map +1 -0
  228. package/dist/inspect/component-set-spec/extract-slots.js +57 -0
  229. package/dist/inspect/component-set-spec/extract-slots.js.map +1 -0
  230. package/dist/inspect/component-set-spec/figma-node.d.ts +9 -0
  231. package/dist/inspect/component-set-spec/figma-node.d.ts.map +1 -0
  232. package/dist/inspect/component-set-spec/figma-node.js +31 -0
  233. package/dist/inspect/component-set-spec/figma-node.js.map +1 -0
  234. package/dist/inspect/component-set-spec/index.d.ts +2 -0
  235. package/dist/inspect/component-set-spec/index.d.ts.map +1 -0
  236. package/dist/inspect/component-set-spec/index.js +2 -0
  237. package/dist/inspect/component-set-spec/index.js.map +1 -0
  238. package/dist/inspect/component-set-spec/parse-props.d.ts +9 -0
  239. package/dist/inspect/component-set-spec/parse-props.d.ts.map +1 -0
  240. package/dist/inspect/component-set-spec/parse-props.js +96 -0
  241. package/dist/inspect/component-set-spec/parse-props.js.map +1 -0
  242. package/dist/inspect/component-set-spec/prop-name.d.ts +5 -0
  243. package/dist/inspect/component-set-spec/prop-name.d.ts.map +1 -0
  244. package/dist/inspect/component-set-spec/prop-name.js +26 -0
  245. package/dist/inspect/component-set-spec/prop-name.js.map +1 -0
  246. package/dist/inspect/component-set-spec/resolve-tokens.d.ts +4 -0
  247. package/dist/inspect/component-set-spec/resolve-tokens.d.ts.map +1 -0
  248. package/dist/inspect/component-set-spec/resolve-tokens.js +42 -0
  249. package/dist/inspect/component-set-spec/resolve-tokens.js.map +1 -0
  250. package/dist/inspect/component-set-spec/slim-context.d.ts +6 -0
  251. package/dist/inspect/component-set-spec/slim-context.d.ts.map +1 -0
  252. package/dist/inspect/component-set-spec/slim-context.js +2 -0
  253. package/dist/inspect/component-set-spec/slim-context.js.map +1 -0
  254. package/dist/inspect/component-set-spec/slim-node.d.ts +5 -0
  255. package/dist/inspect/component-set-spec/slim-node.d.ts.map +1 -0
  256. package/dist/inspect/component-set-spec/slim-node.js +393 -0
  257. package/dist/inspect/component-set-spec/slim-node.js.map +1 -0
  258. package/dist/inspect/component-set-spec/slim-text-export.d.ts +8 -0
  259. package/dist/inspect/component-set-spec/slim-text-export.d.ts.map +1 -0
  260. package/dist/inspect/component-set-spec/slim-text-export.js +74 -0
  261. package/dist/inspect/component-set-spec/slim-text-export.js.map +1 -0
  262. package/dist/inspect/component-set-spec/team-component-registry.d.ts +19 -0
  263. package/dist/inspect/component-set-spec/team-component-registry.d.ts.map +1 -0
  264. package/dist/inspect/component-set-spec/team-component-registry.js +96 -0
  265. package/dist/inspect/component-set-spec/team-component-registry.js.map +1 -0
  266. package/dist/inspect/component-set-spec/types.d.ts +127 -0
  267. package/dist/inspect/component-set-spec/types.d.ts.map +1 -0
  268. package/dist/inspect/component-set-spec/types.js +2 -0
  269. package/dist/inspect/component-set-spec/types.js.map +1 -0
  270. package/dist/inspect/component-set-spec/variable-registry.d.ts +8 -0
  271. package/dist/inspect/component-set-spec/variable-registry.d.ts.map +1 -0
  272. package/dist/inspect/component-set-spec/variable-registry.js +74 -0
  273. package/dist/inspect/component-set-spec/variable-registry.js.map +1 -0
  274. package/dist/inspect/component-set-spec/variant-axes.d.ts +2 -0
  275. package/dist/inspect/component-set-spec/variant-axes.d.ts.map +1 -0
  276. package/dist/inspect/component-set-spec/variant-axes.js +14 -0
  277. package/dist/inspect/component-set-spec/variant-axes.js.map +1 -0
  278. package/dist/inspect/contract/contract-format.d.ts +5 -0
  279. package/dist/inspect/contract/contract-format.d.ts.map +1 -0
  280. package/dist/inspect/contract/contract-format.js +26 -0
  281. package/dist/inspect/contract/contract-format.js.map +1 -0
  282. package/dist/inspect/contract/contract-lock.d.ts +75 -0
  283. package/dist/inspect/contract/contract-lock.d.ts.map +1 -0
  284. package/dist/inspect/contract/contract-lock.js +326 -0
  285. package/dist/inspect/contract/contract-lock.js.map +1 -0
  286. package/dist/inspect/contract/contract-schema.d.ts +51 -0
  287. package/dist/inspect/contract/contract-schema.d.ts.map +1 -0
  288. package/dist/inspect/contract/contract-schema.js +130 -0
  289. package/dist/inspect/contract/contract-schema.js.map +1 -0
  290. package/dist/inspect/contract/fingerprint.d.ts +9 -0
  291. package/dist/inspect/contract/fingerprint.d.ts.map +1 -0
  292. package/dist/inspect/contract/fingerprint.js +301 -0
  293. package/dist/inspect/contract/fingerprint.js.map +1 -0
  294. package/dist/inspect/contract/lock-metadata.d.ts +30 -0
  295. package/dist/inspect/contract/lock-metadata.d.ts.map +1 -0
  296. package/dist/inspect/contract/lock-metadata.js +101 -0
  297. package/dist/inspect/contract/lock-metadata.js.map +1 -0
  298. package/dist/inspect/contract/stable-stringify.d.ts +2 -0
  299. package/dist/inspect/contract/stable-stringify.d.ts.map +1 -0
  300. package/dist/inspect/contract/stable-stringify.js +14 -0
  301. package/dist/inspect/contract/stable-stringify.js.map +1 -0
  302. package/dist/inspect/contract/verify-component-contract.d.ts +19 -0
  303. package/dist/inspect/contract/verify-component-contract.d.ts.map +1 -0
  304. package/dist/inspect/contract/verify-component-contract.js +126 -0
  305. package/dist/inspect/contract/verify-component-contract.js.map +1 -0
  306. package/dist/inspect/errors.d.ts +4 -0
  307. package/dist/inspect/errors.d.ts.map +1 -0
  308. package/dist/inspect/errors.js +7 -0
  309. package/dist/inspect/errors.js.map +1 -0
  310. package/dist/inspect/export/assert-asset-exportable.d.ts +3 -0
  311. package/dist/inspect/export/assert-asset-exportable.d.ts.map +1 -0
  312. package/dist/inspect/export/assert-asset-exportable.js +45 -0
  313. package/dist/inspect/export/assert-asset-exportable.js.map +1 -0
  314. package/dist/inspect/export/export-nested-assets.d.ts +94 -0
  315. package/dist/inspect/export/export-nested-assets.d.ts.map +1 -0
  316. package/dist/inspect/export/export-nested-assets.js +333 -0
  317. package/dist/inspect/export/export-nested-assets.js.map +1 -0
  318. package/dist/inspect/export/export-node-preview.d.ts +24 -0
  319. package/dist/inspect/export/export-node-preview.d.ts.map +1 -0
  320. package/dist/inspect/export/export-node-preview.js +34 -0
  321. package/dist/inspect/export/export-node-preview.js.map +1 -0
  322. package/dist/inspect/export/export-variant-assets.d.ts +18 -0
  323. package/dist/inspect/export/export-variant-assets.d.ts.map +1 -0
  324. package/dist/inspect/export/export-variant-assets.js +127 -0
  325. package/dist/inspect/export/export-variant-assets.js.map +1 -0
  326. package/dist/inspect/export/normalize-exported-svg.d.ts +2 -0
  327. package/dist/inspect/export/normalize-exported-svg.d.ts.map +1 -0
  328. package/dist/inspect/export/normalize-exported-svg.js +15 -0
  329. package/dist/inspect/export/normalize-exported-svg.js.map +1 -0
  330. package/dist/inspect/export/rendered-image-bytes.d.ts +4 -0
  331. package/dist/inspect/export/rendered-image-bytes.d.ts.map +1 -0
  332. package/dist/inspect/export/rendered-image-bytes.js +24 -0
  333. package/dist/inspect/export/rendered-image-bytes.js.map +1 -0
  334. package/dist/inspect/export-contract-target.d.ts +7 -0
  335. package/dist/inspect/export-contract-target.d.ts.map +1 -0
  336. package/dist/inspect/export-contract-target.js +33 -0
  337. package/dist/inspect/export-contract-target.js.map +1 -0
  338. package/dist/inspect/fetch-file-entry.d.ts +4 -0
  339. package/dist/inspect/fetch-file-entry.d.ts.map +1 -0
  340. package/dist/inspect/fetch-file-entry.js +7 -0
  341. package/dist/inspect/fetch-file-entry.js.map +1 -0
  342. package/dist/inspect/fetch-file-node-entry.d.ts +4 -0
  343. package/dist/inspect/fetch-file-node-entry.d.ts.map +1 -0
  344. package/dist/inspect/fetch-file-node-entry.js +7 -0
  345. package/dist/inspect/fetch-file-node-entry.js.map +1 -0
  346. package/dist/inspect/figma-node-url.d.ts +3 -0
  347. package/dist/inspect/figma-node-url.d.ts.map +1 -0
  348. package/dist/inspect/figma-node-url.js +30 -0
  349. package/dist/inspect/figma-node-url.js.map +1 -0
  350. package/dist/inspect/get-node-component-set.d.ts +5 -0
  351. package/dist/inspect/get-node-component-set.d.ts.map +1 -0
  352. package/dist/inspect/get-node-component-set.js +10 -0
  353. package/dist/inspect/get-node-component-set.js.map +1 -0
  354. package/dist/inspect/index.d.ts +17 -0
  355. package/dist/inspect/index.d.ts.map +1 -0
  356. package/dist/inspect/index.js +17 -0
  357. package/dist/inspect/index.js.map +1 -0
  358. package/dist/inspect/list-all-component-sets.d.ts +3 -0
  359. package/dist/inspect/list-all-component-sets.d.ts.map +1 -0
  360. package/dist/inspect/list-all-component-sets.js +27 -0
  361. package/dist/inspect/list-all-component-sets.js.map +1 -0
  362. package/dist/inspect/list-component-set-properties.d.ts +4 -0
  363. package/dist/inspect/list-component-set-properties.d.ts.map +1 -0
  364. package/dist/inspect/list-component-set-properties.js +73 -0
  365. package/dist/inspect/list-component-set-properties.js.map +1 -0
  366. package/dist/inspect/node-contract/build-node-contract.d.ts +12 -0
  367. package/dist/inspect/node-contract/build-node-contract.d.ts.map +1 -0
  368. package/dist/inspect/node-contract/build-node-contract.js +212 -0
  369. package/dist/inspect/node-contract/build-node-contract.js.map +1 -0
  370. package/dist/inspect/node-contract/dependencies.d.ts +5 -0
  371. package/dist/inspect/node-contract/dependencies.d.ts.map +1 -0
  372. package/dist/inspect/node-contract/dependencies.js +84 -0
  373. package/dist/inspect/node-contract/dependencies.js.map +1 -0
  374. package/dist/inspect/node-contract/index.d.ts +6 -0
  375. package/dist/inspect/node-contract/index.d.ts.map +1 -0
  376. package/dist/inspect/node-contract/index.js +6 -0
  377. package/dist/inspect/node-contract/index.js.map +1 -0
  378. package/dist/inspect/node-contract/node-kind.d.ts +9 -0
  379. package/dist/inspect/node-contract/node-kind.d.ts.map +1 -0
  380. package/dist/inspect/node-contract/node-kind.js +31 -0
  381. package/dist/inspect/node-contract/node-kind.js.map +1 -0
  382. package/dist/inspect/node-contract/node-lock.d.ts +6 -0
  383. package/dist/inspect/node-contract/node-lock.d.ts.map +1 -0
  384. package/dist/inspect/node-contract/node-lock.js +181 -0
  385. package/dist/inspect/node-contract/node-lock.js.map +1 -0
  386. package/dist/inspect/node-contract/node-schema.d.ts +14 -0
  387. package/dist/inspect/node-contract/node-schema.d.ts.map +1 -0
  388. package/dist/inspect/node-contract/node-schema.js +137 -0
  389. package/dist/inspect/node-contract/node-schema.js.map +1 -0
  390. package/dist/inspect/node-contract/paths.d.ts +10 -0
  391. package/dist/inspect/node-contract/paths.d.ts.map +1 -0
  392. package/dist/inspect/node-contract/paths.js +29 -0
  393. package/dist/inspect/node-contract/paths.js.map +1 -0
  394. package/dist/inspect/node-contract/tokens.d.ts +4 -0
  395. package/dist/inspect/node-contract/tokens.d.ts.map +1 -0
  396. package/dist/inspect/node-contract/tokens.js +30 -0
  397. package/dist/inspect/node-contract/tokens.js.map +1 -0
  398. package/dist/inspect/node-contract/types.d.ts +84 -0
  399. package/dist/inspect/node-contract/types.d.ts.map +1 -0
  400. package/dist/inspect/node-contract/types.js +2 -0
  401. package/dist/inspect/node-contract/types.js.map +1 -0
  402. package/dist/inspect/node-contract/verify-node-contract.d.ts +20 -0
  403. package/dist/inspect/node-contract/verify-node-contract.d.ts.map +1 -0
  404. package/dist/inspect/node-contract/verify-node-contract.js +131 -0
  405. package/dist/inspect/node-contract/verify-node-contract.js.map +1 -0
  406. package/dist/inspect/resolve-team-component-set.d.ts +14 -0
  407. package/dist/inspect/resolve-team-component-set.d.ts.map +1 -0
  408. package/dist/inspect/resolve-team-component-set.js +77 -0
  409. package/dist/inspect/resolve-team-component-set.js.map +1 -0
  410. package/dist/inspect/schemas.d.ts +37 -0
  411. package/dist/inspect/schemas.d.ts.map +1 -0
  412. package/dist/inspect/schemas.js +79 -0
  413. package/dist/inspect/schemas.js.map +1 -0
  414. package/dist/inspect/team-index.d.ts +76 -0
  415. package/dist/inspect/team-index.d.ts.map +1 -0
  416. package/dist/inspect/team-index.js +361 -0
  417. package/dist/inspect/team-index.js.map +1 -0
  418. package/dist/inspect/types.d.ts +46 -0
  419. package/dist/inspect/types.d.ts.map +1 -0
  420. package/dist/inspect/types.js +2 -0
  421. package/dist/inspect/types.js.map +1 -0
  422. package/dist/test/fixtures.d.ts +3 -0
  423. package/dist/test/fixtures.d.ts.map +1 -0
  424. package/dist/test/fixtures.js +6 -0
  425. package/dist/test/fixtures.js.map +1 -0
  426. package/dist/zod/parse-valid-entries.d.ts +4 -0
  427. package/dist/zod/parse-valid-entries.d.ts.map +1 -0
  428. package/dist/zod/parse-valid-entries.js +20 -0
  429. package/dist/zod/parse-valid-entries.js.map +1 -0
  430. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # figma-inspect-cli
2
+
3
+ Node.js CLI for inspecting Figma API resources and exporting AI-friendly
4
+ contracts for component sets, frames, and standalone components.
5
+
6
+ ## Setup
7
+
8
+ ```sh
9
+ npm install
10
+ npm run build
11
+ ```
12
+
13
+ Set the environment variables needed by API-backed commands:
14
+
15
+ ```sh
16
+ export FIGMA_API_TOKEN="figd_..."
17
+ export FIGMA_TEAM_ID="<team_id>"
18
+ ```
19
+
20
+ From the repository, run the compiled CLI with `npx .`:
21
+
22
+ ```sh
23
+ npx . --help
24
+ ```
25
+
26
+ For source-mode development, use `npm run dev -- <flags>`.
27
+
28
+ ## Commands
29
+
30
+ Only one command can be passed per invocation. `FIGMA_API_TOKEN` is required for
31
+ all API-backed commands and verification. `FIGMA_TEAM_ID` is required for
32
+ team-scoped commands, `--export-team-index`, `--export-component-set`, and
33
+ `--export-contract` when the target is a `COMPONENT_SET`.
34
+
35
+ | Command | Main arguments | Output |
36
+ |---|---|---|
37
+ | `--list-team-projects` | none | Team projects |
38
+ | `--list-project-files` | `--project-id <id>` | Files in one project |
39
+ | `--list-team-project-files` | none | Files across team projects |
40
+ | `--export-team-index` | `--output-dir <dir>` | `team.index.yaml` plus per-file `*.index.yaml` |
41
+ | `--list-team-component-sets` | none | Published team component sets |
42
+ | `--list-file-pages` | `--file-key <key>` | Pages in one file |
43
+ | `--list-file-component-sets` | `--file-key <key>` | Component sets in one file |
44
+ | `--inspect-component-set-properties` | `--url <figma-url>` or `--file-key <key> --node-id <id>` plus component set key/name | Nested component-set properties |
45
+ | `--inspect-component-set` | `--url <figma-url>` or `--file-key <key> --node-id <id>` plus component set key/name | Raw `COMPONENT_SET` node |
46
+ | `--inspect-team-component-set` | `--component-set-key <key>` or `--component-set-name <name>` | Raw published component set |
47
+ | `--inspect-file-node` | `--url <figma-url>` or `--file-key <key> --node-id <id>` | Raw file node |
48
+ | `--build-component-set-spec` | `--input <path> --variables <path>` | Compact local component-set spec |
49
+ | `--build-component-set-pseudocode` | `--input <path> --variables <path>` | Local component-set contract files |
50
+ | `--export-contract` | `--output-dir <dir> --variables <path>` plus URL or file/node ref | Auto-detected component-set, frame, or component contracts |
51
+ | `--export-component-set` | `--output-dir <dir> --variables <path>` plus URL or component set key/name | Component-set contracts |
52
+ | `--export-node-contract` | `--output-dir <dir> --variables <path>` plus URL or file/node ref | Frame or standalone component contracts |
53
+ | `--verify-component-contract` | `--contract-dir <dir>` | Component-set lock verification |
54
+ | `--verify-node-contract` | `--contract-dir <dir>` | Frame/component lock verification |
55
+
56
+ Common optional flags:
57
+
58
+ - `--json` prints JSON instead of YAML, or writes JSON data artifacts for export
59
+ commands. Lock files remain YAML and structure files remain DSL. `--json` is
60
+ not supported with `--export-team-index`.
61
+ - `--team-components <path>` is supported by local component-set build commands.
62
+ - `--export-preview`, `--preview-format png|svg`, and `--preview-scale <scale>`
63
+ write a root preview image next to exported contracts.
64
+ - `--export-assets` writes one SVG per component-set variant. It is supported by
65
+ `--export-component-set` and by `--export-contract` when the target is a
66
+ `COMPONENT_SET`.
67
+ - `--export-nested-assets` writes selected nested nodes as sidecar assets. Use
68
+ `--asset-node-id <id>` or `--asset-include-regex <regex>` to choose nodes.
69
+ `--asset-format svg|png`, `--asset-scale <scale>`, `--asset-node-types <csv>`,
70
+ and `--asset-max <number>` refine nested asset export.
71
+ - `--screen-similarity-threshold <number>` and `--screen-size-tolerance <px>`
72
+ refine screen grouping for `--export-team-index`.
73
+
74
+ ## Discovery
75
+
76
+ ```sh
77
+ npx . --list-team-projects
78
+ npx . --list-project-files --project-id <project_id>
79
+ npx . --list-team-project-files
80
+ npx . --export-team-index --output-dir tmp/figma-index
81
+ npx . --list-team-component-sets
82
+ npx . --list-file-pages --file-key <file_key>
83
+ npx . --list-file-component-sets --file-key <file_key>
84
+ ```
85
+
86
+ `--export-team-index` writes a compact `team.index.yaml` router plus one sibling
87
+ `*.index.yaml` per Figma file. Per-file indexes include component sets,
88
+ standalone components, screens, and screen groups. Detailed contracts are
89
+ exported later with `--export-contract`, `--export-component-set`, or
90
+ `--export-node-contract`.
91
+
92
+ ## Inspect
93
+
94
+ ```sh
95
+ npx . --inspect-component-set-properties --file-key <file_key> --node-id <node_id> --component-set-name Cell
96
+ npx . --inspect-component-set --file-key <file_key> --node-id <node_id> --component-set-key <component_set_key>
97
+ npx . --inspect-component-set --url "https://www.figma.com/design/<file_key>/<name>?node-id=<node_id>"
98
+ npx . --inspect-team-component-set --component-set-name Toast
99
+ npx . --inspect-file-node --file-key <file_key> --node-id <node_id>
100
+ npx . --inspect-file-node --url "https://www.figma.com/design/<file_key>/<name>?node-id=<node_id>"
101
+ ```
102
+
103
+ ## Local Build
104
+
105
+ Build local artifacts from a saved raw `COMPONENT_SET` JSON file:
106
+
107
+ ```sh
108
+ npx . --inspect-component-set ... --json > tmp/Toast.json
109
+ npx . --build-component-set-spec --input tmp/Toast.json --variables tmp/cp-ds-styles-variables-local.json
110
+ npx . --build-component-set-spec --input tmp/Toast.json --variables tmp/cp-ds-styles-variables-local.json --team-components tmp/ComponentSets.json
111
+ npx . --build-component-set-pseudocode --input tmp/Toast.json --variables tmp/cp-ds-styles-variables-local.json --output-dir tmp
112
+ ```
113
+
114
+ ## Export
115
+
116
+ `--export-contract` auto-detects supported node types:
117
+
118
+ - `COMPONENT_SET` writes `<Name>.component-set.{visuals,geometry,meta}.yaml`,
119
+ `<Name>.component-set.structure.dsl`, and `<Name>.component-set.lock.yaml`.
120
+ - `FRAME` writes `<Name>.frame.{visuals,geometry,meta}.yaml`,
121
+ `<Name>.frame.structure.dsl`, and `<Name>.frame.lock.yaml`.
122
+ - Standalone `COMPONENT` writes `<Name>.component.{visuals,geometry,meta}.yaml`,
123
+ `<Name>.component.structure.dsl`, and `<Name>.component.lock.yaml`.
124
+
125
+ ```sh
126
+ npx . --export-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "https://www.figma.com/design/<file_key>/<name>?node-id=<node_id>"
127
+ npx . --export-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --file-key <file_key> --node-id <node_id>
128
+ npx . --export-component-set --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --component-set-name RoadmapHeader
129
+ npx . --export-component-set --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<component_set_url>"
130
+ npx . --export-node-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<frame_or_component_url>"
131
+ ```
132
+
133
+ URL-based exports also write `import-notes.md`.
134
+
135
+ ## Assets And Previews
136
+
137
+ ```sh
138
+ npx . --export-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<figma_url>" --export-preview
139
+ npx . --export-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<figma_url>" --export-preview --preview-format svg
140
+ npx . --export-component-set --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --component-set-name ProfileStreakIcon --export-assets
141
+ npx . --export-node-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<frame_url>" --export-nested-assets --asset-node-id <nested_node_id>
142
+ npx . --export-node-contract --output-dir tmp --variables tmp/cp-ds-styles-variables-local.json --url "<frame_url>" --export-nested-assets --asset-include-regex "icon|logo" --asset-node-types INSTANCE,VECTOR --asset-format svg --asset-format png
143
+ ```
144
+
145
+ Variant asset export writes `<Name>.assets/*.svg` and references those paths from
146
+ `meta.assets`. Nested asset export writes `<Name>.assets/*.{svg,png}` plus
147
+ `<Name>.<kind>.nested-assets.yaml`.
148
+
149
+ ## Verify
150
+
151
+ ```sh
152
+ npx . --verify-component-contract --contract-dir tmp
153
+ npx . --verify-component-contract --contract-dir tmp --component-name Cell --json
154
+ npx . --verify-node-contract --contract-dir tmp
155
+ npx . --verify-node-contract --contract-dir tmp --node-name Settings --json
156
+ ```
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=figma-inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-inspect.d.ts","sourceRoot":"","sources":["../../src/bin/figma-inspect.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { CliError, runCli } from "../cli/index.js";
3
+ runCli(process.argv.slice(2), {
4
+ env: process.env,
5
+ stdout: process.stdout,
6
+ stderr: process.stderr,
7
+ }).catch((error) => {
8
+ if (error instanceof CliError) {
9
+ process.stderr.write(`${error.message}\n`);
10
+ }
11
+ else if (error instanceof Error) {
12
+ process.stderr.write(`Unexpected error: ${error.message}\n`);
13
+ }
14
+ else {
15
+ process.stderr.write("Unexpected error: unknown error\n");
16
+ }
17
+ process.exitCode = 1;
18
+ });
19
+ //# sourceMappingURL=figma-inspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-inspect.js","sourceRoot":"","sources":["../../src/bin/figma-inspect.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC5B,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,MAAM,EAAE,OAAO,CAAC,MAAM;CACvB,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC1B,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IAC7C,CAAC;SAAM,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare class CliError extends Error {
2
+ }
3
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/cli/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;CAAG"}
@@ -0,0 +1,3 @@
1
+ export class CliError extends Error {
2
+ }
3
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/cli/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG"}
@@ -0,0 +1,21 @@
1
+ import { type ContractFormat } from "../inspect/contract/contract-format.js";
2
+ import { type ExportPreviewOptions, type NestedAssetsOptions } from "../inspect/index.js";
3
+ import type { ComponentSetTarget } from "../inspect/types.js";
4
+ import type { ExportArtifactPathExtras, ExportArtifactPaths } from "./export-result.js";
5
+ export interface ExportComponentSetOptions {
6
+ token: string;
7
+ teamId: string;
8
+ outputDir: string;
9
+ componentSet: ComponentSetTarget;
10
+ sourceUrl?: string;
11
+ variablesPath: string;
12
+ exportAssets?: boolean;
13
+ assetFormat?: "svg";
14
+ nestedAssets?: NestedAssetsOptions;
15
+ preview?: ExportPreviewOptions;
16
+ format?: ContractFormat;
17
+ }
18
+ export interface ExportComponentSetResult extends ExportArtifactPaths, ExportArtifactPathExtras {
19
+ }
20
+ export declare function exportComponentSet(options: ExportComponentSetOptions): Promise<ExportComponentSetResult>;
21
+ //# sourceMappingURL=export-component-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-component-set.d.ts","sourceRoot":"","sources":["../../src/cli/export-component-set.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EAGpB,MAAM,wCAAwC,CAAC;AAoBhD,OAAO,EAEL,KAAK,oBAAoB,EAKzB,KAAK,mBAAmB,EAEzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,kBAAkB,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,wBACf,SAAQ,mBAAmB,EACzB,wBAAwB;CAAG;AAsD/B,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAmLnC"}
@@ -0,0 +1,173 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { filterFileComponentsForComponentSet, getComponentSetByKey, listFileComponents, } from "../figma-api/index.js";
4
+ import { readString } from "../inspect/component-set-spec/figma-node.js";
5
+ import { contractArtifactFileName, serializeContractData, } from "../inspect/contract/contract-format.js";
6
+ import { buildContractLock, collectUnchangedVariantNodeIds, readContractLock, resolveContractLockPath, stabilizeContractLockDates, toLockVariants, writeContractLock, } from "../inspect/contract/contract-lock.js";
7
+ import { readComponentContractArtifacts, validateComponentContractArtifacts, } from "../inspect/contract/contract-schema.js";
8
+ import { fingerprintAssetFiles, fingerprintContractSurface, fingerprintContracts, fingerprintTree, } from "../inspect/contract/fingerprint.js";
9
+ import { buildComponentSetPseudocodeFromRaw, exportNestedAssets, exportNodePreview, exportVariantAssets, loadComponentSetContext, resolveTeamComponentSetScope, } from "../inspect/index.js";
10
+ function sanitizeFileName(name) {
11
+ return name.replace(/[/\\?%*:|"<>]/g, "_");
12
+ }
13
+ function teamComponentEntryFromPublishedSet(publishedSet) {
14
+ return {
15
+ id: publishedSet.id,
16
+ key: publishedSet.key,
17
+ name: publishedSet.name,
18
+ fileKey: publishedSet.fileKey,
19
+ projectId: publishedSet.projectId,
20
+ };
21
+ }
22
+ async function writeDataFile(filePath, value, format) {
23
+ await writeFile(filePath, serializeContractData(value, format), "utf8");
24
+ }
25
+ async function writeImportNotes(options) {
26
+ if (!options.sourceUrl) {
27
+ return undefined;
28
+ }
29
+ const notesPath = path.join(options.outputDir, "import-notes.md");
30
+ const lines = [
31
+ "# Import Notes",
32
+ "",
33
+ `sourceUrl: ${JSON.stringify(options.sourceUrl)}`,
34
+ `fileKey: ${JSON.stringify(options.fileKey)}`,
35
+ `nodeId: ${JSON.stringify(options.nodeId)}`,
36
+ `componentSetKey: ${JSON.stringify(options.componentSetKey)}`,
37
+ `componentSetName: ${JSON.stringify(options.componentSetName)}`,
38
+ "",
39
+ ];
40
+ await writeFile(notesPath, lines.join("\n"), "utf8");
41
+ return notesPath;
42
+ }
43
+ export async function exportComponentSet(options) {
44
+ const scope = await resolveTeamComponentSetScope({
45
+ token: options.token,
46
+ teamId: options.teamId,
47
+ componentSet: options.componentSet,
48
+ });
49
+ const [context, componentSetMeta, fileComponents] = await Promise.all([
50
+ loadComponentSetContext({
51
+ token: options.token,
52
+ ...scope,
53
+ }),
54
+ getComponentSetByKey({
55
+ token: options.token,
56
+ componentSetKey: scope.publishedSet.key,
57
+ }),
58
+ listFileComponents({
59
+ token: options.token,
60
+ fileKey: scope.fileKey,
61
+ }),
62
+ ]);
63
+ const raw = context.tree;
64
+ const baseName = sanitizeFileName(scope.publishedSet.name);
65
+ const componentSetNodeId = readString(raw, "id") ?? componentSetMeta.node_id;
66
+ await mkdir(options.outputDir, { recursive: true });
67
+ const format = options.format ?? "yaml";
68
+ const visualsContractPath = path.join(options.outputDir, contractArtifactFileName(baseName, "visuals", format));
69
+ const geometryContractPath = path.join(options.outputDir, contractArtifactFileName(baseName, "geometry", format));
70
+ const metaContractPath = path.join(options.outputDir, contractArtifactFileName(baseName, "meta", format));
71
+ const lockContractPath = resolveContractLockPath(options.outputDir, baseName);
72
+ const structureDslPath = path.join(options.outputDir, `${baseName}.component-set.structure.dsl`);
73
+ const lockVariants = toLockVariants(filterFileComponentsForComponentSet(fileComponents, componentSetNodeId));
74
+ const previousLock = await readContractLock(lockContractPath);
75
+ const treeFingerprint = fingerprintTree(raw);
76
+ const contractSurfaceFingerprint = fingerprintContractSurface(raw);
77
+ const skipNodeIds = collectUnchangedVariantNodeIds(previousLock, lockVariants, treeFingerprint, contractSurfaceFingerprint);
78
+ let assetsDir;
79
+ let exportedAssets;
80
+ if (options.exportAssets) {
81
+ exportedAssets = await exportVariantAssets({
82
+ token: options.token,
83
+ fileKey: scope.fileKey,
84
+ componentSet: raw,
85
+ baseName,
86
+ outputDir: options.outputDir,
87
+ format: options.assetFormat ?? "svg",
88
+ skipNodeIds,
89
+ });
90
+ assetsDir = exportedAssets.assetsDir;
91
+ }
92
+ const previewPath = options.preview
93
+ ? (await exportNodePreview({
94
+ token: options.token,
95
+ fileKey: scope.fileKey,
96
+ nodeId: componentSetNodeId,
97
+ baseName,
98
+ kind: "component-set",
99
+ outputDir: options.outputDir,
100
+ preview: options.preview,
101
+ })).previewPath
102
+ : undefined;
103
+ const nestedAssetsResult = options.nestedAssets
104
+ ? await exportNestedAssets({
105
+ token: options.token,
106
+ fileKey: scope.fileKey,
107
+ root: raw,
108
+ baseName,
109
+ kind: "component-set",
110
+ outputDir: options.outputDir,
111
+ nestedAssets: options.nestedAssets,
112
+ })
113
+ : undefined;
114
+ const contractResult = await buildComponentSetPseudocodeFromRaw(raw, {
115
+ variablesPath: options.variablesPath,
116
+ assetBacked: options.exportAssets,
117
+ assets: exportedAssets?.assets,
118
+ format,
119
+ metaContext: {
120
+ component: teamComponentEntryFromPublishedSet(scope.publishedSet),
121
+ teamComponents: scope.teamComponents,
122
+ },
123
+ });
124
+ await writeDataFile(visualsContractPath, contractResult.visuals, format);
125
+ await writeDataFile(geometryContractPath, contractResult.geometry, format);
126
+ await writeDataFile(metaContractPath, contractResult.meta, format);
127
+ await writeFile(structureDslPath, contractResult.structureDsl, "utf8");
128
+ const artifacts = await readComponentContractArtifacts(options.outputDir, baseName, format);
129
+ validateComponentContractArtifacts(artifacts, format);
130
+ const lock = stabilizeContractLockDates(previousLock, buildContractLock({
131
+ source: {
132
+ fileKey: scope.fileKey,
133
+ nodeId: componentSetNodeId,
134
+ nodeType: "COMPONENT_SET",
135
+ ...(options.sourceUrl ? { sourceUrl: options.sourceUrl } : {}),
136
+ componentSetKey: componentSetMeta.key,
137
+ componentSetUpdatedAt: componentSetMeta.updated_at,
138
+ },
139
+ variants: lockVariants,
140
+ fingerprints: {
141
+ tree: treeFingerprint,
142
+ contractSurface: contractSurfaceFingerprint,
143
+ contracts: fingerprintContracts(contractResult.visuals, contractResult.geometry, contractResult.meta, contractResult.structureDsl),
144
+ ...(assetsDir
145
+ ? {
146
+ assets: await fingerprintAssetFiles(assetsDir, exportedAssets?.assetSlugs ?? []),
147
+ }
148
+ : {}),
149
+ },
150
+ }));
151
+ await writeContractLock(lockContractPath, lock);
152
+ const importNotesPath = await writeImportNotes({
153
+ outputDir: options.outputDir,
154
+ sourceUrl: options.sourceUrl,
155
+ fileKey: scope.fileKey,
156
+ nodeId: componentSetNodeId,
157
+ componentSetKey: componentSetMeta.key,
158
+ componentSetName: scope.publishedSet.name,
159
+ });
160
+ return {
161
+ visualsContractPath,
162
+ geometryContractPath,
163
+ metaContractPath,
164
+ lockContractPath,
165
+ structureDslPath,
166
+ previewPath,
167
+ assetsDir,
168
+ nestedAssetsDir: nestedAssetsResult?.nestedAssetsDir,
169
+ nestedAssetsManifestPath: nestedAssetsResult?.nestedAssetsManifestPath,
170
+ importNotesPath,
171
+ };
172
+ }
173
+ //# sourceMappingURL=export-component-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-component-set.js","sourceRoot":"","sources":["../../src/cli/export-component-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAk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GAAG;YACrC,qBAAqB,EAAE,gBAAgB,CAAC,UAAU;SACnD;QACD,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE;YACZ,IAAI,EAAE,eAAe;YACrB,eAAe,EAAE,0BAA0B;YAC3C,SAAS,EAAE,oBAAoB,CAC7B,cAAc,CAAC,OAAO,EACtB,cAAc,CAAC,QAAQ,EACvB,cAAc,CAAC,IAAI,EACnB,cAAc,CAAC,YAAY,CAC5B;YACD,GAAG,CAAC,SAAS;gBACX,CAAC,CAAC;oBACE,MAAM,EAAE,MAAM,qBAAqB,CACjC,SAAS,EACT,cAAc,EAAE,UAAU,IAAI,EAAE,CACjC;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC,CACH,CAAC;IACF,MAAM,iBAAiB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;IAChD,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC;QAC7C,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,kBAAkB;QAC1B,eAAe,EAAE,gBAAgB,CAAC,GAAG;QACrC,gBAAgB,EAAE,KAAK,CAAC,YAAY,CAAC,IAAI;KAC1C,CAAC,CAAC;IAEH,OAAO;QACL,mBAAmB;QACnB,oBAAoB;QACpB,gBAAgB;QAChB,gBAAgB;QAChB,gBAAgB;QAChB,WAAW;QACX,SAAS;QACT,eAAe,EAAE,kBAAkB,EAAE,eAAe;QACpD,wBAAwB,EAAE,kBAAkB,EAAE,wBAAwB;QACtE,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { ContractFormat } from "../inspect/contract/contract-format.js";
2
+ import type { ExportPreviewOptions, NestedAssetsOptions } from "../inspect/index.js";
3
+ import type { FigmaNodeRef } from "../inspect/types.js";
4
+ import { type ExportComponentSetResult } from "./export-component-set.js";
5
+ import { type ExportNodeContractResult } from "./export-node-contract.js";
6
+ export interface ExportContractOptions extends FigmaNodeRef {
7
+ token: string;
8
+ teamId?: string;
9
+ outputDir: string;
10
+ sourceUrl?: string;
11
+ variablesPath: string;
12
+ exportAssets?: boolean;
13
+ assetFormat?: "svg";
14
+ nestedAssets?: NestedAssetsOptions;
15
+ preview?: ExportPreviewOptions;
16
+ format?: ContractFormat;
17
+ }
18
+ export type ExportContractResult = ExportComponentSetResult | ExportNodeContractResult;
19
+ export declare function exportContract(options: ExportContractOptions): Promise<ExportContractResult>;
20
+ //# sourceMappingURL=export-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-contract.d.ts","sourceRoot":"","sources":["../../src/cli/export-contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,wBAAwB,EAE9B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,MAAM,oBAAoB,GAC5B,wBAAwB,GACxB,wBAAwB,CAAC;AAE7B,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAgD/B"}
@@ -0,0 +1,48 @@
1
+ import { resolveExportContractTarget } from "../inspect/index.js";
2
+ import { CliError } from "./errors.js";
3
+ import { exportComponentSet, } from "./export-component-set.js";
4
+ import { exportNodeContract, } from "./export-node-contract.js";
5
+ export async function exportContract(options) {
6
+ const target = await resolveExportContractTarget({
7
+ token: options.token,
8
+ fileKey: options.fileKey,
9
+ nodeId: options.nodeId,
10
+ });
11
+ if (target.kind === "component-set") {
12
+ if (!options.teamId) {
13
+ throw new CliError("Missing FIGMA_TEAM_ID environment variable.");
14
+ }
15
+ return exportComponentSet({
16
+ token: options.token,
17
+ teamId: options.teamId,
18
+ outputDir: options.outputDir,
19
+ componentSet: {
20
+ kind: "node",
21
+ fileKey: target.fileKey,
22
+ nodeId: target.nodeId,
23
+ },
24
+ sourceUrl: options.sourceUrl,
25
+ variablesPath: options.variablesPath,
26
+ exportAssets: options.exportAssets,
27
+ assetFormat: options.assetFormat,
28
+ nestedAssets: options.nestedAssets,
29
+ preview: options.preview,
30
+ format: options.format,
31
+ });
32
+ }
33
+ if (options.exportAssets) {
34
+ throw new CliError("--export-assets is only supported when --export-contract targets a COMPONENT_SET.");
35
+ }
36
+ return exportNodeContract({
37
+ token: options.token,
38
+ outputDir: options.outputDir,
39
+ fileKey: target.fileKey,
40
+ nodeId: target.nodeId,
41
+ sourceUrl: options.sourceUrl,
42
+ variablesPath: options.variablesPath,
43
+ nestedAssets: options.nestedAssets,
44
+ preview: options.preview,
45
+ format: options.format,
46
+ });
47
+ }
48
+ //# sourceMappingURL=export-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-contract.js","sourceRoot":"","sources":["../../src/cli/export-contract.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CA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AAC,SAAS;QAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type ContractFormat } from "../inspect/contract/contract-format.js";
2
+ import { type ExportPreviewOptions, type NestedAssetsOptions } from "../inspect/index.js";
3
+ import type { FigmaNodeRef } from "../inspect/types.js";
4
+ import type { ExportArtifactPathExtras, ExportArtifactPaths } from "./export-result.js";
5
+ export interface ExportNodeContractOptions extends FigmaNodeRef {
6
+ token: string;
7
+ outputDir: string;
8
+ sourceUrl?: string;
9
+ variablesPath: string;
10
+ nestedAssets?: NestedAssetsOptions;
11
+ preview?: ExportPreviewOptions;
12
+ format?: ContractFormat;
13
+ }
14
+ export interface ExportNodeContractResult extends ExportArtifactPaths, Pick<ExportArtifactPathExtras, "importNotesPath" | "previewPath" | "nestedAssetsDir" | "nestedAssetsManifestPath"> {
15
+ }
16
+ export declare function exportNodeContract(options: ExportNodeContractOptions): Promise<ExportNodeContractResult>;
17
+ //# sourceMappingURL=export-node-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-node-contract.d.ts","sourceRoot":"","sources":["../../src/cli/export-node-contract.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAEL,KAAK,oBAAoB,EAGzB,KAAK,mBAAmB,EASzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EACV,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,WAAW,yBAA0B,SAAQ,YAAY;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,wBACf,SAAQ,mBAAmB,EACzB,IAAI,CACF,wBAAwB,EACtB,iBAAiB,GACjB,aAAa,GACb,iBAAiB,GACjB,0BAA0B,CAC7B;CAAG;AAwCR,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAqGnC"}
@@ -0,0 +1,93 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { serializeContractData, } from "../inspect/contract/contract-format.js";
4
+ import { buildNodeContractFromRef, exportNestedAssets, exportNodePreview, readNodeContractArtifacts, resolveNodeContractLockPath, resolveNodeGeometryContractPath, resolveNodeMetaContractPath, resolveNodeStructureDslPath, resolveNodeVisualsContractPath, validateNodeContractArtifacts, writeNodeContractLock, } from "../inspect/index.js";
5
+ async function writeDataFile(filePath, value, format) {
6
+ await writeFile(filePath, serializeContractData(value, format), "utf8");
7
+ }
8
+ async function writeImportNotes(options) {
9
+ if (!options.sourceUrl) {
10
+ return undefined;
11
+ }
12
+ const notesPath = path.join(options.outputDir, "import-notes.md");
13
+ const lines = [
14
+ "# Import Notes",
15
+ "",
16
+ `sourceUrl: ${JSON.stringify(options.sourceUrl)}`,
17
+ `fileKey: ${JSON.stringify(options.fileKey)}`,
18
+ `nodeId: ${JSON.stringify(options.nodeId)}`,
19
+ `nodeType: ${JSON.stringify(options.nodeType)}`,
20
+ `nodeName: ${JSON.stringify(options.nodeName)}`,
21
+ `kind: ${JSON.stringify(options.kind)}`,
22
+ "",
23
+ ];
24
+ await writeFile(notesPath, lines.join("\n"), "utf8");
25
+ return notesPath;
26
+ }
27
+ export async function exportNodeContract(options) {
28
+ const format = options.format ?? "yaml";
29
+ const contract = await buildNodeContractFromRef({
30
+ token: options.token,
31
+ fileKey: options.fileKey,
32
+ nodeId: options.nodeId,
33
+ sourceUrl: options.sourceUrl,
34
+ variablesPath: options.variablesPath,
35
+ format,
36
+ });
37
+ await mkdir(options.outputDir, { recursive: true });
38
+ const visualsContractPath = resolveNodeVisualsContractPath(options.outputDir, contract.nodeName, contract.kind, format);
39
+ const geometryContractPath = resolveNodeGeometryContractPath(options.outputDir, contract.nodeName, contract.kind, format);
40
+ const metaContractPath = resolveNodeMetaContractPath(options.outputDir, contract.nodeName, contract.kind, format);
41
+ const lockContractPath = resolveNodeContractLockPath(options.outputDir, contract.nodeName, contract.kind);
42
+ const structureDslPath = resolveNodeStructureDslPath(options.outputDir, contract.nodeName, contract.kind);
43
+ const previewPath = options.preview
44
+ ? (await exportNodePreview({
45
+ token: options.token,
46
+ fileKey: options.fileKey,
47
+ nodeId: contract.source.nodeId,
48
+ baseName: contract.nodeName,
49
+ kind: contract.kind,
50
+ outputDir: options.outputDir,
51
+ preview: options.preview,
52
+ })).previewPath
53
+ : undefined;
54
+ const nestedAssetsResult = options.nestedAssets
55
+ ? await exportNestedAssets({
56
+ token: options.token,
57
+ fileKey: options.fileKey,
58
+ root: contract.rawNode,
59
+ baseName: contract.nodeName,
60
+ kind: contract.kind,
61
+ outputDir: options.outputDir,
62
+ nestedAssets: options.nestedAssets,
63
+ })
64
+ : undefined;
65
+ await writeDataFile(visualsContractPath, contract.visuals, format);
66
+ await writeDataFile(geometryContractPath, contract.geometry, format);
67
+ await writeDataFile(metaContractPath, contract.meta, format);
68
+ await writeFile(structureDslPath, contract.structureDsl, "utf8");
69
+ const artifacts = await readNodeContractArtifacts(options.outputDir, contract.nodeName, contract.kind, format);
70
+ validateNodeContractArtifacts(artifacts, format);
71
+ await writeNodeContractLock(lockContractPath, contract.lock);
72
+ const importNotesPath = await writeImportNotes({
73
+ outputDir: options.outputDir,
74
+ sourceUrl: options.sourceUrl,
75
+ fileKey: options.fileKey,
76
+ nodeId: contract.source.nodeId,
77
+ nodeType: contract.source.nodeType,
78
+ nodeName: contract.source.name,
79
+ kind: contract.kind,
80
+ });
81
+ return {
82
+ visualsContractPath,
83
+ geometryContractPath,
84
+ metaContractPath,
85
+ lockContractPath,
86
+ structureDslPath,
87
+ previewPath,
88
+ nestedAssetsDir: nestedAssetsResult?.nestedAssetsDir,
89
+ nestedAssetsManifestPath: nestedAssetsResult?.nestedAssetsManifestPath,
90
+ importNotesPath,
91
+ };
92
+ }
93
+ //# sourceMappingURL=export-node-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-node-contract.js","sourceRoot":"","sources":["../../src/cli/export-node-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAEL,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,wBAAwB,EAExB,kBAAkB,EAClB,iBAAiB,EAEjB,yBAAyB,EACzB,2BAA2B,EAC3B,+BAA+B,EAC/B,2BAA2B,EAC3B,2BAA2B,EAC3B,8BAA8B,EAC9B,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AA2B7B,KAAK,UAAU,aAAa,CAC1B,QAAgB,EAChB,KAAc,EACd,MAAsB;IAEtB,MAAM,SAAS,CAAC,QAAQ,EAAE,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,OAQ/B;IACC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAA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E,kBAAkB,EAAE,wBAAwB;QACtE,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface ExportArtifactPaths {
2
+ visualsContractPath: string;
3
+ geometryContractPath: string;
4
+ metaContractPath: string;
5
+ lockContractPath: string;
6
+ structureDslPath: string;
7
+ }
8
+ export interface ExportArtifactPathExtras {
9
+ previewPath?: string;
10
+ assetsDir?: string;
11
+ nestedAssetsDir?: string;
12
+ nestedAssetsManifestPath?: string;
13
+ importNotesPath?: string;
14
+ }
15
+ export type ExportArtifactPathResult = ExportArtifactPaths & ExportArtifactPathExtras;
16
+ export declare function writeExportArtifactPaths(result: ExportArtifactPathResult, stdout: NodeJS.WriteStream): void;
17
+ //# sourceMappingURL=export-result.d.ts.map