@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.
Files changed (38) hide show
  1. package/CHANGELOG.md +3 -3
  2. package/api/hook/detail/detail.test.mjs +11 -0
  3. package/api/swizzle/copy/copy.mjs +1 -1
  4. package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
  5. package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
  6. package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
  7. package/api/theme/build/build.icon-variants.test.mjs +105 -0
  8. package/api/theme/build/build.mjs +362 -109
  9. package/api/theme/build/build.project-core.test.mjs +63 -8
  10. package/api/theme/build/build.test.mjs +77 -0
  11. package/api/theme/build/icon-imports.d.mts +12 -2
  12. package/api/theme/build/icon-imports.mjs +36 -11
  13. package/assets/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
  14. package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
  15. package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
  16. package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
  17. package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
  18. package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
  19. package/assets/docs/README.md +13 -13
  20. package/assets/docs/author-a-theme.doc.mjs +5 -1
  21. package/assets/docs/getting-started.doc.mjs +5 -5
  22. package/assets/docs/icons.doc.mjs +82 -1
  23. package/assets/docs/motion.doc.mjs +1 -1
  24. package/assets/docs/theme.doc.dense.mjs +8 -0
  25. package/assets/docs/theme.doc.mjs +16 -0
  26. package/assets/docs/theme.doc.zh.mjs +11 -0
  27. package/assets/docs/tree/i18n-library-integration.doc.mjs +1 -1
  28. package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
  29. package/assets/docs/tree/tokens.doc.mjs +1 -1
  30. package/assets/theme.template.ts +19 -6
  31. package/authoring/config/config.doc.mjs +1 -1
  32. package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
  33. package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
  34. package/foundation/config/project.d.mts +1 -1
  35. package/foundation/config/project.mjs +1 -1
  36. package/foundation/debug/redact.test.mjs +1 -1
  37. package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
  38. package/package.json +12 -12
@@ -53,6 +53,22 @@ export const docs = {
53
53
  },
54
54
  ],
55
55
  },
56
+ {
57
+ id: 'icon-sizes',
58
+ title: 'Icon sizes',
59
+ content: [
60
+ {
61
+ type: 'prose',
62
+ text: "A theme sets the dimension of each Icon size in its stylesheet: `width` and `height` on `components.icon['size:sm']` (or `xsm`, `md`, `lg`) resize that size's glyph, for semantic icon names and SVG components passed to `Icon` alike. Give the dimension in `px` or `rem`: a semantic icon takes its font size from it, so an `em` value would also grow its box. A size the theme leaves alone stays 12, 16, 20, or 24px at a 16px root (`xsm`, `sm`, `md`, `lg`) and scales with the root font size; `rem` keeps that scaling. The four size names are fixed.",
63
+ },
64
+ {
65
+ type: 'code',
66
+ lang: 'tsx',
67
+ label: 'Set Icon size dimensions',
68
+ code: "const brandTheme = defineTheme({\n name: 'brand',\n components: {\n icon: {\n 'size:sm': {width: '1.125rem', height: '1.125rem'},\n 'size:lg': {width: '1.75rem', height: '1.75rem'},\n },\n },\n});",
69
+ },
70
+ ],
71
+ },
56
72
  {
57
73
  id: 'light-dark-mode',
58
74
  title: 'Dark mode',
@@ -25,6 +25,17 @@ export const docsZh = {
25
25
  },
26
26
  ],
27
27
  },
28
+ {
29
+ section: 'Icon sizes',
30
+ title: '图标尺寸',
31
+ content: [
32
+ {
33
+ type: 'prose',
34
+ text: "主题在样式表中设置每个 Icon 尺寸的大小:在 `components.icon['size:sm']`(或 `xsm`、`md`、`lg`)上设置 `width` 和 `height`,即可调整该尺寸的图标,语义图标名称和直接传给 `Icon` 的 SVG 组件都适用。请使用 `px` 或 `rem` 设置尺寸:语义图标会据此设置自身的字号,因此 `em` 值也会放大它的外框。主题未设置的尺寸在 16px 根字号下保持 12、16、20 或 24px(`xsm`、`sm`、`md`、`lg`),并随根字号缩放;`rem` 可保留这种缩放。四个尺寸名称是固定的。",
35
+ },
36
+ null,
37
+ ],
38
+ },
28
39
  {
29
40
  section: 'Dark mode',
30
41
  title: '深色模式',
@@ -111,7 +111,7 @@ export default function App() {
111
111
  },
112
112
  {
113
113
  type: 'prose',
114
- text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [facebook/astryx#4029](https://github.com/facebook/astryx/issues/4029). For now, run the two providers side by side as shown above.",
114
+ text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [meta/astryx#4029](https://github.com/meta/astryx/issues/4029). For now, run the two providers side by side as shown above.",
115
115
  },
116
116
  ],
117
117
  },
@@ -36,6 +36,10 @@ export const docs = {
36
36
  [
37
37
  "--ease-standard",
38
38
  "cubic-bezier(0.24, 1, 0.4, 1)"
39
+ ],
40
+ [
41
+ "--ease-exit",
42
+ "cubic-bezier(0.3, 0, 0.6, 0.6)"
39
43
  ]
40
44
  ]
41
45
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  // AUTO-GENERATED — do not edit manually.
4
4
  // Run: node scripts/generate-token-docs.mjs
5
- // Total: 282 tokens across 15 categories.
5
+ // Total: 283 tokens across 15 categories.
6
6
 
7
7
  /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
8
8
  export const docs = {
@@ -91,9 +91,11 @@ export const myTheme = defineTheme({
91
91
 
92
92
  /**
93
93
  * Start from another theme instead of the defaults. Tokens are copied then
94
- * overridden, `components` deep-merge, `icons` shallow-merge — but the scale
95
- * configs below REPLACE the base's rather than merging, because they are
96
- * inputs to a generator, not values.
94
+ * overridden, `components` deep-merge, `icons` shallow-merge — but the
95
+ * typography, radius and color scale configs below REPLACE the base's rather
96
+ * than merging, because they are inputs to a generator, not values. `motion`
97
+ * inherits field by field: `fast`, `medium` and `ratio` regenerate the fast
98
+ * and medium durations, and a `slow` or `easing` left unset keeps the base's.
97
99
  *
98
100
  * Reference: `astryx theme list` (themes you can install and extend).
99
101
  */
@@ -215,7 +217,7 @@ export const myTheme = defineTheme({
215
217
  // --radius-* none · inner · element · container · page · chat · full
216
218
  // --shadow-* low/med/high + inset-{hover,selected,success,warning,error}
217
219
  // --duration-* {fast,medium,slow} × {-min, base, -max}
218
- // --ease-standard
220
+ // --ease-* standard (arriving, state) · exit (leaving)
219
221
  // --font-family-* body · heading · code
220
222
  // --font-size-* 4xs … 5xl
221
223
  // --font-weight-* normal · medium · semibold · bold
@@ -312,10 +314,21 @@ export const myTheme = defineTheme({
312
314
 
313
315
  /**
314
316
  * Swap the artwork behind semantic icon names — every component that asks
315
- * for `check`, `close`, `chevron-down` gets yours.
317
+ * for `check`, `close`, `chevron-down` gets yours. An entry may also be a
318
+ * pure function of `{size, variant}` that picks artwork for the size Icon
319
+ * renders at.
316
320
  * Reference: `astryx docs icons` lists the names.
317
321
  */
318
- // icons: {check: <MyCheck />, close: <MyClose />},
322
+ // icons: {check: <MyCheck />, info: ({size}) => <MyInfo bold={size === 'sm'} />},
323
+
324
+ /**
325
+ * The icon variant names this theme supports, listed once for the whole
326
+ * theme. An icon entry function receives `variant` typed as these names.
327
+ * A theme that sets the list replaces the one it would inherit; omit it to
328
+ * inherit the base's list.
329
+ * Reference: `astryx docs icons`.
330
+ */
331
+ // iconVariants: ['outline', 'filled'],
319
332
 
320
333
  /**
321
334
  * Replace the small components that DRAW control state — the checkbox box,
@@ -31,7 +31,7 @@ export const doc = {
31
31
  type: 'string',
32
32
  description:
33
33
  "Where reports about Core go: `{@command gap-report}` routes a Core report here when no handler is loaded, gapReport handlers receive it as `report.target.issuesUrl`, and `{@command swizzle}` prints it as the feedback link for a Core component. A report or swizzle for an integration's component uses that integration's own issuesUrl, never this one. An absolute URL; a value that is not a URL makes the config invalid.",
34
- default: "'https://github.com/facebook/astryx/issues/new'",
34
+ default: "'https://github.com/meta/astryx/issues/new'",
35
35
  },
36
36
  {
37
37
  name: 'hooks',
@@ -0,0 +1,140 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx theme build` outside any project, as a separate process.
5
+ *
6
+ * A theme in a folder with no Core installed (an empty folder, a fresh clone)
7
+ * imports `defineTheme` from Core all the same: the build hands its imports
8
+ * the Core the CLI answers with, as a new project with that Core would build
9
+ * it (spec AST-081 FR3). The CLI runs as its own process, without the
10
+ * `NODE_PATH` a pnpm script sets (it reaches the repository's packages): in
11
+ * the test runner, or with that path, the theme's import would find the
12
+ * repository's Core, which a real run outside a project cannot.
13
+ */
14
+
15
+ import {afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest';
16
+ import * as fs from 'node:fs';
17
+ import * as os from 'node:os';
18
+ import * as path from 'node:path';
19
+ import {spawnSync} from 'node:child_process';
20
+ import {fileURLToPath} from 'node:url';
21
+ import {ensureCoreBuilt} from './ensure-core-built.mjs';
22
+
23
+ const CLI_BIN = fileURLToPath(new URL('../bin/astryx.mjs', import.meta.url));
24
+ const CORE_DIR = fileURLToPath(new URL('../../../../core', import.meta.url));
25
+
26
+ /** @param {string[]} args @param {string} cwd */
27
+ function runCliProcess(args, cwd) {
28
+ const {NODE_PATH: _repositoryPackages, ...env} = process.env;
29
+ const result = spawnSync(process.execPath, [CLI_BIN, ...args], {
30
+ cwd,
31
+ encoding: 'utf-8',
32
+ timeout: 60_000,
33
+ env,
34
+ });
35
+ if (result.error) throw result.error;
36
+ return result;
37
+ }
38
+
39
+ beforeAll(() => {
40
+ ensureCoreBuilt();
41
+ }, 200_000);
42
+
43
+ let tmpDir;
44
+ beforeEach(() => {
45
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-outside-'));
46
+ });
47
+ afterEach(() => {
48
+ fs.rmSync(tmpDir, {recursive: true, force: true});
49
+ });
50
+
51
+ /**
52
+ * A project beside the empty folder: its own package.json and Core (this
53
+ * repository's, linked), so the same theme builds there through the
54
+ * project's own resolution.
55
+ * @param {string} dir
56
+ */
57
+ function makeProject(dir) {
58
+ fs.mkdirSync(path.join(dir, 'node_modules', '@astryxdesign'), {
59
+ recursive: true,
60
+ });
61
+ fs.writeFileSync(
62
+ path.join(dir, 'package.json'),
63
+ '{"name": "theme-project", "private": true, "dependencies": {"@astryxdesign/core": "*"}}\n',
64
+ );
65
+ fs.symlinkSync(
66
+ CORE_DIR,
67
+ path.join(dir, 'node_modules', '@astryxdesign', 'core'),
68
+ 'junction',
69
+ );
70
+ }
71
+
72
+ describe('theme build outside any project builds a plain-object theme as a project does', () => {
73
+ const themes = {
74
+ typography: `export default {
75
+ name: 'plain-type',
76
+ tokens: {'--color-background': '#123456'},
77
+ typography: {body: {family: 'Helvetica', fallbacks: 'Arial, sans-serif'}},
78
+ };\n`,
79
+ 'local tokens and media surfaces': `export default {
80
+ name: 'plain-local',
81
+ tokens: {'--color-background': '#123456'},
82
+ localTokens: {'--ac-selection-ink': ['#0077b6', '#48cae4']},
83
+ components: {badge: {'variant:info': {backgroundColor: 'var(--ac-selection-ink)'}}},
84
+ onDark: {components: {badge: {'variant:info': {color: 'var(--ac-selection-ink)'}}}},
85
+ };\n`,
86
+ };
87
+ for (const [what, source] of Object.entries(themes)) {
88
+ for (const ext of ['mjs', 'ts']) {
89
+ it(`with ${what}, in a .${ext} file`, () => {
90
+ const name = /name: '([^']+)'/.exec(source)[1];
91
+ const project = path.join(tmpDir, 'project');
92
+ makeProject(project);
93
+ const outside = path.join(tmpDir, 'outside');
94
+ fs.mkdirSync(outside);
95
+ for (const dir of [project, outside]) {
96
+ fs.writeFileSync(path.join(dir, `theme.${ext}`), source);
97
+ const result = runCliProcess(['theme', 'build', `theme.${ext}`], dir);
98
+ expect(result.status, result.stderr + result.stdout).toBe(0);
99
+ }
100
+ expect(fs.readFileSync(path.join(outside, `${name}.css`), 'utf8')).toBe(
101
+ fs.readFileSync(path.join(project, `${name}.css`), 'utf8'),
102
+ );
103
+ });
104
+ }
105
+ }
106
+ });
107
+
108
+ describe('theme build outside any project', () => {
109
+ for (const ext of ['mjs', 'ts']) {
110
+ it(`builds a .${ext} theme that imports defineTheme from Core, with the Core the CLI answers with`, () => {
111
+ fs.writeFileSync(
112
+ path.join(tmpDir, `outside.${ext}`),
113
+ "import {defineTheme} from '@astryxdesign/core/theme';\n" +
114
+ "export default defineTheme({name: 'outside', tokens: {'--color-background': '#123456'}});\n",
115
+ );
116
+ const result = runCliProcess(
117
+ ['theme', 'build', `outside.${ext}`],
118
+ tmpDir,
119
+ );
120
+ expect(result.status, result.stderr + result.stdout).toBe(0);
121
+ expect(
122
+ fs.readFileSync(path.join(tmpDir, 'outside.css'), 'utf8'),
123
+ ).toContain('#123456');
124
+ });
125
+ }
126
+
127
+ for (const ext of ['mjs', 'ts']) {
128
+ it(`still fails a .${ext} module that defines no theme`, () => {
129
+ fs.writeFileSync(
130
+ path.join(tmpDir, `none.${ext}`),
131
+ 'export const notATheme = 42;\n',
132
+ );
133
+ const result = runCliProcess(['theme', 'build', `none.${ext}`], tmpDir);
134
+ expect(result.status).toBe(1);
135
+ expect(result.stderr + result.stdout).toMatch(
136
+ /Could not find a defineTheme\(\) result/,
137
+ );
138
+ });
139
+ }
140
+ });
@@ -155,7 +155,7 @@ describe('swizzle — core feedback routing via config', () => {
155
155
  expect(result.code).toBe(0);
156
156
  const env = JSON.parse(result.stdout);
157
157
  expect(env.data.feedback.issuesUrl).toBe(
158
- 'https://github.com/facebook/astryx/issues/new',
158
+ 'https://github.com/meta/astryx/issues/new',
159
159
  );
160
160
  });
161
161
  });
@@ -44,7 +44,7 @@ export function providerLedgerOf(project: Project): import("../integrations/prov
44
44
  /** Conventional config basenames, in load-precedence order. */
45
45
  export const CONFIG_BASENAMES: string[];
46
46
  /** Default issue tracker used when neither config nor integration routes one. */
47
- export const DEFAULT_ISSUES_URL: "https://github.com/facebook/astryx/issues/new";
47
+ export const DEFAULT_ISSUES_URL: "https://github.com/meta/astryx/issues/new";
48
48
  /**
49
49
  * The single API for reading resolved project configuration. Construct via the
50
50
  * async {@link Project.load} factory.
@@ -330,7 +330,7 @@ export const CONFIG_BASENAMES = [
330
330
 
331
331
  /** Default issue tracker used when neither config nor integration routes one. */
332
332
  export const DEFAULT_ISSUES_URL =
333
- 'https://github.com/facebook/astryx/issues/new';
333
+ 'https://github.com/meta/astryx/issues/new';
334
334
 
335
335
  /**
336
336
  * Whether this project accepts `debug` handlers contributed by the
@@ -305,7 +305,7 @@ describe('credential scrubbing', () => {
305
305
  });
306
306
 
307
307
  it.each([
308
- ['a URL', 'GET https://api.github.com/repos/facebook/astryx/pulls/4812'],
308
+ ['a URL', 'GET https://api.github.com/repos/meta/astryx/pulls/4812'],
309
309
  ['a websocket URL', 'ws://localhost:5173/hmr/client'],
310
310
  ['a proxy URL', 'http://127.0.0.1:8931/a/b/c'],
311
311
  ['a time', 'elapsed 12:30 done'],
@@ -65,12 +65,11 @@ const RUNNERS = {
65
65
  sites: ['importThemeArtifact'],
66
66
  },
67
67
  'api/theme/build/build.mjs': {
68
- runs: "theme source modules, through jiti; eval for legacy theme object literals; the project's installed Core",
68
+ runs: "theme source modules, through jiti; the project's installed Core",
69
69
  sites: [
70
70
  '.evalModule() ×2',
71
71
  '.import()',
72
72
  'createJiti ×5',
73
- 'eval ×2',
74
73
  'import(<computed>) ×3',
75
74
  ],
76
75
  },
@@ -218,10 +217,7 @@ const RUNNERS = {
218
217
  },
219
218
  'clients/cli/commands/hook.mjs': {
220
219
  runs: SELF_DOCS,
221
- sites: [
222
- 'import ../../../api/hook/hook.doc.mjs',
223
- 'import ./hook.doc.mjs',
224
- ],
220
+ sites: ['import ../../../api/hook/hook.doc.mjs', 'import ./hook.doc.mjs'],
225
221
  },
226
222
  'clients/cli/commands/init.mjs': {
227
223
  runs: SELF_DOCS,
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.5-canary.dcdb356",
3
+ "version": "0.7.5-canary.e4b225e",
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",
7
7
  "license": "MIT",
8
- "homepage": "https://github.com/facebook/astryx#readme",
8
+ "homepage": "https://github.com/meta/astryx#readme",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/facebook/astryx.git",
11
+ "url": "git+https://github.com/meta/astryx.git",
12
12
  "directory": "packages/cli"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/facebook/astryx/issues"
15
+ "url": "https://github.com/meta/astryx/issues"
16
16
  },
17
17
  "keywords": [
18
18
  "astryx",
@@ -111,10 +111,10 @@
111
111
  "zod": "^4.4.3"
112
112
  },
113
113
  "peerDependencies": {
114
- "@astryxdesign/charts": "0.7.5-canary.dcdb356",
115
- "@astryxdesign/core": "0.7.5-canary.dcdb356",
116
- "@astryxdesign/lab": "0.7.5-canary.dcdb356",
117
- "@astryxdesign/theme-neutral": "0.7.5-canary.dcdb356"
114
+ "@astryxdesign/charts": "0.7.5-canary.e4b225e",
115
+ "@astryxdesign/core": "0.7.5-canary.e4b225e",
116
+ "@astryxdesign/lab": "0.7.5-canary.e4b225e",
117
+ "@astryxdesign/theme-neutral": "0.7.5-canary.e4b225e"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
120
  "@astryxdesign/charts": {
@@ -131,10 +131,10 @@
131
131
  }
132
132
  },
133
133
  "devDependencies": {
134
- "@astryxdesign/charts": "0.7.5-canary.dcdb356",
135
- "@astryxdesign/core": "0.7.5-canary.dcdb356",
136
- "@astryxdesign/lab": "0.7.5-canary.dcdb356",
137
- "@astryxdesign/theme-neutral": "0.7.5-canary.dcdb356",
134
+ "@astryxdesign/charts": "0.7.5-canary.e4b225e",
135
+ "@astryxdesign/core": "0.7.5-canary.e4b225e",
136
+ "@astryxdesign/lab": "0.7.5-canary.e4b225e",
137
+ "@astryxdesign/theme-neutral": "0.7.5-canary.e4b225e",
138
138
  "@heroicons/react": "^2.2.0",
139
139
  "@stylexjs/stylex": "^0.19.0",
140
140
  "@types/babel__core": "^7.20.5",