@astryxdesign/cli 0.7.17-canary.g248e91d → 0.7.17-canary.g286e4db

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 (67) hide show
  1. package/README.md +2 -2
  2. package/api/doctor/doctor.d.mts +17 -0
  3. package/api/doctor/doctor.mjs +47 -1
  4. package/api/render/_adapter.mjs +38 -12
  5. package/api/render/render.doc.mjs +1 -1
  6. package/api/search/ORDERING.md +1 -1
  7. package/api/search/_candidate-score.d.mts +3 -0
  8. package/api/search/_candidate-score.mjs +36 -3
  9. package/api/search/_named-keywords.d.mts +2 -1
  10. package/api/search/_named-keywords.mjs +48 -6
  11. package/api/theme/build/build.d.mts +3 -1
  12. package/api/theme/build/build.mjs +124 -8
  13. package/api/theme/build/family.mjs +4 -2
  14. package/api/theme/build/null-values.d.mts +14 -0
  15. package/api/theme/build/null-values.mjs +77 -14
  16. package/api/theme/build/setting-effects.d.mts +199 -0
  17. package/api/theme/build/setting-effects.mjs +957 -0
  18. package/api/theme/theme.type.d.mts +15 -0
  19. package/api/theme/theme.type.mjs +7 -2
  20. package/api/theme/themeBuild.doc.mjs +2 -2
  21. package/api/theme-edit/_css.d.mts +3 -16
  22. package/api/theme-edit/_css.mjs +8 -42
  23. package/api/theme-edit/_parts.mjs +25 -5
  24. package/api/theme-edit/_project.d.mts +4 -0
  25. package/api/theme-edit/_project.mjs +8 -1
  26. package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +1828 -62
  27. package/assets/component-list.generated.json +1 -1
  28. package/assets/docs-routes.generated.json +1 -1
  29. package/assets/docs.generated.json +2 -2
  30. package/assets/search-catalog.generated.json +2 -2
  31. package/assets/self-audit.generated.json +1 -1
  32. package/assets/templates/components.generated.json +1 -1
  33. package/assets/templates/pages/dashboard-progress/page.tsx +2 -2
  34. package/assets/templates/pages/dashboard-scorecard/page.tsx +4 -4
  35. package/authoring/debug/parse.d.mts +1 -1
  36. package/authoring/doctypes/_schema.d.mts +6 -6
  37. package/authoring/doctypes/base/type.ts +13 -0
  38. package/authoring/doctypes/component/component.doc.mjs +1 -1
  39. package/clients/cli/build-id.generated.json +1 -1
  40. package/clients/cli/manifest.generated.json +1 -1
  41. package/foundation/discovery/component-discovery.mjs +15 -28
  42. package/foundation/discovery/core-component-views.d.mts +15 -0
  43. package/foundation/discovery/core-component-views.mjs +176 -0
  44. package/foundation/discovery/hook-discovery.d.mts +2 -0
  45. package/foundation/discovery/hook-discovery.mjs +6 -5
  46. package/foundation/discovery/module-exports.mjs +15 -11
  47. package/foundation/discovery/stored-component-list.mjs +34 -2
  48. package/foundation/discovery/template-needs.d.mts +3 -1
  49. package/foundation/discovery/template-needs.mjs +4 -2
  50. package/foundation/discovery/theme-discovery.mjs +14 -6
  51. package/foundation/env/user-dirs.d.mts +14 -0
  52. package/foundation/env/user-dirs.mjs +34 -1
  53. package/foundation/fs/cache-eviction.d.mts +7 -5
  54. package/foundation/fs/cache-eviction.mjs +20 -13
  55. package/foundation/fs/gather-cache.d.mts +4 -3
  56. package/foundation/fs/gather-cache.mjs +35 -30
  57. package/foundation/fs/jiti-cache.d.mts +47 -26
  58. package/foundation/fs/jiti-cache.mjs +222 -130
  59. package/foundation/integrations/may-have-integrations.mjs +7 -6
  60. package/foundation/render/render-page.mjs +7 -2
  61. package/foundation/response/response-types.doc.mjs +2 -2
  62. package/foundation/runtime/css-tree.d.mts +16 -0
  63. package/foundation/runtime/css-tree.mjs +44 -2
  64. package/foundation/suggest/other-command.d.mts +12 -0
  65. package/foundation/suggest/other-command.mjs +48 -4
  66. package/foundation/text/string-utils.mjs +14 -41
  67. package/package.json +6 -6
package/README.md CHANGED
@@ -518,8 +518,8 @@ Every response has a `type` discriminant. The full set is below (generated from
518
518
  | `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. The envelope's package is the run's active base: @astryxdesign/core in a run on Core. |
519
519
  | `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
520
520
  | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |
521
- | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). A --family build whose root extends a theme the family does not select adds base {theme, package (the installed package it comes from, or null for a local base: a file of the project or a theme defined in the file of the root), export (the name the root imports it by, or null for a theme defined in the file of the root)}: a requirement of the outputs. |
522
- | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), the full list of checked paths, and, when any is stale or missing, code ERR_THEME_STALE. Writes nothing. |
521
+ | `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), notices (advisories about a correct theme, such as a named font it does not load), and settingIssues (the page-rule settings the browser does not show as written, also among the warnings; their fields are in the themeBuild doc). A --family build whose root extends a theme the family does not select adds base {theme, package (the installed package it comes from, or null for a local base: a file of the project or a theme defined in the file of the root), export (the name the root imports it by, or null for a theme defined in the file of the root)}: a requirement of the outputs. |
522
+ | `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), the full list of checked paths, when any is stale or missing, code ERR_THEME_STALE, and settingIssues as on the build receipt when any. Writes nothing. |
523
523
  | `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
524
524
  | `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, package (the package that provides it, or the local root), source, added, and default fields, plus owner (the package the app imports the built theme from, such as the bundled theme package @astryxdesign/theme-<slug>, or the local root) and installed (whether that owner is installed). Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |
525
525
  | `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |
@@ -389,6 +389,23 @@ export function checkComputerIntegrationsAvailable({ installed, candidates, inst
389
389
  * @returns {DoctorCheck | null}
390
390
  */
391
391
  export function checkGatherCache(): DoctorCheck | null;
392
+ /**
393
+ * The single folder where earlier CLIs left jiti's own copies of transpiled
394
+ * code, which this CLI never reads, and the command that removes it. Found by
395
+ * one stat, never a listing: that folder can hold so many files that reading
396
+ * it takes minutes.
397
+ * @param {import('../../foundation/env/user-dirs.mjs').UserDirOptions} [options]
398
+ * @returns {DoctorCheck | null}
399
+ */
400
+ export function checkOldTranspileCache(options?: import("../../foundation/env/user-dirs.mjs").UserDirOptions): DoctorCheck | null;
401
+ /**
402
+ * The command that removes a folder and all it holds: PowerShell's on
403
+ * Windows, a POSIX shell's elsewhere, the path quoted as each shell reads it.
404
+ * @param {string} dir
405
+ * @param {string} [platform]
406
+ * @returns {string}
407
+ */
408
+ export function removeFolderCommand(dir: string, platform?: string): string;
392
409
  /**
393
410
  * Run all diagnostic checks and return a structured report.
394
411
  *
@@ -27,6 +27,11 @@
27
27
  import * as fs from 'node:fs';
28
28
  import * as path from 'node:path';
29
29
  import {gatherCacheSummary} from '../../foundation/fs/gather-cache.mjs';
30
+ import {
31
+ oldTranspileCacheDir,
32
+ transpiledCacheDir,
33
+ } from '../../foundation/env/user-dirs.mjs';
34
+ import {SUBFOLDERS} from '../../foundation/fs/jiti-cache.mjs';
30
35
 
31
36
  import {
32
37
  MIN_NODE_VERSION,
@@ -52,6 +57,7 @@ import {
52
57
  formatCliCommand,
53
58
  getCliInvocation,
54
59
  guessCliInvocation,
60
+ quoteCommandArgument,
55
61
  } from '../../foundation/env/package-manager.mjs';
56
62
  import {
57
63
  chooseDeclaredCliCommand,
@@ -2833,10 +2839,49 @@ export function checkGatherCache() {
2833
2839
  id: 'gather-cache',
2834
2840
  label: 'Kept catalog cache',
2835
2841
  status: 'info',
2836
- message: `search, build, component, template, theme, discover, docs and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, the component list, integrations' theme records, what theme build checks a theme against in Core's component docs, the JavaScript theme build compiles from a theme's local TypeScript or JSX modules, what theme build finds when it checks a theme's pseudo-class keys and token names, the lookup commands' not-found hint's name summaries, npm's list of the files an integration package packs, the CLI's own docs tree, discover's record of the integrations a project loads and what each adds, and what it searches in its sources' saved copies, which search's discover line reads, and doctor's docs checks and theme-wiring scan) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, the installed CLI's own files judged by its build id and folder (an upgrade, a reinstall or a copy in another folder changes them; in-place edits aren't supported), and deleting the folder clears it. A lookup command's not-found path may also create the folder, for its name index, and so may an integration package's \`integration check\` of itself, for npm's list. On Linux, when a debug handler is set, runs also keep the locale and time zone here. The folder holds at most ${summary.limitBytes / (1024 * 1024)} MB, dropping oldest entries first, as does the transpile cache in ${summary.jitiDir}, which keeps every copy written, or read where the file system records reads, in the last day.`,
2842
+ message: `search, build, component, template, theme, discover, docs and doctor keep what they gather (search's catalogs, each integration's check results, template discovery's records, the component list and whether the installed Core still matches the stored one, Core's and integrations' components with the doc parts the component matcher scores, Core hooks' declared keywords, integrations' theme records, what theme build checks a theme against in Core's component docs, the JavaScript theme build compiles from a theme's local TypeScript or JSX modules, what theme build finds when it checks a theme's pseudo-class keys and token names, the lookup commands' not-found hint's name summaries, npm's list of the files an integration package packs, the CLI's own docs tree, discover's record of the integrations a project loads and what each adds, and what it searches in its sources' saved copies, which search's discover line reads, and doctor's docs checks and theme-wiring scan) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, the installed CLI's own files judged by its build id and folder (an upgrade, a reinstall or a copy in another folder changes them; in-place edits aren't supported), and deleting the folder clears it. A lookup command's not-found path may also create the folder, for its name index, and so may an integration package's \`integration check\` of itself, for npm's list. On Linux, when a debug handler is set, runs also keep the locale and time zone here. The folder holds at most ${summary.limitBytes / (1024 * 1024)} MB, dropping oldest entries first; the transpile cache in ${summary.transpiledDir} keeps its copies in ${SUBFOLDERS} subfolders, each holding at most 1/${SUBFOLDERS} of that, and drops the copies made longest ago first.`,
2843
+ };
2844
+ }
2845
+
2846
+ /**
2847
+ * The single folder where earlier CLIs left jiti's own copies of transpiled
2848
+ * code, which this CLI never reads, and the command that removes it. Found by
2849
+ * one stat, never a listing: that folder can hold so many files that reading
2850
+ * it takes minutes.
2851
+ * @param {import('../../foundation/env/user-dirs.mjs').UserDirOptions} [options]
2852
+ * @returns {DoctorCheck | null}
2853
+ */
2854
+ export function checkOldTranspileCache(options) {
2855
+ const dir = oldTranspileCacheDir(options);
2856
+ try {
2857
+ if (!fs.lstatSync(dir).isDirectory()) return null;
2858
+ } catch {
2859
+ return null;
2860
+ }
2861
+ const remove = removeFolderCommand(dir, options?.platform);
2862
+ return {
2863
+ id: 'old-transpile-cache',
2864
+ label: 'Old transpile cache',
2865
+ status: 'info',
2866
+ message: `An earlier Astryx CLI left transpiled copies in ${dir}. This CLI keeps its copies in ${transpiledCacheDir(options)} and never reads the old folder.`,
2867
+ fix: `To remove it, run: ${remove}. An earlier CLI that still runs on this computer makes it again.`,
2837
2868
  };
2838
2869
  }
2839
2870
 
2871
+ /**
2872
+ * The command that removes a folder and all it holds: PowerShell's on
2873
+ * Windows, a POSIX shell's elsewhere, the path quoted as each shell reads it.
2874
+ * @param {string} dir
2875
+ * @param {string} [platform]
2876
+ * @returns {string}
2877
+ */
2878
+ export function removeFolderCommand(dir, platform = process.platform) {
2879
+ const folder = quoteCommandArgument(dir, platform);
2880
+ return platform === 'win32'
2881
+ ? `Remove-Item -Recurse -Force -LiteralPath ${folder}`
2882
+ : `rm -rf ${folder}`;
2883
+ }
2884
+
2840
2885
  /**
2841
2886
  * Ordered list of synchronous check functions. Append here to add a check.
2842
2887
  * (checkConfig is async and is awaited separately by {@link runChecks}.)
@@ -2863,6 +2908,7 @@ export const SYNC_CHECKS = [
2863
2908
  checkCliCommand,
2864
2909
  checkInstallGuidance,
2865
2910
  checkGatherCache,
2911
+ () => checkOldTranspileCache(),
2866
2912
  ];
2867
2913
 
2868
2914
  /**
@@ -13,7 +13,6 @@ import * as path from 'node:path';
13
13
  import {freeRestoreFolder} from '../../foundation/render/restore-folder.mjs';
14
14
  import {randomUUID} from 'node:crypto';
15
15
  import {createRequire} from 'node:module';
16
- import {installStepFor} from '../../foundation/discovery/template-needs.mjs';
17
16
  import {installGuidanceFor} from '../../foundation/env/cli-command.mjs';
18
17
  import {AstryxError} from '../error.mjs';
19
18
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
@@ -53,6 +52,7 @@ import {runChoice} from '../../foundation/release/run-context.mjs';
53
52
  import {isAlive, pidSpace} from '../../foundation/release/cache.mjs';
54
53
  import {isServedPackage} from '../../foundation/render/served-packages.mjs';
55
54
  import {hostedRun, recordResolved, servingRootPackages} from '../../foundation/runtime/package-root.mjs';
55
+ import {installCommandFor} from '../../foundation/discovery/template-needs.mjs';
56
56
 
57
57
  export {PAGE_EXTENSIONS, embeddedPathProblem};
58
58
 
@@ -408,30 +408,56 @@ function writeRestore(writes, folder, cwd, overwrite) {
408
408
  return true;
409
409
  }
410
410
 
411
- /** @param {unknown} e @param {string} [cwd] the project the page belongs to */
412
- function asAstryxError(e, cwd = process.cwd()) {
411
+ /**
412
+ * @param {unknown} e
413
+ * @param {string} pageDir the folder of the page the render read
414
+ * @param {string} [cwd] the folder the render runs from
415
+ */
416
+ function asAstryxError(e, pageDir, cwd = process.cwd()) {
413
417
  if (e instanceof RenderError) {
414
418
  const code = /** @type {import('../../foundation/response/error-codes.mjs').ErrorCode} */ (e.code);
415
419
  /** @type {{name: string, reason: string}[]} */
416
420
  const suggestions = [];
421
+ let message = e.message;
417
422
  if (e.code === 'ERR_RENDER_MISSING_DEPENDENCY' && typeof e.detail?.package === 'string') {
418
- // The integration's install guidance first, then the install command
419
- // the render named in the project's package manager, else the
420
- // project's install step for every package it found.
423
+ // The run folder's integration line first, when the page is in the run
424
+ // folder's package; then the install command the render named; then
425
+ // one line for every package from the page's own package.
421
426
  const packages = Array.isArray(e.detail.packages) ? e.detail.packages : [e.detail.package];
422
- const guidance = installGuidanceFor(packages, cwd);
423
427
  const needs = `install ${packages.join(', ')}, which this render needs`;
428
+ const what = packages.length === 1 ? 'install the package the page imports' : 'install the packages the page imports';
429
+ const pageRoot = findPackageRoot(pageDir);
430
+ const runRoot = findPackageRoot(cwd);
431
+ const samePackage = pageRoot !== null && runRoot !== null && path.resolve(runRoot) === path.resolve(pageRoot);
432
+ const guidance = samePackage ? installGuidanceFor(packages, cwd) : undefined;
424
433
  if (guidance) {
425
434
  suggestions.push({name: guidance, reason: needs});
426
435
  } else if (typeof e.detail.install === 'string') {
427
436
  suggestions.push({name: e.detail.install, reason: needs});
437
+ } else if (pageRoot == null) {
438
+ // In a folder no package.json holds, an install would make the folder
439
+ // a project, so the message names the packages for the project that
440
+ // uses the page instead, as template and build do.
441
+ message = `${message}. Install ${packages.length === 1 ? 'it' : 'them'} in the project that uses this page.`;
428
442
  } else {
429
- const {line, note} = installStepFor(packages, cwd);
430
- const what = packages.length === 1 ? 'install the package the page imports' : 'install the packages the page imports';
431
- suggestions.push({name: line, reason: note ? `${what} (${note})` : what});
443
+ // With the CLI's version ranges, as template and build give it; none
444
+ // when the project's lockfiles disagree.
445
+ const step = installCommandFor(packages, pageDir, cwd);
446
+ const line = step.installGuidance ?? step.installCommand;
447
+ if (line && samePackage) {
448
+ suggestions.push({name: line, reason: what});
449
+ } else if (line) {
450
+ // Run from here, the line would add the packages to this folder's
451
+ // package.json, not to the page's, so the message names the page's
452
+ // package and the line to run there.
453
+ const where = path.relative(cwd, pageRoot) || '.';
454
+ message = `${message}. Install ${packages.length === 1 ? 'it' : 'them'} in ${where}, the package that holds this page: from there, run ${line}`;
455
+ } else if (step.noCommandReason) {
456
+ message = `${message}. ${step.noCommandReason}`;
457
+ }
432
458
  }
433
459
  }
434
- return new AstryxError(e.message, suggestions, code);
460
+ return new AstryxError(message, suggestions, code);
435
461
  }
436
462
  const err = /** @type {any} */ (e);
437
463
  if (typeof err?.code === 'string' && err.code.startsWith('ERR_RENDER_')) {
@@ -504,7 +530,7 @@ export async function renderToFile({cwd, input, output, title, absolute = false}
504
530
  throw e;
505
531
  }
506
532
  } catch (e) {
507
- throw asAstryxError(e, cwd);
533
+ throw asAstryxError(e, path.dirname(input), cwd);
508
534
  }
509
535
  for (const {name, dir} of page.fromSet) {
510
536
  let version = null;
@@ -97,7 +97,7 @@ export const doc = {
97
97
  {code: 'ERR_WRITE_FAILED', when: 'a file cannot be written, such as when `out` names a folder; with `reverse`, every file is written or none is'},
98
98
  {code: 'ERR_RENDER_COMPILE', when: 'the page does not compile, or a stylesheet it imports is not valid CSS (the message names the file)'},
99
99
  {code: 'ERR_RENDER_NO_DEFAULT_EXPORT', when: 'the page has no default export'},
100
- {code: 'ERR_RENDER_MISSING_DEPENDENCY', when: "the page imports a package that is not installed (the suggestion is the install line), or the esbuild the CLI depends on is missing from its install"},
100
+ {code: 'ERR_RENDER_MISSING_DEPENDENCY', when: "the page imports a package that is not installed (the suggestion is one install line for every such package, in the project's package manager and with the CLI's version ranges (such as `recharts@\"^3.10.1\"`), and none when the project's lockfiles disagree, which the message then says; for a page in another package than the folder the render runs from, the message names that package and the line to run there; in a folder that no package.json holds, the message says to install them in the project that uses the page, with no install line), or the esbuild the CLI depends on is missing from its install"},
101
101
  {code: 'ERR_RENDER_SCRIPT', when: "the page's script cannot be built for the browser: a module it loads needs Node (`fs`, `path`), or cannot be found or compiled for the browser; the message names the module"},
102
102
  {code: 'ERR_VERSIONS_UNAVAILABLE', when: 'outside a project, the page imports an Astryx package, React or StyleX, and the Core of the release that answers cannot be downloaded'},
103
103
  {code: 'ERR_RENDER_BROWSER_API', when: 'the page reads a browser-only API, such as window or document, while rendering'},
@@ -1,6 +1,6 @@
1
1
  # Search ordering data
2
2
 
3
- `astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one.
3
+ `astryx search` decides **what matches**, and each match's score and reason, with the lexical ranker (`_lexical.mjs` and the files it imports). The files in this folder only decide **the order of matches inside one score band**: they never add or drop a match, change a score, or move a match past one of another band or kind (doc or not). The bands are scores 195 and up, 188–194, 170–187, 160–169, 151–159, 100–150, 55–99, and under 55. A band can be wide (55–99 holds keyword matches beside one-word description hits), so inside a band a lower score can lead a higher one. In search's own reading of the catalog (`searchView` in `_named-keywords.mjs`), a doc that opens a level (a docs-tree namespace, holding the docs under its route as `_summarizes`) does not answer a query word through its text (its prose, or a code term or table cell its keywords gather) when a doc beneath it answers that word at least as strongly (`_candidate-score.mjs`); its name, title, description and declared keywords stay its own. `searchCore`, which build reads, keeps the gathered reading.
4
4
 
5
5
  ## Rule
6
6
 
@@ -21,6 +21,8 @@
21
21
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
22
22
  * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
23
23
  * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
24
+ * @param {any[]} [candidate._summarizes] - The docs beneath a doc that
25
+ * opens a level, in search's view only (_named-keywords.mjs).
24
26
  * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
25
27
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
26
28
  * `alias` marks a hit that read the query's words joined; `inText`, asked
@@ -40,6 +42,7 @@ export function scoreCandidate(term: string, candidate: {
40
42
  guidance?: string[] | undefined;
41
43
  _family?: string | undefined;
42
44
  _familyIndex?: number | undefined;
45
+ _summarizes?: any[] | undefined;
43
46
  }, { fuzzy, joins, part, synonym, mentions, }?: {
44
47
  fuzzy?: boolean;
45
48
  joins?: boolean;
@@ -236,6 +236,8 @@ function weakKeywordScore(t, kw) {
236
236
  * @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
237
237
  * @param {string} [candidate._family] - The family whose doc lists the entry as a member.
238
238
  * @param {number} [candidate._familyIndex] - The entry's place among that family's members.
239
+ * @param {any[]} [candidate._summarizes] - The docs beneath a doc that
240
+ * opens a level, in search's view only (_named-keywords.mjs).
239
241
  * @param {{fuzzy?: boolean, joins?: boolean, part?: boolean, synonym?: boolean, mentions?: boolean}} [opts] - `mentions`: also say whether the hit is only a mention (see `inText`); only the reading of a one-identifier query asks, so other searches pay nothing for it. `fuzzy`: allow edit-distance (typo) matches. Default true; multi-word queries pass false. `joins`: read a spaced query joined into a name or keyword (default true); off when the query names an entry outright. `part`: the term is one word of a longer query, so a name's head word after single letters (Stack in VStack) does not count as a keyword hit for it. `synonym`: the term stands in for a word of the query, so it names no family.
240
242
  * @returns {{score: number, reason: string, alias?: 'partial' | 'keyword', inText?: true} | null}
241
243
  * `alias` marks a hit that read the query's words joined; `inText`, asked
@@ -271,14 +273,37 @@ export function scoreCandidate(
271
273
  let alias = false;
272
274
  /** Whether the best hit is a mention in text, not a name or keyword. */
273
275
  let inText = false;
276
+ // A doc that opens a level (search's view, _named-keywords.mjs) sums up the
277
+ // docs beneath it: a term its text mentions that one of them answers at
278
+ // least as strongly is that doc's evidence, not this page's.
279
+ const summarized = candidate._summarizes;
280
+ /** @param {number} score */
281
+ const answeredBelow = score =>
282
+ summarized != null &&
283
+ summarized.some(
284
+ doc =>
285
+ (scoreCandidate(term, doc, {fuzzy, joins, part, synonym})?.score ??
286
+ 0) >= score,
287
+ );
274
288
  /**
275
289
  * @param {number} score
276
290
  * @param {string} why
277
291
  * @param {'partial' | 'keyword' | false} [byAlias] - the hit reads the
278
292
  * query's words joined, into part of a name or into a keyword
279
293
  * @param {boolean} [mention] - the hit is the term mentioned in text
294
+ * @param {boolean} [text] - the hit is the page's text (its prose, or a
295
+ * keyword that text gathers) rather than its name, title, description or
296
+ * declared keywords; a page that sums up the docs beneath it does not
297
+ * take it when one of them answers the term as strongly
280
298
  */
281
- const consider = (score, why, byAlias = false, mention = false) => {
299
+ const consider = (
300
+ score,
301
+ why,
302
+ byAlias = false,
303
+ mention = false,
304
+ text = false,
305
+ ) => {
306
+ if (text && score > best && answeredBelow(score)) return;
282
307
  if (score > best) {
283
308
  best = score;
284
309
  reason = why;
@@ -378,6 +403,9 @@ export function scoreCandidate(
378
403
 
379
404
  // ── Keyword signals ─────────────────────────────────────────────
380
405
  const termJoined = joined(term);
406
+ /** Whether a keyword is one the page's text gathers (see `consider`). */
407
+ const byText = (/** @type {string} */ lower) =>
408
+ summarized != null && mentionKeyword(candidate, lower);
381
409
  for (const {kw, text: kwText, lower: kwLower} of p.keywords) {
382
410
  // A one-word keyword typed as separate words is the keyword: `number
383
411
  // field` is `numberfield`. Only a
@@ -390,6 +418,7 @@ export function scoreCandidate(
390
418
  `keyword "${kw}"`,
391
419
  false,
392
420
  mentions && mentionKeyword(candidate, kwLower),
421
+ byText(kwLower),
393
422
  );
394
423
  continue;
395
424
  }
@@ -399,6 +428,7 @@ export function scoreCandidate(
399
428
  `keyword "${kw}"`,
400
429
  'keyword',
401
430
  mentions && mentionKeyword(candidate, kwLower),
431
+ byText(kwLower),
402
432
  );
403
433
  continue;
404
434
  }
@@ -408,6 +438,7 @@ export function scoreCandidate(
408
438
  `keyword "${kw}"`,
409
439
  false,
410
440
  mentions && mentionKeyword(candidate, kwLower),
441
+ byText(kwLower),
411
442
  );
412
443
  continue;
413
444
  }
@@ -417,6 +448,7 @@ export function scoreCandidate(
417
448
  `keyword "${kw}"`,
418
449
  false,
419
450
  mentions && mentionKeyword(candidate, kwLower),
451
+ byText(kwLower),
420
452
  );
421
453
  if (fuzzy) {
422
454
  const dist = typoDistance(term, kwLower);
@@ -426,6 +458,7 @@ export function scoreCandidate(
426
458
  `keyword "${kw}" (distance ${dist})`,
427
459
  false,
428
460
  mentions && mentionKeyword(candidate, kwLower),
461
+ byText(kwLower),
429
462
  );
430
463
  }
431
464
  }
@@ -457,7 +490,7 @@ export function scoreCandidate(
457
490
  let matchedProse = false;
458
491
  for (let i = 0; i < prose.length; i++) {
459
492
  if (prose[i] && re.test(loweredAt(p.prose, prose, i))) {
460
- consider(50, `docs mention "${term}"`, false, true);
493
+ consider(50, `docs mention "${term}"`, false, true, true);
461
494
  matchedProse = true;
462
495
  break;
463
496
  }
@@ -468,7 +501,7 @@ export function scoreCandidate(
468
501
  if (!matchedProse) {
469
502
  for (let i = 0; i < guidance.length; i++) {
470
503
  if (guidance[i] && re.test(loweredAt(p.guidance, guidance, i))) {
471
- consider(45, `guidance mentions "${term}"`, false, true);
504
+ consider(45, `guidance mentions "${term}"`, false, true, true);
472
505
  break;
473
506
  }
474
507
  }
@@ -14,7 +14,8 @@
14
14
  export function withoutOtherNames(all: import("./_lexical.mjs").Candidate[], named?: import("./_lexical.mjs").Candidate[]): import("./_lexical.mjs").Candidate[];
15
15
  /**
16
16
  * The gathered catalog as search reads it: its entries with
17
- * {@link withoutOtherNames} applied. Names come from the catalog and from
17
+ * {@link withoutOtherNames} applied, and each doc that opens a level read at
18
+ * its own grain ({@link withSummarized}). Names come from the catalog and from
18
19
  * `others`, further gathered catalogs (a search for one `type` passes the
19
20
  * other of components and hooks, so `type` never changes which keywords
20
21
  * count). A reused gather, with the same others, gets the same view back.
@@ -133,6 +133,45 @@ export function withoutOtherNames(all, named = all) {
133
133
  });
134
134
  }
135
135
 
136
+ /**
137
+ * The catalog's docs, each doc that opens a level (a docs-tree namespace such
138
+ * as `layout`) holding the docs beneath it (`_summarizes`: the pages under its
139
+ * route and their sections). Such a page sums up the docs below it: a word its
140
+ * text shares with one of them is that doc's evidence, which the reader opens
141
+ * at its own grain, so the page does not answer it through that text
142
+ * (`scoreCandidate`, _candidate-score.mjs). Its name, title, description and
143
+ * declared keywords stay its own. Entries with nothing beneath them are
144
+ * returned as they are.
145
+ * @param {import('./_lexical.mjs').Candidate[]} all
146
+ * @returns {import('./_lexical.mjs').Candidate[]}
147
+ */
148
+ function withSummarized(all) {
149
+ /** @type {Map<string, import('./_lexical.mjs').Candidate[]>} */
150
+ const below = new Map();
151
+ for (const c of all) {
152
+ const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
153
+ if (typeof topic !== 'string') continue;
154
+ for (let at = topic.indexOf('/'); at > 0; at = topic.indexOf('/', at + 1)) {
155
+ const route = topic.slice(0, at);
156
+ const list = below.get(route);
157
+ if (list) list.push(c);
158
+ else below.set(route, [c]);
159
+ }
160
+ }
161
+ if (below.size === 0) return all;
162
+ return all.map(c => {
163
+ const topic = c.domain === 'doc' ? /** @type {any} */ (c)._topic : null;
164
+ const docs = typeof topic === 'string' ? below.get(topic) : undefined;
165
+ if (!docs) return c;
166
+ const view = Object.create(
167
+ Object.getPrototypeOf(c),
168
+ Object.getOwnPropertyDescriptors(c),
169
+ );
170
+ Object.defineProperty(view, '_summarizes', {value: docs});
171
+ return view;
172
+ });
173
+ }
174
+
136
175
  /**
137
176
  * Each gathered catalog's search views, one per set of naming catalogs.
138
177
  * @type {WeakMap<object, {others: object[], view: object}[]>}
@@ -141,7 +180,8 @@ const views = new WeakMap();
141
180
 
142
181
  /**
143
182
  * The gathered catalog as search reads it: its entries with
144
- * {@link withoutOtherNames} applied. Names come from the catalog and from
183
+ * {@link withoutOtherNames} applied, and each doc that opens a level read at
184
+ * its own grain ({@link withSummarized}). Names come from the catalog and from
145
185
  * `others`, further gathered catalogs (a search for one `type` passes the
146
186
  * other of components and hooks, so `type` never changes which keywords
147
187
  * count). A reused gather, with the same others, gets the same view back.
@@ -158,11 +198,13 @@ export function searchView(catalog, others = []) {
158
198
  v.others.every((o, i) => o === others[i]),
159
199
  );
160
200
  if (hit) return /** @type {T} */ (hit.view);
161
- const all = withoutOtherNames(
162
- catalog.all,
163
- others.length === 0
164
- ? catalog.all
165
- : [catalog.all, ...others.map(o => o.all)].flat(),
201
+ const all = withSummarized(
202
+ withoutOtherNames(
203
+ catalog.all,
204
+ others.length === 0
205
+ ? catalog.all
206
+ : [catalog.all, ...others.map(o => o.all)].flat(),
207
+ ),
166
208
  );
167
209
  const swap = new Map(catalog.all.map((c, i) => [c, all[i]]));
168
210
  const view = {
@@ -281,6 +281,7 @@ export function validateThemePrivateInputs(file: string, { cwd }?: {
281
281
  *
282
282
  * @param {{components?: Record<string, Record<string, unknown>>, onDark?: {components?: Record<string, Record<string, unknown>>}, onLight?: {components?: Record<string, Record<string, unknown>>}, __onDark?: {components?: Record<string, Record<string, unknown>>}, __onLight?: {components?: Record<string, Record<string, unknown>>}}} themeDef
283
283
  * @param {{propsByKey: Record<string, string[]>}} knownComponents
284
+ * @param {Set<string>} [deadKeys] takes each `<part>\u0000<style key>` the warnings say builds a selector nothing matches
284
285
  * @returns {string[]}
285
286
  */
286
287
  export function validateComponentOverridesAgainstRegistry(themeDef: {
@@ -299,7 +300,7 @@ export function validateComponentOverridesAgainstRegistry(themeDef: {
299
300
  };
300
301
  }, knownComponents: {
301
302
  propsByKey: Record<string, string[]>;
302
- }): string[];
303
+ }, deadKeys?: Set<string>): string[];
303
304
  /**
304
305
  * The refusal of an option given an empty or blank value, which names
305
306
  * nothing: what to give instead, and the command without it; null for any
@@ -421,6 +422,7 @@ export function themeBuildFamily(files: string[], options: {
421
422
  };
422
423
  warnings: any[];
423
424
  notices: string[];
425
+ settingIssues: any[];
424
426
  };
425
427
  }>;
426
428
  /** The first words of every file a build writes. */