@astryxdesign/cli 0.1.6-canary.06b5c6e → 0.1.6-canary.0c9b3ba

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.
Files changed (67) hide show
  1. package/docs/integration-authoring.md +105 -0
  2. package/docs/internationalization.doc.mjs +243 -0
  3. package/docs/layout.doc.dense.mjs +5 -0
  4. package/docs/principles.doc.dense.mjs +5 -5
  5. package/docs/principles.doc.zh.mjs +5 -5
  6. package/docs/theme.doc.dense.mjs +12 -12
  7. package/docs/theme.doc.zh.mjs +10 -10
  8. package/docs/tokens.doc.dense.mjs +6 -7
  9. package/docs/tokens.doc.zh.mjs +6 -7
  10. package/package.json +13 -9
  11. package/src/api/docOverlays.test.mjs +133 -0
  12. package/src/api/docs.mjs +14 -2
  13. package/src/api/integration-block-exports.test.mjs +240 -0
  14. package/src/api/template-suffix.test.mjs +246 -0
  15. package/src/api/template.mjs +104 -28
  16. package/src/api/validate-integration.mjs +0 -8
  17. package/src/codemods/__tests__/registry.test.mjs +1 -0
  18. package/src/codemods/registry.mjs +1 -0
  19. package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +120 -0
  20. package/src/codemods/transforms/v0.1.7/__tests__/rename-table-renderprops-styles-to-xstyle.test.mjs +112 -0
  21. package/src/codemods/transforms/v0.1.7/index.mjs +27 -0
  22. package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +188 -0
  23. package/src/codemods/transforms/v0.1.7/rename-table-renderprops-styles-to-xstyle.mjs +197 -0
  24. package/src/commands/agent-docs.mjs +14 -0
  25. package/src/commands/agent-docs.test.mjs +20 -0
  26. package/src/config.mjs +5 -14
  27. package/src/doc.mjs +27 -0
  28. package/src/doc.test.mjs +383 -0
  29. package/src/integration.mjs +4 -15
  30. package/src/lib/component-discovery.importpath.test.mjs +59 -0
  31. package/src/lib/component-discovery.mjs +15 -5
  32. package/src/lib/component-format.mjs +45 -13
  33. package/src/lib/component-format.test.mjs +95 -1
  34. package/src/lib/component-loader.mjs +104 -2
  35. package/src/lib/componentDocOverlay.test.mjs +111 -0
  36. package/src/lib/config-schema.mjs +0 -30
  37. package/src/lib/hook-format.mjs +8 -3
  38. package/src/lib/xle/registry.mjs +0 -5
  39. package/src/schemas/doc-schema.mjs +226 -0
  40. package/src/schemas/template-schema.mjs +47 -0
  41. package/src/template.mjs +9 -67
  42. package/src/types/config.d.ts +11 -66
  43. package/src/types/doc.d.ts +23 -0
  44. package/src/types/integration.d.ts +7 -18
  45. package/src/types/template-api.d.ts +14 -50
  46. package/templates/blocks/components/Avatar/AvatarGroup.tsx +5 -7
  47. package/templates/blocks/components/Avatar/AvatarShowcase.tsx +4 -6
  48. package/templates/blocks/components/Avatar/AvatarUserCard.tsx +3 -5
  49. package/templates/blocks/components/Avatar/AvatarWithImage.tsx +8 -6
  50. package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +3 -5
  51. package/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx +1 -1
  52. package/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx +1 -1
  53. package/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +1 -1
  54. package/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +1 -1
  55. package/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx +1 -1
  56. package/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx +1 -1
  57. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +14 -0
  58. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +41 -0
  59. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +13 -0
  60. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +78 -0
  61. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +14 -0
  62. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +38 -0
  63. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +14 -0
  64. package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +47 -0
  65. package/templates/pages/ide/page.tsx +35 -41
  66. package/templates/pages/theme-showcase/page.tsx +7 -7
  67. package/templates/themes/neutral/neutralTheme.ts +63 -32
@@ -0,0 +1,105 @@
1
+ # Authoring an Astryx Integration
2
+
3
+ > **Status:** working notes. This should eventually move to the public wiki
4
+ > alongside the rest of the integration-authoring guidance; it lives here for
5
+ > now so it ships and is versioned with the CLI.
6
+
7
+ An **Integration** is an npm package that contributes components, templates, and/or
8
+ codemods to a consumer's design-system workflow. Consumers install the 3rd party
9
+ package, add a line to their astryx.config file:
10
+
11
+ ```js
12
+ import {createConfig} from '@astryxdesign/cli/config';
13
+
14
+ export default createConfig({
15
+ integrations: ['@acme/astryx-widgets'],
16
+ ...
17
+ });
18
+ ```
19
+
20
+ Then the integration's components and templates will be surfaced alongside Astryx
21
+ components in the Astryx CLI.
22
+
23
+ ```sh
24
+ astryx component AcmeCarousel --props
25
+ astryx component --list --package @acme/astryx-widgets
26
+ ```
27
+
28
+ ## The Integration File
29
+
30
+ In order to register your package as an Astryx Integration, create an
31
+ `astryx.integration.{ts,mjs,js}` file as a sibling to your `package.json`. This file
32
+ tells Astryx where to find your components, templates, codemods, etc.
33
+
34
+ ```js
35
+ // astryx.integration.{ts,mjs,js}
36
+ import {createIntegration} from '@astryxdesign/cli/integration';
37
+
38
+ export default createIntegration({
39
+ components: './components',
40
+ templates: './templates',
41
+ codemods: './codemods',
42
+ issuesUrl: 'https://github.com/acme/widgets/issues',
43
+ });
44
+ ```
45
+
46
+ ## Components
47
+
48
+ Your components themselves may be exported from your library as you see fit (consumers
49
+ will still import them from your package) but Astryx CLI will look for a .doc.{ts,mjs,js}
50
+ file with the same stem e.g. `AcmeCarousel.tsx` and `AcmeCarousel.doc.ts`.
51
+
52
+ ```js
53
+ // AcmeCarousel.doc.ts
54
+ import {createComponentDoc} from '@astryxdesign/cli/doc';
55
+
56
+ export default createComponentDoc({
57
+ name: 'AcmeCarousel',
58
+ description: '...',
59
+ ...
60
+ });
61
+ ```
62
+
63
+ ## Templates
64
+
65
+ Templates are typically not exported from the package directly, but instead accessed
66
+ via the Astryx CLI. Consumers can look through your templates and materialize them
67
+ into their apps.
68
+
69
+ You define a template with the `createPageTemplate` (for full pages) or `createBlockTemplate`
70
+ (for smaller chunks). e.g. `AcmeLandingPage.tsx`, `AcmeLandingPage.template.ts`
71
+
72
+ ```js
73
+ // AcmeLandingPage.template.ts
74
+ import {createPageTemplate} from '@astryxdesign/cli/template';
75
+
76
+ export default createPageTemplate({
77
+ ...
78
+ });
79
+ ```
80
+
81
+ Note that, since the CLI needs access to the template source code, you need to make sure
82
+ that it is included in your published package. This will also allow us to render previews
83
+ of templates in the future by bundling your template into a doc site build.
84
+
85
+ Typically, this is done via the package.json `exports` key.
86
+
87
+ ```jsonc
88
+ {
89
+ "exports": {
90
+ // ...
91
+ "./templates/*.tsx": "./templates/*.tsx",
92
+ },
93
+ }
94
+ ```
95
+
96
+ In order to verify that it's working, you can test importing the template component like this:
97
+
98
+ ```ts
99
+ import('@acme/astryx-widgets/templates/AcmeLandingPage.tsx');
100
+ ```
101
+
102
+ Import **with the `.tsx` extension** — an extensionless specifier won't resolve
103
+ under `moduleResolution: bundler`. The extensionful `"./templates/*.tsx"` export
104
+ above is what lets that import type-check without consumers enabling
105
+ `allowImportingTsExtensions`.
@@ -0,0 +1,243 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('../../core/src/docs-types').ReferenceDoc} */
4
+
5
+ export const docs = {
6
+ name: 'internationalization',
7
+ title: 'Internationalization',
8
+ category: 'guide',
9
+ description:
10
+ 'Localize astryx component strings, provide translation catalogs, override default text, coexist with your own i18n library, swap languages at runtime, and test translations with the pseudo locale.',
11
+
12
+ sections: [
13
+ {
14
+ title: 'Quick Start',
15
+ category: 'guide',
16
+ content: [
17
+ {
18
+ type: 'prose',
19
+ text: 'Internationalization ships with `@astryxdesign/core`. There is nothing to install. Wrap your app in `<InternationalizationProvider>` and set a `locale`, and astryx components pick up localized strings automatically.',
20
+ },
21
+ {
22
+ type: 'code',
23
+ lang: 'tsx',
24
+ label: 'Wrap your app',
25
+ code: `import {InternationalizationProvider} from '@astryxdesign/core';
26
+
27
+ function App() {
28
+ return (
29
+ <InternationalizationProvider locale="en">
30
+ <YourApp />
31
+ </InternationalizationProvider>
32
+ );
33
+ }`,
34
+ },
35
+ {
36
+ type: 'code',
37
+ lang: 'tsx',
38
+ label: 'Read strings inside a component',
39
+ code: `import {useTranslator} from '@astryxdesign/core';
40
+
41
+ function SaveButton() {
42
+ const t = useTranslator();
43
+ return <button>{t('@myapp.actions.save')}</button>;
44
+ }`,
45
+ },
46
+ {
47
+ type: 'prose',
48
+ text: 'The hook is available to consumer components too, but using it is entirely optional: many teams keep their app strings on their existing i18n library (react-intl, i18next, next-intl, LinguiJS) and only use `useTranslator` when reading astryx keys. If you do route your own strings through it, we recommend namespacing them (`@myapp.*` or your npm scope) to keep them separated from `@astryx.*`, but this is a convention, not a requirement; the resolver treats every key as an opaque string.',
49
+ },
50
+ {
51
+ type: 'prose',
52
+ text: "Astryx ships translations only for English today. First-party translations for other locales are on the roadmap; track https://github.com/facebook/astryx/issues/3641. In the meantime, if you want astryx UI translated into another locale, you can ship your own catalog through the `messages` prop (covered in the next section). If you're using `useTranslator` for your own strings, you'll want to ship your own catalog either way, since astryx only carries the fallback for `@astryx.*` keys, not the ones you author.",
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ title: 'Providing locale catalogs',
58
+ category: 'guide',
59
+ content: [
60
+ {
61
+ type: 'prose',
62
+ text: 'Astryx bundles only the English catalog today. To render in any other locale, provide a translation catalog through the `messages` prop and set `locale` accordingly. This matches how MUI, Ant Design, and AG Grid work: the consumer app supplies the catalogs it actually needs so unused translations stay out of the bundle.',
63
+ },
64
+ {
65
+ type: 'code',
66
+ lang: 'tsx',
67
+ label: 'Add French',
68
+ code: `import {InternationalizationProvider} from '@astryxdesign/core';
69
+ import fr from './locales/astryx/fr.json';
70
+
71
+ <InternationalizationProvider locale="fr" messages={{fr}}>
72
+ <App />
73
+ </InternationalizationProvider>;`,
74
+ },
75
+ {
76
+ type: 'prose',
77
+ text: "See `@astryxdesign/core/locales/en.json` for the full inventory of keys to translate. Copy it as the starting point: every key you translate replaces the English default; anything you omit falls back through the locale chain to English (e.g. `pt-BR` walks to `pt` then to shipped `en`), so a partial translation renders as a mix rather than empty text or raw key names.",
78
+ },
79
+ {
80
+ type: 'prose',
81
+ text: 'A community-maintained set of astryx translations is on the roadmap but not shipped yet. For now, consumer apps that ship in multiple languages own their astryx catalogs alongside their app catalogs. Contributions to a first-party set are welcome; track discussion at https://github.com/facebook/astryx/issues/3641.',
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ title: "Overriding astryx's default text",
87
+ category: 'guide',
88
+ content: [
89
+ {
90
+ type: 'prose',
91
+ text: 'Use `overrides` to change individual strings without shipping a full catalog. Overrides are keyed by locale and merged on top of the built-in and user-supplied catalogs.',
92
+ },
93
+ {
94
+ type: 'code',
95
+ lang: 'tsx',
96
+ label: 'Change one string in English',
97
+ code: `<InternationalizationProvider
98
+ locale="en"
99
+ overrides={{en: {'@astryx.pagination.next': 'Next →'}}}
100
+ >
101
+ <App />
102
+ </InternationalizationProvider>`,
103
+ },
104
+ {
105
+ type: 'prose',
106
+ text: 'Overrides win over both bundled English and any `messages` catalog for the same key. Use them for brand voice tweaks or one-off wording changes.',
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ title: 'Using astryx with your own i18n library',
112
+ category: 'guide',
113
+ content: [
114
+ {
115
+ type: 'prose',
116
+ text: "Astryx components render astryx strings through astryx's provider. Consumer components render consumer strings through whatever i18n library you already use: react-intl, i18next, next-intl, LinguiJS, and so on. The two systems coexist and read from the same source of truth for the active locale.",
117
+ },
118
+ {
119
+ type: 'code',
120
+ lang: 'tsx',
121
+ label: 'Astryx + react-intl side by side',
122
+ code: `import {InternationalizationProvider} from '@astryxdesign/core';
123
+ import {Selector} from '@astryxdesign/core/Selector';
124
+ import {Button} from '@astryxdesign/core/Button';
125
+ import {FormattedMessage, IntlProvider, useIntl} from 'react-intl';
126
+ import astryxFr from './locales/astryx/fr.json'; // astryx's UI, in French
127
+ import appFr from './locales/app/fr.json'; // your app strings, in French
128
+
129
+ function Pricing() {
130
+ // Consumer strings — resolved by react-intl.
131
+ const intl = useIntl();
132
+
133
+ return (
134
+ <section>
135
+ <h1><FormattedMessage id="pricing.heading" /></h1>
136
+
137
+ {/* Astryx Selector — trigger placeholder, search-box placeholder,
138
+ clear-button aria-label all resolved by
139
+ <InternationalizationProvider>. Options come from react-intl. */}
140
+ <Selector
141
+ label={intl.formatMessage({id: 'pricing.region.label'})}
142
+ options={[
143
+ {value: 'na', label: intl.formatMessage({id: 'pricing.region.na'})},
144
+ {value: 'eu', label: intl.formatMessage({id: 'pricing.region.eu'})},
145
+ ]}
146
+ hasSearch
147
+ hasClear
148
+ />
149
+
150
+ <Button label={intl.formatMessage({id: 'pricing.cta.subscribe'})} />
151
+ </section>
152
+ );
153
+ }
154
+
155
+ export default function App() {
156
+ return (
157
+ // Same locale, two providers reading their own catalogs.
158
+ <IntlProvider locale="fr" messages={appFr}>
159
+ <InternationalizationProvider locale="fr" messages={{fr: astryxFr}}>
160
+ <Pricing />
161
+ </InternationalizationProvider>
162
+ </IntlProvider>
163
+ );
164
+ }`,
165
+ },
166
+ {
167
+ type: 'prose',
168
+ text: 'Keep the two providers in sync on locale, and each library owns its own catalog. Astryx never sees your app strings, and your i18n library never sees astryx internals. Runtime locale swap works the same way: re-render both providers with a new `locale` prop and the whole tree updates live.',
169
+ },
170
+ {
171
+ type: 'prose',
172
+ 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 https://github.com/facebook/astryx/issues/4029. For now, run the two providers side by side as shown above.",
173
+ },
174
+ ],
175
+ },
176
+ {
177
+ title: 'Runtime language swap',
178
+ category: 'guide',
179
+ content: [
180
+ {
181
+ type: 'prose',
182
+ text: 'Re-render `<InternationalizationProvider>` with a new `locale` prop and every astryx string updates live. No reload, no separate API call.',
183
+ },
184
+ {
185
+ type: 'code',
186
+ lang: 'tsx',
187
+ label: 'Toggle between locales',
188
+ code: `const [locale, setLocale] = useState<'en' | 'fr'>('en');
189
+
190
+ <InternationalizationProvider locale={locale} messages={{fr}}>
191
+ <Button
192
+ label={locale === 'en' ? 'Français' : 'English'}
193
+ onClick={() => setLocale(l => (l === 'en' ? 'fr' : 'en'))}
194
+ />
195
+ <App />
196
+ </InternationalizationProvider>;`,
197
+ },
198
+ {
199
+ type: 'prose',
200
+ text: "Persisting the user's choice (localStorage, cookie, URL segment, account setting) is up to the consumer. Astryx reads whatever `locale` you pass in.",
201
+ },
202
+ ],
203
+ },
204
+ {
205
+ title: 'Testing your translations',
206
+ category: 'guide',
207
+ content: [
208
+ {
209
+ type: 'prose',
210
+ text: 'Astryx generates a `pseudo` locale that wraps every string in `⟦…⟧` and replaces letters with accented look-alikes. Switching to it in development instantly reveals any astryx string that isn\'t going through the translator, plus any layout that breaks under longer text.',
211
+ },
212
+ {
213
+ type: 'code',
214
+ lang: 'tsx',
215
+ label: 'Turn on pseudo-localization',
216
+ code: `import pseudo from '@astryxdesign/core/locales/pseudo.json';
217
+
218
+ <InternationalizationProvider locale="pseudo" messages={{pseudo}}>
219
+ <App />
220
+ </InternationalizationProvider>;`,
221
+ },
222
+ {
223
+ type: 'prose',
224
+ text: 'Any bare English text you still see on screen is a hardcoded string that needs to be routed through `useTranslator`.',
225
+ },
226
+ {
227
+ type: 'prose',
228
+ text: "Pseudoloc also has a subtle caveat worth knowing: the pseudo catalog is complete (astryx generates it from every shipped key), so a component using an astryx-shipped key will always render its pseudo version. Your handwritten translation catalogs, on the other hand, only cover the keys you translated; anything missing falls back to English. That means \"looks perfect in pseudo\" is not the same guarantee as \"looks perfect in French.\" Check each real locale by hand for coverage gaps.",
229
+ },
230
+ ],
231
+ },
232
+ {
233
+ title: 'For contributors',
234
+ category: 'guide',
235
+ content: [
236
+ {
237
+ type: 'prose',
238
+ text: "Astryx's own strings live in `packages/core/locales/en.json`. New user-facing strings must go through `useTranslator`; this is enforced by the `@astryx/no-hardcoded-i18n-string` ESLint rule. See the AI contribution guide for the alias-and-resolve pattern used when adding new keys.",
239
+ },
240
+ ],
241
+ },
242
+ ],
243
+ };
@@ -7,6 +7,7 @@ export const docsDense = {
7
7
  'frame-first app layout: shell choice, region budgets, cards vs rows',
8
8
  sections: [
9
9
  {
10
+ section: 'Frame First',
10
11
  title: 'Frame First',
11
12
  content: [
12
13
  {
@@ -26,6 +27,7 @@ export const docsDense = {
26
27
  ],
27
28
  },
28
29
  {
30
+ section: 'App Archetypes',
29
31
  title: 'App Archetypes',
30
32
  content: [
31
33
  {
@@ -40,6 +42,7 @@ export const docsDense = {
40
42
  ],
41
43
  },
42
44
  {
45
+ section: 'Cards vs Rows',
43
46
  title: 'Cards vs Rows',
44
47
  content: [
45
48
  {
@@ -67,6 +70,7 @@ export const docsDense = {
67
70
  ],
68
71
  },
69
72
  {
73
+ section: 'Panels and Inspectors',
70
74
  title: 'Panels and Inspectors',
71
75
  content: [
72
76
  {
@@ -77,6 +81,7 @@ export const docsDense = {
77
81
  ],
78
82
  },
79
83
  {
84
+ section: 'Responsive Contract',
80
85
  title: 'Responsive Contract',
81
86
  content: [
82
87
  {
@@ -5,10 +5,10 @@
5
5
  export const docsDense = {
6
6
  description: 'core design principles + rules for the design system',
7
7
  sections: [
8
- { title: 'Philosophy', content: [{ type: 'list', items: ['components over primitives', 'semantic tokens over hardcoded values', 'theme-agnostic code', 'open internals'] }] },
9
- { title: 'Rules', content: [{ type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content (astryx docs layout)', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling', 'semantic tokens only', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
10
- { title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout. See astryx docs styling.' }] },
11
- { title: 'Anti-Patterns', content: [{ type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'no Card-wrapped list items — frame first, rows for dense data (astryx docs layout)', 'no decorative Badge — StatusDot/Token for status', 'read docs before inventing props'] }] },
12
- { title: 'Tokens', content: [{ type: 'prose', text: 'run npx astryx docs tokens for full reference' }] },
8
+ { section: 'Design Philosophy', title: 'Philosophy', content: [{ type: 'list', items: ['components over primitives', 'semantic tokens over hardcoded values', 'theme-agnostic code', 'open internals'] }] },
9
+ { section: 'Rules', title: 'Rules', content: [{ type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content (astryx docs layout)', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling', 'semantic tokens only', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
10
+ { section: 'Styling Approach', title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout. See astryx docs styling.' }] },
11
+ { section: 'Anti-Patterns', title: 'Anti-Patterns', content: [{ type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'no Card-wrapped list items — frame first, rows for dense data (astryx docs layout)', 'no decorative Badge — StatusDot/Token for status', 'read docs before inventing props'] }] },
12
+ { section: 'Design Tokens', title: 'Tokens', content: [{ type: 'prose', text: 'run npx astryx docs tokens for full reference' }] },
13
13
  ],
14
14
  };
@@ -5,10 +5,10 @@
5
5
  export const docsZh = {
6
6
  description: 'XDS 核心设计原则和规则。',
7
7
  sections: [
8
- { title: '设计哲学', content: [{ type: 'list', items: ['组件优于原始元素 — 优先使用 XDS 组件', '语义化令牌优于硬编码值', '主题无关的代码 — 深色模式自动生效', '开放的内部机制 — 所有基础组件均可导出和组合'] }] },
9
- { title: '规则', content: [{ type: 'list', items: ['所有支持的场景都使用 XDS 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 astryx docs layout)', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置', '使用语义化令牌,不使用硬编码值', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
10
- { title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。详见 astryx docs styling。' }] },
11
- { title: '反模式', content: [{ type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要把每个列表项都包在 Card 里 — 先定框架,密集数据用行渲染(见 astryx docs layout)', '不要把 Badge 当装饰 — 状态请使用 StatusDot 或 Token', '不要自创属性。先阅读组件文档'] }] },
12
- { title: '设计令牌', content: [{ type: 'prose', text: '运行 npx astryx docs tokens 查看完整参考' }] },
8
+ { section: 'Design Philosophy', title: '设计哲学', content: [{ type: 'list', items: ['组件优于原始元素 — 优先使用 XDS 组件', '语义化令牌优于硬编码值', '主题无关的代码 — 深色模式自动生效', '开放的内部机制 — 所有基础组件均可导出和组合'] }] },
9
+ { section: 'Rules', title: '规则', content: [{ type: 'list', items: ['所有支持的场景都使用 XDS 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 astryx docs layout)', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置', '使用语义化令牌,不使用硬编码值', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
10
+ { section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。详见 astryx docs styling。' }] },
11
+ { section: 'Anti-Patterns', title: '反模式', content: [{ type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要把每个列表项都包在 Card 里 — 先定框架,密集数据用行渲染(见 astryx docs layout)', '不要把 Badge 当装饰 — 状态请使用 StatusDot 或 Token', '不要自创属性。先阅读组件文档'] }] },
12
+ { section: 'Design Tokens', title: '设计令牌', content: [{ type: 'prose', text: '运行 npx astryx docs tokens 查看完整参考' }] },
13
13
  ],
14
14
  };
@@ -5,17 +5,17 @@
5
5
  export const docsDense = {
6
6
  description: 'Theme provider, custom themes, light/dark, component overrides',
7
7
  sections: [
8
- { title: 'Quick Start', content: [null, null, null, null, { type: 'prose', text: 'default import = runtime injection. /built import = pre-compiled CSS (pair with theme.css).' }] },
9
- { title: 'Themes', content: [null, null, { type: 'prose', text: 'published: neutral (start here), butter, chocolate, gothic (dark-only), matcha, stone, y2k. @astryxdesign/theme-{name} = source (runtime). @astryxdesign/theme-{name}/built = optimized (+ theme.css).' }] },
10
- { title: 'Props', content: [null] },
11
- { title: 'Custom Theme', content: [{ type: 'prose', text: 'CLI wizard or manual defineTheme. only override tokens that differ.' }, null] },
12
- { title: 'defineTheme', content: [{ type: 'prose', text: 'scale configs (color, typography, radius, motion) + explicit token overrides + component overrides. color derives full palette from accent hex via HCT.' }, null, null] },
13
- { title: 'Component Overrides', content: [{ type: 'prose', text: 'components field uses semantic component keys + style keys (base, variant:value, stateName), not raw selectors. for external CSS, prefer data-* selectors from `astryx docs styling`. write standard CSS (borderRadius, padding) — pipeline expands to internal vars. public vars (--button-press-scale etc) set directly. private vars (--_*) cannot be set — use CSS properties. run `npx astryx component <Name>` for details.' }, null, null, null, null] },
14
- { title: 'Custom Variants', content: [{ type: 'prose', text: 'any unknown prop:value in components becomes a new variant. astryx theme build generates TS augmentations. works on any extensible prop axis (variant, status, etc).' }, null, null, null, null] },
15
- { title: 'Build for Production', content: [{ type: 'prose', text: 'npx astryx theme build compiles defineTheme to static CSS. outputs .css + .js (__built:true) + .d.ts.' }, null, null, null, null] },
16
- { title: 'Runtime vs Built', content: [{ type: 'prose', text: 'runtime: useInsertionEffect injects styles client-side. built: static CSS on first paint. USE /built + theme.css FOR SSR.' }, null, null, null] },
17
- { title: 'Light/Dark', content: [{ type: 'prose', text: 'light-dark() in token values via [light, dark] tuples. mode=system follows OS.' }, null, null] },
18
- { title: 'Nesting', content: [{ type: 'prose', text: 'wrap sections in separate <Theme> providers' }, null] },
19
- { title: 'useTheme', content: [null, { type: 'prose', text: 'read-only. manage state at app level.' }] },
8
+ { section: 'Quick Start', title: 'Quick Start', content: [null, null, null, null, { type: 'prose', text: 'default import = runtime injection. /built import = pre-compiled CSS (pair with theme.css).' }] },
9
+ { section: 'Available Themes', title: 'Themes', content: [null, null, { type: 'prose', text: 'published: neutral (start here), butter, chocolate, gothic (dark-only), matcha, stone, y2k. @astryxdesign/theme-{name} = source (runtime). @astryxdesign/theme-{name}/built = optimized (+ theme.css).' }] },
10
+ { section: 'Theme Props', title: 'Props', content: [null] },
11
+ { section: 'Creating a Custom Theme', title: 'Custom Theme', content: [{ type: 'prose', text: 'CLI wizard or manual defineTheme. only override tokens that differ.' }, null] },
12
+ { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: 'scale configs (color, typography, radius, motion) + explicit token overrides + component overrides. color derives full palette from accent hex via HCT.' }, null, null] },
13
+ { section: 'Component Style Overrides', title: 'Component Overrides', content: [{ type: 'prose', text: 'components field uses semantic component keys + style keys (base, variant:value, stateName), not raw selectors. for external CSS, prefer data-* selectors from `astryx docs styling`. write standard CSS (borderRadius, padding) — pipeline expands to internal vars. public vars (--button-press-scale etc) set directly. private vars (--_*) cannot be set — use CSS properties. run `npx astryx component <Name>` for details.' }, null, null, null, null] },
14
+ { section: 'Custom Variants', title: 'Custom Variants', content: [{ type: 'prose', text: 'any unknown prop:value in components becomes a new variant. astryx theme build generates TS augmentations. works on any extensible prop axis (variant, status, etc).' }, null, null, null, null] },
15
+ { section: 'Building Themes for Production', title: 'Build for Production', content: [{ type: 'prose', text: 'npx astryx theme build compiles defineTheme to static CSS. outputs .css + .js (__built:true) + .d.ts.' }, null, null, null, null] },
16
+ { section: 'Runtime vs Built Themes', title: 'Runtime vs Built', content: [{ type: 'prose', text: 'runtime: useInsertionEffect injects styles client-side. built: static CSS on first paint. USE /built + theme.css FOR SSR.' }, null, null, null] },
17
+ { section: 'Light/Dark Mode', title: 'Light/Dark', content: [{ type: 'prose', text: 'light-dark() in token values via [light, dark] tuples. mode=system follows OS.' }, null, null] },
18
+ { section: 'Nesting Themes', title: 'Nesting', content: [{ type: 'prose', text: 'wrap sections in separate <Theme> providers' }, null] },
19
+ { section: 'useTheme Hook', title: 'useTheme', content: [null, { type: 'prose', text: 'read-only. manage state at app level.' }] },
20
20
  ],
21
21
  };
@@ -5,15 +5,15 @@
5
5
  export const docsZh = {
6
6
  description: 'Theme 提供者、自定义主题、亮/暗模式和组件样式覆盖。',
7
7
  sections: [
8
- { title: '快速开始', content: [null, null, null, null, { type: 'prose', text: '默认导入使用运行时样式注入。/built 导入使用预编译 CSS(需配合 theme.css)。' }] },
9
- { title: '可用主题', content: [null, null, { type: 'prose', text: '已发布主题:neutral(推荐起点)、butter、chocolate、gothic(仅暗色)、matcha、stone、y2k。@astryxdesign/theme-{name} = 源码版(运行时注入)。@astryxdesign/theme-{name}/built = 优化版(配合 theme.css)。' }] },
10
- { title: 'Theme 属性', content: [null] },
11
- { title: '创建自定义主题', content: [{ type: 'prose', text: '使用 CLI 向导(推荐)或手动 defineTheme。只覆盖与默认值不同的令牌。' }, null] },
12
- { title: 'defineTheme', content: [{ type: 'prose', text: '支持比例配置(typography、radius、motion)+ 显式令牌覆盖 + 组件覆盖。' }, null, null] },
13
- { title: '生产构建', content: [{ type: 'prose', text: 'npx astryx theme build 将 defineTheme 编译为静态 CSS。输出 .css + .js(__built:true)+ .d.ts。' }, null, null, null, null] },
14
- { title: '运行时 vs 构建', content: [{ type: 'prose', text: '运行时:useInsertionEffect 在客户端注入样式。构建:静态 CSS 在首次渲染时就存在。SSR 应用请使用 /built + theme.css。' }, null, null, null] },
15
- { title: '亮/暗模式', content: [{ type: 'prose', text: "令牌值使用 [light, dark] 元组实现自动模式切换。Theme 上 mode='system'(默认)跟随系统偏好。" }, null, null] },
16
- { title: '嵌套主题', content: [{ type: 'prose', text: '将不同部分包裹在独立的 <Theme> 提供者中。' }, null] },
17
- { title: 'useTheme 钩子', content: [null, { type: 'prose', text: '这是只读的。要更改主题/模式,在应用层管理状态并传递给 <Theme>。' }] },
8
+ { section: 'Quick Start', title: '快速开始', content: [null, null, null, null, { type: 'prose', text: '默认导入使用运行时样式注入。/built 导入使用预编译 CSS(需配合 theme.css)。' }] },
9
+ { section: 'Available Themes', title: '可用主题', content: [null, null, { type: 'prose', text: '已发布主题:neutral(推荐起点)、butter、chocolate、gothic(仅暗色)、matcha、stone、y2k。@astryxdesign/theme-{name} = 源码版(运行时注入)。@astryxdesign/theme-{name}/built = 优化版(配合 theme.css)。' }] },
10
+ { section: 'Theme Props', title: 'Theme 属性', content: [null] },
11
+ { section: 'Creating a Custom Theme', title: '创建自定义主题', content: [{ type: 'prose', text: '使用 CLI 向导(推荐)或手动 defineTheme。只覆盖与默认值不同的令牌。' }, null] },
12
+ { section: 'defineTheme', title: 'defineTheme', content: [{ type: 'prose', text: '支持比例配置(typography、radius、motion)+ 显式令牌覆盖 + 组件覆盖。' }, null, null] },
13
+ { section: 'Building Themes for Production', title: '生产构建', content: [{ type: 'prose', text: 'npx astryx theme build 将 defineTheme 编译为静态 CSS。输出 .css + .js(__built:true)+ .d.ts。' }, null, null, null, null] },
14
+ { section: 'Runtime vs Built Themes', title: '运行时 vs 构建', content: [{ type: 'prose', text: '运行时:useInsertionEffect 在客户端注入样式。构建:静态 CSS 在首次渲染时就存在。SSR 应用请使用 /built + theme.css。' }, null, null, null] },
15
+ { section: 'Light/Dark Mode', title: '亮/暗模式', content: [{ type: 'prose', text: "令牌值使用 [light, dark] 元组实现自动模式切换。Theme 上 mode='system'(默认)跟随系统偏好。" }, null, null] },
16
+ { section: 'Nesting Themes', title: '嵌套主题', content: [{ type: 'prose', text: '将不同部分包裹在独立的 <Theme> 提供者中。' }, null] },
17
+ { section: 'useTheme Hook', title: 'useTheme 钩子', content: [null, { type: 'prose', text: '这是只读的。要更改主题/模式,在应用层管理状态并传递给 <Theme>。' }] },
18
18
  ],
19
19
  };
@@ -5,12 +5,11 @@
5
5
  export const docsDense = {
6
6
  description: 'spacing/color/radius/type/shadow token ref',
7
7
  sections: [
8
- { title: 'Spacing', content: [{ type: 'prose', text: 'defined in tokens.stylex.ts. gap props use space0-space12.' }, null] },
9
- { title: 'Size', content: [{ type: 'prose', text: 'control heights for buttons/inputs/selectors.' }, null] },
10
- { title: 'Color', content: [{ type: 'prose', text: 'semantic colors, support light-dark() auto switching.' }, null, null, null] },
11
- { title: 'Radius', content: [null] },
12
- { title: 'Elevation', content: [null] },
13
- { title: 'Typography', content: [null, null, null, null] },
14
- { title: 'StyleX Usage', content: [null, null] },
8
+ { section: 'Color Tokens', title: 'Color', content: [{ type: 'prose', text: 'semantic colors, support light-dark() auto switching.' }, null, null, null] },
9
+ { section: 'Spacing Tokens', title: 'Spacing', content: [{ type: 'prose', text: 'defined in tokens.stylex.ts. gap props use space0-space12.' }, null] },
10
+ { section: 'Size Tokens', title: 'Size', content: [{ type: 'prose', text: 'control heights for buttons/inputs/selectors.' }, null] },
11
+ { section: 'Radius Tokens', title: 'Radius', content: [null] },
12
+ { section: 'Shadow Tokens', title: 'Elevation', content: [null] },
13
+ { section: 'Usage in StyleX', title: 'StyleX Usage', content: [null, null] },
15
14
  ],
16
15
  };
@@ -5,12 +5,11 @@
5
5
  export const docsZh = {
6
6
  description: '间距、颜色、圆角、排版和阴影设计令牌参考。',
7
7
  sections: [
8
- { title: '间距令牌', content: [{ type: 'prose', text: '所有设计令牌定义在 packages/core/src/theme/tokens.stylex.ts 中。组件的 gap 属性使用 space0-space12 映射到这些令牌。' }, null] },
9
- { title: '尺寸令牌', content: [{ type: 'prose', text: '控制按钮、输入框和选择器的一致高度。' }, null] },
10
- { title: '颜色令牌', content: [{ type: 'prose', text: '语义化颜色,支持 light-dark() 自动切换模式。' }, null, null, null] },
11
- { title: '圆角令牌', content: [null] },
12
- { title: '阴影令牌', content: [null] },
13
- { title: '排版令牌', content: [null, null, null, null] },
14
- { title: 'StyleX 用法', content: [null, null] },
8
+ { section: 'Color Tokens', title: '颜色令牌', content: [{ type: 'prose', text: '语义化颜色,支持 light-dark() 自动切换模式。' }, null, null, null] },
9
+ { section: 'Spacing Tokens', title: '间距令牌', content: [{ type: 'prose', text: '所有设计令牌定义在 packages/core/src/theme/tokens.stylex.ts 中。组件的 gap 属性使用 space0-space12 映射到这些令牌。' }, null] },
10
+ { section: 'Size Tokens', title: '尺寸令牌', content: [{ type: 'prose', text: '控制按钮、输入框和选择器的一致高度。' }, null] },
11
+ { section: 'Radius Tokens', title: '圆角令牌', content: [null] },
12
+ { section: 'Shadow Tokens', title: '阴影令牌', content: [null] },
13
+ { section: 'Usage in StyleX', title: 'StyleX 用法', content: [null, null] },
15
14
  ],
16
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.6-canary.06b5c6e",
3
+ "version": "0.1.6-canary.0c9b3ba",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -47,6 +47,10 @@
47
47
  "types": "./src/types/integration.d.ts",
48
48
  "import": "./src/integration.mjs"
49
49
  },
50
+ "./doc": {
51
+ "types": "./src/types/doc.d.ts",
52
+ "import": "./src/doc.mjs"
53
+ },
50
54
  "./template": {
51
55
  "types": "./src/types/template-api.d.ts",
52
56
  "import": "./src/template.mjs"
@@ -75,10 +79,10 @@
75
79
  "zod": "^4.4.3"
76
80
  },
77
81
  "peerDependencies": {
78
- "@astryxdesign/charts": "0.1.6-canary.06b5c6e",
79
- "@astryxdesign/core": "0.1.6-canary.06b5c6e",
80
- "@astryxdesign/lab": "0.1.6-canary.06b5c6e",
81
- "@astryxdesign/theme-neutral": "0.1.6-canary.06b5c6e",
82
+ "@astryxdesign/charts": "0.1.6-canary.0c9b3ba",
83
+ "@astryxdesign/core": "0.1.6-canary.0c9b3ba",
84
+ "@astryxdesign/lab": "0.1.6-canary.0c9b3ba",
85
+ "@astryxdesign/theme-neutral": "0.1.6-canary.0c9b3ba",
82
86
  "gpt-tokenizer": "^3.4.0"
83
87
  },
84
88
  "peerDependenciesMeta": {
@@ -96,10 +100,10 @@
96
100
  }
97
101
  },
98
102
  "devDependencies": {
99
- "@astryxdesign/charts": "0.1.6-canary.06b5c6e",
100
- "@astryxdesign/core": "0.1.6-canary.06b5c6e",
101
- "@astryxdesign/lab": "0.1.6-canary.06b5c6e",
102
- "@astryxdesign/theme-neutral": "0.1.6-canary.06b5c6e",
103
+ "@astryxdesign/charts": "0.1.6-canary.0c9b3ba",
104
+ "@astryxdesign/core": "0.1.6-canary.0c9b3ba",
105
+ "@astryxdesign/lab": "0.1.6-canary.0c9b3ba",
106
+ "@astryxdesign/theme-neutral": "0.1.6-canary.0c9b3ba",
103
107
  "gpt-tokenizer": "^3.4.0"
104
108
  },
105
109
  "scripts": {