@astryxdesign/cli 0.7.17 → 0.7.18-canary.g57306fd

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 (241) hide show
  1. package/README.md +1 -1
  2. package/api/discover/_adapter.d.mts +7 -5
  3. package/api/discover/_adapter.mjs +12 -11
  4. package/api/docs/_adapter.d.mts +19 -2
  5. package/api/docs/_adapter.mjs +66 -5
  6. package/api/doctor/_adapter.d.mts +11 -62
  7. package/api/doctor/_adapter.mjs +242 -472
  8. package/api/doctor/doctor.d.mts +1 -1
  9. package/api/doctor/doctor.mjs +3 -3
  10. package/api/doctor/theme-checks.mjs +37 -45
  11. package/api/error.d.mts +21 -0
  12. package/api/error.mjs +89 -0
  13. package/api/hook/list/list.d.mts +1 -1
  14. package/api/icon/_adapter.d.mts +8 -0
  15. package/api/icon/_adapter.mjs +17 -0
  16. package/api/icon/_authoring.mjs +6 -6
  17. package/api/icon/_default-look.mjs +16 -16
  18. package/api/icon/add/add.mjs +3 -3
  19. package/api/icon/exportIconIndex.doc.mjs +2 -2
  20. package/api/icon/icon.doc.mjs +2 -2
  21. package/api/icon/icon.type.d.mts +4 -0
  22. package/api/icon/icon.type.mjs +2 -1
  23. package/api/icon/search/icon-index.mjs +16 -3
  24. package/api/icon/search/search.d.mts +15 -5
  25. package/api/icon/search/search.mjs +74 -16
  26. package/api/icon/use/use.mjs +4 -4
  27. package/api/render/_adapter.mjs +233 -40
  28. package/api/render/render.type.d.mts +1 -1
  29. package/api/render/render.type.mjs +1 -1
  30. package/api/search/ORDERING.md +2 -2
  31. package/api/search/_adapter.mjs +4 -0
  32. package/api/search/_candidate-score.mjs +32 -8
  33. package/api/search/_cards.json +1 -1
  34. package/api/search/_compound.d.mts +0 -1
  35. package/api/search/_compound.mjs +93 -2
  36. package/api/search/_icons.d.mts +4 -2
  37. package/api/search/_icons.mjs +4 -2
  38. package/api/search/_lexical.mjs +177 -17
  39. package/api/search/_order.d.mts +3 -1
  40. package/api/search/_order.mjs +16 -5
  41. package/api/search/_result.d.mts +9 -0
  42. package/api/search/_result.mjs +10 -0
  43. package/api/search/_score.mjs +21 -3
  44. package/api/swizzle/_moduleGraph.d.mts +8 -0
  45. package/api/swizzle/_moduleGraph.mjs +61 -3
  46. package/api/template/copy/copy.mjs +5 -3
  47. package/api/theme/_adapter.mjs +48 -12
  48. package/api/theme/build/build.d.mts +4 -0
  49. package/api/theme/build/build.mjs +69 -18
  50. package/api/theme/build/style-keys.mjs +4 -5
  51. package/api/theme/build/theme-object.mjs +5 -0
  52. package/api/theme/palette/generate/color.d.mts +47 -0
  53. package/api/theme/palette/generate/color.mjs +58 -1
  54. package/api/theme/palette/generate/derive-look.d.mts +293 -0
  55. package/api/theme/palette/generate/derive-look.mjs +1362 -0
  56. package/api/theme/palette/generate/editor-look.d.mts +62 -0
  57. package/api/theme/palette/generate/editor-look.mjs +550 -0
  58. package/api/theme/palette/generate/mapping.d.mts +94 -9
  59. package/api/theme/palette/generate/mapping.mjs +94 -22
  60. package/api/theme-edit/_adapter.mjs +13 -2
  61. package/api/theme-edit/_catalog.d.mts +13 -13
  62. package/api/theme-edit/_catalog.mjs +66 -28
  63. package/api/theme-edit/_check.d.mts +82 -6
  64. package/api/theme-edit/_check.mjs +1270 -238
  65. package/api/theme-edit/_color.d.mts +74 -0
  66. package/api/theme-edit/_color.mjs +168 -3
  67. package/api/theme-edit/_compiler.d.mts +3 -5
  68. package/api/theme-edit/_compiler.mjs +122 -23
  69. package/api/theme-edit/_context.d.mts +55 -12
  70. package/api/theme-edit/_context.mjs +114 -60
  71. package/api/theme-edit/_css.d.mts +11 -0
  72. package/api/theme-edit/_css.mjs +40 -0
  73. package/api/theme-edit/_edit.d.mts +15 -2
  74. package/api/theme-edit/_edit.mjs +1469 -133
  75. package/api/theme-edit/_how-commands.d.mts +116 -0
  76. package/api/theme-edit/_how-commands.mjs +227 -115
  77. package/api/theme-edit/_how-question.d.mts +74 -29
  78. package/api/theme-edit/_how-question.mjs +8514 -1256
  79. package/api/theme-edit/_how-sides.d.mts +22 -0
  80. package/api/theme-edit/_how-sides.mjs +173 -0
  81. package/api/theme-edit/_how-steps.d.mts +42 -0
  82. package/api/theme-edit/_how-steps.mjs +208 -0
  83. package/api/theme-edit/_how-values.d.mts +29 -0
  84. package/api/theme-edit/_how-values.mjs +111 -0
  85. package/api/theme-edit/_how-words.d.mts +15 -0
  86. package/api/theme-edit/_how-words.mjs +239 -0
  87. package/api/theme-edit/_how.d.mts +1 -1
  88. package/api/theme-edit/_how.mjs +422 -37
  89. package/api/theme-edit/_missed.d.mts +2 -1
  90. package/api/theme-edit/_missed.mjs +125 -13
  91. package/api/theme-edit/_normal.d.mts +5 -3
  92. package/api/theme-edit/_normal.mjs +54 -14
  93. package/api/theme-edit/_palette.d.mts +204 -4
  94. package/api/theme-edit/_palette.mjs +901 -25
  95. package/api/theme-edit/_part-pieces.d.mts +54 -0
  96. package/api/theme-edit/_part-pieces.mjs +179 -0
  97. package/api/theme-edit/_part-words.mjs +33 -5
  98. package/api/theme-edit/_parts.d.mts +133 -0
  99. package/api/theme-edit/_parts.mjs +599 -10
  100. package/api/theme-edit/_picture-traits.d.mts +259 -0
  101. package/api/theme-edit/_picture-traits.mjs +1030 -0
  102. package/api/theme-edit/_preview.d.mts +95 -4
  103. package/api/theme-edit/_preview.mjs +284 -31
  104. package/api/theme-edit/_project.d.mts +14 -4
  105. package/api/theme-edit/_project.mjs +95 -26
  106. package/api/theme-edit/_resolved.d.mts +46 -0
  107. package/api/theme-edit/_resolved.mjs +800 -0
  108. package/api/theme-edit/_set-line.d.mts +29 -0
  109. package/api/theme-edit/_set-line.mjs +100 -0
  110. package/api/theme-edit/_settings.d.mts +625 -28
  111. package/api/theme-edit/_settings.mjs +4867 -888
  112. package/api/theme-edit/_tables.d.mts +25 -1
  113. package/api/theme-edit/_tables.mjs +115 -11
  114. package/api/theme-edit/_text-looks.d.mts +78 -0
  115. package/api/theme-edit/_text-looks.mjs +376 -0
  116. package/api/theme-edit/_vet.d.mts +3 -26
  117. package/api/theme-edit/_vet.mjs +5 -89
  118. package/api/theme-edit/how/how.d.mts +1 -1
  119. package/api/theme-edit/how/how.mjs +1 -1
  120. package/api/theme-edit/show/show.d.mts +4 -3
  121. package/api/theme-edit/show/show.mjs +3 -2
  122. package/api/theme-edit/theme-edit.type.d.mts +117 -1
  123. package/api/theme-edit/theme-edit.type.mjs +46 -3
  124. package/api/theme-edit/themeEditHow.doc.mjs +3 -3
  125. package/api/theme-edit/themeEditNew.doc.mjs +4 -0
  126. package/api/theme-edit/themeEditSet.doc.mjs +6 -2
  127. package/api/theme-edit/themeEditShow.doc.mjs +22 -3
  128. package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
  129. package/assets/component-list.generated.json +1 -1
  130. package/assets/docs/author-a-theme.doc.mjs +7 -4
  131. package/assets/docs/theme.doc.dense.mjs +10 -0
  132. package/assets/docs/theme.doc.mjs +10 -0
  133. package/assets/docs/theme.doc.zh.mjs +10 -0
  134. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  135. package/assets/docs/tree/icon-sets.doc.mjs +1 -1
  136. package/assets/docs/use-a-theme.doc.mjs +89 -17
  137. package/assets/docs-routes.generated.json +1 -1
  138. package/assets/docs.generated.json +2 -2
  139. package/assets/icons/definitions/article.doc.mjs +9 -0
  140. package/assets/icons/template-icons.json +5 -0
  141. package/assets/search-catalog.generated.json +2 -2
  142. package/assets/self-audit.generated.json +1 -1
  143. package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
  144. package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
  145. package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
  146. package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
  147. package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
  148. package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
  149. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
  150. package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
  151. package/assets/templates/components.generated.json +1 -1
  152. package/assets/templates/pages/ide/page.tsx +5 -10
  153. package/assets/templates/pages/payment-form/page.tsx +16 -60
  154. package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
  155. package/authoring/debug/parse.d.mts +1 -1
  156. package/authoring/doctypes/_schema.d.mts +13 -13
  157. package/authoring/gap-report/parse.d.mts +1 -1
  158. package/clients/cli/build-id.generated.json +1 -1
  159. package/clients/cli/commands/ensure-core-built.mjs +17 -10
  160. package/clients/cli/commands/experimental/icon.mjs +7 -7
  161. package/clients/cli/commands/experimental/theme.mjs +175 -13
  162. package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
  163. package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
  164. package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
  165. package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
  166. package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
  167. package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
  168. package/clients/cli/commands/hook.mjs +7 -0
  169. package/clients/cli/commands/theme-build.doc.mjs +1 -1
  170. package/clients/cli/index.mjs +6 -2
  171. package/clients/cli/lib/hook-format.mjs +41 -1
  172. package/clients/cli/lib/json-shim.mjs +34 -14
  173. package/clients/cli/lib/other-cli-words.mjs +7 -0
  174. package/clients/cli/lib/unknown-command.mjs +345 -46
  175. package/clients/cli/manifest.generated.json +1 -1
  176. package/foundation/agent-docs/agent-docs.d.mts +11 -2
  177. package/foundation/agent-docs/agent-docs.mjs +51 -8
  178. package/foundation/config/project.d.mts +11 -1
  179. package/foundation/config/project.mjs +11 -2
  180. package/foundation/discovery/component-replacement.d.mts +5 -8
  181. package/foundation/discovery/component-replacement.mjs +12 -14
  182. package/foundation/discovery/core-augmentation-points.d.mts +35 -0
  183. package/foundation/discovery/core-augmentation-points.mjs +410 -9
  184. package/foundation/discovery/core-elements.d.mts +6 -0
  185. package/foundation/discovery/core-elements.mjs +10 -2
  186. package/foundation/discovery/core-prop-types.d.mts +5 -0
  187. package/foundation/discovery/core-prop-types.mjs +10 -3
  188. package/foundation/discovery/core-props.d.mts +8 -0
  189. package/foundation/discovery/core-props.mjs +29 -13
  190. package/foundation/discovery/icon-ranking.d.mts +5 -2
  191. package/foundation/discovery/icon-ranking.mjs +101 -18
  192. package/foundation/discovery/icon-set-checks.mjs +1 -1
  193. package/foundation/discovery/icon-set-writer.mjs +1 -1
  194. package/foundation/discovery/official-list.d.mts +17 -0
  195. package/foundation/discovery/official-list.mjs +77 -0
  196. package/foundation/discovery/unknown-core-props.d.mts +130 -0
  197. package/foundation/discovery/unknown-core-props.mjs +601 -0
  198. package/foundation/discovery/written-prop-values.d.mts +35 -0
  199. package/foundation/discovery/written-prop-values.mjs +258 -0
  200. package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
  201. package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
  202. package/foundation/fs/package-name.d.mts +10 -0
  203. package/foundation/fs/package-name.mjs +37 -0
  204. package/foundation/fs/project-source-files.d.mts +27 -0
  205. package/foundation/fs/project-source-files.mjs +115 -0
  206. package/foundation/fs/project-sources.d.mts +25 -0
  207. package/foundation/fs/project-sources.mjs +83 -0
  208. package/foundation/fs/read-record.d.mts +18 -0
  209. package/foundation/fs/read-record.mjs +36 -2
  210. package/foundation/integrations/integration-warnings.d.mts +39 -7
  211. package/foundation/integrations/integration-warnings.mjs +141 -19
  212. package/foundation/integrations/missing-dependency.d.mts +11 -0
  213. package/foundation/integrations/missing-dependency.mjs +20 -5
  214. package/foundation/release/folder-lock.d.mts +5 -2
  215. package/foundation/release/folder-lock.mjs +9 -3
  216. package/foundation/release/notices.mjs +2 -8
  217. package/foundation/render/cut-short.d.mts +8 -2
  218. package/foundation/render/cut-short.mjs +50 -5
  219. package/foundation/render/drawn-contrast.d.mts +40 -0
  220. package/foundation/render/drawn-contrast.mjs +355 -0
  221. package/foundation/render/file-header.mjs +4 -0
  222. package/foundation/render/layers.d.mts +2 -1
  223. package/foundation/render/layers.mjs +22 -1
  224. package/foundation/render/package-resolve-hooks.d.mts +38 -9
  225. package/foundation/render/package-resolve-hooks.mjs +124 -32
  226. package/foundation/render/page-worker.mjs +95 -23
  227. package/foundation/render/part-boxes.d.mts +27 -0
  228. package/foundation/render/part-boxes.mjs +45 -0
  229. package/foundation/render/picture-chrome.mjs +36 -4
  230. package/foundation/render/picture-playwright.mjs +26 -2
  231. package/foundation/render/picture-window.d.mts +29 -2
  232. package/foundation/render/picture-window.mjs +99 -1
  233. package/foundation/render/render-page.d.mts +39 -6
  234. package/foundation/render/render-page.mjs +26 -10
  235. package/foundation/render/ts-paths.mjs +2 -1
  236. package/foundation/response/error-codes.doc.mjs +1 -1
  237. package/foundation/response/error-codes.mjs +1 -1
  238. package/foundation/response/response-types.doc.mjs +9 -5
  239. package/foundation/text/written-string.d.mts +4 -1
  240. package/foundation/text/written-string.mjs +4 -1
  241. package/package.json +8 -7
@@ -87,14 +87,32 @@ import {
87
87
  } from '../../foundation/discovery/button-actions.mjs';
88
88
  import {iconImportFindings} from '../../foundation/discovery/icon-imports.mjs';
89
89
  import {packageImportTarget} from '../../foundation/discovery/package-exports.mjs';
90
- import {projectAugmentations} from '../../foundation/discovery/core-augmentation-points.mjs';
91
90
  import {
92
- resolveProjectTypeScript,
93
- TYPESCRIPT_FIX,
94
- unusableTypeScriptReason,
95
- } from '../../foundation/discovery/project-typescript.mjs';
96
- import {nameWords, orderByAffinity} from '../../foundation/text/suggest-order.mjs';
97
- import {compilerOptionsFor, existingFile, pathsFor, projectMapsImport, resolvePath} from '../../foundation/render/ts-paths.mjs';
91
+ OTHER_JSX_RUNTIME,
92
+ judgeCoreProps,
93
+ projectTypeScript,
94
+ readCoreDocs,
95
+ widensJsx,
96
+ } from '../../foundation/discovery/unknown-core-props.mjs';
97
+ import {
98
+ listProjectSourceFiles,
99
+ MARKUP_PAGE,
100
+ SOURCE_FILE_LIMIT,
101
+ } from '../../foundation/fs/project-source-files.mjs';
102
+ export {
103
+ listProjectSourceFiles,
104
+ SOURCE_EXTENSIONS,
105
+ } from '../../foundation/fs/project-source-files.mjs';
106
+ export {
107
+ projectImportsModule,
108
+ specifierTargets,
109
+ } from '../../foundation/fs/project-sources.mjs';
110
+ import {
111
+ existingFile,
112
+ pathsFor,
113
+ projectMapsImport,
114
+ resolvePath,
115
+ } from '../../foundation/render/ts-paths.mjs';
98
116
  import {
99
117
  resolveIconModule,
100
118
  splitSpecifier,
@@ -112,8 +130,10 @@ import {
112
130
  import {cssImports} from '../../foundation/render/embedded-imports.mjs';
113
131
  import {postcss} from '../../foundation/runtime/lazy-dependencies.mjs';
114
132
  import {hostedRun} from '../../foundation/runtime/package-root.mjs';
115
- import {pointsToDoctor} from '../../foundation/integrations/integration-warnings.mjs';
116
- import {CORE_COMPARISON_CODES} from '../../foundation/discovery/component-replacement.mjs';
133
+ import {
134
+ doctorChecksOutside,
135
+ pointsToDoctor,
136
+ } from '../../foundation/integrations/integration-warnings.mjs';
117
137
  import {isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
118
138
  import * as path from 'node:path';
119
139
  import {
@@ -142,7 +162,6 @@ import {
142
162
  findInstalledPackage,
143
163
  findPackageRoot,
144
164
  isInside,
145
- findWorkspaceRoot,
146
165
  } from '../../foundation/fs/paths.mjs';
147
166
  import {compareText} from '../../foundation/text/compare-text.mjs';
148
167
  import {
@@ -287,7 +306,8 @@ export const BUTTON_ACTIONS_CODEC = {
287
306
  Array.isArray(value.found) &&
288
307
  Number.isInteger(value.files) &&
289
308
  typeof value.incomplete === 'boolean' &&
290
- (value.domListener === undefined || typeof value.domListener === 'string') &&
309
+ (value.domListener === undefined ||
310
+ typeof value.domListener === 'string') &&
291
311
  value.found.every(
292
312
  (/** @type {any} */ button) =>
293
313
  button != null &&
@@ -308,29 +328,6 @@ export function themeRecordOwner(theme) {
308
328
  return themeImportPackage(theme);
309
329
  }
310
330
 
311
- export const SOURCE_EXTENSIONS = new Set([
312
- '.js',
313
- '.jsx',
314
- '.mjs',
315
- '.cjs',
316
- '.ts',
317
- '.tsx',
318
- '.mts',
319
- '.cts',
320
- ]);
321
-
322
- /** The folders the source walk skips as a build's output, at a package's root. */
323
- const ROOT_OUTPUT_DIRS = new Set(['build', 'coverage', 'dist']);
324
-
325
- const SKIP_DIRS = new Set([
326
- '.git',
327
- '.next',
328
- 'build',
329
- 'coverage',
330
- 'dist',
331
- 'node_modules',
332
- ]);
333
-
334
331
  /** @param {string} file */
335
332
  export function readTextFile(file) {
336
333
  return fs.readFileSync(file, 'utf-8');
@@ -347,10 +344,8 @@ export function readTextFileIfExists(file) {
347
344
  }
348
345
 
349
346
  /** A module path of only `.` and `..`, with an optional `index`: `'..'`, `'./index'`. */
350
- const FOLDER_PATH = /['"`](?:\.{1,2}\/)*\.{1,2}(?:\/(?:index(?:\.[cm]?[jt]sx?)?)?)?['"`]/;
351
-
352
- /** A page in a format that renders components but is not a script: MDX or Astro. */
353
- const MARKUP_PAGE = /\.(?:mdx|astro)$/u;
347
+ const FOLDER_PATH =
348
+ /['"`](?:\.{1,2}\/)*\.{1,2}(?:\/(?:index(?:\.[cm]?[jt]sx?)?)?)?['"`]/;
354
349
 
355
350
  /**
356
351
  * A load in a module's text: `import(…)`, `require(…)`, `require.context(…)`
@@ -361,74 +356,6 @@ const MARKUP_PAGE = /\.(?:mdx|astro)$/u;
361
356
  const TEXT_LOAD =
362
357
  /(?:\bimport\s*\(|\brequire(?:\.context)?\s*\(|\bimport\.meta\.glob(?:Eager)?\s*\(\s*\[?)\s*(?:(['"`])([^'"`$*?{[]*))?/g;
363
358
 
364
- /** The most source files {@link listProjectSourceFiles} reads. */
365
- const SOURCE_FILE_LIMIT = 5000;
366
-
367
- /**
368
- * A bounded app-source walk that excludes dependencies, generated output, and
369
- * links. The doctor parses the returned bytes without executing app code.
370
- * @param {string} root
371
- * @param {string} generatedModule
372
- * @param {{stylesheets?: boolean, pages?: boolean, markup?: boolean, outputAtRootsOnly?: boolean, skippedLinks?: string[]}} [options] - also list
373
- * `.css` files, `.html` pages, and `.mdx` and `.astro` pages; with
374
- * `outputAtRootsOnly`, skip a `build`, `dist` or `coverage` folder only in
375
- * a folder with a package.json, where a build writes its output, and read
376
- * one anywhere else (an app route named `build`); `skippedLinks` collects
377
- * each linked folder or source file the walk does not follow
378
- */
379
- export function listProjectSourceFiles(root, generatedModule, options = {}) {
380
- /** @type {string[]} */
381
- const files = [];
382
- /** @type {string[]} */
383
- const queue = [root];
384
- while (queue.length > 0 && files.length < SOURCE_FILE_LIMIT) {
385
- const dir = /** @type {string} */ (queue.shift());
386
- let entries;
387
- try {
388
- entries = fs.readdirSync(dir, {withFileTypes: true});
389
- } catch {
390
- continue;
391
- }
392
- for (const entry of entries) {
393
- const file = path.join(dir, entry.name);
394
- if (entry.isSymbolicLink()) {
395
- if (options.skippedLinks && !SKIP_DIRS.has(entry.name)) {
396
- let linkedFolder = false;
397
- try {
398
- linkedFolder = fs.statSync(file).isDirectory();
399
- } catch {
400
- // A link that resolves to nothing holds no module.
401
- }
402
- if (linkedFolder || SOURCE_EXTENSIONS.has(path.extname(entry.name)) || MARKUP_PAGE.test(entry.name)) {
403
- options.skippedLinks.push(file);
404
- }
405
- }
406
- continue;
407
- }
408
- if (entry.isDirectory()) {
409
- const skipped =
410
- SKIP_DIRS.has(entry.name) &&
411
- !(options.outputAtRootsOnly === true && ROOT_OUTPUT_DIRS.has(entry.name) && !fs.existsSync(path.join(dir, 'package.json')));
412
- if (!skipped && !entry.name.startsWith('.astryx-')) {
413
- queue.push(file);
414
- }
415
- } else if (
416
- entry.isFile() &&
417
- file !== generatedModule &&
418
- (SOURCE_EXTENSIONS.has(path.extname(entry.name)) ||
419
- (options.stylesheets === true &&
420
- path.extname(entry.name) === '.css') ||
421
- (options.pages === true &&
422
- /^\.html?$/u.test(path.extname(entry.name))) ||
423
- (options.markup === true && MARKUP_PAGE.test(entry.name)))
424
- ) {
425
- files.push(file);
426
- }
427
- }
428
- }
429
- return files;
430
- }
431
-
432
359
  /**
433
360
  * Each file in the project's own source that still uses the placeholder
434
361
  * component the CLI writes for a missing icon: the file, the component's
@@ -470,7 +397,8 @@ export function findIconPlaceholders(projectDir) {
470
397
  * Test, story and fixture files: code that shows or checks a button, not a
471
398
  * page that a person uses. The check reads none of them.
472
399
  */
473
- const TEST_FILE = /(^|\/)(__tests__|__mocks__|__fixtures__|__stories__)\/|\.(test|spec|cy|fixture|stories|story)\.(?:[cm]?[jt]sx?|mdx)$/;
400
+ const TEST_FILE =
401
+ /(^|\/)(__tests__|__mocks__|__fixtures__|__stories__)\/|\.(test|spec|cy|fixture|stories|story)\.(?:[cm]?[jt]sx?|mdx)$/;
474
402
 
475
403
  /**
476
404
  * Folders that usually hold tests, stories or fixtures, though an app may
@@ -502,7 +430,8 @@ const DOM_PRESS_LISTENER =
502
430
  * (`from 'x'`, `import('x')`, `require('x')`), as the capture: a package, a
503
431
  * path alias or a `#` key.
504
432
  */
505
- const NON_RELATIVE_MODULE = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)['"]([^'"./][^'"]*)['"]/g;
433
+ const NON_RELATIVE_MODULE =
434
+ /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+|\brequire\s*\(\s*)['"]([^'"./][^'"]*)['"]/g;
506
435
 
507
436
  /** @param {string} text */
508
437
  const escapeRegExp = text => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -520,8 +449,13 @@ const escapeRegExp = text => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
520
449
  export function findButtonsWithoutAction(projectDir) {
521
450
  /** @type {string[]} */
522
451
  const skippedLinks = [];
523
- const listed = listProjectSourceFiles(projectDir, '', {markup: true, outputAtRootsOnly: true, skippedLinks});
524
- const relative = (/** @type {string} */ file) => path.relative(projectDir, file).split(path.sep).join('/');
452
+ const listed = listProjectSourceFiles(projectDir, '', {
453
+ markup: true,
454
+ outputAtRootsOnly: true,
455
+ skippedLinks,
456
+ });
457
+ const relative = (/** @type {string} */ file) =>
458
+ path.relative(projectDir, file).split(path.sep).join('/');
525
459
  const kept = listed.filter(file => !TEST_FILE.test(relative(file)));
526
460
  // An MDX or Astro page is not read, but one that names a component may
527
461
  // render it anywhere.
@@ -529,7 +463,8 @@ export function findButtonsWithoutAction(projectDir) {
529
463
  const files = kept.filter(file => !MARKUP_PAGE.test(file));
530
464
  // A listing cut short may leave out a module that renders a component, so
531
465
  // the check cannot tell that nothing renders it.
532
- if (listed.length >= SOURCE_FILE_LIMIT) return {found: [], files: files.length, incomplete: true};
466
+ if (listed.length >= SOURCE_FILE_LIMIT)
467
+ return {found: [], files: files.length, incomplete: true};
533
468
  /** @type {Map<string, string | null>} */
534
469
  const texts = new Map();
535
470
  const textOf = (/** @type {string} */ file) => {
@@ -549,13 +484,28 @@ export function findButtonsWithoutAction(projectDir) {
549
484
  const candidates = files.filter(file => {
550
485
  if (TEST_FOLDER.test(relative(file))) return false;
551
486
  const text = textOf(file);
552
- return text != null && text.includes('@astryxdesign/core') && /\b(?:Icon)?Button\b/.test(text);
487
+ return (
488
+ text != null &&
489
+ text.includes('@astryxdesign/core') &&
490
+ /\b(?:Icon)?Button\b/.test(text)
491
+ );
553
492
  });
554
- if (candidates.length === 0) return {found: [], files: files.length, incomplete: false};
493
+ if (candidates.length === 0)
494
+ return {found: [], files: files.length, incomplete: false};
555
495
  // A script that listens for a press through the DOM may act on any button,
556
496
  // by its wrapper's id or from the document, so no button is judged.
557
- const listener = files.find(file => !TEST_FOLDER.test(relative(file)) && DOM_PRESS_LISTENER.test(textOf(file) ?? ''));
558
- if (listener) return {found: [], files: files.length, incomplete: false, domListener: relative(listener)};
497
+ const listener = files.find(
498
+ file =>
499
+ !TEST_FOLDER.test(relative(file)) &&
500
+ DOM_PRESS_LISTENER.test(textOf(file) ?? ''),
501
+ );
502
+ if (listener)
503
+ return {
504
+ found: [],
505
+ files: files.length,
506
+ incomplete: false,
507
+ domListener: relative(listener),
508
+ };
559
509
  const declared = declaredPackages(projectDir);
560
510
  const ownName = readPackageJson(path.join(projectDir, 'package.json'))?.name;
561
511
  // The project's own packages, by name: a package.json in a folder of the
@@ -566,27 +516,42 @@ export function findButtonsWithoutAction(projectDir) {
566
516
  /** @type {Set<string>} */
567
517
  const walked = new Set();
568
518
  for (const file of files) {
569
- for (let dir = path.dirname(file); isInside(dir, projectDir) && !walked.has(dir); dir = path.dirname(dir)) {
519
+ for (
520
+ let dir = path.dirname(file);
521
+ isInside(dir, projectDir) && !walked.has(dir);
522
+ dir = path.dirname(dir)
523
+ ) {
570
524
  walked.add(dir);
571
525
  const name = readPackageJson(path.join(dir, 'package.json'))?.name;
572
- if (typeof name === 'string' && !localPackages.has(name)) localPackages.set(name, dir);
526
+ if (typeof name === 'string' && !localPackages.has(name))
527
+ localPackages.set(name, dir);
573
528
  }
574
529
  }
575
530
  /** @type {Map<string, {kind: 'member' | 'installed' | 'none', dir: string | null}>} */
576
531
  const installed = new Map();
577
532
  // Where Node finds a package from a file: a workspace member is linked from
578
533
  // node_modules to a folder of the project outside any node_modules.
579
- const installedAs = (/** @type {string} */ name, /** @type {string} */ file) => {
534
+ const installedAs = (
535
+ /** @type {string} */ name,
536
+ /** @type {string} */ file,
537
+ ) => {
580
538
  const key = `${path.dirname(file)}\0${name}`;
581
539
  let found = installed.get(key);
582
540
  if (found == null) {
583
541
  const local = localPackages.get(name);
584
- const packageDir = local ?? findInstalledPackage(path.dirname(file), name, Infinity);
542
+ const packageDir =
543
+ local ?? findInstalledPackage(path.dirname(file), name, Infinity);
585
544
  found = {kind: packageDir == null ? 'none' : 'installed', dir: null};
586
545
  if (packageDir != null) {
587
546
  try {
588
547
  const dir = fs.realpathSync(packageDir);
589
- if (isInside(dir, projectDir) && !path.relative(projectDir, dir).split(path.sep).includes('node_modules')) {
548
+ if (
549
+ isInside(dir, projectDir) &&
550
+ !path
551
+ .relative(projectDir, dir)
552
+ .split(path.sep)
553
+ .includes('node_modules')
554
+ ) {
590
555
  found = {kind: 'member', dir};
591
556
  }
592
557
  } catch {
@@ -602,10 +567,14 @@ export function findButtonsWithoutAction(projectDir) {
602
567
  // resolves, such as an alias with no tsconfig path. The project's own name
603
568
  // (a package.json `exports` path to its own files) and a workspace member
604
569
  // (a package linked to a folder of the project) are its own code.
605
- const knownPackage = (/** @type {string} */ specifier, /** @type {string} */ file) => {
570
+ const knownPackage = (
571
+ /** @type {string} */ specifier,
572
+ /** @type {string} */ file,
573
+ ) => {
606
574
  const {name} = splitSpecifier(specifier.replace(/^node:/, ''));
607
575
  if (name === ownName) return false;
608
- if (specifier.startsWith('node:') || builtinModules.includes(name)) return true;
576
+ if (specifier.startsWith('node:') || builtinModules.includes(name))
577
+ return true;
609
578
  const {kind} = installedAs(name, file);
610
579
  if (kind === 'member') return false;
611
580
  return declared.has(name) || kind === 'installed';
@@ -616,7 +585,9 @@ export function findButtonsWithoutAction(projectDir) {
616
585
  /** @type {Set<string>} */
617
586
  const importedMembers = new Set();
618
587
  for (const file of [...files, ...markup]) {
619
- for (const [, specifier] of (textOf(file) ?? '').matchAll(NON_RELATIVE_MODULE)) {
588
+ for (const [, specifier] of (textOf(file) ?? '').matchAll(
589
+ NON_RELATIVE_MODULE,
590
+ )) {
620
591
  if (specifier.startsWith('#')) continue;
621
592
  const {name} = splitSpecifier(specifier);
622
593
  const {kind, dir} = installedAs(name, file);
@@ -635,7 +606,9 @@ export function findButtonsWithoutAction(projectDir) {
635
606
  };
636
607
  // An app that routes by the URL hash opens its first page from a `#` link:
637
608
  // one that imports a hash router or a hash history.
638
- const hashRouting = files.some(file => routesByHash(textOf(file) ?? '', {jsx: !/\.[cm]?ts$/.test(file)}));
609
+ const hashRouting = files.some(file =>
610
+ routesByHash(textOf(file) ?? '', {jsx: !/\.[cm]?ts$/.test(file)}),
611
+ );
639
612
  /** @type {Map<string, import('../../foundation/discovery/button-actions.mjs').ModuleScan | null>} */
640
613
  const scans = new Map();
641
614
  const scan = (/** @type {string} */ file) => {
@@ -658,7 +631,9 @@ export function findButtonsWithoutAction(projectDir) {
658
631
  const target = /^\.{1,2}(?:\/|$)/.test(specifier)
659
632
  ? path.resolve(path.dirname(file), specifier)
660
633
  : ownImportTarget(specifier, file);
661
- return specifierStem((target ?? specifier).split(path.sep).join('/'));
634
+ return specifierStem(
635
+ (target ?? specifier).split(path.sep).join('/'),
636
+ );
662
637
  },
663
638
  }),
664
639
  );
@@ -671,7 +646,9 @@ export function findButtonsWithoutAction(projectDir) {
671
646
  /** @type {Set<string>} */
672
647
  const aliasImporters = new Set();
673
648
  for (const file of files) {
674
- for (const [, specifier] of (textOf(file) ?? '').matchAll(NON_RELATIVE_MODULE)) {
649
+ for (const [, specifier] of (textOf(file) ?? '').matchAll(
650
+ NON_RELATIVE_MODULE,
651
+ )) {
675
652
  if (specifier.startsWith('#') || projectMapsImport(specifier, file)) {
676
653
  aliasImporters.add(file);
677
654
  break;
@@ -686,7 +663,9 @@ export function findButtonsWithoutAction(projectDir) {
686
663
  const pattern = new RegExp(`\\b(?:${alternatives})\\b`);
687
664
  return [...files, ...markup].filter(file => {
688
665
  const text = textOf(file) ?? '';
689
- return pattern.test(text) || FOLDER_PATH.test(text) || aliasImporters.has(file);
666
+ return (
667
+ pattern.test(text) || FOLDER_PATH.test(text) || aliasImporters.has(file)
668
+ );
690
669
  });
691
670
  };
692
671
  // A module that loads modules by a path the scan cannot read may load any
@@ -699,7 +678,11 @@ export function findButtonsWithoutAction(projectDir) {
699
678
  for (const file of [...files, ...markup]) {
700
679
  // A tool's config file (`next.config.js`, beside a package.json) loads its
701
680
  // own settings, never a component.
702
- if (/\.config\.[cm]?[jt]s$/.test(file) && fs.existsSync(path.join(path.dirname(file), 'package.json'))) continue;
681
+ if (
682
+ /\.config\.[cm]?[jt]s$/.test(file) &&
683
+ fs.existsSync(path.join(path.dirname(file), 'package.json'))
684
+ )
685
+ continue;
703
686
  const text = textOf(file) ?? '';
704
687
  if (!/\bimport\s*\(|\brequire\b|import\.meta\.glob/.test(text)) continue;
705
688
  const read = scan(file);
@@ -707,7 +690,13 @@ export function findButtonsWithoutAction(projectDir) {
707
690
  const folders = read
708
691
  ? read.loads
709
692
  : [...text.matchAll(TEXT_LOAD)]
710
- .filter(([, quote, written]) => !quote || written === '' || /^\.{1,2}\//.test(written) || !knownPackage(written, file))
693
+ .filter(
694
+ ([, quote, written]) =>
695
+ !quote ||
696
+ written === '' ||
697
+ /^\.{1,2}\//.test(written) ||
698
+ !knownPackage(written, file),
699
+ )
711
700
  .map(([, quote, written]) => loadFolder(quote ? written : ''));
712
701
  for (const folder of folders) {
713
702
  if (folder === '*') loadsAnything = true;
@@ -725,16 +714,32 @@ export function findButtonsWithoutAction(projectDir) {
725
714
  // A linked folder or file the walk does not follow may render any
726
715
  // component, so no component counts as one that nothing renders.
727
716
  const complete = skippedLinks.length === 0;
728
- const found = buttonsWithoutAction({files: withButtons, scan, modulesNaming, loaded, complete}).map(each => ({
717
+ const found = buttonsWithoutAction({
718
+ files: withButtons,
719
+ scan,
720
+ modulesNaming,
721
+ loaded,
722
+ complete,
723
+ }).map(each => ({
729
724
  ...each,
730
725
  file: path.relative(projectDir, each.file).split(path.sep).join('/'),
731
726
  }));
732
- found.sort((a, b) => compareText(a.file, b.file) || a.line - b.line || a.column - b.column);
727
+ found.sort(
728
+ (a, b) =>
729
+ compareText(a.file, b.file) || a.line - b.line || a.column - b.column,
730
+ );
733
731
  return {found, files: files.length, incomplete: false};
734
732
  }
735
733
 
736
734
  /** The conditions a bundler reads a package.json `imports` key under. */
737
- const BUNDLER_CONDITIONS = ['types', 'import', 'module', 'browser', 'require', 'node'];
735
+ const BUNDLER_CONDITIONS = [
736
+ 'types',
737
+ 'import',
738
+ 'module',
739
+ 'browser',
740
+ 'require',
741
+ 'node',
742
+ ];
738
743
 
739
744
  /**
740
745
  * The module of the app's own code that a path alias or a package.json
@@ -748,8 +753,12 @@ const BUNDLER_CONDITIONS = ['types', 'import', 'module', 'browser', 'require', '
748
753
  function ownImportTarget(specifier, file) {
749
754
  if (specifier.startsWith('#')) {
750
755
  const root = findPackageRoot(path.dirname(file));
751
- const imports = root ? readPackageJson(path.join(root, 'package.json'))?.imports : null;
752
- const target = root ? packageImportTarget(imports, specifier, BUNDLER_CONDITIONS) : null;
756
+ const imports = root
757
+ ? readPackageJson(path.join(root, 'package.json'))?.imports
758
+ : null;
759
+ const target = root
760
+ ? packageImportTarget(imports, specifier, BUNDLER_CONDITIONS)
761
+ : null;
753
762
  if (!root || !target?.startsWith('./')) return null;
754
763
  return existingFile(path.join(root, target)) ?? path.join(root, target);
755
764
  }
@@ -766,188 +775,47 @@ function ownImportTarget(specifier, file) {
766
775
  function declaredPackages(projectDir, {ownName = false} = {}) {
767
776
  const pkg = readPackageJson(path.join(projectDir, 'package.json')) ?? {};
768
777
  return new Set(
769
- ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
778
+ [
779
+ 'dependencies',
780
+ 'devDependencies',
781
+ 'peerDependencies',
782
+ 'optionalDependencies',
783
+ ]
770
784
  .flatMap(field => Object.keys(pkg[field] ?? {}))
771
785
  .concat(ownName && typeof pkg.name === 'string' ? [pkg.name] : []),
772
786
  );
773
787
  }
774
788
 
775
- /**
776
- * A TypeScript module that may widen what JSX gives every component: one
777
- * that augments React or the global scope (where `JSX` lives), or that loads
778
- * a library's `css` prop types.
779
- */
780
- const JSX_DECLARATION = /\bdeclare\s+(?:module\s+['"]react(?:\/jsx-runtime)?['"]|global\b)|\bnamespace\s+JSX\b|styled-components\/cssprop|@emotion\/react\/types\/css-prop/;
781
-
782
- /**
783
- * A module that compiles its JSX with a runtime other than React's (a
784
- * `@jsxImportSource` or `@jsx` pragma), which can give every component props
785
- * of its own.
786
- */
787
- const OTHER_JSX_RUNTIME = /@jsxImportSource\s+(?!react(?:\s|\*|$))\S|@jsx\s+(?!React\.createElement\b)[A-Za-z_$]/m;
788
-
789
- /**
790
- * The JSX runtime other than React's that compiler options name: a
791
- * `jsxImportSource` other than `react`, or a `jsxFactory` other than
792
- * `React.createElement`. Null for React's.
793
- * @param {Record<string, unknown>} options
794
- * @returns {string | null}
795
- */
796
- function otherJsxRuntime(options) {
797
- const {jsxImportSource: source, jsxFactory: factory} = options;
798
- if (typeof source === 'string' && source !== 'react') return source;
799
- if (typeof factory === 'string' && factory !== 'React.createElement') return factory;
800
- return null;
801
- }
802
-
803
- /**
804
- * A build config, by file name, that can set how JSX compiles: Babel, SWC,
805
- * Vite, Vitest, esbuild, webpack, Rspack, Rsbuild, Next.js or tsup.
806
- */
807
- const BUILD_CONFIG =
808
- /^(?:\.babelrc(?:\.[cm]?js|\.json)?|babel\.config\.(?:[cm]?[jt]s|json)|\.swcrc|(?:vite|vitest|webpack|rspack|rsbuild|next|esbuild|tsup)\.config\.[cm]?[jt]s)$/;
809
-
810
- /**
811
- * A build setting that compiles JSX other than as React does: a runtime
812
- * (`jsxImportSource`, `importSource`) other than `react`; a classic factory
813
- * (`jsxFactory`, `pragma`, a name such as `jsx` or `h`) other than
814
- * `React.createElement`; or Next.js's `styledComponents` compiler option,
815
- * which compiles a `css` prop, when it is not `false`.
816
- */
817
- const BUILD_JSX_RUNTIME =
818
- /\b(?:jsxImportSource|importSource)['"]?\s*[:=]\s*['"](?!react['"])[^'"\s]+['"]|\b(?:jsxFactory|pragma)['"]?\s*[:=]\s*['"](?!React\.createElement['"])[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*['"]|\bstyledComponents['"]?\s*:(?!\s*false\b)/;
819
-
820
- /**
821
- * The packages that compile a `css` prop at build time, whatever name the
822
- * build config gives them (Babel reads `styled-components` as
823
- * `babel-plugin-styled-components`): a config can use one only when the
824
- * project depends on it, or when it is installed through another package
825
- * (`gatsby-plugin-emotion` brings emotion's preset).
826
- */
827
- const CSS_PROP_TRANSFORMS = new Set([
828
- '@emotion/babel-preset-css-prop',
829
- 'gatsby-plugin-emotion',
830
- 'babel-plugin-styled-components',
831
- '@swc/plugin-styled-components',
832
- '@compiled/babel-plugin',
833
- '@compiled/webpack-loader',
834
- '@compiled/vite-plugin',
835
- '@compiled/parcel-config',
836
- '@compiled/parcel-transformer',
837
- ]);
838
-
839
- /**
840
- * What compiles the JSX of a page other than as React does, in the folder of
841
- * the page or a folder above it, up to the project's workspace root (as
842
- * `findWorkspaceRoot` reads it): a build config
843
- * that sets another runtime or factory (a config file, or the `babel` key of
844
- * a `package.json`), a `package.json` that depends on a transform that
845
- * compiles a `css` prop, or such a transform installed where the project
846
- * finds packages. Null when nothing does.
847
- * @param {string[]} pages
848
- * @param {string} projectDir
849
- * @returns {{file: string, transform: string | null, installed?: boolean} | null}
850
- * the config, and the transform it depends on or has installed
851
- */
852
- function buildJsxRuntime(pages, projectDir) {
853
- const top = findWorkspaceRoot(projectDir);
854
- /** @type {Map<string, {file: string, transform: string | null, installed?: boolean} | null>} */
855
- const configIn = new Map();
856
- const read = (/** @type {string} */ dir) => {
857
- /** @type {string[]} */
858
- let names;
859
- try {
860
- names = fs.readdirSync(dir).sort();
861
- } catch {
862
- return null;
863
- }
864
- for (const name of names) {
865
- const file = path.join(dir, name);
866
- /** @type {string | null} */
867
- let text = null;
868
- try {
869
- if (BUILD_CONFIG.test(name)) text = readTextFile(file);
870
- else if (name === 'package.json') {
871
- const manifest = JSON.parse(readTextFile(file));
872
- for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
873
- const transform = Object.keys(manifest?.[field] ?? {}).find(dependency => CSS_PROP_TRANSFORMS.has(dependency));
874
- if (transform) return {file, transform};
875
- }
876
- text = manifest?.babel == null ? null : JSON.stringify(manifest.babel);
877
- }
878
- } catch {
879
- continue;
880
- }
881
- if (text != null && BUILD_JSX_RUNTIME.test(text)) return {file, transform: null};
882
- }
883
- return null;
884
- };
885
- for (const page of pages) {
886
- for (let dir = path.dirname(page); ; dir = path.dirname(dir)) {
887
- if (!configIn.has(dir)) configIn.set(dir, read(dir));
888
- const found = configIn.get(dir);
889
- if (found) return found;
890
- if (dir === top || path.relative(top, dir).startsWith('..') || dir === path.dirname(dir)) break;
891
- }
892
- }
893
- // A transform installed where a page finds packages: the project's own
894
- // folders, or a workspace member's.
895
- const pageDirs = [...new Set([projectDir, ...pages.map(page => path.dirname(page))])];
896
- for (const transform of [...CSS_PROP_TRANSFORMS].sort()) {
897
- for (const dir of pageDirs) {
898
- const installed = findInstalledPackage(dir, transform, Infinity);
899
- if (installed) return {file: installed, transform, installed: true};
900
- }
901
- }
902
- return null;
903
- }
904
-
905
- /**
906
- * @typedef {object} UnknownCoreProp
907
- * @property {string} file relative to the project, with `/`
908
- * @property {number} line
909
- * @property {number} column
910
- * @property {string} component
911
- * @property {string} prop
912
- * @property {string | null} suggestion a documented prop with the same
913
- * words, when there is one
914
- */
915
-
916
789
  /**
917
790
  * The props the project's own source gives Core components that the
918
- * component does not take. A prop is a candidate when Core's docs for the
919
- * component (the props `astryx component <Name> --package @astryxdesign/core`
920
- * lists) leave it out, and it is reported only when the project's TypeScript,
921
- * reading Core's own published types as the project's pages see them, says
922
- * the component's props do not take it either; the project's own modules
923
- * that widen React's JSX are read with Core's types. A prop name React's types
924
- * give an HTML or SVG element is never reported, since a component may pass
925
- * it on to the element it renders, and neither is a prop JSX gives every
926
- * component. A component with no docs, one TypeScript cannot read, a generic
927
- * one, and a module that compiles its JSX with another runtime are not
928
- * judged. Test, story and fixture files are not read. Each page is judged
929
- * with the config TypeScript reads for it. `skipped` says why nothing was
930
- * checked: no TypeScript, a config that compiles JSX with another runtime, or
931
- * more source files than doctor reads, whatever the pages hold; or, for a
932
- * prop the docs leave out, types or augmentations it could not read.
791
+ * component does not take, judged by `judgeCoreProps`. Test, story and
792
+ * fixture files are not read, and neither is a module that compiles its JSX
793
+ * with another runtime (a pragma). `skipped` says why nothing was checked:
794
+ * no TypeScript, more source files than doctor reads, pages that find no
795
+ * installed Core, or a config or build on another JSX runtime, whatever the
796
+ * pages hold; or, for a prop the docs leave out, the reason `judgeCoreProps`
797
+ * gives.
933
798
  * @param {string} projectDir
934
- * @returns {Promise<{found: UnknownCoreProp[], uses: number, skipped: string | null}>}
799
+ * @returns {Promise<{found: import('../../foundation/discovery/unknown-core-props.mjs').UnknownCoreProp[], uses: number, skipped: string | null}>}
935
800
  */
936
801
  export async function findUnknownCoreProps(projectDir) {
937
- const notChecked = (/** @type {string} */ reason) => ({found: [], uses: 0, skipped: `${reason}, so the props were not checked.`});
802
+ const notChecked = (/** @type {string} */ reason) => ({
803
+ found: [],
804
+ uses: 0,
805
+ skipped: `${reason}, so the props were not checked.`,
806
+ });
938
807
  const files = listProjectSourceFiles(projectDir, '');
939
808
  // A declaration beyond the files doctor reads could add a prop to every
940
809
  // component.
941
- if (files.length >= SOURCE_FILE_LIMIT) return notChecked('the project has more source files than doctor reads');
942
- const compiler = resolveProjectTypeScript([projectDir]);
943
- if (compiler === null) {
944
- return {found: [], uses: 0, skipped: `TypeScript is not installed in this project, so the props were not checked. ${TYPESCRIPT_FIX}`};
945
- }
946
- if (compiler.ts === null) {
947
- return {found: [], uses: 0, skipped: unusableTypeScriptReason(compiler.version, 'the props were not checked')};
948
- }
949
- const relative = (/** @type {string} */ file) => path.relative(projectDir, file).split(path.sep).join('/');
950
- /** @type {Array<import('../../foundation/discovery/core-props.mjs').CorePropUse & {file: string, path: string}>} */
810
+ if (files.length >= SOURCE_FILE_LIMIT)
811
+ return notChecked('the project has more source files than doctor reads');
812
+ const compiler = projectTypeScript([projectDir]);
813
+ if (!('ts' in compiler))
814
+ return {found: [], uses: 0, skipped: compiler.skipped};
815
+ const {ts} = compiler;
816
+ const relative = (/** @type {string} */ file) =>
817
+ path.relative(projectDir, file).split(path.sep).join('/');
818
+ /** @type {import('../../foundation/discovery/unknown-core-props.mjs').PageCorePropUse[]} */
951
819
  const uses = [];
952
820
  /** @type {string[]} */
953
821
  const jsxDeclarations = [];
@@ -962,158 +830,39 @@ export async function findUnknownCoreProps(projectDir) {
962
830
  } catch {
963
831
  continue;
964
832
  }
965
- if (/\.[cm]?tsx?$/.test(file) && JSX_DECLARATION.test(text)) jsxDeclarations.push(file);
966
- if (notPageCode(relative(file)) || !text.includes('@astryxdesign/core')) continue;
833
+ if (widensJsx(file, text)) jsxDeclarations.push(file);
834
+ if (notPageCode(relative(file)) || !text.includes('@astryxdesign/core'))
835
+ continue;
967
836
  corePages.push(file);
968
837
  if (OTHER_JSX_RUNTIME.test(text)) continue;
969
838
  // The scanner loads only when a page imports Core.
970
- scanCoreProps ??= (await import('../../foundation/discovery/core-props.mjs')).scanCoreProps;
971
- for (const use of scanCoreProps(text) ?? []) uses.push({...use, file: relative(file), path: file});
972
- }
973
- // Each page that imports Core is read with the config TypeScript reads for
974
- // it; pages that share a config share one read.
975
- /** @type {Map<string, {file: string, options: Record<string, unknown>}>} */
976
- const configs = new Map();
977
- /** @type {Map<string, string>} */
978
- const configOf = new Map();
979
- for (const file of corePages) {
980
- const config = compilerOptionsFor(file) ?? {file: '', options: {}};
981
- configs.set(config.file, config);
982
- configOf.set(file, config.file);
983
- }
984
- // Each page is read as TypeScript reads it: with its config, and with Core
985
- // and React found from the page's own folder. Pages that share a config and
986
- // an installed Core share one read. A page whose config maps a Core module
987
- // path elsewhere (`paths`) reads another module, and a page that finds no
988
- // installed Core has no types to read; neither is judged.
989
- /** @type {Map<string, string | null>} */
990
- const coreFrom = new Map();
991
- const coreDirFrom = (/** @type {string} */ dir) => {
992
- if (!coreFrom.has(dir)) {
993
- const found = findInstalledPackage(dir, '@astryxdesign/core', Infinity);
994
- let real = found;
995
- try {
996
- real = found ? fs.realpathSync(found) : null;
997
- } catch {
998
- // A Core folder that does not resolve is read where it is found.
999
- }
1000
- coreFrom.set(dir, real);
1001
- }
1002
- return coreFrom.get(dir) ?? null;
1003
- };
1004
- // Pages that import Core and find no installed Core have no types to read.
1005
- if (corePages.length > 0 && corePages.every(page => !coreDirFrom(path.dirname(page)))) {
1006
- return notChecked('Core is not installed where the pages that import it can find it');
839
+ scanCoreProps ??= (
840
+ await import('../../foundation/discovery/core-props.mjs')
841
+ ).scanCoreProps;
842
+ for (const use of scanCoreProps(text) ?? [])
843
+ uses.push({...use, file: relative(file), path: file});
1007
844
  }
1008
- for (const {options} of configs.values()) {
1009
- const runtime = otherJsxRuntime(options);
1010
- if (runtime) return notChecked(`the project compiles JSX with \`${runtime}\`, which can give every component props of its own`);
1011
- }
1012
- const build = buildJsxRuntime(corePages, projectDir);
1013
- if (build?.transform) {
1014
- return notChecked(
1015
- `${build.installed ? `\`${build.transform}\` is installed` : `the project depends on \`${build.transform}\``}, which compiles a \`css\` prop that every component can take`,
1016
- );
1017
- }
1018
- if (build) {
1019
- return notChecked(
1020
- `the build config \`${relative(build.file)}\` sets another JSX runtime or compiles a \`css\` prop, which can give every component props of its own`,
1021
- );
1022
- }
1023
- /** @type {Map<string, {configFile: string, from: string, uses: typeof uses}>} */
1024
- const groups = new Map();
1025
- for (const use of uses) {
1026
- if (projectMapsImport(use.source, use.path)) continue;
1027
- const from = path.dirname(use.path);
1028
- const coreDir = coreDirFrom(from);
1029
- if (!coreDir) continue;
1030
- const configFile = configOf.get(use.path) ?? '';
1031
- const key = `${configFile}\0${coreDir}`;
1032
- const group = groups.get(key) ?? /** @type {any} */ (groups.set(key, {configFile, from, uses: []}).get(key));
1033
- group.uses.push(use);
1034
- }
1035
- /** @type {UnknownCoreProp[]} */
1036
- const found = [];
1037
- for (const group of groups.values()) {
1038
- const {COMPONENT_BATCH_SELECTOR_LIMIT, component: componentAnswer} = await import('../component/component.mjs');
1039
- // Batched reads of the props the docs of the group's Core list, as
1040
- // `astryx component <Name> --props` prints them; a component they do not
1041
- // describe is not judged.
1042
- /** @type {Map<string, string[]>} */
1043
- const documented = new Map();
1044
- const names = [...new Set(group.uses.map(use => use.component))];
1045
- for (let start = 0; start < names.length; start += COMPONENT_BATCH_SELECTOR_LIMIT) {
1046
- const batch = names.slice(start, start + COMPONENT_BATCH_SELECTOR_LIMIT);
1047
- const answer = /** @type {any} */ (await componentAnswer(batch, {cwd: group.from, package: '@astryxdesign/core', props: true}));
1048
- for (const read of answer?.data?.results ?? []) {
1049
- const props = read?.status === 'found' ? read.result?.data : null;
1050
- if (Array.isArray(props)) documented.set(read.selector, props.map((/** @type {any} */ prop) => prop?.name).filter(Boolean));
1051
- }
1052
- }
1053
- const candidates = group.uses.filter(use => {
1054
- const props = documented.get(use.component);
1055
- return props != null && !props.includes(use.prop);
1056
- });
1057
- if (candidates.length === 0) continue;
1058
- const {readCorePropTypes} = await import('../../foundation/discovery/core-prop-types.mjs');
1059
- // What augments Core for a page: the project's files and installed
1060
- // packages, and those of the page's own package, as a workspace member
1061
- // installs its own.
1062
- const memberDir = findPackageRoot(group.from) ?? projectDir;
1063
- const reads = [projectAugmentations(projectDir, candidates[0].path)];
1064
- if (memberDir !== projectDir) reads.push(projectAugmentations(memberDir, candidates[0].path));
1065
- if (reads.some(read => !read.complete)) return notChecked("the files that may add to Core's types could not all be read");
1066
- const augmentations = {files: [...new Set(reads.flatMap(read => read.files))]};
1067
- /** @type {Map<string, Set<string>>} */
1068
- const asked = new Map();
1069
- /** @type {Map<string, string>} */
1070
- const sources = new Map();
1071
- for (const use of candidates) {
1072
- (asked.get(use.component) ?? asked.set(use.component, new Set()).get(use.component))?.add(use.prop);
1073
- if (!sources.has(use.component)) sources.set(use.component, use.source);
1074
- }
1075
- const types = readCorePropTypes({
1076
- ts: compiler.ts,
1077
- projectDir: group.from,
1078
- configDir: group.configFile ? path.dirname(group.configFile) : group.from,
1079
- options: configs.get(group.configFile)?.options ?? {},
1080
- augmentations: [...augmentations.files, ...jsxDeclarations],
1081
- props: asked,
1082
- sources,
1083
- configFile: group.configFile || undefined,
1084
- });
1085
- if (types.unread) return notChecked(types.unread);
1086
- for (const use of candidates) {
1087
- if (types.attributes.has(use.prop) || types.takes.get(use.component)?.get(use.prop) !== false) continue;
1088
- const {path: _file, source: _source, ...report} = use;
1089
- found.push({...report, suggestion: closestProp(use.prop, documented.get(use.component) ?? [])});
1090
- }
1091
- }
1092
- found.sort((a, b) => compareText(a.file, b.file) || a.line - b.line || a.column - b.column);
1093
- return {found, uses: uses.length, skipped: null};
1094
- }
1095
-
1096
- /**
1097
- * The documented prop a name means, when one has the same words: in another
1098
- * order or case, with a plural `s`, or with the `is` or `has` that Core puts
1099
- * in front of a yes-or-no prop (`isLabelHidden` for `labelHidden`,
1100
- * `startIcon` for `iconStart`). Words are read as a failed lookup reads them.
1101
- * A name with another word, or a near spelling, can mean something else
1102
- * (`padding` for `paddingX`, `maxWidth` for `minWidth`), so it is not
1103
- * offered. Null when no prop has the same words.
1104
- * @param {string} name
1105
- * @param {string[]} props
1106
- * @returns {string | null}
1107
- */
1108
- function closestProp(name, props) {
1109
- const key = (/** @type {string} */ text) =>
1110
- nameWords(text)
1111
- .filter(word => word !== 'is' && word !== 'has')
1112
- .map(word => (word.length > 3 ? word.replace(/s$/, '') : word))
1113
- .sort()
1114
- .join(' ');
1115
- const wanted = key(name);
1116
- return orderByAffinity(name, props, prop => [prop]).find(prop => prop !== name && key(prop) === wanted) ?? null;
845
+ const judged = await judgeCoreProps({
846
+ projectDir,
847
+ // Doctor says a project on another JSX runtime is not checked whatever
848
+ // its props are.
849
+ runtimeFirst: true,
850
+ uses,
851
+ pages: corePages,
852
+ readDocs: async (names, cwd) => {
853
+ const {COMPONENT_BATCH_SELECTOR_LIMIT, component: componentAnswer} =
854
+ await import('../component/component.mjs');
855
+ return readCoreDocs(
856
+ componentAnswer,
857
+ names,
858
+ cwd,
859
+ COMPONENT_BATCH_SELECTOR_LIMIT,
860
+ );
861
+ },
862
+ typescript: () => ({ts}),
863
+ jsxDeclarations: () => jsxDeclarations,
864
+ });
865
+ return {...judged, uses: judged.skipped ? 0 : uses.length};
1117
866
  }
1118
867
 
1119
868
  /**
@@ -1559,24 +1308,19 @@ export async function computerIntegrationsOutside(cwd) {
1559
1308
  }
1560
1309
  /** @type {Array<{name: string, __computer?: boolean, __loadError?: string}>} */
1561
1310
  const loaded = project.loadedIntegrations;
1562
- const used = loaded
1563
- .filter(i => i.__computer && !i.__loadError)
1564
- .map(i => i.name);
1311
+ const used = loaded.filter(doctorChecksOutside).map(i => i.name);
1565
1312
  // The everyday commands count these issues when they point at doctor, so
1566
- // doctor names them. Doctor reads no Core outside a project, so it leaves
1567
- // out the comparisons with Core components; the everyday commands judge
1568
- // those against the Core they carry. Core's templates come with the CLI.
1313
+ // doctor names them. Where doctor reads no Core, they name a comparison
1314
+ // with Core components themselves.
1569
1315
  const names = new Set(used);
1570
- const noCore = project.coreDir() == null;
1316
+ const doctorReadsCore = project.coreDir() != null;
1571
1317
  /** @type {Array<{package: string, severity: string, message: string}>} */
1572
1318
  let issues = [];
1573
1319
  try {
1574
1320
  issues = (await project.issues())
1575
1321
  .filter(
1576
1322
  issue =>
1577
- names.has(issue.package) &&
1578
- pointsToDoctor(issue) &&
1579
- !(noCore && CORE_COMPARISON_CODES.has(issue.code)),
1323
+ names.has(issue.package) && pointsToDoctor(issue, {doctorReadsCore}),
1580
1324
  )
1581
1325
  .map(issue => ({
1582
1326
  package: issue.package,
@@ -2024,7 +1768,6 @@ export async function fontPackagesInstallLine(projectDir, families) {
2024
1768
  };
2025
1769
  }
2026
1770
 
2027
-
2028
1771
  /**
2029
1772
  * What doctor reads about the project's skill places.
2030
1773
  * @typedef {object} SkillPlacesReport
@@ -2053,7 +1796,8 @@ export async function fontPackagesInstallLine(projectDir, families) {
2053
1796
  export async function readSkillPlaces(cwd) {
2054
1797
  const root = resolveAgentDocsRoot(cwd) ?? cwd;
2055
1798
  /** @param {string} file */
2056
- const shown = file => path.relative(cwd, file).split(path.sep).join('/') || '.';
1799
+ const shown = file =>
1800
+ path.relative(cwd, file).split(path.sep).join('/') || '.';
2057
1801
  /** @param {string} file */
2058
1802
  const read = file => {
2059
1803
  try {
@@ -2073,7 +1817,9 @@ export async function readSkillPlaces(cwd) {
2073
1817
  atHome = true;
2074
1818
  }
2075
1819
  const places = atHome ? [] : await readProjectPlaces(root);
2076
- const skillPlaces = places.filter(place => place.kind === 'skills' || place.kind === 'folder');
1820
+ const skillPlaces = places.filter(
1821
+ place => place.kind === 'skills' || place.kind === 'folder',
1822
+ );
2077
1823
  /** @type {SkillPlacesReport['files']} */
2078
1824
  const files = [];
2079
1825
  // A place linked out of the project is not the project's: init and
@@ -2095,18 +1841,32 @@ export async function readSkillPlaces(cwd) {
2095
1841
  const text = renderProjectSkill(await renderProjectAgentDocsBlock(root));
2096
1842
  const declared = await integrationSkillFiles(root);
2097
1843
  // A package that did not load is the integration checks' to report.
2098
- skillProblems.push(...declared.problems.filter(problem => !problem.unread));
1844
+ skillProblems.push(
1845
+ ...declared.problems.filter(problem => !problem.unread),
1846
+ );
2099
1847
  const keep = declared.keep;
2100
1848
  for (const place of inside) {
2101
1849
  for (const {file, state} of inspectSkillPlace(place, root, text)) {
2102
1850
  files.push({path: shown(file), place: savedName(place), state});
2103
1851
  }
2104
1852
  for (const each of declared.skills) {
2105
- for (const {file, state} of inspectSkillPlace(place, root, each.text, each.name)) {
2106
- files.push({path: shown(file), place: savedName(place), skill: each.name, state});
1853
+ for (const {file, state} of inspectSkillPlace(
1854
+ place,
1855
+ root,
1856
+ each.text,
1857
+ each.name,
1858
+ )) {
1859
+ files.push({
1860
+ path: shown(file),
1861
+ place: savedName(place),
1862
+ skill: each.name,
1863
+ state,
1864
+ });
2107
1865
  }
2108
1866
  }
2109
- for (const file of declared.complete ? leftoverIntegrationSkills(place, root, keep) : []) {
1867
+ for (const file of declared.complete
1868
+ ? leftoverIntegrationSkills(place, root, keep)
1869
+ : []) {
2110
1870
  leftovers.push(shown(file));
2111
1871
  }
2112
1872
  }
@@ -2118,7 +1878,11 @@ export async function readSkillPlaces(cwd) {
2118
1878
  // pointer line, so its problems are read either way.
2119
1879
  if (skillPlaces.length === 0) {
2120
1880
  try {
2121
- skillProblems.push(...(await integrationSkillFiles(root)).problems.filter(problem => !problem.unread));
1881
+ skillProblems.push(
1882
+ ...(await integrationSkillFiles(root)).problems.filter(
1883
+ problem => !problem.unread,
1884
+ ),
1885
+ );
2122
1886
  } catch {
2123
1887
  // Unreadable integrations are the integration checks' to report.
2124
1888
  }
@@ -2130,7 +1894,10 @@ export async function readSkillPlaces(cwd) {
2130
1894
  // out of the project (such as `.claude` linked to `~/.claude`) holds the
2131
1895
  // computer's skills, not the project's, so it is not read.
2132
1896
  const projectFolders = (atHome ? [] : PROJECT_SKILL_FOLDERS).filter(folder =>
2133
- resolvesInside(path.join(root, folder, PROJECT_SKILL_NAME, 'SKILL.md'), root),
1897
+ resolvesInside(
1898
+ path.join(root, folder, PROJECT_SKILL_NAME, 'SKILL.md'),
1899
+ root,
1900
+ ),
2134
1901
  );
2135
1902
  // The project skill copies in those folders.
2136
1903
  const skillsFolderFiles = projectFolders
@@ -2141,7 +1908,9 @@ export async function readSkillPlaces(cwd) {
2141
1908
  // the folder places saved in the project.
2142
1909
  const skillFiles = [
2143
1910
  ...new Set([
2144
- ...projectFolders.map(folder => path.join(root, folder, PROJECT_SKILL_NAME, 'SKILL.md')),
1911
+ ...projectFolders.map(folder =>
1912
+ path.join(root, folder, PROJECT_SKILL_NAME, 'SKILL.md'),
1913
+ ),
2145
1914
  ...inside
2146
1915
  .filter(place => place.kind === 'folder')
2147
1916
  .flatMap(place => placeSkillFiles(place, root)),
@@ -2149,7 +1918,8 @@ export async function readSkillPlaces(cwd) {
2149
1918
  ]
2150
1919
  .filter(file => read(file) != null)
2151
1920
  .map(shown);
2152
- const plainNamed = projectFolders.map(folder => path.join(root, folder, COMPUTER_SKILL_NAME))
1921
+ const plainNamed = projectFolders
1922
+ .map(folder => path.join(root, folder, COMPUTER_SKILL_NAME))
2153
1923
  .filter(dir => fs.existsSync(path.join(dir, 'SKILL.md')))
2154
1924
  .map(shown);
2155
1925
  return {