@astryxdesign/cli 0.1.6-canary.eb23da7 → 0.1.6-canary.eba4f34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -13
- package/src/api/template.mjs +27 -103
- package/src/api/validate-integration.mjs +8 -0
- package/src/lib/component-discovery.mjs +5 -15
- package/src/lib/component-loader.mjs +0 -53
- package/src/lib/config-schema.mjs +30 -0
- package/src/lib/xle/registry.mjs +5 -0
- package/templates/blocks/components/Avatar/AvatarGroup.tsx +7 -5
- package/templates/blocks/components/Avatar/AvatarShowcase.tsx +6 -4
- package/templates/blocks/components/Avatar/AvatarUserCard.tsx +5 -3
- package/templates/blocks/components/Avatar/AvatarWithImage.tsx +6 -8
- package/templates/blocks/components/Avatar/AvatarWithStatus.tsx +5 -3
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputControlledInput.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputDisabled.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputShowcase.tsx +1 -1
- package/templates/blocks/components/ChatComposerInput/ChatComposerInputSlashCommands.tsx +1 -1
- package/templates/pages/theme-showcase/page.tsx +7 -7
- package/templates/themes/neutral/neutralTheme.ts +32 -63
- package/docs/integration-authoring.md +0 -105
- package/docs/internationalization.doc.mjs +0 -243
- package/src/api/integration-block-exports.test.mjs +0 -240
- package/src/api/template-suffix.test.mjs +0 -246
- package/src/doc.mjs +0 -271
- package/src/doc.test.mjs +0 -383
- package/src/lib/component-discovery.importpath.test.mjs +0 -59
- package/src/types/doc.d.ts +0 -139
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +0 -41
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +0 -13
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +0 -78
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +0 -38
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +0 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.1.6-canary.
|
|
3
|
+
"version": "0.1.6-canary.eba4f34",
|
|
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,10 +47,6 @@
|
|
|
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
|
-
},
|
|
54
50
|
"./template": {
|
|
55
51
|
"types": "./src/types/template-api.d.ts",
|
|
56
52
|
"import": "./src/template.mjs"
|
|
@@ -79,10 +75,10 @@
|
|
|
79
75
|
"zod": "^4.4.3"
|
|
80
76
|
},
|
|
81
77
|
"peerDependencies": {
|
|
82
|
-
"@astryxdesign/charts": "0.1.6-canary.
|
|
83
|
-
"@astryxdesign/core": "0.1.6-canary.
|
|
84
|
-
"@astryxdesign/lab": "0.1.6-canary.
|
|
85
|
-
"@astryxdesign/theme-neutral": "0.1.6-canary.
|
|
78
|
+
"@astryxdesign/charts": "0.1.6-canary.eba4f34",
|
|
79
|
+
"@astryxdesign/core": "0.1.6-canary.eba4f34",
|
|
80
|
+
"@astryxdesign/lab": "0.1.6-canary.eba4f34",
|
|
81
|
+
"@astryxdesign/theme-neutral": "0.1.6-canary.eba4f34",
|
|
86
82
|
"gpt-tokenizer": "^3.4.0"
|
|
87
83
|
},
|
|
88
84
|
"peerDependenciesMeta": {
|
|
@@ -100,10 +96,10 @@
|
|
|
100
96
|
}
|
|
101
97
|
},
|
|
102
98
|
"devDependencies": {
|
|
103
|
-
"@astryxdesign/charts": "0.1.6-canary.
|
|
104
|
-
"@astryxdesign/core": "0.1.6-canary.
|
|
105
|
-
"@astryxdesign/lab": "0.1.6-canary.
|
|
106
|
-
"@astryxdesign/theme-neutral": "0.1.6-canary.
|
|
99
|
+
"@astryxdesign/charts": "0.1.6-canary.eba4f34",
|
|
100
|
+
"@astryxdesign/core": "0.1.6-canary.eba4f34",
|
|
101
|
+
"@astryxdesign/lab": "0.1.6-canary.eba4f34",
|
|
102
|
+
"@astryxdesign/theme-neutral": "0.1.6-canary.eba4f34",
|
|
107
103
|
"gpt-tokenizer": "^3.4.0"
|
|
108
104
|
},
|
|
109
105
|
"scripts": {
|
package/src/api/template.mjs
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import * as fs from 'node:fs';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
|
-
import {createJiti} from 'jiti';
|
|
10
9
|
import {loadModuleWithSchema} from '../lib/module-loader.mjs';
|
|
11
10
|
import {TemplateEnvelopeSchema} from '../template.mjs';
|
|
12
11
|
import {CLI_ROOT, discoverExternalPackages} from '../utils/paths.mjs';
|
|
@@ -22,54 +21,9 @@ import {Project} from '../lib/project.mjs';
|
|
|
22
21
|
/** Identity used for core (built-in) templates in package-scoped listings. */
|
|
23
22
|
const CORE_PACKAGE = '@astryxdesign/core';
|
|
24
23
|
|
|
25
|
-
/**
|
|
26
|
-
* Canonical basename suffixes for template-spec files, in precedence order.
|
|
27
|
-
* A template spec exports a `createBlockTemplate`/`createPageTemplate` result
|
|
28
|
-
* (a scaffoldable TEMPLATE), so `.template.*` is the descriptive family name.
|
|
29
|
-
*/
|
|
30
|
-
const TEMPLATE_SUFFIXES = ['.template.ts', '.template.mjs', '.template.js'];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Legacy basename suffixes for template-spec files, in precedence order.
|
|
34
|
-
* `.doc.*` was inherited from the component-doc convention before templates
|
|
35
|
-
* had their own name; it is still accepted during the transition window.
|
|
36
|
-
*/
|
|
24
|
+
/** Doc-file basename suffixes for integration templates, in precedence order. */
|
|
37
25
|
const DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
38
26
|
|
|
39
|
-
/**
|
|
40
|
-
* The union of canonical + legacy template-spec suffixes, canonical first so
|
|
41
|
-
* `.template.*` wins over `.doc.*` when both stems exist. All template
|
|
42
|
-
* discovery matches this union so a `Foo.template.ts` file is treated exactly
|
|
43
|
-
* like a legacy `Foo.doc.mjs`.
|
|
44
|
-
*/
|
|
45
|
-
const ALL_TEMPLATE_SUFFIXES = [...TEMPLATE_SUFFIXES, ...DOC_SUFFIXES];
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The template-spec suffix present on `file`, or null if none matches.
|
|
49
|
-
* Recognizes both the canonical `.template.*` and legacy `.doc.*` families.
|
|
50
|
-
* @param {string} file
|
|
51
|
-
* @returns {string | null}
|
|
52
|
-
*/
|
|
53
|
-
function matchedTemplateSuffix(file) {
|
|
54
|
-
return ALL_TEMPLATE_SUFFIXES.find(suffix => file.endsWith(suffix)) ?? null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* RegExp matching either template-spec suffix family at end of a basename.
|
|
59
|
-
* Used where a per-file regex is convenient (e.g. block discovery walks).
|
|
60
|
-
*/
|
|
61
|
-
const TEMPLATE_SUFFIX_RE = /\.(template|doc)\.(ts|mjs|js)$/;
|
|
62
|
-
|
|
63
|
-
let jitiInstance;
|
|
64
|
-
/** Lazily-created jiti for loading `.ts` template specs (JSX-capable). */
|
|
65
|
-
function getJiti() {
|
|
66
|
-
if (!jitiInstance) {
|
|
67
|
-
jitiInstance = createJiti(import.meta.url, {jsx: true});
|
|
68
|
-
}
|
|
69
|
-
return jitiInstance;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
27
|
/**
|
|
74
28
|
* Load an integration template doc module and validate it against the template
|
|
75
29
|
* envelope at the load boundary. Default export only — `.ts` via jiti,
|
|
@@ -133,29 +87,12 @@ export function stripTemplateAssetRefs(source) {
|
|
|
133
87
|
source,
|
|
134
88
|
);
|
|
135
89
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Load a template-spec module and return its metadata object. Supports both
|
|
138
|
-
* families of suffix:
|
|
139
|
-
* - Legacy `.doc.*` core/external specs export `export const doc = {...}`.
|
|
140
|
-
* - Specs authored with `createPageTemplate`/`createBlockTemplate` export the
|
|
141
|
-
* stamped object as the default export.
|
|
142
|
-
* Prefers the default export, falling back to the named `doc` export, so a
|
|
143
|
-
* `Foo.template.ts` (default export) is read identically to a legacy
|
|
144
|
-
* `Foo.doc.mjs` (`doc` export). `.ts` is loaded via jiti; `.mjs`/`.js` via a
|
|
145
|
-
* native dynamic import. Returns null if the file does not exist.
|
|
146
|
-
*
|
|
147
|
-
* @param {string} docPath absolute path to the spec file
|
|
148
|
-
* @returns {Promise<Record<string, unknown> | undefined | null>}
|
|
149
|
-
*/
|
|
150
90
|
async function loadDocModule(docPath) {
|
|
151
91
|
if (!fs.existsSync(docPath)) return null;
|
|
152
|
-
const docModule = docPath
|
|
153
|
-
|
|
154
|
-
: await import(`file://${docPath}`);
|
|
155
|
-
return docModule.default ?? docModule.doc;
|
|
92
|
+
const docModule = await import(`file://${docPath}`);
|
|
93
|
+
return docModule.doc;
|
|
156
94
|
}
|
|
157
95
|
|
|
158
|
-
|
|
159
96
|
export {discoverAll as discoverTemplates};
|
|
160
97
|
|
|
161
98
|
export function listTemplates() {
|
|
@@ -185,20 +122,6 @@ function findDocFiles(dir, pattern) {
|
|
|
185
122
|
return results;
|
|
186
123
|
}
|
|
187
124
|
|
|
188
|
-
/**
|
|
189
|
-
* Resolve the template-spec file for a core page directory: the first existing
|
|
190
|
-
* `template.<suffix>` in canonical-then-legacy precedence, or null.
|
|
191
|
-
* @param {string} dirPath
|
|
192
|
-
* @returns {string | null}
|
|
193
|
-
*/
|
|
194
|
-
function findPageDocFile(dirPath) {
|
|
195
|
-
for (const suffix of ALL_TEMPLATE_SUFFIXES) {
|
|
196
|
-
const candidate = path.join(dirPath, `template${suffix}`);
|
|
197
|
-
if (fs.existsSync(candidate)) return candidate;
|
|
198
|
-
}
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
125
|
async function discoverPages() {
|
|
203
126
|
if (!fs.existsSync(PAGES_DIR)) return [];
|
|
204
127
|
const dirs = fs
|
|
@@ -208,9 +131,7 @@ async function discoverPages() {
|
|
|
208
131
|
const templates = [];
|
|
209
132
|
for (const dir of dirs) {
|
|
210
133
|
const dirPath = path.join(PAGES_DIR, dir.name);
|
|
211
|
-
const
|
|
212
|
-
findPageDocFile(dirPath) ?? path.join(dirPath, 'template.doc.mjs');
|
|
213
|
-
const doc = await loadDocModule(docPath);
|
|
134
|
+
const doc = await loadDocModule(path.join(dirPath, 'template.doc.mjs'));
|
|
214
135
|
templates.push({
|
|
215
136
|
type: 'page',
|
|
216
137
|
dirName: dir.name,
|
|
@@ -220,18 +141,17 @@ async function discoverPages() {
|
|
|
220
141
|
isReady: doc?.isReady ?? true,
|
|
221
142
|
scaffold: doc?.scaffold ?? false,
|
|
222
143
|
filePath: path.join(dirPath, 'page.tsx'),
|
|
223
|
-
docPath,
|
|
144
|
+
docPath: path.join(dirPath, 'template.doc.mjs'),
|
|
224
145
|
});
|
|
225
146
|
}
|
|
226
147
|
return templates;
|
|
227
148
|
}
|
|
228
149
|
|
|
229
150
|
async function discoverBlocks() {
|
|
230
|
-
const docFiles = findDocFiles(BLOCKS_DIR,
|
|
151
|
+
const docFiles = findDocFiles(BLOCKS_DIR, /\.doc\.mjs$/);
|
|
231
152
|
const blocks = [];
|
|
232
153
|
for (const docPath of docFiles) {
|
|
233
|
-
const
|
|
234
|
-
const basename = path.basename(docPath, suffix);
|
|
154
|
+
const basename = path.basename(docPath, '.doc.mjs');
|
|
235
155
|
const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
|
|
236
156
|
if (!fs.existsSync(tsxPath)) continue;
|
|
237
157
|
const doc = await loadDocModule(docPath);
|
|
@@ -253,7 +173,6 @@ async function discoverBlocks() {
|
|
|
253
173
|
return blocks;
|
|
254
174
|
}
|
|
255
175
|
|
|
256
|
-
|
|
257
176
|
/**
|
|
258
177
|
* Discover blocks from external packages that declare `astryx.blocks` in
|
|
259
178
|
* their package.json. Same shape as discoverBlocks() output.
|
|
@@ -266,10 +185,9 @@ async function discoverExternalBlocks(cwd = process.cwd()) {
|
|
|
266
185
|
|
|
267
186
|
for (const ext of externals) {
|
|
268
187
|
if (!ext.blocksDir || !fs.existsSync(ext.blocksDir)) continue;
|
|
269
|
-
const docFiles = findDocFiles(ext.blocksDir,
|
|
188
|
+
const docFiles = findDocFiles(ext.blocksDir, /\.doc\.mjs$/);
|
|
270
189
|
for (const docPath of docFiles) {
|
|
271
|
-
const
|
|
272
|
-
const basename = path.basename(docPath, suffix);
|
|
190
|
+
const basename = path.basename(docPath, '.doc.mjs');
|
|
273
191
|
const tsxPath = path.join(path.dirname(docPath), basename + '.tsx');
|
|
274
192
|
if (!fs.existsSync(tsxPath)) continue;
|
|
275
193
|
const doc = await loadDocModule(docPath);
|
|
@@ -340,9 +258,8 @@ async function discoverAllWithErrors(cwd = process.cwd()) {
|
|
|
340
258
|
export {discoverAllWithErrors};
|
|
341
259
|
|
|
342
260
|
/**
|
|
343
|
-
* Recursively collect integration template
|
|
344
|
-
* Returns absolute paths to files ending in one of
|
|
345
|
-
* (canonical `.template.*` or legacy `.doc.*`).
|
|
261
|
+
* Recursively collect integration template doc files under `root`.
|
|
262
|
+
* Returns absolute paths to files ending in one of DOC_SUFFIXES.
|
|
346
263
|
*
|
|
347
264
|
* @param {string} root
|
|
348
265
|
* @returns {string[]}
|
|
@@ -355,7 +272,7 @@ function findIntegrationDocFiles(root) {
|
|
|
355
272
|
const full = path.join(dir, entry.name);
|
|
356
273
|
if (entry.isDirectory()) {
|
|
357
274
|
walk(full);
|
|
358
|
-
} else if (
|
|
275
|
+
} else if (DOC_SUFFIXES.some(suffix => entry.name.endsWith(suffix))) {
|
|
359
276
|
results.push(full);
|
|
360
277
|
}
|
|
361
278
|
}
|
|
@@ -364,17 +281,24 @@ function findIntegrationDocFiles(root) {
|
|
|
364
281
|
return results;
|
|
365
282
|
}
|
|
366
283
|
|
|
284
|
+
/**
|
|
285
|
+
* The doc-file suffix present on `file`, or null if none matches.
|
|
286
|
+
* @param {string} file
|
|
287
|
+
*/
|
|
288
|
+
function matchedDocSuffix(file) {
|
|
289
|
+
return DOC_SUFFIXES.find(suffix => file.endsWith(suffix)) ?? null;
|
|
290
|
+
}
|
|
291
|
+
|
|
367
292
|
/**
|
|
368
293
|
* Discover templates contributed by configured integrations.
|
|
369
294
|
*
|
|
370
295
|
* For each integration with a resolved `templates` root, every
|
|
371
|
-
* `<id>.
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* template is skipped (recorded in `errors`).
|
|
296
|
+
* `<id>.doc.{ts,mjs,js}` file is a template whose id is its path relative to
|
|
297
|
+
* the templates root with the `.doc.*` suffix stripped (kebab-case, may be
|
|
298
|
+
* nested). The doc's `type` (page|block) decides scaffolding — there is no
|
|
299
|
+
* `/pages` vs `/blocks` requirement. A same-stem sibling source file
|
|
300
|
+
* (`<id>.tsx`) is required; a doc missing its source, or missing `type`, is
|
|
301
|
+
* an integration error and that template is skipped (recorded in `errors`).
|
|
378
302
|
*
|
|
379
303
|
* @param {string} [cwd]
|
|
380
304
|
* @returns {Promise<{templates: object[], errors: {package: string, template?: string, message: string}[]}>}
|
|
@@ -420,7 +344,7 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
420
344
|
if (!root || !fs.existsSync(root)) return {templates, errors};
|
|
421
345
|
|
|
422
346
|
for (const docPath of findIntegrationDocFiles(root)) {
|
|
423
|
-
const suffix =
|
|
347
|
+
const suffix = matchedDocSuffix(docPath);
|
|
424
348
|
const id = path
|
|
425
349
|
.relative(root, docPath)
|
|
426
350
|
.slice(0, -suffix.length)
|
|
@@ -67,6 +67,11 @@ function error(code, message) {
|
|
|
67
67
|
return {code, severity: 'error', message};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/** @param {string} code @param {string} message @returns {Issue} */
|
|
71
|
+
function warning(code, message) {
|
|
72
|
+
return {code, severity: 'warning', message};
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
/**
|
|
71
76
|
* Verify each declared contribution root exists on disk. A declared-but-missing
|
|
72
77
|
* root is a `missing_root` error.
|
|
@@ -360,3 +365,6 @@ export function summarizeIssues(issues) {
|
|
|
360
365
|
}
|
|
361
366
|
return {errors, warnings};
|
|
362
367
|
}
|
|
368
|
+
|
|
369
|
+
// Re-export issue constructors for callers/tests that want them.
|
|
370
|
+
export {error as integrationError, warning as integrationWarning};
|
|
@@ -273,24 +273,14 @@ export function findComponentReadme(coreDir, name) {
|
|
|
273
273
|
* For "Button" finds src/Button/XDSButton.tsx
|
|
274
274
|
* For "Layout" finds src/Layout/XDSLayout/XDSLayout.tsx
|
|
275
275
|
* For "Card" finds src/Layout/Container/XDSCard.tsx (deep search fallback)
|
|
276
|
-
*
|
|
277
|
-
* Hooks and other functions are authored as `.ts` (e.g. `useMediaQuery.ts`,
|
|
278
|
-
* `useResizable.ts`), so `.ts` candidates are searched alongside `.tsx`. Without
|
|
279
|
-
* this, deriving the import path for a `.ts`-authored function falls back to the
|
|
280
|
-
* bare `@astryxdesign/core` root instead of its tree-shakeable subpath.
|
|
281
276
|
*/
|
|
282
277
|
export function findComponentSource(coreDir, name) {
|
|
283
278
|
const srcDir = path.join(coreDir, 'src');
|
|
284
|
-
// Try the prefixed
|
|
285
|
-
// on-disk convention, then the bare
|
|
286
|
-
// migration (P4) renames to.
|
|
287
|
-
//
|
|
288
|
-
const candidateFiles = [
|
|
289
|
-
`XDS${name}.tsx`,
|
|
290
|
-
`${name}.tsx`,
|
|
291
|
-
`XDS${name}.ts`,
|
|
292
|
-
`${name}.ts`,
|
|
293
|
-
];
|
|
279
|
+
// Try the prefixed form (`XDSButton.tsx`) first since that is the current
|
|
280
|
+
// on-disk convention, then the bare form (`Button.tsx`) that the Astryx-prefix
|
|
281
|
+
// migration (P4) renames to. Listing the prefixed name first keeps behavior
|
|
282
|
+
// identical until files are actually renamed.
|
|
283
|
+
const candidateFiles = [`XDS${name}.tsx`, `${name}.tsx`];
|
|
294
284
|
|
|
295
285
|
function searchDir(dirPath) {
|
|
296
286
|
if (!fs.existsSync(dirPath)) return null;
|
|
@@ -5,59 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import {pathToFileURL} from 'node:url';
|
|
8
|
-
import {importUserModule} from './module-loader.mjs';
|
|
9
|
-
import {formatZodError} from './config-schema.mjs';
|
|
10
|
-
import {ComponentDocSchema} from '../doc.mjs';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Load a component doc through the shared load/validation boundary.
|
|
14
|
-
*
|
|
15
|
-
* This is the typed counterpart to {@link loadDocs}: it loads `.doc.ts` via
|
|
16
|
-
* jiti (and `.doc.mjs`/`.doc.js` via native import) and validates against
|
|
17
|
-
* {@link ComponentDocSchema}. That schema accepts BOTH formats, so this loader
|
|
18
|
-
* reads whichever the file uses:
|
|
19
|
-
* - NEW: the factory default export
|
|
20
|
-
* (`export default createComponentDoc({...})` / `createFunctionDoc` /
|
|
21
|
-
* `createDoc`) — the same single-export convention
|
|
22
|
-
* {@link loadModuleWithSchema} uses for config/integration/template. These
|
|
23
|
-
* carry a stamped `type` and validate against the matching per-kind schema.
|
|
24
|
-
* - OLD: the legacy loose `export const docs = {...}` (no `type`), validated
|
|
25
|
-
* against the permissive legacy union.
|
|
26
|
-
* The default export wins when both are present. Throws a readable
|
|
27
|
-
* `formatZodError`-style message on failure. Translations (`docsZh`/
|
|
28
|
-
* `docsDense`) are merged exactly as {@link loadDocs} does so callers see
|
|
29
|
-
* identical output.
|
|
30
|
-
*
|
|
31
|
-
* @param {string} docPath absolute path to a `.doc.{ts,mjs,js}` file
|
|
32
|
-
* @param {{zh?: boolean, dense?: boolean, lang?: string}} [opts]
|
|
33
|
-
* @returns {Promise<object>} the validated (and optionally translated) doc
|
|
34
|
-
*/
|
|
35
|
-
export async function loadComponentDoc(
|
|
36
|
-
docPath,
|
|
37
|
-
{zh = false, dense = false, lang} = {},
|
|
38
|
-
) {
|
|
39
|
-
const mod = await importUserModule(docPath);
|
|
40
|
-
const authored = mod?.default ?? mod?.docs;
|
|
41
|
-
|
|
42
|
-
const result = ComponentDocSchema.safeParse(authored);
|
|
43
|
-
if (!result.success) {
|
|
44
|
-
throw new Error(formatZodError(docPath, result.error));
|
|
45
|
-
}
|
|
46
|
-
const docs = authored;
|
|
47
|
-
|
|
48
|
-
const locale = lang || (dense ? 'dense' : zh ? 'zh' : null);
|
|
49
|
-
if (!locale) return docs;
|
|
50
|
-
|
|
51
|
-
const translationKey =
|
|
52
|
-
locale === 'zh' ? 'docsZh' : locale === 'dense' ? 'docsDense' : null;
|
|
53
|
-
if (!translationKey || !mod[translationKey]) return docs;
|
|
54
|
-
|
|
55
|
-
const translation = mod[translationKey];
|
|
56
|
-
if (translation.props || translation.components?.some(c => c.props)) {
|
|
57
|
-
return translation;
|
|
58
|
-
}
|
|
59
|
-
return mergeTranslation(docs, translation);
|
|
60
|
-
}
|
|
61
8
|
|
|
62
9
|
export function mergeTranslation(docs, translation) {
|
|
63
10
|
if (!translation) return docs;
|
|
@@ -73,3 +73,33 @@ export function formatZodError(label, error) {
|
|
|
73
73
|
.join('; ');
|
|
74
74
|
return `${label} is invalid: ${issues}`;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param {unknown} config
|
|
79
|
+
* @returns {import('../types/config').AstryxConfig}
|
|
80
|
+
*/
|
|
81
|
+
export function validateConfig(config) {
|
|
82
|
+
const result = AstryxConfigSchema.safeParse(config);
|
|
83
|
+
if (!result.success) {
|
|
84
|
+
throw new Error(
|
|
85
|
+
formatZodError('astryx.config default export', result.error),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return result.data;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {unknown} integration
|
|
93
|
+
* @param {string} [label]
|
|
94
|
+
* @returns {import('../types/integration').AstryxIntegration}
|
|
95
|
+
*/
|
|
96
|
+
export function validateIntegration(
|
|
97
|
+
integration,
|
|
98
|
+
label = 'integration manifest',
|
|
99
|
+
) {
|
|
100
|
+
const result = AstryxIntegrationSchema.safeParse(integration);
|
|
101
|
+
if (!result.success) {
|
|
102
|
+
throw new Error(formatZodError(label, result.error));
|
|
103
|
+
}
|
|
104
|
+
return result.data;
|
|
105
|
+
}
|
package/src/lib/xle/registry.mjs
CHANGED
|
@@ -7,26 +7,28 @@ import {AvatarGroup, AvatarGroupOverflow} from '@astryxdesign/core/AvatarGroup';
|
|
|
7
7
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
8
8
|
import {Text} from '@astryxdesign/core/Text';
|
|
9
9
|
|
|
10
|
+
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
11
|
+
|
|
10
12
|
const USERS = [
|
|
11
13
|
{
|
|
12
14
|
name: 'Ami Pena',
|
|
13
|
-
src:
|
|
15
|
+
src: `${CDN}/DATA-Ami-Pena.png`,
|
|
14
16
|
},
|
|
15
17
|
{
|
|
16
18
|
name: 'Drew Young',
|
|
17
|
-
src:
|
|
19
|
+
src: `${CDN}/DATA-Drew-Young.png`,
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
name: 'Gabriela Fernandez',
|
|
21
|
-
src:
|
|
23
|
+
src: `${CDN}/DATA-Gabriela-Fernandez.png`,
|
|
22
24
|
},
|
|
23
25
|
{
|
|
24
26
|
name: 'Jihoo Song',
|
|
25
|
-
src:
|
|
27
|
+
src: `${CDN}/DATA-Jihoo-Song.png`,
|
|
26
28
|
},
|
|
27
29
|
{
|
|
28
30
|
name: 'Nam Tran',
|
|
29
|
-
src:
|
|
31
|
+
src: `${CDN}/DATA-Nam-Tran.png`,
|
|
30
32
|
},
|
|
31
33
|
];
|
|
32
34
|
|
|
@@ -5,27 +5,29 @@
|
|
|
5
5
|
import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
+
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
+
|
|
8
10
|
export default function AvatarShowcase() {
|
|
9
11
|
return (
|
|
10
12
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
11
13
|
<Avatar
|
|
12
|
-
src=
|
|
14
|
+
src={`${CDN}/DATA-Ana-Thomas.png`}
|
|
13
15
|
name="Ana Thomas"
|
|
14
16
|
size="large"
|
|
15
17
|
status={<AvatarStatusDot variant="success" label="Online" />}
|
|
16
18
|
/>
|
|
17
19
|
<Avatar
|
|
18
|
-
src=
|
|
20
|
+
src={`${CDN}/DATA-Drew-Young.png`}
|
|
19
21
|
name="Drew Young"
|
|
20
22
|
size="large"
|
|
21
23
|
/>
|
|
22
24
|
<Avatar
|
|
23
|
-
src=
|
|
25
|
+
src={`${CDN}/DATA-Jihoo-Song.png`}
|
|
24
26
|
name="Jihoo Song"
|
|
25
27
|
size="large"
|
|
26
28
|
/>
|
|
27
29
|
<Avatar
|
|
28
|
-
src=
|
|
30
|
+
src={`${CDN}/DATA-Nam-Tran.png`}
|
|
29
31
|
name="Nam Tran"
|
|
30
32
|
size="large"
|
|
31
33
|
status={<AvatarStatusDot variant="error" label="Online" />}
|
|
@@ -6,22 +6,24 @@ import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
import {Text} from '@astryxdesign/core/Text';
|
|
8
8
|
|
|
9
|
+
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
10
|
+
|
|
9
11
|
const USERS = [
|
|
10
12
|
{
|
|
11
13
|
name: 'Itai Jordaan',
|
|
12
|
-
src:
|
|
14
|
+
src: `${CDN}/DATA-Itai-Jordaan.png`,
|
|
13
15
|
role: 'Engineering Lead',
|
|
14
16
|
variant: 'success' as const,
|
|
15
17
|
},
|
|
16
18
|
{
|
|
17
19
|
name: 'Margot Schroder',
|
|
18
|
-
src:
|
|
20
|
+
src: `${CDN}/DATA-Margot-Schroder.png`,
|
|
19
21
|
role: 'Product Designer',
|
|
20
22
|
variant: 'neutral' as const,
|
|
21
23
|
},
|
|
22
24
|
{
|
|
23
25
|
name: 'Daniela Gimenez',
|
|
24
|
-
src:
|
|
26
|
+
src: `${CDN}/DATA-Daniela-Gimenez.png`,
|
|
25
27
|
role: 'Engineering Manager',
|
|
26
28
|
variant: 'error' as const,
|
|
27
29
|
},
|
|
@@ -5,26 +5,24 @@
|
|
|
5
5
|
import {Avatar} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
+
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
+
|
|
8
10
|
export default function AvatarWithImage() {
|
|
9
11
|
return (
|
|
10
12
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
13
|
+
<Avatar src={`${CDN}/DATA-Ami-Pena.png`} name="Ami Pena" size="tiny" />
|
|
11
14
|
<Avatar
|
|
12
|
-
src=
|
|
13
|
-
name="Ami Pena"
|
|
14
|
-
size="tiny"
|
|
15
|
-
/>
|
|
16
|
-
<Avatar
|
|
17
|
-
src="https://lookaside.facebook.com/assets/astryx/DATA-Ana-Thomas.png"
|
|
15
|
+
src={`${CDN}/DATA-Ana-Thomas.png`}
|
|
18
16
|
name="Ana Thomas"
|
|
19
17
|
size="small"
|
|
20
18
|
/>
|
|
21
19
|
<Avatar
|
|
22
|
-
src=
|
|
20
|
+
src={`${CDN}/DATA-Daniela-Gimenez.png`}
|
|
23
21
|
name="Daniela Gimenez"
|
|
24
22
|
size="medium"
|
|
25
23
|
/>
|
|
26
24
|
<Avatar
|
|
27
|
-
src=
|
|
25
|
+
src={`${CDN}/DATA-Gabriela-Fernandez.png`}
|
|
28
26
|
name="Gabriela Fernandez"
|
|
29
27
|
size="large"
|
|
30
28
|
/>
|
|
@@ -5,23 +5,25 @@
|
|
|
5
5
|
import {Avatar, AvatarStatusDot} from '@astryxdesign/core/Avatar';
|
|
6
6
|
import {Stack} from '@astryxdesign/core/Layout';
|
|
7
7
|
|
|
8
|
+
const CDN = 'https://lookaside.facebook.com/assets/astryx';
|
|
9
|
+
|
|
8
10
|
export default function AvatarWithStatus() {
|
|
9
11
|
return (
|
|
10
12
|
<Stack direction="horizontal" gap={4} vAlign="center">
|
|
11
13
|
<Avatar
|
|
12
|
-
src=
|
|
14
|
+
src={`${CDN}/DATA-Itai-Jordaan.png`}
|
|
13
15
|
name="Itai Jordaan"
|
|
14
16
|
size="large"
|
|
15
17
|
status={<AvatarStatusDot variant="success" label="Online" />}
|
|
16
18
|
/>
|
|
17
19
|
<Avatar
|
|
18
|
-
src=
|
|
20
|
+
src={`${CDN}/DATA-Margot-Schroder.png`}
|
|
19
21
|
name="Margot Schroder"
|
|
20
22
|
size="large"
|
|
21
23
|
status={<AvatarStatusDot variant="neutral" label="Offline" />}
|
|
22
24
|
/>
|
|
23
25
|
<Avatar
|
|
24
|
-
src=
|
|
26
|
+
src={`${CDN}/DATA-Pablo-Morales.png`}
|
|
25
27
|
name="Pablo Morales"
|
|
26
28
|
size="large"
|
|
27
29
|
status={<AvatarStatusDot variant="error" label="Busy" />}
|
|
@@ -10,7 +10,7 @@ import {Text} from '@astryxdesign/core/Text';
|
|
|
10
10
|
export default function ChatComposerInputControlledInput() {
|
|
11
11
|
const [value, setValue] = useState('');
|
|
12
12
|
return (
|
|
13
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
13
|
+
<Stack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
|
|
14
14
|
<ChatComposer
|
|
15
15
|
onSubmit={() => setValue('')}
|
|
16
16
|
value={value}
|
|
@@ -7,7 +7,7 @@ import {Stack} from '@astryxdesign/core/Layout';
|
|
|
7
7
|
|
|
8
8
|
export default function ChatComposerInputDisabled() {
|
|
9
9
|
return (
|
|
10
|
-
<Stack direction="vertical" style={{width:
|
|
10
|
+
<Stack direction="vertical" style={{width: '100%', maxWidth: 450}}>
|
|
11
11
|
<ChatComposer
|
|
12
12
|
onSubmit={() => {}}
|
|
13
13
|
isDisabled
|
|
@@ -43,7 +43,7 @@ export default function ChatComposerInputMentionTrigger() {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
46
|
+
<Stack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
|
|
47
47
|
<ChatComposer
|
|
48
48
|
onSubmit={() => setValue('')}
|
|
49
49
|
input={
|
|
@@ -54,7 +54,7 @@ export default function ChatComposerInputMultipleTriggers() {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
return (
|
|
57
|
-
<Stack direction="vertical" gap={3} style={{width:
|
|
57
|
+
<Stack direction="vertical" gap={3} style={{width: '100%', maxWidth: 450}}>
|
|
58
58
|
<Text type="supporting" color="secondary">
|
|
59
59
|
Type @ for mentions (blue) or / for commands (yellow)
|
|
60
60
|
</Text>
|
|
@@ -7,7 +7,7 @@ import {Stack} from '@astryxdesign/core/Layout';
|
|
|
7
7
|
|
|
8
8
|
export default function ChatComposerInputShowcase() {
|
|
9
9
|
return (
|
|
10
|
-
<Stack direction="vertical" style={{width:
|
|
10
|
+
<Stack direction="vertical" style={{width: '100%', maxWidth: 450}}>
|
|
11
11
|
<ChatComposer
|
|
12
12
|
onSubmit={() => {}}
|
|
13
13
|
input={
|
|
@@ -40,7 +40,7 @@ export default function ChatComposerInputSlashCommands() {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
|
-
<Stack direction="vertical" style={{width:
|
|
43
|
+
<Stack direction="vertical" style={{width: '100%', maxWidth: 450}}>
|
|
44
44
|
<ChatComposer
|
|
45
45
|
onSubmit={() => {}}
|
|
46
46
|
input={
|