@astryxdesign/cli 0.7.8-canary.f9d496e → 0.7.8-canary.ffd29c5

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.
@@ -134,7 +134,7 @@ generateThemeRules generateThemeRules theme/MediaTheme.doc.mjs theme/generateThe
134
134
  gestureCounter gestureCounter Layer/Layer.doc.mjs Layer/gestureCounter.ts
135
135
  getInitialFocusDate getInitialFocusDate Calendar/Calendar.doc.mjs Calendar/getInitialFocusDate.ts
136
136
  getLocaleDirection getLocaleDirection i18n/InternationalizationProvider.doc.mjs i18n/getLocaleDirection.ts
137
- getStandaloneShortWeekdayNames getStandaloneShortWeekdayNames Calendar/Calendar.doc.mjs Calendar/getStandaloneShortWeekdayNames.ts
137
+ getWeekdayHeaderNames getWeekdayHeaderNames Calendar/Calendar.doc.mjs Calendar/getWeekdayHeaderNames.ts
138
138
  glidingDivider glidingDivider Table/Table.doc.mjs Table/glidingDivider.ts
139
139
  globalIconRegistry globalIconRegistry Icon/Icon.doc.mjs Icon/globalIconRegistry.tsx
140
140
  grammar grammar CodeBlock/CodeBlock.doc.mjs CodeBlock/grammar.ts
@@ -270,7 +270,7 @@ useInternalConfig useInternalConfig PowerSearch/PowerSearch.doc.mjs PowerSearch/
270
270
  useIsHydrating useIsHydrating hooks/useAnimatedLayout.doc.mjs hooks/useIsHydrating.ts
271
271
  useIsomorphicLayoutEffect useIsomorphicLayoutEffect hooks/useAnimatedLayout.doc.mjs hooks/useIsomorphicLayoutEffect.ts
272
272
  useLayerDismissal useLayerDismissal Layer/Layer.doc.mjs Layer/useLayerDismissal.ts
273
- useLightbox useLightbox Lightbox/Lightbox.doc.mjs Lightbox/useLightbox.tsx
273
+ useLightbox useLightbox Lightbox/useLightbox.doc.mjs Lightbox/useLightbox.tsx
274
274
  useLinkComponent useLinkComponent Link/Link.doc.mjs Link/useLinkComponent.ts
275
275
  useLinkify useLinkify Link/Link.doc.mjs Link/useLinkify.tsx
276
276
  useListFormatter useListFormatter i18n/InternationalizationProvider.doc.mjs i18n/useListFormatter.ts
@@ -285,7 +285,6 @@ usePager usePager hooks/useAnimatedLayout.doc.mjs hooks/usePager.ts
285
285
  usePointerDragScroll usePointerDragScroll DateInput/DateInput.doc.mjs DateInput/usePointerDragScroll.ts
286
286
  usePowerSearchConfig usePowerSearchConfig PowerSearch/PowerSearch.doc.mjs PowerSearch/usePowerSearchConfig.ts
287
287
  usePowerSearchSource usePowerSearchSource PowerSearch/PowerSearch.doc.mjs PowerSearch/usePowerSearchSource.ts
288
- usePressPin usePressPin Layer/Layer.doc.mjs Layer/usePressPin.ts
289
288
  useRenamedProp useRenamedProp hooks/useAnimatedLayout.doc.mjs hooks/useRenamedProp.ts
290
289
  useResolvedRequired useResolvedRequired hooks/useAnimatedLayout.doc.mjs hooks/useResolvedRequired.ts
291
290
  useScrollSettle useScrollSettle DateInput/DateInput.doc.mjs DateInput/useScrollSettle.ts
@@ -35,7 +35,7 @@ export const docs = {
35
35
  content: [
36
36
  {
37
37
  type: 'prose',
38
- text: 'Nine duration tokens in fast, medium, and slow bands.',
38
+ text: 'Nine duration tokens in fast, medium, and slow bands, and `--duration-exit`, the standard dismissal duration, which follows `--duration-fast`.',
39
39
  },
40
40
  {
41
41
  type: 'token-ref',
@@ -68,6 +68,10 @@ export const docs = {
68
68
  [
69
69
  "--duration-slow-max",
70
70
  "1300ms"
71
+ ],
72
+ [
73
+ "--duration-exit",
74
+ "var(--duration-fast)"
71
75
  ]
72
76
  ]
73
77
  }
@@ -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: 285 tokens across 15 categories.
5
+ // Total: 286 tokens across 15 categories.
6
6
 
7
7
  /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
8
8
  export const docs = {
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useHotkeys',
7
+ name: 'useHotkeys — Search and Help Shortcuts',
8
+ displayName: 'useHotkeys — Search and Help Shortcuts',
9
+ description:
10
+ 'Page shortcuts registered with useHotkeys: "/" focuses the search field and "?" opens the shortcut help, while typing either character in the field just types it. A switch turns the single-key shortcuts off through isDisabled.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: [
14
+ 'Card',
15
+ 'TextInput',
16
+ 'Button',
17
+ 'Switch',
18
+ 'Dialog',
19
+ 'Kbd',
20
+ 'Text',
21
+ 'Layout',
22
+ ],
23
+ };
@@ -0,0 +1,90 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useRef, useState} from 'react';
6
+ import {Button} from '@astryxdesign/core/Button';
7
+ import {Card} from '@astryxdesign/core/Card';
8
+ import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';
9
+ import {useHotkeys} from '@astryxdesign/core/hooks';
10
+ import {Kbd} from '@astryxdesign/core/Kbd';
11
+ import {
12
+ HStack,
13
+ Layout,
14
+ LayoutContent,
15
+ StackItem,
16
+ VStack,
17
+ } from '@astryxdesign/core/Layout';
18
+ import {Switch} from '@astryxdesign/core/Switch';
19
+ import {Text} from '@astryxdesign/core/Text';
20
+ import {TextInput} from '@astryxdesign/core/TextInput';
21
+
22
+ export default function UseHotkeysHookUsage() {
23
+ const searchRef = useRef<HTMLInputElement>(null);
24
+ const [query, setQuery] = useState('');
25
+ const [isHelpOpen, setIsHelpOpen] = useState(false);
26
+ // Single-character shortcuts need an off switch (WCAG 2.1.4).
27
+ const [hasShortcuts, setHasShortcuts] = useState(true);
28
+
29
+ useHotkeys([
30
+ {
31
+ keys: '/',
32
+ onPress: () => searchRef.current?.focus(),
33
+ isDisabled: !hasShortcuts,
34
+ },
35
+ {
36
+ keys: '?',
37
+ onPress: () => setIsHelpOpen(true),
38
+ isDisabled: !hasShortcuts,
39
+ },
40
+ ]);
41
+
42
+ return (
43
+ <Card width={480} padding={4}>
44
+ <VStack gap={3}>
45
+ <HStack gap={2} vAlign="center">
46
+ <StackItem size="fill">
47
+ <TextInput
48
+ ref={searchRef}
49
+ label="Search"
50
+ isLabelHidden
51
+ placeholder="Search projects"
52
+ value={query}
53
+ onChange={setQuery}
54
+ />
55
+ </StackItem>
56
+ <Button label="Shortcuts" onClick={() => setIsHelpOpen(true)} />
57
+ </HStack>
58
+ <Switch
59
+ label="Single-key shortcuts"
60
+ value={hasShortcuts}
61
+ onChange={setHasShortcuts}
62
+ />
63
+ </VStack>
64
+ <Dialog isOpen={isHelpOpen} onOpenChange={setIsHelpOpen}>
65
+ <Layout
66
+ header={
67
+ <DialogHeader
68
+ title="Keyboard shortcuts"
69
+ onOpenChange={setIsHelpOpen}
70
+ />
71
+ }
72
+ content={
73
+ <LayoutContent>
74
+ <VStack gap={2}>
75
+ <HStack gap={2} vAlign="center">
76
+ <Kbd keys="/" />
77
+ <Text type="body">Focus search</Text>
78
+ </HStack>
79
+ <HStack gap={2} vAlign="center">
80
+ <Kbd keys="?" />
81
+ <Text type="body">Show this help</Text>
82
+ </HStack>
83
+ </VStack>
84
+ </LayoutContent>
85
+ }
86
+ />
87
+ </Dialog>
88
+ </Card>
89
+ );
90
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
4
+ export const doc = {
5
+ type: 'block',
6
+ exampleFor: 'useInputStatusIcon',
7
+ name: 'useInputStatusIcon — Coupon Code Status',
8
+ displayName: 'useInputStatusIcon — Coupon Code Status',
9
+ description:
10
+ 'A custom bordered coupon-code input whose status affordance comes from useInputStatusIcon. A wrong code shows the error status and SAVE20 shows success. Switching the variant moves between a plain glyph with a message below (attached), no icon on the field (detached), and a focusable button whose tooltip keyboard and screen-reader users can reach, with its aria-describedby id returned by the hook (tooltip).',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Card', 'Field', 'SegmentedControl', 'Text', 'Layout'],
14
+ };
@@ -0,0 +1,119 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ import {useId, useState} from 'react';
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import {Card} from '@astryxdesign/core/Card';
8
+ import {
9
+ Field,
10
+ inputStatusBorderStyles,
11
+ inputWrapperStyles,
12
+ } from '@astryxdesign/core/Field';
13
+ import type {FieldStatusPlacement, InputStatus} from '@astryxdesign/core/Field';
14
+ import {useInputStatusIcon} from '@astryxdesign/core/hooks';
15
+ import {VStack} from '@astryxdesign/core/Layout';
16
+ import {
17
+ SegmentedControl,
18
+ SegmentedControlItem,
19
+ } from '@astryxdesign/core/SegmentedControl';
20
+ import {Text} from '@astryxdesign/core/Text';
21
+ import {colorVars, spacingVars} from '@astryxdesign/core/theme/tokens.stylex';
22
+
23
+ const VALID_CODE = 'SAVE20';
24
+
25
+ const styles = stylex.create({
26
+ field: {
27
+ paddingInline: spacingVars['--spacing-3'],
28
+ },
29
+ input: {
30
+ flexGrow: 1,
31
+ minWidth: 0,
32
+ borderWidth: 0,
33
+ backgroundColor: 'transparent',
34
+ color: colorVars['--color-text-primary'],
35
+ font: 'inherit',
36
+ outline: 'none',
37
+ },
38
+ });
39
+
40
+ function CouponField({statusVariant}: {statusVariant: FieldStatusPlacement}) {
41
+ const [code, setCode] = useState('SAVE10');
42
+ const inputId = useId();
43
+ const messageId = useId();
44
+
45
+ const status: InputStatus | undefined =
46
+ code === ''
47
+ ? undefined
48
+ : code.toUpperCase() === VALID_CODE
49
+ ? {type: 'success', message: 'Code applied: 20% off.'}
50
+ : {type: 'error', message: 'This code is not valid.'};
51
+
52
+ // The hook decides what the field shows for this status and variant, and
53
+ // returns the id of its tooltip only when that tooltip is in the DOM.
54
+ const {statusIcon, describedBy} = useInputStatusIcon({
55
+ status,
56
+ statusVariant,
57
+ });
58
+
59
+ // `attached` and `detached` carry the text in a message box under the field;
60
+ // `tooltip` carries it in the hook's tooltip instead.
61
+ const hasMessageBox =
62
+ statusVariant !== 'tooltip' && !!status && !!status.message;
63
+ const ariaDescribedBy =
64
+ [hasMessageBox ? messageId : null, describedBy].filter(Boolean).join(' ') ||
65
+ undefined;
66
+
67
+ return (
68
+ <Field
69
+ label="Coupon code"
70
+ isLabelHidden
71
+ inputID={inputId}
72
+ status={status && {...status, messageID: messageId}}
73
+ statusVariant={statusVariant}>
74
+ <div
75
+ {...stylex.props(
76
+ inputWrapperStyles.base,
77
+ styles.field,
78
+ status && inputStatusBorderStyles[status.type],
79
+ )}>
80
+ <input
81
+ id={inputId}
82
+ type="text"
83
+ aria-invalid={status?.type === 'error' || undefined}
84
+ aria-describedby={ariaDescribedBy}
85
+ placeholder="Enter a coupon code"
86
+ value={code}
87
+ onChange={e => setCode(e.target.value)}
88
+ {...stylex.props(styles.input)}
89
+ />
90
+ {statusIcon}
91
+ </div>
92
+ </Field>
93
+ );
94
+ }
95
+
96
+ export default function UseInputStatusIconHookUsage() {
97
+ const [statusVariant, setStatusVariant] =
98
+ useState<FieldStatusPlacement>('attached');
99
+
100
+ return (
101
+ <Card width={360} padding={4}>
102
+ <VStack gap={3}>
103
+ <SegmentedControl
104
+ label="Status variant"
105
+ value={statusVariant}
106
+ onChange={next => setStatusVariant(next as FieldStatusPlacement)}
107
+ size="sm">
108
+ <SegmentedControlItem value="attached" label="Attached" />
109
+ <SegmentedControlItem value="detached" label="Detached" />
110
+ <SegmentedControlItem value="tooltip" label="Tooltip" />
111
+ </SegmentedControl>
112
+ <CouponField statusVariant={statusVariant} />
113
+ <Text type="supporting">
114
+ Type {VALID_CODE} to see the success status.
115
+ </Text>
116
+ </VStack>
117
+ </Card>
118
+ );
119
+ }
@@ -230,7 +230,8 @@ export const myTheme = defineTheme({
230
230
  // --border-width hairline thickness shared by bordered surfaces
231
231
  // --radius-* none · inner · element · container · page · chat · full
232
232
  // --shadow-* low/med/high + inset-{hover,selected,success,warning,error}
233
- // --duration-* {fast,medium,slow} × {-min, base, -max}
233
+ // --duration-* {fast,medium,slow} × {-min, base, -max} · exit
234
+ // (dismissal; defaults to fast)
234
235
  // --ease-* standard (state) · entrance (arriving) · move (on
235
236
  // screen) · exit (leaving)
236
237
  // --font-family-* body · heading · code
@@ -3,13 +3,13 @@
3
3
  /**
4
4
  * @file Astryx CLI — Commander program setup
5
5
  *
6
- * Registers all commands via lazy loading. If one command fails to load
7
- * (bad import, syntax error), the other commands still work.
6
+ * Commands load lazily: a bin run loads only the one its arguments name.
7
+ * One that fails to load (bad import, syntax error) leaves the rest working.
8
8
  *
9
9
  * The program is built by {@link createProgram} — a factory so tests can drive
10
10
  * a FRESH program in-process (via parseAsync) instead of spawning `node
11
- * bin/astryx.mjs` per assertion. `bin/astryx.mjs` and legacy importers use the
12
- * eager {@link program} singleton, which is just `await createProgram()`.
11
+ * bin/astryx.mjs` per assertion. Code that reads every command at once uses
12
+ * the full program in program.mjs.
13
13
  */
14
14
 
15
15
  import {Command, Option} from 'commander';
@@ -329,6 +329,52 @@ const commands = [
329
329
  {name: 'postinstall', path: './commands/postinstall.mjs', register: 'registerPostinstall'},
330
330
  ];
331
331
 
332
+ /** The name each registry entry registers, in registration order. */
333
+ export const COMMAND_NAMES = Object.freeze(commands.map(cmd => cmd.name));
334
+
335
+ /** Commands whose run reads every other command: the manifest lists them. */
336
+ const READS_EVERY_COMMAND = new Set(['manifest']);
337
+
338
+ /**
339
+ * The commands a run of the bin loads. Commander dispatches a run to its
340
+ * first operand after the root's own options, so this reads the arguments the
341
+ * same way. It returns that one command, no command for a run that only
342
+ * prints the version, or null for every command. These runs load every
343
+ * command: help, the manifest, `help <command>`, an unknown word, and a flag
344
+ * the root does not declare. They print or read the whole list.
345
+ *
346
+ * @param {import('commander').Command} program the root, with its options
347
+ * @param {string[]} argv the arguments after `astryx`
348
+ * @returns {Set<string> | null}
349
+ */
350
+ export function commandsForArgs(program, argv) {
351
+ let printsVersion = false;
352
+ for (let i = 0; i < argv.length; i += 1) {
353
+ const arg = argv[i];
354
+ // Commander reads a lone `-` as an operand, as it reads any word.
355
+ if (arg.length < 2 || arg[0] !== '-') {
356
+ return commands.some(cmd => cmd.name === arg) && !READS_EVERY_COMMAND.has(arg)
357
+ ? new Set([arg])
358
+ : null;
359
+ }
360
+ const equals = arg.startsWith('--') ? arg.indexOf('=') : -1;
361
+ const flag = equals === -1 ? arg : arg.slice(0, equals);
362
+ const option = program.options.find(o => o.long === flag || o.short === flag);
363
+ // Help flags, `--`, combined short flags and unknown flags read the whole
364
+ // list, or make Commander stop dispatching by name.
365
+ if (option == null) return null;
366
+ const takesValue = option.required || option.optional;
367
+ if (equals !== -1 && !takesValue) return null;
368
+ if (equals === -1 && option.required) i += 1;
369
+ const next = argv[i + 1];
370
+ if (equals === -1 && option.optional && next != null && !(next.length > 1 && next[0] === '-')) {
371
+ i += 1;
372
+ }
373
+ if (option.long === '--version') printsVersion = true;
374
+ }
375
+ return printsVersion ? new Set() : null;
376
+ }
377
+
332
378
  const SETUP_NUDGE_EXEMPT = new Set(['init', 'agent-docs']);
333
379
 
334
380
  /**
@@ -363,9 +409,12 @@ const INTEGRATION_MANIFEST_FILES = [
363
409
  * lazy-imported. Each call returns an independent Command so tests can
364
410
  * parseAsync repeatedly without commander state leaking between runs.
365
411
  *
412
+ * @param {{argv?: string[]}} [options] `argv`, the arguments after `astryx`:
413
+ * load only the commands a run of them needs (commandsForArgs). Without
414
+ * it, every command loads.
366
415
  * @returns {Promise<import('commander').Command>}
367
416
  */
368
- export async function createProgram() {
417
+ export async function createProgram({argv} = {}) {
369
418
  const program = new Command();
370
419
 
371
420
  // Deterministic, single-line help. Commander wraps each option/command
@@ -708,7 +757,9 @@ export async function createProgram() {
708
757
  }
709
758
  });
710
759
 
760
+ const loads = argv == null ? null : commandsForArgs(program, argv);
711
761
  for (const cmd of commands) {
762
+ if (loads != null && !loads.has(cmd.name)) continue;
712
763
  try {
713
764
  const mod = await import(cmd.path);
714
765
  mod[cmd.register](program, {jsonSupported: JSON_SUPPORTED, version: pkg.version});
@@ -740,9 +791,3 @@ export async function createProgram() {
740
791
 
741
792
  return program;
742
793
  }
743
-
744
- /**
745
- * Eager singleton program for `bin/astryx.mjs` and legacy importers. Tests
746
- * should call {@link createProgram} to get an isolated instance.
747
- */
748
- export const program = await createProgram();
@@ -0,0 +1,15 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file The full Astryx CLI program, with every command loaded.
5
+ *
6
+ * @input createProgram (index.mjs).
7
+ * @output `program`, built once when this module loads.
8
+ * @position For code that reads every command at once, such as tests of the
9
+ * manifest and the docs drift check. A run of the bin builds its own
10
+ * program from its arguments (run.mjs), so it does not load this module.
11
+ */
12
+
13
+ import {createProgram} from './index.mjs';
14
+
15
+ export const program = await createProgram();
@@ -33,11 +33,14 @@ export async function runCli({cliRoot, argv, declinedProjectCli}) {
33
33
  if (answered) return answered;
34
34
 
35
35
  const {
36
- program,
36
+ createProgram,
37
37
  loadProjectDebugHandler,
38
38
  loadProjectForHelp,
39
39
  handleVersionJsonPreflight,
40
40
  } = await import('./index.mjs');
41
+ // Only the commands these arguments need load, before anything below runs,
42
+ // as the full program did.
43
+ const program = await createProgram({argv: process.argv.slice(2)});
41
44
  const {isJsonMode, toErrorEnvelope} =
42
45
  await import('../../foundation/response/json.mjs');
43
46
  const {handleCommanderError} = await import('./lib/json-shim.mjs');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.8-canary.f9d496e",
3
+ "version": "0.7.8-canary.ffd29c5",
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",
@@ -124,10 +124,10 @@
124
124
  "zod": "^4.4.3"
125
125
  },
126
126
  "peerDependencies": {
127
- "@astryxdesign/charts": "0.7.8-canary.f9d496e",
128
- "@astryxdesign/core": "0.7.8-canary.f9d496e",
129
- "@astryxdesign/lab": "0.7.8-canary.f9d496e",
130
- "@astryxdesign/theme-neutral": "0.7.8-canary.f9d496e"
127
+ "@astryxdesign/charts": "0.7.8-canary.ffd29c5",
128
+ "@astryxdesign/core": "0.7.8-canary.ffd29c5",
129
+ "@astryxdesign/lab": "0.7.8-canary.ffd29c5",
130
+ "@astryxdesign/theme-neutral": "0.7.8-canary.ffd29c5"
131
131
  },
132
132
  "peerDependenciesMeta": {
133
133
  "@astryxdesign/charts": {
@@ -144,10 +144,10 @@
144
144
  }
145
145
  },
146
146
  "devDependencies": {
147
- "@astryxdesign/charts": "0.7.8-canary.f9d496e",
148
- "@astryxdesign/core": "0.7.8-canary.f9d496e",
149
- "@astryxdesign/lab": "0.7.8-canary.f9d496e",
150
- "@astryxdesign/theme-neutral": "0.7.8-canary.f9d496e",
147
+ "@astryxdesign/charts": "0.7.8-canary.ffd29c5",
148
+ "@astryxdesign/core": "0.7.8-canary.ffd29c5",
149
+ "@astryxdesign/lab": "0.7.8-canary.ffd29c5",
150
+ "@astryxdesign/theme-neutral": "0.7.8-canary.ffd29c5",
151
151
  "@heroicons/react": "^2.2.0",
152
152
  "@stylexjs/stylex": "^0.19.0",
153
153
  "@types/babel__core": "^7.20.5",