@astryxdesign/cli 0.7.5-canary.dcdb356 → 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.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +362 -109
- package/api/theme/build/build.project-core.test.mjs +63 -8
- package/api/theme/build/build.test.mjs +77 -0
- 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 +5 -1
- package/assets/docs/getting-started.doc.mjs +5 -5
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/motion.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- 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 +19 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- 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/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/package.json +12 -12
|
@@ -7,15 +7,26 @@
|
|
|
7
7
|
* app's `<Theme>` runs on the app's Core either way, so the build loads the
|
|
8
8
|
* project's installed `@astryxdesign/core` when it differs from the CLI's own.
|
|
9
9
|
* When there is no Core to use, the error names the fix for where it ran:
|
|
10
|
-
* install it in an app, build it in the Astryx repository.
|
|
10
|
+
* install it in an app, build it in the Astryx repository. An installed Core
|
|
11
|
+
* that does not load, or lacks the functions the build calls, fails the build,
|
|
12
|
+
* naming it, rather than leave the build to the CLI's own Core.
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
15
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
14
16
|
import * as fs from 'node:fs';
|
|
15
17
|
import * as os from 'node:os';
|
|
16
18
|
import * as path from 'node:path';
|
|
17
19
|
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
18
20
|
import {coreUnavailableMessage, themeBuild} from './build.mjs';
|
|
21
|
+
import {fetchCarriedThemeCoreDir} from '../_adapter.mjs';
|
|
22
|
+
|
|
23
|
+
vi.mock('../_adapter.mjs', async importOriginal => {
|
|
24
|
+
const actual = /** @type {Record<string, any>} */ (await importOriginal());
|
|
25
|
+
return {
|
|
26
|
+
...actual,
|
|
27
|
+
fetchCarriedThemeCoreDir: vi.fn(actual.fetchCarriedThemeCoreDir),
|
|
28
|
+
};
|
|
29
|
+
});
|
|
19
30
|
|
|
20
31
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
|
21
32
|
const REPO_ROOT = path.resolve(HERE, '../../../../..');
|
|
@@ -53,9 +64,10 @@ afterEach(() => {
|
|
|
53
64
|
* entry as it is imported. Its `exports` map lists `source` first, as Core's
|
|
54
65
|
* own does, so the build must skip that condition to find the runtime file.
|
|
55
66
|
* @param {string} dir
|
|
56
|
-
* @param {{broken?: boolean}} [options]
|
|
67
|
+
* @param {{broken?: boolean, themeModule?: string}} [options] `themeModule`
|
|
68
|
+
* replaces the theme entry's source
|
|
57
69
|
*/
|
|
58
|
-
function installCore(dir, {broken = false} = {}) {
|
|
70
|
+
function installCore(dir, {broken = false, themeModule} = {}) {
|
|
59
71
|
const core = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
60
72
|
fs.mkdirSync(core, {recursive: true});
|
|
61
73
|
fs.writeFileSync(
|
|
@@ -82,12 +94,29 @@ function installCore(dir, {broken = false} = {}) {
|
|
|
82
94
|
`globalThis.__astryxProjectCoreLoads = [...(globalThis.__astryxProjectCoreLoads ?? []), '${entry}'];\n`;
|
|
83
95
|
fs.writeFileSync(
|
|
84
96
|
path.join(core, 'theme.mjs'),
|
|
85
|
-
module('theme', 'theme/index.js'),
|
|
97
|
+
themeModule ?? module('theme', 'theme/index.js'),
|
|
86
98
|
);
|
|
87
99
|
fs.writeFileSync(path.join(core, 'root.mjs'), module('root', 'index.js'));
|
|
88
100
|
return core;
|
|
89
101
|
}
|
|
90
102
|
|
|
103
|
+
describe('theme build outside a project, with the Core this CLI release carries', () => {
|
|
104
|
+
it('fails naming a carried Core that does not load, rather than build with the CLI’s own', async () => {
|
|
105
|
+
const carried = installCore(makeDir(), {broken: true});
|
|
106
|
+
vi.mocked(fetchCarriedThemeCoreDir).mockReturnValueOnce(carried);
|
|
107
|
+
const bare = makeDir();
|
|
108
|
+
const build = themeBuild('ocean.mjs', {}, {cwd: bare});
|
|
109
|
+
await expect(build).rejects.toMatchObject({
|
|
110
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
111
|
+
message: expect.stringContaining(
|
|
112
|
+
`Could not load the @astryxdesign/core this CLI release carries, at ${carried}`,
|
|
113
|
+
),
|
|
114
|
+
});
|
|
115
|
+
await expect(build).rejects.toThrow(/Import error: this Core is broken/);
|
|
116
|
+
expect(fs.existsSync(path.join(bare, 'ocean.css'))).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
91
120
|
describe('theme build generates with the Core the project installed', () => {
|
|
92
121
|
it('loads the app’s installed Core when it differs from the CLI’s own', async () => {
|
|
93
122
|
const app = makeDir();
|
|
@@ -114,11 +143,37 @@ describe('theme build generates with the Core the project installed', () => {
|
|
|
114
143
|
expect(fs.existsSync(path.join(bare, 'ocean.css'))).toBe(true);
|
|
115
144
|
});
|
|
116
145
|
|
|
117
|
-
it('
|
|
146
|
+
it('fails naming an installed Core that does not load, rather than build with the CLI’s own', async () => {
|
|
118
147
|
const app = makeDir();
|
|
119
148
|
installCore(app, {broken: true});
|
|
120
|
-
await themeBuild('ocean.mjs', {}, {cwd: app})
|
|
121
|
-
|
|
149
|
+
await expect(themeBuild('ocean.mjs', {}, {cwd: app})).rejects.toMatchObject(
|
|
150
|
+
{
|
|
151
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
152
|
+
message: expect.stringContaining(
|
|
153
|
+
`Could not load the @astryxdesign/core installed at ${path.join('node_modules', '@astryxdesign', 'core')}`,
|
|
154
|
+
),
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
await expect(themeBuild('ocean.mjs', {}, {cwd: app})).rejects.toThrow(
|
|
158
|
+
/Import error: this Core is broken/,
|
|
159
|
+
);
|
|
160
|
+
expect(fs.existsSync(path.join(app, 'ocean.css'))).toBe(false);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('fails naming an installed Core without the functions the build calls, rather than build with the CLI’s own', async () => {
|
|
164
|
+
const app = makeDir();
|
|
165
|
+
installCore(app, {
|
|
166
|
+
themeModule: 'export const defineTheme = theme => theme;\n',
|
|
167
|
+
});
|
|
168
|
+
await expect(themeBuild('ocean.mjs', {}, {cwd: app})).rejects.toMatchObject(
|
|
169
|
+
{
|
|
170
|
+
code: 'ERR_CORE_INCOMPATIBLE',
|
|
171
|
+
message: expect.stringContaining(
|
|
172
|
+
'does not export generateThemeRulesSplit',
|
|
173
|
+
),
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
expect(fs.existsSync(path.join(app, 'ocean.css'))).toBe(false);
|
|
122
177
|
});
|
|
123
178
|
});
|
|
124
179
|
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
themeBuild,
|
|
29
29
|
validateComponentOverridesAgainstRegistry,
|
|
30
|
+
validateThemePrivateInputs,
|
|
30
31
|
} from './build.mjs';
|
|
31
32
|
|
|
32
33
|
// `themeBuild` captures core's generator once at module load. Wrap the two
|
|
@@ -212,6 +213,55 @@ describe('themeBuild() — receipt', () => {
|
|
|
212
213
|
});
|
|
213
214
|
});
|
|
214
215
|
|
|
216
|
+
describe.each(['mjs', 'ts'])('a .%s theme module with no theme export', ext => {
|
|
217
|
+
beforeEach(() => {
|
|
218
|
+
fs.writeFileSync(
|
|
219
|
+
path.join(tmpDir, `none.${ext}`),
|
|
220
|
+
'export const notATheme = 42;\n',
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('fails the build as a module that does not load a theme', async () => {
|
|
225
|
+
const build = themeBuild(`none.${ext}`, {}, {cwd: tmpDir});
|
|
226
|
+
await expect(build).rejects.toThrow(
|
|
227
|
+
/Could not find a defineTheme\(\) result/,
|
|
228
|
+
);
|
|
229
|
+
await expect(build).rejects.toMatchObject({code: 'ERR_THEME_LOAD'});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("fails doctor's private-input check the same way, rather than read its exports as a theme", async () => {
|
|
233
|
+
await expect(
|
|
234
|
+
validateThemePrivateInputs(`none.${ext}`, {cwd: tmpDir}),
|
|
235
|
+
).rejects.toThrow(/Could not find a defineTheme\(\) result/);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe('themeBuild() — a theme module that does not load', () => {
|
|
240
|
+
it('fails with the import error, rather than build the theme from the file text', async () => {
|
|
241
|
+
fs.writeFileSync(
|
|
242
|
+
path.join(tmpDir, 'unresolved.mjs'),
|
|
243
|
+
"import './missing-helper.mjs';\nexport default {name: 'unresolved', tokens: {'--color-bg': '#000'}};\n",
|
|
244
|
+
);
|
|
245
|
+
await expect(
|
|
246
|
+
themeBuild('unresolved.mjs', {}, {cwd: tmpDir}),
|
|
247
|
+
).rejects.toThrow(
|
|
248
|
+
/Failed to load theme from .*unresolved\.mjs: .*missing-helper\.mjs/s,
|
|
249
|
+
);
|
|
250
|
+
expect(fs.existsSync(path.join(tmpDir, 'unresolved.css'))).toBe(false);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('fails with the error the module throws, rather than build the theme from the file text', async () => {
|
|
254
|
+
fs.writeFileSync(
|
|
255
|
+
path.join(tmpDir, 'throws.mjs'),
|
|
256
|
+
"throw new Error('the theme module failed');\nexport default {name: 'throws', tokens: {'--color-bg': '#000'}};\n",
|
|
257
|
+
);
|
|
258
|
+
await expect(themeBuild('throws.mjs', {}, {cwd: tmpDir})).rejects.toThrow(
|
|
259
|
+
/the theme module failed/,
|
|
260
|
+
);
|
|
261
|
+
expect(fs.existsSync(path.join(tmpDir, 'throws.css'))).toBe(false);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
|
|
215
265
|
describe('themeBuild() — dropped declarations reach the receipt', () => {
|
|
216
266
|
// Core's generator refuses a declaration whose value would end it early
|
|
217
267
|
// (an unquoted `;` or brace, an unclosed string/comment/url). The runtime
|
|
@@ -599,6 +649,33 @@ describe('themeBuild() — component override validation', () => {
|
|
|
599
649
|
});
|
|
600
650
|
});
|
|
601
651
|
|
|
652
|
+
describe('themeBuild() — Icon size dimensions', () => {
|
|
653
|
+
it('writes width and height on an icon size into the vars the glyph reads, with no warnings', async () => {
|
|
654
|
+
// spec:AST-087 FR10: a built theme sets an Icon size's glyph dimension the
|
|
655
|
+
// way the runtime provider does, through the shared compiler's derived
|
|
656
|
+
// vars. Raw width/height would lose to a consumer's unlayered StyleX.
|
|
657
|
+
const themeFile = path.join(tmpDir, 'iconsizes.mjs');
|
|
658
|
+
fs.writeFileSync(
|
|
659
|
+
themeFile,
|
|
660
|
+
`export default {
|
|
661
|
+
name: 'iconsizes',
|
|
662
|
+
tokens: {'--color-bg': '#0a0a0a'},
|
|
663
|
+
components: {icon: {'size:sm': {width: '18px', height: '22px'}}},
|
|
664
|
+
};\n`,
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
const result = await themeBuild('iconsizes.mjs', {}, {cwd: tmpDir});
|
|
668
|
+
|
|
669
|
+
expect(result?.data.warnings).toEqual([]);
|
|
670
|
+
const css = fs.readFileSync(path.join(tmpDir, 'iconsizes.css'), 'utf8');
|
|
671
|
+
const rule =
|
|
672
|
+
css.match(/\.astryx-icon\[data-size="sm"\]\s*\{([^}]*)\}/)?.[1] ?? '';
|
|
673
|
+
expect(rule).toMatch(/--_icon-width:\s*18px/);
|
|
674
|
+
expect(rule).toMatch(/--_icon-height:\s*22px/);
|
|
675
|
+
expect(rule).not.toMatch(/(^|[\s;])(width|height)\s*:/);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
|
|
602
679
|
describe('themeBuild() — the shipped theme template', () => {
|
|
603
680
|
// `assets/theme.template.ts` is what `astryx theme template` puts in a
|
|
604
681
|
// consumer's project. It is the one theme file we hand out, so it has to
|
|
@@ -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
|
|
|
@@ -55,9 +55,11 @@ export const docs = {
|
|
|
55
55
|
['tokens', 'Base tokens are copied first, then child tokens override on top.'],
|
|
56
56
|
['components', 'Deep-merged: child component rules override matching keys from the base.'],
|
|
57
57
|
['icons', 'Shallow-merged: child icons override matching names from the base.'],
|
|
58
|
+
['iconVariants', 'Replaced, never merged: a child that sets iconVariants replaces the base list; a child that omits it inherits the list.'],
|
|
58
59
|
['indicators', 'Shallow-merged: child indicators override matching names from the base.'],
|
|
59
60
|
['onDark, onLight', "Deep-merged per surface: the base's resolved surface first, then the child's overrides."],
|
|
60
|
-
['
|
|
61
|
+
['motion', "Field by field: the child's `fast`, `medium` and `ratio` regenerate the fast and medium duration tokens; `slow` and `easing` left unset keep the base theme's tokens, so an inherited slow band stays at the base's ratio."],
|
|
62
|
+
['typography, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
|
|
61
63
|
['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
|
|
62
64
|
]},
|
|
63
65
|
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `{@command theme build}` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
|
|
@@ -134,6 +136,8 @@ export const docs = {
|
|
|
134
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.'},
|
|
135
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.'},
|
|
136
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."},
|
|
137
141
|
],
|
|
138
142
|
},
|
|
139
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}`,
|
|
@@ -101,11 +101,92 @@ export const brandTheme = defineTheme({
|
|
|
101
101
|
},
|
|
102
102
|
});`,
|
|
103
103
|
},
|
|
104
|
+
{
|
|
105
|
+
type: 'prose',
|
|
106
|
+
text: "An entry can also be a function of the request, so the theme maps Icon's size to its icon library's own props or artwork. `Icon` calls it with `{size, variant}`, where `size` is the size it renders at (`xsm`, `sm`, `md`, or `lg`: an explicit `size`, else the owning component's default, else `md`). Reads that return one node — `getIcon()`, `useIcon()`, `getIconRegistry()`, and the theme's `icons` field — call it with `{size: 'md'}`. The same entry shape works in `registerIcons()`.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'code',
|
|
110
|
+
lang: 'tsx',
|
|
111
|
+
label: 'A size-aware icon entry',
|
|
112
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
113
|
+
import {Info} from 'lucide-react';
|
|
114
|
+
|
|
115
|
+
export const brandTheme = defineTheme({
|
|
116
|
+
name: 'brand',
|
|
117
|
+
icons: {
|
|
118
|
+
// A heavier stroke keeps the small size legible.
|
|
119
|
+
info: ({size}) => <Info strokeWidth={size === 'sm' || size === 'xsm' ? 2.5 : 2} />,
|
|
120
|
+
},
|
|
121
|
+
});`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'Keep the function pure and synchronous: it computes its result from the request only, with no hooks, DOM or SVG measurement, browser globals, network access, mutable module state, or side effects. Its result is final. Returning `null` draws no glyph instead of falling back to a registered or built-in icon, while a `null` or `undefined` node entry still falls back. A child theme that sets an entry for a key replaces the inherited entry for that key.',
|
|
126
|
+
},
|
|
104
127
|
],
|
|
105
128
|
},
|
|
106
129
|
{
|
|
107
|
-
title: '
|
|
130
|
+
title: 'Icon Variants',
|
|
108
131
|
category: 'foundations',
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'prose',
|
|
135
|
+
text: "A theme lists the icon variant names it supports once, with `iconVariants` in `defineTheme()`. The list belongs to the whole theme, never to one icon, and Astryx defines no names of its own. Inside `defineTheme`, an entry function receives `variant` typed as the listed names, or `undefined`, so a misspelled name is a type error. An entry that receives `undefined` draws its normal artwork.",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'code',
|
|
139
|
+
lang: 'tsx',
|
|
140
|
+
label: 'Listing variants and mapping them to artwork',
|
|
141
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
142
|
+
import {InfoFilledIcon, InfoIcon} from './brand-icons';
|
|
143
|
+
|
|
144
|
+
export const brandTheme = defineTheme({
|
|
145
|
+
name: 'brand',
|
|
146
|
+
iconVariants: ['outline', 'filled'],
|
|
147
|
+
icons: {
|
|
148
|
+
info: ({size, variant}) =>
|
|
149
|
+
variant === 'filled' ? <InfoFilledIcon /> : <InfoIcon bold={size === 'sm'} />,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
brandTheme.iconVariants; // ['outline', 'filled']`,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'prose',
|
|
157
|
+
text: 'A theme that `extends` another inherits its list unless it sets its own; a list it sets replaces the inherited one instead of merging with it.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'prose',
|
|
161
|
+
text: "Request a variant with `Icon`'s `variant` prop. The entry receives it only when the active theme lists it; an entry the theme inherited also needs the theme that defined it to list it. Otherwise the entry receives `undefined` and draws its normal artwork, so an unlisted variant never breaks rendering. A `registerIcons()` entry receives the variants the active theme lists, and a node entry draws the same node for every variant. An icon component passed directly to `Icon` never receives `variant`, and `variant` is never written to the DOM: it selects artwork, so there is no theming selector for it.",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'code',
|
|
165
|
+
lang: 'tsx',
|
|
166
|
+
label: 'Requesting a variant',
|
|
167
|
+
code: `<Icon icon="info" variant="filled" /> // brandTheme: the filled artwork
|
|
168
|
+
<Icon icon="info" /> // the normal artwork`,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
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`. `astryx theme build` writes this augmentation for a built theme\'s list.',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'code',
|
|
176
|
+
lang: 'ts',
|
|
177
|
+
label: 'Declaring the variant names an application uses',
|
|
178
|
+
code: `declare module '@astryxdesign/core/Icon' {
|
|
179
|
+
interface IconVariantMap {
|
|
180
|
+
outline: true;
|
|
181
|
+
filled: true;
|
|
182
|
+
}
|
|
183
|
+
}`,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
title: 'Component and Library Icons',
|
|
189
|
+
category: 'foundations',
|
|
109
190
|
content: [
|
|
110
191
|
{
|
|
111
192
|
type: 'prose',
|
|
@@ -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',
|
|
@@ -21,6 +21,14 @@ export const docsDense = {
|
|
|
21
21
|
{type: 'prose', text: "new palette: `astryx theme palette generate palette.config.json --out palette.generated.ts` → review + commit module and receipt → `import {palette} from './palette.generated';` → map semantic tokens to stable stops such as `palette.neutral.light[100]` / `palette.neutral.dark[15]`. regeneration updates mapped roles; generation does not rewrite the theme."},
|
|
22
22
|
],
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
section: 'Icon sizes',
|
|
26
|
+
title: 'Icon sizes',
|
|
27
|
+
content: [
|
|
28
|
+
{type: 'prose', text: "theme sets each Icon size's glyph dimension: `width` + `height` on `components.icon['size:sm']` (or xsm/md/lg); semantic names + SVG components alike. px or rem only: a semantic icon takes its font size from the dimension, so em also grows its box. unstyled: xsm/sm/md/lg = 12/16/20/24px at 16px root, scale w/ root font size (rem keeps it). size names are fixed."},
|
|
29
|
+
null,
|
|
30
|
+
],
|
|
31
|
+
},
|
|
24
32
|
{
|
|
25
33
|
section: 'Dark mode',
|
|
26
34
|
title: 'Dark mode',
|