@astryxdesign/cli 0.7.8-canary.ffd29c5 → 0.7.9-canary.048476f

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 (64) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +1 -1
  3. package/api/component/__fixtures__/resolutions/modules.txt +1 -1
  4. package/api/docs/_adapter.d.mts +8 -2
  5. package/api/docs/_adapter.mjs +10 -4
  6. package/api/docs/detail/section/section.d.mts +5 -2
  7. package/api/docs/detail/section/section.mjs +6 -2
  8. package/api/docs/docs.mjs +7 -1
  9. package/api/doctor/_adapter.d.mts +6 -2
  10. package/api/doctor/_adapter.mjs +5 -3
  11. package/api/doctor/built-checks.d.mts +9 -4
  12. package/api/doctor/built-checks.mjs +15 -10
  13. package/api/search/_adapter.d.mts +3 -1
  14. package/api/search/_adapter.mjs +12 -2
  15. package/api/search/_candidate-score.d.mts +4 -1
  16. package/api/search/_candidate-score.mjs +27 -11
  17. package/api/search/_gather-components.mjs +5 -0
  18. package/api/search/_gather-templates.mjs +31 -6
  19. package/api/search/_lexical.d.mts +14 -0
  20. package/api/search/_lexical.mjs +4 -0
  21. package/api/search/_result.d.mts +1 -0
  22. package/api/search/_result.mjs +1 -0
  23. package/api/search/search.d.mts +3 -1
  24. package/api/search/search.doc.mjs +1 -1
  25. package/api/search/search.mjs +9 -8
  26. package/api/search/search.type.d.mts +4 -0
  27. package/api/search/search.type.mjs +1 -0
  28. package/api/theme/build/build.d.mts +26 -1
  29. package/api/theme/build/build.mjs +50 -19
  30. package/api/theme/build/core-interception.d.mts +2 -1
  31. package/api/theme/build/core-interception.mjs +23 -5
  32. package/assets/codemods/registry.mjs +1 -0
  33. package/assets/codemods/transforms/next/index.mjs +1 -11
  34. package/assets/codemods/transforms/v0.7.8/index.mjs +20 -0
  35. package/assets/docs/browser-support.doc.mjs +27 -1
  36. package/assets/docs/tree/tokens-color.doc.mjs +1 -1
  37. package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.doc.mjs +14 -0
  38. package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.tsx +67 -0
  39. package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.doc.mjs +14 -0
  40. package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.tsx +35 -0
  41. package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.doc.mjs +14 -0
  42. package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -0
  43. package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.doc.mjs +15 -0
  44. package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.tsx +98 -0
  45. package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.doc.mjs +14 -0
  46. package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.tsx +46 -0
  47. package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.doc.mjs +14 -0
  48. package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.tsx +41 -0
  49. package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.doc.mjs +13 -0
  50. package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.tsx +24 -0
  51. package/assets/theme.template.ts +1 -1
  52. package/authoring/doctypes/_schema.d.mts +16 -0
  53. package/authoring/doctypes/_schema.mjs +15 -0
  54. package/authoring/doctypes/component/component.doc.mjs +6 -0
  55. package/authoring/doctypes/component/type.ts +16 -0
  56. package/authoring/index.d.ts +1 -0
  57. package/clients/cli/commands/build.mjs +9 -3
  58. package/clients/cli/commands/search.mjs +8 -2
  59. package/clients/cli/formatters/index.mjs +11 -0
  60. package/foundation/discovery/template-adapter.d.mts +10 -0
  61. package/foundation/discovery/template-adapter.mjs +94 -4
  62. package/foundation/response/response-types.doc.mjs +1 -1
  63. package/package.json +9 -9
  64. /package/assets/codemods/transforms/{next → v0.7.8}/promote-tokenizer-presentation.mjs +0 -0
@@ -73,6 +73,8 @@ async function gatherCoreComponents(coreDir) {
73
73
  let description = '';
74
74
  /** @type {string[]} */
75
75
  let guidance = [];
76
+ /** @type {import('@astryxdesign/cli/authoring').ComponentDeprecation | undefined} */
77
+ let deprecated;
76
78
  if (readme && readme.endsWith('.doc.mjs')) {
77
79
  const loaded = await loadModuleDoc(readme);
78
80
  // A member documented in its family's doc (VStack in Stack's doc) is
@@ -83,6 +85,7 @@ async function gatherCoreComponents(coreDir) {
83
85
  keywords = Array.isArray(doc.keywords) ? doc.keywords : [];
84
86
  description = doc.usage?.description || doc.description || '';
85
87
  guidance = guidanceFrom(doc);
88
+ deprecated = doc.deprecated;
86
89
  }
87
90
  for (const [n, place] of familyPlaces(loaded)) places.set(n, place);
88
91
  }
@@ -92,6 +95,7 @@ async function gatherCoreComponents(coreDir) {
92
95
  keywords,
93
96
  description,
94
97
  guidance,
98
+ ...(deprecated ? {_deprecated: deprecated} : {}),
95
99
  _package: CORE_PACKAGE,
96
100
  _import: resolveImportPath(coreDir, comp),
97
101
  });
@@ -178,6 +182,7 @@ async function gatherIntegrationComponents(loadedIntegrations) {
178
182
  keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
179
183
  description: doc ? doc.usage?.description || doc.description || '' : '',
180
184
  guidance: guidanceFrom(doc),
185
+ ...(doc?.deprecated ? {_deprecated: doc.deprecated} : {}),
181
186
  ...places.get(rec.name),
182
187
  _package: rec.package ?? integration.name,
183
188
  // Exactly what `component` reports: a doc may state its own specifier
@@ -4,10 +4,15 @@
4
4
  * @file Search's template and theme candidates. Imported only by the adapter.
5
5
  */
6
6
 
7
+ import fs from 'node:fs';
7
8
  import {CORE_PACKAGE} from '../../foundation/discovery/component-discovery.mjs';
8
- import {discoverTemplates, extractComponents} from '../template/template.mjs';
9
+ import {discoverTemplates} from '../template/template.mjs';
9
10
  import {listAvailableThemes} from '../theme/_adapter.mjs';
10
- import {templateLookupIds} from '../../foundation/discovery/template-adapter.mjs';
11
+ import {
12
+ componentNameBound,
13
+ componentsInSource,
14
+ templateLookupIds,
15
+ } from '../../foundation/discovery/template-adapter.mjs';
11
16
  import {sameWord, wordsOf} from './_words.mjs';
12
17
 
13
18
  /** @typedef {import('./_lexical.mjs').Candidate} Candidate */
@@ -66,12 +71,29 @@ export async function gatherTemplates(cwd) {
66
71
  ? [...t.componentsUsed]
67
72
  : [];
68
73
  keywords.push(...templateLookupIds(t).filter(id => id !== commandName));
69
- /** @type {string[]} */
70
- let weakKeywords = [];
74
+ /** @type {() => string[]} */
75
+ let derive = () => [];
76
+ /** @type {string[] | null} */
77
+ let weakKeywordBound = null;
71
78
  if (t.type === 'page') {
72
79
  if (t.filePath) {
73
80
  try {
74
- weakKeywords = extractComponents(t.filePath);
81
+ const source = fs.readFileSync(t.filePath, 'utf-8');
82
+ // Parsing the source costs more than the rest of the page's gather.
83
+ // It waits until a term could match a name the source can yield.
84
+ /** @type {string[] | undefined} */
85
+ let derived;
86
+ derive = () => {
87
+ if (derived === undefined) {
88
+ try {
89
+ derived = componentsInSource(source);
90
+ } catch {
91
+ derived = [];
92
+ }
93
+ }
94
+ return derived;
95
+ };
96
+ weakKeywordBound = componentNameBound(source);
75
97
  } catch {
76
98
  // Best-effort: skip keyword enrichment if the source can't be read.
77
99
  }
@@ -83,7 +105,10 @@ export async function gatherTemplates(cwd) {
83
105
  domain: 'template',
84
106
  name: commandName,
85
107
  keywords,
86
- weakKeywords,
108
+ get weakKeywords() {
109
+ return derive();
110
+ },
111
+ ...(weakKeywordBound ? {weakKeywordBound} : {}),
87
112
  description: t.description || '',
88
113
  // A template's own keywords name the many ideas it serves, so they score
89
114
  // as its prose does, not as a name: one of them matching one word of a
@@ -14,6 +14,8 @@
14
14
  * author lists in `keywords`, without the code terms and table cells its
15
15
  * other keywords add.
16
16
  * @property {string[]} [weakKeywords]
17
+ * @property {string[]} [weakKeywordBound] - Every name `weakKeywords` can
18
+ * hold, for a page whose weak keywords cost a parse to read.
17
19
  * @property {string} [description]
18
20
  * @property {string[]} [prose]
19
21
  * @property {string[]} [guidance]
@@ -40,6 +42,8 @@
40
42
  * @property {'file'|'doc'} [_hold] - How an integration component holds its
41
43
  * name, for the owner rule.
42
44
  * @property {string} [_docPath] - An integration component's doc.
45
+ * @property {import('@astryxdesign/cli/authoring').ComponentDeprecation} [_deprecated] -
46
+ * A deprecated component's replacement, from its doc's `deprecated`.
43
47
  */
44
48
  /**
45
49
  * True when the query is the candidate's whole name or another name of it,
@@ -88,6 +92,11 @@ export type Candidate = {
88
92
  */
89
93
  _declared?: string[] | undefined;
90
94
  weakKeywords?: string[] | undefined;
95
+ /**
96
+ * - Every name `weakKeywords` can
97
+ * hold, for a page whose weak keywords cost a parse to read.
98
+ */
99
+ weakKeywordBound?: string[] | undefined;
91
100
  description?: string | undefined;
92
101
  prose?: string[] | undefined;
93
102
  guidance?: string[] | undefined;
@@ -144,4 +153,9 @@ export type Candidate = {
144
153
  * - An integration component's doc.
145
154
  */
146
155
  _docPath?: string | undefined;
156
+ /**
157
+ * -
158
+ * A deprecated component's replacement, from its doc's `deprecated`.
159
+ */
160
+ _deprecated?: import("@astryxdesign/cli/authoring").ComponentDeprecation | undefined;
147
161
  };
@@ -73,6 +73,8 @@ import {toResult, searchedComponentsOf} from './_result.mjs';
73
73
  * author lists in `keywords`, without the code terms and table cells its
74
74
  * other keywords add.
75
75
  * @property {string[]} [weakKeywords]
76
+ * @property {string[]} [weakKeywordBound] - Every name `weakKeywords` can
77
+ * hold, for a page whose weak keywords cost a parse to read.
76
78
  * @property {string} [description]
77
79
  * @property {string[]} [prose]
78
80
  * @property {string[]} [guidance]
@@ -99,6 +101,8 @@ import {toResult, searchedComponentsOf} from './_result.mjs';
99
101
  * @property {'file'|'doc'} [_hold] - How an integration component holds its
100
102
  * name, for the owner rule.
101
103
  * @property {string} [_docPath] - An integration component's doc.
104
+ * @property {import('@astryxdesign/cli/authoring').ComponentDeprecation} [_deprecated] -
105
+ * A deprecated component's replacement, from its doc's `deprecated`.
102
106
  */
103
107
 
104
108
  /**
@@ -24,6 +24,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
24
24
  reason: string;
25
25
  description: string;
26
26
  } | {
27
+ deprecated?: import("../../authoring/index.js").ComponentDeprecation | undefined;
27
28
  import: string | undefined;
28
29
  command: string;
29
30
  domain: "template" | "component" | "hook" | "theme" | "doc";
@@ -49,6 +49,7 @@ export function toResult(
49
49
  ...base,
50
50
  import: c._import,
51
51
  command: c._command ?? `astryx component ${c.name}`,
52
+ ...(c._deprecated ? {deprecated: c._deprecated} : {}),
52
53
  };
53
54
  break;
54
55
  case 'hook':
@@ -18,7 +18,9 @@ export function search(query: string, options?: {
18
18
  }): Promise<import("./search.type.mjs").SearchResponse>;
19
19
  /**
20
20
  * The lexical ranker alone: keyword and fuzzy scoring of every candidate.
21
- * `build` ranks from it.
21
+ * `build` ranks from it. It ranks the candidates search gathers, reused the
22
+ * same way. A later query in the same folder, for the same `type`, gathers
23
+ * again only when an input changed.
22
24
  *
23
25
  * @param {string} query
24
26
  * @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
@@ -58,7 +58,7 @@ export const doc = {
58
58
  {
59
59
  type: 'search',
60
60
  description:
61
- "The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the topic level (Guides or Foundations) for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `{@command theme add <slug>}` (outside a project, where there is no app to add it to, `{@command theme eject <slug>}`), and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI's own themes). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is `{skipped, reason}`: the domains it skipped (`component`, `hook`, `template`) and why; the results are the docs and themes, and text mode prints one line on standard error.",
61
+ "The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, `displayName` and `kind` for templates, and `displayName` for themes. A deprecated component's result also carries `deprecated`, `{replacement, description}` from its doc: the name of the component to use instead and the modernization route. A doc result is the smallest part that answers: one section (with `section`, and a command that reads only it), one docs-tree route, or a topic, whose command lists its sections. `parent` is the command that opens the level above it: the section list of its topic, the namespace a tree node sits in, the topic level (Guides or Foundations) for a flat topic, or the topic list for a top-level namespace. Every doc result also carries `package`, the npm package that authored it (for a section, the package its file came from). A theme result is one theme you can import: `name` is its slug, its command is `{@command theme add <slug>}` (outside a project, where there is no app to add it to, `{@command theme eject <slug>}`), and `package` is the npm package that ships it (`@astryxdesign/cli` for the CLI's own themes). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is `{skipped, reason}`: the domains it skipped (`component`, `hook`, `template`) and why; the results are the docs and themes, and text mode prints one line on standard error.",
62
62
  },
63
63
  ],
64
64
  throws: [
@@ -19,11 +19,7 @@ import {
19
19
  runWithDocPackageManager,
20
20
  } from '../../foundation/env/package-manager.mjs';
21
21
  import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
22
- import {
23
- gatherCandidates,
24
- gatherCandidatesReused,
25
- loadSearchData,
26
- } from './_adapter.mjs';
22
+ import {gatherCandidatesReused, loadSearchData} from './_adapter.mjs';
27
23
  import {rankLexical} from './_lexical.mjs';
28
24
  import {checkSearchArgs} from './_result.mjs';
29
25
  import {runTree} from '../../foundation/route/route.mjs';
@@ -76,7 +72,10 @@ async function searchRead(query, options) {
76
72
  await runTree(
77
73
  SEARCH_TREE,
78
74
  {query, options},
79
- {...(await gatherCandidatesReused(options)), data: loadSearchData()},
75
+ {
76
+ ...(await gatherCandidatesReused(options)),
77
+ data: loadSearchData(),
78
+ },
80
79
  )
81
80
  ),
82
81
  options.cwd ?? process.cwd(),
@@ -87,7 +86,9 @@ async function searchRead(query, options) {
87
86
 
88
87
  /**
89
88
  * The lexical ranker alone: keyword and fuzzy scoring of every candidate.
90
- * `build` ranks from it.
89
+ * `build` ranks from it. It ranks the candidates search gathers, reused the
90
+ * same way. A later query in the same folder, for the same `type`, gathers
91
+ * again only when an input changed.
91
92
  *
92
93
  * @param {string} query
93
94
  * @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
@@ -109,7 +110,7 @@ export async function searchCore(query, options = {}) {
109
110
  async function searchCoreRead(query, options) {
110
111
  return withListingCache(async () =>
111
112
  linkSearchResponse(
112
- rankLexical(query, options, await gatherCandidates(options)),
113
+ rankLexical(query, options, await gatherCandidatesReused(options)),
113
114
  options.cwd ?? process.cwd(),
114
115
  ),
115
116
  );
@@ -66,6 +66,10 @@ export type SearchResultEntry = {
66
66
  * - Template kind (`page` | `block`) — present for template results.
67
67
  */
68
68
  kind?: "page" | "block" | undefined;
69
+ /**
70
+ * - The replacement and modernization route — present for a deprecated component, from its doc's `deprecated`.
71
+ */
72
+ deprecated?: import("@astryxdesign/cli/authoring").ComponentDeprecation | undefined;
69
73
  };
70
74
  /**
71
75
  * astryx --json search <query>
@@ -33,6 +33,7 @@
33
33
  * @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
34
34
  * @property {string} [displayName] - Friendly display name — present for template and theme results.
35
35
  * @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
36
+ * @property {import('@astryxdesign/cli/authoring').ComponentDeprecation} [deprecated] - The replacement and modernization route — present for a deprecated component, from its doc's `deprecated`.
36
37
  */
37
38
 
38
39
  /**
@@ -1,6 +1,31 @@
1
1
  // @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
2
2
  // DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
3
3
 
4
+ /**
5
+ * The bindings one Core provides: the namespaces interception spreads, the
6
+ * functions the build calls, and why the import failed, if it did.
7
+ * @typedef {{
8
+ * themeModule: any,
9
+ * rootModule: (() => any) | null,
10
+ * importError: any,
11
+ * defineTheme: any,
12
+ * generateThemeRulesSplit: any,
13
+ * generateOnMediaCSS: any,
14
+ * generateAdaptationCSS: any,
15
+ * }} CoreBindings
16
+ */
17
+ /**
18
+ * A Core's root namespace, loaded on first use. The root entry loads all of
19
+ * Core and React, and only a theme that imports the root specifier needs it.
20
+ * Requiring the file an import resolves to returns the namespace `import()`
21
+ * gives. A root that cannot be loaded gives null, and interception then hands
22
+ * the theme namespace in its place. A root that only `import()` can load
23
+ * throws instead: one that awaits at its top level, or any root when Node runs
24
+ * without require(esm).
25
+ * @param {() => string | null} resolveFile
26
+ * @returns {() => any}
27
+ */
28
+ export function lazyRootModule(resolveFile: () => string | null): () => any;
4
29
  /**
5
30
  * Why `theme build` has no Core to generate with, and the fix for where it
6
31
  * ran: the Astryx repository builds Core, an app installs it, and an installed
@@ -170,7 +195,7 @@ export function themeBuildFamily(files: string[], options: {
170
195
  */
171
196
  export type CoreBindings = {
172
197
  themeModule: any;
173
- rootModule: any;
198
+ rootModule: (() => any) | null;
174
199
  importError: any;
175
200
  defineTheme: any;
176
201
  generateThemeRulesSplit: any;
@@ -132,12 +132,13 @@ import {resolveIconImports} from './icon-imports.mjs';
132
132
  */
133
133
  /** @type {any} */ let _coreThemeModule = null;
134
134
  /**
135
- * The `@astryxdesign/core` ROOT namespace, imported separately because it
135
+ * The `@astryxdesign/core` ROOT namespace, loaded separately because it
136
136
  * exports far more than the theme subpath. Interception must hand a theme file
137
137
  * that imports a component from the root the root's own exports, not the theme
138
- * namespace wearing its name.
138
+ * namespace wearing its name. It loads on first use: see lazyRootModule.
139
+ * @type {(() => any) | null}
139
140
  */
140
- /** @type {any} */ let _coreRootModule = null;
141
+ let _coreRootModule = null;
141
142
  /** @type {any} */ let _coreImportError = null;
142
143
 
143
144
  /**
@@ -145,7 +146,7 @@ import {resolveIconImports} from './icon-imports.mjs';
145
146
  * functions the build calls, and why the import failed, if it did.
146
147
  * @typedef {{
147
148
  * themeModule: any,
148
- * rootModule: any,
149
+ * rootModule: (() => any) | null,
149
150
  * importError: any,
150
151
  * defineTheme: any,
151
152
  * generateThemeRulesSplit: any,
@@ -154,6 +155,47 @@ import {resolveIconImports} from './icon-imports.mjs';
154
155
  * }} CoreBindings
155
156
  */
156
157
 
158
+ /**
159
+ * A Core's root namespace, loaded on first use. The root entry loads all of
160
+ * Core and React, and only a theme that imports the root specifier needs it.
161
+ * Requiring the file an import resolves to returns the namespace `import()`
162
+ * gives. A root that cannot be loaded gives null, and interception then hands
163
+ * the theme namespace in its place. A root that only `import()` can load
164
+ * throws instead: one that awaits at its top level, or any root when Node runs
165
+ * without require(esm).
166
+ * @param {() => string | null} resolveFile
167
+ * @returns {() => any}
168
+ */
169
+ export function lazyRootModule(resolveFile) {
170
+ /** @type {{namespace: any} | null} */
171
+ let loaded = null;
172
+ return () => {
173
+ if (loaded) return loaded.namespace;
174
+ let namespace = null;
175
+ let file = null;
176
+ try {
177
+ file = resolveFile();
178
+ } catch {
179
+ // A Core whose root entry does not resolve falls back below.
180
+ }
181
+ try {
182
+ if (file) namespace = createRequire(import.meta.url)(file);
183
+ } catch (error) {
184
+ const code = /** @type {any} */ (error)?.code;
185
+ // The theme namespace would stand in for the root's own exports here.
186
+ if (code === 'ERR_REQUIRE_ASYNC_MODULE' || code === 'ERR_REQUIRE_ESM') {
187
+ throw new Error(
188
+ `The @astryxdesign/core root entry at ${file} cannot be loaded with require() (${code}), so a theme that imports it cannot be built.`,
189
+ {cause: error},
190
+ );
191
+ }
192
+ // A Core without a usable root entry still builds themes.
193
+ }
194
+ loaded = {namespace};
195
+ return namespace;
196
+ };
197
+ }
198
+
157
199
  /**
158
200
  * Import the CLI's own Core: the `@astryxdesign/core` this module resolves.
159
201
  * Never throws. A failed import is kept as `importError`, so the build can
@@ -178,12 +220,9 @@ async function importCliCore() {
178
220
  core.generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
179
221
  core.generateOnMediaCSS = coreTheme.generateOnMediaCSS;
180
222
  core.generateAdaptationCSS = coreTheme.generateAdaptationCSS;
181
- try {
182
- core.rootModule = await import('@astryxdesign/core');
183
- } catch {
184
- // A core without a usable root entry still builds themes; interception
185
- // falls back to the theme namespace for the root specifier.
186
- }
223
+ core.rootModule = lazyRootModule(() =>
224
+ fileURLToPath(import.meta.resolve('@astryxdesign/core')),
225
+ );
187
226
  } catch (e) {
188
227
  // Capture the reason so the theme action can surface a precise, actionable
189
228
  // error. The hard failure happens when `theme build` runs.
@@ -350,18 +389,10 @@ async function loadProjectCore(cwd, cliCore, {projectOnly = false} = {}) {
350
389
  ERROR_CODES.ERR_CORE_INCOMPATIBLE,
351
390
  );
352
391
  }
353
- let rootModule = null;
354
392
  const rootFile = importTarget(dir, '.');
355
- if (rootFile) {
356
- try {
357
- rootModule = await import(pathToFileURL(rootFile).href);
358
- } catch {
359
- // As with the CLI's own import, the theme namespace stands in for it.
360
- }
361
- }
362
393
  return {
363
394
  themeModule,
364
- rootModule,
395
+ rootModule: lazyRootModule(() => rootFile),
365
396
  importError: null,
366
397
  defineTheme: themeModule.defineTheme,
367
398
  generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
@@ -16,7 +16,8 @@
16
16
  * standalone builds with current Core do not.
17
17
  *
18
18
  * @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
19
- * @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace.
19
+ * @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
20
+ * or a function that loads it. A function is called once, on first use.
20
21
  * @returns {CoreInterception}
21
22
  */
22
23
  export function interceptCore(coreThemeModule: any, coreRootModule?: any): CoreInterception;
@@ -236,7 +236,8 @@ function mergeGenerativeAxes(inherited, own) {
236
236
  * standalone builds with current Core do not.
237
237
  *
238
238
  * @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
239
- * @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace.
239
+ * @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
240
+ * or a function that loads it. A function is called once, on first use.
240
241
  * @returns {CoreInterception}
241
242
  */
242
243
  export function interceptCore(coreThemeModule, coreRootModule) {
@@ -287,14 +288,31 @@ export function interceptCore(coreThemeModule, coreRootModule) {
287
288
  };
288
289
  };
289
290
 
290
- return {
291
- modules: {
292
- '@astryxdesign/core/theme': wrapNamespace(coreThemeModule),
291
+ const modules = {
292
+ '@astryxdesign/core/theme': wrapNamespace(coreThemeModule),
293
+ };
294
+ /** @type {any} */
295
+ let wrappedRoot;
296
+ // jiti reads a virtual module only when a theme imports its specifier. So
297
+ // the root, which loads all of Core, loads only for a theme that asks.
298
+ Object.defineProperty(modules, '@astryxdesign/core', {
299
+ enumerable: true,
300
+ configurable: true,
301
+ get() {
302
+ const root =
303
+ typeof coreRootModule === 'function'
304
+ ? coreRootModule()
305
+ : coreRootModule;
293
306
  // Falls back to the theme namespace only when the root could not be
294
307
  // imported at all; a partial root is better than none, and a core
295
308
  // missing its own root entry is already broken.
296
- '@astryxdesign/core': wrapNamespace(coreRootModule ?? coreThemeModule),
309
+ wrappedRoot ??= wrapNamespace(root ?? coreThemeModule);
310
+ return wrappedRoot;
297
311
  },
312
+ });
313
+
314
+ return {
315
+ modules,
298
316
 
299
317
  // prettier-ignore
300
318
  observed(theme) { return wasObserved(theme, byReference); },
@@ -34,6 +34,7 @@ const registry = new Map([
34
34
  ['0.7.0', () => import('./transforms/v0.7.0/index.mjs')],
35
35
  ['0.7.2', () => import('./transforms/v0.7.2/index.mjs')],
36
36
  ['0.7.5', () => import('./transforms/v0.7.5/index.mjs')],
37
+ ['0.7.8', () => import('./transforms/v0.7.8/index.mjs')],
37
38
  ]);
38
39
 
39
40
  // Re-export from the shared utility so registry callers and other consumers
@@ -7,14 +7,4 @@
7
7
  * this file into the resolved version folder.
8
8
  */
9
9
 
10
- import promoteTokenizerPresentation, {
11
- meta as promoteTokenizerPresentationMeta,
12
- } from './promote-tokenizer-presentation.mjs';
13
-
14
- export default [
15
- {
16
- name: 'promote-tokenizer-presentation',
17
- transform: promoteTokenizerPresentation,
18
- meta: promoteTokenizerPresentationMeta,
19
- },
20
- ];
10
+ export default [];
@@ -0,0 +1,20 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file next transform manifest
5
+ *
6
+ * Staged codemods for the next release. The Version Packages PR promotes
7
+ * this file into the resolved version folder.
8
+ */
9
+
10
+ import promoteTokenizerPresentation, {
11
+ meta as promoteTokenizerPresentationMeta,
12
+ } from './promote-tokenizer-presentation.mjs';
13
+
14
+ export default [
15
+ {
16
+ name: 'promote-tokenizer-presentation',
17
+ transform: promoteTokenizerPresentation,
18
+ meta: promoteTokenizerPresentationMeta,
19
+ },
20
+ ];
@@ -32,7 +32,12 @@ export const docs = {
32
32
  },
33
33
  {
34
34
  type: 'table',
35
- headers: ['Tier', 'Baseline', 'Representative versions', 'What your users experience'],
35
+ headers: [
36
+ 'Tier',
37
+ 'Baseline',
38
+ 'Representative versions',
39
+ 'What your users experience',
40
+ ],
36
41
  rows: [
37
42
  [
38
43
  'Tier 1: Full fidelity',
@@ -138,6 +143,27 @@ export const docs = {
138
143
  },
139
144
  ],
140
145
  },
146
+ {
147
+ title: 'The On-Screen Keyboard',
148
+ content: [
149
+ {
150
+ type: 'prose',
151
+ text: "On a phone, a fully expanded `height='tall'` BottomSheet responds to the on-screen keyboard: it measures the keyboard as the layout viewport's height minus the visual viewport's height times its scale. Where the visual viewport shrinks for the keyboard, as in Safari on iOS in the browser and as a home-screen app, in Firefox for Android and in Chrome on Android, it keeps the focused field above the keyboard and leaves the page where it was. If Firefox for Android pans to the field, the sheet puts the page back within a couple of frames.",
152
+ },
153
+ {
154
+ type: 'prose',
155
+ text: 'In Chrome on Android, a Tall BottomSheet\u2019s focused field rides the keyboard as Gboard slides it up, and as Gboard slides it down after the field loses focus. The scroll room stays until the keyboard is down. A hide Chrome reports late, such as Back, which keeps the focus, rides down from Chrome\u2019s report. When the keyboard is reported, the sheet places the field just above it in that same frame, so Chrome has no covered field to pan to; if Chrome pans anyway, the sheet puts the page back when that pan ends. Chrome follows your viewport setting, which Astryx documents and never sets: your app owns its viewport `<meta>` element. By default (`interactive-widget=resizes-visual`) Chrome lays the keyboard over the page and pans to a focused field elsewhere on the page. With `interactive-widget=resizes-content` it shrinks the layout viewport instead, so content anchored to the bottom sits above the keyboard, and the sheet measures no keyboard and changes nothing: the browser has already made the room.',
156
+ },
157
+ {
158
+ type: 'code',
159
+ lang: 'html',
160
+ label: 'Chrome on Android resizes the page for the keyboard',
161
+ code: `<meta
162
+ name="viewport"
163
+ content="width=device-width, initial-scale=1, interactive-widget=resizes-content" />`,
164
+ },
165
+ ],
166
+ },
141
167
  {
142
168
  title: 'Supporting Older Browsers',
143
169
  content: [
@@ -86,7 +86,7 @@ export const docs = {
86
86
  [
87
87
  "--color-accent",
88
88
  "#0064E0",
89
- "#2694FE"
89
+ "#0171E3"
90
90
  ],
91
91
  [
92
92
  "--color-accent-muted",
@@ -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: 'useClickableContainer',
7
+ name: 'useClickableContainer — Clickable Project Card',
8
+ displayName: 'useClickableContainer — Clickable Project Card',
9
+ description:
10
+ 'A project card that useClickableContainer makes clickable anywhere: a click on the card follows its title link, while the Star button, the owner link and a text selection keep their own behavior, and Ctrl/Cmd+click or middle-click opens the project in a new tab.',
11
+ isReady: true,
12
+ aspectRatio: 4 / 3,
13
+ componentsUsed: ['Card', 'Button', 'Link', 'Text', 'Layout'],
14
+ };
@@ -0,0 +1,67 @@
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 {useClickableContainer} from '@astryxdesign/core/hooks';
9
+ import {HStack, VStack} from '@astryxdesign/core/Layout';
10
+ import {Link} from '@astryxdesign/core/Link';
11
+ import {Heading, Text} from '@astryxdesign/core/Text';
12
+
13
+ const PROJECT_HREF = '#project-design-tokens';
14
+
15
+ export default function UseClickableContainerHookUsage() {
16
+ const containerRef = useRef<HTMLDivElement>(null);
17
+ const projectLinkRef = useRef<HTMLAnchorElement | HTMLButtonElement>(null);
18
+ const [openCount, setOpenCount] = useState(0);
19
+ const [isStarred, setIsStarred] = useState(false);
20
+ const {onClick, onMouseUp} = useClickableContainer({
21
+ containerRef,
22
+ interactiveRef: projectLinkRef,
23
+ href: PROJECT_HREF,
24
+ });
25
+
26
+ return (
27
+ <VStack gap={3}>
28
+ <Card
29
+ ref={containerRef}
30
+ onClick={onClick}
31
+ onMouseUp={onMouseUp}
32
+ width={360}
33
+ padding={4}>
34
+ <VStack gap={2}>
35
+ <HStack gap={2} justify="between" vAlign="center">
36
+ <Heading level={4}>
37
+ <Link
38
+ ref={projectLinkRef}
39
+ href={PROJECT_HREF}
40
+ type="inherit"
41
+ onClick={() => setOpenCount(count => count + 1)}>
42
+ Design tokens
43
+ </Link>
44
+ </Heading>
45
+ <Button
46
+ label={isStarred ? 'Starred' : 'Star'}
47
+ variant="secondary"
48
+ onClick={() => setIsStarred(starred => !starred)}
49
+ />
50
+ </HStack>
51
+ <Text type="body" color="secondary">
52
+ Color, spacing and type tokens shared by every product surface.
53
+ </Text>
54
+ <Text type="supporting" color="secondary">
55
+ Owned by{' '}
56
+ <Link href="#team-design-systems" type="inherit">
57
+ Design Systems
58
+ </Link>
59
+ </Text>
60
+ </VStack>
61
+ </Card>
62
+ <Text type="supporting">
63
+ Project opened {openCount} {openCount === 1 ? 'time' : 'times'}
64
+ </Text>
65
+ </VStack>
66
+ );
67
+ }