@astryxdesign/cli 0.6.6-canary.9613feb → 0.6.6-canary.bbeffca
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 +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.mjs +5 -3
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/init/run/run.mjs +1 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/template.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +4 -1
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
|
@@ -74,7 +74,11 @@ import {
|
|
|
74
74
|
collectThemingTargets,
|
|
75
75
|
targetValidationRegistry,
|
|
76
76
|
} from '../../../foundation/discovery/theming-targets.mjs';
|
|
77
|
-
import {
|
|
77
|
+
import {
|
|
78
|
+
collectUnloadedFonts,
|
|
79
|
+
formatBatchFontLoadingHelp,
|
|
80
|
+
formatFontLoadingHelp,
|
|
81
|
+
} from './font-warning.mjs';
|
|
78
82
|
import {interceptCore} from './core-interception.mjs';
|
|
79
83
|
import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
|
|
80
84
|
import {resolveIconImports} from './icon-imports.mjs';
|
|
@@ -2339,6 +2343,7 @@ async function themeBuildInternal(
|
|
|
2339
2343
|
file,
|
|
2340
2344
|
options = {},
|
|
2341
2345
|
{cwd = process.cwd()} = {},
|
|
2346
|
+
/** @type {{compact?: boolean, trailers?: ThemeBuildTrailer[]}} */ report = {},
|
|
2342
2347
|
) {
|
|
2343
2348
|
const filePath = path.resolve(cwd, file);
|
|
2344
2349
|
|
|
@@ -2350,7 +2355,11 @@ async function themeBuildInternal(
|
|
|
2350
2355
|
);
|
|
2351
2356
|
}
|
|
2352
2357
|
|
|
2353
|
-
|
|
2358
|
+
if (!report.compact) {
|
|
2359
|
+
logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
|
|
2360
|
+
}
|
|
2361
|
+
// A compact report has no per-theme heading, so each warning names its file.
|
|
2362
|
+
const source = report.compact ? `${path.relative(cwd, filePath)}: ` : '';
|
|
2354
2363
|
|
|
2355
2364
|
await selectCore(cwd);
|
|
2356
2365
|
|
|
@@ -2469,18 +2478,18 @@ async function themeBuildInternal(
|
|
|
2469
2478
|
const noticeMessages = [];
|
|
2470
2479
|
for (const w of warnings) {
|
|
2471
2480
|
warningMessages.push(w);
|
|
2472
|
-
logger.warn(` [warn] ${w}`);
|
|
2481
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2473
2482
|
}
|
|
2474
2483
|
|
|
2475
2484
|
// Validate no private vars are set directly
|
|
2476
2485
|
const privateVarErrors = validatePrivateVars(themeDef);
|
|
2477
2486
|
for (const e of privateVarErrors) {
|
|
2478
2487
|
warningMessages.push(e);
|
|
2479
|
-
logger.error(` [error] ${e}`);
|
|
2488
|
+
logger.error(` [error] ${source}${e}`);
|
|
2480
2489
|
}
|
|
2481
2490
|
if (privateVarErrors.length > 0) {
|
|
2482
2491
|
logger.error(
|
|
2483
|
-
`\n ${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2492
|
+
`\n ${source}${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2484
2493
|
);
|
|
2485
2494
|
}
|
|
2486
2495
|
|
|
@@ -2719,7 +2728,7 @@ async function themeBuildInternal(
|
|
|
2719
2728
|
for (const message of droppedDeclarations) {
|
|
2720
2729
|
const w = `Declaration ${message}. The generated CSS omits it; fix the value in the theme source.`;
|
|
2721
2730
|
warningMessages.push(w);
|
|
2722
|
-
logger.warn(` [warn] ${w}`);
|
|
2731
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2723
2732
|
}
|
|
2724
2733
|
const unemittedHeadingTypes = headingTypesWithoutEmittedRule(
|
|
2725
2734
|
customHeadingTypes(themeDef),
|
|
@@ -2741,7 +2750,7 @@ async function themeBuildInternal(
|
|
|
2741
2750
|
);
|
|
2742
2751
|
}
|
|
2743
2752
|
if (cssParts.length === 0) {
|
|
2744
|
-
logger.log(
|
|
2753
|
+
logger.log(`${source}No overrides found; nothing to build.`);
|
|
2745
2754
|
return null;
|
|
2746
2755
|
}
|
|
2747
2756
|
// The data-token defaults are theme-independent and go in @layer
|
|
@@ -2933,19 +2942,21 @@ async function themeBuildInternal(
|
|
|
2933
2942
|
|
|
2934
2943
|
writeBuildOutputs(writes);
|
|
2935
2944
|
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2940
|
-
);
|
|
2941
|
-
logger.log(` ${size} KB`);
|
|
2942
|
-
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2943
|
-
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2944
|
-
if (variantDtsPath && variantDecl) {
|
|
2945
|
-
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2945
|
+
if (!report.compact) {
|
|
2946
|
+
logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
|
|
2947
|
+
logger.log(`[ok] ${path.relative(cwd, cssDtsPath)}`);
|
|
2946
2948
|
logger.log(
|
|
2947
|
-
`
|
|
2949
|
+
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2948
2950
|
);
|
|
2951
|
+
logger.log(` ${size} KB`);
|
|
2952
|
+
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2953
|
+
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2954
|
+
if (variantDtsPath && variantDecl) {
|
|
2955
|
+
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2956
|
+
logger.log(
|
|
2957
|
+
`[ok] ${path.relative(cwd, variantDtsPath)} (${augCount} type augmentations)`,
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2949
2960
|
}
|
|
2950
2961
|
|
|
2951
2962
|
const relOutDir = path.relative(cwd, outDir) || '.';
|
|
@@ -2953,25 +2964,6 @@ async function themeBuildInternal(
|
|
|
2953
2964
|
const jsImport = importSpecifier(relOutDir, baseName);
|
|
2954
2965
|
const cssImport = importSpecifier(relOutDir, cssBase) + '.css';
|
|
2955
2966
|
const exportName = `${toIdentifier(baseName)}Theme`;
|
|
2956
|
-
logger.log(`
|
|
2957
|
-
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
2958
|
-
|
|
2959
|
-
import { ${exportName} } from '${jsImport}';
|
|
2960
|
-
import '${cssImport}';
|
|
2961
|
-
|
|
2962
|
-
<Theme theme={${exportName}}>
|
|
2963
|
-
<App />
|
|
2964
|
-
</Theme>
|
|
2965
|
-
|
|
2966
|
-
Or with a <link> tag:
|
|
2967
|
-
|
|
2968
|
-
import { ${exportName} } from '${jsImport}';
|
|
2969
|
-
|
|
2970
|
-
<link rel="stylesheet" href="${cssImport}" />
|
|
2971
|
-
<Theme theme={${exportName}}>
|
|
2972
|
-
<App />
|
|
2973
|
-
</Theme>
|
|
2974
|
-
`);
|
|
2975
2967
|
|
|
2976
2968
|
// Fonts the theme names but nothing loads (#5015). Resolved tokens and
|
|
2977
2969
|
// component overrides carry the final font-family values on both load
|
|
@@ -2985,15 +2977,27 @@ Or with a <link> tag:
|
|
|
2985
2977
|
// permanently in violation of its own "compiles with no warnings" guard).
|
|
2986
2978
|
// Adaptation rules are resolved theme writes in their own right, so a family
|
|
2987
2979
|
// named only inside one needs the same notice as one named at the root.
|
|
2980
|
+
/** @type {string[]} */
|
|
2981
|
+
const fontNotices = [];
|
|
2988
2982
|
for (const family of unloadedFonts) {
|
|
2989
2983
|
const msg = `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`;
|
|
2990
2984
|
noticeMessages.push(msg);
|
|
2991
|
-
|
|
2992
|
-
}
|
|
2993
|
-
if (unloadedFonts.length > 0) {
|
|
2994
|
-
logger.log(formatFontLoadingHelp(themeDef.name, unloadedFonts));
|
|
2985
|
+
fontNotices.push(msg);
|
|
2995
2986
|
}
|
|
2996
2987
|
|
|
2988
|
+
/** @type {ThemeBuildTrailer} */
|
|
2989
|
+
const trailer = {
|
|
2990
|
+
themeName: themeDef.name,
|
|
2991
|
+
exportName,
|
|
2992
|
+
jsImport,
|
|
2993
|
+
cssImport,
|
|
2994
|
+
unloadedFonts,
|
|
2995
|
+
fontNotices,
|
|
2996
|
+
};
|
|
2997
|
+
// A batch or compact report prints this once for the whole run instead.
|
|
2998
|
+
if (report.trailers) report.trailers.push(trailer);
|
|
2999
|
+
else printBuildTrailer(trailer);
|
|
3000
|
+
|
|
2997
3001
|
return {
|
|
2998
3002
|
type: 'theme.build',
|
|
2999
3003
|
data: {
|
|
@@ -3016,6 +3020,166 @@ Or with a <link> tag:
|
|
|
3016
3020
|
};
|
|
3017
3021
|
}
|
|
3018
3022
|
|
|
3023
|
+
/**
|
|
3024
|
+
* What a standalone build prints after its [ok] lines, kept as data so a
|
|
3025
|
+
* batch can print it once for every theme.
|
|
3026
|
+
* @typedef {object} ThemeBuildTrailer
|
|
3027
|
+
* @property {string} themeName The theme's name.
|
|
3028
|
+
* @property {string} exportName The built module's theme export.
|
|
3029
|
+
* @property {string} jsImport Import specifier of the built JS module.
|
|
3030
|
+
* @property {string} cssImport Import specifier of the built CSS.
|
|
3031
|
+
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
3032
|
+
* @property {string[]} fontNotices One notice per unloaded font family.
|
|
3033
|
+
*/
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* Print a standalone build's install snippet and font guidance.
|
|
3037
|
+
* @param {ThemeBuildTrailer} trailer
|
|
3038
|
+
*/
|
|
3039
|
+
function printBuildTrailer(trailer) {
|
|
3040
|
+
logger.log(`
|
|
3041
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3042
|
+
|
|
3043
|
+
import { Theme } from '@astryxdesign/core';
|
|
3044
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3045
|
+
import '${trailer.cssImport}';
|
|
3046
|
+
|
|
3047
|
+
<Theme theme={${trailer.exportName}}>
|
|
3048
|
+
<App />
|
|
3049
|
+
</Theme>
|
|
3050
|
+
|
|
3051
|
+
Or with a <link> tag:
|
|
3052
|
+
|
|
3053
|
+
import { Theme } from '@astryxdesign/core';
|
|
3054
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3055
|
+
|
|
3056
|
+
<link rel="stylesheet" href="${trailer.cssImport}" />
|
|
3057
|
+
<Theme theme={${trailer.exportName}}>
|
|
3058
|
+
<App />
|
|
3059
|
+
</Theme>
|
|
3060
|
+
`);
|
|
3061
|
+
for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
|
|
3062
|
+
if (trailer.unloadedFonts.length > 0) {
|
|
3063
|
+
logger.log(formatFontLoadingHelp(trailer.themeName, trailer.unloadedFonts));
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* Print the install snippet and font guidance once for a batch: the first
|
|
3069
|
+
* theme as the full example, one import line per built theme, and one font
|
|
3070
|
+
* recipe naming every family the themes do not load.
|
|
3071
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3072
|
+
*/
|
|
3073
|
+
export function printBatchTrailer(trailers) {
|
|
3074
|
+
if (trailers.length === 0) return;
|
|
3075
|
+
const [first] = trailers;
|
|
3076
|
+
logger.log(`
|
|
3077
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3078
|
+
|
|
3079
|
+
import { Theme } from '@astryxdesign/core';
|
|
3080
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3081
|
+
import '${first.cssImport}';
|
|
3082
|
+
|
|
3083
|
+
<Theme theme={${first.exportName}}>
|
|
3084
|
+
<App />
|
|
3085
|
+
</Theme>
|
|
3086
|
+
|
|
3087
|
+
Or with a <link> tag:
|
|
3088
|
+
|
|
3089
|
+
import { Theme } from '@astryxdesign/core';
|
|
3090
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3091
|
+
|
|
3092
|
+
<link rel="stylesheet" href="${first.cssImport}" />
|
|
3093
|
+
<Theme theme={${first.exportName}}>
|
|
3094
|
+
<App />
|
|
3095
|
+
</Theme>
|
|
3096
|
+
`);
|
|
3097
|
+
if (trailers.length > 1) {
|
|
3098
|
+
logger.log('Each built theme imports the same way:');
|
|
3099
|
+
for (const trailer of trailers) {
|
|
3100
|
+
logger.log(
|
|
3101
|
+
` import { ${trailer.exportName} } from '${trailer.jsImport}'; import '${trailer.cssImport}';`,
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3106
|
+
if (fonts.length > 0) logger.log(formatBatchFontLoadingHelp(fonts));
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* Print what a short report keeps after its one line per theme: one line
|
|
3111
|
+
* naming the fonts the themes do not load, and, when the caller chose no
|
|
3112
|
+
* detail level, where the install example and font recipe are.
|
|
3113
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3114
|
+
* @param {{hint?: boolean}} [options]
|
|
3115
|
+
*/
|
|
3116
|
+
export function printCompactTrailer(trailers, {hint = false} = {}) {
|
|
3117
|
+
if (trailers.length === 0) return;
|
|
3118
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3119
|
+
if (fonts.length > 0) {
|
|
3120
|
+
const named = fonts
|
|
3121
|
+
.map(({family, themes}) =>
|
|
3122
|
+
trailers.length > 1
|
|
3123
|
+
? `"${family}" (${themes.join(', ')})`
|
|
3124
|
+
: `"${family}"`,
|
|
3125
|
+
)
|
|
3126
|
+
.join(', ');
|
|
3127
|
+
logger.log(
|
|
3128
|
+
`[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: astryx docs typography).`,
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
if (hint) {
|
|
3132
|
+
logger.log(
|
|
3133
|
+
'Run with --detail full for the install example and font recipe.',
|
|
3134
|
+
);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* Each font family the themes name but do not load, with the themes that
|
|
3140
|
+
* name it, in first-seen order.
|
|
3141
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3142
|
+
* @returns {Array<{family: string, themes: string[]}>}
|
|
3143
|
+
*/
|
|
3144
|
+
function groupUnloadedFonts(trailers) {
|
|
3145
|
+
/** @type {Map<string, {family: string, themes: string[]}>} */
|
|
3146
|
+
const byFamily = new Map();
|
|
3147
|
+
for (const trailer of trailers) {
|
|
3148
|
+
for (const family of trailer.unloadedFonts) {
|
|
3149
|
+
const key = family.toLowerCase();
|
|
3150
|
+
const entry = byFamily.get(key) ?? {family, themes: []};
|
|
3151
|
+
entry.themes.push(trailer.themeName);
|
|
3152
|
+
byFamily.set(key, entry);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return [...byFamily.values()];
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/**
|
|
3159
|
+
* Build one theme for a batch or compact CLI report. Same build, outputs, and
|
|
3160
|
+
* receipt as {@link themeBuild}; the install snippet and font guidance come
|
|
3161
|
+
* back as `trailer` instead of being printed, and `compact` leaves out the
|
|
3162
|
+
* per-file progress lines. CLI-internal: not exported from the API entry.
|
|
3163
|
+
* @param {string} file
|
|
3164
|
+
* @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options]
|
|
3165
|
+
* @param {{cwd?: string}} [ctx]
|
|
3166
|
+
* @param {{compact?: boolean}} [report]
|
|
3167
|
+
* @returns {Promise<{receipt: import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null, trailer: ThemeBuildTrailer | null}>}
|
|
3168
|
+
*/
|
|
3169
|
+
export async function themeBuildForReport(
|
|
3170
|
+
file,
|
|
3171
|
+
options = {},
|
|
3172
|
+
ctx = {},
|
|
3173
|
+
{compact = false} = {},
|
|
3174
|
+
) {
|
|
3175
|
+
/** @type {ThemeBuildTrailer[]} */
|
|
3176
|
+
const trailers = [];
|
|
3177
|
+
const receipt = /** @type {any} */ (
|
|
3178
|
+
await themeBuildInternal(file, options, ctx, {compact, trailers})
|
|
3179
|
+
);
|
|
3180
|
+
return {receipt, trailer: trailers[0] ?? null};
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3019
3183
|
/** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
|
|
3020
3184
|
export async function themeBuild(file, options = {}, ctx = {}) {
|
|
3021
3185
|
return /** @type {any} */ (themeBuildInternal(file, options, ctx));
|
|
@@ -38,3 +38,14 @@ export function collectUnloadedFonts(resolvedTheme: {
|
|
|
38
38
|
* @returns {string}
|
|
39
39
|
*/
|
|
40
40
|
export function formatFontLoadingHelp(themeName: string, families: string[]): string;
|
|
41
|
+
/**
|
|
42
|
+
* The same fix once for a batch build: each family the built themes name but
|
|
43
|
+
* do not load, with the themes that name it, then one recipe for all of them.
|
|
44
|
+
*
|
|
45
|
+
* @param {Array<{family: string, themes: string[]}>} entries
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
export function formatBatchFontLoadingHelp(entries: Array<{
|
|
49
|
+
family: string;
|
|
50
|
+
themes: string[];
|
|
51
|
+
}>): string;
|
|
@@ -202,6 +202,33 @@ export function collectUnloadedFonts(resolvedTheme) {
|
|
|
202
202
|
*/
|
|
203
203
|
export function formatFontLoadingHelp(themeName, families) {
|
|
204
204
|
const named = families.map(f => `"${f}"`).join(', ');
|
|
205
|
+
return `
|
|
206
|
+
[note] Theme "${themeName}" names fonts it does not load: ${named}
|
|
207
|
+
${fontLoadingRecipe(families)}`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The same fix once for a batch build: each family the built themes name but
|
|
212
|
+
* do not load, with the themes that name it, then one recipe for all of them.
|
|
213
|
+
*
|
|
214
|
+
* @param {Array<{family: string, themes: string[]}>} entries
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
export function formatBatchFontLoadingHelp(entries) {
|
|
218
|
+
const named = entries
|
|
219
|
+
.map(({family, themes}) => ` "${family}" (${themes.join(', ')})`)
|
|
220
|
+
.join('\n');
|
|
221
|
+
return `
|
|
222
|
+
[note] The built themes name fonts they do not load:
|
|
223
|
+
${named}
|
|
224
|
+
${fontLoadingRecipe(entries.map(entry => entry.family))}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @param {string[]} families
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
function fontLoadingRecipe(families) {
|
|
205
232
|
const cssHref =
|
|
206
233
|
'https://fonts.googleapis.com/css2?' +
|
|
207
234
|
families
|
|
@@ -210,9 +237,7 @@ export function formatFontLoadingHelp(themeName, families) {
|
|
|
210
237
|
'&display=swap';
|
|
211
238
|
const first = families[0];
|
|
212
239
|
const slug = first.toLowerCase().replace(/ /g, '-');
|
|
213
|
-
return `
|
|
214
|
-
[note] Theme "${themeName}" names fonts it does not load: ${named}
|
|
215
|
-
The built CSS only sets font-family; load these in your app, or every
|
|
240
|
+
return ` The built CSS only sets font-family; load these in your app, or every
|
|
216
241
|
browser quietly falls back.
|
|
217
242
|
|
|
218
243
|
Google Fonts (add :wght@... axes as your theme's weights require):
|
|
@@ -118,7 +118,7 @@ export const docs = {
|
|
|
118
118
|
['ocean.d.ts', 'TypeScript declarations for the theme and icon registry exports'],
|
|
119
119
|
['ocean.variants.d.ts', "(Optional) Module augmentations for custom component prop values"],
|
|
120
120
|
]},
|
|
121
|
-
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
121
|
+
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
122
122
|
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The build also warns when the theme names font families it does not load. See {@link generic:typography} for the full recipe."},
|
|
123
123
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
124
124
|
],
|
|
@@ -122,7 +122,7 @@ export const docs = {
|
|
|
122
122
|
content: [
|
|
123
123
|
{
|
|
124
124
|
type: 'prose',
|
|
125
|
-
text: 'Only needed when you swizzle a component (`astryx swizzle <Component>`) or write your own StyleX. The plain path already supports `xstyle` overrides \u2014 this path is for editing component internals.',
|
|
125
|
+
text: 'Only needed when you swizzle a component (`astryx swizzle <Component>`) or write your own StyleX. The plain path already supports `xstyle` overrides \u2014 this path is for editing component internals. Some built-in page templates also use StyleX for layout; if you scaffold one and see "Unexpected stylex.create call at runtime", add the compiler plugin for your bundler below.',
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
128
|
type: 'code',
|
|
@@ -9,7 +9,7 @@ export const docsDense = {
|
|
|
9
9
|
section: 'Wrap your app in a theme',
|
|
10
10
|
title: 'Quick start',
|
|
11
11
|
content: [
|
|
12
|
-
{type: 'prose', text:
|
|
12
|
+
{type: 'prose', text: "Install a theme, wrap in `<Theme>` (`import {Theme} from '@astryxdesign/core'`). {@link generic:use-a-theme} for full guide."},
|
|
13
13
|
],
|
|
14
14
|
},
|
|
15
15
|
{
|
|
@@ -11,7 +11,7 @@ export const docsZh = {
|
|
|
11
11
|
content: [
|
|
12
12
|
{
|
|
13
13
|
type: 'prose',
|
|
14
|
-
text:
|
|
14
|
+
text: "安装主题包,用 `<Theme>`(`import {Theme} from '@astryxdesign/core'`)包裹应用,选择浅色或深色模式。完整指南——可用主题、集成主题、深色模式、嵌套主题和生产构建——请参阅 {@link generic:use-a-theme}。",
|
|
15
15
|
},
|
|
16
16
|
],
|
|
17
17
|
},
|
|
@@ -31,7 +31,7 @@ export const docs = {
|
|
|
31
31
|
type: 'code',
|
|
32
32
|
lang: 'tsx',
|
|
33
33
|
label: 'Switch among added themes',
|
|
34
|
-
code: "import {useState} from 'react';\nimport {themes, type ThemeSlug} from './astryx-themes';\n\nconst [slug, setSlug] = useState<ThemeSlug>('neutral');\nconst app = <Theme theme={themes[slug]}><YourApp /></Theme>;",
|
|
34
|
+
code: "import {useState} from 'react';\nimport {Theme} from '@astryxdesign/core';\nimport {themes, type ThemeSlug} from './astryx-themes';\n\nconst [slug, setSlug] = useState<ThemeSlug>('neutral');\nconst app = <Theme theme={themes[slug]}><YourApp /></Theme>;",
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
type: 'prose',
|
|
@@ -8,5 +8,5 @@ export const doc = {
|
|
|
8
8
|
description:
|
|
9
9
|
'Transposed matrix that puts candidates in the columns and criteria in grouped rows, with a pinned label column that survives horizontal scroll, columns you can swap or add, and best-in-row marks you can toggle. Compare, comparison, matrix, spec sheet, feature grid, pricing table, benchmark, frozen column, sticky column, or side-by-side.',
|
|
10
10
|
isReady: true,
|
|
11
|
-
category: 'Table -
|
|
11
|
+
category: 'Table - Comparison',
|
|
12
12
|
};
|
|
@@ -353,7 +353,7 @@ describe('theme build adaptations', () => {
|
|
|
353
353
|
expect(rebuiltCss).toContain('light-dark(#111111, #eeeeee)');
|
|
354
354
|
expect(rebuiltCss).toContain(':root { color-scheme: light dark; }');
|
|
355
355
|
expect(`${rebuilt.stdout}${rebuilt.stderr}`).toContain(
|
|
356
|
-
'
|
|
356
|
+
'[note] Fonts named but not loaded: "Revision Webfont".',
|
|
357
357
|
);
|
|
358
358
|
});
|
|
359
359
|
|
|
@@ -72,7 +72,17 @@ function run(args) {
|
|
|
72
72
|
|
|
73
73
|
describe('theme command human output is plain ASCII', () => {
|
|
74
74
|
it('a standalone build: ok, warning, error, notice, and font help lines', async () => {
|
|
75
|
-
const
|
|
75
|
+
const short = await run(['build', 'ocean.mjs']);
|
|
76
|
+
expect(short.code).toBe(0);
|
|
77
|
+
expect(short.stdout).toContain(
|
|
78
|
+
'[note] Fonts named but not loaded: "Inter"',
|
|
79
|
+
);
|
|
80
|
+
expect(nonAscii(short)).toEqual([]);
|
|
81
|
+
|
|
82
|
+
const result = await runCli(
|
|
83
|
+
['--detail', 'full', 'theme', 'build', 'ocean.mjs'],
|
|
84
|
+
dir,
|
|
85
|
+
);
|
|
76
86
|
|
|
77
87
|
expect(result.code).toBe(0);
|
|
78
88
|
expect(result.stdout).toContain('[ok] ocean.css');
|