@astryxdesign/cli 0.7.1 → 0.7.2-canary.01eab6a

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 (101) hide show
  1. package/README.md +7 -7
  2. package/api/component/_adapter.d.mts +41 -1
  3. package/api/component/_adapter.mjs +93 -7
  4. package/api/component/component.mjs +22 -5
  5. package/api/component/component.test.mjs +420 -167
  6. package/api/component/integration-export-name.test.mjs +644 -0
  7. package/api/component/list/list.mjs +42 -4
  8. package/api/gap-report/gap-report.mjs +67 -4
  9. package/api/integration/_adapter.d.mts +12 -0
  10. package/api/integration/_adapter.mjs +54 -0
  11. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  12. package/api/integration/add-contribution.mjs +7 -3
  13. package/api/integration/authoring-checks.mjs +11 -2
  14. package/api/integration/authoring-checks.test.mjs +39 -0
  15. package/api/integration/authoring-checks.type.d.mts +9 -0
  16. package/api/integration/authoring-checks.type.mjs +14 -1
  17. package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
  18. package/api/integration/pack-check.mjs +61 -107
  19. package/api/integration/pack-check.test.mjs +359 -0
  20. package/api/search/search.d.mts +9 -0
  21. package/api/search/search.mjs +108 -16
  22. package/api/search/search.test.mjs +36 -0
  23. package/api/swizzle/copy/copy.mjs +28 -14
  24. package/api/template/table-filter-view-tabs.test.mjs +45 -0
  25. package/api/template/template.test.mjs +120 -3
  26. package/api/theme/build/build.core-on-demand.test.mjs +113 -0
  27. package/api/theme/build/build.d.mts +13 -13
  28. package/api/theme/build/build.family.test.mjs +16 -0
  29. package/api/theme/build/build.mjs +149 -55
  30. package/api/theme/themeBuild.doc.mjs +3 -3
  31. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  32. package/assets/codemods/transforms/next/index.mjs +11 -1
  33. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  34. package/assets/docs/tree/add-a-component.doc.mjs +10 -0
  35. package/assets/docs/tree/check-the-props.doc.mjs +145 -0
  36. package/assets/docs/tree/checks.doc.mjs +4 -4
  37. package/assets/docs/tree/component-family.doc.mjs +5 -1
  38. package/assets/docs/tree/component-imports.doc.mjs +8 -0
  39. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  40. package/assets/docs/tree/single-component.doc.mjs +3 -2
  41. package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
  42. package/assets/docs/tree/versioning.doc.mjs +1 -0
  43. package/assets/docs/working-with-ai.doc.mjs +43 -4
  44. package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
  45. package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
  46. package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
  47. package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
  48. package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
  49. package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
  50. package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
  51. package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
  52. package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
  53. package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
  54. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
  55. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
  56. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
  57. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
  58. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
  59. package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
  60. package/assets/templates/pages/detail-page/page.tsx +3 -3
  61. package/assets/templates/pages/table-filter/page.tsx +3 -2
  62. package/assets/templates/pages/table-inbox/page.tsx +10 -8
  63. package/authoring/doctypes/base/type.ts +6 -0
  64. package/authoring/doctypes/component/component.doc.mjs +4 -4
  65. package/authoring/doctypes/component/type.ts +6 -3
  66. package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
  67. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  68. package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
  69. package/clients/cli/commands/doctor-integration.test.mjs +327 -0
  70. package/clients/cli/commands/doctor.mjs +74 -0
  71. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  72. package/clients/cli/lib/component-format.mjs +5 -1
  73. package/foundation/discovery/component-discovery.d.mts +190 -10
  74. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  75. package/foundation/discovery/component-discovery.mjs +864 -56
  76. package/foundation/discovery/component-discovery.test.mjs +96 -0
  77. package/foundation/discovery/component-replacement.mjs +18 -0
  78. package/foundation/discovery/component-replacement.test.mjs +40 -0
  79. package/foundation/discovery/module-exports.d.mts +27 -0
  80. package/foundation/discovery/module-exports.mjs +356 -31
  81. package/foundation/discovery/module-exports.test.mjs +172 -0
  82. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  83. package/foundation/discovery/package-tsconfig.mjs +228 -0
  84. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  85. package/foundation/discovery/project-typescript.d.mts +23 -0
  86. package/foundation/discovery/project-typescript.mjs +61 -0
  87. package/foundation/discovery/prop-drift.d.mts +220 -0
  88. package/foundation/discovery/prop-drift.mjs +1765 -0
  89. package/foundation/discovery/prop-drift.test.mjs +1197 -0
  90. package/foundation/discovery/template-adapter.mjs +74 -5
  91. package/foundation/discovery/unresolved-references.d.mts +62 -0
  92. package/foundation/discovery/unresolved-references.mjs +790 -0
  93. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  94. package/foundation/doc-compiler/doc-loads.test.mjs +9 -1
  95. package/foundation/doc-compiler/inputs.mjs +23 -0
  96. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  97. package/foundation/integrations/contribution-inventory.mjs +6 -1
  98. package/foundation/response/response-types.doc.mjs +1 -1
  99. package/foundation/xle/registry.mjs +4 -0
  100. package/foundation/xle/registry.test.mjs +28 -0
  101. package/package.json +10 -10
@@ -15,7 +15,8 @@
15
15
  * needs it: `Project` assembles templates from it. While this sat in api/, that
16
16
  * made a cycle across the layer boundary — Project reached up for discovery and
17
17
  * this module imported Project back. Nothing here depends on api/; every import
18
- * is node:*, jiti, foundation/*, or authoring/*.
18
+ * is node:*, jiti, foundation/*, or authoring/*, plus a lazily required
19
+ * @babel/parser for extractComponents' local-declaration scan.
19
20
  *
20
21
  * @position packages/cli/foundation/discovery — shared template discovery/IO;
21
22
  * consumed by Project and by the api/template leaves.
@@ -512,6 +513,19 @@ function expressionUse(source, open, close) {
512
513
  return null;
513
514
  }
514
515
 
516
+ /** @type {typeof import('@babel/parser') | undefined} */
517
+ let babelParser;
518
+
519
+ /**
520
+ * The template source parser, loaded on first use so listing templates
521
+ * never pays for it.
522
+ * @returns {typeof import('@babel/parser')}
523
+ */
524
+ function templateSourceParser() {
525
+ babelParser ??= require('@babel/parser');
526
+ return /** @type {typeof import('@babel/parser')} */ (babelParser);
527
+ }
528
+
515
529
  /**
516
530
  * The [start, end) range of every comment in `source`, or none when it does
517
531
  * not parse as TSX.
@@ -520,8 +534,7 @@ function expressionUse(source, open, close) {
520
534
  */
521
535
  function commentRanges(source) {
522
536
  try {
523
- const {parse} = require('@babel/parser');
524
- const {comments} = parse(source, {
537
+ const {comments} = templateSourceParser().parse(source, {
525
538
  sourceType: 'module',
526
539
  plugins: ['jsx', 'typescript'],
527
540
  });
@@ -1267,7 +1280,8 @@ export async function discoverIntegrationTemplatesForOne(integration) {
1267
1280
  template: id,
1268
1281
  message: `Template "${id}" is missing a "type" of "page" or "block". Stamp the default export with type: 'page' or type: 'block'.`,
1269
1282
  });
1270
- const declared = doc?.replaces ?? (await declaredReplacement(docPath, id));
1283
+ const declared =
1284
+ doc?.replaces ?? (await declaredReplacement(docPath, id));
1271
1285
  if (declared != null) {
1272
1286
  errors.push({
1273
1287
  code: 'invalid_template_replacement',
@@ -1423,6 +1437,51 @@ const UBIQUITOUS = new Set([
1423
1437
  'Icon',
1424
1438
  ]);
1425
1439
 
1440
+ /**
1441
+ * Names bound by top-level `function`, `class`, `const`, `let` or `var`
1442
+ * declarations (exported or not). Returns an empty set when the source does
1443
+ * not parse, so a parse failure never drops a real component.
1444
+ *
1445
+ * @param {string} src
1446
+ * @returns {Set<string>}
1447
+ */
1448
+ function topLevelBindingNames(src) {
1449
+ /** @type {Set<string>} */
1450
+ const names = new Set();
1451
+ let program;
1452
+ try {
1453
+ program = templateSourceParser().parse(src, {
1454
+ sourceType: 'module',
1455
+ plugins: ['jsx', 'typescript'],
1456
+ errorRecovery: true,
1457
+ }).program;
1458
+ } catch {
1459
+ return names;
1460
+ }
1461
+ for (const statement of program.body) {
1462
+ const node =
1463
+ statement.type === 'ExportNamedDeclaration' ||
1464
+ statement.type === 'ExportDefaultDeclaration'
1465
+ ? statement.declaration
1466
+ : statement;
1467
+ if (node == null) continue;
1468
+ if (
1469
+ (node.type === 'FunctionDeclaration' ||
1470
+ node.type === 'ClassDeclaration') &&
1471
+ node.id
1472
+ ) {
1473
+ names.add(node.id.name);
1474
+ } else if (node.type === 'VariableDeclaration') {
1475
+ for (const declarator of node.declarations) {
1476
+ if (declarator.id.type === 'Identifier') {
1477
+ names.add(declarator.id.name);
1478
+ }
1479
+ }
1480
+ }
1481
+ }
1482
+ return names;
1483
+ }
1484
+
1426
1485
  /**
1427
1486
  * @param {string} pagePath
1428
1487
  * @returns {string[]}
@@ -1449,14 +1508,24 @@ export function extractComponents(pagePath) {
1449
1508
  while ((m = tagRegex.exec(src)) !== null) {
1450
1509
  matches.push(m[2]);
1451
1510
  }
1511
+
1512
+ // Exclude names bound by a top-level declaration in the same file: those are
1513
+ // page-local helpers (e.g. `function TimelineSection()`), not components a
1514
+ // builder can import. Read real bindings from the syntax tree so comments,
1515
+ // strings and type annotations cannot add or hide a name.
1516
+ const localDeclNames = topLevelBindingNames(src);
1517
+
1452
1518
  return [
1453
1519
  ...new Set(
1454
1520
  matches
1521
+ .filter(n => !localDeclNames.has(n))
1455
1522
  .filter(n => !['Theme', 'ThemeProvider'].includes(n))
1456
1523
  .filter(n => !UBIQUITOUS.has(n))
1457
1524
  .map(n =>
1458
1525
  n.replace(
1459
- /(Item|Section|Header|Content|Footer|Panel|Heading|CollapseButton|Column|Sortable|Selection|Group|Source)$/,
1526
+ // Strip only when a stem remains, so a bare `<Section>` keeps its
1527
+ // own name instead of emptying out.
1528
+ /(?<=.)(Item|Section|Header|Content|Footer|Panel|Heading|CollapseButton|Column|Sortable|Selection|Group|Source)$/,
1460
1529
  '',
1461
1530
  ),
1462
1531
  )
@@ -0,0 +1,62 @@
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
+ * The first reference that does not resolve from the given files, the files
6
+ * they import, and so on, as far as `follow` allows. A reference fails when
7
+ * the program finds no module, no type package or no file for it, when a
8
+ * module does not export a name imported from it, or, in the files `mine`
9
+ * accepts, when a type name resolves to no declaration (TS2304). A module
10
+ * found without types (a JavaScript file) resolves: its names are `any`. A
11
+ * side-effect import counts where the compiler checks one
12
+ * (`noUncheckedSideEffectImports`, on by default from TypeScript 6).
13
+ * @param {any} ts the project's own `typescript`
14
+ * @param {any} program
15
+ * @param {any} checker
16
+ * @param {any[]} roots source files
17
+ * @param {(file: string) => boolean} follow which files it reads past them
18
+ * @param {(file: string) => boolean} mine whose type names it checks
19
+ * @returns {UnresolvedReference | null}
20
+ */
21
+ export function unresolvedReference(ts: any, program: any, checker: any, roots: any[], follow: (file: string) => boolean, mine: (file: string) => boolean): UnresolvedReference | null;
22
+ /**
23
+ * The first reference that does not resolve from the program's global roots,
24
+ * whose types every file sees: a type package the program loads by name
25
+ * (`compilerOptions.types`, `*` expanded as TypeScript does, or every
26
+ * package in `typeRoots` where TypeScript loads them all) that cannot be
27
+ * found, or a reference in a declaration file the package's own config
28
+ * includes, wherever it sits, or in the package's own type packages, or in a
29
+ * file they import. Of those, only a file that acts globally starts the walk:
30
+ * a script, `declare global`, `declare module`, `export as namespace`, an
31
+ * import that takes no names (a side-effect import, `import {} from`), a
32
+ * bare `export *`, or a `/// <reference>`. A config from above the package,
33
+ * such as a monorepo's root config, may include the whole repository, so
34
+ * only the package's own declaration files start the walk then. A
35
+ * dependency's declarations (below `node_modules`) are not followed: `tsc`
36
+ * skips their errors (`skipLibCheck`), and they reach a component only
37
+ * through the globals they declare.
38
+ * @param {any} ts the project's own `typescript`
39
+ * @param {any} program
40
+ * @param {any} checker
41
+ * @param {string[]} declarations the declaration files the config includes
42
+ * @param {any} options the program's compiler options
43
+ * @param {(file: string) => boolean} isOwnFile whether a file is the
44
+ * package's own
45
+ * @returns {UnresolvedReference | null}
46
+ */
47
+ export function unresolvedGlobals(ts: any, program: any, checker: any, declarations: string[], options: any, isOwnFile: (file: string) => boolean): UnresolvedReference | null;
48
+ export type UnresolvedReference = {
49
+ /**
50
+ * the reference as written, quoted
51
+ */
52
+ name: string;
53
+ /**
54
+ * the file that writes it
55
+ */
56
+ file: string;
57
+ /**
58
+ * a file imports it, a file
59
+ * uses it as a type name, or the config names it
60
+ */
61
+ how: "imported" | "used" | "named";
62
+ };