@astryxdesign/cli 0.7.5-canary.dc5a8cf → 0.7.5-canary.e4b225e
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 +3 -3
- package/api/hook/detail/detail.test.mjs +11 -0
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
- package/api/theme/build/build.mjs +172 -14
- package/api/theme/build/icon-imports.d.mts +12 -2
- package/api/theme/build/icon-imports.mjs +36 -11
- package/assets/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
- package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
- package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
- package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
- package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
- package/assets/docs/README.md +13 -13
- package/assets/docs/author-a-theme.doc.mjs +2 -0
- package/assets/docs/getting-started.doc.mjs +5 -5
- package/assets/docs/icons.doc.mjs +1 -1
- package/assets/docs/motion.doc.mjs +1 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +1 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/theme.template.ts +1 -1
- package/authoring/config/config.doc.mjs +1 -1
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/foundation/config/project.d.mts +1 -1
- package/foundation/config/project.mjs +1 -1
- package/foundation/debug/redact.test.mjs +1 -1
- package/package.json +12 -12
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* build emits the exact CSS the `<Theme>` runtime does), writes:
|
|
13
13
|
* - A CSS file with token overrides and component styles
|
|
14
14
|
* - A CSS declaration module for strict side-effect imports
|
|
15
|
-
* - A JS module that re-exports the built theme (+ icon registry)
|
|
16
|
-
*
|
|
15
|
+
* - A JS module that re-exports the built theme (+ icon registry); function
|
|
16
|
+
* icon entries stay functions for `Icon`, beside a node view of the registry
|
|
17
|
+
* - A .d.ts (plus an optional .variants.d.ts for custom prop values and the
|
|
18
|
+
* theme's icon variant names)
|
|
17
19
|
*
|
|
18
20
|
* It performs the writes and returns a `theme.build` receipt — its `warnings`
|
|
19
21
|
* carry override problems and every declaration core's generator dropped
|
|
@@ -1577,12 +1579,21 @@ async function validateAdaptationEnrollment(themeDef) {
|
|
|
1577
1579
|
* generating a `declare module` block for them would be dead code — those are
|
|
1578
1580
|
* skipped.
|
|
1579
1581
|
*
|
|
1580
|
-
*
|
|
1582
|
+
* A theme that lists `iconVariants` also augments `IconVariantMap` in
|
|
1583
|
+
* `@astryxdesign/core/Icon` with those names, when the installed core declares
|
|
1584
|
+
* it, so `<Icon variant>` accepts them (spec:AST-087 FR3).
|
|
1585
|
+
*
|
|
1586
|
+
* @param {{components?: Record<string, Record<string, Record<string, unknown>>>, iconVariants?: readonly string[]}} themeDef - Theme definition (resolved by defineTheme)
|
|
1581
1587
|
* @returns {Promise<string|null>} TypeScript declaration content, or null if no augmentations needed
|
|
1582
1588
|
*/
|
|
1583
1589
|
async function generateVariantDeclarationsAsync(themeDef) {
|
|
1584
1590
|
const componentLayers = getThemeComponentLayers(themeDef);
|
|
1585
|
-
|
|
1591
|
+
const iconVariantNames =
|
|
1592
|
+
Array.isArray(themeDef.iconVariants) &&
|
|
1593
|
+
componentHasAugmentableInterface('Icon', 'IconVariantMap')
|
|
1594
|
+
? [...new Set(themeDef.iconVariants)]
|
|
1595
|
+
: [];
|
|
1596
|
+
if (componentLayers.length === 0 && iconVariantNames.length === 0) {
|
|
1586
1597
|
return null;
|
|
1587
1598
|
}
|
|
1588
1599
|
|
|
@@ -1618,7 +1629,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
1618
1629
|
const hasCustom = Object.values(customValues).some(props =>
|
|
1619
1630
|
Object.values(props).some(values => values.size > 0),
|
|
1620
1631
|
);
|
|
1621
|
-
if (!hasCustom) return null;
|
|
1632
|
+
if (!hasCustom && iconVariantNames.length === 0) return null;
|
|
1622
1633
|
|
|
1623
1634
|
const sections = ['// Generated by astryx theme build', 'export {};', ''];
|
|
1624
1635
|
|
|
@@ -1658,6 +1669,17 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
1658
1669
|
}
|
|
1659
1670
|
}
|
|
1660
1671
|
|
|
1672
|
+
if (iconVariantNames.length > 0) {
|
|
1673
|
+
sections.push(`declare module '@astryxdesign/core/Icon' {`);
|
|
1674
|
+
sections.push(' interface IconVariantMap {');
|
|
1675
|
+
for (const name of iconVariantNames) {
|
|
1676
|
+
sections.push(` ${tsStringLiteral(name)}: true;`);
|
|
1677
|
+
}
|
|
1678
|
+
sections.push(' }');
|
|
1679
|
+
sections.push('}');
|
|
1680
|
+
sections.push('');
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1661
1683
|
// If every custom value targeted a non-augmentable prop, there's nothing to
|
|
1662
1684
|
// emit beyond the header — return null so no `.variants.d.ts` is written.
|
|
1663
1685
|
const hasEmittedAugmentation = sections.some(line =>
|
|
@@ -2098,6 +2120,53 @@ function extractRegistryInfo(filePath, field) {
|
|
|
2098
2120
|
return null;
|
|
2099
2121
|
}
|
|
2100
2122
|
|
|
2123
|
+
/**
|
|
2124
|
+
* Whether a theme's icon entries include a function of `{size, variant}`.
|
|
2125
|
+
* @param {Record<string, unknown> | null | undefined} entries
|
|
2126
|
+
* @returns {boolean}
|
|
2127
|
+
*/
|
|
2128
|
+
function hasFunctionIconEntry(entries) {
|
|
2129
|
+
return Object.values(entries ?? {}).some(
|
|
2130
|
+
entry => typeof entry === 'function',
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
/**
|
|
2135
|
+
* A built theme's icon entries: a theme from defineTheme keeps them in
|
|
2136
|
+
* `__icons` when any is a function (its `icons` is the node view); otherwise
|
|
2137
|
+
* `icons` holds them.
|
|
2138
|
+
* @param {any} theme
|
|
2139
|
+
* @returns {Record<string, unknown> | undefined}
|
|
2140
|
+
*/
|
|
2141
|
+
function themeIconEntries(theme) {
|
|
2142
|
+
return theme?.__icons ?? theme?.icons;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
/**
|
|
2146
|
+
* The generated code that reads a registry's entries as React nodes, each
|
|
2147
|
+
* function entry read at `{size: 'md'}` like core's public reads. It never
|
|
2148
|
+
* passes the registry to a call, so a theme extending the built module can
|
|
2149
|
+
* still trace the registry through its `__icons` field, and it reads no
|
|
2150
|
+
* global, which a registry import could shadow. The registry expression runs
|
|
2151
|
+
* where only `entriesName` and `nodesName` are declared, both names the
|
|
2152
|
+
* registry imports cannot use.
|
|
2153
|
+
* @param {string} entries - Expression for the registry's entries.
|
|
2154
|
+
* @param {string} entriesName - A reserved local name.
|
|
2155
|
+
* @param {string} nodesName - A reserved local name.
|
|
2156
|
+
* @returns {string}
|
|
2157
|
+
*/
|
|
2158
|
+
function iconNodesExpression(entries, entriesName, nodesName) {
|
|
2159
|
+
return `(() => {
|
|
2160
|
+
const ${entriesName} = ${entries};
|
|
2161
|
+
const ${nodesName} = {};
|
|
2162
|
+
for (const name in ${entriesName}) {
|
|
2163
|
+
const entry = ${entriesName}[name];
|
|
2164
|
+
${nodesName}[name] = typeof entry === 'function' ? entry({size: 'md'}) : entry;
|
|
2165
|
+
}
|
|
2166
|
+
return ${nodesName};
|
|
2167
|
+
})()`;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2101
2170
|
/**
|
|
2102
2171
|
* Generate a minimal JS module for a built theme.
|
|
2103
2172
|
* Includes the theme name, marker, and re-exports the icon registry.
|
|
@@ -2119,6 +2188,11 @@ function extractRegistryInfo(filePath, field) {
|
|
|
2119
2188
|
* not given, direct registry specifiers are preserved, and inherited relative
|
|
2120
2189
|
* imports are rebased from the base module to the theme entry's directory.
|
|
2121
2190
|
*
|
|
2191
|
+
* When an icon entry is a function of `{size, variant}`, the module keeps the
|
|
2192
|
+
* registry as `__icons`, which `Icon` resolves at the size and variant it
|
|
2193
|
+
* renders, and the theme's `icons` and the re-exported registry are the node
|
|
2194
|
+
* view, each function read at `{size: 'md'}` as `DefinedTheme['icons']` is.
|
|
2195
|
+
*
|
|
2122
2196
|
* @param {any} themeDef
|
|
2123
2197
|
* @param {import('./icon-imports.mjs').IconImports | null} iconInfo
|
|
2124
2198
|
* @param {string} [iconsSpecifier] - Overrides the selected registry specifier.
|
|
@@ -2167,12 +2241,28 @@ function generateBuiltModule(
|
|
|
2167
2241
|
? `const ${iconInfo.exportName} = ${iconInfo.expression};\n`
|
|
2168
2242
|
: '';
|
|
2169
2243
|
const iconsExpression = moduleOptions.iconsExpression ?? iconInfo?.exportName;
|
|
2170
|
-
const
|
|
2244
|
+
const iconNodes =
|
|
2245
|
+
iconsExpression && hasFunctionIconEntry(themeIconEntries(themeDef))
|
|
2246
|
+
? `${themeBinding}IconNodes`
|
|
2247
|
+
: null;
|
|
2248
|
+
const iconNodesDeclaration =
|
|
2249
|
+
iconNodes && iconsExpression
|
|
2250
|
+
? `const ${iconNodes} = ${iconNodesExpression(iconsExpression, `${themeBinding}IconEntries`, iconNodes)};\n`
|
|
2251
|
+
: '';
|
|
2252
|
+
const iconsField = iconNodes
|
|
2253
|
+
? ` icons: ${iconNodes},\n __icons: ${iconsExpression},`
|
|
2254
|
+
: iconsExpression
|
|
2255
|
+
? ` icons: ${iconsExpression},`
|
|
2256
|
+
: '';
|
|
2171
2257
|
const indicatorsField = moduleOptions.indicatorsExpression
|
|
2172
2258
|
? `\n indicators: ${moduleOptions.indicatorsExpression},`
|
|
2173
2259
|
: '';
|
|
2174
2260
|
const iconReExport =
|
|
2175
|
-
iconInfo && exportIcons
|
|
2261
|
+
iconInfo && exportIcons
|
|
2262
|
+
? iconNodes
|
|
2263
|
+
? `\nexport { ${iconNodes} as ${iconInfo.exportName} };\n`
|
|
2264
|
+
: `\nexport { ${iconInfo.exportName} };\n`
|
|
2265
|
+
: '';
|
|
2176
2266
|
|
|
2177
2267
|
// Resolve token values — tuples become light-dark() strings
|
|
2178
2268
|
/** @type {Record<string, unknown>} */
|
|
@@ -2246,7 +2336,7 @@ function generateBuiltModule(
|
|
|
2246
2336
|
),
|
|
2247
2337
|
);
|
|
2248
2338
|
|
|
2249
|
-
return `${iconImport}${iconDeclaration}/**
|
|
2339
|
+
return `${iconImport}${iconDeclaration}${iconNodesDeclaration}/**
|
|
2250
2340
|
* ${themeDef.name} theme — built by \`${getCliInvocation()} theme build\`
|
|
2251
2341
|
* Import the CSS file alongside this module:
|
|
2252
2342
|
*
|
|
@@ -2296,7 +2386,39 @@ export declare const ${iconInfo.exportName}: IconRegistry;
|
|
|
2296
2386
|
(typeOptions.includeThemeImport ?? true)
|
|
2297
2387
|
? `import type { DefinedTheme } from '@astryxdesign/core/theme';\n`
|
|
2298
2388
|
: '';
|
|
2299
|
-
return `${variantsRef}${themeImport}${iconType}export declare const ${themeBinding}:
|
|
2389
|
+
return `${variantsRef}${themeImport}${iconType}export declare const ${themeBinding}: ${builtThemeType(themeDef)};\n`;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
/**
|
|
2393
|
+
* A TypeScript string literal type for `value`.
|
|
2394
|
+
* @param {string} value
|
|
2395
|
+
* @returns {string}
|
|
2396
|
+
*/
|
|
2397
|
+
function tsStringLiteral(value) {
|
|
2398
|
+
const inner = JSON.stringify(value)
|
|
2399
|
+
.slice(1, -1)
|
|
2400
|
+
.replace(/\\"/g, '"')
|
|
2401
|
+
.replace(/'/g, "\\'");
|
|
2402
|
+
return `'${inner}'`;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* The declared type of a built theme. A theme that lists icon variants
|
|
2407
|
+
* carries core's type-only `__iconVariant` marker with those names, so a theme
|
|
2408
|
+
* that extends the built one types its icon entries' `variant` by the list,
|
|
2409
|
+
* exactly as it would extending the source theme.
|
|
2410
|
+
* SYNC: packages/core/src/theme/defineTheme.ts (ResolvedDefinedTheme)
|
|
2411
|
+
* @param {any} themeDef
|
|
2412
|
+
* @returns {string}
|
|
2413
|
+
*/
|
|
2414
|
+
function builtThemeType(themeDef) {
|
|
2415
|
+
const names = themeDef.iconVariants;
|
|
2416
|
+
if (!Array.isArray(names)) return 'DefinedTheme';
|
|
2417
|
+
const variant =
|
|
2418
|
+
names.length > 0
|
|
2419
|
+
? [...new Set(names)].map(tsStringLiteral).join(' | ')
|
|
2420
|
+
: 'never';
|
|
2421
|
+
return `DefinedTheme & { __iconVariant?(variant: ${variant}): void }`;
|
|
2300
2422
|
}
|
|
2301
2423
|
|
|
2302
2424
|
// =============================================================================
|
|
@@ -2770,10 +2892,26 @@ async function themeBuildInternal(
|
|
|
2770
2892
|
// Family preparation keeps its own named-import registry contract, which
|
|
2771
2893
|
// themeBuildFamily checks against the selected members' graph.
|
|
2772
2894
|
const standaloneIcons = !options.__prepareFamily;
|
|
2895
|
+
// Function icon entries stay functions in the built module, beside a node
|
|
2896
|
+
// view bound to `<theme>IconNodes` and computed from `<theme>IconEntries`.
|
|
2897
|
+
const functionEntries =
|
|
2898
|
+
hasFunctionIconEntry(themeIconEntries(themeDef)) ||
|
|
2899
|
+
hasFunctionIconEntry(themeIconEntries(themeDef.extends));
|
|
2900
|
+
/** @param {boolean} reserveIconNodes */
|
|
2901
|
+
const reservedNames = reserveIconNodes => [
|
|
2902
|
+
`${toIdentifier(themeDef.name)}Theme`,
|
|
2903
|
+
...(reserveIconNodes
|
|
2904
|
+
? [
|
|
2905
|
+
`${toIdentifier(themeDef.name)}ThemeIconNodes`,
|
|
2906
|
+
`${toIdentifier(themeDef.name)}ThemeIconEntries`,
|
|
2907
|
+
]
|
|
2908
|
+
: []),
|
|
2909
|
+
];
|
|
2773
2910
|
const iconResolution = {
|
|
2774
2911
|
readSource: (/** @type {string} */ file) => fs.readFileSync(file, 'utf8'),
|
|
2775
2912
|
resolveModule: resolveThemeModule,
|
|
2776
|
-
reservedNames:
|
|
2913
|
+
reservedNames: reservedNames(functionEntries),
|
|
2914
|
+
functionEntries,
|
|
2777
2915
|
rawInput: 'extends' in themeDef,
|
|
2778
2916
|
hasIcons:
|
|
2779
2917
|
Object.keys(themeDef.icons ?? {}).length > 0 ||
|
|
@@ -2897,9 +3035,14 @@ async function themeBuildInternal(
|
|
|
2897
3035
|
!iconInfo &&
|
|
2898
3036
|
Object.keys(resolvedTheme.icons ?? {}).length > 0
|
|
2899
3037
|
) {
|
|
3038
|
+
const resolvedFunctionEntries = hasFunctionIconEntry(
|
|
3039
|
+
themeIconEntries(resolvedTheme),
|
|
3040
|
+
);
|
|
2900
3041
|
iconInfo = await resolveIconImports(filePath, themeExportName, {
|
|
2901
3042
|
...iconResolution,
|
|
2902
3043
|
hasIcons: true,
|
|
3044
|
+
functionEntries: resolvedFunctionEntries,
|
|
3045
|
+
reservedNames: reservedNames(resolvedFunctionEntries),
|
|
2903
3046
|
});
|
|
2904
3047
|
}
|
|
2905
3048
|
// An opaque package base can legitimately have no icons. Its .icons
|
|
@@ -3162,7 +3305,7 @@ async function themeBuildInternal(
|
|
|
3162
3305
|
);
|
|
3163
3306
|
const dtsContent =
|
|
3164
3307
|
generatedHeader(sourceRelative, 'ts', buildCommand, versions) +
|
|
3165
|
-
generateBuiltTypes(themeDef, iconInfo, variantsFileName);
|
|
3308
|
+
generateBuiltTypes(resolvedTheme || themeDef, iconInfo, variantsFileName);
|
|
3166
3309
|
|
|
3167
3310
|
const unloadedFonts = [
|
|
3168
3311
|
...new Set([
|
|
@@ -3609,8 +3752,16 @@ export async function themeBuildFamily(
|
|
|
3609
3752
|
['icons', member.iconInfo],
|
|
3610
3753
|
['indicators', member.indicatorInfo],
|
|
3611
3754
|
]) {
|
|
3612
|
-
|
|
3613
|
-
|
|
3755
|
+
// A theme with a function entry gets its own node view of `icons`, so
|
|
3756
|
+
// an inherit-only member is recognized by its entries.
|
|
3757
|
+
const value =
|
|
3758
|
+
field === 'icons'
|
|
3759
|
+
? themeIconEntries(member.theme)
|
|
3760
|
+
: member.theme[field];
|
|
3761
|
+
const inherited =
|
|
3762
|
+
field === 'icons'
|
|
3763
|
+
? themeIconEntries(member.sourceParent)
|
|
3764
|
+
: member.sourceParent?.[field];
|
|
3614
3765
|
if (
|
|
3615
3766
|
value &&
|
|
3616
3767
|
Object.keys(value).length > 0 &&
|
|
@@ -3681,7 +3832,14 @@ export async function themeBuildFamily(
|
|
|
3681
3832
|
// prettier-ignore
|
|
3682
3833
|
for (const registry of [icon, indicator]) if (registry.info) registryImports.push({specifier: registry.specifier ?? registry.info.importPath, exportName: registry.info.exportName});
|
|
3683
3834
|
const ownIcons = icon.info ? `${themeBinding}Icons` : null;
|
|
3684
|
-
|
|
3835
|
+
// A parent with function entries keeps them in `__icons`; its `icons`
|
|
3836
|
+
// is the node view.
|
|
3837
|
+
const parent = members.find(
|
|
3838
|
+
other => other.theme.name === member.parentName,
|
|
3839
|
+
);
|
|
3840
|
+
const inheritedIcons = parentBinding
|
|
3841
|
+
? `${parentBinding}.${hasFunctionIconEntry(themeIconEntries(parent?.theme)) ? '__icons' : 'icons'}`
|
|
3842
|
+
: null;
|
|
3685
3843
|
const ownIndicators = indicator.info ? `${themeBinding}Indicators` : null;
|
|
3686
3844
|
const inheritedIndicators = parentBinding
|
|
3687
3845
|
? `${parentBinding}.indicators`
|
|
@@ -6,13 +6,18 @@
|
|
|
6
6
|
* Local base themes are traced to their registry imports. Package bases remain
|
|
7
7
|
* public theme imports, so their implementation and private files stay private.
|
|
8
8
|
*
|
|
9
|
+
* A theme whose resolved icon entries include a function keeps them: a package
|
|
10
|
+
* base is read for its entries (`__icons`) as well as its node-valued `icons`,
|
|
11
|
+
* and a built base module's `__icons` field is followed instead of `icons`.
|
|
12
|
+
*
|
|
9
13
|
* @param {string} filePath
|
|
10
14
|
* @param {string | undefined} exportName
|
|
11
|
-
* @param {{hasIcons: boolean, readSource: (filename: string) => string, resolveModule: (specifier: string, fromFile: string) => string | Promise<string>, reservedNames?: string[], rawInput?: boolean}} options
|
|
15
|
+
* @param {{hasIcons: boolean, functionEntries?: boolean, readSource: (filename: string) => string, resolveModule: (specifier: string, fromFile: string) => string | Promise<string>, reservedNames?: string[], rawInput?: boolean}} options
|
|
12
16
|
* @returns {Promise<IconImports | null>}
|
|
13
17
|
*/
|
|
14
|
-
export function resolveIconImports(filePath: string, exportName: string | undefined, { hasIcons, readSource, resolveModule, reservedNames, rawInput }: {
|
|
18
|
+
export function resolveIconImports(filePath: string, exportName: string | undefined, { hasIcons, functionEntries, readSource, resolveModule, reservedNames, rawInput, }: {
|
|
15
19
|
hasIcons: boolean;
|
|
20
|
+
functionEntries?: boolean;
|
|
16
21
|
readSource: (filename: string) => string;
|
|
17
22
|
resolveModule: (specifier: string, fromFile: string) => string | Promise<string>;
|
|
18
23
|
reservedNames?: string[];
|
|
@@ -35,11 +40,16 @@ export type RegistryReference = {
|
|
|
35
40
|
binding: any;
|
|
36
41
|
members: string[];
|
|
37
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* `entries` marks a package theme read for its icon entries: its node-valued
|
|
45
|
+
* `icons` merged with the `__icons` that hold its function entries, if any.
|
|
46
|
+
*/
|
|
38
47
|
export type RegistryPlan = {
|
|
39
48
|
kind: "registry";
|
|
40
49
|
ref: RegistryReference;
|
|
41
50
|
preferredName: string;
|
|
42
51
|
override?: boolean;
|
|
52
|
+
entries?: boolean;
|
|
43
53
|
} | {
|
|
44
54
|
kind: "merge";
|
|
45
55
|
base: RegistryPlan;
|
|
@@ -24,7 +24,11 @@ import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
/** @typedef {{kind: 'reference', module: any, binding: any, members: string[]}} RegistryReference */
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* `entries` marks a package theme read for its icon entries: its node-valued
|
|
29
|
+
* `icons` merged with the `__icons` that hold its function entries, if any.
|
|
30
|
+
* @typedef {{kind: 'registry', ref: RegistryReference, preferredName: string, override?: boolean, entries?: boolean} | {kind: 'merge', base: RegistryPlan, own: RegistryPlan}} RegistryPlan
|
|
31
|
+
*/
|
|
28
32
|
|
|
29
33
|
/** @param {any} node */
|
|
30
34
|
function unwrap(node) {
|
|
@@ -98,15 +102,26 @@ function invalidRegistry(name, reason = '') {
|
|
|
98
102
|
* Local base themes are traced to their registry imports. Package bases remain
|
|
99
103
|
* public theme imports, so their implementation and private files stay private.
|
|
100
104
|
*
|
|
105
|
+
* A theme whose resolved icon entries include a function keeps them: a package
|
|
106
|
+
* base is read for its entries (`__icons`) as well as its node-valued `icons`,
|
|
107
|
+
* and a built base module's `__icons` field is followed instead of `icons`.
|
|
108
|
+
*
|
|
101
109
|
* @param {string} filePath
|
|
102
110
|
* @param {string | undefined} exportName
|
|
103
|
-
* @param {{hasIcons: boolean, readSource: (filename: string) => string, resolveModule: (specifier: string, fromFile: string) => string | Promise<string>, reservedNames?: string[], rawInput?: boolean}} options
|
|
111
|
+
* @param {{hasIcons: boolean, functionEntries?: boolean, readSource: (filename: string) => string, resolveModule: (specifier: string, fromFile: string) => string | Promise<string>, reservedNames?: string[], rawInput?: boolean}} options
|
|
104
112
|
* @returns {Promise<IconImports | null>}
|
|
105
113
|
*/
|
|
106
114
|
export async function resolveIconImports(
|
|
107
115
|
filePath,
|
|
108
116
|
exportName,
|
|
109
|
-
{
|
|
117
|
+
{
|
|
118
|
+
hasIcons,
|
|
119
|
+
functionEntries = false,
|
|
120
|
+
readSource,
|
|
121
|
+
resolveModule,
|
|
122
|
+
reservedNames = [],
|
|
123
|
+
rawInput = false,
|
|
124
|
+
},
|
|
110
125
|
) {
|
|
111
126
|
if (exportName === undefined) {
|
|
112
127
|
if (!hasIcons) return null;
|
|
@@ -391,11 +406,16 @@ export async function resolveIconImports(
|
|
|
391
406
|
|
|
392
407
|
/** @param {RegistryReference} ref @returns {RegistryPlan} */
|
|
393
408
|
function packageTheme(ref) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
409
|
+
// A theme's `icons` is node-valued; its function entries live in
|
|
410
|
+
// `__icons`. Read both only when the built theme needs its functions, so
|
|
411
|
+
// a theme without them keeps its existing output.
|
|
412
|
+
return functionEntries
|
|
413
|
+
? {kind: 'registry', ref, preferredName: 'themeIcons', entries: true}
|
|
414
|
+
: {
|
|
415
|
+
kind: 'registry',
|
|
416
|
+
ref: {...ref, members: [...ref.members, 'icons']},
|
|
417
|
+
preferredName: 'themeIcons',
|
|
418
|
+
};
|
|
399
419
|
}
|
|
400
420
|
|
|
401
421
|
/** @param {any} module @param {string} name @param {boolean} [rejectOpaque] @returns {Promise<RegistryPlan | null>} */
|
|
@@ -513,7 +533,7 @@ export async function resolveIconImports(
|
|
|
513
533
|
: propertyName(item.key);
|
|
514
534
|
if (key === null)
|
|
515
535
|
invalidRegistry(undefined, 'Computed theme keys cannot be resolved.');
|
|
516
|
-
if (!['icons', 'extends'].includes(key)) continue;
|
|
536
|
+
if (!['icons', '__icons', 'extends'].includes(key)) continue;
|
|
517
537
|
if (
|
|
518
538
|
!['ObjectProperty', 'Property'].includes(item.type) ||
|
|
519
539
|
item.method ||
|
|
@@ -566,7 +586,9 @@ export async function resolveIconImports(
|
|
|
566
586
|
}
|
|
567
587
|
const config = await fields(module, node);
|
|
568
588
|
const baseField = config.get('extends');
|
|
569
|
-
|
|
589
|
+
// A built module keeps its function entries in `__icons` beside its
|
|
590
|
+
// node-valued `icons`; the entries are the registry to carry.
|
|
591
|
+
const iconField = config.get('__icons') ?? config.get('icons');
|
|
570
592
|
const base = baseField
|
|
571
593
|
? await theme(baseField.module, baseField.node)
|
|
572
594
|
: null;
|
|
@@ -655,10 +677,13 @@ export async function resolveIconImports(
|
|
|
655
677
|
localName,
|
|
656
678
|
});
|
|
657
679
|
}
|
|
658
|
-
const
|
|
680
|
+
const target = ref.members.reduce(
|
|
659
681
|
(result, member) => `${result}[${JSON.stringify(member)}]`,
|
|
660
682
|
localName,
|
|
661
683
|
);
|
|
684
|
+
const expression = value.entries
|
|
685
|
+
? `{...${target}["icons"], ...${target}["__icons"]}`
|
|
686
|
+
: target;
|
|
662
687
|
return {
|
|
663
688
|
expression,
|
|
664
689
|
preferredName:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Rename Text/Heading/Link/Timestamp color "active" to "accent"
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/2863
|
|
6
6
|
*
|
|
7
7
|
* The `active` text-color value is renamed to `accent` and now maps to the
|
|
8
8
|
* dedicated `--color-text-accent` token (legible accent ink) instead of
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Rename Switch labelSpacing "default" to "hug"
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/2889
|
|
6
6
|
*
|
|
7
7
|
* The `labelSpacing="default"` value is renamed to `labelSpacing="hug"` so
|
|
8
8
|
* the name describes the behavior (label and switch hug each other), matching
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Migrate Table tableProps to direct root props
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/3679
|
|
6
6
|
*
|
|
7
7
|
* `tableProps` (typed HTMLAttributes<HTMLTableElement>, nesting HTML
|
|
8
8
|
* attributes one level deep) is deprecated. As of v0.1.7, <Table> honors
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Rename Avatar named sizes to Icon's abbreviated scale
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/2672
|
|
6
6
|
*
|
|
7
7
|
* This transform is deliberately limited to static literals written directly
|
|
8
8
|
* in the `size` prop of an imported Avatar or AvatarGroup JSX element. It does
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Remove TabList orientation prop
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/4231
|
|
6
6
|
*
|
|
7
7
|
* As of v0.2.0, TabList no longer accepts an `orientation` prop. The prop
|
|
8
8
|
* was misleading: it only drove the keyboard-hint badge, not a real vertical
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Migrate Dialog position left/right -> start/end
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/pull/4568
|
|
6
6
|
*
|
|
7
7
|
* The Dialog `position` prop's physical `left`/`right` offsets are deprecated
|
|
8
8
|
* in favor of the logical `start`/`end` offsets. `start`/`end` map to
|
package/assets/docs/README.md
CHANGED
|
@@ -32,22 +32,22 @@ A public authoring-quality rubric is also caller-facing when it helps someone ev
|
|
|
32
32
|
|
|
33
33
|
## Where the rest goes
|
|
34
34
|
|
|
35
|
-
The material is usually good; the finding is placement, not quality. It goes in the [wiki](https://github.com/
|
|
35
|
+
The material is usually good; the finding is placement, not quality. It goes in the [wiki](https://github.com/meta/astryx/wiki) — **as a section on the page that already covers it, not a new page.** The wiki is at nearly 60 pages, several of them overlapping, because every stray section got its own.
|
|
36
36
|
|
|
37
37
|
| what you wrote | where it goes |
|
|
38
38
|
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
-
| how a component is graded — checks, scoring | [Component-Audit-Rubric](https://github.com/
|
|
40
|
-
| lab → core promotion, what a component must satisfy | [Component-Lifecycle](https://github.com/
|
|
41
|
-
| how to build a new component | [Component-Authoring-Guide](https://github.com/
|
|
42
|
-
| what a component must be hardened against | [Component-Hardening-Protocol](https://github.com/
|
|
43
|
-
| a11y requirements as checks we run | [Accessibility-Checklist](https://github.com/
|
|
44
|
-
| how the system is put together | [System-Architecture](https://github.com/
|
|
45
|
-
| API naming and shape decisions | [API-Conventions](https://github.com/
|
|
46
|
-
| contributor workflow, PR process | [Contributing](https://github.com/
|
|
47
|
-
| release mechanics | [Release-Process](https://github.com/
|
|
48
|
-
| what a nightly agent role does | the Night-Watch pages, from [Night-Watch-Overview](https://github.com/
|
|
49
|
-
|
|
50
|
-
**Fits no row?** It is still not caller-facing. Default it to [Contributing](https://github.com/
|
|
39
|
+
| how a component is graded — checks, scoring | [Component-Audit-Rubric](https://github.com/meta/astryx/wiki/Component-Audit-Rubric) |
|
|
40
|
+
| lab → core promotion, what a component must satisfy | [Component-Lifecycle](https://github.com/meta/astryx/wiki/Component-Lifecycle) |
|
|
41
|
+
| how to build a new component | [Component-Authoring-Guide](https://github.com/meta/astryx/wiki/Component-Authoring-Guide), [Creating-New-Components](https://github.com/meta/astryx/wiki/Creating-New-Components) |
|
|
42
|
+
| what a component must be hardened against | [Component-Hardening-Protocol](https://github.com/meta/astryx/wiki/Component-Hardening-Protocol), [Hardening-Audit-Guide](https://github.com/meta/astryx/wiki/Hardening-Audit-Guide) |
|
|
43
|
+
| a11y requirements as checks we run | [Accessibility-Checklist](https://github.com/meta/astryx/wiki/Accessibility-Checklist) |
|
|
44
|
+
| how the system is put together | [System-Architecture](https://github.com/meta/astryx/wiki/System-Architecture), [Theming-Infrastructure](https://github.com/meta/astryx/wiki/Theming-Infrastructure) |
|
|
45
|
+
| API naming and shape decisions | [API-Conventions](https://github.com/meta/astryx/wiki/API-Conventions), [API-Arbitration](https://github.com/meta/astryx/wiki/API-Arbitration) |
|
|
46
|
+
| contributor workflow, PR process | [Contributing](https://github.com/meta/astryx/wiki/Contributing), [Contributing-with-AI-Assistants](https://github.com/meta/astryx/wiki/Contributing-with-AI-Assistants) |
|
|
47
|
+
| release mechanics | [Release-Process](https://github.com/meta/astryx/wiki/Release-Process) |
|
|
48
|
+
| what a nightly agent role does | the Night-Watch pages, from [Night-Watch-Overview](https://github.com/meta/astryx/wiki/Night-Watch-Overview) |
|
|
49
|
+
|
|
50
|
+
**Fits no row?** It is still not caller-facing. Default it to [Contributing](https://github.com/meta/astryx/wiki/Contributing), or `CONTRIBUTING.md` when it is a step someone follows with the repo cloned. Never default it back to this directory.
|
|
51
51
|
|
|
52
52
|
Worked example: a responsive-and-interaction readiness rubric is grading criteria → **Component-Audit-Rubric**, or **Component-Lifecycle** if it is a promotion gate.
|
|
53
53
|
|
|
@@ -136,6 +136,8 @@ export const docs = {
|
|
|
136
136
|
{type: 'prose', text: 'In the example above, the generated theme imports `./icons.mjs` from `dist`. If the second command is skipped, `theme build` can still succeed, but loading or bundling the generated module fails because `dist/icons.mjs` is missing. `--icons-specifier` changes the emitted import; it does not create or verify the target file. Match the specifier to a module that resolves from the generated JS file.'},
|
|
137
137
|
{type: 'prose', text: 'Without `--icons-specifier`, the detected source import specifier is emitted unchanged. In the default flow without `--out`, a bundler can resolve an extensionless `./icons` to the neighboring `icons.tsx` source, but Node ESM does not perform that lookup and reports `ERR_MODULE_NOT_FOUND`. Moving the output with `--out` also changes where relative imports resolve from.'},
|
|
138
138
|
{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},
|
|
139
|
+
{type: 'prose', text: "A registry entry can be a function of `{size, variant}`. The built theme keeps the function, so `Icon` asks it for the size and variant it renders, as the runtime theme does, including for entries inherited from a built or package theme. The built theme's `icons` field and the registry its module re-exports are React nodes, with each function read at size `md`. A function written in the theme file itself cannot be carried, so the build fails; move it into the registry module."},
|
|
140
|
+
{type: 'prose', text: "A theme that lists `iconVariants` also writes an `IconVariantMap` augmentation into `<theme>.variants.d.ts`, so `Icon`'s `variant` accepts those names wherever the theme's types load. Its declaration carries the list too, so a theme that extends the built theme types `variant` in its icon entries by that list."},
|
|
139
141
|
],
|
|
140
142
|
},
|
|
141
143
|
{
|
|
@@ -193,22 +193,22 @@ const overrides = stylex.create({
|
|
|
193
193
|
[
|
|
194
194
|
'Next.js',
|
|
195
195
|
'Next.js + theme CSS',
|
|
196
|
-
'[apps/example-nextjs](https://github.com/
|
|
196
|
+
'[apps/example-nextjs](https://github.com/meta/astryx/tree/main/apps/example-nextjs)',
|
|
197
197
|
],
|
|
198
198
|
[
|
|
199
199
|
'Next.js + StyleX',
|
|
200
200
|
'Next.js + StyleX for custom styles',
|
|
201
|
-
'[apps/example-nextjs-stylex](https://github.com/
|
|
201
|
+
'[apps/example-nextjs-stylex](https://github.com/meta/astryx/tree/main/apps/example-nextjs-stylex)',
|
|
202
202
|
],
|
|
203
203
|
[
|
|
204
204
|
'Next.js + Tailwind',
|
|
205
205
|
'Next.js + Tailwind bridge',
|
|
206
|
-
'[apps/example-nextjs-tailwind](https://github.com/
|
|
206
|
+
'[apps/example-nextjs-tailwind](https://github.com/meta/astryx/tree/main/apps/example-nextjs-tailwind)',
|
|
207
207
|
],
|
|
208
208
|
[
|
|
209
209
|
'Vite + Tailwind',
|
|
210
210
|
'Vite + Tailwind bridge',
|
|
211
|
-
'[apps/example-vite-tailwind](https://github.com/
|
|
211
|
+
'[apps/example-vite-tailwind](https://github.com/meta/astryx/tree/main/apps/example-vite-tailwind)',
|
|
212
212
|
],
|
|
213
213
|
],
|
|
214
214
|
},
|
|
@@ -216,7 +216,7 @@ const overrides = stylex.create({
|
|
|
216
216
|
type: 'code',
|
|
217
217
|
lang: 'bash',
|
|
218
218
|
label: 'Clone and run an example',
|
|
219
|
-
code: `git clone https://github.com/
|
|
219
|
+
code: `git clone https://github.com/meta/astryx.git
|
|
220
220
|
cd astryx/apps/example-nextjs
|
|
221
221
|
{@pm install}
|
|
222
222
|
{@pm run dev}`,
|
|
@@ -169,7 +169,7 @@ brandTheme.iconVariants; // ['outline', 'filled']`,
|
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
type: 'prose',
|
|
172
|
-
text: 'An application declares the variant names it uses by augmenting `IconVariantMap` from `@astryxdesign/core/Icon`. `IconVariant` is those names, and an entry passed to `registerIcons()` receives `variant` typed as `IconVariant`.',
|
|
172
|
+
text: 'An application declares the variant names it uses by augmenting `IconVariantMap` from `@astryxdesign/core/Icon`. `IconVariant` is those names, and an entry passed to `registerIcons()` receives `variant` typed as `IconVariant`. `astryx theme build` writes this augmentation for a built theme\'s list.',
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
type: 'code',
|
|
@@ -50,7 +50,7 @@ export const docs = {
|
|
|
50
50
|
content: [
|
|
51
51
|
{
|
|
52
52
|
type: 'prose',
|
|
53
|
-
text: '
|
|
53
|
+
text: 'Two easing curves. `--ease-standard` decelerates, for things arriving and state changes. `--ease-exit` accelerates, for things leaving: it moves off from rest and leaves fast, so the travel stays visible for the whole duration.',
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
type: 'token-ref',
|
|
@@ -111,7 +111,7 @@ export default function App() {
|
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
type: 'prose',
|
|
114
|
-
text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [
|
|
114
|
+
text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [meta/astryx#4029](https://github.com/meta/astryx/issues/4029). For now, run the two providers side by side as shown above.",
|
|
115
115
|
},
|
|
116
116
|
],
|
|
117
117
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// AUTO-GENERATED — do not edit manually.
|
|
4
4
|
// Run: node scripts/generate-token-docs.mjs
|
|
5
|
-
// Total:
|
|
5
|
+
// Total: 283 tokens across 15 categories.
|
|
6
6
|
|
|
7
7
|
/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
|
|
8
8
|
export const docs = {
|