@astryxdesign/cli 0.7.17-canary.g72f2d7c → 0.7.17-canary.g7f2e0e8

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 (147) hide show
  1. package/README.md +5 -5
  2. package/api/discover/_adapter.d.mts +13 -2
  3. package/api/discover/_adapter.mjs +38 -30
  4. package/api/discover/_catalog-view.d.mts +15 -0
  5. package/api/discover/_catalog-view.mjs +20 -0
  6. package/api/discover/_icon-set-coverage.d.mts +22 -0
  7. package/api/discover/_icon-set-coverage.mjs +32 -0
  8. package/api/discover/detail/detail.d.mts +3 -1
  9. package/api/discover/detail/detail.mjs +11 -4
  10. package/api/discover/detail/item/item.d.mts +11 -1
  11. package/api/discover/detail/item/item.mjs +29 -8
  12. package/api/discover/discover.d.mts +1 -0
  13. package/api/discover/discover.mjs +24 -7
  14. package/api/discover/discover.type.d.mts +23 -3
  15. package/api/discover/discover.type.mjs +14 -3
  16. package/api/discover/search/search.mjs +3 -0
  17. package/api/docs/_adapter.d.mts +2 -1
  18. package/api/docs/_adapter.mjs +9 -2
  19. package/api/doctor/_adapter.d.mts +11 -0
  20. package/api/doctor/_adapter.mjs +29 -0
  21. package/api/doctor/doctor.d.mts +8 -0
  22. package/api/doctor/doctor.mjs +42 -0
  23. package/api/error.d.mts +12 -1
  24. package/api/error.mjs +18 -6
  25. package/api/icon/_adapter.d.mts +1 -1
  26. package/api/icon/_adapter.mjs +4 -1
  27. package/api/icon/_authoring.mjs +6 -3
  28. package/api/icon/list/list.mjs +2 -4
  29. package/api/init/_adapter.d.mts +69 -0
  30. package/api/init/_adapter.mjs +262 -13
  31. package/api/init/init.doc.mjs +16 -3
  32. package/api/init/init.mjs +66 -4
  33. package/api/init/init.type.d.mts +39 -2
  34. package/api/init/init.type.mjs +18 -2
  35. package/api/init/run/run.d.mts +34 -2
  36. package/api/init/run/run.mjs +341 -32
  37. package/api/render/_adapter.mjs +1 -1
  38. package/api/search/ORDERING.md +1 -1
  39. package/api/search/_lexical.mjs +131 -7
  40. package/api/search/_order.mjs +7 -3
  41. package/api/search/_result.d.mts +7 -0
  42. package/api/search/_result.mjs +8 -0
  43. package/api/search/_titles.d.mts +14 -0
  44. package/api/search/_titles.mjs +16 -3
  45. package/api/template/_adapter.d.mts +20 -0
  46. package/api/template/_adapter.mjs +86 -2
  47. package/api/template/copy/copy.d.mts +8 -2
  48. package/api/template/copy/copy.mjs +6 -1
  49. package/api/template/show/show.d.mts +9 -3
  50. package/api/template/show/show.mjs +13 -3
  51. package/api/template/template.doc.mjs +2 -2
  52. package/api/template/template.mjs +20 -4
  53. package/api/template/template.type.d.mts +2 -0
  54. package/api/template/template.type.mjs +3 -1
  55. package/api/theme/_adapter.mjs +31 -8
  56. package/api/theme/_shared-source.mjs +3 -1
  57. package/api/theme/build/build.mjs +35 -79
  58. package/api/theme/build/null-values.d.mts +11 -3
  59. package/api/theme/build/null-values.mjs +49 -23
  60. package/api/theme/build/theme-object.d.mts +47 -0
  61. package/api/theme/build/theme-object.mjs +144 -0
  62. package/api/theme/theme.type.d.mts +9 -2
  63. package/api/theme/theme.type.mjs +8 -3
  64. package/assets/component-list.generated.json +1 -1
  65. package/assets/docs/tree/export-pages.doc.mjs +1 -1
  66. package/assets/docs/tree/icon-sets.doc.mjs +3 -3
  67. package/assets/docs-routes.generated.json +1 -1
  68. package/assets/docs.generated.json +2 -2
  69. package/assets/search-catalog.generated.json +2 -2
  70. package/assets/self-audit.generated.json +1 -1
  71. package/assets/templates/blocks/components/Step/StepContent.tsx +1 -1
  72. package/assets/templates/blocks/components/Step/StepShowcase.tsx +1 -1
  73. package/assets/templates/blocks/components/Stepper/StepperCustomContent.tsx +18 -14
  74. package/assets/templates/blocks/components/Stepper/StepperOnTrackHorizontal.tsx +1 -1
  75. package/assets/templates/blocks/components/Table/TableInCard.tsx +1 -1
  76. package/assets/templates/blocks/components/Table/TableShowcase.tsx +1 -1
  77. package/assets/templates/blocks/components/Toolbar/ToolbarCardHeader.tsx +2 -1
  78. package/assets/templates/blocks/components/Toolbar/ToolbarSizes.tsx +1 -1
  79. package/assets/templates/blocks/components/Toolbar/ToolbarThreeSlot.tsx +2 -1
  80. package/assets/templates/blocks/components/TopNav/TopNavShowcase.tsx +1 -1
  81. package/assets/templates/blocks/components/TopNavItem/TopNavItemShowcase.tsx +1 -1
  82. package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuBasic.tsx +1 -1
  83. package/assets/templates/blocks/components/TopNavMegaMenu/TopNavMegaMenuShowcase.tsx +1 -1
  84. package/assets/templates/blocks/components/TopNavMenu/TopNavMenuBasic.tsx +1 -1
  85. package/assets/templates/blocks/components/TopNavMenu/TopNavMenuShowcase.tsx +1 -1
  86. package/assets/templates/components.generated.json +1 -1
  87. package/assets/templates/pages/shell-nav/page.tsx +27 -15
  88. package/authoring/config/config.doc.mjs +7 -0
  89. package/authoring/config/parse.mjs +15 -0
  90. package/authoring/config/skill-places.d.mts +23 -0
  91. package/authoring/config/skill-places.mjs +35 -0
  92. package/authoring/config/type.ts +15 -0
  93. package/authoring/discover/parse.d.mts +2 -1
  94. package/authoring/discover/parse.mjs +24 -3
  95. package/authoring/discover/type.ts +9 -2
  96. package/clients/cli/build-id.generated.json +1 -1
  97. package/clients/cli/commands/discover.mjs +86 -6
  98. package/clients/cli/commands/docs.mjs +22 -16
  99. package/clients/cli/commands/experimental/icon.mjs +2 -1
  100. package/clients/cli/commands/experimental-export.doc.mjs +1 -1
  101. package/clients/cli/commands/experimental.doc.mjs +1 -1
  102. package/clients/cli/commands/init.doc.mjs +13 -3
  103. package/clients/cli/commands/template.mjs +18 -0
  104. package/clients/cli/commands/theme-add.doc.mjs +1 -1
  105. package/clients/cli/commands/theme.mjs +2 -2
  106. package/clients/cli/lib/unknown-command.mjs +1 -1
  107. package/clients/cli/manifest.generated.json +1 -1
  108. package/foundation/agent-docs/agent-doc-state.d.mts +20 -2
  109. package/foundation/agent-docs/agent-doc-state.mjs +69 -2
  110. package/foundation/agent-docs/computer-agent-text.d.mts +5 -14
  111. package/foundation/agent-docs/computer-agent-text.mjs +60 -155
  112. package/foundation/agent-docs/managed-skill-file.d.mts +103 -0
  113. package/foundation/agent-docs/managed-skill-file.mjs +193 -0
  114. package/foundation/agent-docs/skill-place-files.d.mts +12 -0
  115. package/foundation/agent-docs/skill-place-files.mjs +38 -0
  116. package/foundation/agent-docs/skill-places.d.mts +115 -0
  117. package/foundation/agent-docs/skill-places.mjs +322 -0
  118. package/foundation/config/config-path.d.mts +2 -2
  119. package/foundation/config/config-path.mjs +5 -6
  120. package/foundation/config/config-writer.d.mts +5 -1
  121. package/foundation/config/config-writer.mjs +20 -4
  122. package/foundation/discovery/icon-definition-discovery.d.mts +11 -0
  123. package/foundation/discovery/icon-definition-discovery.mjs +16 -0
  124. package/foundation/discovery/icon-ranking.d.mts +76 -0
  125. package/foundation/discovery/icon-ranking.mjs +160 -56
  126. package/foundation/discovery/template-adapter.d.mts +23 -0
  127. package/foundation/discovery/template-adapter.mjs +84 -0
  128. package/foundation/doc-compiler/read.d.mts +1 -1
  129. package/foundation/env/user-settings.d.mts +15 -0
  130. package/foundation/env/user-settings.mjs +56 -2
  131. package/foundation/fs/gather-cache.mjs +75 -11
  132. package/foundation/release/agent-text-worker.mjs +32 -1
  133. package/foundation/release/choose.d.mts +2 -1
  134. package/foundation/release/choose.mjs +24 -3
  135. package/foundation/release/global-state.mjs +10 -2
  136. package/foundation/render/embedded-imports.d.mts +6 -4
  137. package/foundation/render/embedded-imports.mjs +47 -8
  138. package/foundation/render/render-page.d.mts +1 -1
  139. package/foundation/render/render-page.mjs +97 -23
  140. package/foundation/render/source-block.d.mts +4 -0
  141. package/foundation/render/source-block.mjs +2 -0
  142. package/foundation/response/response-types.doc.mjs +5 -5
  143. package/foundation/text/definition-coverage.d.mts +21 -0
  144. package/foundation/text/definition-coverage.mjs +20 -0
  145. package/foundation/text/suggest-order.d.mts +10 -4
  146. package/foundation/text/suggest-order.mjs +20 -13
  147. package/package.json +6 -6
package/README.md CHANGED
@@ -510,11 +510,11 @@ Every response has a `type` discriminant. The full set is below (generated from
510
510
  | `swizzle.copy` | An eject receipt: component name, owning package, output directory, files-copied count, the copied file names (relative to the component folder; owner modules copied beside it start with ../), whether any file uses StyleX, and, when the owner has an issues URL, feedback ({issuesUrl, ghCommand?}): where to report the gap that led to swizzling. The envelope's package names the same owning package. |
511
511
  | `gap-report.categories` | The fixed gap category values and human-readable labels; when a loaded integration names its own issues URL, meta.destinations lists every destination ({to, default, issuesUrl}) and meta.ask tells an agent to ask the person. |
512
512
  | `gap-report.file` | An aggregate receipt: overall status, the selected package, issuesUrl (or null), deliveries in handler order, each {handlerType: project \| integration \| fallback, handler, audience, status, url, message}, and filedCount/routedOnlyCount totals; without --to, when a loaded integration names its own issues URL, destinations and ask as on gap-report.categories. |
513
- | `template.list` | The effective discovered TemplateListEntry[] for pages and blocks. A winning replacement entry includes optional `replaces`, naming the Core id omitted from the default list. |
514
- | `template.show` | The resolved template's source, exactly as a copy writes it, plus its description, kind, the component names it composes, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media), and demoContentReplaced (how many Astryx docs-only demo content elements were replaced with a Text placeholder for your own content), and isReady (false when the template's doc sets isReady: false). |
515
- | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description, the components it composes, and isReady. The envelope's package names the npm package that owns the template. |
516
- | `template.copy` | A scaffold receipt: template id, output directory (relative to the project; absolute for a scratch copy in the system temp folder), written file name, file count, givenPath (optional; the absolute path as given, present only when it was inside the project), demoMediaReplaced (how many Astryx demo media references were replaced with placeholders), demoContentReplaced (how many Astryx docs-only demo content elements were replaced with a Text placeholder), notes (setup notes naming what the template needs that the project lacks — missing packages, missing StyleX compiler; empty when satisfied), missingPackages (external package names the template imports that are not in the project), and installCommand (a ready-to-run install command with the detected package manager and workspace version ranges; null when nothing is missing, when several lockfiles leave the package manager undetermined, or when no package.json holds the folder, where an install would make the folder a project), installGuidance (only when a loaded integration gives one: how this project adds the missing packages, followed in place of installCommand), and isReady. The envelope's package names the npm package that owns the template. |
517
- | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
513
+ | `template.list` | The effective TemplateListEntry[] for pages and blocks; a replacement carries `replaces`, the Core id it hides from the default list. |
514
+ | `template.show` | The template's source, as a copy writes it, with its description, kind, components (a sorted summary, without common ones such as Text), componentsToRead (what it renders, in the form `astryx component` takes, in first-use order), demoMediaReplaced and demoContentReplaced (demo media and content replaced with placeholders), and isReady (false when its doc says so). |
515
+ | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) with the template's description, components, and isReady. |
516
+ | `template.copy` | A scaffold receipt: template id, outputDir (absolute for a scratch copy), fileName, filesCopied, givenPath (the absolute path given, only when inside the project), demoMediaReplaced, demoContentReplaced, notes (what the project lacks, such as missing packages or a StyleX compiler; empty when nothing), missingPackages, installCommand (null when nothing is missing, the package manager is undetermined, or no package.json holds the folder), installGuidance (how an integration adds them, used instead of installCommand), components (what it renders, in the form `astryx component` takes, in first-use order), and isReady. |
517
+ | `template.cdn` | A write receipt for the no-build CDN starter page: path (relative to cwd), the Astryx version its CDN URLs pin, written, and reason (`exists`, a success, when a file was already there). |
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. |
@@ -148,13 +148,13 @@ export function callSources(project: Project | undefined, request?: {
148
148
  official?: OfficialList;
149
149
  }): Promise<CatalogResult>;
150
150
  /**
151
- * The item kinds discover reads in the project at the working directory, or
151
+ * The item kinds `--type` takes in the project at the working directory, or
152
152
  * the stable kinds when it cannot be read.
153
153
  * @returns {Promise<readonly string[]>}
154
154
  */
155
155
  export function loadReadKinds(): Promise<readonly string[]>;
156
156
  /**
157
- * The item kinds discover reads in this project: every stable kind, and the
157
+ * The item kinds `--type` takes in this project: every stable kind, and the
158
158
  * experimental ones where icon features are on.
159
159
  * @param {Project | undefined} project
160
160
  * @returns {readonly string[]}
@@ -265,6 +265,17 @@ export function loadValidatedDoc(result: ComponentResolution, { lang, zh }: {
265
265
  * @returns {Promise<AstryxError>}
266
266
  */
267
267
  export function withCoreMatch(err: AstryxError, query: string, cwd: string): Promise<AstryxError>;
268
+ /**
269
+ * How many of the icon definitions this CLI ships a set's definitions cover,
270
+ * of how many: the coverage `experimental icon --list` reports as
271
+ * `coverage.astryx`.
272
+ * @param {string[]} definitions
273
+ * @returns {{mapped: number, total: number}}
274
+ */
275
+ export function iconSetCoverage(definitions: string[]): {
276
+ mapped: number;
277
+ total: number;
278
+ };
268
279
  /** The name the official list goes by, as a source and on each of its entries. */
269
280
  export const OFFICIAL_SOURCE_NAME: "Astryx";
270
281
  /** The official list, generated from the repository when the CLI is built. */
@@ -38,6 +38,7 @@ import {
38
38
  projectTree,
39
39
  } from '../docs/_adapter.mjs';
40
40
  import {discoverIntegrationIconSets} from '../../foundation/discovery/icon-set-discovery.mjs';
41
+ import {astryxDefinitionCoverage} from '../../foundation/discovery/icon-definition-discovery.mjs';
41
42
  import {iconFeatureGate} from '../../foundation/integrations/icon-features.mjs';
42
43
  import {isValidSemver, semverCompare} from '../../foundation/env/semver.mjs';
43
44
  import {assertWithin} from '../../foundation/fs/path-safety.mjs';
@@ -691,6 +692,24 @@ function savedCopyPath(cacheDir, from, request) {
691
692
  return assertWithin(`${key}.json`, dir, {label: 'discover saved copy'});
692
693
  }
693
694
 
695
+ /**
696
+ * A source's catalog with its icon sets, which discover lists in every
697
+ * project (spec:AST-084 FR17). With icon features off, a malformed icon-set
698
+ * item never fails a source: the catalog is then read as a CLI without icon
699
+ * sets reads it, with the kind and its fields unknown (spec:AST-051 FR7).
700
+ * @param {unknown} value
701
+ * @param {string} label
702
+ * @param {boolean} iconSets icon features are on in the project
703
+ */
704
+ function parseCatalog(value, label, iconSets) {
705
+ if (iconSets) return parseDiscoverCatalog(value, label, {iconSets: true});
706
+ try {
707
+ return parseDiscoverCatalog(value, label, {iconSets: true});
708
+ } catch {
709
+ return parseDiscoverCatalog(value, label);
710
+ }
711
+ }
712
+
694
713
  /**
695
714
  * @param {string} file
696
715
  * @param {string} label
@@ -701,7 +720,7 @@ function readSavedCopy(file, label, iconSets) {
701
720
  const saved = JSON.parse(fs.readFileSync(file, 'utf8'));
702
721
  return {
703
722
  savedAt: String(saved.savedAt),
704
- catalog: parseDiscoverCatalog(saved.catalog, label, {iconSets}),
723
+ catalog: parseCatalog(saved.catalog, label, iconSets),
705
724
  };
706
725
  } catch {
707
726
  return null;
@@ -752,7 +771,7 @@ async function callSource(source, request, label, timeoutMs, iconSets) {
752
771
  ),
753
772
  timedOut,
754
773
  ]);
755
- return parseDiscoverCatalog(answer, label, {iconSets});
774
+ return parseCatalog(answer, label, iconSets);
756
775
  } finally {
757
776
  clearTimeout(timer);
758
777
  }
@@ -850,10 +869,7 @@ export function savedCatalog(
850
869
  }
851
870
  }
852
871
  if (!saved) return null;
853
- return withoutUnreadKinds(project, [
854
- ...packages,
855
- ...officialNotCovered(packages, official),
856
- ]);
872
+ return [...packages, ...officialNotCovered(packages, official)];
857
873
  }
858
874
 
859
875
  /**
@@ -912,8 +928,6 @@ async function callOwnSources(project, request = {}, options = {}) {
912
928
  const result = {sources: [], packages: []};
913
929
  const fromDoor = doorSources();
914
930
  if (project == null && fromDoor.length === 0) return result;
915
- // With icon features off, icon-set items and fields are unknown before the
916
- // catalog is checked, so one cannot fail a source (spec:AST-051 FR7).
917
931
  const iconSets = optedIntoIconSets(project);
918
932
 
919
933
  const origins = sourceOrigins(project);
@@ -1019,11 +1033,9 @@ export async function callSources(project, request = {}, options = {}) {
1019
1033
  ],
1020
1034
  // Source order: the first entry per integration is the one discover
1021
1035
  // keeps. Official packages are put first only where discover shows them.
1022
- // An experimental kind is a kind this project does not read unless that
1023
- // kind is on here (for icon sets: an installed icon-set package or
1024
- // `experimental.iconSet`), so its items are ignored like any unknown kind
1025
- // (FR7).
1026
- packages: withoutUnreadKinds(project, [...own.packages, ...added]),
1036
+ // Icon sets a project could add are listed in every project, so an app
1037
+ // can compare them before it picks one (spec:AST-084 FR17).
1038
+ packages: [...own.packages, ...added],
1027
1039
  };
1028
1040
  }
1029
1041
 
@@ -1063,7 +1075,7 @@ export const STABLE_KINDS = DISCOVER_KINDS.filter(
1063
1075
  );
1064
1076
 
1065
1077
  /**
1066
- * The item kinds discover reads in the project at the working directory, or
1078
+ * The item kinds `--type` takes in the project at the working directory, or
1067
1079
  * the stable kinds when it cannot be read.
1068
1080
  * @returns {Promise<readonly string[]>}
1069
1081
  */
@@ -1072,7 +1084,7 @@ export async function loadReadKinds() {
1072
1084
  }
1073
1085
 
1074
1086
  /**
1075
- * The item kinds discover reads in this project: every stable kind, and the
1087
+ * The item kinds `--type` takes in this project: every stable kind, and the
1076
1088
  * experimental ones where icon features are on.
1077
1089
  * @param {Project | undefined} project
1078
1090
  * @returns {readonly string[]}
@@ -1089,21 +1101,6 @@ export function optedIntoIconSets(project) {
1089
1101
  return iconFeatureGate(project).on;
1090
1102
  }
1091
1103
 
1092
- /**
1093
- * @template {{contributions: Array<{kind: string}>}} P
1094
- * @param {Project | undefined} project
1095
- * @param {P[]} packages
1096
- * @returns {P[]}
1097
- */
1098
- function withoutUnreadKinds(project, packages) {
1099
- if (optedIntoIconSets(project)) return packages;
1100
- const kinds = readKinds(project);
1101
- return packages.map(pkg => ({
1102
- ...pkg,
1103
- contributions: pkg.contributions.filter(c => kinds.includes(c.kind)),
1104
- }));
1105
- }
1106
-
1107
1104
  /**
1108
1105
  * Official packages first, in the official list's order; the rest keep theirs.
1109
1106
  * @template T
@@ -1441,3 +1438,14 @@ export async function withCoreMatch(err, query, cwd) {
1441
1438
  return err;
1442
1439
  }
1443
1440
  }
1441
+
1442
+ /**
1443
+ * How many of the icon definitions this CLI ships a set's definitions cover,
1444
+ * of how many: the coverage `experimental icon --list` reports as
1445
+ * `coverage.astryx`.
1446
+ * @param {string[]} definitions
1447
+ * @returns {{mapped: number, total: number}}
1448
+ */
1449
+ export function iconSetCoverage(definitions) {
1450
+ return astryxDefinitionCoverage(definitions);
1451
+ }
@@ -50,6 +50,19 @@ export function catalogState(pkg: CatalogPackage, installedNames: Set<string>, d
50
50
  state: "installed" | "declared" | "alias" | "available";
51
51
  installedAs?: string;
52
52
  };
53
+ /**
54
+ * A catalog package as discover may show it: an installed package's icon
55
+ * sets, under its own name or an alias, are read only where icon features are
56
+ * on (spec:AST-084 FR17), whichever version is shown.
57
+ * @param {CatalogPackage} entry
58
+ * @param {{installed: boolean, iconSets?: boolean}} options `installed`: the
59
+ * project has the package, under its name or an alias
60
+ * @returns {CatalogPackage}
61
+ */
62
+ export function shownEntry(entry: CatalogPackage, { installed, iconSets }: {
63
+ installed: boolean;
64
+ iconSets?: boolean;
65
+ }): CatalogPackage;
53
66
  /**
54
67
  * The version a catalog package shows by default.
55
68
  * @param {CatalogPackage} pkg
@@ -62,6 +75,7 @@ export function defaultVersion(pkg: CatalogPackage): string | undefined;
62
75
  * @param {string | undefined} version
63
76
  */
64
77
  export function catalogEntry(pkg: CatalogPackage, version: string | undefined): {
78
+ experimentalFields?: string[] | undefined;
65
79
  description?: string | undefined;
66
80
  version?: string | undefined;
67
81
  name: string;
@@ -85,6 +99,7 @@ export function availableEntries(catalog: CatalogResult, installed: InstalledPac
85
99
  install?: string | undefined;
86
100
  source: string;
87
101
  aliases?: string[] | undefined;
102
+ experimentalFields?: string[] | undefined;
88
103
  description?: string | undefined;
89
104
  version?: string | undefined;
90
105
  name: string;
@@ -86,6 +86,23 @@ export function catalogState(pkg, installedNames, declared, officialDeclared) {
86
86
  return {state: 'available'};
87
87
  }
88
88
 
89
+ /**
90
+ * A catalog package as discover may show it: an installed package's icon
91
+ * sets, under its own name or an alias, are read only where icon features are
92
+ * on (spec:AST-084 FR17), whichever version is shown.
93
+ * @param {CatalogPackage} entry
94
+ * @param {{installed: boolean, iconSets?: boolean}} options `installed`: the
95
+ * project has the package, under its name or an alias
96
+ * @returns {CatalogPackage}
97
+ */
98
+ export function shownEntry(entry, {installed, iconSets}) {
99
+ if (!installed || iconSets) return entry;
100
+ return {
101
+ ...entry,
102
+ contributions: entry.contributions.filter(c => c.kind !== 'icon-set'),
103
+ };
104
+ }
105
+
89
106
  /**
90
107
  * The version a catalog package shows by default.
91
108
  * @param {CatalogPackage} pkg
@@ -110,6 +127,9 @@ export function catalogEntry(pkg, version) {
110
127
  ...(version ? {version} : {}),
111
128
  ...(pkg.description ? {description: pkg.description} : {}),
112
129
  ...others,
130
+ // Icon sets are experimental (spec:AST-017 FR27): the entry names the
131
+ // field that lists them, so a consumer can leave them out.
132
+ ...(others.iconSets ? {experimentalFields: ['iconSets']} : {}),
113
133
  };
114
134
  }
115
135
 
@@ -0,0 +1,22 @@
1
+ // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
+ // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
+
4
+ /**
5
+ * Record the coverage of the icon set an item response shows.
6
+ * @param {object} response
7
+ * @param {{mapped: number, total: number}} coverage
8
+ */
9
+ export function setIconSetCoverage(response: object, coverage: {
10
+ mapped: number;
11
+ total: number;
12
+ }): void;
13
+ /**
14
+ * How many of this CLI's icon definitions the icon set an item response
15
+ * shows maps, of how many; null when its source lists no definitions.
16
+ * @param {object} response
17
+ * @returns {{mapped: number, total: number} | null}
18
+ */
19
+ export function iconSetCoverageOf(response: object): {
20
+ mapped: number;
21
+ total: number;
22
+ } | null;
@@ -0,0 +1,32 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file How many of this CLI's icon definitions an icon set a source lists
5
+ * maps, kept beside the item response that shows the set.
6
+ * @input The item leaf records it; the text view reads it.
7
+ * @output `iconSetCoverageOf(response)`: `{mapped, total}`, or null.
8
+ * @position A module of its own so search's discover line, which imports
9
+ * discover's entry, loads no leaf for it. It never enters discover's JSON.
10
+ */
11
+
12
+ /** @type {WeakMap<object, {mapped: number, total: number}>} */
13
+ const coverageByResponse = new WeakMap();
14
+
15
+ /**
16
+ * Record the coverage of the icon set an item response shows.
17
+ * @param {object} response
18
+ * @param {{mapped: number, total: number}} coverage
19
+ */
20
+ export function setIconSetCoverage(response, coverage) {
21
+ coverageByResponse.set(response, coverage);
22
+ }
23
+
24
+ /**
25
+ * How many of this CLI's icon definitions the icon set an item response
26
+ * shows maps, of how many; null when its source lists no definitions.
27
+ * @param {object} response
28
+ * @returns {{mapped: number, total: number} | null}
29
+ */
30
+ export function iconSetCoverageOf(response) {
31
+ return coverageByResponse.get(response) ?? null;
32
+ }
@@ -15,7 +15,8 @@
15
15
  * version?: string,
16
16
  * add?: (name: string, version?: string) => string,
17
17
  * installedAs?: string,
18
- * }} [options]
18
+ * iconSets?: boolean,
19
+ * }} [options] `iconSets`: icon features are on in the project
19
20
  * @returns {import('../discover.type.mjs').DiscoverDetailResponse}
20
21
  */
21
22
  export function detail(packages: import("../_adapter.mjs").InstalledPackage[], name: string, options?: {
@@ -23,4 +24,5 @@ export function detail(packages: import("../_adapter.mjs").InstalledPackage[], n
23
24
  version?: string;
24
25
  add?: (name: string, version?: string) => string;
25
26
  installedAs?: string;
27
+ iconSets?: boolean;
26
28
  }): import("../discover.type.mjs").DiscoverDetailResponse;
@@ -10,7 +10,7 @@
10
10
  */
11
11
 
12
12
  import {toEntry} from '../_adapter.mjs';
13
- import {catalogEntry, defaultVersion} from '../_catalog-view.mjs';
13
+ import {catalogEntry, defaultVersion, shownEntry} from '../_catalog-view.mjs';
14
14
  import {AstryxError} from '../../error.mjs';
15
15
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
16
16
 
@@ -28,12 +28,16 @@ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
28
28
  * version?: string,
29
29
  * add?: (name: string, version?: string) => string,
30
30
  * installedAs?: string,
31
- * }} [options]
31
+ * iconSets?: boolean,
32
+ * }} [options] `iconSets`: icon features are on in the project
32
33
  * @returns {import('../discover.type.mjs').DiscoverDetailResponse}
33
34
  */
34
35
  export function detail(packages, name, options = {}) {
35
- const {catalog, version, add, installedAs} = options;
36
+ const {catalog: listed, version, add, installedAs, iconSets} = options;
36
37
  const pkg = packages.find(p => p.name === name);
38
+ const catalog =
39
+ listed &&
40
+ shownEntry(listed, {installed: pkg != null || !!installedAs, iconSets});
37
41
  if (!pkg && !catalog) {
38
42
  throw new AstryxError(
39
43
  `Package "${name}" not found`,
@@ -64,7 +68,10 @@ export function detail(packages, name, options = {}) {
64
68
  : {
65
69
  ...catalogEntry(
66
70
  /** @type {NonNullable<typeof catalog>} */ (catalog),
67
- version ?? defaultVersion(/** @type {NonNullable<typeof catalog>} */ (catalog)),
71
+ version ??
72
+ defaultVersion(
73
+ /** @type {NonNullable<typeof catalog>} */ (catalog),
74
+ ),
68
75
  ),
69
76
  installed: pkg != null,
70
77
  ...(pkg?.version ? {installedVersion: pkg.version} : {}),
@@ -15,7 +15,12 @@
15
15
  * version?: string,
16
16
  * add?: (name: string, version?: string) => string,
17
17
  * installedAs?: string,
18
- * }} [options]
18
+ * iconSets?: boolean,
19
+ * coverageOf?: (definitions: string[]) => {mapped: number, total: number},
20
+ * }} [options] `iconSets`: icon features are on in the project, so an installed
21
+ * package's set answers and a set's `definitions` are shown. `coverageOf`
22
+ * counts how many of this CLI's icon definitions a set maps
23
+ * (iconSetCoverageOf).
19
24
  * @returns {import('../../discover.type.mjs').DiscoverItemResponse | null}
20
25
  */
21
26
  export function item(packages: import("../../_adapter.mjs").InstalledPackage[], packageName: string, itemName: string, options?: {
@@ -23,4 +28,9 @@ export function item(packages: import("../../_adapter.mjs").InstalledPackage[],
23
28
  version?: string;
24
29
  add?: (name: string, version?: string) => string;
25
30
  installedAs?: string;
31
+ iconSets?: boolean;
32
+ coverageOf?: (definitions: string[]) => {
33
+ mapped: number;
34
+ total: number;
35
+ };
26
36
  }): import("../../discover.type.mjs").DiscoverItemResponse | null;