@astryxdesign/cli 0.6.5-canary.f261d2f → 0.6.5-canary.f2f43e1

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 (364) hide show
  1. package/README.md +58 -55
  2. package/api/build/_adapter.d.mts +19 -0
  3. package/api/build/_adapter.mjs +60 -1
  4. package/api/build/build.test.mjs +74 -1
  5. package/api/build/build.type.d.mts +8 -0
  6. package/api/build/build.type.mjs +2 -0
  7. package/api/build/kit/kit.mjs +40 -7
  8. package/api/build/kit/rank.d.mts +8 -0
  9. package/api/build/kit/rank.mjs +14 -0
  10. package/api/build/kit/weights.d.mts +82 -0
  11. package/api/build/kit/weights.json +1 -0
  12. package/api/build/kit/weights.mjs +305 -0
  13. package/api/build/kit/weights.test.mjs +190 -0
  14. package/api/component/_adapter.d.mts +19 -0
  15. package/api/component/_adapter.mjs +33 -0
  16. package/api/component/component-replacement.test.mjs +603 -0
  17. package/api/component/component.mjs +49 -15
  18. package/api/component/component.test.mjs +32 -0
  19. package/api/component/component.type.d.mts +33 -3
  20. package/api/component/component.type.mjs +10 -3
  21. package/api/component/detail/blocks/blocks.d.mts +2 -1
  22. package/api/component/detail/blocks/blocks.mjs +5 -2
  23. package/api/component/detail/detail.mjs +5 -1
  24. package/api/component/detail/props/props.d.mts +2 -1
  25. package/api/component/detail/props/props.mjs +3 -2
  26. package/api/component/detail/showcase/showcase.d.mts +3 -1
  27. package/api/component/detail/showcase/showcase.mjs +3 -1
  28. package/api/component/detail/source/source.d.mts +3 -2
  29. package/api/component/detail/source/source.mjs +7 -3
  30. package/api/component/list/list.mjs +128 -10
  31. package/api/docs/_adapter.d.mts +11 -0
  32. package/api/docs/_adapter.mjs +25 -0
  33. package/api/docs/detail/detail.mjs +19 -3
  34. package/api/docs/detail/section/section.mjs +7 -1
  35. package/api/docs/docOverlays.test.mjs +10 -6
  36. package/api/docs/docs.d.mts +6 -0
  37. package/api/docs/docs.depth.test.mjs +134 -0
  38. package/api/docs/docs.doc.mjs +31 -2
  39. package/api/docs/docs.mjs +46 -1
  40. package/api/docs/docs.test.mjs +1 -1
  41. package/api/docs/docs.type.d.mts +81 -4
  42. package/api/docs/docs.type.mjs +41 -4
  43. package/api/docs/index/index.mjs +11 -2
  44. package/api/docs/index/index.test.mjs +7 -2
  45. package/api/docs/integrationDocs.test.mjs +6 -5
  46. package/api/docs/node/node.d.mts +28 -3
  47. package/api/docs/node/node.mjs +149 -23
  48. package/api/doctor/_adapter.d.mts +43 -0
  49. package/api/doctor/_adapter.mjs +142 -0
  50. package/api/doctor/doctor.d.mts +0 -10
  51. package/api/doctor/doctor.doc.mjs +1 -3
  52. package/api/doctor/doctor.mjs +6 -123
  53. package/api/doctor/theme-checks.d.mts +12 -0
  54. package/api/doctor/theme-checks.mjs +1117 -0
  55. package/api/doctor/theme-checks.test.mjs +526 -0
  56. package/api/error.d.mts +22 -0
  57. package/api/error.mjs +42 -0
  58. package/api/gap-report/gap-report.d.mts +3 -1
  59. package/api/gap-report/gap-report.mjs +27 -3
  60. package/api/gap-report/gap-report.test.mjs +106 -0
  61. package/api/hook/_adapter.d.mts +1 -0
  62. package/api/hook/_adapter.mjs +3 -0
  63. package/api/hook/detail/detail.mjs +2 -2
  64. package/api/hook/detail/params/params.mjs +2 -2
  65. package/api/hook/hook.type.d.mts +12 -0
  66. package/api/hook/hook.type.mjs +3 -0
  67. package/api/hook/list/list.d.mts +1 -1
  68. package/api/hook/list/list.mjs +8 -8
  69. package/api/index.d.mts +1 -1
  70. package/api/index.mjs +4 -0
  71. package/api/init/run/run.d.mts +3 -5
  72. package/api/init/run/run.mjs +10 -11
  73. package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
  74. package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
  75. package/api/integration/add-contribution.d.mts +2 -1
  76. package/api/integration/add-contribution.mjs +7 -3
  77. package/api/integration/add-helpers.d.mts +26 -5
  78. package/api/integration/add-helpers.mjs +50 -5
  79. package/api/integration/add-theme.mjs +352 -27
  80. package/api/integration/add-theme.test.mjs +379 -15
  81. package/api/integration/authoring-checks.mjs +31 -8
  82. package/api/integration/authoring-checks.type.d.mts +8 -0
  83. package/api/integration/authoring-checks.type.mjs +7 -3
  84. package/api/integration/integration-authoring.type.d.mts +4 -1
  85. package/api/integration/integration-authoring.type.mjs +6 -1
  86. package/api/integration/integrationAdd.doc.mjs +6 -0
  87. package/api/integration/integrationAddTheme.doc.mjs +10 -0
  88. package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
  89. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  90. package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
  91. package/api/integration/pack-check.component-replaces.test.mjs +126 -0
  92. package/api/integration/pack-check.d.mts +10 -0
  93. package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
  94. package/api/integration/pack-check.mjs +483 -1
  95. package/api/integration/pack-check.test.mjs +568 -8
  96. package/api/integration/validate-integration.d.mts +4 -2
  97. package/api/integration/validate-integration.mjs +7 -2
  98. package/api/integration/validate-integration.test.mjs +55 -0
  99. package/api/integration/validate-integration.type.d.mts +5 -0
  100. package/api/integration/validate-integration.type.mjs +5 -1
  101. package/api/integration/validateIntegration.doc.mjs +1 -1
  102. package/api/layout/expand/expand.mjs +12 -7
  103. package/api/layout/expand/expand.receipt.test.mjs +74 -0
  104. package/api/layout/layout.type.d.mts +1 -0
  105. package/api/layout/layout.type.mjs +1 -0
  106. package/api/layout/layoutExpand.doc.mjs +1 -1
  107. package/api/search/search.d.mts +15 -8
  108. package/api/search/search.doc.mjs +4 -4
  109. package/api/search/search.mjs +179 -67
  110. package/api/search/search.test.mjs +128 -9
  111. package/api/search/search.type.d.mts +6 -6
  112. package/api/search/search.type.mjs +5 -5
  113. package/api/swizzle/_adapter.d.mts +10 -0
  114. package/api/swizzle/_adapter.mjs +23 -0
  115. package/api/swizzle/copy/copy.d.mts +5 -6
  116. package/api/swizzle/copy/copy.mjs +95 -13
  117. package/api/swizzle/list/list.mjs +2 -2
  118. package/api/swizzle/swizzle.doc.mjs +4 -0
  119. package/api/swizzle/swizzle.test.mjs +55 -5
  120. package/api/swizzle/swizzle.type.d.mts +8 -0
  121. package/api/swizzle/swizzle.type.mjs +2 -0
  122. package/api/template/copy/copy.mjs +15 -8
  123. package/api/template/copy/copy.receipt.test.mjs +77 -0
  124. package/api/template/show/show.mjs +17 -4
  125. package/api/template/show/show.test.mjs +76 -0
  126. package/api/template/skeleton/skeleton.mjs +2 -1
  127. package/api/template/template.d.mts +1 -1
  128. package/api/template/template.doc.mjs +6 -2
  129. package/api/template/template.mjs +2 -0
  130. package/api/template/template.type.d.mts +14 -0
  131. package/api/template/template.type.mjs +5 -0
  132. package/api/theme/_adapter.d.mts +106 -6
  133. package/api/theme/_adapter.mjs +687 -18
  134. package/api/theme/add/add.binary.test.mjs +76 -3
  135. package/api/theme/add/add.d.mts +5 -9
  136. package/api/theme/add/add.mjs +87 -64
  137. package/api/theme/add/add.rollback.test.mjs +9 -9
  138. package/api/theme/add/add.staging.test.mjs +9 -9
  139. package/api/theme/add/add.test.mjs +461 -55
  140. package/api/theme/add/add.types.test.mjs +151 -0
  141. package/api/theme/build/build.d.mts +50 -2
  142. package/api/theme/build/build.family.test.mjs +13 -4
  143. package/api/theme/build/build.icon-lineage.test.mjs +117 -0
  144. package/api/theme/build/build.icon-preservation.test.mjs +639 -0
  145. package/api/theme/build/build.mjs +463 -155
  146. package/api/theme/build/build.project-core.test.mjs +165 -0
  147. package/api/theme/build/build.test.mjs +220 -1
  148. package/api/theme/build/icon-imports.d.mts +47 -0
  149. package/api/theme/build/icon-imports.mjs +691 -0
  150. package/api/theme/eject/eject.binary.test.mjs +90 -0
  151. package/api/theme/eject/eject.d.mts +17 -0
  152. package/api/theme/eject/eject.mjs +65 -0
  153. package/api/theme/eject/eject.rollback.test.mjs +158 -0
  154. package/api/theme/eject/eject.staging.test.mjs +83 -0
  155. package/api/theme/eject/eject.test.mjs +160 -0
  156. package/api/theme/integration-themes.test.mjs +30 -6
  157. package/api/theme/list/list.d.mts +10 -0
  158. package/api/theme/list/list.mjs +75 -7
  159. package/api/theme/list/list.test.mjs +155 -4
  160. package/api/theme/remove/remove.d.mts +12 -0
  161. package/api/theme/remove/remove.mjs +15 -0
  162. package/api/theme/remove/remove.test.mjs +94 -0
  163. package/api/theme/template/template.mjs +3 -4
  164. package/api/theme/theme.d.mts +5 -2
  165. package/api/theme/theme.mjs +13 -8
  166. package/api/theme/theme.type.d.mts +106 -2
  167. package/api/theme/theme.type.mjs +54 -5
  168. package/api/theme/themeAdd.doc.d.mts +1 -3
  169. package/api/theme/themeAdd.doc.mjs +35 -22
  170. package/api/theme/themeBuild.doc.d.mts +4 -1
  171. package/api/theme/themeBuild.doc.mjs +15 -4
  172. package/api/theme/themeEject.doc.d.mts +8 -0
  173. package/api/theme/themeEject.doc.mjs +89 -0
  174. package/api/theme/themeListAvailable.doc.mjs +4 -4
  175. package/api/theme/themeListCopySources.doc.d.mts +8 -0
  176. package/api/theme/themeListCopySources.doc.mjs +60 -0
  177. package/api/theme/themeRemove.doc.d.mts +6 -0
  178. package/api/theme/themeRemove.doc.mjs +50 -0
  179. package/api/theme/themeTemplate.doc.mjs +4 -3
  180. package/api/theme/themeUse.doc.d.mts +6 -0
  181. package/api/theme/themeUse.doc.mjs +47 -0
  182. package/api/theme/use/use.d.mts +12 -0
  183. package/api/theme/use/use.mjs +15 -0
  184. package/api/theme/use/use.test.mjs +98 -0
  185. package/api/upgrade/_adapter.d.mts +1 -0
  186. package/api/upgrade/_adapter.mjs +3 -0
  187. package/api/upgrade/list/list.mjs +9 -3
  188. package/api/upgrade/run/run.mjs +20 -3
  189. package/api/upgrade/run/run.test.mjs +45 -1
  190. package/api/upgrade/upgrade.doc.mjs +1 -1
  191. package/api/upgrade/upgrade.type.d.mts +5 -0
  192. package/api/upgrade/upgrade.type.mjs +2 -0
  193. package/assets/codemods/integration-discovery.mjs +1 -1
  194. package/assets/codemods/integration-discovery.test.mjs +64 -0
  195. package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
  196. package/assets/codemods/transforms/next/index.mjs +14 -1
  197. package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
  198. package/assets/docs/author-a-theme.doc.mjs +161 -0
  199. package/assets/docs/getting-started.doc.mjs +59 -15
  200. package/assets/docs/icons.doc.mjs +1 -0
  201. package/assets/docs/principles.doc.dense.mjs +2 -2
  202. package/assets/docs/principles.doc.mjs +2 -2
  203. package/assets/docs/principles.doc.zh.mjs +2 -2
  204. package/assets/docs/styling-libraries.doc.mjs +1 -1
  205. package/assets/docs/styling.doc.mjs +2 -2
  206. package/assets/docs/theme.doc.dense.mjs +10 -198
  207. package/assets/docs/theme.doc.mjs +13 -770
  208. package/assets/docs/theme.doc.zh.mjs +31 -12
  209. package/assets/docs/tokens.doc.mjs +4 -4
  210. package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
  211. package/assets/docs/tree/checks.doc.mjs +5 -4
  212. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
  213. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  214. package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
  215. package/assets/docs/tree/fonts-and-assets.doc.mjs +25 -20
  216. package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
  217. package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
  218. package/assets/docs/tree/layout.doc.mjs +32 -0
  219. package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
  220. package/assets/docs/tree/responsive.doc.mjs +102 -0
  221. package/assets/docs/tree/scaffold.doc.mjs +145 -0
  222. package/assets/docs/tree/side-panels.doc.mjs +82 -0
  223. package/assets/docs/tree/structure.doc.mjs +144 -0
  224. package/assets/docs/tree/themes.doc.mjs +2 -2
  225. package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
  226. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
  227. package/assets/docs/tree/versioning.doc.mjs +4 -1
  228. package/assets/docs/use-a-theme.doc.mjs +97 -0
  229. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +15 -0
  230. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +38 -0
  231. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +20 -0
  232. package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +48 -0
  233. package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
  234. package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
  235. package/assets/templates/pages/table-comparison/page.tsx +1449 -0
  236. package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
  237. package/assets/templates/themes/butter/icons.tsx +2 -0
  238. package/assets/templates/themes/chocolate/icons.tsx +2 -0
  239. package/assets/templates/themes/gothic/icons.tsx +2 -0
  240. package/assets/templates/themes/matcha/icons.tsx +2 -0
  241. package/assets/templates/themes/neutral/icons.tsx +2 -0
  242. package/assets/templates/themes/stone/icons.tsx +2 -0
  243. package/assets/templates/themes/y2k/icons.tsx +2 -0
  244. package/authoring/doctypes/command/command.doc.mjs +5 -0
  245. package/authoring/doctypes/command/type.ts +2 -0
  246. package/authoring/doctypes/component/component.doc.mjs +1 -1
  247. package/authoring/doctypes/component/type.ts +8 -4
  248. package/authoring/integration/integration.doc.mjs +1 -1
  249. package/clients/cli/commands/build-theme.mjs +279 -30
  250. package/clients/cli/commands/build.mjs +7 -6
  251. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  252. package/clients/cli/commands/component/index.mjs +88 -12
  253. package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
  254. package/clients/cli/commands/component.doc.mjs +9 -2
  255. package/clients/cli/commands/discover.mjs +29 -1
  256. package/clients/cli/commands/discover.no-source.test.mjs +75 -0
  257. package/clients/cli/commands/docs.depth.test.mjs +219 -0
  258. package/clients/cli/commands/docs.doc.mjs +15 -2
  259. package/clients/cli/commands/docs.mjs +273 -16
  260. package/clients/cli/commands/docs.test.mjs +2 -3
  261. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  262. package/clients/cli/commands/doctor.doc.mjs +1 -1
  263. package/clients/cli/commands/doctor.mjs +4 -4
  264. package/clients/cli/commands/doctor.test.mjs +9 -51
  265. package/clients/cli/commands/gap-report.doc.mjs +2 -2
  266. package/clients/cli/commands/gap-report.mjs +12 -0
  267. package/clients/cli/commands/gap-report.test.mjs +63 -0
  268. package/clients/cli/commands/hook/index.mjs +7 -2
  269. package/clients/cli/commands/import-hint-correctness.test.mjs +5 -5
  270. package/clients/cli/commands/init.next-steps.test.mjs +18 -23
  271. package/clients/cli/commands/integration-add.doc.mjs +10 -0
  272. package/clients/cli/commands/integration-authoring.test.mjs +12 -2
  273. package/clients/cli/commands/integration-real-world.test.mjs +61 -12
  274. package/clients/cli/commands/integration.mjs +3 -1
  275. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  276. package/clients/cli/commands/layout-expand.doc.mjs +4 -1
  277. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  278. package/clients/cli/commands/layout.doc.mjs +1 -0
  279. package/clients/cli/commands/layout.expand-receipt.test.mjs +94 -0
  280. package/clients/cli/commands/layout.mjs +61 -4
  281. package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
  282. package/clients/cli/commands/search.doc.mjs +5 -4
  283. package/clients/cli/commands/search.mjs +30 -6
  284. package/clients/cli/commands/search.test.mjs +63 -17
  285. package/clients/cli/commands/swizzle.doc.mjs +12 -3
  286. package/clients/cli/commands/swizzle.mjs +2 -1
  287. package/clients/cli/commands/template.copy-receipt.test.mjs +60 -0
  288. package/clients/cli/commands/template.mjs +70 -6
  289. package/clients/cli/commands/template.show-media.test.mjs +62 -0
  290. package/clients/cli/commands/text-json-parity.test.mjs +40 -0
  291. package/clients/cli/commands/theme-add-lifecycle.test.mjs +132 -0
  292. package/clients/cli/commands/theme-add.doc.mjs +19 -19
  293. package/clients/cli/commands/theme-eject.doc.mjs +47 -0
  294. package/clients/cli/commands/theme-list.behavior.test.mjs +44 -0
  295. package/clients/cli/commands/theme-list.doc.mjs +2 -2
  296. package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
  297. package/clients/cli/commands/theme-remove.doc.mjs +22 -0
  298. package/clients/cli/commands/theme-template.doc.mjs +4 -3
  299. package/clients/cli/commands/theme-use.doc.mjs +22 -0
  300. package/clients/cli/commands/theme.doc.mjs +21 -16
  301. package/clients/cli/commands/upgrade.ascii-output.test.mjs +14 -0
  302. package/clients/cli/commands/upgrade.mjs +1 -1
  303. package/clients/cli/commands/write-failure.test.mjs +175 -0
  304. package/clients/cli/index.mjs +4 -1
  305. package/clients/cli/lib/component-format.mjs +19 -2
  306. package/clients/cli/lib/manifest.mjs +44 -165
  307. package/clients/cli/lib/manifest.test.mjs +98 -7
  308. package/clients/cli/lib/resolve-theme.mjs +80 -78
  309. package/clients/cli/lib/resolve-theme.test.mjs +523 -27
  310. package/foundation/agent-docs/agent-docs.mjs +31 -28
  311. package/foundation/agent-docs/agent-docs.test.mjs +35 -32
  312. package/foundation/agent-docs/app-theme-workflow.test.mjs +13 -0
  313. package/foundation/config/project.d.mts +20 -5
  314. package/foundation/config/project.mjs +43 -6
  315. package/foundation/config/theme-private-vars.d.mts +12 -0
  316. package/foundation/config/theme-private-vars.mjs +107 -0
  317. package/foundation/config/theme-private-vars.test.mjs +55 -0
  318. package/foundation/config/theme-state.d.mts +145 -0
  319. package/foundation/config/theme-state.mjs +417 -0
  320. package/foundation/config/theme-state.test.mjs +182 -0
  321. package/foundation/discovery/component-discovery.d.mts +5 -2
  322. package/foundation/discovery/component-discovery.mjs +12 -6
  323. package/foundation/discovery/component-replacement.d.mts +91 -0
  324. package/foundation/discovery/component-replacement.mjs +417 -0
  325. package/foundation/discovery/component-replacement.test.mjs +480 -0
  326. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  327. package/foundation/discovery/docs-output-budget.mjs +2 -1
  328. package/foundation/discovery/docs-section-key.d.mts +4 -2
  329. package/foundation/discovery/docs-section-key.mjs +1 -1
  330. package/foundation/discovery/module-exports.d.mts +10 -0
  331. package/foundation/discovery/module-exports.mjs +146 -0
  332. package/foundation/discovery/package-exports.d.mts +29 -0
  333. package/foundation/discovery/package-exports.mjs +200 -0
  334. package/foundation/discovery/template-adapter.d.mts +13 -0
  335. package/foundation/discovery/template-adapter.fixture-refs.test.mjs +37 -1
  336. package/foundation/discovery/template-adapter.mjs +16 -1
  337. package/foundation/discovery/theme-discovery.d.mts +78 -5
  338. package/foundation/discovery/theme-discovery.mjs +143 -18
  339. package/foundation/discovery/theme-discovery.test.mjs +9 -3
  340. package/foundation/discovery/theme-imports.d.mts +15 -0
  341. package/foundation/discovery/theme-imports.mjs +217 -0
  342. package/foundation/discovery/theme-imports.test.mjs +173 -0
  343. package/foundation/doc-compiler/doc-loads.test.mjs +18 -8
  344. package/foundation/doc-compiler/inputs.mjs +2 -1
  345. package/foundation/doc-compiler/lenses.d.mts +4 -2
  346. package/foundation/doc-compiler/lenses.mjs +1 -1
  347. package/foundation/doc-compiler/tree.test.mjs +2 -2
  348. package/foundation/fs/module-loader.d.mts +9 -0
  349. package/foundation/fs/module-loader.mjs +71 -2
  350. package/foundation/integrations/cli-requirement.d.mts +22 -0
  351. package/foundation/integrations/cli-requirement.mjs +31 -0
  352. package/foundation/integrations/cli-requirement.test.mjs +70 -0
  353. package/foundation/integrations/contribution-inventory.mjs +3 -3
  354. package/foundation/response/base.d.ts +9 -3
  355. package/foundation/response/json.d.mts +7 -4
  356. package/foundation/response/json.mjs +10 -6
  357. package/foundation/response/response-types.doc.d.mts +5 -5
  358. package/foundation/response/response-types.doc.mjs +50 -35
  359. package/foundation/response/response.doc.mjs +18 -4
  360. package/foundation/text/copyright-header.mjs +1 -1
  361. package/foundation/text/copyright-header.test.mjs +1 -1
  362. package/package.json +9 -9
  363. package/assets/docs/layout.doc.dense.mjs +0 -388
  364. package/assets/docs/layout.doc.mjs +0 -550
@@ -0,0 +1,146 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Static JavaScript module export inspection.
5
+ *
6
+ * Proves a runtime export without executing package code. Local ESM re-exports
7
+ * are followed recursively; unresolved or unparsable modules fail closed.
8
+ *
9
+ * @input A module path and runtime export name
10
+ * @output Whether that export can be proved statically
11
+ * @position packages/cli/foundation/discovery — shared package inspection
12
+ */
13
+
14
+ import * as fs from 'node:fs';
15
+ import * as path from 'node:path';
16
+ import jscodeshift from 'jscodeshift';
17
+
18
+ const MODULE_EXTENSIONS = [
19
+ '.mjs',
20
+ '.js',
21
+ '.cjs',
22
+ '.mts',
23
+ '.ts',
24
+ '.cts',
25
+ '.tsx',
26
+ '.jsx',
27
+ ];
28
+ const parser = jscodeshift.withParser('tsx');
29
+
30
+ /** @param {unknown} specifier @param {string} fromFile */
31
+ function resolveLocalModule(specifier, fromFile) {
32
+ if (typeof specifier !== 'string' || !specifier.startsWith('.')) return null;
33
+ const base = path.resolve(path.dirname(fromFile), specifier);
34
+ const candidates = [
35
+ base,
36
+ ...MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
37
+ ...MODULE_EXTENSIONS.map(extension => path.join(base, `index${extension}`)),
38
+ ];
39
+ return candidates.find(candidate => {
40
+ try {
41
+ return fs.statSync(candidate).isFile();
42
+ } catch {
43
+ return false;
44
+ }
45
+ }) ?? null;
46
+ }
47
+
48
+ /** @param {any} declaration @param {string} exportName */
49
+ function declarationExports(declaration, exportName) {
50
+ if (!declaration || declaration.declare === true) return false;
51
+ if (['FunctionDeclaration', 'ClassDeclaration'].includes(declaration.type)) {
52
+ return declaration.id?.name === exportName;
53
+ }
54
+ if (declaration.type !== 'VariableDeclaration') return false;
55
+ return declaration.declarations.some(
56
+ (/** @type {any} */ item) =>
57
+ item.id?.type === 'Identifier' && item.id.name === exportName,
58
+ );
59
+ }
60
+
61
+ /** @param {any} declaration */
62
+ function runtimeDefault(declaration) {
63
+ return (
64
+ declaration != null &&
65
+ declaration.declare !== true &&
66
+ ![
67
+ 'TSDeclareFunction',
68
+ 'TSInterfaceDeclaration',
69
+ 'TSTypeAliasDeclaration',
70
+ ].includes(declaration.type)
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Check one module's static export surface without executing it.
76
+ * @param {string} file
77
+ * @param {string} exportName
78
+ * @param {Set<string>} [seen]
79
+ */
80
+ export function moduleExportsName(file, exportName, seen = new Set()) {
81
+ const identity = `${file}\0${exportName}`;
82
+ if (seen.has(identity)) return false;
83
+ seen.add(identity);
84
+ try {
85
+ if (!fs.statSync(file).isFile()) return false;
86
+ } catch {
87
+ return false;
88
+ }
89
+
90
+ let root;
91
+ try {
92
+ root = parser(fs.readFileSync(file, 'utf-8'));
93
+ } catch {
94
+ return false;
95
+ }
96
+
97
+ let found = false;
98
+ root
99
+ .find(parser.ExportNamedDeclaration)
100
+ .forEach((/** @type {any} */ exportPath) => {
101
+ if (found || exportPath.node.exportKind === 'type') return;
102
+ const node = exportPath.node;
103
+ if (declarationExports(node.declaration, exportName)) {
104
+ found = true;
105
+ return;
106
+ }
107
+ for (const specifier of node.specifiers ?? []) {
108
+ if (
109
+ specifier.type !== 'ExportSpecifier' ||
110
+ specifier.exportKind === 'type'
111
+ ) {
112
+ continue;
113
+ }
114
+ const exported = specifier.exported?.name ?? specifier.exported?.value;
115
+ if (exported !== exportName) continue;
116
+ if (!node.source) {
117
+ found = true;
118
+ return;
119
+ }
120
+ const target = resolveLocalModule(node.source.value, file);
121
+ const imported =
122
+ specifier.local?.name ?? specifier.local?.value ?? exportName;
123
+ if (target && moduleExportsName(target, imported, seen)) {
124
+ found = true;
125
+ return;
126
+ }
127
+ }
128
+ });
129
+ if (found) return true;
130
+
131
+ if (exportName === 'default') {
132
+ const defaults = root.find(parser.ExportDefaultDeclaration).nodes();
133
+ if (defaults.some((/** @type {any} */ node) => runtimeDefault(node.declaration))) {
134
+ return true;
135
+ }
136
+ }
137
+
138
+ root
139
+ .find(parser.ExportAllDeclaration)
140
+ .forEach((/** @type {any} */ exportPath) => {
141
+ if (found || exportPath.node.exportKind === 'type') return;
142
+ const target = resolveLocalModule(exportPath.node.source?.value, file);
143
+ if (target && moduleExportsName(target, exportName, seen)) found = true;
144
+ });
145
+ return found;
146
+ }
@@ -0,0 +1,29 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * @typedef {object} PackageExportResult
6
+ * @property {string} subpath
7
+ * @property {string} specifier
8
+ * @property {boolean} exported
9
+ * @property {string|null} target
10
+ * @property {string|null} authoredTarget
11
+ */
12
+ /**
13
+ * Inspect one public package subpath.
14
+ * @param {{name?: unknown, exports?: unknown}} pkg
15
+ * @param {string} packageDir
16
+ * @param {string} subpath `.` or a `./`-prefixed subpath
17
+ * @returns {PackageExportResult}
18
+ */
19
+ export function inspectPackageExport(pkg: {
20
+ name?: unknown;
21
+ exports?: unknown;
22
+ }, packageDir: string, subpath: string): PackageExportResult;
23
+ export type PackageExportResult = {
24
+ subpath: string;
25
+ specifier: string;
26
+ exported: boolean;
27
+ target: string | null;
28
+ authoredTarget: string | null;
29
+ };
@@ -0,0 +1,200 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Package export-map inspection for built theme assets.
5
+ *
6
+ * Resolves exact and wildcard subpaths through ordinary conditional export
7
+ * objects without executing package code. Packages with no exports map retain
8
+ * their legacy public deep paths and are resolved from files on disk.
9
+ *
10
+ * @input Parsed package.json, package directory, and a public subpath
11
+ * @output The public specifier and confined target file, when exported
12
+ * @position packages/cli/foundation/discovery — shared package import metadata
13
+ */
14
+
15
+ import * as fs from 'node:fs';
16
+ import * as path from 'node:path';
17
+
18
+ const MODULE_EXTENSIONS = [
19
+ '.mjs',
20
+ '.js',
21
+ '.cjs',
22
+ '.mts',
23
+ '.ts',
24
+ '.cts',
25
+ '.tsx',
26
+ '.jsx',
27
+ ];
28
+ const CONDITION_ORDER = ['import', 'default', 'browser', 'node', 'require'];
29
+
30
+ /** @param {unknown} value @returns {value is Record<string, unknown>} */
31
+ function isRecord(value) {
32
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
33
+ }
34
+
35
+ /**
36
+ * Select one string target from a conditional or fallback export value.
37
+ * @param {unknown} value
38
+ * @returns {string|null}
39
+ */
40
+ function targetString(value) {
41
+ if (typeof value === 'string') return value;
42
+ if (Array.isArray(value)) {
43
+ for (const item of value) {
44
+ const selected = targetString(item);
45
+ if (selected) return selected;
46
+ }
47
+ return null;
48
+ }
49
+ if (!isRecord(value)) return null;
50
+ const keys = [
51
+ ...CONDITION_ORDER.filter(key => Object.hasOwn(value, key)),
52
+ ...Object.keys(value).filter(
53
+ key => key !== 'types' && !CONDITION_ORDER.includes(key),
54
+ ),
55
+ ];
56
+ for (const key of keys) {
57
+ const selected = targetString(value[key]);
58
+ if (selected) return selected;
59
+ }
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * Find an exact or one-star subpath mapping and the wildcard value it matched.
65
+ * @param {Record<string, unknown>} map
66
+ * @param {string} subpath
67
+ */
68
+ function subpathValue(map, subpath) {
69
+ if (Object.hasOwn(map, subpath)) {
70
+ return {found: map[subpath] != null, value: map[subpath], wildcard: ''};
71
+ }
72
+ const patterns = Object.keys(map)
73
+ .filter(key => key.startsWith('./') && key.split('*').length === 2)
74
+ .sort((a, b) => b.length - a.length);
75
+ for (const pattern of patterns) {
76
+ const star = pattern.indexOf('*');
77
+ const prefix = pattern.slice(0, star);
78
+ const suffix = pattern.slice(star + 1);
79
+ if (
80
+ subpath.length >= prefix.length + suffix.length &&
81
+ subpath.startsWith(prefix) &&
82
+ subpath.endsWith(suffix)
83
+ ) {
84
+ return {
85
+ found: map[pattern] != null,
86
+ value: map[pattern],
87
+ wildcard: subpath.slice(prefix.length, subpath.length - suffix.length),
88
+ };
89
+ }
90
+ }
91
+ return {found: false, value: null, wildcard: ''};
92
+ }
93
+
94
+ /**
95
+ * Select the export value for one subpath.
96
+ * @param {unknown} exportsField
97
+ * @param {string} subpath
98
+ */
99
+ function exportValue(exportsField, subpath) {
100
+ if (exportsField === undefined) {
101
+ return {hasMap: false, exported: true, target: null};
102
+ }
103
+ if (!isRecord(exportsField)) {
104
+ return {
105
+ hasMap: true,
106
+ exported: subpath === '.' && exportsField != null,
107
+ target: subpath === '.' ? targetString(exportsField) : null,
108
+ };
109
+ }
110
+ const keys = Object.keys(exportsField);
111
+ const subpathMap = keys.some(key => key.startsWith('.'));
112
+ if (!subpathMap) {
113
+ return {
114
+ hasMap: true,
115
+ exported: subpath === '.',
116
+ target: subpath === '.' ? targetString(exportsField) : null,
117
+ };
118
+ }
119
+ const selected = subpathValue(exportsField, subpath);
120
+ const target = selected.found ? targetString(selected.value) : null;
121
+ return {
122
+ hasMap: true,
123
+ exported: selected.found && target != null,
124
+ target: target?.replaceAll('*', selected.wildcard) ?? null,
125
+ };
126
+ }
127
+
128
+ /** @param {string} file */
129
+ function regularFile(file) {
130
+ try {
131
+ return fs.statSync(file).isFile();
132
+ } catch {
133
+ return false;
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Resolve an export target while confining it to its package.
139
+ * @param {string} packageDir
140
+ * @param {string} target
141
+ */
142
+ function resolveTarget(packageDir, target) {
143
+ if (!target.startsWith('./')) return null;
144
+ const resolved = path.resolve(packageDir, target);
145
+ const root = path.resolve(packageDir);
146
+ if (resolved !== root && !resolved.startsWith(root + path.sep)) return null;
147
+ return regularFile(resolved) ? resolved : null;
148
+ }
149
+
150
+ /**
151
+ * Resolve a public legacy deep path for a package with no exports map.
152
+ * @param {string} packageDir
153
+ * @param {string} subpath
154
+ */
155
+ function resolveLegacy(packageDir, subpath) {
156
+ if (!subpath.startsWith('./')) return null;
157
+ const base = path.resolve(packageDir, subpath.slice(2));
158
+ const root = path.resolve(packageDir);
159
+ if (base !== root && !base.startsWith(root + path.sep)) return null;
160
+ const candidates = [
161
+ base,
162
+ ...MODULE_EXTENSIONS.map(extension => `${base}${extension}`),
163
+ ...MODULE_EXTENSIONS.map(extension => path.join(base, `index${extension}`)),
164
+ ];
165
+ return candidates.find(regularFile) ?? null;
166
+ }
167
+
168
+ /**
169
+ * @typedef {object} PackageExportResult
170
+ * @property {string} subpath
171
+ * @property {string} specifier
172
+ * @property {boolean} exported
173
+ * @property {string|null} target
174
+ * @property {string|null} authoredTarget
175
+ */
176
+
177
+ /**
178
+ * Inspect one public package subpath.
179
+ * @param {{name?: unknown, exports?: unknown}} pkg
180
+ * @param {string} packageDir
181
+ * @param {string} subpath `.` or a `./`-prefixed subpath
182
+ * @returns {PackageExportResult}
183
+ */
184
+ export function inspectPackageExport(pkg, packageDir, subpath) {
185
+ const name = typeof pkg.name === 'string' ? pkg.name : '';
186
+ const selected = exportValue(pkg.exports, subpath);
187
+ const target = selected.hasMap
188
+ ? selected.target
189
+ ? resolveTarget(packageDir, selected.target)
190
+ : null
191
+ : resolveLegacy(packageDir, subpath);
192
+ const suffix = subpath === '.' ? '' : `/${subpath.slice(2)}`;
193
+ return {
194
+ subpath,
195
+ specifier: `${name}${suffix}`,
196
+ exported: selected.exported,
197
+ target,
198
+ authoredTarget: selected.target,
199
+ };
200
+ }
@@ -49,6 +49,19 @@ export function effectiveTemplateDiscovery(templates: DiscoveredTemplate[]): Dis
49
49
  * @returns {string} Source with demo asset references replaced.
50
50
  */
51
51
  export function stripTemplateAssetRefs(source: string): string;
52
+ /**
53
+ * {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
54
+ * replaced reference, however many fixture paths its URL carries (a reference
55
+ * is replaced whole, query included), and none for a prose mention or a
56
+ * third-party URL left as written. That count is what a receipt discloses.
57
+ *
58
+ * @param {string} source - Template source code.
59
+ * @returns {{source: string, demoMediaReplaced: number}}
60
+ */
61
+ export function replaceDemoMedia(source: string): {
62
+ source: string;
63
+ demoMediaReplaced: number;
64
+ };
52
65
  /**
53
66
  * List the core page-template directory names (sorted). The `template --list`
54
67
  * view discovers far more; this is the minimal core-page set `init` scaffolds
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
5
5
  import * as path from 'node:path';
6
6
  import {fileURLToPath} from 'node:url';
7
7
  import jscodeshift from 'jscodeshift';
8
- import {stripTemplateAssetRefs} from './template-adapter.mjs';
8
+ import {replaceDemoMedia, stripTemplateAssetRefs} from './template-adapter.mjs';
9
9
 
10
10
  const PLACEHOLDER = stripTemplateAssetRefs("'/template-assets/x.png'").slice(
11
11
  1,
@@ -212,6 +212,42 @@ describe('stripTemplateAssetRefs fixture references', () => {
212
212
  });
213
213
  });
214
214
 
215
+ describe('replaceDemoMedia', () => {
216
+ it('counts a reference once, however many fixture paths its URL carries', () => {
217
+ const source =
218
+ "const hero = '/template-assets/a.png?f=/template-assets/b.png';";
219
+ expect(replaceDemoMedia(source)).toEqual({
220
+ source: stripTemplateAssetRefs(source),
221
+ demoMediaReplaced: 1,
222
+ });
223
+ });
224
+
225
+ it('counts a poster and a video as two references', () => {
226
+ const source =
227
+ '<video poster="/template-assets/poster.jpg" src="/template-assets/clip.mp4" />';
228
+ const result = replaceDemoMedia(source);
229
+ expect(result).toEqual({
230
+ source: stripTemplateAssetRefs(source),
231
+ demoMediaReplaced: 2,
232
+ });
233
+ expect(result.source).not.toContain('/template-assets/');
234
+ });
235
+
236
+ it.each([
237
+ [
238
+ 'a prose mention',
239
+ '<p>Demo media lives under /template-assets/ in the docsite.</p>',
240
+ ],
241
+ [
242
+ 'a third-party URL',
243
+ "const u = 'https://example.com/template-assets/a.png';",
244
+ ],
245
+ ['source with no fixture', 'const x = 1;'],
246
+ ])('counts nothing for %s it leaves as written', (_label, source) => {
247
+ expect(replaceDemoMedia(source)).toEqual({source, demoMediaReplaced: 0});
248
+ });
249
+ });
250
+
215
251
  describe('shipped templates', () => {
216
252
  it('copy with every fixture replaced and still parse', () => {
217
253
  const root = path.resolve(
@@ -321,9 +321,23 @@ function toPosixPath(p) {
321
321
  * @returns {string} Source with demo asset references replaced.
322
322
  */
323
323
  export function stripTemplateAssetRefs(source) {
324
+ return replaceDemoMedia(source).source;
325
+ }
326
+
327
+ /**
328
+ * {@link stripTemplateAssetRefs}, plus how many references it replaced: one per
329
+ * replaced reference, however many fixture paths its URL carries (a reference
330
+ * is replaced whole, query included), and none for a prose mention or a
331
+ * third-party URL left as written. That count is what a receipt discloses.
332
+ *
333
+ * @param {string} source - Template source code.
334
+ * @returns {{source: string, demoMediaReplaced: number}}
335
+ */
336
+ export function replaceDemoMedia(source) {
324
337
  const needle = `/${FIXTURE_SEGMENT}`;
325
338
  let output = '';
326
339
  let copied = 0;
340
+ let demoMediaReplaced = 0;
327
341
  /** @type {Array<[number, number]> | undefined} */
328
342
  let comments;
329
343
  let at = source.indexOf(needle);
@@ -344,10 +358,11 @@ export function stripTemplateAssetRefs(source) {
344
358
  if (edit) {
345
359
  output += source.slice(copied, start) + edit.text;
346
360
  copied = edit.end;
361
+ demoMediaReplaced += 1;
347
362
  }
348
363
  at = source.indexOf(needle, end);
349
364
  }
350
- return output + source.slice(copied);
365
+ return {source: output + source.slice(copied), demoMediaReplaced};
351
366
  }
352
367
 
353
368
  /** @param {string | undefined} char */
@@ -1,6 +1,38 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * @typedef {object} DiscoveredTheme
6
+ * @property {string} slug
7
+ * @property {string} displayName
8
+ * @property {string} description
9
+ * @property {boolean} maintained
10
+ * @property {string} entry
11
+ * @property {string} exportName
12
+ * @property {string[]} files what `theme eject` copies, relative to sourceDir,
13
+ * entry first
14
+ * @property {string} package package exposed for discovery and --package selection
15
+ * @property {string} [importPackage] package that owns built imports when it differs from the selector package
16
+ * @property {string} [packageDir] absolute package/project directory
17
+ * @property {Record<string, unknown>|null} [packageExports] parsed package exports
18
+ * @property {'bundled'|'package'|'local'} source
19
+ * @property {string} sourceDir absolute directory holding this theme's files
20
+ * @property {boolean} bundled
21
+ * @property {string} docPath absolute descriptor path
22
+ */
23
+ /**
24
+ * The package written to the app record and used for built imports. Bundled
25
+ * themes keep the released CLI package as their selector while importing from
26
+ * their standalone theme package.
27
+ * @param {DiscoveredTheme} theme
28
+ */
29
+ export function themeImportPackage(theme: DiscoveredTheme): string;
30
+ /**
31
+ * Every module a theme source file imports or re-exports, as written.
32
+ * @param {string} file
33
+ * @returns {string[]}
34
+ */
35
+ export function themeFileImports(file: string): string[];
4
36
  /**
5
37
  * How messages about a theme descriptor name it.
6
38
  * @param {string} docPath
@@ -31,21 +63,32 @@ export function isThemeFolder(folder: string): boolean;
31
63
  /**
32
64
  * The files one theme folder ships: every regular file below it except
33
65
  * {@link isIgnoredThemeEntry} entries. What pack-check requires and what
34
- * `theme add` copies.
66
+ * `theme eject` copies.
35
67
  * @param {string} folder absolute path
36
68
  * @returns {string[]} sorted POSIX paths relative to the folder
37
69
  */
38
70
  export function listThemeFiles(folder: string): string[];
71
+ /**
72
+ * Source copies left by the released `theme add`, before it copied a
73
+ * descriptor. Commands skip these until the next-release project codemod adds
74
+ * the same-stem descriptor.
75
+ * @param {string} projectDir
76
+ * @param {string} [owner]
77
+ * @returns {UnmigratedThemeCopy[]}
78
+ */
79
+ export function discoverUnmigratedThemeCopies(projectDir: string, owner?: string): UnmigratedThemeCopy[];
39
80
  /**
40
81
  * Discover and validate one theme root.
41
82
  * @param {string} themeRoot absolute root containing one directory per slug
42
83
  * @param {string} owner package that owns the root
43
- * @param {{bundled?: boolean}} [options] a bundled root is the CLI's own; its
44
- * sources are checked by the CLI's tests rather than on every read
84
+ * @param {{bundled?: boolean, allowUnmigrated?: boolean}} [options] a bundled root is the CLI's own; its
85
+ * sources are checked by the CLI's tests rather than on every read. A local
86
+ * root may skip released source copies until `astryx upgrade` adds descriptors.
45
87
  * @returns {DiscoveredTheme[]}
46
88
  */
47
- export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled }?: {
89
+ export function discoverThemeDirectory(themeRoot: string, owner: string, { bundled, allowUnmigrated }?: {
48
90
  bundled?: boolean;
91
+ allowUnmigrated?: boolean;
49
92
  }): DiscoveredTheme[];
50
93
  /**
51
94
  * Folders under a themes root that look like themes (see looksLikeTheme)
@@ -63,6 +106,13 @@ export function unreadThemeFolders(themeRoot: string, { packageDir, packageName
63
106
  }): string[];
64
107
  /** @returns {DiscoveredTheme[]} */
65
108
  export function discoverBundledThemes(): DiscoveredTheme[];
109
+ /**
110
+ * Discover authored themes in the app's conventional local themes root.
111
+ * @param {string} projectDir
112
+ * @param {string} [owner]
113
+ * @returns {DiscoveredTheme[]}
114
+ */
115
+ export function discoverLocalThemes(projectDir: string, owner?: string): DiscoveredTheme[];
66
116
  /**
67
117
  * @param {import('../integrations/integrations.mjs').LoadedIntegration} integration
68
118
  * @returns {Promise<DiscoveredTheme[]>}
@@ -82,11 +132,27 @@ export type DiscoveredTheme = {
82
132
  entry: string;
83
133
  exportName: string;
84
134
  /**
85
- * what `theme add` copies, relative to sourceDir,
135
+ * what `theme eject` copies, relative to sourceDir,
86
136
  * entry first
87
137
  */
88
138
  files: string[];
139
+ /**
140
+ * package exposed for discovery and --package selection
141
+ */
89
142
  package: string;
143
+ /**
144
+ * package that owns built imports when it differs from the selector package
145
+ */
146
+ importPackage?: string | undefined;
147
+ /**
148
+ * absolute package/project directory
149
+ */
150
+ packageDir?: string | undefined;
151
+ /**
152
+ * parsed package exports
153
+ */
154
+ packageExports?: Record<string, unknown> | null | undefined;
155
+ source: "bundled" | "package" | "local";
90
156
  /**
91
157
  * absolute directory holding this theme's files
92
158
  */
@@ -97,3 +163,10 @@ export type DiscoveredTheme = {
97
163
  */
98
164
  docPath: string;
99
165
  };
166
+ export type UnmigratedThemeCopy = {
167
+ slug: string;
168
+ sourceDir: string;
169
+ entry: string;
170
+ exportName: string;
171
+ descriptor: string;
172
+ };