@astryxdesign/cli 0.7.17 → 0.7.18-canary.g170df15
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.
- package/README.md +1 -1
- package/api/discover/_adapter.d.mts +7 -5
- package/api/discover/_adapter.mjs +12 -11
- package/api/docs/_adapter.d.mts +19 -2
- package/api/docs/_adapter.mjs +66 -5
- package/api/doctor/_adapter.d.mts +11 -62
- package/api/doctor/_adapter.mjs +242 -472
- package/api/doctor/doctor.d.mts +1 -1
- package/api/doctor/doctor.mjs +3 -3
- package/api/doctor/theme-checks.mjs +37 -45
- package/api/error.d.mts +21 -0
- package/api/error.mjs +89 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +8 -0
- package/api/icon/_adapter.mjs +17 -0
- package/api/icon/_authoring.mjs +6 -6
- package/api/icon/_default-look.mjs +16 -16
- package/api/icon/add/add.mjs +3 -3
- package/api/icon/exportIconIndex.doc.mjs +2 -2
- package/api/icon/icon.doc.mjs +2 -2
- package/api/icon/icon.type.d.mts +4 -0
- package/api/icon/icon.type.mjs +2 -1
- package/api/icon/search/icon-index.mjs +16 -3
- package/api/icon/search/search.d.mts +15 -5
- package/api/icon/search/search.mjs +74 -16
- package/api/icon/use/use.mjs +4 -4
- package/api/render/_adapter.mjs +233 -40
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.mjs +4 -0
- package/api/search/_candidate-score.mjs +32 -8
- package/api/search/_cards.json +1 -1
- package/api/search/_compound.d.mts +0 -1
- package/api/search/_compound.mjs +93 -2
- package/api/search/_icons.d.mts +4 -2
- package/api/search/_icons.mjs +4 -2
- package/api/search/_lexical.mjs +177 -17
- package/api/search/_order.d.mts +3 -1
- package/api/search/_order.mjs +16 -5
- package/api/search/_result.d.mts +9 -0
- package/api/search/_result.mjs +10 -0
- package/api/search/_score.mjs +21 -3
- package/api/swizzle/_moduleGraph.d.mts +8 -0
- package/api/swizzle/_moduleGraph.mjs +61 -3
- package/api/template/copy/copy.mjs +5 -3
- package/api/template/template.type.d.mts +3 -3
- package/api/template/template.type.mjs +3 -3
- package/api/theme/_adapter.mjs +48 -12
- package/api/theme/build/build.d.mts +4 -0
- package/api/theme/build/build.mjs +69 -18
- package/api/theme/build/style-keys.mjs +4 -5
- package/api/theme/build/theme-object.mjs +5 -0
- package/api/theme/palette/generate/color.d.mts +47 -0
- package/api/theme/palette/generate/color.mjs +58 -1
- package/api/theme/palette/generate/derive-look.d.mts +293 -0
- package/api/theme/palette/generate/derive-look.mjs +1362 -0
- package/api/theme/palette/generate/editor-look.d.mts +62 -0
- package/api/theme/palette/generate/editor-look.mjs +550 -0
- package/api/theme/palette/generate/mapping.d.mts +94 -9
- package/api/theme/palette/generate/mapping.mjs +94 -22
- package/api/theme-edit/_adapter.mjs +13 -2
- package/api/theme-edit/_catalog.d.mts +13 -13
- package/api/theme-edit/_catalog.mjs +66 -28
- package/api/theme-edit/_check.d.mts +82 -6
- package/api/theme-edit/_check.mjs +1270 -238
- package/api/theme-edit/_color.d.mts +74 -0
- package/api/theme-edit/_color.mjs +168 -3
- package/api/theme-edit/_compiler.d.mts +3 -5
- package/api/theme-edit/_compiler.mjs +122 -23
- package/api/theme-edit/_context.d.mts +55 -12
- package/api/theme-edit/_context.mjs +114 -60
- package/api/theme-edit/_css.d.mts +11 -0
- package/api/theme-edit/_css.mjs +40 -0
- package/api/theme-edit/_edit.d.mts +15 -2
- package/api/theme-edit/_edit.mjs +1469 -133
- package/api/theme-edit/_how-commands.d.mts +116 -0
- package/api/theme-edit/_how-commands.mjs +227 -115
- package/api/theme-edit/_how-question.d.mts +74 -29
- package/api/theme-edit/_how-question.mjs +8514 -1256
- package/api/theme-edit/_how-sides.d.mts +22 -0
- package/api/theme-edit/_how-sides.mjs +173 -0
- package/api/theme-edit/_how-steps.d.mts +42 -0
- package/api/theme-edit/_how-steps.mjs +208 -0
- package/api/theme-edit/_how-values.d.mts +29 -0
- package/api/theme-edit/_how-values.mjs +111 -0
- package/api/theme-edit/_how-words.d.mts +15 -0
- package/api/theme-edit/_how-words.mjs +239 -0
- package/api/theme-edit/_how.d.mts +1 -1
- package/api/theme-edit/_how.mjs +422 -37
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +125 -13
- package/api/theme-edit/_normal.d.mts +5 -3
- package/api/theme-edit/_normal.mjs +54 -14
- package/api/theme-edit/_palette.d.mts +204 -4
- package/api/theme-edit/_palette.mjs +901 -25
- package/api/theme-edit/_part-pieces.d.mts +54 -0
- package/api/theme-edit/_part-pieces.mjs +179 -0
- package/api/theme-edit/_part-words.mjs +33 -5
- package/api/theme-edit/_parts.d.mts +133 -0
- package/api/theme-edit/_parts.mjs +599 -10
- package/api/theme-edit/_picture-traits.d.mts +259 -0
- package/api/theme-edit/_picture-traits.mjs +1030 -0
- package/api/theme-edit/_preview.d.mts +95 -4
- package/api/theme-edit/_preview.mjs +284 -31
- package/api/theme-edit/_project.d.mts +14 -4
- package/api/theme-edit/_project.mjs +95 -26
- package/api/theme-edit/_resolved.d.mts +46 -0
- package/api/theme-edit/_resolved.mjs +800 -0
- package/api/theme-edit/_set-line.d.mts +29 -0
- package/api/theme-edit/_set-line.mjs +100 -0
- package/api/theme-edit/_settings.d.mts +625 -28
- package/api/theme-edit/_settings.mjs +4867 -888
- package/api/theme-edit/_tables.d.mts +25 -1
- package/api/theme-edit/_tables.mjs +115 -11
- package/api/theme-edit/_text-looks.d.mts +78 -0
- package/api/theme-edit/_text-looks.mjs +376 -0
- package/api/theme-edit/_vet.d.mts +3 -26
- package/api/theme-edit/_vet.mjs +5 -89
- package/api/theme-edit/how/how.d.mts +1 -1
- package/api/theme-edit/how/how.mjs +1 -1
- package/api/theme-edit/show/show.d.mts +4 -3
- package/api/theme-edit/show/show.mjs +3 -2
- package/api/theme-edit/theme-edit.type.d.mts +117 -1
- package/api/theme-edit/theme-edit.type.mjs +46 -3
- package/api/theme-edit/themeEditHow.doc.mjs +3 -3
- package/api/theme-edit/themeEditNew.doc.mjs +4 -0
- package/api/theme-edit/themeEditSet.doc.mjs +6 -2
- package/api/theme-edit/themeEditShow.doc.mjs +22 -3
- package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/icons.doc.mjs +7 -6
- package/assets/docs/theme.doc.dense.mjs +10 -0
- package/assets/docs/theme.doc.mjs +10 -0
- package/assets/docs/theme.doc.zh.mjs +10 -0
- package/assets/docs/tree/export-pages.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +89 -17
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/article.doc.mjs +9 -0
- package/assets/icons/template-icons.json +5 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ide/page.tsx +5 -10
- package/assets/templates/pages/payment-form/page.tsx +16 -60
- package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
- package/authoring/config/parse.mjs +1 -1
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +13 -13
- package/authoring/doctypes/icon-definition/parse.mjs +2 -2
- package/authoring/doctypes/icon-set/parse.mjs +1 -1
- package/authoring/doctypes/template/parse.mjs +1 -4
- package/authoring/gap-report/parse.d.mts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/ensure-core-built.mjs +17 -10
- package/clients/cli/commands/experimental/icon.mjs +7 -7
- package/clients/cli/commands/experimental/theme.mjs +175 -13
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/hook.mjs +7 -0
- package/clients/cli/commands/template.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/index.mjs +6 -2
- package/clients/cli/lib/hook-format.mjs +41 -1
- package/clients/cli/lib/json-shim.mjs +34 -14
- package/clients/cli/lib/other-cli-words.mjs +7 -0
- package/clients/cli/lib/unknown-command.mjs +345 -46
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +11 -2
- package/foundation/agent-docs/agent-docs.mjs +51 -8
- package/foundation/config/project.d.mts +11 -1
- package/foundation/config/project.mjs +11 -2
- package/foundation/discovery/component-replacement.d.mts +5 -8
- package/foundation/discovery/component-replacement.mjs +12 -14
- package/foundation/discovery/core-augmentation-points.d.mts +35 -0
- package/foundation/discovery/core-augmentation-points.mjs +410 -9
- package/foundation/discovery/core-elements.d.mts +6 -0
- package/foundation/discovery/core-elements.mjs +10 -2
- package/foundation/discovery/core-prop-types.d.mts +5 -0
- package/foundation/discovery/core-prop-types.mjs +10 -3
- package/foundation/discovery/core-props.d.mts +8 -0
- package/foundation/discovery/core-props.mjs +29 -13
- package/foundation/discovery/icon-ranking.d.mts +5 -2
- package/foundation/discovery/icon-ranking.mjs +101 -18
- package/foundation/discovery/icon-set-checks.mjs +1 -1
- package/foundation/discovery/icon-set-writer.mjs +1 -1
- package/foundation/discovery/official-list.d.mts +17 -0
- package/foundation/discovery/official-list.mjs +77 -0
- package/foundation/discovery/template-icon-notes.mjs +3 -3
- package/foundation/discovery/template-icons.mjs +2 -2
- package/foundation/discovery/template-placeholders.mjs +1 -1
- package/foundation/discovery/unknown-core-props.d.mts +130 -0
- package/foundation/discovery/unknown-core-props.mjs +601 -0
- package/foundation/discovery/written-prop-values.d.mts +35 -0
- package/foundation/discovery/written-prop-values.mjs +258 -0
- package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
- package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
- package/foundation/fs/package-name.d.mts +10 -0
- package/foundation/fs/package-name.mjs +37 -0
- package/foundation/fs/project-source-files.d.mts +27 -0
- package/foundation/fs/project-source-files.mjs +115 -0
- package/foundation/fs/project-sources.d.mts +25 -0
- package/foundation/fs/project-sources.mjs +83 -0
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +36 -2
- package/foundation/integrations/integration-warnings.d.mts +39 -7
- package/foundation/integrations/integration-warnings.mjs +141 -19
- package/foundation/integrations/missing-dependency.d.mts +11 -0
- package/foundation/integrations/missing-dependency.mjs +20 -5
- package/foundation/release/folder-lock.d.mts +5 -2
- package/foundation/release/folder-lock.mjs +9 -3
- package/foundation/release/notices.mjs +2 -8
- package/foundation/render/cut-short.d.mts +8 -2
- package/foundation/render/cut-short.mjs +50 -5
- package/foundation/render/drawn-contrast.d.mts +40 -0
- package/foundation/render/drawn-contrast.mjs +355 -0
- package/foundation/render/file-header.mjs +4 -0
- package/foundation/render/layers.d.mts +2 -1
- package/foundation/render/layers.mjs +22 -1
- package/foundation/render/package-resolve-hooks.d.mts +38 -9
- package/foundation/render/package-resolve-hooks.mjs +124 -32
- package/foundation/render/page-worker.mjs +95 -23
- package/foundation/render/part-boxes.d.mts +27 -0
- package/foundation/render/part-boxes.mjs +45 -0
- package/foundation/render/picture-chrome.mjs +36 -4
- package/foundation/render/picture-playwright.mjs +26 -2
- package/foundation/render/picture-window.d.mts +29 -2
- package/foundation/render/picture-window.mjs +99 -1
- package/foundation/render/render-page.d.mts +39 -6
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.mjs +2 -1
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +9 -5
- package/foundation/suggest/other-command.mjs +25 -1
- package/foundation/text/icon-set-next.d.mts +1 -1
- package/foundation/text/icon-set-next.mjs +2 -2
- package/foundation/text/written-string.d.mts +4 -1
- package/foundation/text/written-string.mjs +4 -1
- package/package.json +8 -7
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -719,7 +719,7 @@ export type DoctorContext = {
|
|
|
719
719
|
* the project reads no Core or the scan failed.
|
|
720
720
|
*/
|
|
721
721
|
coreProps?: {
|
|
722
|
-
found: import("
|
|
722
|
+
found: import("../../foundation/discovery/unknown-core-props.mjs").UnknownCoreProp[];
|
|
723
723
|
uses: number;
|
|
724
724
|
skipped: string | null;
|
|
725
725
|
} | null | undefined;
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -228,7 +228,7 @@ import {
|
|
|
228
228
|
* Each file in the project's own source with icon imports that do not
|
|
229
229
|
* match its icon sets, read only when the placeholders are; null otherwise.
|
|
230
230
|
* Experimental: may change or be removed in a patch release.
|
|
231
|
-
* @property {{found: import('
|
|
231
|
+
* @property {{found: import('../../foundation/discovery/unknown-core-props.mjs').UnknownCoreProp[], uses: number, skipped: string | null}|null} [coreProps]
|
|
232
232
|
* The props the project's own source gives Core components that they do
|
|
233
233
|
* not take, with how many props it read, or why it checked none; null when
|
|
234
234
|
* the project reads no Core or the scan failed.
|
|
@@ -1681,7 +1681,7 @@ export function checkIconSets(ctx) {
|
|
|
1681
1681
|
status: 'fail',
|
|
1682
1682
|
message:
|
|
1683
1683
|
declared.length === 0
|
|
1684
|
-
? `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no variants
|
|
1684
|
+
? `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no variants, so it has none to pick.`
|
|
1685
1685
|
: `experimental.iconVariant names "${choice.variant}", but the main set ${choice.configured ?? choice.set.name} declares no such variant. Its variants: ${declared.join(', ')}.`,
|
|
1686
1686
|
fix:
|
|
1687
1687
|
declared.length === 0
|
|
@@ -1738,7 +1738,7 @@ export function checkIconSets(ctx) {
|
|
|
1738
1738
|
id,
|
|
1739
1739
|
label,
|
|
1740
1740
|
status: 'pass',
|
|
1741
|
-
message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}${choice.variant ? ` Each icon draws its "${choice.variant}"
|
|
1741
|
+
message: `${sets.length} icon set${sets.length === 1 ? '' : 's'} installed. ${choice.reason}${choice.variant ? ` Each icon draws its "${choice.variant}" variant where its set has one.` : ''}`,
|
|
1742
1742
|
};
|
|
1743
1743
|
}
|
|
1744
1744
|
|
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
isLocalThemeOwner,
|
|
29
29
|
listDoctorThemePackages,
|
|
30
30
|
listProjectSourceFiles,
|
|
31
|
+
projectImportsModule,
|
|
32
|
+
specifierTargets,
|
|
31
33
|
planThemeAppWrite,
|
|
32
34
|
readPackageJson,
|
|
33
35
|
readTextFile,
|
|
@@ -36,7 +38,6 @@ import {
|
|
|
36
38
|
resolveDoctorThemeImports,
|
|
37
39
|
resolveRecordedTheme,
|
|
38
40
|
resolveThemeModule,
|
|
39
|
-
SOURCE_EXTENSIONS,
|
|
40
41
|
doctorStylesheetImportFile,
|
|
41
42
|
fileMark,
|
|
42
43
|
generatedSourceCommand,
|
|
@@ -253,42 +254,6 @@ export function moduleSpecifiers(source, options = {}) {
|
|
|
253
254
|
return values;
|
|
254
255
|
}
|
|
255
256
|
|
|
256
|
-
/** @param {string} specifier @param {string} fromFile @param {string} target */
|
|
257
|
-
function specifierTargets(specifier, fromFile, target) {
|
|
258
|
-
if (!specifier.startsWith('.')) return false;
|
|
259
|
-
const base = path.resolve(path.dirname(fromFile), specifier);
|
|
260
|
-
const candidates = [
|
|
261
|
-
base,
|
|
262
|
-
...[...SOURCE_EXTENSIONS].map(extension => `${base}${extension}`),
|
|
263
|
-
...[...SOURCE_EXTENSIONS].map(extension =>
|
|
264
|
-
path.join(base, `index${extension}`),
|
|
265
|
-
),
|
|
266
|
-
];
|
|
267
|
-
return candidates.some(
|
|
268
|
-
candidate => path.resolve(candidate) === path.resolve(target),
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/** @param {string} root @param {string} generatedModule */
|
|
273
|
-
function sourceImportEvidence(root, generatedModule) {
|
|
274
|
-
let parseFailures = 0;
|
|
275
|
-
for (const file of listProjectSourceFiles(root, generatedModule)) {
|
|
276
|
-
try {
|
|
277
|
-
const source = readTextFile(file);
|
|
278
|
-
if (
|
|
279
|
-
[...moduleSpecifiers(source)].some(specifier =>
|
|
280
|
-
specifierTargets(specifier, file, generatedModule),
|
|
281
|
-
)
|
|
282
|
-
) {
|
|
283
|
-
return {found: true, parseFailures};
|
|
284
|
-
}
|
|
285
|
-
} catch {
|
|
286
|
-
parseFailures += 1;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return {found: false, parseFailures};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
257
|
/**
|
|
293
258
|
* Whether the file's leading comment says the CLI generated it: a theme
|
|
294
259
|
* build, or a file of the theme editor (its settings module, its app copy).
|
|
@@ -620,7 +585,8 @@ function namedThemeFonts(files) {
|
|
|
620
585
|
* local `@import`s (a relative file, or a package's stylesheet such as
|
|
621
586
|
* `@fontsource/inter/index.css`), and the families the `family` parameters
|
|
622
587
|
* of a font service URL it imports name; `external` when it imports a URL
|
|
623
|
-
* (http, https, `//`)
|
|
588
|
+
* (http, https, `//`) that names no families doctor can read; `serviced`
|
|
589
|
+
* when it imports a font service URL that names its families.
|
|
624
590
|
* @param {string} css
|
|
625
591
|
* @param {string} [file] the stylesheet's path, to resolve local imports
|
|
626
592
|
* @param {Set<string>} [seen]
|
|
@@ -629,17 +595,21 @@ function fontStylesheetEvidence(css, file, seen = new Set()) {
|
|
|
629
595
|
const loaded = new Set();
|
|
630
596
|
let external = false;
|
|
631
597
|
let unread = false;
|
|
598
|
+
let serviced = false;
|
|
632
599
|
const root = postcss().parse(css);
|
|
633
600
|
root.walkAtRules(atRule => {
|
|
634
601
|
if (atRule.name.toLowerCase() === 'import') {
|
|
635
602
|
const spec = [...doctorStylesheetImports(`@import ${atRule.params};`)][0];
|
|
636
603
|
if (!spec || /^(?:https?:)?\/\//i.test(spec)) {
|
|
637
604
|
// A family the request names counts as loaded, as an @font-face rule
|
|
638
|
-
// does: the stylesheet asks the service for it.
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
605
|
+
// does: the stylesheet asks the service for it. A font service URL
|
|
606
|
+
// that names its families loads only those, so a family it does not
|
|
607
|
+
// name has no loader there; any other URL may load families doctor
|
|
608
|
+
// cannot read.
|
|
609
|
+
const named = fontServiceFamilies(spec ?? '');
|
|
610
|
+
for (const family of named) loaded.add(family);
|
|
611
|
+
if (named.size === 0) external = true;
|
|
612
|
+
else serviced = true;
|
|
643
613
|
return;
|
|
644
614
|
}
|
|
645
615
|
const target = file ? doctorStylesheetImportFile(spec, file) : null;
|
|
@@ -664,6 +634,7 @@ function fontStylesheetEvidence(css, file, seen = new Set()) {
|
|
|
664
634
|
);
|
|
665
635
|
for (const name of inner.loaded) loaded.add(name);
|
|
666
636
|
external ||= inner.external;
|
|
637
|
+
serviced ||= inner.serviced;
|
|
667
638
|
unread ||= inner.unread;
|
|
668
639
|
} catch {
|
|
669
640
|
unread = true;
|
|
@@ -675,7 +646,7 @@ function fontStylesheetEvidence(css, file, seen = new Set()) {
|
|
|
675
646
|
loaded.add(normalizeFontName(declaration.value).toLowerCase());
|
|
676
647
|
});
|
|
677
648
|
});
|
|
678
|
-
return {loaded, external, unread};
|
|
649
|
+
return {loaded, external, unread, serviced};
|
|
679
650
|
}
|
|
680
651
|
|
|
681
652
|
/** @param {import('postcss').Rule} rule @param {string} slug */
|
|
@@ -1678,7 +1649,7 @@ export async function checkAppThemes(cwd) {
|
|
|
1678
1649
|
});
|
|
1679
1650
|
}
|
|
1680
1651
|
|
|
1681
|
-
const importEvidence =
|
|
1652
|
+
const importEvidence = projectImportsModule(
|
|
1682
1653
|
state.projectDir,
|
|
1683
1654
|
state.module.file,
|
|
1684
1655
|
);
|
|
@@ -2178,6 +2149,10 @@ export async function checkAppThemes(cwd) {
|
|
|
2178
2149
|
|
|
2179
2150
|
const fontFailures = [];
|
|
2180
2151
|
const externalFontWarnings = [];
|
|
2152
|
+
/** @type {string[]} */
|
|
2153
|
+
const unnamedFontWarnings = [];
|
|
2154
|
+
/** @type {string[]} */
|
|
2155
|
+
const unnamedFamilies = [];
|
|
2181
2156
|
/** Families behind a local font import doctor could not follow. */
|
|
2182
2157
|
const unreadFontWarnings = [];
|
|
2183
2158
|
const missingFontWarnings = [];
|
|
@@ -2267,6 +2242,11 @@ export async function checkAppThemes(cwd) {
|
|
|
2267
2242
|
if (missing.length === 0) continue;
|
|
2268
2243
|
if (evidence.external) {
|
|
2269
2244
|
externalFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
|
|
2245
|
+
} else if (evidence.serviced) {
|
|
2246
|
+
// (AST-050 FR11 item 9: a font service URL that does not name the
|
|
2247
|
+
// family is a warning that names it, never a failure.)
|
|
2248
|
+
unnamedFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
|
|
2249
|
+
unnamedFamilies.push(...missing);
|
|
2270
2250
|
} else if (evidence.unread) {
|
|
2271
2251
|
unreadFontWarnings.push(`${theme.slug}: ${missing.join(', ')}`);
|
|
2272
2252
|
} else {
|
|
@@ -2305,6 +2285,18 @@ export async function checkAppThemes(cwd) {
|
|
|
2305
2285
|
`Font imports doctor could not follow prevent proof for ${unreadFontWarnings.join('; ')}.`,
|
|
2306
2286
|
);
|
|
2307
2287
|
}
|
|
2288
|
+
if (unnamedFontWarnings.length > 0) {
|
|
2289
|
+
fontWarningMessages.push(
|
|
2290
|
+
`The font service stylesheet each theme imports does not name ${unnamedFontWarnings.join('; ')}.`,
|
|
2291
|
+
);
|
|
2292
|
+
const install = await fontPackagesInstallLine(
|
|
2293
|
+
state.projectDir,
|
|
2294
|
+
unnamedFamilies,
|
|
2295
|
+
);
|
|
2296
|
+
fontWarningFixes.push(
|
|
2297
|
+
`Add each named family to the font service URL${install.line ? `, or install the packages that load them (${install.line})` : ''}, or load it another way.`,
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2308
2300
|
if (externalFontWarnings.length > 0) {
|
|
2309
2301
|
fontWarningMessages.push(
|
|
2310
2302
|
`External font imports prevent proof for ${externalFontWarnings.join('; ')}.`,
|
package/api/error.d.mts
CHANGED
|
@@ -34,6 +34,27 @@ export function writeFailed(target: string, cwd: string, cause: unknown, unresto
|
|
|
34
34
|
outcome?: string;
|
|
35
35
|
next?: string;
|
|
36
36
|
}): AstryxError;
|
|
37
|
+
/**
|
|
38
|
+
* The refusal for a failure that is a broken install: an installed package
|
|
39
|
+
* (one in a node_modules folder, such as a package the CLI uses) needs a
|
|
40
|
+
* package it declares, and that package is not installed. The command's own
|
|
41
|
+
* subject (a theme, a page) is not at fault, so the refusal names both
|
|
42
|
+
* packages and how to install them again. When the run uses a CLI copy of
|
|
43
|
+
* its own (global, a package runner's or the release cache's) and the app's
|
|
44
|
+
* install does not hold the package that needs the missing one, the package
|
|
45
|
+
* is that copy's: installing the copy again repairs it and the app's install
|
|
46
|
+
* does not, so the refusal names the copy (a release-cache copy is installed
|
|
47
|
+
* again once its folder is gone). Otherwise the refusal names the app's
|
|
48
|
+
* install command. A missing import in the app's own files is not a broken
|
|
49
|
+
* install: it stays the caller's failure.
|
|
50
|
+
*
|
|
51
|
+
* @param {unknown} cause the error the load threw
|
|
52
|
+
* @param {string} cwd project root, for its install and package manager
|
|
53
|
+
* @param {string} [outcome] what the command left as it was
|
|
54
|
+
* @param {string} [cliRoot] the running CLI package's folder
|
|
55
|
+
* @returns {AstryxError | null} null when the cause is not a broken install
|
|
56
|
+
*/
|
|
57
|
+
export function brokenInstallError(cause: unknown, cwd: string, outcome?: string, cliRoot?: string): AstryxError | null;
|
|
37
58
|
/**
|
|
38
59
|
* Locate the Core a command answers from (`requireCoreDir` in
|
|
39
60
|
* foundation/fs/paths.mjs), raising its coded failure as an AstryxError:
|
package/api/error.mjs
CHANGED
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
|
|
15
|
+
import {
|
|
16
|
+
explainPackageManager,
|
|
17
|
+
installDependenciesCommand,
|
|
18
|
+
} from '../foundation/env/package-manager.mjs';
|
|
19
|
+
import {relativeWithin, samePath} from '../foundation/fs/path-compare.mjs';
|
|
20
|
+
import {
|
|
21
|
+
CLI_ROOT,
|
|
22
|
+
findNodeModulesPackage,
|
|
23
|
+
realDir,
|
|
24
|
+
} from '../foundation/fs/paths.mjs';
|
|
25
|
+
import {installPlaceOf, isGlobalCopy} from '../foundation/release/choose.mjs';
|
|
26
|
+
import {isInReleaseCache} from '../foundation/release/cache.mjs';
|
|
27
|
+
import {brokenInstall} from '../foundation/integrations/missing-dependency.mjs';
|
|
15
28
|
import * as path from 'node:path';
|
|
16
29
|
|
|
17
30
|
export class AstryxError extends Error {
|
|
@@ -91,6 +104,82 @@ export function writeFailed(target, cwd, cause, unrestored = [], say = {}) {
|
|
|
91
104
|
);
|
|
92
105
|
}
|
|
93
106
|
|
|
107
|
+
/**
|
|
108
|
+
* The refusal for a failure that is a broken install: an installed package
|
|
109
|
+
* (one in a node_modules folder, such as a package the CLI uses) needs a
|
|
110
|
+
* package it declares, and that package is not installed. The command's own
|
|
111
|
+
* subject (a theme, a page) is not at fault, so the refusal names both
|
|
112
|
+
* packages and how to install them again. When the run uses a CLI copy of
|
|
113
|
+
* its own (global, a package runner's or the release cache's) and the app's
|
|
114
|
+
* install does not hold the package that needs the missing one, the package
|
|
115
|
+
* is that copy's: installing the copy again repairs it and the app's install
|
|
116
|
+
* does not, so the refusal names the copy (a release-cache copy is installed
|
|
117
|
+
* again once its folder is gone). Otherwise the refusal names the app's
|
|
118
|
+
* install command. A missing import in the app's own files is not a broken
|
|
119
|
+
* install: it stays the caller's failure.
|
|
120
|
+
*
|
|
121
|
+
* @param {unknown} cause the error the load threw
|
|
122
|
+
* @param {string} cwd project root, for its install and package manager
|
|
123
|
+
* @param {string} [outcome] what the command left as it was
|
|
124
|
+
* @param {string} [cliRoot] the running CLI package's folder
|
|
125
|
+
* @returns {AstryxError | null} null when the cause is not a broken install
|
|
126
|
+
*/
|
|
127
|
+
export function brokenInstallError(cause, cwd, outcome, cliRoot = CLI_ROOT) {
|
|
128
|
+
const found = brokenInstall(
|
|
129
|
+
cause instanceof Error ? cause.message : String(cause),
|
|
130
|
+
);
|
|
131
|
+
if (!found || !found.importer.split(/[\\/]/).includes('node_modules'))
|
|
132
|
+
return null;
|
|
133
|
+
const done = outcome ? ` ${outcome}` : '';
|
|
134
|
+
const what = `${found.requiredBy} needs ${found.name}, which is missing or incomplete`;
|
|
135
|
+
const cli = realDir(cliRoot);
|
|
136
|
+
const cached = isInReleaseCache(cli);
|
|
137
|
+
const place = installPlaceOf(cli);
|
|
138
|
+
if (
|
|
139
|
+
(cached || place.runner || isGlobalCopy(cli)) &&
|
|
140
|
+
!appLinks(cwd, found.requiredBy, found.importer)
|
|
141
|
+
)
|
|
142
|
+
return new AstryxError(
|
|
143
|
+
cached
|
|
144
|
+
? `The CLI release this run uses is not fully installed: ${what}. Remove ${place.owner ?? cli} so the next run installs that release again, then run the command again.${done}`
|
|
145
|
+
: `The CLI copy this run uses (${cli}) is not fully installed: ${what}. The app's install does not hold ${found.requiredBy}, so install that copy of the CLI again, then run the command again.${done}`,
|
|
146
|
+
undefined,
|
|
147
|
+
ERROR_CODES.ERR_DEP_MISSING,
|
|
148
|
+
);
|
|
149
|
+
const install = installDependenciesCommand(cwd);
|
|
150
|
+
return new AstryxError(
|
|
151
|
+
`The app's packages are not fully installed: ${what} in node_modules. Run ${install} to install them again, then run the command again.${done}`,
|
|
152
|
+
[
|
|
153
|
+
{
|
|
154
|
+
name: install,
|
|
155
|
+
reason: `install the app's packages again: ${found.requiredBy} needs ${found.name}`,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
ERROR_CODES.ERR_DEP_MISSING,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whether the app's own install holds the package `name` that `importer` is
|
|
164
|
+
* in: the importer is in the app's folder, or the app resolves `name` to
|
|
165
|
+
* that same folder, wherever its package manager keeps it.
|
|
166
|
+
* @param {string} cwd
|
|
167
|
+
* @param {string} name
|
|
168
|
+
* @param {string} importer
|
|
169
|
+
* @returns {boolean}
|
|
170
|
+
*/
|
|
171
|
+
function appLinks(cwd, name, importer) {
|
|
172
|
+
const app = explainPackageManager(cwd).dir ?? cwd;
|
|
173
|
+
const at = realDir(path.dirname(importer));
|
|
174
|
+
if (relativeWithin(realDir(app), at) !== null) return true;
|
|
175
|
+
// Found in node_modules only, never through NODE_PATH or Node's global
|
|
176
|
+
// folders, which can hold the CLI copy itself.
|
|
177
|
+
const folder = findNodeModulesPackage(app, name)?.packageDir;
|
|
178
|
+
if (!folder) return false;
|
|
179
|
+
const linked = realDir(folder);
|
|
180
|
+
return samePath(linked, at) || relativeWithin(linked, at) !== null;
|
|
181
|
+
}
|
|
182
|
+
|
|
94
183
|
/**
|
|
95
184
|
* Locate the Core a command answers from (`requireCoreDir` in
|
|
96
185
|
* foundation/fs/paths.mjs), raising its coded failure as an AstryxError:
|
package/api/hook/list/list.d.mts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export function list({ cwd, category, detail, zh, lang, }?: {
|
|
14
14
|
cwd?: string | undefined;
|
|
15
15
|
category?: string | undefined;
|
|
16
|
-
detail?: "
|
|
16
|
+
detail?: "compact" | "full" | "names" | "brief" | undefined;
|
|
17
17
|
zh?: boolean | undefined;
|
|
18
18
|
lang?: string | null | undefined;
|
|
19
19
|
}): Promise<import("../hook.type.mjs").HookListResponse>;
|
package/api/icon/_adapter.d.mts
CHANGED
|
@@ -37,6 +37,14 @@ export function loadIconSets(cwd: string): Promise<{
|
|
|
37
37
|
* @returns {Promise<boolean>}
|
|
38
38
|
*/
|
|
39
39
|
export function discoverListsIconSet(cwd: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* The names of the components of the Core the project in `cwd` reads: an
|
|
42
|
+
* icon query's words that name one say where the icon goes (spec:AST-084
|
|
43
|
+
* FR6). Empty when there is no Core.
|
|
44
|
+
* @param {string} cwd
|
|
45
|
+
* @returns {string[]}
|
|
46
|
+
*/
|
|
47
|
+
export function coreComponentNames(cwd: string): string[];
|
|
40
48
|
/**
|
|
41
49
|
* The project directory, its installed icon sets, and the sets withdrawn,
|
|
42
50
|
* for `experimental icon use`.
|
package/api/icon/_adapter.mjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import * as fs from 'node:fs';
|
|
14
14
|
import * as path from 'node:path';
|
|
15
15
|
import {Project} from '../../foundation/config/project.mjs';
|
|
16
|
+
import {discoverComponents} from '../../foundation/discovery/component-discovery.mjs';
|
|
16
17
|
import {AstryxError} from '../error.mjs';
|
|
17
18
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
18
19
|
import {
|
|
@@ -178,6 +179,22 @@ export async function discoverListsIconSet(cwd) {
|
|
|
178
179
|
return listsToAdd(project, ICON_PACK_QUERY, 'icon-set');
|
|
179
180
|
}
|
|
180
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The names of the components of the Core the project in `cwd` reads: an
|
|
184
|
+
* icon query's words that name one say where the icon goes (spec:AST-084
|
|
185
|
+
* FR6). Empty when there is no Core.
|
|
186
|
+
* @param {string} cwd
|
|
187
|
+
* @returns {string[]}
|
|
188
|
+
*/
|
|
189
|
+
export function coreComponentNames(cwd) {
|
|
190
|
+
const project = Project.lastLoaded(cwd);
|
|
191
|
+
try {
|
|
192
|
+
return Object.values(discoverComponents(project?.coreDir() ?? null)).flat();
|
|
193
|
+
} catch {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
181
198
|
/**
|
|
182
199
|
* The project directory, its installed icon sets, and the sets withdrawn,
|
|
183
200
|
* for `experimental icon use`.
|
package/api/icon/_authoring.mjs
CHANGED
|
@@ -737,7 +737,7 @@ async function redeclareIconSet(
|
|
|
737
737
|
.map(icon => icon.id);
|
|
738
738
|
if (asExtra.length > 0) {
|
|
739
739
|
throw new AstryxError(
|
|
740
|
-
`"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another
|
|
740
|
+
`"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another variant (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
|
|
741
741
|
undefined,
|
|
742
742
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
743
743
|
);
|
|
@@ -800,7 +800,7 @@ async function redeclareIconSet(
|
|
|
800
800
|
: `Updated icon set "${name}" in place; its icons, map and generated module are unchanged.`,
|
|
801
801
|
...(added.length > 0
|
|
802
802
|
? [
|
|
803
|
-
`Give each icon its ${added.join(', ')}
|
|
803
|
+
`Give each icon its ${added.join(', ')} variant${added.length > 1 ? 's' : ''}: ${added.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${fromFor(variant)} --all --set ${name}\``).join(', ')}, or one icon with \`astryx experimental icon add <Export> --from <module> --id <icon> --variant <name> --set ${name}\`.`,
|
|
804
804
|
]
|
|
805
805
|
: []),
|
|
806
806
|
];
|
|
@@ -827,10 +827,10 @@ function lookNotes(summary, count, from, looks, name) {
|
|
|
827
827
|
variant => variant !== looks?.default && styles.has(variant),
|
|
828
828
|
);
|
|
829
829
|
return [
|
|
830
|
-
`Found ${count} icons in ${from}, each drawn in several
|
|
830
|
+
`Found ${count} icons in ${from}, each drawn in several styles, sizes and weights (${described}) by ${summary.exports} exports. The set wraps each icon once, as its ${taken} export, named without those words (\`x\`, \`XIcon\`).`,
|
|
831
831
|
others.length > 0
|
|
832
|
-
? `Add
|
|
833
|
-
: `To offer another
|
|
832
|
+
? `Add ${others.join(', ')} as ${others.length > 1 ? 'variants' : 'a variant'}: ${others.map(variant => `\`astryx experimental icon add --variant ${variant} --from ${from} --all --set ${name}\``).join(', ')}.`
|
|
833
|
+
: `To offer another variant, declare it with \`astryx experimental icon new-set ${name} --variants ${[...summary.preferred].reverse()[0]},<variant>\` (no --from: the set's icons stay as they are) and run \`astryx experimental icon add --variant <variant> --from ${from} --all --set ${name}\`.`,
|
|
834
834
|
];
|
|
835
835
|
}
|
|
836
836
|
|
|
@@ -1154,7 +1154,7 @@ async function refreshIconSet(
|
|
|
1154
1154
|
.map(icon => icon.id);
|
|
1155
1155
|
if (asExtra.length > 0) {
|
|
1156
1156
|
throw new AstryxError(
|
|
1157
|
-
`"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another
|
|
1157
|
+
`"${looks.default}" can't be the default variant: ${asExtra.length} icons list it as another variant (${asExtra.slice(0, 8).join(', ')}${asExtra.length > 8 ? ', …' : ''}), and each icon's own export draws the default.`,
|
|
1158
1158
|
undefined,
|
|
1159
1159
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
1160
1160
|
);
|
|
@@ -184,10 +184,10 @@ export function drawnLooks(set, packageDir, positionsOf, options = {}) {
|
|
|
184
184
|
*/
|
|
185
185
|
function unknownLook(word, flag, module, positions) {
|
|
186
186
|
return new AstryxError(
|
|
187
|
-
`"${word}" is no look of ${module}: its exports name their
|
|
187
|
+
`"${word}" is no look word of ${module}: its exports name their look words with ${describedLooks(sortedWords(positions))}. Name one of these words, so each icon's export draws that variant.`,
|
|
188
188
|
styleWords(positions).map(each => ({
|
|
189
189
|
name: `${flag} ${each}`,
|
|
190
|
-
reason: `a look ${module} names`,
|
|
190
|
+
reason: `a look word ${module} names`,
|
|
191
191
|
})),
|
|
192
192
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
193
193
|
);
|
|
@@ -214,11 +214,11 @@ function refreshCommand(name, module, looks) {
|
|
|
214
214
|
*/
|
|
215
215
|
function inPlaceMove(name, count, now, looks, module, current) {
|
|
216
216
|
return new AstryxError(
|
|
217
|
-
`Icon set "${name}" can't ${current != null ? `move its default variant from "${current}" to "${looks.default}"` : `take "${looks.default}" as its default variant`} in place: each of its ${count} icons still draws "${now}". Wrap the library again with the new default, so each icon takes that
|
|
217
|
+
`Icon set "${name}" can't ${current != null ? `move its default variant from "${current}" to "${looks.default}"` : `take "${looks.default}" as its default variant`} in place: each of its ${count} icons still draws "${now}". Wrap the library again with the new default, so each icon takes that variant.`,
|
|
218
218
|
[
|
|
219
219
|
{
|
|
220
220
|
name: refreshCommand(name, module, looks),
|
|
221
|
-
reason: 'wrap the library again in the new default
|
|
221
|
+
reason: 'wrap the library again in the new default variant',
|
|
222
222
|
},
|
|
223
223
|
],
|
|
224
224
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
@@ -237,7 +237,7 @@ function inPlaceMove(name, count, now, looks, module, current) {
|
|
|
237
237
|
function unencodedMove(name, count, current, looks) {
|
|
238
238
|
const variants = [...new Set([current, ...looks.variants])];
|
|
239
239
|
return new AstryxError(
|
|
240
|
-
`Icon set "${name}" can't move its default variant from "${current}" to "${looks.default}": its icons' export names
|
|
240
|
+
`Icon set "${name}" can't move its default variant from "${current}" to "${looks.default}": its icons' export names carry no look words, so each of its ${count} icons draws "${current}", the variant its icons' module draws. Keep "${current}" as the default, declare "${looks.default}" as a variant, and add it from the module that draws it (fill <module> with that module).`,
|
|
241
241
|
[
|
|
242
242
|
{
|
|
243
243
|
name: `astryx experimental icon new-set ${name} --variants ${variants.join(',')} --default-variant ${current}`,
|
|
@@ -245,7 +245,7 @@ function unencodedMove(name, count, current, looks) {
|
|
|
245
245
|
},
|
|
246
246
|
{
|
|
247
247
|
name: `astryx experimental icon add --variant ${looks.default} --from <module> --all --set ${name}`,
|
|
248
|
-
reason: `give each icon its ${looks.default}
|
|
248
|
+
reason: `give each icon its ${looks.default} variant from the module that draws it`,
|
|
249
249
|
},
|
|
250
250
|
],
|
|
251
251
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
@@ -265,15 +265,15 @@ function unencodedMove(name, count, current, looks) {
|
|
|
265
265
|
function droppedDefault(name, count, current, looks, from) {
|
|
266
266
|
const others = looks.variants.filter(variant => variant !== current);
|
|
267
267
|
return new AstryxError(
|
|
268
|
-
`--variants (${looks.variants.join(', ')}) leaves out "${current}", the default variant of icon set "${name}". Its icons' export names
|
|
268
|
+
`--variants (${looks.variants.join(', ')}) leaves out "${current}", the default variant of icon set "${name}". Its icons' export names carry no look words, so each of its ${count} icons still draws "${current}", the variant its icons' module draws. List "${current}" in --variants, and add each other variant from the module that draws it (fill <module> with that module).`,
|
|
269
269
|
[
|
|
270
270
|
{
|
|
271
271
|
name: `astryx experimental icon new-set ${name}${from} --variants ${[current, ...others].join(',')}`,
|
|
272
|
-
reason: `keep ${current}, the
|
|
272
|
+
reason: `keep ${current}, the variant each icon draws, as the default`,
|
|
273
273
|
},
|
|
274
274
|
...others.map(variant => ({
|
|
275
275
|
name: `astryx experimental icon add --variant ${variant} --from <module> --all --set ${name}`,
|
|
276
|
-
reason: `give each icon its ${variant}
|
|
276
|
+
reason: `give each icon its ${variant} variant from the module that draws it`,
|
|
277
277
|
})),
|
|
278
278
|
],
|
|
279
279
|
ERROR_CODES.ERR_INVALID_OPTION,
|
|
@@ -350,13 +350,13 @@ export function resolveDefaultLook({
|
|
|
350
350
|
const words = now != null ? now.words : preferredLook(positions, []);
|
|
351
351
|
const look = drawnWord(positions, words, given.variants);
|
|
352
352
|
if (look == null || !given.variants.includes(look)) {
|
|
353
|
-
const shown = look ?? '<
|
|
353
|
+
const shown = look ?? '<variant>';
|
|
354
354
|
throw new AstryxError(
|
|
355
|
-
`None of --variants (${given.variants.join(', ')}) is the
|
|
355
|
+
`None of --variants (${given.variants.join(', ')}) is the variant ${now != null ? `the set's ${now.icons} icons draw` : `${module} is wrapped in by default`} ("${shown}"), and each icon's own export draws the default variant. List it in --variants, or name the default with --default-variant.`,
|
|
356
356
|
[
|
|
357
357
|
{
|
|
358
358
|
name: `astryx experimental icon new-set ${name}${refresh ? ` --from ${shellArg(/** @type {string} */ (module))}` : ''} --variants ${[shown, ...given.variants].join(',')}`,
|
|
359
|
-
reason: `declare ${shown}, the
|
|
359
|
+
reason: `declare ${shown}, the variant each icon draws, as the default`,
|
|
360
360
|
},
|
|
361
361
|
],
|
|
362
362
|
ERROR_CODES.ERR_INVALID_OPTION,
|
|
@@ -386,7 +386,7 @@ function unencodedDefault({name, given, current, icons, module, refresh}) {
|
|
|
386
386
|
}
|
|
387
387
|
if (current == null && icons > 0) {
|
|
388
388
|
throw new AstryxError(
|
|
389
|
-
`Icon set "${name}" declares no default variant, and its icons' export names name none of ${given.variants.join(', ')}. Name the
|
|
389
|
+
`Icon set "${name}" declares no default variant, and its icons' export names name none of ${given.variants.join(', ')}. Name the variant its ${icons} icons draw with --default-variant.`,
|
|
390
390
|
given.variants.map(variant => ({
|
|
391
391
|
name: `astryx experimental icon new-set ${name}${from} --variants ${given.variants.join(',')} --default-variant ${variant}`,
|
|
392
392
|
reason: `if each icon draws ${variant}`,
|
|
@@ -433,7 +433,7 @@ export function declareVariantSuggestion(set, variant, drawn) {
|
|
|
433
433
|
name: `astryx experimental icon new-set ${set.name} --variants ${variants.join(',')} --default-variant ${kept}`,
|
|
434
434
|
reason:
|
|
435
435
|
kept === '<default>'
|
|
436
|
-
? 'declare the variants; fill <default> with the
|
|
436
|
+
? 'declare the variants; fill <default> with the variant the icons draw'
|
|
437
437
|
: 'declare the variants',
|
|
438
438
|
};
|
|
439
439
|
}
|
|
@@ -458,7 +458,7 @@ export function checkVariantLook({set, variant, module, positions, drawn}) {
|
|
|
458
458
|
const drawnHere = index >= 0 ? drawn?.words[index] : null;
|
|
459
459
|
if (set.data.default?.variant === variant || drawnHere === variant) {
|
|
460
460
|
throw new AstryxError(
|
|
461
|
-
`"${variant}" is the
|
|
461
|
+
`"${variant}" is the variant each icon's own export in "${set.name}" already draws${set.data.default?.variant === variant ? ' (its default variant)' : ''}, so adding it as a variant would export the same artwork twice.`,
|
|
462
462
|
undefined,
|
|
463
463
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
464
464
|
);
|
|
@@ -466,7 +466,7 @@ export function checkVariantLook({set, variant, module, positions, drawn}) {
|
|
|
466
466
|
const declared = set.data.variants ?? [];
|
|
467
467
|
if (!declared.includes(variant)) {
|
|
468
468
|
throw new AstryxError(
|
|
469
|
-
`Icon set "${set.name}" declares no variant "${variant}"${declared.length > 0 ? ` (it declares ${declared.join(', ')})` : ''}. Declare it first${keptDefault(set, drawn) == null ? ', and name the
|
|
469
|
+
`Icon set "${set.name}" declares no variant "${variant}"${declared.length > 0 ? ` (it declares ${declared.join(', ')})` : ''}. Declare it first${keptDefault(set, drawn) == null ? ', and name the variant its icons draw now as the default variant in place of <default>' : ''}.`,
|
|
470
470
|
[declareVariantSuggestion(set, variant, drawn)],
|
|
471
471
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
472
472
|
);
|
package/api/icon/add/add.mjs
CHANGED
|
@@ -357,7 +357,7 @@ export async function iconAdd(exportName, options) {
|
|
|
357
357
|
sameIconModule(own.module, source.module)
|
|
358
358
|
) {
|
|
359
359
|
throw new AstryxError(
|
|
360
|
-
`"${sourceExport}" is icon "${id}"'s own export, which draws its default
|
|
360
|
+
`"${sourceExport}" is icon "${id}"'s own export, which draws its default variant, so it can't be its ${variant} variant too.`,
|
|
361
361
|
undefined,
|
|
362
362
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
363
363
|
);
|
|
@@ -759,11 +759,11 @@ async function addVariantForAll({cwd, from, selector, variant}) {
|
|
|
759
759
|
...(set.data.variants ?? []).filter(each => each !== variant),
|
|
760
760
|
];
|
|
761
761
|
throw new AstryxError(
|
|
762
|
-
`"${source.module}" is the module the ${own.length} icons of "${set.name}" come from: its exports
|
|
762
|
+
`"${source.module}" is the module the ${own.length} icons of "${set.name}" come from: its exports already draw those icons as "${variant}", so "${variant}" can't be another variant of them. "${set.name}" declares no default variant; declare "${variant}" as the default first.`,
|
|
763
763
|
[
|
|
764
764
|
{
|
|
765
765
|
name: `astryx experimental icon new-set ${set.name} --variants ${variants.join(',')} --default-variant ${variant}`,
|
|
766
|
-
reason: `declare ${variant}, the
|
|
766
|
+
reason: `declare ${variant}, the variant each icon draws, as the default`,
|
|
767
767
|
},
|
|
768
768
|
],
|
|
769
769
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
@@ -17,7 +17,7 @@ export const doc = {
|
|
|
17
17
|
summary:
|
|
18
18
|
'The icon sets icon() searches in a folder, as plain JSON to store and rank later with rankIconIndex().',
|
|
19
19
|
description:
|
|
20
|
-
"Reads the icon sets `icon()` would search in `cwd` and returns them as `{version, sets, withdrawn}`. Reading them loads each installed package's integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankIconIndex}. With `package`, the index keeps only the sets that package ships, for a catalog that stores one index per package. Paths into the folder are left out, so an index reads the same wherever it was made. A set in the list of the folder's project carries the look that project picks (`look`), so its matches draw that look as `icon()` draws it there. The sets are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
|
|
20
|
+
"Reads the icon sets `icon()` would search in `cwd` and returns them as `{version, sets, withdrawn, components}`. Reading them loads each installed package's integration manifest, which runs that package's code, so a catalog that lists packages it must not load makes the index where loading is safe (a folder with those packages installed), stores it, and ranks it with {@link function:rankIconIndex}. With `package`, the index keeps only the sets that package ships, for a catalog that stores one index per package. Paths into the folder are left out, so an index reads the same wherever it was made. A set in the list of the folder's project carries the look that project picks (`look`), so its matches draw that look as `icon()` draws it there. The sets are the ranker's input, not a stable shape: an index is ranked only by the CLI version that made it. Experimental: it may change or be removed in a patch release.",
|
|
21
21
|
importPath: '@astryxdesign/cli/api',
|
|
22
22
|
signature:
|
|
23
23
|
'exportIconIndex(options?: {cwd?: string, package?: string}): Promise<IconIndex>',
|
|
@@ -40,7 +40,7 @@ export const doc = {
|
|
|
40
40
|
{
|
|
41
41
|
type: 'IconIndex',
|
|
42
42
|
description:
|
|
43
|
-
|
|
43
|
+
"`version`, the CLI version that made it; `sets`, the valid sets in tie order as plain JSON; `withdrawn`, the sets read but withdrawn, and why; and `components`, the names of the folder's Core components, so a query's words that name one rank as `icon()` ranks them there.",
|
|
44
44
|
},
|
|
45
45
|
],
|
|
46
46
|
throws: [
|
package/api/icon/icon.doc.mjs
CHANGED
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
summary:
|
|
17
17
|
'Find an icon by meaning in the installed icon sets, read one icon, or list the sets.',
|
|
18
18
|
description:
|
|
19
|
-
"Reads every installed icon set's data file, never the icon modules. With words it ranks icons by meaning: an icon definition the set's `map` names the icon for, then exact matches on its id or words, then a word that starts with the query, then partial matches, and for a query of several words that none of those answer, the icons that carry some of its words, rarer words counting more within a set. A word written as an export name (`SearchIcon`) also reads as its words, and the reading with the better match answers. Equal scores keep the project's set first, then integration load order; within a set, a whole-id name match before an id-part one and a meaning match by its tag position; then an icon whose id the query names in full; then id order. With `<set>/<id>` it reads one icon with every variant's import line. With `list` it lists the installed sets, how many icon definitions each one's `map` covers (built-in and all of Astryx's) and its own definitions, and any set withdrawn and why. `search()` and `astryx search` with no `type` answer from the same ranking when a query asks for an icon (one word as typed is `icon` or `icons`, an installed set's name, or an icon export name such as `SearchIcon`, and is not the name of a component or hook; an `icon` or `icons` right after `with`, with only `a`, `an` or `the` between, that no `of` or `for` follows names a feature of an answered component or template, as in `card with an icon`, and asks for none, while `card with an icon of a star` still asks): after `results` they return `icons`, `{matchCount, results}`, with at most 3 icons (fewer when `limit` is smaller), each with `domain: 'icon'`, `name` (`<set>/<id>`), `set`, `id`, `package`, `score`, `reason`, `import` and `command`; text mode lists them last, one line each. It never changes search's `results` or `matchCount`, and it is absent when no icon answers. Experimental: it may change or be removed in a patch release.",
|
|
19
|
+
"Reads every installed icon set's data file, never the icon modules. With words it ranks icons by meaning: an icon definition the set's `map` names the icon for, then exact matches on its id or words, then a word that starts with the query, then partial matches, and for a query of several words that none of those answer, the icons that carry some of its words, rarer words counting more within a set and the words after the icon word that name a component of the project's Core (`information icon popover links`) counting only to break a tie. A word written as an export name (`SearchIcon`) also reads as its words, and the reading with the better match answers. Equal scores keep the project's set first, then integration load order; within a set, a whole-id name match before an id-part one and a meaning match by its tag position; then an icon whose id the query names in full; then id order. With `<set>/<id>` it reads one icon with every variant's import line. With `list` it lists the installed sets, how many icon definitions each one's `map` covers (built-in and all of Astryx's) and its own definitions, and any set withdrawn and why. `search()` and `astryx search` with no `type` answer from the same ranking when a query asks for an icon (one word as typed is `icon` or `icons`, an installed set's name, or an icon export name such as `SearchIcon`, and is not the name of a component or hook; an `icon` or `icons` right after `with`, with only `a`, `an` or `the` between, that no `of` or `for` follows names a feature of an answered component or template, as in `card with an icon`, and asks for none, while `card with an icon of a star` still asks): after `results` they return `icons`, `{matchCount, results}`, with at most 3 icons (fewer when `limit` is smaller), each with `domain: 'icon'`, `name` (`<set>/<id>`), `set`, `id`, `package`, `score`, `reason`, `import` and `command`; text mode lists them last, one line each. It never changes search's `results` or `matchCount`, and it is absent when no icon answers. Experimental: it may change or be removed in a patch release.",
|
|
20
20
|
importPath: '@astryxdesign/cli/api',
|
|
21
21
|
signature:
|
|
22
22
|
'icon(query?: string, options?: IconOptions): Promise<IconSearchResponse | IconDetailResponse | IconListResponse>',
|
|
@@ -69,7 +69,7 @@ export const doc = {
|
|
|
69
69
|
{
|
|
70
70
|
type: 'icon.search',
|
|
71
71
|
description:
|
|
72
|
-
"The query, how many icons matched, and the ranked matches, each with its set, id, package, module, export, import line, words, filled names, variants, reason, and score, plus `relatives` (the other definitions in the groups of the ones it draws) when there are any. A replaced definition's old name answers like its successor's name. A match that a definition names also has `meaningImport`: the import line that names the icon by that meaning (`import {TrashIcon as DeleteIcon} from '…'`), so app code keeps the name when another set draws it. No match is an empty list. When the project picks a look (`experimental.iconVariant`), a match from a set in the project's list has the module, export, and import of that look; one whose icon lacks the look keeps its own and names both looks in `look` ({asked, used}). With no icon set installed, `reason` says so, `definitions` lists the Astryx icon definitions that match ({name, builtIn, description}, plus `group` and `relatives` for a definition in a group), built-in ones first, since Core draws those by name, and `next` says how to get a set.",
|
|
72
|
+
"The query, how many icons matched, and the ranked matches, each with its set, id, package, module, export, import line, words, filled names, variants, reason, and score, plus `relatives` (the other definitions in the groups of the ones it draws) when there are any. A replaced definition's old name answers like its successor's name. A match that a definition names also has `meaningImport`: the import line that names the icon by that meaning (`import {TrashIcon as DeleteIcon} from '…'`), so app code keeps the name when another set draws it. No match is an empty list. When the project picks a look (`experimental.iconVariant`), a match from a set in the project's list has the module, export, and import of that look; one whose icon lacks the look keeps its own and names both looks in `look` ({asked, used}). With no icon set installed, `reason` says so, `definitions` lists the Astryx icon definitions that match ({name, builtIn, description}, plus `group` and `relatives` for a definition in a group), built-in ones first, since Core draws those by name; a matching definition that Core does not draw brings the built-in that draws in its place (`help` brings `info`) unless a match ranked above it has none, and `next` says how to get a set.",
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
type: 'icon.detail',
|
package/api/icon/icon.type.d.mts
CHANGED
|
@@ -786,4 +786,8 @@ export type IconIndex = {
|
|
|
786
786
|
package: string;
|
|
787
787
|
reason: string;
|
|
788
788
|
}>;
|
|
789
|
+
/**
|
|
790
|
+
* - The names of the folder's Core components, so a query's words that name one say where the icon goes, as with `icon()`.
|
|
791
|
+
*/
|
|
792
|
+
components?: string[] | undefined;
|
|
789
793
|
};
|