@astryxdesign/cli 0.7.1 → 0.7.2-canary.020e1fe

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 (247) hide show
  1. package/README.md +15 -14
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +41 -1
  4. package/api/component/_adapter.mjs +93 -7
  5. package/api/component/component.mjs +22 -5
  6. package/api/component/component.test.mjs +420 -167
  7. package/api/component/integration-export-name.test.mjs +644 -0
  8. package/api/component/list/list.mjs +42 -4
  9. package/api/docs/_adapter.d.mts +11 -0
  10. package/api/docs/_adapter.mjs +244 -1
  11. package/api/docs/integrationDocs.test.mjs +124 -0
  12. package/api/doctor/doctor.mjs +27 -3
  13. package/api/doctor/doctor.test.mjs +43 -0
  14. package/api/doctor/theme-checks.mjs +1 -1
  15. package/api/gap-report/gap-report.mjs +67 -4
  16. package/api/index.d.mts +2 -0
  17. package/api/index.mjs +2 -0
  18. package/api/init/run/run.mjs +2 -2
  19. package/api/integration/_adapter.d.mts +12 -0
  20. package/api/integration/_adapter.mjs +54 -0
  21. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  22. package/api/integration/add-contribution.mjs +8 -4
  23. package/api/integration/add-contribution.test.mjs +4 -2
  24. package/api/integration/authoring-checks.mjs +11 -2
  25. package/api/integration/authoring-checks.test.mjs +39 -0
  26. package/api/integration/authoring-checks.type.d.mts +9 -0
  27. package/api/integration/authoring-checks.type.mjs +14 -1
  28. package/api/integration/check/check.d.mts +96 -0
  29. package/api/integration/check/check.mjs +357 -0
  30. package/api/integration/check/check.test.mjs +489 -0
  31. package/api/integration/integration-check.type.d.mts +118 -0
  32. package/api/integration/integration-check.type.mjs +84 -0
  33. package/api/integration/integrationCheck.doc.d.mts +10 -0
  34. package/api/integration/integrationCheck.doc.mjs +73 -0
  35. package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
  36. package/api/integration/pack-check.mjs +61 -107
  37. package/api/integration/pack-check.test.mjs +359 -0
  38. package/api/integration/validate-integration.mjs +8 -0
  39. package/api/integration/validate-integration.test.mjs +11 -0
  40. package/api/integration/validate-integration.type.d.mts +8 -0
  41. package/api/integration/validate-integration.type.mjs +12 -1
  42. package/api/integration/validateIntegration.doc.mjs +19 -3
  43. package/api/search/search.d.mts +81 -12
  44. package/api/search/search.domain-priority.test.mjs +108 -18
  45. package/api/search/search.integration-check.test.mjs +24 -0
  46. package/api/search/search.mjs +609 -53
  47. package/api/search/search.test.mjs +175 -0
  48. package/api/swizzle/copy/copy.mjs +28 -14
  49. package/api/template/table-filter-view-tabs.test.mjs +45 -0
  50. package/api/template/template.test.mjs +120 -3
  51. package/api/theme/build/build.core-on-demand.test.mjs +113 -0
  52. package/api/theme/build/build.d.mts +13 -13
  53. package/api/theme/build/build.family.test.mjs +64 -0
  54. package/api/theme/build/build.mjs +252 -61
  55. package/api/theme/themeBuild.doc.mjs +4 -4
  56. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  57. package/assets/codemods/transforms/next/index.mjs +11 -1
  58. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  59. package/assets/docs/README.md +10 -0
  60. package/assets/docs/author-a-theme.doc.mjs +1 -1
  61. package/assets/docs/getting-started.doc.mjs +3 -3
  62. package/assets/docs/styling-overview.doc.mjs +1 -1
  63. package/assets/docs/theme.doc.dense.mjs +1 -1
  64. package/assets/docs/theme.doc.mjs +1 -1
  65. package/assets/docs/theme.doc.zh.mjs +1 -1
  66. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  67. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  68. package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
  69. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  70. package/assets/docs/tree/block-template.doc.mjs +8 -20
  71. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  72. package/assets/docs/tree/check-the-props.doc.mjs +196 -0
  73. package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
  74. package/assets/docs/tree/checks.doc.mjs +24 -16
  75. package/assets/docs/tree/codemods.doc.mjs +4 -4
  76. package/assets/docs/tree/component-family.doc.mjs +8 -6
  77. package/assets/docs/tree/component-imports.doc.mjs +10 -2
  78. package/assets/docs/tree/components.doc.mjs +1 -1
  79. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -18
  80. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  81. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  82. package/assets/docs/tree/docs.doc.mjs +3 -3
  83. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  84. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  85. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  86. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  87. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  88. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  89. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  90. package/assets/docs/tree/integrations.doc.mjs +8 -0
  91. package/assets/docs/tree/links.doc.mjs +6 -5
  92. package/assets/docs/tree/migration-setup.doc.mjs +1 -0
  93. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  94. package/assets/docs/tree/migration.doc.mjs +0 -1
  95. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  96. package/assets/docs/tree/page-template.doc.mjs +4 -8
  97. package/assets/docs/tree/publishing.doc.mjs +1 -1
  98. package/assets/docs/tree/quick-start.doc.mjs +37 -21
  99. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  100. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  101. package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
  102. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  103. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  104. package/assets/docs/tree/single-component.doc.mjs +15 -6
  105. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  106. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  107. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  108. package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
  109. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  110. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  111. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  112. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  113. package/assets/docs/tree/templates.doc.mjs +1 -1
  114. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  115. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  116. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  117. package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
  118. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  119. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  120. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  121. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  122. package/assets/docs/tree/versioning.doc.mjs +7 -6
  123. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  124. package/assets/docs/use-a-theme.doc.mjs +2 -2
  125. package/assets/docs/working-with-ai.doc.mjs +43 -4
  126. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  127. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  128. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  129. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  130. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  131. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  132. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  133. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  134. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  135. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  136. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  137. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  138. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  139. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  140. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  141. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  142. package/assets/templates/pages/detail-page/page.tsx +3 -3
  143. package/assets/templates/pages/table-filter/page.tsx +3 -2
  144. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  145. package/assets/theme.template.ts +1 -1
  146. package/authoring/codemod/codemod.doc.mjs +7 -3
  147. package/authoring/config/config.doc.mjs +9 -6
  148. package/authoring/config/type.ts +4 -2
  149. package/authoring/discover/discover.doc.mjs +1 -1
  150. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  151. package/authoring/doctypes/base/type.ts +6 -0
  152. package/authoring/doctypes/command/command.doc.mjs +14 -12
  153. package/authoring/doctypes/component/component.doc.mjs +31 -28
  154. package/authoring/doctypes/component/type.ts +13 -8
  155. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  156. package/authoring/doctypes/function/function.doc.mjs +9 -8
  157. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  158. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  159. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  160. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  161. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  162. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  163. package/authoring/doctypes/template/parse.d.mts +6 -2
  164. package/authoring/doctypes/template/parse.mjs +3 -1
  165. package/authoring/doctypes/template/template.doc.mjs +3 -3
  166. package/authoring/doctypes/template/type.ts +22 -0
  167. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  168. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  169. package/authoring/identity/identity.doc.mjs +3 -3
  170. package/authoring/index.d.ts +1 -0
  171. package/authoring/integration/integration.doc.mjs +12 -4
  172. package/authoring/integration/parse.test.mjs +10 -0
  173. package/authoring/integration/schema.d.mts +2 -0
  174. package/authoring/integration/schema.mjs +1 -0
  175. package/authoring/integration/type.ts +4 -0
  176. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  177. package/clients/cli/commands/build-theme.mjs +1 -1
  178. package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
  179. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  180. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  181. package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
  182. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  183. package/clients/cli/commands/doctor-integration.test.mjs +837 -0
  184. package/clients/cli/commands/doctor.mjs +190 -0
  185. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  186. package/clients/cli/commands/integration-check.test.mjs +267 -0
  187. package/clients/cli/commands/integration.doc.mjs +6 -2
  188. package/clients/cli/commands/integration.mjs +107 -1
  189. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  190. package/clients/cli/commands/swizzle.mjs +5 -3
  191. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  192. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  193. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  194. package/clients/cli/index.mjs +30 -5
  195. package/clients/cli/lib/component-format.mjs +5 -1
  196. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  197. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  198. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  199. package/foundation/agent-docs/agent-docs.mjs +8 -6
  200. package/foundation/config/project.mjs +82 -0
  201. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  202. package/foundation/discovery/component-discovery.d.mts +190 -10
  203. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  204. package/foundation/discovery/component-discovery.mjs +864 -56
  205. package/foundation/discovery/component-discovery.test.mjs +96 -0
  206. package/foundation/discovery/component-replacement.mjs +18 -0
  207. package/foundation/discovery/component-replacement.test.mjs +40 -0
  208. package/foundation/discovery/doc-types.d.mts +157 -0
  209. package/foundation/discovery/doc-types.mjs +1224 -0
  210. package/foundation/discovery/doc-types.test.mjs +700 -0
  211. package/foundation/discovery/docs-discovery.d.mts +81 -0
  212. package/foundation/discovery/docs-discovery.mjs +57 -0
  213. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  214. package/foundation/discovery/integration-doc-files.mjs +231 -0
  215. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  216. package/foundation/discovery/module-exports.d.mts +27 -0
  217. package/foundation/discovery/module-exports.mjs +356 -31
  218. package/foundation/discovery/module-exports.test.mjs +172 -0
  219. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  220. package/foundation/discovery/package-tsconfig.mjs +228 -0
  221. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  222. package/foundation/discovery/project-typescript.d.mts +32 -0
  223. package/foundation/discovery/project-typescript.mjs +89 -0
  224. package/foundation/discovery/prop-drift.d.mts +278 -0
  225. package/foundation/discovery/prop-drift.mjs +2263 -0
  226. package/foundation/discovery/prop-drift.test.mjs +2272 -0
  227. package/foundation/discovery/template-adapter.mjs +74 -5
  228. package/foundation/discovery/type-match.d.mts +53 -0
  229. package/foundation/discovery/type-match.mjs +660 -0
  230. package/foundation/discovery/type-match.test.mjs +169 -0
  231. package/foundation/discovery/type-text.d.mts +68 -0
  232. package/foundation/discovery/type-text.mjs +658 -0
  233. package/foundation/discovery/type-text.test.mjs +196 -0
  234. package/foundation/discovery/unresolved-references.d.mts +62 -0
  235. package/foundation/discovery/unresolved-references.mjs +790 -0
  236. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  237. package/foundation/doc-compiler/doc-loads.test.mjs +15 -1
  238. package/foundation/doc-compiler/inputs.mjs +23 -0
  239. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  240. package/foundation/doc-compiler/links.d.mts +9 -5
  241. package/foundation/doc-compiler/links.mjs +4 -2
  242. package/foundation/integrations/contribution-inventory.mjs +6 -1
  243. package/foundation/response/response-types.doc.mjs +7 -2
  244. package/foundation/xle/registry.mjs +4 -0
  245. package/foundation/xle/registry.test.mjs +28 -0
  246. package/package.json +10 -10
  247. package/scripts/postinstall.mjs +3 -3
@@ -616,6 +616,42 @@ describe('search leaf — a theme is found by its names; its description is pros
616
616
  );
617
617
  });
618
618
 
619
+ describe('search leaf — components whose docs live in a family folder', () => {
620
+ it("indexes a family member from its own entry, not the family's keywords", async () => {
621
+ // HStack and VStack are documented in Stack's doc, whose keywords
622
+ // (horizontal, vertical, row, column, ...) describe Stack.
623
+ const reasons = async (/** @type {string} */ query) =>
624
+ Object.fromEntries(
625
+ (await search(query, {cwd, type: 'component'})).data.results.map(r => [
626
+ r.name,
627
+ r.reason,
628
+ ]),
629
+ );
630
+ const column = await reasons('column');
631
+ expect(column.HStack ?? '').not.toMatch(/keyword/);
632
+ expect(column.VStack ?? '').not.toMatch(/keyword/);
633
+ expect(column.Stack).toMatch(/keyword/);
634
+ const vertical = (await search('vertical', {cwd, type: 'component'})).data.results.map(
635
+ r => r.name,
636
+ );
637
+ expect(vertical.indexOf('VStack')).toBeGreaterThanOrEqual(0);
638
+ if (vertical.includes('HStack')) {
639
+ expect(vertical.indexOf('VStack')).toBeLessThan(vertical.indexOf('HStack'));
640
+ }
641
+ }, SLOW);
642
+
643
+ it('ranks VStack, HStack and Heading first for their own names, with their own import', async () => {
644
+ for (const name of ['VStack', 'HStack', 'Heading']) {
645
+ const r = await search(name.toLowerCase(), {cwd, type: 'component'});
646
+ expect(r.data.results[0]).toMatchObject({
647
+ domain: 'component',
648
+ name,
649
+ import: `@astryxdesign/core/${name}`,
650
+ });
651
+ }
652
+ }, SLOW);
653
+ });
654
+
619
655
  describe('search leaf — integration components', () => {
620
656
  /**
621
657
  * A minimal consumer project: a stub `@astryxdesign/core` (so `findCoreDir`
@@ -827,3 +863,142 @@ describe('search — usage guidance is indexed, a tier below description', () =>
827
863
  expect(hit?.score).toBe(45);
828
864
  });
829
865
  });
866
+
867
+ describe('search leaf — compound names, other names, and word forms', () => {
868
+ it('finds a compound name typed as separate words inside a longer query', async () => {
869
+ const {data} = await search('table header cell with sort arrow', {cwd});
870
+ expect(
871
+ data.results.slice(0, 3).map(r => r.name),
872
+ ).toContain('TableHeaderCell');
873
+ }, SLOW);
874
+
875
+ it('finds a one-word keyword typed as separate words', async () => {
876
+ // MetadataList declares `keyvalue`.
877
+ const {data} = await search('key value pairs', {cwd});
878
+ expect(data.results[0]).toMatchObject({
879
+ domain: 'component',
880
+ name: 'MetadataList',
881
+ });
882
+ }, SLOW);
883
+
884
+ it('finds a hook named by its words without the `use` prefix', async () => {
885
+ const {data} = await search('persisted table column settings', {cwd});
886
+ expect(data.results[0]).toMatchObject({
887
+ domain: 'hook',
888
+ name: 'useTableColumnSettings',
889
+ });
890
+ }, SLOW);
891
+
892
+ it('reads a camelCase identifier as the words it spells', async () => {
893
+ const {data} = await search('useTablePaginationState', {cwd});
894
+ expect(data.results[0]).toMatchObject({
895
+ domain: 'hook',
896
+ name: 'useTablePagination',
897
+ });
898
+ }, SLOW);
899
+
900
+ it('keeps each identifier of a multi-word query whole', async () => {
901
+ const {data} = await search('ChatMessageList ChatComposer', {cwd});
902
+ expect(data.results.slice(0, 2).map(r => r.name).sort()).toEqual([
903
+ 'ChatComposer',
904
+ 'ChatMessageList',
905
+ ]);
906
+ }, SLOW);
907
+
908
+ it("finds a component by another library's name for it", async () => {
909
+ for (const [q, name] of [
910
+ ['ScrollArea viewport', 'ScrollableArea'],
911
+ ['toggle group of buttons', 'ToggleButtonGroup'],
912
+ ['circular progress for uploads', 'Spinner'],
913
+ ]) {
914
+ const {data} = await search(q, {cwd});
915
+ expect(data.results[0], q).toMatchObject({domain: 'component', name});
916
+ }
917
+ }, SLOW);
918
+
919
+ it('reads a one-identifier other name as typed', async () => {
920
+ const {data} = await search('AppHeader', {cwd});
921
+ expect(data.results[0]).toMatchObject({
922
+ domain: 'component',
923
+ name: 'LayoutHeader',
924
+ });
925
+ }, SLOW);
926
+
927
+ it('adds no near siblings beside an entry the query names outright', async () => {
928
+ const {data} = await search('top nav mega menu', {cwd});
929
+ expect(data.results[0]).toMatchObject({name: 'TopNavMegaMenu'});
930
+ // Its sub-parts start with its name; read joined they would score in the
931
+ // whole-name tier right under it.
932
+ const siblings = data.results.filter(
933
+ r => r.name !== 'TopNavMegaMenu' && r.name.startsWith('TopNavMegaMenu'),
934
+ );
935
+ for (const sibling of siblings) expect(sibling.score).toBeLessThan(190);
936
+ }, SLOW);
937
+
938
+ it('ranks an entry the query names above a match on part of another name', async () => {
939
+ // `table header` names TableHeader; useTableStickyColumns only holds the
940
+ // words `sticky columns`.
941
+ const {data} = await search('table header with sticky columns', {cwd});
942
+ const names = data.results.map(r => r.name);
943
+ expect(names.indexOf('TableHeader')).toBeLessThan(
944
+ names.indexOf('useTableStickyColumns') === -1
945
+ ? Infinity
946
+ : names.indexOf('useTableStickyColumns'),
947
+ );
948
+ }, SLOW);
949
+
950
+ it('keeps an entry a query word names by its whole name at its own rank', async () => {
951
+ // Two words join into TextInput, and TextArea also matches two words
952
+ // through its joined keyword; one word is still TextArea's whole name.
953
+ const {data} = await search('text input and textarea with multi line', {
954
+ cwd,
955
+ });
956
+ expect(data.results[0]).toMatchObject({name: 'TextArea'});
957
+ }, SLOW);
958
+
959
+ it('ranks a match on more of the query above a shorter named entry', async () => {
960
+ const {data} = await search('dropdown menu radio options', {cwd});
961
+ expect(data.results[0]).toMatchObject({name: 'DropdownMenuRadioItem'});
962
+ }, SLOW);
963
+
964
+ it('lets a plural start a name through its singular', () => {
965
+ expect(
966
+ scoreCandidate('tokens', {domain: 'component', name: 'Tokenizer'}),
967
+ ).toMatchObject({score: 60});
968
+ });
969
+
970
+ it('finds Icon by a glyph name', async () => {
971
+ for (const q of ['cog', 'lightning bolt']) {
972
+ const {data} = await search(q, {cwd});
973
+ expect(data.results[0], q).toMatchObject({
974
+ domain: 'component',
975
+ name: 'Icon',
976
+ });
977
+ }
978
+ }, SLOW);
979
+
980
+ it('matches a verb form against its verb', () => {
981
+ // "spacing" lost the final e of "space".
982
+ expect(
983
+ scoreCandidate('spacing', {domain: 'component', name: 'Gap', keywords: ['space']}),
984
+ ).toMatchObject({score: 88});
985
+ expect(
986
+ scoreCandidate('dragging', {domain: 'component', name: 'Gap', keywords: ['drag']}),
987
+ ).toMatchObject({score: 88});
988
+ });
989
+
990
+ it('lets a plural start a longer word through its singular', () => {
991
+ expect(
992
+ scoreCandidate('chips', {domain: 'component', name: 'Chipset'}),
993
+ ).toMatchObject({score: 60});
994
+ // A four-letter singular is too short: "stats" does not start "statusbar".
995
+ expect(
996
+ scoreCandidate('stats', {domain: 'component', name: 'Statusbar'}),
997
+ ).toBeNull();
998
+ });
999
+
1000
+ it('leaves an identifier joined with _ unmatched when nothing has it', async () => {
1001
+ const {data} = await search('qqzz_no_match_here', {cwd});
1002
+ expect(data.results).toEqual([]);
1003
+ }, SLOW);
1004
+ });
@@ -21,8 +21,10 @@ import {checkGhCli} from '../_github.mjs';
21
21
  import {Project} from '../../../foundation/config/project.mjs';
22
22
  import {
23
23
  CORE_PACKAGE,
24
- findIntegrationComponentDoc,
25
- findIntegrationComponentSource,
24
+ docStem,
25
+ findComponentReadme,
26
+ findIntegrationComponent,
27
+ unscopedComponentOwners,
26
28
  } from '../../../foundation/discovery/component-discovery.mjs';
27
29
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
28
30
  import {AstryxError, writeFailed} from '../../error.mjs';
@@ -126,33 +128,38 @@ async function loadConfigSafely(cwd) {
126
128
 
127
129
  /**
128
130
  * Build the set of OWNER packages that provide a component named `name` across
129
- * core + every loaded integration.
131
+ * core + every loaded integration. Core holds every name it documents, but has
132
+ * source to copy (`sourceDir`) only for a name with its own folder.
130
133
  * @param {string} coreDir
131
134
  * @param {Array<{name: string, components?: string, issuesUrl?: string}>} loadedIntegrations
132
135
  * @param {string} name
133
136
  * @param {string|undefined} coreIssuesUrl
134
- * @returns {Array<{package: string, sourceDir: string|null, ownerPackage: string, issuesUrl: string|undefined}>}
137
+ * @returns {Array<{package: string, sourceDir: string|null, docPath: string|null, ownerPackage: string, issuesUrl: string|undefined, hold: string}>}
135
138
  */
136
139
  function resolveOwners(coreDir, loadedIntegrations, name, coreIssuesUrl) {
137
140
  const owners = [];
138
141
  const coreComponentDir = path.join(coreDir, 'src', name);
139
- if (fs.existsSync(coreComponentDir)) {
142
+ const coreFolder = fs.existsSync(coreComponentDir);
143
+ if (coreFolder || findComponentReadme(coreDir, name)) {
140
144
  owners.push({
141
145
  package: CORE_PACKAGE,
142
- sourceDir: coreComponentDir,
146
+ sourceDir: coreFolder ? coreComponentDir : null,
147
+ docPath: null,
143
148
  ownerPackage: CORE_PACKAGE,
144
149
  issuesUrl: coreIssuesUrl || DEFAULT_ISSUES_URL,
150
+ hold: 'core',
145
151
  });
146
152
  }
147
153
  for (const integration of loadedIntegrations) {
148
- const docPath = findIntegrationComponentDoc(integration, name);
149
- if (!docPath) continue;
150
- const sourcePath = findIntegrationComponentSource(integration, name);
154
+ const found = findIntegrationComponent(integration, name);
155
+ if (!found) continue;
151
156
  owners.push({
152
157
  package: integration.name,
153
- sourceDir: sourcePath ? path.dirname(sourcePath) : null,
158
+ sourceDir: found.sourcePath ? path.dirname(found.sourcePath) : null,
159
+ docPath: found.docPath,
154
160
  ownerPackage: integration.name,
155
161
  issuesUrl: integration.issuesUrl,
162
+ hold: found.hold,
156
163
  });
157
164
  }
158
165
  return owners;
@@ -222,25 +229,32 @@ export async function swizzleCopy(component, options = {}) {
222
229
  : undefined;
223
230
  // An active integration replacement answers to the Core name it replaces,
224
231
  // bare or qualified by its own package (spec:AST-035 FR11): copy it under its
225
- // own name. `--package @astryxdesign/core` still copies the Core original.
232
+ // doc's file name, the folder it has always gone to. `--package
233
+ // @astryxdesign/core` still copies the Core original.
226
234
  if (pkg !== CORE_PACKAGE) {
227
235
  const replacement = await resolveComponentReplacement(
228
236
  coreDir,
229
237
  loadedIntegrations,
230
238
  dirName,
231
239
  );
240
+ const copyName = replacement ? docStem(replacement.docPath) : null;
232
241
  if (
233
242
  replacement &&
234
- (!pkg || (pkg === replacement.package && replacement.name !== dirName))
243
+ copyName &&
244
+ (!pkg || (pkg === replacement.package && copyName !== dirName))
235
245
  ) {
236
- return swizzleCopy(replacement.name, {
246
+ return swizzleCopy(copyName, {
237
247
  ...options,
238
248
  package: replacement.package,
239
249
  });
240
250
  }
241
251
  }
242
252
 
243
- const allOwners = resolveOwners(coreDir, loadedIntegrations, dirName, coreIssuesUrl);
253
+ const found = resolveOwners(coreDir, loadedIntegrations, dirName, coreIssuesUrl);
254
+ // The owner rule, then a Core name without its own folder drops out.
255
+ const allOwners = (pkg ? found : unscopedComponentOwners(found)).filter(
256
+ owner => owner.package !== CORE_PACKAGE || owner.sourceDir != null,
257
+ );
244
258
 
245
259
  if (allOwners.length === 0) {
246
260
  throw new AstryxError(
@@ -0,0 +1,45 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Regression coverage for the table-filter page's compact view-options tabs.
5
+ * @input The shipped table-filter page template source.
6
+ * @output Assertions that the shared tabpanel is labelled by its selected tab.
7
+ * @position Template contract test for the tabs relationship in the narrow-view sheet.
8
+ */
9
+
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import {fileURLToPath} from 'node:url';
13
+ import {describe, expect, it} from 'vitest';
14
+
15
+ const sourcePath = path.resolve(
16
+ path.dirname(fileURLToPath(import.meta.url)),
17
+ '../../assets/templates/pages/table-filter/page.tsx',
18
+ );
19
+ const source = fs.readFileSync(sourcePath, 'utf8');
20
+ const sheet = source.match(
21
+ /const viewOptionsSheet = \(([\s\S]*?)\n {2}\);/,
22
+ )?.[1];
23
+ const tab = sheet?.match(/<Tab\b([\s\S]*?)\/>/)?.[1];
24
+ const panel = sheet?.match(/<VStack\b([^>]*?role="tabpanel"[^>]*?)>/)?.[1];
25
+
26
+ describe('table-filter view-options tabs', () => {
27
+ it('finds the compact sheet, its tab and its panel', () => {
28
+ expect(sheet).toBeDefined();
29
+ expect(tab).toBeDefined();
30
+ expect(panel).toBeDefined();
31
+ });
32
+
33
+ it('gives every tab an id derived from the panel id and its section', () => {
34
+ expect(tab).toContain('id={`${viewPanelId}-tab-${section.key}`}');
35
+ expect(tab).toContain('panelId={viewPanelId}');
36
+ });
37
+
38
+ it('labels the shared panel by the selected tab, not a fixed string', () => {
39
+ expect(panel).toContain('id={viewPanelId}');
40
+ expect(panel).toContain(
41
+ 'aria-labelledby={`${viewPanelId}-tab-${viewSection}`}',
42
+ );
43
+ expect(panel).not.toContain('aria-label=');
44
+ });
45
+ });
@@ -1,7 +1,14 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
+ import * as fs from 'node:fs';
4
+ import * as os from 'node:os';
5
+ import * as path from 'node:path';
3
6
  import {describe, it, expect} from 'vitest';
4
- import {stripTemplateAssetRefs, template} from './template.mjs';
7
+ import {
8
+ stripTemplateAssetRefs,
9
+ template,
10
+ extractComponents,
11
+ } from './template.mjs';
5
12
 
6
13
  describe('stripTemplateAssetRefs', () => {
7
14
  it('replaces a /template-assets image path with an inline data URI', () => {
@@ -31,8 +38,7 @@ describe('stripTemplateAssetRefs', () => {
31
38
  });
32
39
 
33
40
  it('preserves surrounding source structure', () => {
34
- const src =
35
- "const data = [{src: '/template-assets/x.png', alt: 'X'}];";
41
+ const src = "const data = [{src: '/template-assets/x.png', alt: 'X'}];";
36
42
  const out = stripTemplateAssetRefs(src);
37
43
  expect(out).toContain("alt: 'X'");
38
44
  expect(out).toContain('const data = [{src:');
@@ -102,4 +108,115 @@ describe('template --skeleton component extraction (prefix-agnostic)', () => {
102
108
 
103
109
  expect(result.data.skeleton).toContain('columns={{minWidth: 200}}');
104
110
  });
111
+
112
+ it('filters out local helper components declared in the same file', () => {
113
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-test-'));
114
+ const pagePath = path.join(tmpDir, 'page.tsx');
115
+ fs.writeFileSync(
116
+ pagePath,
117
+ `
118
+ import {Card} from '@astryxdesign/core/Layout';
119
+
120
+ function TimelineSection() {
121
+ return <div />;
122
+ }
123
+
124
+ export default function Page() {
125
+ return (
126
+ <Card>
127
+ <TimelineSection />
128
+ </Card>
129
+ );
130
+ }
131
+ `,
132
+ );
133
+
134
+ try {
135
+ const components = extractComponents(pagePath);
136
+ expect(components).toContain('Card');
137
+ expect(components).not.toContain('Timeline');
138
+ } finally {
139
+ fs.rmSync(tmpDir, {recursive: true, force: true});
140
+ }
141
+ });
142
+
143
+ it('filters out a type-annotated local helper', () => {
144
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-test-'));
145
+ const pagePath = path.join(tmpDir, 'page.tsx');
146
+ fs.writeFileSync(
147
+ pagePath,
148
+ `
149
+ import type {FC} from 'react';
150
+ import {Card} from '@astryxdesign/core/Layout';
151
+
152
+ const TimelineSection: FC = () => <div />;
153
+
154
+ export default function Page() {
155
+ return (
156
+ <Card>
157
+ <TimelineSection />
158
+ </Card>
159
+ );
160
+ }
161
+ `,
162
+ );
163
+ try {
164
+ const components = extractComponents(pagePath);
165
+ expect(components).toContain('Card');
166
+ expect(components).not.toContain('Timeline');
167
+ } finally {
168
+ fs.rmSync(tmpDir, {recursive: true, force: true});
169
+ }
170
+ });
171
+
172
+ it('keeps an imported component when declaration-like text appears in a comment or string', () => {
173
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-test-'));
174
+ const pagePath = path.join(tmpDir, 'page.tsx');
175
+ fs.writeFileSync(
176
+ pagePath,
177
+ `
178
+ import {Card} from '@astryxdesign/core/Layout';
179
+
180
+ // const Card = () => null;
181
+ const note = 'function Card() {}';
182
+
183
+ export default function Page() {
184
+ return <Card>{note}</Card>;
185
+ }
186
+ `,
187
+ );
188
+ try {
189
+ expect(extractComponents(pagePath)).toContain('Card');
190
+ } finally {
191
+ fs.rmSync(tmpDir, {recursive: true, force: true});
192
+ }
193
+ });
194
+
195
+ it('keeps a bare imported component whose name is itself a stripped suffix', () => {
196
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-test-'));
197
+ const pagePath = path.join(tmpDir, 'page.tsx');
198
+ fs.writeFileSync(
199
+ pagePath,
200
+ `
201
+ import {Section} from '@astryxdesign/core/Section';
202
+
203
+ function SectionHeading() {
204
+ return <div />;
205
+ }
206
+
207
+ export default function Page() {
208
+ return (
209
+ <Section>
210
+ <SectionHeading />
211
+ </Section>
212
+ );
213
+ }
214
+ `,
215
+ );
216
+ try {
217
+ expect(extractComponents(pagePath)).toContain('Section');
218
+ } finally {
219
+ fs.rmSync(tmpDir, {recursive: true, force: true});
220
+ }
221
+ });
105
222
  });
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The theme build imports Core when a build runs, not when the CLI starts.
5
+ *
6
+ * The CLI loads the theme build module for every command, and Core's root
7
+ * entry pulls in all of Core and React. So a command that builds no theme must
8
+ * not ask for either, or `astryx --version` pays for them whenever a Core is
9
+ * installed. A resolve hook in a real subprocess records every request for
10
+ * Core or React and the module that made it, whether or not the request
11
+ * resolves.
12
+ */
13
+
14
+ import {afterAll, beforeAll, describe, expect, it} from 'vitest';
15
+ import {spawnSync} from 'node:child_process';
16
+ import * as fs from 'node:fs';
17
+ import * as os from 'node:os';
18
+ import * as path from 'node:path';
19
+ import {fileURLToPath, pathToFileURL} from 'node:url';
20
+
21
+ const BIN = fileURLToPath(
22
+ new URL('../../../clients/cli/bin/astryx.mjs', import.meta.url),
23
+ );
24
+
25
+ /** @type {string} */
26
+ let dir;
27
+ /** @type {string} */
28
+ let register;
29
+ /** @type {string} */
30
+ let log;
31
+
32
+ beforeAll(() => {
33
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-core-on-demand-'));
34
+ log = path.join(dir, 'requests.jsonl');
35
+ const hooks = path.join(dir, 'hooks.mjs');
36
+ fs.writeFileSync(
37
+ hooks,
38
+ [
39
+ "import {appendFileSync} from 'node:fs';",
40
+ `const LOG = ${JSON.stringify(log)};`,
41
+ 'const WATCHED = /^(?:@astryxdesign\\/core|react|react-dom)(?:\\/|$)/;',
42
+ 'export async function resolve(specifier, context, nextResolve) {',
43
+ ' if (WATCHED.test(specifier)) {',
44
+ ' const parent = context.parentURL ?? null;',
45
+ " appendFileSync(LOG, JSON.stringify({specifier, parent}) + '\\n');",
46
+ ' }',
47
+ ' return nextResolve(specifier, context);',
48
+ '}',
49
+ '',
50
+ ].join('\n'),
51
+ );
52
+ register = path.join(dir, 'register.mjs');
53
+ fs.writeFileSync(
54
+ register,
55
+ `import {register} from 'node:module';\nregister(${JSON.stringify(pathToFileURL(hooks).href)});\n`,
56
+ );
57
+ // A plain theme object: the file itself never imports Core, so a request for
58
+ // Core can only come from the build.
59
+ fs.writeFileSync(
60
+ path.join(dir, 'ocean.mjs'),
61
+ "export default {name: 'ocean', tokens: {'--color-bg': '#0a0a0a'}};\n",
62
+ );
63
+ });
64
+
65
+ afterAll(() => {
66
+ fs.rmSync(dir, {recursive: true, force: true});
67
+ });
68
+
69
+ /**
70
+ * Run the CLI and return each Core or React specifier it asked for, mapped to
71
+ * the first module that asked.
72
+ * @param {string[]} args
73
+ * @returns {{status: number | null, requested: Record<string, string | null>}}
74
+ */
75
+ function run(args) {
76
+ fs.rmSync(log, {force: true});
77
+ const res = spawnSync(
78
+ process.execPath,
79
+ ['--import', pathToFileURL(register).href, BIN, ...args],
80
+ {cwd: dir, encoding: 'utf-8', timeout: 20_000},
81
+ );
82
+ /** @type {Record<string, string | null>} */
83
+ const requested = {};
84
+ const lines = fs.existsSync(log)
85
+ ? fs.readFileSync(log, 'utf-8').split('\n').filter(Boolean)
86
+ : [];
87
+ for (const line of lines) {
88
+ const {specifier, parent} = JSON.parse(line);
89
+ if (!(specifier in requested)) requested[specifier] = parent;
90
+ }
91
+ return {status: res.status, requested};
92
+ }
93
+
94
+ describe('theme build imports Core on demand', () => {
95
+ it('astryx --version asks for neither Core nor React', () => {
96
+ const {status, requested} = run(['--version']);
97
+ expect(status).toBe(0);
98
+ expect(requested).toEqual({});
99
+ });
100
+
101
+ it('theme build imports Core from the theme build module', () => {
102
+ const {requested} = run([
103
+ 'theme',
104
+ 'build',
105
+ 'ocean.mjs',
106
+ '--check',
107
+ '--json',
108
+ ]);
109
+ expect(requested['@astryxdesign/core/theme']).toMatch(
110
+ /\/api\/theme\/build\/build\.mjs$/,
111
+ );
112
+ });
113
+ });
@@ -163,6 +163,19 @@ export function themeBuildFamily(files: string[], options: {
163
163
  checked?: undefined;
164
164
  };
165
165
  }>;
166
+ /**
167
+ * The bindings one Core provides: the namespaces interception spreads, the
168
+ * functions the build calls, and why the import failed, if it did.
169
+ */
170
+ export type CoreBindings = {
171
+ themeModule: any;
172
+ rootModule: any;
173
+ importError: any;
174
+ defineTheme: any;
175
+ generateThemeRulesSplit: any;
176
+ generateOnMediaCSS: any;
177
+ generateAdaptationCSS: any;
178
+ };
166
179
  /**
167
180
  * How one `prop:value` pair on a component target is classified — the single
168
181
  * vocabulary both the root and adaptation paths reason in.
@@ -210,16 +223,3 @@ export type ThemeBuildTrailer = {
210
223
  */
211
224
  fontNotices: string[];
212
225
  };
213
- /**
214
- * The bindings one Core provides: the namespaces interception spreads, the
215
- * functions the build calls, and why the import failed, if it did.
216
- */
217
- export type CoreBindings = {
218
- themeModule: any;
219
- rootModule: any;
220
- importError: any;
221
- defineTheme: any;
222
- generateThemeRulesSplit: any;
223
- generateOnMediaCSS: any;
224
- generateAdaptationCSS: any;
225
- };