@astryxdesign/cli 0.7.2-canary.db3a2e7 → 0.7.2-canary.e26723d
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/README.md +7 -7
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/component.test.mjs +420 -167
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/docs/_adapter.mjs +207 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/gap-report/gap-report.mjs +67 -4
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
- package/api/integration/pack-check.mjs +61 -107
- package/api/integration/pack-check.test.mjs +359 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/search/search.d.mts +9 -0
- package/api/search/search.mjs +108 -16
- package/api/search/search.test.mjs +36 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/template/template.test.mjs +120 -3
- package/api/theme/build/build.family.test.mjs +16 -0
- package/api/theme/build/build.mjs +81 -22
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +10 -0
- package/assets/docs/tree/check-the-props.doc.mjs +145 -0
- package/assets/docs/tree/checks.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +5 -1
- package/assets/docs/tree/component-imports.doc.mjs +8 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/single-component.doc.mjs +3 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +1 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +2 -1
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
- package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
- package/assets/templates/pages/detail-page/page.tsx +3 -3
- package/assets/templates/pages/table-inbox/page.tsx +10 -8
- package/assets/theme.template.ts +1 -1
- package/authoring/doctypes/base/type.ts +6 -0
- package/authoring/doctypes/component/component.doc.mjs +4 -4
- package/authoring/doctypes/component/type.ts +6 -3
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +8 -1
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
- package/clients/cli/commands/doctor-integration.test.mjs +392 -0
- package/clients/cli/commands/doctor.mjs +74 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/lib/component-format.mjs +5 -1
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +1 -0
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1224 -0
- package/foundation/discovery/doc-types.test.mjs +652 -0
- package/foundation/discovery/docs-discovery.d.mts +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +23 -0
- package/foundation/discovery/project-typescript.mjs +61 -0
- package/foundation/discovery/prop-drift.d.mts +220 -0
- package/foundation/discovery/prop-drift.mjs +1765 -0
- package/foundation/discovery/prop-drift.test.mjs +1197 -0
- package/foundation/discovery/template-adapter.mjs +74 -5
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +9 -1
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- package/foundation/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +10 -10
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* needs it: `Project` assembles templates from it. While this sat in api/, that
|
|
16
16
|
* made a cycle across the layer boundary — Project reached up for discovery and
|
|
17
17
|
* this module imported Project back. Nothing here depends on api/; every import
|
|
18
|
-
* is node:*, jiti, foundation/*, or authoring
|
|
18
|
+
* is node:*, jiti, foundation/*, or authoring/*, plus a lazily required
|
|
19
|
+
* @babel/parser for extractComponents' local-declaration scan.
|
|
19
20
|
*
|
|
20
21
|
* @position packages/cli/foundation/discovery — shared template discovery/IO;
|
|
21
22
|
* consumed by Project and by the api/template leaves.
|
|
@@ -512,6 +513,19 @@ function expressionUse(source, open, close) {
|
|
|
512
513
|
return null;
|
|
513
514
|
}
|
|
514
515
|
|
|
516
|
+
/** @type {typeof import('@babel/parser') | undefined} */
|
|
517
|
+
let babelParser;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* The template source parser, loaded on first use so listing templates
|
|
521
|
+
* never pays for it.
|
|
522
|
+
* @returns {typeof import('@babel/parser')}
|
|
523
|
+
*/
|
|
524
|
+
function templateSourceParser() {
|
|
525
|
+
babelParser ??= require('@babel/parser');
|
|
526
|
+
return /** @type {typeof import('@babel/parser')} */ (babelParser);
|
|
527
|
+
}
|
|
528
|
+
|
|
515
529
|
/**
|
|
516
530
|
* The [start, end) range of every comment in `source`, or none when it does
|
|
517
531
|
* not parse as TSX.
|
|
@@ -520,8 +534,7 @@ function expressionUse(source, open, close) {
|
|
|
520
534
|
*/
|
|
521
535
|
function commentRanges(source) {
|
|
522
536
|
try {
|
|
523
|
-
const {
|
|
524
|
-
const {comments} = parse(source, {
|
|
537
|
+
const {comments} = templateSourceParser().parse(source, {
|
|
525
538
|
sourceType: 'module',
|
|
526
539
|
plugins: ['jsx', 'typescript'],
|
|
527
540
|
});
|
|
@@ -1267,7 +1280,8 @@ export async function discoverIntegrationTemplatesForOne(integration) {
|
|
|
1267
1280
|
template: id,
|
|
1268
1281
|
message: `Template "${id}" is missing a "type" of "page" or "block". Stamp the default export with type: 'page' or type: 'block'.`,
|
|
1269
1282
|
});
|
|
1270
|
-
const declared =
|
|
1283
|
+
const declared =
|
|
1284
|
+
doc?.replaces ?? (await declaredReplacement(docPath, id));
|
|
1271
1285
|
if (declared != null) {
|
|
1272
1286
|
errors.push({
|
|
1273
1287
|
code: 'invalid_template_replacement',
|
|
@@ -1423,6 +1437,51 @@ const UBIQUITOUS = new Set([
|
|
|
1423
1437
|
'Icon',
|
|
1424
1438
|
]);
|
|
1425
1439
|
|
|
1440
|
+
/**
|
|
1441
|
+
* Names bound by top-level `function`, `class`, `const`, `let` or `var`
|
|
1442
|
+
* declarations (exported or not). Returns an empty set when the source does
|
|
1443
|
+
* not parse, so a parse failure never drops a real component.
|
|
1444
|
+
*
|
|
1445
|
+
* @param {string} src
|
|
1446
|
+
* @returns {Set<string>}
|
|
1447
|
+
*/
|
|
1448
|
+
function topLevelBindingNames(src) {
|
|
1449
|
+
/** @type {Set<string>} */
|
|
1450
|
+
const names = new Set();
|
|
1451
|
+
let program;
|
|
1452
|
+
try {
|
|
1453
|
+
program = templateSourceParser().parse(src, {
|
|
1454
|
+
sourceType: 'module',
|
|
1455
|
+
plugins: ['jsx', 'typescript'],
|
|
1456
|
+
errorRecovery: true,
|
|
1457
|
+
}).program;
|
|
1458
|
+
} catch {
|
|
1459
|
+
return names;
|
|
1460
|
+
}
|
|
1461
|
+
for (const statement of program.body) {
|
|
1462
|
+
const node =
|
|
1463
|
+
statement.type === 'ExportNamedDeclaration' ||
|
|
1464
|
+
statement.type === 'ExportDefaultDeclaration'
|
|
1465
|
+
? statement.declaration
|
|
1466
|
+
: statement;
|
|
1467
|
+
if (node == null) continue;
|
|
1468
|
+
if (
|
|
1469
|
+
(node.type === 'FunctionDeclaration' ||
|
|
1470
|
+
node.type === 'ClassDeclaration') &&
|
|
1471
|
+
node.id
|
|
1472
|
+
) {
|
|
1473
|
+
names.add(node.id.name);
|
|
1474
|
+
} else if (node.type === 'VariableDeclaration') {
|
|
1475
|
+
for (const declarator of node.declarations) {
|
|
1476
|
+
if (declarator.id.type === 'Identifier') {
|
|
1477
|
+
names.add(declarator.id.name);
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return names;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1426
1485
|
/**
|
|
1427
1486
|
* @param {string} pagePath
|
|
1428
1487
|
* @returns {string[]}
|
|
@@ -1449,14 +1508,24 @@ export function extractComponents(pagePath) {
|
|
|
1449
1508
|
while ((m = tagRegex.exec(src)) !== null) {
|
|
1450
1509
|
matches.push(m[2]);
|
|
1451
1510
|
}
|
|
1511
|
+
|
|
1512
|
+
// Exclude names bound by a top-level declaration in the same file: those are
|
|
1513
|
+
// page-local helpers (e.g. `function TimelineSection()`), not components a
|
|
1514
|
+
// builder can import. Read real bindings from the syntax tree so comments,
|
|
1515
|
+
// strings and type annotations cannot add or hide a name.
|
|
1516
|
+
const localDeclNames = topLevelBindingNames(src);
|
|
1517
|
+
|
|
1452
1518
|
return [
|
|
1453
1519
|
...new Set(
|
|
1454
1520
|
matches
|
|
1521
|
+
.filter(n => !localDeclNames.has(n))
|
|
1455
1522
|
.filter(n => !['Theme', 'ThemeProvider'].includes(n))
|
|
1456
1523
|
.filter(n => !UBIQUITOUS.has(n))
|
|
1457
1524
|
.map(n =>
|
|
1458
1525
|
n.replace(
|
|
1459
|
-
|
|
1526
|
+
// Strip only when a stem remains, so a bare `<Section>` keeps its
|
|
1527
|
+
// own name instead of emptying out.
|
|
1528
|
+
/(?<=.)(Item|Section|Header|Content|Footer|Panel|Heading|CollapseButton|Column|Sortable|Selection|Group|Source)$/,
|
|
1460
1529
|
'',
|
|
1461
1530
|
),
|
|
1462
1531
|
)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Judge a documented type. A doc may name an alias and spell out what it
|
|
6
|
+
* stands for, as `Name = expansion` or `Name (expansion)` (text that is not a
|
|
7
|
+
* type by itself): both parts are judged, and a mismatch in either is one;
|
|
8
|
+
* with one value after it (`Size = 'md'`, `Size = Size.Md`), or after a
|
|
9
|
+
* keyword, that part may be a default, and only the name is judged.
|
|
10
|
+
* @param {string} docType
|
|
11
|
+
* @param {any[]} codeTypes the prop's type in each member of the props type
|
|
12
|
+
* @param {JudgeContext} ctx
|
|
13
|
+
* @returns {TypeVerdict}
|
|
14
|
+
*/
|
|
15
|
+
export function judgeType(docType: string, codeTypes: any[], ctx: JudgeContext): TypeVerdict;
|
|
16
|
+
export type TypeVerdict = "match" | "mismatch" | "not_compared";
|
|
17
|
+
export type JudgeContext = {
|
|
18
|
+
ts: any;
|
|
19
|
+
checker: any;
|
|
20
|
+
/**
|
|
21
|
+
* where names in the documented type resolve (the
|
|
22
|
+
* prop's declaration, else the component's source file)
|
|
23
|
+
*/
|
|
24
|
+
location: any;
|
|
25
|
+
/**
|
|
26
|
+
* the prop is optional, so `undefined` is set
|
|
27
|
+
* aside on both sides
|
|
28
|
+
*/
|
|
29
|
+
optional: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* whether a source
|
|
32
|
+
* file is one of TypeScript's own libraries
|
|
33
|
+
*/
|
|
34
|
+
isDefaultLibrary?: ((file: any) => boolean) | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* the project checks without strict null
|
|
37
|
+
* checks, so the compiler drops `null` and `undefined` from every type and
|
|
38
|
+
* both are set aside on both sides
|
|
39
|
+
*/
|
|
40
|
+
nullable?: boolean | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* the project sets
|
|
43
|
+
* `exactOptionalPropertyTypes`: an optional prop takes `undefined` only when
|
|
44
|
+
* its type says so, and the compiler's mark for an absent prop is not a
|
|
45
|
+
* type the prop takes
|
|
46
|
+
*/
|
|
47
|
+
exactOptional?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* the code's type as the source writes it and
|
|
50
|
+
* as the compiler prints it, each a list of union members
|
|
51
|
+
*/
|
|
52
|
+
written: string[][];
|
|
53
|
+
};
|