@astryxdesign/cli 0.7.16-canary.ge95b87c → 0.7.16
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/CHANGELOG.md +369 -0
- package/README.md +1 -1
- package/api/build/_adapter.d.mts +9 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/doctor/_adapter.d.mts +3 -2
- package/api/doctor/_adapter.mjs +7 -1
- package/api/doctor/doctor.d.mts +8 -0
- package/api/doctor/doctor.mjs +53 -8
- package/api/doctor/theme-checks.mjs +157 -8
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.mjs +16 -2
- package/api/theme/build/build.d.mts +10 -6
- package/api/theme/build/build.mjs +42 -29
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/theme.type.d.mts +39 -0
- package/api/theme/theme.type.mjs +21 -0
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme-edit/_adapter.d.mts +1 -0
- package/api/theme-edit/_adapter.mjs +79 -21
- package/api/theme-edit/_check.d.mts +25 -2
- package/api/theme-edit/_check.mjs +251 -61
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +19 -1
- package/api/theme-edit/_edit.d.mts +16 -0
- package/api/theme-edit/_edit.mjs +360 -59
- package/api/theme-edit/_how-question.d.mts +8 -0
- package/api/theme-edit/_how-question.mjs +169 -22
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_palette.d.mts +27 -0
- package/api/theme-edit/_palette.mjs +112 -8
- package/api/theme-edit/_preview-app.d.mts +46 -1
- package/api/theme-edit/_preview-app.mjs +367 -36
- package/api/theme-edit/_preview.d.mts +55 -0
- package/api/theme-edit/_preview.mjs +231 -6
- package/api/theme-edit/_project.d.mts +4 -0
- package/api/theme-edit/_project.mjs +27 -6
- package/api/theme-edit/_settings.d.mts +61 -2
- package/api/theme-edit/_settings.mjs +317 -115
- package/api/theme-edit/_tables.mjs +1 -1
- package/api/theme-edit/theme-edit.type.d.mts +30 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +9 -2
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +41 -18
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +150 -56
- package/foundation/config/project.mjs +43 -2
- package/foundation/discovery/component-discovery.mjs +6 -5
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +57 -16
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/theme-discovery.d.mts +25 -0
- package/foundation/discovery/theme-discovery.mjs +48 -7
- package/foundation/fs/gather-cache.mjs +6 -2
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/may-have-integrations.mjs +5 -2
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/package.json +6 -6
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* default naming a variant the set does not declare);
|
|
15
15
|
* `icon_builtin_definition_missing`; `icon_module_not_public`;
|
|
16
16
|
* `icon_not_component`; `icon_export_missing` (an export, the
|
|
17
|
-
* generated module,
|
|
18
|
-
* statically with re-exports followed);
|
|
19
|
-
* `
|
|
20
|
-
* theme map
|
|
21
|
-
*
|
|
17
|
+
* generated module, the adapter, or a look's theme map its module
|
|
18
|
+
* does not have, read statically with re-exports followed);
|
|
19
|
+
* `icon_module_invalid`; `icon_generated_types_mismatch`;
|
|
20
|
+
* `icon_theme_map_mismatch` (a theme map, or the theme map of a
|
|
21
|
+
* look an icon draws, whose keys or values disagree with the
|
|
22
|
+
* built-in entries of `map`, or a look's theme map the generated
|
|
23
|
+
* module lacks);
|
|
22
24
|
* warnings `icon_export_name` (an export not named `<Name>Icon`);
|
|
23
25
|
* `icon_definition_unused` and `icon_definition_shadowed` (a
|
|
24
26
|
* definition the set declares that `map` leaves out, or that has
|
|
@@ -54,12 +56,14 @@ import {inspectPackageExport} from './package-exports.mjs';
|
|
|
54
56
|
import {
|
|
55
57
|
THEME_MAP_NAME,
|
|
56
58
|
entryWiringNote,
|
|
59
|
+
generatedOrigins,
|
|
57
60
|
generatedTypesPath,
|
|
58
61
|
otherNamesOf,
|
|
59
62
|
generatedTypesText,
|
|
60
63
|
readGeneratedStatements,
|
|
61
64
|
generatedTypesMatch,
|
|
62
65
|
} from './icon-set-writer.mjs';
|
|
66
|
+
import {variantThemeMaps} from './icon-set-theme-maps.mjs';
|
|
63
67
|
import {
|
|
64
68
|
exportValueKind,
|
|
65
69
|
aliasedOrigin,
|
|
@@ -889,6 +893,8 @@ function checkExports(set, packageDir, packageName, unchecked) {
|
|
|
889
893
|
}
|
|
890
894
|
/** @type {Map<string, {file: string, name: string} | null>} */
|
|
891
895
|
const iconOrigins = new Map();
|
|
896
|
+
/** @type {Map<string, Map<string, {file: string, name: string} | null>>} each icon's variant origins, by variant */
|
|
897
|
+
const variantOrigins = new Map();
|
|
892
898
|
for (const icon of set.data.icons) {
|
|
893
899
|
const module = icon.module ?? set.data.module;
|
|
894
900
|
if (wiring && module === set.data.module) continue;
|
|
@@ -896,14 +902,20 @@ function checkExports(set, packageDir, packageName, unchecked) {
|
|
|
896
902
|
icon.id,
|
|
897
903
|
originOf(module, icon.export, `icon "${icon.id}"`, {icon: icon.id}),
|
|
898
904
|
);
|
|
905
|
+
/** @type {Map<string, {file: string, name: string} | null>} */
|
|
906
|
+
const looks = new Map();
|
|
899
907
|
for (const variant of icon.variants ?? []) {
|
|
900
|
-
|
|
901
|
-
variant.
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
908
|
+
looks.set(
|
|
909
|
+
variant.variant,
|
|
910
|
+
originOf(
|
|
911
|
+
variant.module ?? module,
|
|
912
|
+
variant.export,
|
|
913
|
+
`a variant of icon "${icon.id}"`,
|
|
914
|
+
{icon: icon.id},
|
|
915
|
+
),
|
|
905
916
|
);
|
|
906
917
|
}
|
|
918
|
+
variantOrigins.set(icon.id, looks);
|
|
907
919
|
}
|
|
908
920
|
|
|
909
921
|
/** @type {Map<string, {id: string, origin: {file: string, name: string} | null}>} */
|
|
@@ -934,67 +946,171 @@ function checkExports(set, packageDir, packageName, unchecked) {
|
|
|
934
946
|
);
|
|
935
947
|
const file = fileOf(set.data.module);
|
|
936
948
|
if (!mapOrigin || !file) return issues;
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Hold one theme map to the built-in entries of `map`: the same keys, each
|
|
952
|
+
* drawing the artwork `expected` names for it.
|
|
953
|
+
* @param {string} name the theme map's export
|
|
954
|
+
* @param {(name: string, filler: {id: string, origin: {file: string, name: string} | null}) => {origin: {file: string, name: string} | null, what: string, fix: string}} expected
|
|
955
|
+
* for each entry, the origin it must draw, what that is, and the fix
|
|
956
|
+
*/
|
|
957
|
+
const compareThemeMap = (name, expected) => {
|
|
958
|
+
const bindings = staticExportBindings(file, name);
|
|
959
|
+
// A theme map built at runtime cannot be read, so it is not checked.
|
|
960
|
+
if (!bindings) {
|
|
961
|
+
unchecked.push({
|
|
962
|
+
entry: name,
|
|
963
|
+
reason: `Theme map "${name}" is not one object literal the static reader can read, so none of its entries were checked. Export it as \`export const ${name} = {...}\` to have it checked.`,
|
|
964
|
+
});
|
|
965
|
+
return;
|
|
954
966
|
}
|
|
967
|
+
for (const key of bindings.keys()) {
|
|
968
|
+
if (!fillers.has(key)) {
|
|
969
|
+
issues.push(
|
|
970
|
+
issueError(
|
|
971
|
+
ICON_THEME_MAP_MISMATCH,
|
|
972
|
+
`${label}: theme map "${name}" has "${key}", which "map" does not map. Remove it, or add "${key}" to "map" with the id of the icon that draws it.`,
|
|
973
|
+
),
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
for (const [definition, filler] of fillers) {
|
|
978
|
+
if (!bindings.has(definition)) {
|
|
979
|
+
issues.push(
|
|
980
|
+
issueError(
|
|
981
|
+
ICON_THEME_MAP_MISMATCH,
|
|
982
|
+
`${label}: theme map "${name}" has no "${definition}", which "map" maps to icon "${filler.id}". Add it.`,
|
|
983
|
+
),
|
|
984
|
+
);
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
const value = bindings.get(definition);
|
|
988
|
+
if (!value) {
|
|
989
|
+
unchecked.push({
|
|
990
|
+
entry: definition,
|
|
991
|
+
reason: `Theme map "${name}" has an entry for "${definition}" the static reader cannot read. Write it as the icon's binding (${definition}: TrashIcon), an element (<TrashIcon />), or createElement(TrashIcon) to have it checked.`,
|
|
992
|
+
});
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
const want = expected(definition, filler);
|
|
996
|
+
if (!want.origin) continue;
|
|
997
|
+
// Compare the bindings each finally names: \`const XIcon = X\` is X. A
|
|
998
|
+
// mismatch is reported only when both are followed to their declarations.
|
|
999
|
+
const mapped = aliasedOrigin(value);
|
|
1000
|
+
const drawn = aliasedOrigin(want.origin);
|
|
1001
|
+
if (!mapped || !drawn) {
|
|
1002
|
+
unchecked.push({
|
|
1003
|
+
entry: definition,
|
|
1004
|
+
reason: `Theme map "${name}" maps "${definition}" through an alias the static reader cannot follow to its declaration, so it was not compared with ${want.what}. ${want.fix}, or alias a binding declared in this package.`,
|
|
1005
|
+
});
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
if (mapped.file !== drawn.file || mapped.name !== drawn.name) {
|
|
1009
|
+
issues.push(
|
|
1010
|
+
issueError(
|
|
1011
|
+
ICON_THEME_MAP_MISMATCH,
|
|
1012
|
+
`${label}: theme map "${name}" maps "${definition}" to other artwork than ${want.what}, which "map" names for it. ${want.fix}.`,
|
|
1013
|
+
),
|
|
1014
|
+
);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
compareThemeMap(themeMap, (_, filler) => ({
|
|
1020
|
+
origin: filler.origin,
|
|
1021
|
+
what: `icon "${filler.id}"`,
|
|
1022
|
+
fix: "Point it at the icon's export",
|
|
1023
|
+
}));
|
|
1024
|
+
|
|
1025
|
+
// A look an icon draws has its own theme map in the generated module
|
|
1026
|
+
// (`themeIconsFilled`), keyed like `themeIcons`: each entry draws the
|
|
1027
|
+
// icon's export for that variant, or its own export when it has none.
|
|
1028
|
+
const lookMaps = variantThemeMaps(set.data);
|
|
1029
|
+
if (lookMaps.length === 0) return issues;
|
|
1030
|
+
const generated = /** @type {string} */ (set.data.generated);
|
|
1031
|
+
const generatedFile = path.join(packageDir, generated);
|
|
1032
|
+
if (!fs.existsSync(generatedFile)) return issues;
|
|
1033
|
+
/** @type {string[]} */
|
|
1034
|
+
let statements;
|
|
1035
|
+
try {
|
|
1036
|
+
statements = readGeneratedStatements(
|
|
1037
|
+
fs.readFileSync(generatedFile, 'utf-8'),
|
|
1038
|
+
generated,
|
|
1039
|
+
);
|
|
1040
|
+
} catch {
|
|
1041
|
+
return issues;
|
|
955
1042
|
}
|
|
956
|
-
|
|
957
|
-
|
|
1043
|
+
const sources = generatedOrigins(packageDir, generated);
|
|
1044
|
+
const byId = new Map(set.data.icons.map(icon => [icon.id, icon]));
|
|
1045
|
+
for (const {variant, name} of lookMaps) {
|
|
1046
|
+
if (!statements.some(line => line.startsWith(`export const ${name} = `))) {
|
|
958
1047
|
issues.push(
|
|
959
1048
|
issueError(
|
|
960
1049
|
ICON_THEME_MAP_MISMATCH,
|
|
961
|
-
`${label}:
|
|
1050
|
+
`${label}: its generated module ${generated} has no theme map "${name}", which draws the built-in icons in the ${variant} look an icon draws. Rewrite the module: \`${lookRewriteCommand(set, variant, sources)}\`.`,
|
|
962
1051
|
),
|
|
963
1052
|
);
|
|
964
1053
|
continue;
|
|
965
1054
|
}
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
968
|
-
unchecked.push({
|
|
969
|
-
entry: name,
|
|
970
|
-
reason: `Theme map "${themeMap}" has an entry for "${name}" the static reader cannot read. Write it as the icon's binding (${name}: TrashIcon), an element (<TrashIcon />), or createElement(TrashIcon) to have it checked.`,
|
|
971
|
-
});
|
|
972
|
-
continue;
|
|
973
|
-
}
|
|
974
|
-
if (!filler.origin) continue;
|
|
975
|
-
// Compare the bindings each finally names: \`const XIcon = X\` is X. A
|
|
976
|
-
// mismatch is reported only when both are followed to their declarations.
|
|
977
|
-
const mapped = aliasedOrigin(value);
|
|
978
|
-
const drawn = aliasedOrigin(filler.origin);
|
|
979
|
-
if (!mapped || !drawn) {
|
|
1055
|
+
const found = exportOriginVerdict(file, name);
|
|
1056
|
+
if (found?.verdict === 'unknown') {
|
|
980
1057
|
unchecked.push({
|
|
981
1058
|
entry: name,
|
|
982
|
-
reason: `Theme map "${
|
|
1059
|
+
reason: `Theme map "${name}" is in ${generated}, but this check could not prove "${set.data.module}" exports it: ${found.reason}`,
|
|
983
1060
|
});
|
|
984
1061
|
continue;
|
|
985
1062
|
}
|
|
986
|
-
if (
|
|
1063
|
+
if (found?.verdict !== 'exports') {
|
|
987
1064
|
issues.push(
|
|
988
1065
|
issueError(
|
|
989
|
-
|
|
990
|
-
`${label}: theme map "${
|
|
1066
|
+
ICON_EXPORT_MISSING,
|
|
1067
|
+
`${label}: theme map "${name}" is in ${generated}, but "${set.data.module}" does not export it. Export it from the package's entry, as it exports "${themeMap}".`,
|
|
991
1068
|
),
|
|
992
1069
|
);
|
|
1070
|
+
continue;
|
|
993
1071
|
}
|
|
1072
|
+
compareThemeMap(name, (_, filler) => {
|
|
1073
|
+
const icon = byId.get(filler.id);
|
|
1074
|
+
const own = icon?.variants?.find(each => each.variant === variant);
|
|
1075
|
+
return own
|
|
1076
|
+
? {
|
|
1077
|
+
origin: variantOrigins.get(filler.id)?.get(variant) ?? null,
|
|
1078
|
+
what: `the ${variant} variant of icon "${filler.id}"`,
|
|
1079
|
+
fix: `Point it at ${own.export}, the icon's ${variant} export`,
|
|
1080
|
+
}
|
|
1081
|
+
: {
|
|
1082
|
+
origin: filler.origin,
|
|
1083
|
+
what: `icon "${filler.id}", which has no ${variant} variant`,
|
|
1084
|
+
fix: "Point it at the icon's export",
|
|
1085
|
+
};
|
|
1086
|
+
});
|
|
994
1087
|
}
|
|
995
1088
|
return issues;
|
|
996
1089
|
}
|
|
997
1090
|
|
|
1091
|
+
/**
|
|
1092
|
+
* The command that rewrites a set's generated module with its theme map for
|
|
1093
|
+
* one look: `add --variant <variant> --all` from the module most of that
|
|
1094
|
+
* look's exports come from, which writes the module again.
|
|
1095
|
+
* @param {DiscoveredIconSet} set
|
|
1096
|
+
* @param {string} variant
|
|
1097
|
+
* @param {Map<string, {module: string, source: string, adapt: boolean}>} origins
|
|
1098
|
+
* where each export of the generated module comes from
|
|
1099
|
+
*/
|
|
1100
|
+
function lookRewriteCommand(set, variant, origins) {
|
|
1101
|
+
/** @type {Map<string, number>} */
|
|
1102
|
+
const counts = new Map();
|
|
1103
|
+
for (const icon of set.data.icons) {
|
|
1104
|
+
const own = icon.variants?.find(each => each.variant === variant);
|
|
1105
|
+
const from = own ? origins.get(own.export)?.module : undefined;
|
|
1106
|
+
if (from) counts.set(from, (counts.get(from) ?? 0) + 1);
|
|
1107
|
+
}
|
|
1108
|
+
const module = [...counts].sort(
|
|
1109
|
+
(a, b) => b[1] - a[1] || a[0].localeCompare(b[0]),
|
|
1110
|
+
)[0]?.[0];
|
|
1111
|
+
return `astryx experimental icon add --variant ${shellArg(variant)} --from ${module ? shellArg(module) : '<module>'} --all --set ${shellArg(set.name)}`;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
998
1114
|
/** The lowest search score a find hint needs: a whole word or a word start. */
|
|
999
1115
|
const FIND_FLOOR = 60;
|
|
1000
1116
|
|
|
@@ -68,6 +68,10 @@ export function hasLicenseNotice(dir: string): boolean;
|
|
|
68
68
|
* @property {DiscoveredIconSet[]} [order] the sets a template icon is looked
|
|
69
69
|
* up in, in order: the main set, then each backup that resolves. Present
|
|
70
70
|
* only when the main set is selected
|
|
71
|
+
* @property {string} [variant] the look every icon draws, as
|
|
72
|
+
* `experimental.iconVariant` names it: each set in the list draws its
|
|
73
|
+
* variant of that name, or its default look when it declares none. Present
|
|
74
|
+
* only when `experimental.iconSet` and `experimental.iconVariant` are set
|
|
71
75
|
* @property {string} reason one sentence saying why
|
|
72
76
|
*/
|
|
73
77
|
/**
|
|
@@ -140,17 +144,38 @@ export function withdrawnNamed(withdrawn: WithdrawnIconSet[], selector: string):
|
|
|
140
144
|
* @returns {string[]}
|
|
141
145
|
*/
|
|
142
146
|
export function iconSetList(configured: string | readonly string[] | undefined): string[];
|
|
147
|
+
/**
|
|
148
|
+
* The `experimental icon use` command for a main set, its backups in order,
|
|
149
|
+
* and the project's look. `use` writes the whole choice, so a printed
|
|
150
|
+
* command that left out a backup or the look would remove it.
|
|
151
|
+
* @param {string} main
|
|
152
|
+
* @param {readonly string[]} backups
|
|
153
|
+
* @param {string | null} [variant]
|
|
154
|
+
* @returns {string}
|
|
155
|
+
*/
|
|
156
|
+
export function iconUseCommand(main: string, backups: readonly string[], variant?: string | null): string;
|
|
157
|
+
/**
|
|
158
|
+
* The look a set's icons draw when the project picks a variant: that
|
|
159
|
+
* variant when the set declares it, else the set's default look, null for a
|
|
160
|
+
* set with one look.
|
|
161
|
+
* @param {DiscoveredIconSet} set
|
|
162
|
+
* @param {string} variant
|
|
163
|
+
* @returns {string | null}
|
|
164
|
+
*/
|
|
165
|
+
export function iconSetLook(set: DiscoveredIconSet, variant: string): string | null;
|
|
143
166
|
/**
|
|
144
167
|
* Installed sets the project's list leaves out: the problem, and the fix that
|
|
145
|
-
* adds them as backups after the list's own
|
|
146
|
-
* use` print the same words. Every set is
|
|
147
|
-
* when no other installed set has that
|
|
168
|
+
* adds them as backups after the list's own, keeping the project's look.
|
|
169
|
+
* Doctor and `experimental icon use` print the same words. Every set is
|
|
170
|
+
* named the same way: by its name when no other installed set has that
|
|
171
|
+
* name, else as `<package>/<set>`.
|
|
148
172
|
* @param {Array<{package: string, name: string}>} installed every installed set
|
|
149
173
|
* @param {{package: string, name: string}} main the list's main set
|
|
150
174
|
* @param {Array<{package: string, name: string}>} backups the list's
|
|
151
175
|
* backups, in order
|
|
152
176
|
* @param {Array<{package: string, name: string}>} unlisted the installed
|
|
153
177
|
* sets the list leaves out
|
|
178
|
+
* @param {string | null} [variant] the project's look
|
|
154
179
|
* @returns {{problem: string, command: string, fix: string}}
|
|
155
180
|
*/
|
|
156
181
|
export function unlistedIconSets(installed: Array<{
|
|
@@ -165,7 +190,7 @@ export function unlistedIconSets(installed: Array<{
|
|
|
165
190
|
}>, unlisted: Array<{
|
|
166
191
|
package: string;
|
|
167
192
|
name: string;
|
|
168
|
-
}
|
|
193
|
+
}>, variant?: string | null): {
|
|
169
194
|
problem: string;
|
|
170
195
|
command: string;
|
|
171
196
|
fix: string;
|
|
@@ -179,9 +204,10 @@ export function unlistedIconSets(installed: Array<{
|
|
|
179
204
|
* @param {DiscoveredIconSet[]} sets installed sets, in integration load order
|
|
180
205
|
* @param {string | readonly string[] | undefined} configured the `experimental.iconSet` config value
|
|
181
206
|
* @param {WithdrawnIconSet[]} [withdrawn] installed sets that were withdrawn
|
|
207
|
+
* @param {string} [variant] the `experimental.iconVariant` config value
|
|
182
208
|
* @returns {IconSetChoice}
|
|
183
209
|
*/
|
|
184
|
-
export function chooseProjectIconSet(sets: DiscoveredIconSet[], configured: string | readonly string[] | undefined, withdrawn?: WithdrawnIconSet[]): IconSetChoice;
|
|
210
|
+
export function chooseProjectIconSet(sets: DiscoveredIconSet[], configured: string | readonly string[] | undefined, withdrawn?: WithdrawnIconSet[], variant?: string): IconSetChoice;
|
|
185
211
|
/**
|
|
186
212
|
* A set's full name, `<package>/<set>`.
|
|
187
213
|
* @param {{package: string, name: string}} set
|
|
@@ -318,6 +344,13 @@ export type IconSetChoice = {
|
|
|
318
344
|
* only when the main set is selected
|
|
319
345
|
*/
|
|
320
346
|
order?: DiscoveredIconSet[] | undefined;
|
|
347
|
+
/**
|
|
348
|
+
* the look every icon draws, as
|
|
349
|
+
* `experimental.iconVariant` names it: each set in the list draws its
|
|
350
|
+
* variant of that name, or its default look when it declares none. Present
|
|
351
|
+
* only when `experimental.iconSet` and `experimental.iconVariant` are set
|
|
352
|
+
*/
|
|
353
|
+
variant?: string | undefined;
|
|
321
354
|
/**
|
|
322
355
|
* one sentence saying why
|
|
323
356
|
*/
|
|
@@ -125,6 +125,10 @@ export function hasLicenseNotice(dir) {
|
|
|
125
125
|
* @property {DiscoveredIconSet[]} [order] the sets a template icon is looked
|
|
126
126
|
* up in, in order: the main set, then each backup that resolves. Present
|
|
127
127
|
* only when the main set is selected
|
|
128
|
+
* @property {string} [variant] the look every icon draws, as
|
|
129
|
+
* `experimental.iconVariant` names it: each set in the list draws its
|
|
130
|
+
* variant of that name, or its default look when it declares none. Present
|
|
131
|
+
* only when `experimental.iconSet` and `experimental.iconVariant` are set
|
|
128
132
|
* @property {string} reason one sentence saying why
|
|
129
133
|
*/
|
|
130
134
|
|
|
@@ -473,20 +477,49 @@ function resolveSelector(sets, selector, withdrawn) {
|
|
|
473
477
|
export const ICON_USE_ORDER_COMMAND =
|
|
474
478
|
'astryx experimental icon use <main> --backup <set>';
|
|
475
479
|
|
|
480
|
+
/**
|
|
481
|
+
* The `experimental icon use` command for a main set, its backups in order,
|
|
482
|
+
* and the project's look. `use` writes the whole choice, so a printed
|
|
483
|
+
* command that left out a backup or the look would remove it.
|
|
484
|
+
* @param {string} main
|
|
485
|
+
* @param {readonly string[]} backups
|
|
486
|
+
* @param {string | null} [variant]
|
|
487
|
+
* @returns {string}
|
|
488
|
+
*/
|
|
489
|
+
export function iconUseCommand(main, backups, variant) {
|
|
490
|
+
return `astryx experimental icon use ${main}${backups.map(each => ` --backup ${each}`).join('')}${variant ? ` --variant ${variant}` : ''}`;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* The look a set's icons draw when the project picks a variant: that
|
|
495
|
+
* variant when the set declares it, else the set's default look, null for a
|
|
496
|
+
* set with one look.
|
|
497
|
+
* @param {DiscoveredIconSet} set
|
|
498
|
+
* @param {string} variant
|
|
499
|
+
* @returns {string | null}
|
|
500
|
+
*/
|
|
501
|
+
export function iconSetLook(set, variant) {
|
|
502
|
+
return (set.data.variants ?? []).includes(variant)
|
|
503
|
+
? variant
|
|
504
|
+
: (set.data.default?.variant ?? null);
|
|
505
|
+
}
|
|
506
|
+
|
|
476
507
|
/**
|
|
477
508
|
* Installed sets the project's list leaves out: the problem, and the fix that
|
|
478
|
-
* adds them as backups after the list's own
|
|
479
|
-
* use` print the same words. Every set is
|
|
480
|
-
* when no other installed set has that
|
|
509
|
+
* adds them as backups after the list's own, keeping the project's look.
|
|
510
|
+
* Doctor and `experimental icon use` print the same words. Every set is
|
|
511
|
+
* named the same way: by its name when no other installed set has that
|
|
512
|
+
* name, else as `<package>/<set>`.
|
|
481
513
|
* @param {Array<{package: string, name: string}>} installed every installed set
|
|
482
514
|
* @param {{package: string, name: string}} main the list's main set
|
|
483
515
|
* @param {Array<{package: string, name: string}>} backups the list's
|
|
484
516
|
* backups, in order
|
|
485
517
|
* @param {Array<{package: string, name: string}>} unlisted the installed
|
|
486
518
|
* sets the list leaves out
|
|
519
|
+
* @param {string | null} [variant] the project's look
|
|
487
520
|
* @returns {{problem: string, command: string, fix: string}}
|
|
488
521
|
*/
|
|
489
|
-
export function unlistedIconSets(installed, main, backups, unlisted) {
|
|
522
|
+
export function unlistedIconSets(installed, main, backups, unlisted, variant) {
|
|
490
523
|
/** @param {{package: string, name: string}} set */
|
|
491
524
|
const named = set =>
|
|
492
525
|
installed.filter(each => each.name === set.name).length > 1
|
|
@@ -494,7 +527,11 @@ export function unlistedIconSets(installed, main, backups, unlisted) {
|
|
|
494
527
|
: set.name;
|
|
495
528
|
const left = unlisted.map(named);
|
|
496
529
|
const them = left.length === 1 ? 'it' : 'them';
|
|
497
|
-
const command =
|
|
530
|
+
const command = iconUseCommand(
|
|
531
|
+
named(main),
|
|
532
|
+
[...backups.map(named), ...left],
|
|
533
|
+
variant,
|
|
534
|
+
);
|
|
498
535
|
return {
|
|
499
536
|
problem: `${installed.length} icon sets are installed and ${left.join(', ')} ${left.length === 1 ? 'is' : 'are'} not in your list`,
|
|
500
537
|
command,
|
|
@@ -511,9 +548,15 @@ export function unlistedIconSets(installed, main, backups, unlisted) {
|
|
|
511
548
|
* @param {DiscoveredIconSet[]} sets installed sets, in integration load order
|
|
512
549
|
* @param {string | readonly string[] | undefined} configured the `experimental.iconSet` config value
|
|
513
550
|
* @param {WithdrawnIconSet[]} [withdrawn] installed sets that were withdrawn
|
|
551
|
+
* @param {string} [variant] the `experimental.iconVariant` config value
|
|
514
552
|
* @returns {IconSetChoice}
|
|
515
553
|
*/
|
|
516
|
-
export function chooseProjectIconSet(
|
|
554
|
+
export function chooseProjectIconSet(
|
|
555
|
+
sets,
|
|
556
|
+
configured,
|
|
557
|
+
withdrawn = [],
|
|
558
|
+
variant = undefined,
|
|
559
|
+
) {
|
|
517
560
|
const [main, ...rest] = iconSetList(configured);
|
|
518
561
|
if (main) {
|
|
519
562
|
const resolved = resolveSelector(sets, main, withdrawn);
|
|
@@ -528,6 +571,7 @@ export function chooseProjectIconSet(sets, configured, withdrawn = []) {
|
|
|
528
571
|
...(resolved.set ? {set: resolved.set} : {}),
|
|
529
572
|
configured: main,
|
|
530
573
|
...(backups.length > 0 ? {backups} : {}),
|
|
574
|
+
...(variant ? {variant} : {}),
|
|
531
575
|
reason: resolved.reason,
|
|
532
576
|
};
|
|
533
577
|
if (resolved.set) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The name of the theme map that draws one look: `themeIcons`, then the
|
|
6
|
+
* variant's name in PascalCase (`filled` is `themeIconsFilled`), the way
|
|
7
|
+
* a variant's icon export takes it (`TrashFilledIcon`).
|
|
8
|
+
* @param {string} variant one of the set's declared variants
|
|
9
|
+
*/
|
|
10
|
+
export function variantThemeMapName(variant: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The theme maps the generated module writes beside `themeIcons`: one for
|
|
13
|
+
* each variant the set declares, other than its default, that an icon
|
|
14
|
+
* draws. Empty for a set without a generated module, or whose `themeMap` is
|
|
15
|
+
* not `themeIcons`: the CLI writes only that map.
|
|
16
|
+
* @param {IconSetData} data
|
|
17
|
+
* @returns {Array<{variant: string, name: string}>}
|
|
18
|
+
*/
|
|
19
|
+
export function variantThemeMaps(data: IconSetData): Array<{
|
|
20
|
+
variant: string;
|
|
21
|
+
name: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* The theme map that draws a set's built-in icons in one look: the set's
|
|
25
|
+
* `themeMap` for its default look, and for a look no icon draws (every entry
|
|
26
|
+
* is then the icon's own export); the look's own map when the generated
|
|
27
|
+
* module writes one. Null when the set names no theme map, or when an icon
|
|
28
|
+
* draws the look and the set's theme map is one the CLI does not write.
|
|
29
|
+
* @param {IconSetData} data
|
|
30
|
+
* @param {string | null | undefined} variant
|
|
31
|
+
* @returns {string | null}
|
|
32
|
+
*/
|
|
33
|
+
export function lookThemeMap(data: IconSetData, variant: string | null | undefined): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The export one icon draws a look with: its export for that variant, or its
|
|
36
|
+
* own export when it has none.
|
|
37
|
+
* @param {import('../../authoring/doctypes/icon-set/type').IconSetIcon} icon
|
|
38
|
+
* @param {string} variant
|
|
39
|
+
*/
|
|
40
|
+
export function lookExport(icon: import("../../authoring/doctypes/icon-set/type").IconSetIcon, variant: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* @file The theme maps a generated icon module writes: one for the set's
|
|
43
|
+
* default look, and one for each other look an icon draws.
|
|
44
|
+
*
|
|
45
|
+
* A theme map is keyed by the built-in icon definitions the set maps. The
|
|
46
|
+
* default one, `themeIcons`, draws each icon's own export. A look's map,
|
|
47
|
+
* `themeIcons<Variant>` (`themeIconsFilled`), draws each icon's export for
|
|
48
|
+
* that variant, or the icon's own export when it has none, so a theme that
|
|
49
|
+
* takes it draws every built-in icon in that look where the set has it.
|
|
50
|
+
*
|
|
51
|
+
* @input A set's data file
|
|
52
|
+
* @output The theme maps' names and which one draws a look
|
|
53
|
+
* @position packages/cli/foundation/discovery — read by the icon-set writer,
|
|
54
|
+
* `integration check`, and `astryx experimental icon use`
|
|
55
|
+
*/
|
|
56
|
+
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
|
|
57
|
+
/** The theme map the generated module writes for the default look. */
|
|
58
|
+
export const THEME_MAP_NAME: "themeIcons";
|
|
59
|
+
export type IconSetData = import("../../authoring/doctypes/icon-set/type").IconSetData;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The theme maps a generated icon module writes: one for the set's
|
|
5
|
+
* default look, and one for each other look an icon draws.
|
|
6
|
+
*
|
|
7
|
+
* A theme map is keyed by the built-in icon definitions the set maps. The
|
|
8
|
+
* default one, `themeIcons`, draws each icon's own export. A look's map,
|
|
9
|
+
* `themeIcons<Variant>` (`themeIconsFilled`), draws each icon's export for
|
|
10
|
+
* that variant, or the icon's own export when it has none, so a theme that
|
|
11
|
+
* takes it draws every built-in icon in that look where the set has it.
|
|
12
|
+
*
|
|
13
|
+
* @input A set's data file
|
|
14
|
+
* @output The theme maps' names and which one draws a look
|
|
15
|
+
* @position packages/cli/foundation/discovery — read by the icon-set writer,
|
|
16
|
+
* `integration check`, and `astryx experimental icon use`
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
|
|
20
|
+
|
|
21
|
+
/** The theme map the generated module writes for the default look. */
|
|
22
|
+
export const THEME_MAP_NAME = 'themeIcons';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The name of the theme map that draws one look: `themeIcons`, then the
|
|
26
|
+
* variant's name in PascalCase (`filled` is `themeIconsFilled`), the way
|
|
27
|
+
* a variant's icon export takes it (`TrashFilledIcon`).
|
|
28
|
+
* @param {string} variant one of the set's declared variants
|
|
29
|
+
*/
|
|
30
|
+
export function variantThemeMapName(variant) {
|
|
31
|
+
return `${THEME_MAP_NAME}${variant
|
|
32
|
+
.split('-')
|
|
33
|
+
.map(part => (part ? part[0].toUpperCase() + part.slice(1) : ''))
|
|
34
|
+
.join('')}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The variants at least one icon of the set draws with its own export.
|
|
39
|
+
* @param {IconSetData} data
|
|
40
|
+
* @returns {Set<string>}
|
|
41
|
+
*/
|
|
42
|
+
function drawnVariants(data) {
|
|
43
|
+
return new Set(
|
|
44
|
+
data.icons.flatMap(icon => (icon.variants ?? []).map(each => each.variant)),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The theme maps the generated module writes beside `themeIcons`: one for
|
|
50
|
+
* each variant the set declares, other than its default, that an icon
|
|
51
|
+
* draws. Empty for a set without a generated module, or whose `themeMap` is
|
|
52
|
+
* not `themeIcons`: the CLI writes only that map.
|
|
53
|
+
* @param {IconSetData} data
|
|
54
|
+
* @returns {Array<{variant: string, name: string}>}
|
|
55
|
+
*/
|
|
56
|
+
export function variantThemeMaps(data) {
|
|
57
|
+
if (!data.generated || data.themeMap !== THEME_MAP_NAME) return [];
|
|
58
|
+
const drawn = drawnVariants(data);
|
|
59
|
+
return (data.variants ?? [])
|
|
60
|
+
.filter(variant => variant !== data.default?.variant && drawn.has(variant))
|
|
61
|
+
.map(variant => ({variant, name: variantThemeMapName(variant)}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The theme map that draws a set's built-in icons in one look: the set's
|
|
66
|
+
* `themeMap` for its default look, and for a look no icon draws (every entry
|
|
67
|
+
* is then the icon's own export); the look's own map when the generated
|
|
68
|
+
* module writes one. Null when the set names no theme map, or when an icon
|
|
69
|
+
* draws the look and the set's theme map is one the CLI does not write.
|
|
70
|
+
* @param {IconSetData} data
|
|
71
|
+
* @param {string | null | undefined} variant
|
|
72
|
+
* @returns {string | null}
|
|
73
|
+
*/
|
|
74
|
+
export function lookThemeMap(data, variant) {
|
|
75
|
+
if (!data.themeMap) return null;
|
|
76
|
+
if (variant == null || variant === data.default?.variant) {
|
|
77
|
+
return data.themeMap;
|
|
78
|
+
}
|
|
79
|
+
const own = variantThemeMaps(data).find(each => each.variant === variant);
|
|
80
|
+
if (own) return own.name;
|
|
81
|
+
return drawnVariants(data).has(variant) ? null : data.themeMap;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The export one icon draws a look with: its export for that variant, or its
|
|
86
|
+
* own export when it has none.
|
|
87
|
+
* @param {import('../../authoring/doctypes/icon-set/type').IconSetIcon} icon
|
|
88
|
+
* @param {string} variant
|
|
89
|
+
*/
|
|
90
|
+
export function lookExport(icon, variant) {
|
|
91
|
+
return (
|
|
92
|
+
(icon.variants ?? []).find(each => each.variant === variant)?.export ??
|
|
93
|
+
icon.export
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -634,7 +634,6 @@ export function iconsWithWord(set: {
|
|
|
634
634
|
* @returns {string | null}
|
|
635
635
|
*/
|
|
636
636
|
export function localSourceNote(packageDir: string, module: string): string | null;
|
|
637
|
-
export { generatedTypesPath };
|
|
638
637
|
/** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
|
|
639
638
|
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
|
|
640
639
|
/**
|
|
@@ -656,8 +655,6 @@ export class IconSetAuthoringError extends Error {
|
|
|
656
655
|
reason: string;
|
|
657
656
|
}[];
|
|
658
657
|
}
|
|
659
|
-
/** The theme map the generated module writes. */
|
|
660
|
-
export const THEME_MAP_NAME: "themeIcons";
|
|
661
658
|
/**
|
|
662
659
|
* One icon a library gives.
|
|
663
660
|
*/
|
|
@@ -743,3 +740,5 @@ export type GeneratedIcon = {
|
|
|
743
740
|
adapt: boolean;
|
|
744
741
|
};
|
|
745
742
|
import { generatedTypesPath } from './icon-set-paths.mjs';
|
|
743
|
+
import { THEME_MAP_NAME } from './icon-set-theme-maps.mjs';
|
|
744
|
+
export { generatedTypesPath, THEME_MAP_NAME };
|