@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.78641f8
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 +63 -63
- package/api/component/_adapter.mjs +4 -3
- package/api/component/component.mjs +13 -6
- package/api/component/doc-links.test.mjs +33 -0
- package/api/docs/_adapter.d.mts +80 -0
- package/api/docs/_adapter.mjs +261 -11
- package/api/docs/detail/detail.mjs +8 -0
- package/api/docs/docOverlays.test.mjs +2 -1
- package/api/docs/docs.d.mts +16 -6
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.mjs +55 -6
- package/api/docs/docs.type.d.mts +28 -2
- package/api/docs/docs.type.mjs +13 -3
- package/api/docs/guide-route-targets.test.mjs +1002 -0
- package/api/docs/index/index.mjs +9 -0
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +85 -0
- package/api/docs/list/list.mjs +7 -1
- package/api/docs/node/node.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +1 -1
- package/api/doctor/built-checks.mjs +43 -13
- package/api/doctor/built-checks.test.mjs +29 -0
- package/api/doctor/doctor.doc.mjs +2 -2
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/_adapter.d.mts +11 -2
- package/api/integration/_adapter.mjs +30 -4
- package/api/integration/authoring-checks.mjs +29 -2
- package/api/integration/authoring-checks.test.mjs +131 -1
- package/api/integration/check/check.d.mts +4 -1
- package/api/integration/check/check.mjs +34 -4
- package/api/integration/check/check.test.mjs +49 -0
- package/api/integration/example-checks.no-npm.test.mjs +140 -0
- package/api/integration/example-checks.test.mjs +776 -0
- package/api/integration/integration-check.type.d.mts +8 -0
- package/api/integration/integration-check.type.mjs +4 -1
- package/api/integration/integrationCheck.doc.mjs +8 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +65 -1
- package/api/integration/pack-check.test.mjs +63 -0
- package/api/integration/validate-integration-case-disk.test.mjs +14 -2
- package/api/integration/validate-integration-gaps.test.mjs +43 -19
- package/api/integration/validate-integration.mjs +112 -14
- package/api/integration/validate-integration.type.d.mts +23 -4
- package/api/integration/validate-integration.type.mjs +14 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_candidate-score.d.mts +9 -3
- package/api/search/_candidate-score.mjs +90 -3
- package/api/search/_gather-components.mjs +48 -1
- package/api/search/_gather-docs.mjs +12 -2
- package/api/search/_lexical.d.mts +12 -0
- package/api/search/_lexical.mjs +3 -0
- package/api/search/_priority.mjs +5 -2
- package/api/search/_score.d.mts +2 -1
- package/api/search/_score.mjs +4 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.family-members.test.mjs +124 -0
- package/api/search/search.family-word.test.mjs +146 -0
- package/api/search/search.mjs +28 -0
- package/api/template/template-suffix.test.mjs +26 -0
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/author-a-theme.doc.mjs +15 -15
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +16 -16
- package/assets/docs/is-my-code-good.doc.mjs +6 -6
- package/assets/docs/styling-overview.doc.mjs +5 -5
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
- package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
- package/assets/docs/tree/authoring.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +3 -3
- package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
- package/assets/docs/tree/checks.doc.mjs +11 -11
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +6 -6
- package/assets/docs/tree/codemods.doc.mjs +7 -7
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/component-lookups.doc.mjs +6 -5
- package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
- package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +11 -11
- package/assets/docs/tree/global.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +1 -1
- package/assets/docs/tree/install-once.doc.mjs +4 -4
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/migration-setup.doc.mjs +15 -15
- package/assets/docs/tree/migration.doc.mjs +2 -1
- package/assets/docs/tree/other-libraries.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +2 -2
- package/assets/docs/tree/problems.doc.mjs +8 -8
- package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +7 -7
- package/assets/docs/tree/quick-start.doc.mjs +9 -9
- package/assets/docs/tree/reference.doc.mjs +2 -2
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -4
- package/assets/docs/tree/start-a-template.doc.mjs +5 -5
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
- package/assets/docs/tree/styling.doc.mjs +1 -1
- package/assets/docs/tree/tailwind.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
- package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
- package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
- package/assets/docs/tree/uninstall.doc.mjs +2 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +4 -4
- package/assets/docs/tree/who-answers.doc.mjs +4 -4
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
- package/assets/docs/use-a-theme.doc.mjs +10 -10
- package/assets/docs/use-integrations.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +15 -15
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/authoring/codemod/codemod.doc.mjs +1 -1
- package/authoring/config/config.doc.mjs +4 -4
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/_schema.d.mts +4 -0
- package/authoring/doctypes/_schema.mjs +4 -0
- package/authoring/doctypes/reference/type.ts +14 -2
- package/authoring/gap-report/gap-report.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +27 -2
- package/clients/cli/commands/docs.test.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +12 -1
- package/clients/cli/commands/integration-check.doc.mjs +11 -0
- package/clients/cli/commands/integration-check.test.mjs +36 -3
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +1 -1
- package/clients/cli/commands/integration.mjs +15 -3
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +2 -2
- package/clients/cli/lib/define-command.mjs +5 -3
- package/foundation/agent-docs/agent-docs.d.mts +14 -2
- package/foundation/agent-docs/agent-docs.mjs +65 -4
- package/foundation/agent-docs/agent-docs.test.mjs +107 -0
- package/foundation/discovery/docs-discovery.d.mts +93 -2
- package/foundation/discovery/docs-discovery.mjs +237 -8
- package/foundation/discovery/runner-allowlist.d.mts +2 -0
- package/foundation/discovery/runner-allowlist.mjs +4 -0
- package/foundation/discovery/runner-commands.d.mts +29 -13
- package/foundation/discovery/runner-commands.mjs +253 -17
- package/foundation/discovery/stray-pointers.mjs +11 -5
- package/foundation/discovery/stray-pointers.test.mjs +6 -0
- package/foundation/discovery/template-adapter.mjs +11 -0
- package/foundation/doc-compiler/compile.mjs +8 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +7 -0
- package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
- package/foundation/doc-compiler/doc-syntax.mjs +739 -0
- package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
- package/foundation/doc-compiler/links.d.mts +13 -16
- package/foundation/doc-compiler/links.mjs +40 -7
- package/foundation/doc-compiler/tree.d.mts +5 -0
- package/foundation/doc-compiler/tree.mjs +9 -0
- package/foundation/env/package-manager.d.mts +18 -0
- package/foundation/env/package-manager.mjs +40 -0
- package/foundation/integrations/cli-requirement.d.mts +29 -0
- package/foundation/integrations/cli-requirement.mjs +47 -0
- package/foundation/integrations/cli-requirement.test.mjs +23 -2
- package/foundation/integrations/validate-contributions.d.mts +53 -0
- package/foundation/integrations/validate-contributions.mjs +788 -0
- package/foundation/response/response-types.doc.mjs +6 -6
- package/package.json +9 -9
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A family member named by short words is found by them spelled out:
|
|
5
|
+
* "vertical stack" is VStack, whose own description says so, and a member whose
|
|
6
|
+
* name is its head word after single letters is a match for that head word.
|
|
7
|
+
* The same holds for any integration's members, which no learned weights know.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
14
|
+
import {search} from './search.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
|
|
18
|
+
describe('family members found by their spelled-out names', () => {
|
|
19
|
+
it.each([
|
|
20
|
+
['vertical stack', 'VStack'],
|
|
21
|
+
['horizontal stack', 'HStack'],
|
|
22
|
+
])('`%s` ranks %s first', async (query, name) => {
|
|
23
|
+
const {results} = (await search(query)).data;
|
|
24
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
25
|
+
domain: 'component',
|
|
26
|
+
name,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('`stack` keeps Stack first and lists VStack and HStack', async () => {
|
|
31
|
+
const {results} = (await search('stack')).data;
|
|
32
|
+
expect(results[0]).toMatchObject({domain: 'component', name: 'Stack'});
|
|
33
|
+
const top = results.slice(0, 8).map(r => r.name);
|
|
34
|
+
expect(top).toContain('VStack');
|
|
35
|
+
expect(top).toContain('HStack');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('only a single-letter word is spelled out', async () => {
|
|
39
|
+
// "without" begins with "With" but spells out no letter of the name.
|
|
40
|
+
const {results} = (await search('checkbox list without end content')).data;
|
|
41
|
+
expect(results[0]?.reason).not.toMatch(/spelled out/);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('a longer query keeps Stack first', async () => {
|
|
45
|
+
// Stack in VStack counts as a keyword hit only when it is the whole query.
|
|
46
|
+
const {results} = (await search('vertical stack of cards')).data;
|
|
47
|
+
expect(results[0]).toMatchObject({domain: 'component', name: 'Stack'});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("a longer query does not lift a head word's members", async () => {
|
|
51
|
+
const {results} = (await search('stack direction')).data;
|
|
52
|
+
const top = results.slice(0, 3).map(r => r.name);
|
|
53
|
+
expect(top).not.toContain('VStack');
|
|
54
|
+
expect(top).not.toContain('HStack');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('a word the description does not spell out is no name', async () => {
|
|
58
|
+
const {results} = (await search('visual stack')).data;
|
|
59
|
+
expect(results[0]?.name).not.toBe('VStack');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("an integration's family members (cold start)", () => {
|
|
64
|
+
/** @type {string} */
|
|
65
|
+
let dir;
|
|
66
|
+
beforeAll(() => {
|
|
67
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-family-members-'));
|
|
68
|
+
const pkg = path.join(dir, 'node_modules', '@acme', 'grids');
|
|
69
|
+
fs.mkdirSync(path.join(pkg, 'components'), {recursive: true});
|
|
70
|
+
fs.mkdirSync(
|
|
71
|
+
path.join(dir, 'node_modules', '@astryxdesign', 'core', 'src'),
|
|
72
|
+
{
|
|
73
|
+
recursive: true,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"consumer"}');
|
|
77
|
+
fs.writeFileSync(
|
|
78
|
+
path.join(dir, 'astryx.config.mjs'),
|
|
79
|
+
"export default { integrations: ['@acme/grids'] };\n",
|
|
80
|
+
);
|
|
81
|
+
fs.writeFileSync(
|
|
82
|
+
path.join(pkg, 'package.json'),
|
|
83
|
+
'{"name":"@acme/grids","version":"1.0.0"}',
|
|
84
|
+
);
|
|
85
|
+
fs.writeFileSync(
|
|
86
|
+
path.join(pkg, 'astryx.integration.mjs'),
|
|
87
|
+
"export default { components: './components' };\n",
|
|
88
|
+
);
|
|
89
|
+
for (const [name, description] of [
|
|
90
|
+
['VGrid', 'Vertical grid for arranging tiles in columns.'],
|
|
91
|
+
['HGrid', 'Horizontal grid for arranging tiles in rows.'],
|
|
92
|
+
]) {
|
|
93
|
+
fs.writeFileSync(
|
|
94
|
+
path.join(pkg, 'components', `${name}.doc.mjs`),
|
|
95
|
+
`export default {
|
|
96
|
+
type: 'component',
|
|
97
|
+
name: '${name}',
|
|
98
|
+
usage: {description: '${description}'},
|
|
99
|
+
props: [],
|
|
100
|
+
};\n`,
|
|
101
|
+
);
|
|
102
|
+
fs.writeFileSync(
|
|
103
|
+
path.join(pkg, 'components', `${name}.tsx`),
|
|
104
|
+
`export function ${name}() { return null; }\n`,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
109
|
+
|
|
110
|
+
it.each([
|
|
111
|
+
['vertical grid', 'VGrid'],
|
|
112
|
+
['horizontal grid', 'HGrid'],
|
|
113
|
+
])(
|
|
114
|
+
'`%s` ranks %s first',
|
|
115
|
+
async (query, name) => {
|
|
116
|
+
const {results} = (await search(query, {cwd: dir, type: 'component'}))
|
|
117
|
+
.data;
|
|
118
|
+
expect(results[0], JSON.stringify(results.slice(0, 3))).toMatchObject({
|
|
119
|
+
name,
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
SLOW,
|
|
123
|
+
);
|
|
124
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file A query naming a family lists the first three members its family doc
|
|
5
|
+
* names, after the family's own entry: the family doc names them, so
|
|
6
|
+
* this holds with no component of the family's name (Chat) and for any
|
|
7
|
+
* integration's family, which no learned weights know.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import os from 'node:os';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
14
|
+
import {search} from './search.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
|
|
18
|
+
/** @param {{name: string, reason: string}[]} results */
|
|
19
|
+
const members = results =>
|
|
20
|
+
results.filter(r => /^member of /.test(r.reason)).map(r => r.name);
|
|
21
|
+
|
|
22
|
+
describe('a family word lists its first members', () => {
|
|
23
|
+
it('`table` keeps Table first and lists three of its members', async () => {
|
|
24
|
+
const {results} = (await search('table')).data;
|
|
25
|
+
expect(results[0]).toMatchObject({domain: 'component', name: 'Table'});
|
|
26
|
+
expect(members(results)).toHaveLength(3);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('`chat` lists Chat members though no Chat component exists', async () => {
|
|
30
|
+
const {results} = (await search('chat')).data;
|
|
31
|
+
const top = results.slice(0, 5).map(r => r.name);
|
|
32
|
+
expect(top.filter(n => n.startsWith('Chat')).length).toBeGreaterThan(0);
|
|
33
|
+
expect(members(results)).toHaveLength(3);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('a family word keeps its members ahead of passing doc sections', () => {
|
|
38
|
+
it('`selector` lists SelectorOption before any doc section', async () => {
|
|
39
|
+
const {results} = (await search('selector')).data;
|
|
40
|
+
const member = results.findIndex(r => r.name === 'SelectorOption');
|
|
41
|
+
const section = results.findIndex(r => r.domain === 'doc');
|
|
42
|
+
expect(member).toBeGreaterThan(-1);
|
|
43
|
+
expect(member).toBeLessThan(5);
|
|
44
|
+
if (section !== -1) expect(section).toBeGreaterThan(member);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('a synonym of a family name names no family', () => {
|
|
49
|
+
it.each(['message', 'messages'])(
|
|
50
|
+
'`%s` lists no member above the entries that declare it',
|
|
51
|
+
async query => {
|
|
52
|
+
const {results} = (await search(query)).data;
|
|
53
|
+
const top = results.slice(0, 5);
|
|
54
|
+
expect(top.some(r => /^member of /.test(r.reason))).toBe(false);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe("an integration's family (cold start)", () => {
|
|
60
|
+
/** @type {string} */
|
|
61
|
+
let dir;
|
|
62
|
+
beforeAll(() => {
|
|
63
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-family-word-'));
|
|
64
|
+
const pkg = path.join(dir, 'node_modules', '@acme', 'plots');
|
|
65
|
+
fs.mkdirSync(path.join(pkg, 'components'), {recursive: true});
|
|
66
|
+
fs.mkdirSync(
|
|
67
|
+
path.join(dir, 'node_modules', '@astryxdesign', 'core', 'src'),
|
|
68
|
+
{
|
|
69
|
+
recursive: true,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"consumer"}');
|
|
73
|
+
fs.writeFileSync(
|
|
74
|
+
path.join(dir, 'astryx.config.mjs'),
|
|
75
|
+
"export default { integrations: ['@acme/plots'] };\n",
|
|
76
|
+
);
|
|
77
|
+
fs.writeFileSync(
|
|
78
|
+
path.join(pkg, 'package.json'),
|
|
79
|
+
'{"name":"@acme/plots","version":"1.0.0","main":"components/Plot.tsx"}',
|
|
80
|
+
);
|
|
81
|
+
fs.writeFileSync(
|
|
82
|
+
path.join(pkg, 'astryx.integration.mjs'),
|
|
83
|
+
"export default { components: './components' };\n",
|
|
84
|
+
);
|
|
85
|
+
const names = ['Plot', 'PlotAxis', 'PlotLegend', 'PlotLine', 'PlotTooltip'];
|
|
86
|
+
// A member with a doc of its own, which the family doc names by name.
|
|
87
|
+
fs.writeFileSync(
|
|
88
|
+
path.join(pkg, 'components', 'PlotTitle.doc.mjs'),
|
|
89
|
+
`export default {
|
|
90
|
+
type: 'component',
|
|
91
|
+
name: 'PlotTitle',
|
|
92
|
+
usage: {description: 'The title above a plot.'},
|
|
93
|
+
props: [],
|
|
94
|
+
};\n`,
|
|
95
|
+
);
|
|
96
|
+
fs.writeFileSync(
|
|
97
|
+
path.join(pkg, 'components', 'PlotTitle.tsx'),
|
|
98
|
+
'export function PlotTitle() {\n return null;\n}\n',
|
|
99
|
+
);
|
|
100
|
+
fs.writeFileSync(
|
|
101
|
+
path.join(pkg, 'components', 'Plot.doc.mjs'),
|
|
102
|
+
`export default {
|
|
103
|
+
type: 'component',
|
|
104
|
+
name: 'Plot',
|
|
105
|
+
import: '@acme/plots',
|
|
106
|
+
usage: {description: 'A plot of data series.'},
|
|
107
|
+
props: [],
|
|
108
|
+
components: ${JSON.stringify([
|
|
109
|
+
...names.slice(0, 1).map(name => ({
|
|
110
|
+
name,
|
|
111
|
+
usage: {description: `The ${name} part of a plot.`},
|
|
112
|
+
props: [],
|
|
113
|
+
})),
|
|
114
|
+
{name: 'PlotTitle'},
|
|
115
|
+
...names.slice(1).map(name => ({
|
|
116
|
+
name,
|
|
117
|
+
usage: {description: `The ${name} part of a plot.`},
|
|
118
|
+
props: [],
|
|
119
|
+
})),
|
|
120
|
+
])},
|
|
121
|
+
};\n`,
|
|
122
|
+
);
|
|
123
|
+
fs.writeFileSync(
|
|
124
|
+
path.join(pkg, 'components', 'Plot.tsx'),
|
|
125
|
+
names.map(n => `export function ${n}() {\n return null;\n}\n`).join(''),
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
129
|
+
|
|
130
|
+
it(
|
|
131
|
+
'`plot` lists the first three members its doc names, after Plot',
|
|
132
|
+
async () => {
|
|
133
|
+
const {results} = (await search('plot', {cwd: dir, type: 'component'}))
|
|
134
|
+
.data;
|
|
135
|
+
// The first three members the doc lists, one with a doc of its own.
|
|
136
|
+
expect(results[0]).toMatchObject({name: 'Plot'});
|
|
137
|
+
expect(
|
|
138
|
+
results
|
|
139
|
+
.slice(1, 4)
|
|
140
|
+
.map(r => r.name)
|
|
141
|
+
.sort(),
|
|
142
|
+
).toEqual(['PlotAxis', 'PlotLegend', 'PlotTitle']);
|
|
143
|
+
},
|
|
144
|
+
SLOW,
|
|
145
|
+
);
|
|
146
|
+
});
|
package/api/search/search.mjs
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
* reads it, so build's output does not move when search's tree does.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import {
|
|
18
|
+
docPackageManager,
|
|
19
|
+
runWithDocPackageManager,
|
|
20
|
+
} from '../../foundation/env/package-manager.mjs';
|
|
17
21
|
import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
18
22
|
import {
|
|
19
23
|
gatherCandidates,
|
|
@@ -52,6 +56,18 @@ export {componentKeywords} from './_adapter.mjs';
|
|
|
52
56
|
*/
|
|
53
57
|
export async function search(query, options = {}) {
|
|
54
58
|
checkSearchArgs(query, options);
|
|
59
|
+
return runWithDocPackageManager(
|
|
60
|
+
docPackageManager(options.cwd ?? process.cwd()),
|
|
61
|
+
() => searchRead(query, options),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The search itself, inside its project's package-manager scope.
|
|
67
|
+
* @param {string} query
|
|
68
|
+
* @param {any} options
|
|
69
|
+
*/
|
|
70
|
+
async function searchRead(query, options) {
|
|
55
71
|
return withListingCache(
|
|
56
72
|
async () =>
|
|
57
73
|
/** @type {import('./search.type.mjs').SearchResponse} */ (
|
|
@@ -79,6 +95,18 @@ export async function search(query, options = {}) {
|
|
|
79
95
|
*/
|
|
80
96
|
export async function searchCore(query, options = {}) {
|
|
81
97
|
checkSearchArgs(query, options);
|
|
98
|
+
return runWithDocPackageManager(
|
|
99
|
+
docPackageManager(options.cwd ?? process.cwd()),
|
|
100
|
+
() => searchCoreRead(query, options),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The lexical search itself, inside its project's package-manager scope.
|
|
106
|
+
* @param {string} query
|
|
107
|
+
* @param {any} options
|
|
108
|
+
*/
|
|
109
|
+
async function searchCoreRead(query, options) {
|
|
82
110
|
return withListingCache(async () =>
|
|
83
111
|
linkSearchResponse(
|
|
84
112
|
rankLexical(query, options, await gatherCandidates(options)),
|
|
@@ -250,6 +250,32 @@ describe('external showcase blocks: canonical .doc.* plus released .template.* c
|
|
|
250
250
|
expect(result.name).toBe('Bar — Showcase');
|
|
251
251
|
});
|
|
252
252
|
|
|
253
|
+
it('findShowcase prefers the showcase that names the component in exampleFor', async () => {
|
|
254
|
+
makeShowcaseFixture();
|
|
255
|
+
// Bar's showcase also uses Chip; Chip's own showcase sits in a folder
|
|
256
|
+
// that does not carry its name and says so only through exampleFor.
|
|
257
|
+
const dir = path.join(
|
|
258
|
+
tmpDir,
|
|
259
|
+
'node_modules',
|
|
260
|
+
'@test',
|
|
261
|
+
'ext',
|
|
262
|
+
'blocks',
|
|
263
|
+
'components',
|
|
264
|
+
'Gallery',
|
|
265
|
+
);
|
|
266
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
267
|
+
fs.writeFileSync(
|
|
268
|
+
path.join(dir, 'ChipCard.doc.mjs'),
|
|
269
|
+
"export default {type: 'block', name: 'Chip — Card', description: 'Chip showcase.', category: 'Test - Showcases', exampleFor: 'Chip', isShowcase: true, componentsUsed: ['Chip']};\n",
|
|
270
|
+
);
|
|
271
|
+
fs.writeFileSync(
|
|
272
|
+
path.join(dir, 'ChipCard.tsx'),
|
|
273
|
+
"'use client';\nexport default function ChipCard() { return <div>Chip</div>; }",
|
|
274
|
+
);
|
|
275
|
+
const result = await findShowcase('Chip', tmpDir);
|
|
276
|
+
expect(result?.name).toBe('Chip — Card');
|
|
277
|
+
});
|
|
278
|
+
|
|
253
279
|
it('findRelatedBlocks finds both suffix families', async () => {
|
|
254
280
|
makeShowcaseFixture();
|
|
255
281
|
const foo = await findRelatedBlocks('Foo', tmpDir);
|
|
@@ -20,7 +20,7 @@ export const doc = {
|
|
|
20
20
|
summary:
|
|
21
21
|
'Compile a defineTheme() file to scoped CSS, a JS module, and type declarations, or check committed outputs for drift in CI.',
|
|
22
22
|
description:
|
|
23
|
-
'The compiler behind `
|
|
23
|
+
'The compiler behind `{@command theme build}`. Reads a file that calls defineTheme() and ' +
|
|
24
24
|
'writes a scoped CSS file, a JS module that re-exports the built theme, and a .d.ts ' +
|
|
25
25
|
'(plus an optional .variants.d.ts when the theme adds custom prop values). It uses ' +
|
|
26
26
|
"@astryxdesign/core's own generator, so the CSS matches what the <Theme> runtime emits. " +
|
|
@@ -13,7 +13,7 @@ export const doc = {
|
|
|
13
13
|
displayName: 'themeList()',
|
|
14
14
|
summary: 'List themes bundled with this CLI build.',
|
|
15
15
|
description:
|
|
16
|
-
'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `
|
|
16
|
+
'Synchronous list of the themes bundled with the CLI. It does not include themes from installed integrations; use themeListAvailable() for the list `{@command theme list}` shows.',
|
|
17
17
|
importPath: '@astryxdesign/cli/api',
|
|
18
18
|
signature: 'themeList(): ThemeListResponse',
|
|
19
19
|
keywords: ['theme', 'list', 'themes', 'bundled', 'available'],
|
|
@@ -18,7 +18,7 @@ export const doc = {
|
|
|
18
18
|
description:
|
|
19
19
|
'Enumerates the whole themeable surface: each `defineTheme` components key, the stable ' +
|
|
20
20
|
'class it paints, the component that declares it, and the props and states that are legal ' +
|
|
21
|
-
'override keys under it. Same source as the Theming table `
|
|
21
|
+
'override keys under it. Same source as the Theming table `{@command component <Name>}` prints ' +
|
|
22
22
|
'(the component docs), so the list cannot drift from the components, and `theme build` ' +
|
|
23
23
|
'validates overrides against this exact set. A filter naming a component gives that ' +
|
|
24
24
|
"component's set; anything else is a case-insensitive substring search over each target's key, class and component.",
|
|
@@ -243,6 +243,22 @@
|
|
|
243
243
|
{
|
|
244
244
|
"kind": "template",
|
|
245
245
|
"name": "EmojiPickerShowcase"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"kind": "template",
|
|
249
|
+
"name": "ListInputBudgetAllocation"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"kind": "template",
|
|
253
|
+
"name": "ListInputFamilyMembers"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"kind": "template",
|
|
257
|
+
"name": "ListInputMailingList"
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"kind": "template",
|
|
261
|
+
"name": "ListInputShowcase"
|
|
246
262
|
}
|
|
247
263
|
]
|
|
248
264
|
},
|
|
@@ -15,8 +15,8 @@ export const docs = {
|
|
|
15
15
|
title: 'Custom themes',
|
|
16
16
|
content: [
|
|
17
17
|
{type: 'prose', text: "Use an installed built theme as the base for ordinary customization. Import it into your source and pass it as `extends` to `defineTheme({extends: importedTheme, ...})`. Build the result, then add the local slug. Only eject when you need to own and maintain a full source fork."},
|
|
18
|
-
{type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: '
|
|
19
|
-
{type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `
|
|
18
|
+
{type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: '{@command theme list}\n{@command theme add stone}\n{@command theme eject stone}\n{@command theme build src/themes/stone/stoneTheme.ts}\n{@command theme add stone}'},
|
|
19
|
+
{type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `{@command theme template}`. It writes `theme.template.ts` into your project to read and copy from (`{@command init --features theme}` writes it as part of project setup)."},
|
|
20
20
|
{type: 'prose', text: 'To apply a theme you created, see {@link generic:use-a-theme}. To generate colors from seed values, see the Palette section below. Before you eject a package theme instead, see when that fits in {@link generic:use-a-theme}.'},
|
|
21
21
|
],
|
|
22
22
|
},
|
|
@@ -26,9 +26,9 @@ export const docs = {
|
|
|
26
26
|
content: [
|
|
27
27
|
{type: 'prose', text: 'Name a few seed colors and generate every shade a theme needs, light and dark; {@link generic:generate-a-palette} explains what a palette holds.'},
|
|
28
28
|
{type: 'code', lang: 'json', label: 'Minimal palette config (palette.config.json)', code: '{"families": [{"id": "ocean", "seed": "#0074e2"}]}'},
|
|
29
|
-
{type: 'code', lang: 'bash', label: 'Generate and preview', code: '# Print the palette without writing files\
|
|
29
|
+
{type: 'code', lang: 'bash', label: 'Generate and preview', code: '# Print the palette without writing files\n{@command theme palette generate palette.config.json}\n\n# Write palette + receipt, and open a visual preview\n{@command theme palette generate palette.config.json} \\\n --out src/themes/ocean/tokens/ocean.palette.ts \\\n --preview preview.html'},
|
|
30
30
|
{type: 'prose', text: "The command writes a `.ts` file exporting 21 shades (stops 0–100) for both light and dark, plus a `.receipt.json` to regenerate later. Point your theme's tokens at the palette, then run defineTheme (see below)."},
|
|
31
|
-
{type: 'prose', text: 'For the full palette config fields and CLI flags, run `
|
|
31
|
+
{type: 'prose', text: 'For the full palette config fields and CLI flags, run `{@command docs cli/commands/theme-palette-generate}`. For the integration-authoring walkthrough of connecting a palette to theme tokens, run `{@command docs authoring/building-blocks/themes/generate-a-palette}`.'},
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -60,8 +60,8 @@ export const docs = {
|
|
|
60
60
|
['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
|
|
61
61
|
['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
62
|
]},
|
|
63
|
-
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `
|
|
64
|
-
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `
|
|
63
|
+
{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."},
|
|
64
|
+
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `{@command docs authoring/building-blocks/themes/define-the-theme}`.'},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -69,15 +69,15 @@ export const docs = {
|
|
|
69
69
|
content: [
|
|
70
70
|
{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling-advanced}.'},
|
|
71
71
|
{type: 'code', lang: 'tsx', label: 'Component overrides with standard CSS', code: "components: {\n card: {\n base: { borderRadius: '20px', padding: '24px' },\n },\n button: {\n base: {\n borderRadius: '9999px',\n textTransform: 'uppercase',\n '--button-focus-offset': '3px',\n },\n 'variant:ghost': { borderWidth: '2px', borderStyle: 'solid' },\n },\n}"},
|
|
72
|
-
{type: 'prose', text: "Run `
|
|
72
|
+
{type: 'prose', text: "Run `{@command theme targets}` for every themeable key in the system (`{@command theme targets <Name>}` to scope it, `--json` to lint a theme against it), and `{@command component <Name>}` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},
|
|
73
73
|
{type: 'list', style: 'do', items: ['Write standard CSS properties (borderRadius, padding); the pipeline expands them into internal vars.', 'Set public CSS vars directly when no standard property equivalent exists.']},
|
|
74
|
-
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `
|
|
74
|
+
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `{@command theme build}` will error.', 'Set a public CSS var the component does not define. It compiles to CSS that never applies, and the build does not warn. Take the names from `{@command component <Name>}`.']},
|
|
75
75
|
],
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
title: 'Custom Variants',
|
|
79
79
|
content: [
|
|
80
|
-
{type: 'prose', text: "Themes can add new prop values to any component. Any `prop:value` key where the value isn't a built-in gets treated as a new variant. Use `
|
|
80
|
+
{type: 'prose', text: "Themes can add new prop values to any component. Any `prop:value` key where the value isn't a built-in gets treated as a new variant. Use `{@command theme build}` to generate TypeScript augmentations for type safety."},
|
|
81
81
|
{type: 'code', lang: 'tsx', label: 'Adding custom variants', code: "components: {\n button: {\n 'variant:secondary': { backgroundColor: 'rgba(0,0,0,0.06)' },\n 'variant:primary-muted': {\n backgroundColor: 'light-dark(#F2F4F6, #28292C)',\n color: 'var(--color-text-primary)',\n },\n },\n banner: {\n 'status:neutral': {\n backgroundColor: 'var(--color-background-muted)',\n color: 'var(--color-text-secondary)',\n },\n },\n}"},
|
|
82
82
|
{type: 'code', lang: 'tsx', label: 'Using custom variants', code: "// TypeScript knows about 'primary-muted' after astryx theme build\n<Button variant=\"primary-muted\" label=\"Save draft\" />\n<Banner status=\"neutral\" title=\"Note\" />"},
|
|
83
83
|
{type: 'prose', text: "Custom variants only work when the theme that defines them is active. The component's variant map is extended via module augmentation, with no changes to the component source needed."},
|
|
@@ -104,15 +104,15 @@ export const docs = {
|
|
|
104
104
|
{type: 'prose', text: "Precedence follows rule order. Root theme values apply first, then every matching rule in declaration order. A later rule may deliberately restore a root value. `onDark` and `onLight` media-surface overrides apply after adaptations and win on the same leaf."},
|
|
105
105
|
{type: 'prose', text: "`extends` preserves the base rule order and appends child rules. Inherited conditions use the child's effective breakpoint map. An empty child rule is a no-op, not a removal operator."},
|
|
106
106
|
{type: 'prose', text: "A rule may replace a theme-local token only when the exact name is already enrolled by root `localTokens` or an enrolled base. Component writes in a rule are validated exactly like root `components`: same targets, axes, and value domains. The one addition is that a rule may not be the only place a custom value is enrolled: a value that is valid only because a theme enrolls it generates unconditional type augmentation, so declare it on the root theme first and let rules restyle it. Built-in values need no root declaration. When rules can match together, their ordered portable and local token writes are validated as one effective graph; any reachable cycle fails before CSS is emitted."},
|
|
107
|
-
{type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `
|
|
107
|
+
{type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `{@command theme build}` use the same compiler, but only a built theme is present at first paint in an SSR app.'},
|
|
108
108
|
],
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
id: 'building-themes-for-production',
|
|
112
112
|
title: 'Build a theme',
|
|
113
113
|
content: [
|
|
114
|
-
{type: 'prose', text: '`
|
|
115
|
-
{type: 'code', lang: 'bash', label: 'Build a theme', code: '
|
|
114
|
+
{type: 'prose', text: '`{@command theme build}` compiles a defineTheme file into production-ready artifacts. Recommended for SSR apps (Next.js, Remix) where styles must be present on first paint.'},
|
|
115
|
+
{type: 'code', lang: 'bash', label: 'Build a theme', code: '{@command theme build ./src/themes/ocean.ts}'},
|
|
116
116
|
{type: 'table', headers: ['File', 'Description'], rows: [
|
|
117
117
|
['ocean.css', 'Pre-compiled CSS with token overrides, component overrides, and prose element styles in @scope rules'],
|
|
118
118
|
['ocean.js', 'ES module exporting the theme object with `__built: true` and pre-resolved token values.'],
|
|
@@ -121,7 +121,7 @@ export const docs = {
|
|
|
121
121
|
]},
|
|
122
122
|
{type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},
|
|
123
123
|
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core/theme';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
124
|
-
{type: 'prose', text: "After upgrading Astryx, rerun `
|
|
124
|
+
{type: 'prose', text: "After upgrading Astryx, rerun `{@command theme build}` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},
|
|
125
125
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
126
126
|
],
|
|
127
127
|
},
|
|
@@ -130,7 +130,7 @@ export const docs = {
|
|
|
130
130
|
title: 'Built themes with an icon registry',
|
|
131
131
|
content: [
|
|
132
132
|
{type: 'prose', text: "`theme build` emits an icon import when it detects a named import used by the theme's `icons:` field. It does not compile that registry module. Move the registry to a separate module and use a named import."},
|
|
133
|
-
{type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\
|
|
133
|
+
{type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\n{@command theme build ./src/themes/ocean.ts -o dist/theme.css --icons-specifier ./icons.mjs}\n\n# Compile the icon registry alongside it\nesbuild src/themes/icons.tsx --bundle --format=esm --outfile=dist/icons.mjs \\\n --external:react --external:lucide-react --jsx=automatic"},
|
|
134
134
|
{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
135
|
{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
136
|
{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},
|
|
@@ -140,7 +140,7 @@ export const docs = {
|
|
|
140
140
|
title: 'Building a Theme Family',
|
|
141
141
|
content: [
|
|
142
142
|
{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file, beside the root source.'},
|
|
143
|
-
{type: 'code', lang: 'bash', label: 'Build one family', code: "
|
|
143
|
+
{type: 'code', lang: 'bash', label: 'Build one family', code: "{@command theme build} --family \\\n ./src/themes/ocean.mjs \\\n ./src/themes/ocean-calm.mjs \\\n ./src/themes/ocean-calm-deep.mjs \\\n --family-key ocean-family"},
|
|
144
144
|
{type: 'prose', text: 'The family stylesheet eagerly downloads every selected member so first paint is complete. Switching members changes only the theme identity; it does not add, remove, or reorder stylesheets.'},
|
|
145
145
|
],
|
|
146
146
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
export const docs = {
|
|
6
6
|
name: 'browser-support',
|
|
7
|
-
title: 'Browser
|
|
7
|
+
title: 'Browser support',
|
|
8
8
|
category: 'guide',
|
|
9
9
|
description:
|
|
10
10
|
'What browsers Astryx targets, which modern platform features it depends on, and how to support older browsers for your own audience.',
|
|
@@ -21,7 +21,7 @@ export const docs = {
|
|
|
21
21
|
type: 'code',
|
|
22
22
|
lang: 'text',
|
|
23
23
|
label: 'Set up the design system',
|
|
24
|
-
code: 'Install @astryxdesign/core, @stylexjs/stylex, @astryxdesign/theme-neutral, and @astryxdesign/cli in this project, then run `
|
|
24
|
+
code: 'Install @astryxdesign/core, @stylexjs/stylex, @astryxdesign/theme-neutral, and @astryxdesign/cli in this project, then run `{@command init}` to set up agent docs. Read the generated files to learn the conventions.',
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
type: 'prose',
|
|
@@ -31,7 +31,7 @@ export const docs = {
|
|
|
31
31
|
type: 'code',
|
|
32
32
|
lang: 'text',
|
|
33
33
|
label: 'Give it a look',
|
|
34
|
-
code: 'Ask me what look and feel this app should have. Run `
|
|
34
|
+
code: 'Ask me what look and feel this app should have. Run `{@command theme list}`, install the closest theme package, and run `theme add <slug>`; use `--package` when owners share a slug. Import `themes` and `defaultThemeSlug` from the generated module once and pass `themes[defaultThemeSlug]` to `<Theme>`. Customize with `defineTheme({extends: importedTheme, ...})`. Use `theme eject` only when I ask for an independent source fork. Default to neutral if I have no preference, and show me the result before moving on.',
|
|
35
35
|
},
|
|
36
36
|
],
|
|
37
37
|
},
|
|
@@ -50,17 +50,17 @@ export const docs = {
|
|
|
50
50
|
type: 'code',
|
|
51
51
|
lang: 'bash',
|
|
52
52
|
label: 'Terminal',
|
|
53
|
-
code: `
|
|
53
|
+
code: `{@pm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral @astryxdesign/cli}`,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
type: 'prose',
|
|
57
|
-
text: "Then run `
|
|
57
|
+
text: "Then run `{@command init}` to install the AI agent cheat sheet (AGENTS.md/CLAUDE.md). It's non-interactive; no prompts; so it's safe for AI agents, CI, and scripts. Add `--all` for pointers to the theme and page-building workflows.",
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
type: 'code',
|
|
61
61
|
lang: 'bash',
|
|
62
62
|
label: 'Terminal',
|
|
63
|
-
code: `
|
|
63
|
+
code: `{@command init}`,
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
@@ -76,7 +76,7 @@ export const docs = {
|
|
|
76
76
|
type: 'code',
|
|
77
77
|
lang: 'bash',
|
|
78
78
|
label: 'Terminal',
|
|
79
|
-
code: `
|
|
79
|
+
code: `{@pm install @astryxdesign/cli --global}`,
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
type: 'prose',
|
|
@@ -89,7 +89,7 @@ export const docs = {
|
|
|
89
89
|
content: [
|
|
90
90
|
{
|
|
91
91
|
type: 'prose',
|
|
92
|
-
text: 'Import the reset and base styles in your global CSS. Then run `
|
|
92
|
+
text: 'Import the reset and base styles in your global CSS. Then run `{@command theme add neutral}`; the generated app module imports the theme’s production CSS and font CSS.',
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
type: 'code',
|
|
@@ -100,7 +100,7 @@ export const docs = {
|
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
type: 'prose',
|
|
103
|
-
text: 'Run `
|
|
103
|
+
text: 'Run `{@command theme list}` to see every theme.',
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
type: 'code',
|
|
@@ -139,7 +139,7 @@ import {themes, defaultThemeSlug} from './astryx-themes';
|
|
|
139
139
|
content: [
|
|
140
140
|
{
|
|
141
141
|
type: 'prose',
|
|
142
|
-
text: 'Import each component from its own entry, the path `
|
|
142
|
+
text: 'Import each component from its own entry, the path `{@command component <Name>}` prints. This keeps bundles small and makes intent clear.',
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
type: 'code',
|
|
@@ -218,8 +218,8 @@ const overrides = stylex.create({
|
|
|
218
218
|
label: 'Clone and run an example',
|
|
219
219
|
code: `git clone https://github.com/facebook/astryx.git
|
|
220
220
|
cd astryx/apps/example-nextjs
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
{@pm install}
|
|
222
|
+
{@pm run dev}`,
|
|
223
223
|
},
|
|
224
224
|
],
|
|
225
225
|
},
|
|
@@ -246,11 +246,11 @@ pnpm dev`,
|
|
|
246
246
|
type: 'code',
|
|
247
247
|
lang: 'bash',
|
|
248
248
|
label: 'Terminal',
|
|
249
|
-
code: `
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
code: `{@command component} # list all components
|
|
250
|
+
{@command component Button} # props, usage, theming for Button
|
|
251
|
+
{@command docs} # list all doc topics
|
|
252
|
+
{@command template --list} # available page templates
|
|
253
|
+
{@command docs tokens} # spacing, color, radius reference`,
|
|
254
254
|
},
|
|
255
255
|
],
|
|
256
256
|
},
|