@astryxdesign/cli 0.6.4-canary.06c8fa3 → 0.6.4-canary.0e1fbdb
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 +49 -40
- package/api/build/build.doc.mjs +6 -1
- package/api/build/build.test.mjs +22 -0
- package/api/build/kit/kit.mjs +44 -5
- package/api/component/component.doc.mjs +14 -7
- package/api/docs/_adapter.d.mts +8 -3
- package/api/docs/_adapter.mjs +14 -6
- package/api/docs/docOverlays.test.mjs +27 -1
- package/api/docs/docs.doc.mjs +2 -2
- package/api/doctor/doctor.doc.mjs +17 -8
- package/api/doctor/doctor.type.d.mts +1 -1
- package/api/doctor/doctor.type.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +19 -10
- package/api/hook/hook.doc.mjs +6 -3
- package/api/index.d.mts +2 -0
- package/api/index.mjs +3 -1
- package/api/init/init.doc.mjs +17 -12
- package/api/integration/add-theme.mjs +22 -1
- package/api/integration/add-theme.test.mjs +34 -0
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationPackCheck.doc.mjs +3 -3
- package/api/integration/pack-check.lifecycle-output.test.mjs +2 -0
- package/api/integration/pack-check.mjs +54 -6
- package/api/integration/pack-check.test.mjs +90 -0
- package/api/integration/pack-check.type.mjs +1 -1
- package/api/json/assertResponse.doc.mjs +1 -1
- package/api/json/index.ts +1 -0
- package/api/json/isError.doc.mjs +1 -1
- package/api/layout/_adapter.d.mts +34 -0
- package/api/layout/_adapter.mjs +148 -0
- package/api/layout/check/check.d.mts +16 -0
- package/api/layout/check/check.mjs +40 -0
- package/api/layout/expand/expand.d.mts +22 -0
- package/api/layout/expand/expand.mjs +155 -0
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.d.mts +13 -0
- package/api/layout/grammar/grammar.mjs +87 -0
- package/api/layout/layout.d.mts +6 -0
- package/api/layout/layout.mjs +17 -0
- package/api/layout/layout.test.mjs +297 -0
- package/api/layout/layout.type.d.mts +89 -0
- package/api/layout/layout.type.mjs +103 -0
- package/api/layout/layoutCheck.doc.d.mts +11 -0
- package/api/layout/layoutCheck.doc.mjs +85 -0
- package/api/layout/layoutExpand.doc.d.mts +11 -0
- package/api/layout/layoutExpand.doc.mjs +107 -0
- package/api/layout/layoutGrammar.doc.d.mts +11 -0
- package/api/layout/layoutGrammar.doc.mjs +57 -0
- package/api/search/search.d.mts +27 -1
- package/api/search/search.doc.mjs +2 -2
- package/api/search/search.mjs +228 -16
- package/api/swizzle/swizzle.doc.mjs +7 -5
- package/api/template/copy/copy.mjs +1 -1
- package/api/template/copy/copy.test.mjs +9 -0
- package/api/template/template-integration.test.mjs +65 -1
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.mjs +1 -1
- package/api/theme/generateTonalPalette.doc.mjs +1 -2
- package/api/theme/listThemes.doc.mjs +1 -1
- package/api/theme/themeAdd.doc.mjs +9 -10
- package/api/theme/themeBuild.doc.mjs +13 -13
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +2 -1
- package/api/theme/themePaletteGenerate.doc.mjs +15 -8
- package/api/theme/themeTargets.doc.mjs +3 -2
- package/api/theme/themeTemplate.doc.mjs +2 -1
- package/api/upgrade/run/run.mjs +1 -1
- package/api/upgrade/upgrade.doc.mjs +24 -22
- package/assets/docs/README.md +4 -2
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +8 -2
- package/assets/docs/elevation.doc.mjs +6 -4
- package/assets/docs/getting-started.doc.mjs +5 -16
- package/assets/docs/icons.doc.mjs +2 -21
- package/assets/docs/illustrations.doc.mjs +7 -15
- package/assets/docs/layout.doc.dense.mjs +130 -82
- package/assets/docs/layout.doc.mjs +133 -77
- package/assets/docs/migration.doc.mjs +19 -21
- package/assets/docs/motion.doc.mjs +16 -3
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +8 -0
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +8 -3
- package/assets/docs/spacing.doc.mjs +7 -2
- package/assets/docs/styling-libraries.doc.mjs +6 -2
- package/assets/docs/styling.doc.mjs +19 -23
- package/assets/docs/theme.doc.dense.mjs +58 -18
- package/assets/docs/theme.doc.mjs +56 -46
- package/assets/docs/theme.doc.zh.mjs +9 -8
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +389 -8
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +75 -0
- package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
- package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
- package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
- package/assets/docs/tree/block-template.doc.mjs +130 -0
- package/assets/docs/tree/build-the-template.doc.mjs +28 -0
- package/assets/docs/tree/building-blocks.doc.mjs +46 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
- package/assets/docs/tree/checks.doc.mjs +119 -0
- package/assets/docs/tree/codemods.doc.mjs +147 -0
- package/assets/docs/tree/component-family.doc.mjs +113 -0
- package/assets/docs/tree/component-imports.doc.mjs +69 -0
- package/assets/docs/tree/components.doc.mjs +23 -0
- package/assets/docs/tree/configuration.doc.mjs +23 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
- package/assets/docs/tree/docs.doc.mjs +21 -0
- package/assets/docs/tree/document-the-template.doc.mjs +28 -0
- package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
- package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
- package/assets/docs/tree/help.doc.mjs +16 -0
- package/assets/docs/tree/integrations.doc.mjs +25 -470
- package/assets/docs/tree/links.doc.mjs +98 -0
- package/assets/docs/tree/package-and-test.doc.mjs +32 -0
- package/assets/docs/tree/page-template.doc.mjs +71 -0
- package/assets/docs/tree/publishing.doc.mjs +111 -0
- package/assets/docs/tree/quick-start.doc.mjs +272 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
- package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
- package/assets/docs/tree/ship.doc.mjs +16 -0
- package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
- package/assets/docs/tree/single-component.doc.mjs +165 -0
- package/assets/docs/tree/start-a-template.doc.mjs +143 -0
- package/assets/docs/tree/subcomponent.doc.mjs +115 -0
- package/assets/docs/tree/template-assets.doc.mjs +64 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
- package/assets/docs/tree/template-fonts.doc.mjs +102 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
- package/assets/docs/tree/template-icons.doc.mjs +97 -0
- package/assets/docs/tree/template-images-media.doc.mjs +127 -0
- package/assets/docs/tree/template-styles.doc.mjs +93 -0
- package/assets/docs/tree/templates.doc.mjs +34 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
- package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
- package/assets/docs/tree/themes.doc.mjs +39 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
- package/assets/docs/tree/upgrading.doc.mjs +103 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
- package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
- package/assets/docs/tree/versioning.doc.mjs +161 -0
- package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
- package/assets/docs/typography.doc.mjs +24 -4
- package/assets/docs/working-with-ai.doc.mjs +30 -22
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/type.ts +2 -2
- package/authoring/doctypes/_schema.d.mts +3 -2
- package/authoring/doctypes/_schema.mjs +6 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
- package/authoring/doctypes/base/type.ts +4 -2
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/reference/reference.doc.mjs +7 -0
- package/authoring/doctypes/reference/type.ts +5 -0
- package/authoring/doctypes/schema/schema.doc.mjs +2 -2
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -2
- package/authoring/integration/integration.doc.mjs +12 -10
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component.doc.mjs +4 -3
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +60 -17
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration.test.mjs +53 -0
- package/clients/cli/commands/doctor.doc.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +49 -5
- package/clients/cli/commands/gap-report.doc.mjs +10 -9
- package/clients/cli/commands/init.doc.mjs +9 -6
- package/clients/cli/commands/integration-add.doc.mjs +9 -9
- package/clients/cli/commands/integration-authoring.test.mjs +61 -10
- package/clients/cli/commands/integration-pack.doc.mjs +5 -9
- package/clients/cli/commands/integration-real-world.test.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +22 -0
- package/clients/cli/commands/integration.doc.mjs +4 -4
- package/clients/cli/commands/integration.mjs +74 -43
- package/clients/cli/commands/layout-check.doc.mjs +65 -0
- package/clients/cli/commands/layout-expand.doc.mjs +83 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
- package/clients/cli/commands/layout.doc.mjs +34 -0
- package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
- package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
- package/clients/cli/commands/layout.mjs +275 -0
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +10 -3
- package/clients/cli/commands/search.mjs +21 -2
- package/clients/cli/commands/search.test.mjs +21 -4
- package/clients/cli/commands/swizzle.doc.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +24 -1
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-palette.doc.mjs +1 -2
- package/clients/cli/commands/theme-targets.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +2 -1
- package/clients/cli/commands/upgrade.doc.mjs +62 -3
- package/clients/cli/index.mjs +32 -6
- package/clients/cli/lib/define-command.mjs +28 -4
- package/clients/cli/lib/define-command.test.mjs +54 -0
- package/clients/cli/lib/exit-codes.test.mjs +25 -2
- package/clients/cli/lib/json-shim.test.mjs +20 -6
- package/clients/cli/lib/manifest.mjs +23 -5
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/discovery/authoring-self-docs.test.mjs +6 -2
- package/foundation/discovery/cli-self-docs.mjs +16 -2
- package/foundation/discovery/cli-self-docs.test.mjs +20 -0
- package/foundation/discovery/docs-discovery.mjs +5 -1
- package/foundation/discovery/docs-discovery.test.mjs +21 -0
- package/foundation/discovery/docs-section-key.d.mts +1 -1
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -2
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/tree.d.mts +4 -0
- package/foundation/doc-compiler/tree.mjs +6 -1
- package/foundation/integrations/cli-requirement.d.mts +26 -6
- package/foundation/integrations/cli-requirement.mjs +46 -11
- package/foundation/integrations/cli-requirement.test.mjs +7 -2
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/response/error-codes.doc.mjs +6 -8
- package/foundation/response/error-codes.test.mjs +30 -5
- package/foundation/response/response-types.doc.d.mts +4 -3
- package/foundation/response/response-types.doc.mjs +42 -6
- package/foundation/response/response.doc.mjs +11 -10
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.mjs +1 -1
- package/package.json +9 -9
- package/api/docs/docs.test.mjs +0 -245
- package/api/docs/integration-tree.test.mjs +0 -555
- package/api/docs/integrationDocs.test.mjs +0 -314
- package/api/search/search.test.mjs +0 -530
- package/assets/docs/tree/integrations.test.mjs +0 -62
- package/assets/docs/tree/writing-docs.doc.mjs +0 -286
- package/clients/cli/commands/docs.test.mjs +0 -323
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1159
- package/foundation/doc-compiler/tree.test.mjs +0 -606
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Integration tests for the layout API against the real @astryxdesign/core
|
|
5
|
+
* registry and real template blocks. Every expansion is additionally
|
|
6
|
+
* checked for TSX syntactic validity with the TypeScript parser, so the
|
|
7
|
+
* "expansion emits compilable JSX" contract is enforced, not assumed.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {describe, it, expect, beforeAll} from 'vitest';
|
|
11
|
+
import {mkdtempSync, writeFileSync, rmSync} from 'node:fs';
|
|
12
|
+
import {tmpdir} from 'node:os';
|
|
13
|
+
import {join} from 'node:path';
|
|
14
|
+
import ts from 'typescript';
|
|
15
|
+
import {layoutExpand, layoutCheck, layoutGrammar} from './layout.mjs';
|
|
16
|
+
import {buildRegistry} from '../../foundation/xle/registry.mjs';
|
|
17
|
+
|
|
18
|
+
// The registry imports ~140 .doc.mjs modules on first use; under full-suite
|
|
19
|
+
// parallel load that can exceed the default 5s test timeout. Warm it once.
|
|
20
|
+
beforeAll(async () => {
|
|
21
|
+
await buildRegistry();
|
|
22
|
+
}, 120_000);
|
|
23
|
+
|
|
24
|
+
const SLOW = 30_000;
|
|
25
|
+
|
|
26
|
+
/** Assert TSX parses cleanly; returns the source file for inspection. */
|
|
27
|
+
function expectValidTsx(code) {
|
|
28
|
+
const sourceFile = ts.createSourceFile('generated.tsx', code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
|
|
29
|
+
const diagnostics = sourceFile.parseDiagnostics || [];
|
|
30
|
+
const messages = diagnostics.map(d => ts.flattenDiagnosticMessageText(d.messageText, ' '));
|
|
31
|
+
expect(messages).toEqual([]);
|
|
32
|
+
return sourceFile;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const LOGIN_COMPACT =
|
|
36
|
+
'Ctr[h="100dvh"] > C[w=400 p8] > V[g6] > ' +
|
|
37
|
+
'(V[g1] > Tx"Welcome back" + Tx[t=supporting]"Sign in to your account") + ' +
|
|
38
|
+
'(F > TI"Email"[t=email req] + TI"Password"[t=password req]) + ' +
|
|
39
|
+
'(H[j=between a=center] > CB"Remember me" + Lk[href="/forgot"]"Forgot password?") + ' +
|
|
40
|
+
'B.primary"Sign in"';
|
|
41
|
+
|
|
42
|
+
const CHAT_OUTLINE = `
|
|
43
|
+
AppShell
|
|
44
|
+
topNav: TN
|
|
45
|
+
Layout > LC !scroll
|
|
46
|
+
ChL
|
|
47
|
+
composer:
|
|
48
|
+
ChC
|
|
49
|
+
ChML
|
|
50
|
+
ChS "Today"
|
|
51
|
+
repeat 2:
|
|
52
|
+
ChM
|
|
53
|
+
ChB "Reply $"
|
|
54
|
+
Tbar "Actions"
|
|
55
|
+
B "Delete" opens=#confirm
|
|
56
|
+
|
|
57
|
+
overlays:
|
|
58
|
+
AD#confirm "Delete item?"
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const DASHBOARD_COMPACT =
|
|
62
|
+
'A[@topNav=TN @sideNav=SN] > L > V[g6] > ' +
|
|
63
|
+
'(G[c4 g4] > C{card-callout}*4) + ' +
|
|
64
|
+
'(C[p0] > T[striped] > (TR > THC"Name" + THC"Amount") + (TR > TC"Order $" + TC"\\$12.00")*3)';
|
|
65
|
+
|
|
66
|
+
describe('layoutExpand', () => {
|
|
67
|
+
it('expands the login card with typed state scaffolds', async () => {
|
|
68
|
+
const result = await layoutExpand(LOGIN_COMPACT);
|
|
69
|
+
expect(result.type).toBe('layout.expand');
|
|
70
|
+
const {code} = result.data;
|
|
71
|
+
expectValidTsx(code);
|
|
72
|
+
|
|
73
|
+
expect(code).toContain(`const [email, setEmail] = useState('');`);
|
|
74
|
+
expect(code).toContain(`const [rememberMe, setRememberMe] = useState(false);`);
|
|
75
|
+
expect(code).toContain('<XDSCenter height="100dvh">');
|
|
76
|
+
expect(code).toContain('variant="primary"');
|
|
77
|
+
// axis-neutral j/a resolved onto the HStack's real props
|
|
78
|
+
expect(code).toContain('hAlign="between"');
|
|
79
|
+
expect(code).toContain('vAlign="center"');
|
|
80
|
+
// payload routed to label props, not duplicated as children
|
|
81
|
+
expect(code).not.toMatch(/label="Forgot password\?"[\s\S]{0,80}Forgot password\?/);
|
|
82
|
+
}, SLOW);
|
|
83
|
+
|
|
84
|
+
it('expands the outline chat page: slots, repeat blocks, overlays, triggers', async () => {
|
|
85
|
+
const result = await layoutExpand(CHAT_OUTLINE);
|
|
86
|
+
const {code, form} = result.data;
|
|
87
|
+
expect(form).toBe('outline');
|
|
88
|
+
expectValidTsx(code);
|
|
89
|
+
|
|
90
|
+
expect(code).toContain('composer={');
|
|
91
|
+
// slot satisfied required prop — no double assignment, no TODO for it
|
|
92
|
+
expect(code.match(/composer=/g)).toHaveLength(1);
|
|
93
|
+
expect(code).toContain('TODO(xle): open #confirm');
|
|
94
|
+
expect(code).toContain('overlays — wire open state');
|
|
95
|
+
expect((code.match(/<XDSChatMessage\b/g) || [])).toHaveLength(2);
|
|
96
|
+
}, SLOW);
|
|
97
|
+
|
|
98
|
+
it('expands the dashboard: table partition, repeats with $ counter and \\$ escape', async () => {
|
|
99
|
+
const result = await layoutExpand(DASHBOARD_COMPACT);
|
|
100
|
+
const {code} = result.data;
|
|
101
|
+
expectValidTsx(code);
|
|
102
|
+
|
|
103
|
+
expect(code).toContain('<XDSTableHeader>');
|
|
104
|
+
expect(code).toContain('<XDSTableBody>');
|
|
105
|
+
expect(code).toContain('Order 1');
|
|
106
|
+
expect(code).toContain('Order 3');
|
|
107
|
+
expect(code).toContain('$12.00');
|
|
108
|
+
expect(code).not.toContain('112.00');
|
|
109
|
+
// {card-callout} now splices: the block is co-defined once and referenced
|
|
110
|
+
// four times — no TODO marker.
|
|
111
|
+
expect((code.match(/^function CardCallout\(\)/gm) || [])).toHaveLength(1);
|
|
112
|
+
expect((code.match(/<CardCallout \/>/g) || [])).toHaveLength(4);
|
|
113
|
+
expect(code).not.toContain("TODO(xle): content block 'CardCallout'");
|
|
114
|
+
}, SLOW);
|
|
115
|
+
|
|
116
|
+
it('compact and outline surfaces expand to identical TSX', async () => {
|
|
117
|
+
const check = await layoutCheck(LOGIN_COMPACT);
|
|
118
|
+
const fromCompact = await layoutExpand(LOGIN_COMPACT);
|
|
119
|
+
const fromOutline = await layoutExpand(check.data.outline, {form: 'outline'});
|
|
120
|
+
expect(fromOutline.data.code).toEqual(fromCompact.data.code);
|
|
121
|
+
}, SLOW);
|
|
122
|
+
|
|
123
|
+
it('expansion is deterministic', async () => {
|
|
124
|
+
const a = await layoutExpand(DASHBOARD_COMPACT);
|
|
125
|
+
const b = await layoutExpand(DASHBOARD_COMPACT);
|
|
126
|
+
expect(a.data.code).toEqual(b.data.code);
|
|
127
|
+
}, SLOW);
|
|
128
|
+
|
|
129
|
+
it('throws structured errors with suggestions on invalid expressions', async () => {
|
|
130
|
+
await expect(layoutExpand('A[p6] > Grdi')).rejects.toMatchObject({
|
|
131
|
+
code: 'ERR_LAYOUT_INVALID',
|
|
132
|
+
message: expect.stringMatching(/AppShell has no prop 'padding'/),
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('rejects non-PascalCase --name', async () => {
|
|
137
|
+
await expect(layoutExpand('V > C', {name: 'not pascal'})).rejects.toMatchObject({
|
|
138
|
+
code: 'ERR_INVALID_ARGUMENT',
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('surfaces parse errors with positions', async () => {
|
|
143
|
+
await expect(layoutExpand('V > > C')).rejects.toMatchObject({
|
|
144
|
+
code: 'ERR_LAYOUT_PARSE',
|
|
145
|
+
message: expect.stringMatching(/line 1/),
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('maps pathologically deep nesting to a coded parse error, not ERR_UNKNOWN', async () => {
|
|
150
|
+
await expect(layoutCheck('V > '.repeat(2000) + 'C')).rejects.toMatchObject({
|
|
151
|
+
code: 'ERR_LAYOUT_PARSE',
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('wraps top-level repeats and groups in a fragment (valid JSX)', async () => {
|
|
156
|
+
for (const expr of ['B"Sign in"*3', '(B"a" + B"b")', '(B"a" + B"b")*2']) {
|
|
157
|
+
const {data} = await layoutExpand(expr);
|
|
158
|
+
expectValidTsx(data.code);
|
|
159
|
+
expect(data.code).toContain('<>');
|
|
160
|
+
}
|
|
161
|
+
}, SLOW);
|
|
162
|
+
|
|
163
|
+
it('wraps a top-level outline repeat block in a fragment', async () => {
|
|
164
|
+
const {data} = await layoutExpand('repeat 3:\n B "x"', {form: 'outline'});
|
|
165
|
+
expectValidTsx(data.code);
|
|
166
|
+
}, SLOW);
|
|
167
|
+
|
|
168
|
+
it('emits JSX-safe TSX for text payloads containing < and >', async () => {
|
|
169
|
+
const result = await layoutExpand('Text"5 < 3 and 3 > 1"');
|
|
170
|
+
expectValidTsx(result.data.code);
|
|
171
|
+
}, SLOW);
|
|
172
|
+
|
|
173
|
+
it('emits JSX-safe TSX for text payloads containing { and }', async () => {
|
|
174
|
+
const result = await layoutExpand('Text"cost is {price}"');
|
|
175
|
+
expectValidTsx(result.data.code);
|
|
176
|
+
}, SLOW);
|
|
177
|
+
|
|
178
|
+
it('emits JSX-safe TSX when a text payload looks like a closing tag', async () => {
|
|
179
|
+
const result = await layoutExpand('Text"end</Text><img/>"');
|
|
180
|
+
expectValidTsx(result.data.code);
|
|
181
|
+
}, SLOW);
|
|
182
|
+
|
|
183
|
+
it('emits JSX-safe TSX for JSX-special chars in outline form', async () => {
|
|
184
|
+
const result = await layoutExpand('VStack\n Text "a < b"', {form: 'outline'});
|
|
185
|
+
expectValidTsx(result.data.code);
|
|
186
|
+
}, SLOW);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('layoutCheck', () => {
|
|
190
|
+
it('returns both canonical surfaces for valid input', async () => {
|
|
191
|
+
const result = await layoutCheck('V[g6] > C{card-callout}*2');
|
|
192
|
+
expect(result.data.valid).toBe(true);
|
|
193
|
+
expect(result.data.compact).toContain('{card-callout}');
|
|
194
|
+
expect(result.data.outline).toContain('C {card-callout} x2');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it('collects all errors instead of stopping at the first', async () => {
|
|
198
|
+
const result = await layoutCheck('A[p6] > V[g7] > Bd.sucess"x" + C{not-a-block}');
|
|
199
|
+
expect(result.data.valid).toBe(false);
|
|
200
|
+
expect(result.data.errors.length).toBeGreaterThanOrEqual(4);
|
|
201
|
+
const all = result.data.errors.map(e => e.message).join('\n');
|
|
202
|
+
expect(all).toMatch(/no prop 'padding'/);
|
|
203
|
+
expect(all).toMatch(/must be one of/);
|
|
204
|
+
expect(all).toMatch(/Unknown block/);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('template referencing', () => {
|
|
209
|
+
it('splices a template block: co-defined once, referenced, imports merged', async () => {
|
|
210
|
+
const result = await layoutExpand('S[p6] > C{card-callout}*3', {name: 'Demo'});
|
|
211
|
+
const {code} = result.data;
|
|
212
|
+
expectValidTsx(code);
|
|
213
|
+
// co-defined exactly once, referenced three times, no TODO
|
|
214
|
+
expect((code.match(/^function CardCallout\(\)/gm) || [])).toHaveLength(1);
|
|
215
|
+
expect((code.match(/<CardCallout \/>/g) || [])).toHaveLength(3);
|
|
216
|
+
expect(code).not.toContain('TODO(xle)');
|
|
217
|
+
// the block's own import is hoisted, and shared specifiers dedupe
|
|
218
|
+
expect((code.match(/from '@astryxdesign\/core\/Card'/g) || [])).toHaveLength(1);
|
|
219
|
+
// the block lost its export — it's a local declaration now
|
|
220
|
+
expect(code).not.toContain('export default function CardCallout');
|
|
221
|
+
expect(result.data.blocksReferenced).toEqual([{name: 'CardCallout', mode: 'splice'}]);
|
|
222
|
+
}, SLOW);
|
|
223
|
+
|
|
224
|
+
it('merges a stateful block useState into a single react import', async () => {
|
|
225
|
+
const result = await layoutExpand(
|
|
226
|
+
'V > TI"Search"[t=text] + {table-column-settings-table}',
|
|
227
|
+
{name: 'Demo'},
|
|
228
|
+
);
|
|
229
|
+
const {code} = result.data;
|
|
230
|
+
expectValidTsx(code);
|
|
231
|
+
// page TextInput scaffolds useState; block also uses useState → one import
|
|
232
|
+
expect((code.match(/^import \{useState\} from 'react';$/gm) || [])).toHaveLength(1);
|
|
233
|
+
expect(code).toContain('function TableColumnSettingsTable()');
|
|
234
|
+
}, SLOW);
|
|
235
|
+
|
|
236
|
+
it('imports app-registered local components (the local-component bridge)', async () => {
|
|
237
|
+
// Inside the workspace so @astryxdesign/core resolves; cleaned up after.
|
|
238
|
+
// A package.json beside the config makes Project.load resolve it as the
|
|
239
|
+
// sibling-of-nearest-package.json (the standard config resolution).
|
|
240
|
+
const cwd = mkdtempSync(join(process.cwd(), '.xle-imp-test-'));
|
|
241
|
+
try {
|
|
242
|
+
writeFileSync(join(cwd, 'package.json'), '{"name": "xle-imp-fixture"}\n');
|
|
243
|
+
writeFileSync(
|
|
244
|
+
join(cwd, 'astryx.config.mjs'),
|
|
245
|
+
`export default {experimental: {xle: {components: {KpiCard: {from: '@/components/KpiCard'}, TimeRangePicker: {from: '@/components/TimeRangePicker'}}}}};\n`,
|
|
246
|
+
);
|
|
247
|
+
const result = await layoutExpand('S[p6] > (G[c4 g4] > {kpi-card}*4) + {time-range-picker}', {
|
|
248
|
+
name: 'Demo',
|
|
249
|
+
cwd,
|
|
250
|
+
});
|
|
251
|
+
const {code} = result.data;
|
|
252
|
+
expectValidTsx(code);
|
|
253
|
+
expect(code).toContain("import {KpiCard} from '@/components/KpiCard';");
|
|
254
|
+
expect(code).toContain("import {TimeRangePicker} from '@/components/TimeRangePicker';");
|
|
255
|
+
expect((code.match(/<KpiCard \/>/g) || [])).toHaveLength(4);
|
|
256
|
+
expect(code).toContain('<TimeRangePicker />');
|
|
257
|
+
expect(result.data.blocksReferenced).toContainEqual({name: 'KpiCard', mode: 'import'});
|
|
258
|
+
} finally {
|
|
259
|
+
rmSync(cwd, {recursive: true, force: true});
|
|
260
|
+
}
|
|
261
|
+
}, SLOW);
|
|
262
|
+
|
|
263
|
+
it('parses a standalone {block} in both surfaces', async () => {
|
|
264
|
+
const check = await layoutCheck('G[c4 g4] > {card-callout}*2');
|
|
265
|
+
expect(check.data.valid).toBe(true);
|
|
266
|
+
expect(check.data.compact).toContain('{card-callout}*2');
|
|
267
|
+
expect(check.data.outline).toMatch(/\{card-callout\} x2/);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
describe('layoutGrammar', () => {
|
|
272
|
+
it('emits the cheatsheet with branch-generated aliases', async () => {
|
|
273
|
+
const result = await layoutGrammar();
|
|
274
|
+
expect(result.data.text).toContain('TWO SURFACES');
|
|
275
|
+
expect(result.data.aliases.V).toBe('VStack');
|
|
276
|
+
expect(result.data.aliases.TB).toBe('TableBody');
|
|
277
|
+
// every alias target must exist — the table is registry-filtered
|
|
278
|
+
expect(Object.values(result.data.aliases)).not.toContain(undefined);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
describe('layout — input validation (API matches CLI)', () => {
|
|
284
|
+
it('rejects an invalid --form value instead of silently parsing as compact', async () => {
|
|
285
|
+
await expect(layoutCheck('V > C', {form: /** @type {any} */ ('xml')})).rejects.toMatchObject({
|
|
286
|
+
code: 'ERR_INVALID_OPTION',
|
|
287
|
+
});
|
|
288
|
+
await expect(layoutExpand('V > C', {form: /** @type {any} */ ('nonsense')})).rejects.toMatchObject({
|
|
289
|
+
code: 'ERR_INVALID_OPTION',
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('rejects an empty expression at the API layer', async () => {
|
|
294
|
+
await expect(layoutCheck('')).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
295
|
+
await expect(layoutExpand(' ')).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
296
|
+
});
|
|
297
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The input surface an expression was parsed as.
|
|
6
|
+
*/
|
|
7
|
+
export type LayoutForm = "compact" | "outline" | "auto";
|
|
8
|
+
/**
|
|
9
|
+
* A validation issue with its formatted, human-readable rendering.
|
|
10
|
+
*/
|
|
11
|
+
export type LayoutIssue = {
|
|
12
|
+
line?: number | undefined;
|
|
13
|
+
col?: number | undefined;
|
|
14
|
+
message: string;
|
|
15
|
+
formatted: string;
|
|
16
|
+
suggestions?: string[] | undefined;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A block referenced by a layout expression and how it was spliced in.
|
|
20
|
+
*/
|
|
21
|
+
export type LayoutBlockReference = {
|
|
22
|
+
name: string;
|
|
23
|
+
mode: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* astryx --json layout expand "<expr>" [path]
|
|
27
|
+
*/
|
|
28
|
+
export type LayoutExpandResponse = {
|
|
29
|
+
type: "layout.expand";
|
|
30
|
+
data: {
|
|
31
|
+
form: LayoutForm;
|
|
32
|
+
code: string;
|
|
33
|
+
componentsUsed: string[];
|
|
34
|
+
states: number;
|
|
35
|
+
todos: string[];
|
|
36
|
+
blocksReferenced: LayoutBlockReference[];
|
|
37
|
+
warnings: string[];
|
|
38
|
+
written: string | null;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* astryx --json layout check "<expr>"
|
|
43
|
+
*/
|
|
44
|
+
export type LayoutCheckResponse = {
|
|
45
|
+
type: "layout.check";
|
|
46
|
+
data: {
|
|
47
|
+
valid: boolean;
|
|
48
|
+
form: LayoutForm;
|
|
49
|
+
errors: LayoutIssue[];
|
|
50
|
+
warnings: string[];
|
|
51
|
+
compact: string;
|
|
52
|
+
outline: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* astryx --json layout grammar
|
|
57
|
+
*/
|
|
58
|
+
export type LayoutGrammarResponse = {
|
|
59
|
+
type: "layout.grammar";
|
|
60
|
+
data: {
|
|
61
|
+
text: string;
|
|
62
|
+
aliases: Record<string, string>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type LayoutResponse = LayoutExpandResponse | LayoutCheckResponse | LayoutGrammarResponse;
|
|
66
|
+
/**
|
|
67
|
+
* Options for `layoutExpand()`.
|
|
68
|
+
*/
|
|
69
|
+
export type LayoutExpandOptions = {
|
|
70
|
+
targetPath?: string | undefined;
|
|
71
|
+
form?: LayoutForm | undefined;
|
|
72
|
+
loose?: boolean | undefined;
|
|
73
|
+
name?: string | undefined;
|
|
74
|
+
cwd?: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Options for `layoutCheck()`.
|
|
78
|
+
*/
|
|
79
|
+
export type LayoutCheckOptions = {
|
|
80
|
+
form?: LayoutForm | undefined;
|
|
81
|
+
loose?: boolean | undefined;
|
|
82
|
+
cwd?: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Options for `layoutGrammar()`.
|
|
86
|
+
*/
|
|
87
|
+
export type LayoutGrammarOptions = {
|
|
88
|
+
cwd?: string | undefined;
|
|
89
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Colocated types for the `layout` command — source of truth for its JSON
|
|
5
|
+
* responses. `astryx layout expand|check|grammar` turn compressed XLE/XLO
|
|
6
|
+
* expressions into validated XDS TSX (or echo canonical surfaces / a grammar
|
|
7
|
+
* cheatsheet). The `types/layout.d.ts` barrel re-exports from here.
|
|
8
|
+
*
|
|
9
|
+
* Invocation -> type discriminator
|
|
10
|
+
* -----------------------------------------------------------------
|
|
11
|
+
* astryx --json layout expand "<expr>" -> layout.expand
|
|
12
|
+
* astryx --json layout check "<expr>" -> layout.check
|
|
13
|
+
* astryx --json layout grammar -> layout.grammar
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The input surface an expression was parsed as.
|
|
18
|
+
* @typedef {'compact' | 'outline' | 'auto'} LayoutForm
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A validation issue with its formatted, human-readable rendering.
|
|
23
|
+
* @typedef {object} LayoutIssue
|
|
24
|
+
* @property {number} [line]
|
|
25
|
+
* @property {number} [col]
|
|
26
|
+
* @property {string} message
|
|
27
|
+
* @property {string} formatted
|
|
28
|
+
* @property {string[]} [suggestions]
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A block referenced by a layout expression and how it was spliced in.
|
|
33
|
+
* @typedef {object} LayoutBlockReference
|
|
34
|
+
* @property {string} name
|
|
35
|
+
* @property {string} mode
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* astryx --json layout expand "<expr>" [path]
|
|
40
|
+
* @typedef {object} LayoutExpandResponse
|
|
41
|
+
* @property {'layout.expand'} type
|
|
42
|
+
* @property {object} data
|
|
43
|
+
* @property {LayoutForm} data.form
|
|
44
|
+
* @property {string} data.code
|
|
45
|
+
* @property {string[]} data.componentsUsed
|
|
46
|
+
* @property {number} data.states Number of useState hooks the expansion scaffolded.
|
|
47
|
+
* @property {string[]} data.todos
|
|
48
|
+
* @property {LayoutBlockReference[]} data.blocksReferenced
|
|
49
|
+
* @property {string[]} data.warnings
|
|
50
|
+
* @property {string | null} data.written
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* astryx --json layout check "<expr>"
|
|
55
|
+
* @typedef {object} LayoutCheckResponse
|
|
56
|
+
* @property {'layout.check'} type
|
|
57
|
+
* @property {object} data
|
|
58
|
+
* @property {boolean} data.valid
|
|
59
|
+
* @property {LayoutForm} data.form
|
|
60
|
+
* @property {LayoutIssue[]} data.errors
|
|
61
|
+
* @property {string[]} data.warnings
|
|
62
|
+
* @property {string} data.compact
|
|
63
|
+
* @property {string} data.outline
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* astryx --json layout grammar
|
|
68
|
+
* @typedef {object} LayoutGrammarResponse
|
|
69
|
+
* @property {'layout.grammar'} type
|
|
70
|
+
* @property {object} data
|
|
71
|
+
* @property {string} data.text
|
|
72
|
+
* @property {Record<string, string>} data.aliases Alias table (short name -> canonical component), from the registry.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {LayoutExpandResponse | LayoutCheckResponse | LayoutGrammarResponse} LayoutResponse
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Options for `layoutExpand()`.
|
|
81
|
+
* @typedef {object} LayoutExpandOptions
|
|
82
|
+
* @property {string} [targetPath]
|
|
83
|
+
* @property {LayoutForm} [form]
|
|
84
|
+
* @property {boolean} [loose]
|
|
85
|
+
* @property {string} [name]
|
|
86
|
+
* @property {string} [cwd]
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Options for `layoutCheck()`.
|
|
91
|
+
* @typedef {object} LayoutCheckOptions
|
|
92
|
+
* @property {LayoutForm} [form]
|
|
93
|
+
* @property {boolean} [loose]
|
|
94
|
+
* @property {string} [cwd]
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Options for `layoutGrammar()`.
|
|
99
|
+
* @typedef {object} LayoutGrammarOptions
|
|
100
|
+
* @property {string} [cwd]
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file FunctionDoc for `layoutCheck()` / `astryx layout check`. Colocated with
|
|
6
|
+
* the API function it documents; the response-shape source of truth stays in
|
|
7
|
+
* `layout.type.mjs`.
|
|
8
|
+
* @position packages/cli/api/layout — function documentation
|
|
9
|
+
*/
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
+
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file FunctionDoc for `layoutCheck()` / `astryx layout check`. Colocated with
|
|
5
|
+
* the API function it documents; the response-shape source of truth stays in
|
|
6
|
+
* `layout.type.mjs`.
|
|
7
|
+
* @position packages/cli/api/layout — function documentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
+
export const doc = {
|
|
12
|
+
type: 'function',
|
|
13
|
+
kind: 'api',
|
|
14
|
+
name: 'layoutCheck',
|
|
15
|
+
namespace: 'cli/api',
|
|
16
|
+
displayName: 'layoutCheck()',
|
|
17
|
+
summary: 'Validate a layout expression without expanding it.',
|
|
18
|
+
description:
|
|
19
|
+
'The validator behind `astryx layout check`. Parses and validates a compressed XLE/XLO ' +
|
|
20
|
+
'expression without generating any TSX, and echoes it back in both canonical surfaces ' +
|
|
21
|
+
'(compact and outline). Validation failures are reported in the layout.check envelope ' +
|
|
22
|
+
'(valid: false) with line/col and suggestions (not thrown) so callers can lint an ' +
|
|
23
|
+
'expression and surface fixes.',
|
|
24
|
+
importPath: '@astryxdesign/cli/api',
|
|
25
|
+
signature:
|
|
26
|
+
'layoutCheck(expression: string, options?: LayoutCheckOptions): Promise<LayoutCheckResponse>',
|
|
27
|
+
keywords: ['layout', 'check', 'validate', 'xle', 'xlo', 'lint'],
|
|
28
|
+
params: [
|
|
29
|
+
{
|
|
30
|
+
name: 'expression',
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'The layout expression to validate.',
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'options.form',
|
|
37
|
+
type: "'compact' | 'outline' | 'auto'",
|
|
38
|
+
description:
|
|
39
|
+
'Force which input surface the expression is parsed as, or auto-detect it.',
|
|
40
|
+
default: "'auto'",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'options.loose',
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
description:
|
|
46
|
+
'Treat unknown {hint} references as warnings instead of errors.',
|
|
47
|
+
default: 'false',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'options.cwd',
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Directory the block catalog and registry resolve against.',
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
returns: [
|
|
56
|
+
{
|
|
57
|
+
type: 'layout.check',
|
|
58
|
+
description:
|
|
59
|
+
'The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline).',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
throws: [
|
|
63
|
+
{code: 'ERR_INVALID_ARGUMENT', when: 'the expression is empty'},
|
|
64
|
+
{
|
|
65
|
+
code: 'ERR_INVALID_OPTION',
|
|
66
|
+
when: 'form is not one of "compact", "outline", or "auto"',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
code: 'ERR_LAYOUT_PARSE',
|
|
70
|
+
when: 'the expression has a syntax error (reported with line/col)',
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
examples: [
|
|
74
|
+
{
|
|
75
|
+
label: 'Validate an expression',
|
|
76
|
+
code: 'const r = await layoutCheck(\'VStack[g4] > Text"Hi"\');',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: 'Read the canonical forms',
|
|
80
|
+
code: 'const {data} = await layoutCheck(\'Card > Text"Hi"\');',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
command: 'layout check',
|
|
84
|
+
related: ['layoutExpand', 'layoutGrammar'],
|
|
85
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file FunctionDoc for `layoutExpand()` / `astryx layout expand`. Colocated
|
|
6
|
+
* with the API function it documents; the response-shape source of truth stays
|
|
7
|
+
* in `layout.type.mjs`.
|
|
8
|
+
* @position packages/cli/api/layout — function documentation
|
|
9
|
+
*/
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
+
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|