@astryxdesign/cli 0.7.0-canary.450c68d → 0.7.0-canary.4ec1f4e

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 (168) hide show
  1. package/README.md +30 -33
  2. package/api/doctor/doctor.doc.mjs +1 -1
  3. package/api/doctor/doctor.test.mjs +28 -0
  4. package/api/doctor/theme-checks.mjs +10 -10
  5. package/api/doctor/theme-checks.test.mjs +5 -4
  6. package/api/gap-report/gap-report.doc.mjs +1 -1
  7. package/api/gap-report/gap-report.mjs +15 -0
  8. package/api/gap-report/gap-report.test.mjs +1 -1
  9. package/api/index.d.mts +0 -2
  10. package/api/index.mjs +0 -2
  11. package/api/init/init.doc.mjs +5 -1
  12. package/api/init/init.mjs +22 -0
  13. package/api/init/init.type.d.mts +4 -1
  14. package/api/init/init.type.mjs +1 -1
  15. package/api/init/remove/remove.mjs +8 -3
  16. package/api/init/remove/remove.test.mjs +12 -0
  17. package/api/init/run/run.d.mts +1 -1
  18. package/api/init/run/run.mjs +3 -3
  19. package/api/integration/validate-integration.d.mts +4 -0
  20. package/api/integration/validate-integration.mjs +5 -2
  21. package/api/integration/validateIntegration.doc.mjs +1 -1
  22. package/api/json/index.ts +0 -1
  23. package/api/search/search.doc.mjs +1 -1
  24. package/api/search/search.mjs +1 -1
  25. package/api/search/search.test.mjs +1 -1
  26. package/api/search/search.type.d.mts +1 -1
  27. package/api/search/search.type.mjs +1 -1
  28. package/api/template/template-integration.test.mjs +37 -100
  29. package/api/template/template.doc.mjs +5 -1
  30. package/api/template/template.mjs +45 -0
  31. package/api/theme/_adapter.mjs +3 -3
  32. package/api/theme/add/add.d.mts +11 -5
  33. package/api/theme/add/add.mjs +19 -192
  34. package/api/theme/add/add.test.mjs +68 -258
  35. package/api/theme/add/add.types.test.mjs +0 -1
  36. package/api/theme/build/build.d.mts +3 -3
  37. package/api/theme/build/build.mjs +22 -36
  38. package/api/theme/build/build.test.mjs +11 -24
  39. package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
  40. package/api/theme/integration-themes.test.mjs +3 -3
  41. package/api/theme/remove/remove.test.mjs +1 -1
  42. package/api/theme/targets/targets.test.mjs +0 -4
  43. package/api/theme/template/template.mjs +1 -1
  44. package/api/theme/theme.type.d.mts +1 -30
  45. package/api/theme/theme.type.mjs +3 -13
  46. package/api/theme/themeAdd.doc.mjs +19 -27
  47. package/api/theme/themeTargets.doc.mjs +3 -4
  48. package/api/theme/themeTemplate.doc.mjs +1 -1
  49. package/api/theme/use/use.test.mjs +1 -1
  50. package/api/upgrade/upgrade.doc.mjs +1 -1
  51. package/api/upgrade/upgrade.mjs +19 -0
  52. package/assets/codemods/transforms/next/README.md +15 -17
  53. package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
  54. package/assets/codemods/transforms/next/index.mjs +11 -1
  55. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
  56. package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
  57. package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
  58. package/assets/docs/author-a-theme.doc.mjs +1 -1
  59. package/assets/docs/getting-started.doc.mjs +2 -2
  60. package/assets/docs/theme.doc.dense.mjs +1 -1
  61. package/assets/docs/theme.doc.mjs +2 -2
  62. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  63. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  64. package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
  65. package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
  66. package/assets/docs/tree/themes.doc.mjs +1 -1
  67. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
  68. package/assets/docs/tree/versioning.doc.mjs +1 -4
  69. package/assets/docs/use-a-theme.doc.mjs +16 -16
  70. package/authoring/debug/type.ts +2 -2
  71. package/authoring/doctypes/base/type.ts +0 -9
  72. package/authoring/integration/integration.doc.mjs +1 -1
  73. package/clients/cli/command-result-coverage.test.mjs +1 -1
  74. package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
  75. package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
  76. package/clients/cli/commands/build-theme.mjs +31 -67
  77. package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
  78. package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
  79. package/clients/cli/commands/discover.mjs +2 -1
  80. package/clients/cli/commands/doctor.mjs +5 -2
  81. package/clients/cli/commands/empty-argument.test.mjs +16 -0
  82. package/clients/cli/commands/gap-report.doc.mjs +1 -1
  83. package/clients/cli/commands/gap-report.test.mjs +2 -2
  84. package/clients/cli/commands/init.doc.mjs +4 -4
  85. package/clients/cli/commands/init.flag-help.test.mjs +7 -10
  86. package/clients/cli/commands/init.next-steps.test.mjs +1 -1
  87. package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
  88. package/clients/cli/commands/search.test.mjs +1 -1
  89. package/clients/cli/commands/swizzle.mjs +4 -1
  90. package/clients/cli/commands/template.doc.mjs +3 -3
  91. package/clients/cli/commands/template.flag-help.test.mjs +18 -11
  92. package/clients/cli/commands/template.mjs +7 -1
  93. package/clients/cli/commands/text-json-parity.test.mjs +0 -17
  94. package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
  95. package/clients/cli/commands/theme-add.doc.mjs +10 -17
  96. package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
  97. package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
  98. package/clients/cli/commands/theme-template.doc.mjs +1 -1
  99. package/clients/cli/commands/theme.doc.mjs +2 -2
  100. package/clients/cli/commands/upgrade.doc.mjs +1 -1
  101. package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
  102. package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
  103. package/clients/cli/index.mjs +0 -4
  104. package/clients/cli/lib/cli-error.mjs +19 -0
  105. package/clients/cli/lib/component-format.mjs +111 -57
  106. package/clients/cli/lib/component-format.test.mjs +28 -39
  107. package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
  108. package/clients/cli/lib/exit-codes.test.mjs +0 -7
  109. package/clients/cli/lib/json-shim.test.mjs +0 -24
  110. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  111. package/foundation/agent-docs/agent-docs.mjs +6 -1
  112. package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
  113. package/foundation/config/theme-state.mjs +3 -3
  114. package/foundation/debug/debug-fields.test.mjs +13 -35
  115. package/foundation/debug/event.mjs +13 -78
  116. package/foundation/debug/privacy-contract.test.mjs +20 -12
  117. package/foundation/debug/redact.d.mts +2 -2
  118. package/foundation/debug/redact.mjs +2 -2
  119. package/foundation/discovery/theme-imports.mjs +1 -1
  120. package/foundation/discovery/theming-targets.d.mts +1 -20
  121. package/foundation/discovery/theming-targets.mjs +1 -38
  122. package/foundation/discovery/theming-targets.test.mjs +9 -175
  123. package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
  124. package/foundation/response/error-codes.doc.mjs +1 -1
  125. package/foundation/response/response-types.doc.mjs +11 -30
  126. package/foundation/response/response-types.doc.test.mjs +36 -14
  127. package/foundation/response/response.doc.mjs +1 -1
  128. package/foundation/xle/browser.d.mts +2 -2
  129. package/foundation/xle/browser.mjs +2 -2
  130. package/foundation/xle/expand.mjs +1 -1
  131. package/foundation/xle/print.mjs +1 -1
  132. package/package.json +9 -9
  133. package/api/layout/_adapter.d.mts +0 -34
  134. package/api/layout/_adapter.mjs +0 -148
  135. package/api/layout/check/check.d.mts +0 -17
  136. package/api/layout/check/check.mjs +0 -41
  137. package/api/layout/expand/expand.d.mts +0 -23
  138. package/api/layout/expand/expand.mjs +0 -161
  139. package/api/layout/expand/expand.path-safety.test.mjs +0 -53
  140. package/api/layout/expand/expand.receipt.test.mjs +0 -74
  141. package/api/layout/grammar/grammar.d.mts +0 -14
  142. package/api/layout/grammar/grammar.mjs +0 -88
  143. package/api/layout/layout.d.mts +0 -6
  144. package/api/layout/layout.mjs +0 -17
  145. package/api/layout/layout.test.mjs +0 -297
  146. package/api/layout/layout.type.d.mts +0 -90
  147. package/api/layout/layout.type.mjs +0 -104
  148. package/api/layout/layoutCheck.doc.d.mts +0 -11
  149. package/api/layout/layoutCheck.doc.mjs +0 -85
  150. package/api/layout/layoutExpand.doc.d.mts +0 -11
  151. package/api/layout/layoutExpand.doc.mjs +0 -107
  152. package/api/layout/layoutGrammar.doc.d.mts +0 -11
  153. package/api/layout/layoutGrammar.doc.mjs +0 -57
  154. package/api/theme/add/add.binary.test.mjs +0 -157
  155. package/api/theme/add/add.rollback.test.mjs +0 -158
  156. package/api/theme/add/add.staging.test.mjs +0 -83
  157. package/clients/cli/commands/layout-check.doc.mjs +0 -67
  158. package/clients/cli/commands/layout-expand.doc.mjs +0 -87
  159. package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
  160. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
  161. package/clients/cli/commands/layout.doc.mjs +0 -36
  162. package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
  163. package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
  164. package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
  165. package/clients/cli/commands/layout.mjs +0 -327
  166. package/clients/cli/commands/layout.path-help.test.mjs +0 -33
  167. package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
  168. package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
@@ -1,161 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `astryx layout expand` leaf — expand a validated layout expression into
5
- * XDS TSX (optionally written to disk). Resolution + validation come from
6
- * ../_adapter.mjs (analyze); this leaf owns block-module assembly, code
7
- * generation, and the path-safe write, and projects the `layout.expand` envelope.
8
- *
9
- * @input expression string (+ options)
10
- * @output {type:'layout.expand', data}
11
- * @position api — leaf over ../_adapter.mjs + lib/xle/expand
12
- */
13
-
14
- import * as fs from 'node:fs';
15
- import * as path from 'node:path';
16
- import {AstryxError} from '../../error.mjs';
17
- import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
18
- import {assertWithin, isFilePathArg, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
19
- import {detectForm} from '../../../foundation/xle/parse.mjs';
20
- import {expand} from '../../../foundation/xle/expand.mjs';
21
- import {replaceDemoMedia} from '../../template/template.mjs';
22
- import {analyze, formatIssue} from '../_adapter.mjs';
23
-
24
- /** @param {string} name */
25
- const normKey = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, '');
26
-
27
- /**
28
- * Collect the block names referenced by {hints} anywhere in the doc.
29
- * @param {import('../../../foundation/xle/xle-ast').XLEDoc} doc
30
- */
31
- function collectHintNames(doc) {
32
- /** @type {Set<string>} */
33
- const names = new Set();
34
- /** @param {import('../../../foundation/xle/xle-ast').XLEItem} node */
35
- const visitNode = (node) => {
36
- if (!node || node.kind === 'group') {
37
- (node?.children || []).forEach(visit);
38
- return;
39
- }
40
- if (node.hint?.block) names.add(node.hint.block.name);
41
- for (const slot of node.slots || []) {
42
- const value = slot.value;
43
- if (value && typeof value === 'object' && 'hint' in value && value.hint?.block) {
44
- names.add(value.hint.block.name);
45
- }
46
- if (value && typeof value === 'object' && 'subexpr' in value) {
47
- (value.subexpr || []).forEach(visit);
48
- }
49
- }
50
- (node.children || []).forEach(visit);
51
- };
52
- /** @param {import('../../../foundation/xle/xle-ast').XLEItem} item */
53
- const visit = (item) => (item?.kind === 'group' ? item.children.forEach(visit) : visitNode(item));
54
- doc.roots.forEach(visit);
55
- doc.overlays.forEach(visit);
56
- return names;
57
- }
58
-
59
- /**
60
- * Build the blockModules map expand() needs: import-mode for app components,
61
- * splice-mode (reading + asset-stripping the block source) for template blocks.
62
- * Only blocks actually referenced are read. Also returns how many demo media
63
- * references the splice-mode sources had replaced.
64
- *
65
- * @param {import('../../../foundation/xle/xle-ast').XLEDoc} doc
66
- * @param {import('../_adapter.mjs').LayoutBlock[]} blocks
67
- * @returns {{modules: Map<string, import('../../../foundation/xle/xle-ast').BlockModule>, demoMediaReplaced: number}}
68
- */
69
- function buildBlockModules(doc, blocks) {
70
- const referenced = collectHintNames(doc);
71
- if (referenced.size === 0) return {modules: new Map(), demoMediaReplaced: 0};
72
- const byKey = new Map(blocks.map(b => [normKey(b.dirName), b]));
73
- /** @type {Map<string, import('../../../foundation/xle/xle-ast').BlockModule>} */
74
- const modules = new Map();
75
- let demoMediaReplaced = 0;
76
- for (const name of referenced) {
77
- const block = byKey.get(normKey(name));
78
- if (!block) continue;
79
- if (block.kind === 'component') {
80
- modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ (/** @type {unknown} */ ({mode: 'import', componentName: block.name, importPath: block.importPath, isDefault: block.isDefault})));
81
- } else if (block.filePath && fs.existsSync(block.filePath)) {
82
- const spliced = replaceDemoMedia(fs.readFileSync(block.filePath, 'utf-8'));
83
- demoMediaReplaced += spliced.demoMediaReplaced;
84
- modules.set(name, /** @type {import('../../../foundation/xle/xle-ast').BlockModule} */ ({mode: 'splice', componentName: block.dirName, source: spliced.source}));
85
- }
86
- }
87
- return {modules, demoMediaReplaced};
88
- }
89
-
90
- /**
91
- * @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
92
- * `astryx layout expand "<expr>" [path]`
93
- *
94
- * @param {string} expression
95
- * @param {object} [options]
96
- * @param {string} [options.targetPath] - write TSX here (validated against cwd)
97
- * @param {'compact'|'outline'|'auto'} [options.form]
98
- * @param {boolean} [options.loose] - downgrade unknown {hints} to TODO warnings
99
- * @param {string} [options.name] - generated component name
100
- * @param {string} [options.cwd]
101
- * @returns {Promise<import('../layout.type.mjs').LayoutExpandResponse>}
102
- */
103
- export async function layoutExpand(expression, options = {}) {
104
- const {targetPath, form = 'auto', loose = false, name, cwd = process.cwd()} = options;
105
- const {doc, registry, blocks, errors, warnings} = await analyze(expression, {form, loose, cwd});
106
-
107
- if (errors.length > 0) {
108
- throw new AstryxError(
109
- `Layout expression is invalid:\n` + errors.map(e => ` - ${formatIssue(e)}`).join('\n'),
110
- errors.flatMap(e => (e.suggestions || []).map(s => ({name: s, reason: 'did you mean this?'}))),
111
- ERROR_CODES.ERR_LAYOUT_INVALID,
112
- );
113
- }
114
-
115
- const componentName = name || 'GeneratedLayout';
116
- if (!/^[A-Z][A-Za-z0-9]*$/.test(componentName)) {
117
- throw new AstryxError(
118
- `--name must be a PascalCase component name, got '${componentName}'`,
119
- undefined,
120
- ERROR_CODES.ERR_INVALID_ARGUMENT,
121
- );
122
- }
123
- const {modules: blockModules, demoMediaReplaced} = buildBlockModules(doc, blocks);
124
- const result = expand(doc, registry, {componentName, blockModules});
125
-
126
- let written = null;
127
- if (targetPath) {
128
- // The guard sees the file that will be written, not only its directory:
129
- // a symlink at that name would otherwise carry the write outside the root.
130
- const fileTarget = isFilePathArg(targetPath)
131
- ? targetPath
132
- : path.join(targetPath, `${componentName}.tsx`);
133
- let filePath;
134
- try {
135
- filePath = assertWithin(fileTarget, cwd, {label: 'layout target path'});
136
- } catch (err) {
137
- if (err instanceof PathSafetyError) {
138
- throw new AstryxError(err.message, undefined, ERROR_CODES.ERR_PATH_TRAVERSAL);
139
- }
140
- throw err;
141
- }
142
- fs.mkdirSync(path.dirname(filePath), {recursive: true});
143
- fs.writeFileSync(filePath, result.code);
144
- written = path.relative(cwd, filePath);
145
- }
146
-
147
- return {
148
- type: 'layout.expand',
149
- data: {
150
- form: form === 'auto' ? detectForm(expression) : form,
151
- code: result.code,
152
- componentsUsed: result.componentsUsed,
153
- states: result.states,
154
- todos: result.todos,
155
- blocksReferenced: [...blockModules.entries()].map(([name, m]) => ({name, mode: m.mode})),
156
- warnings: warnings.map(formatIssue),
157
- written,
158
- demoMediaReplaced,
159
- },
160
- };
161
- }
@@ -1,53 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file Path-safety tests for the `layout.expand` write. The file written, not
5
- * only the directory it lands in, must stay inside the project root.
6
- */
7
-
8
- import {describe, it, expect, beforeAll} from 'vitest';
9
- import * as fs from 'node:fs';
10
- import * as os from 'node:os';
11
- import * as path from 'node:path';
12
- import {layoutExpand} from '../layout.mjs';
13
- import {buildRegistry} from '../../../foundation/xle/registry.mjs';
14
-
15
- const SLOW = 30_000;
16
-
17
- // The registry imports every component doc on first use; warm it once.
18
- beforeAll(async () => {
19
- await buildRegistry();
20
- }, 120_000);
21
-
22
- describe('layout.expand — write confinement', () => {
23
- it('rejects a directory target whose generated file is a symlink leading outside cwd', async () => {
24
- // Inside the workspace so @astryxdesign/core resolves.
25
- const cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-confine-test-'));
26
- const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'xle-confine-outside-'));
27
- try {
28
- const victim = path.join(outside, 'victim.tsx');
29
- fs.writeFileSync(victim, 'OUTSIDE');
30
- fs.mkdirSync(path.join(cwd, 'out'));
31
- fs.symlinkSync(victim, path.join(cwd, 'out', 'GeneratedLayout.tsx'));
32
-
33
- await expect(
34
- layoutExpand('V > B', {targetPath: './out', cwd}),
35
- ).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
36
- expect(fs.readFileSync(victim, 'utf-8')).toBe('OUTSIDE');
37
- } finally {
38
- fs.rmSync(cwd, {recursive: true, force: true});
39
- fs.rmSync(outside, {recursive: true, force: true});
40
- }
41
- }, SLOW);
42
-
43
- it('still writes <Name>.tsx into a plain directory target', async () => {
44
- const cwd = fs.mkdtempSync(path.join(process.cwd(), '.xle-confine-test-'));
45
- try {
46
- const result = await layoutExpand('V > B', {targetPath: './out', name: 'Demo', cwd});
47
- expect(result.data.written).toBe(path.join('out', 'Demo.tsx'));
48
- expect(fs.existsSync(path.join(cwd, 'out', 'Demo.tsx'))).toBe(true);
49
- } finally {
50
- fs.rmSync(cwd, {recursive: true, force: true});
51
- }
52
- }, SLOW);
53
- });
@@ -1,74 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file The layout.expand receipt discloses demo media replaced in the template
5
- * blocks it splices. Blocks are picked by what their source contains, not by
6
- * name, so catalog renames do not break the suite.
7
- */
8
-
9
- import {describe, it, expect, beforeAll} from 'vitest';
10
- import * as fs from 'node:fs';
11
- import {layoutExpand} from '../layout.mjs';
12
- import {discoverTemplates} from '../../template/template.mjs';
13
- import {buildRegistry} from '../../../foundation/xle/registry.mjs';
14
-
15
- const SLOW = 60_000;
16
- const FIXTURE_REF = /\/template-assets\/[\w.-]+\.\w+/g;
17
-
18
- beforeAll(async () => {
19
- await buildRegistry();
20
- }, 120_000);
21
-
22
- /** @param {string} name */
23
- const hintKey = name => name.toLowerCase().replace(/[^a-z0-9]/g, '');
24
-
25
- /** @type {Promise<Array<{hint: string, refs: number}>> | undefined} */
26
- let catalog;
27
-
28
- /**
29
- * Template blocks a `{hint}` resolves to unambiguously, with the number of demo
30
- * media references in each one's source.
31
- * @returns {Promise<Array<{hint: string, refs: number}>>}
32
- */
33
- function catalogBlocks() {
34
- catalog ??= discoverTemplates().then(found => {
35
- const all = /** @type {Array<{dirName: string, type: string, filePath: string}>} */ (
36
- found
37
- ).filter(t => t.type === 'block' && t.filePath && fs.existsSync(t.filePath));
38
- const seen = new Map();
39
- for (const t of all) seen.set(hintKey(t.dirName), (seen.get(hintKey(t.dirName)) ?? 0) + 1);
40
- return all
41
- .filter(t => seen.get(hintKey(t.dirName)) === 1)
42
- .map(t => ({
43
- hint: hintKey(t.dirName),
44
- refs: (fs.readFileSync(t.filePath, 'utf-8').match(FIXTURE_REF) ?? []).length,
45
- }));
46
- });
47
- return catalog;
48
- }
49
-
50
- describe('layout.expand receipt - replaced demo media', () => {
51
- it('counts the demo media of a spliced block once, however often it is referenced', async () => {
52
- const block = (await catalogBlocks()).find(b => b.refs > 0);
53
- if (!block) throw new Error('no template block carries demo media');
54
- const res = await layoutExpand(`V > {${block.hint}}*3`);
55
- expect(res.type).toBe('layout.expand');
56
- expect(res.data.blocksReferenced).toHaveLength(1);
57
- expect(res.data.demoMediaReplaced).toBe(block.refs);
58
- expect(res.data.code).not.toContain('/template-assets/');
59
- }, SLOW);
60
-
61
- it('sums the demo media of every spliced block', async () => {
62
- const [a, b] = (await catalogBlocks()).filter(x => x.refs > 0);
63
- if (!b) throw new Error('fewer than two template blocks carry demo media');
64
- const res = await layoutExpand(`V > {${a.hint}} + {${b.hint}}`);
65
- expect(res.data.demoMediaReplaced).toBe(a.refs + b.refs);
66
- }, SLOW);
67
-
68
- it('reports 0 when nothing spliced carries demo media', async () => {
69
- const plain = (await catalogBlocks()).find(b => b.refs === 0);
70
- if (!plain) throw new Error('every template block carries demo media');
71
- expect((await layoutExpand(`V > {${plain.hint}}`)).data.demoMediaReplaced).toBe(0);
72
- expect((await layoutExpand('V > B"Save"')).data.demoMediaReplaced).toBe(0);
73
- }, SLOW);
74
- });
@@ -1,14 +0,0 @@
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
- * @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
6
- * `astryx layout grammar` — the agent cheatsheet, with the alias table
7
- * generated from this branch's registry (never hand-maintained).
8
- *
9
- * @param {{cwd?: string}} [options]
10
- * @returns {Promise<import('../layout.type.mjs').LayoutGrammarResponse>}
11
- */
12
- export function layoutGrammar(options?: {
13
- cwd?: string;
14
- }): Promise<import("../layout.type.mjs").LayoutGrammarResponse>;
@@ -1,88 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `astryx layout grammar` leaf — the agent cheatsheet, with the alias
5
- * table generated from this branch's registry (never hand-maintained). Reads
6
- * only the registry; shares nothing with expand/check, so it has no adapter.
7
- *
8
- * @output {type:'layout.grammar', data}
9
- * @position api — leaf over lib/xle/registry
10
- */
11
-
12
- import {buildRegistry} from '../../../foundation/xle/registry.mjs';
13
- import {MAX_REPEAT} from '../../../foundation/xle/expand.mjs';
14
-
15
- /**
16
- * @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
17
- * `astryx layout grammar` — the agent cheatsheet, with the alias table
18
- * generated from this branch's registry (never hand-maintained).
19
- *
20
- * @param {{cwd?: string}} [options]
21
- * @returns {Promise<import('../layout.type.mjs').LayoutGrammarResponse>}
22
- */
23
- export async function layoutGrammar(options = {}) {
24
- const {cwd = process.cwd()} = options;
25
- const registry = await buildRegistry({cwd});
26
-
27
- /** @type {string[]} */
28
- const aliasLines = [];
29
- /** @type {Map<string, string[]>} */
30
- const byTarget = new Map();
31
- for (const [alias, target] of registry.aliases) {
32
- if (!byTarget.has(target)) byTarget.set(target, []);
33
- byTarget.get(target)?.push(alias);
34
- }
35
- for (const [target, aliases] of [...byTarget.entries()].sort(([a], [b]) => a.localeCompare(b))) {
36
- aliasLines.push(`${aliases.join('/')}=${target}`);
37
- }
38
-
39
- const text = `XLE/XLO — XDS layout expressions (branch-generated; aliases reflect this install)
40
-
41
- WORKFLOW
42
- astryx layout check "<expr>" validate; echoes canonical compact + outline forms
43
- astryx layout expand "<expr>" [path] emit validated TSX (path optional; --name <Pascal>)
44
- Errors carry line/col + suggestions. Fix and resubmit; nothing is guessed.
45
-
46
- TWO SURFACES, ONE LANGUAGE (autodetected; --form to force)
47
- compact: A[cp6 @topNav=TN] > L > LC > S[p6] > (C{card-callout}*4) + T
48
- outline: indentation = nesting · same-indent = siblings · "repeat N:" block = (...)*N
49
- slot lines: topNav: TN (or a block: topNav:\\n TN ...)
50
-
51
- NODE ANATOMY Name#id.enum"payload"[attrs]{hint}*N > children
52
- .enum unique enum value of any prop: Bd.success Tx.lg B.primary
53
- "payload" primary text prop (label/title/heading) or text child: TI"Email" B"Save"
54
- {hint} kebab-case template/component reference (see TEMPLATE REFERENCING) — NEVER text
55
- *N / xN repeat, at most ${MAX_REPEAT} copies (use $ for the counter: Tk"item-$"*3)
56
- trailing ! initial selection for scaffolded state: Tab"Overview"!
57
-
58
- ATTRS [...] (outline: bare tokens after the name, no brackets)
59
- fused p6 g4 c4 w240 h2 cp2 mw960 rg2 cg2 (per-component: padding lives on Card/Section/AppShell.cp — p6 on AppShell/Layout/VStack errors with a correction)
60
- key=value t=email href='/x' c{min:340} dv=[top,bottom] — keys validated per component
61
- flags req opt dis striped hover divider … (isX/hasX props) · negate: !scroll
62
- align j= main axis, a= cross axis — expander picks hAlign/vAlign per stack direction
63
- slots @slotName=Node | @slotName=(sub > expr) | @slotName='text' | @slotName=#id
64
- trigger opens=#id (a plain attr, no @ — binds an onClick that opens the overlay)
65
- fill on a stack child → wraps in <StackItem size="fill">
66
-
67
- TEMPLATE REFERENCING ({hint} pulls in real content — this is how XLE reaches past the @astryxdesign/core shell)
68
- C{card-callout} splice a template block (astryx template --list --type block):
69
- the block is co-defined once in the file, referenced, imports merged
70
- {kpi-card} standalone reference (no wrapper element) — place a component directly
71
- {kpi-card}*4 repeat a reference; the definition/import is emitted once
72
- app components register local ones in astryx.config.mjs to import them by name:
73
- export default {experimental: {xle: {components: {KpiCard: {from: '@/components/KpiCard'}}}}}
74
- then {kpi-card} → import {KpiCard} + <KpiCard /> (kebab ↔ Pascal)
75
-
76
- STRUCTURE THE EXPANDER HANDLES
77
- Layout > LH + LC + LF + LP children auto-route into header/content/footer/start slots
78
- T > (TR>THC*4) + (TR>TC*4)*6 rows partition into TableHeader/TableBody automatically
79
- TabList/inputs required value+onChange scaffold typed useState automatically
80
- overlays compact: tree ;; Dlg#confirm[...] · outline: overlays: section
81
- trigger: B"Delete"[opens=#confirm]
82
-
83
- ALIASES (full component names always valid; XDS prefix optional)
84
- ${aliasLines.join(' ')}
85
- `;
86
-
87
- return {type: 'layout.grammar', data: {text, aliases: Object.fromEntries(registry.aliases)}};
88
- }
@@ -1,6 +0,0 @@
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
- export { layoutExpand } from "./expand/expand.mjs";
5
- export { layoutCheck } from "./check/check.mjs";
6
- export { layoutGrammar } from "./grammar/grammar.mjs";
@@ -1,17 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
-
3
- /**
4
- * @file `layout` command barrel — re-exports the expand/check/grammar leaves so
5
- * the CLI (cli/commands/layout.mjs) and scripted callers import from one place.
6
- * Each leaf is also importable directly (e.g. api/layout/expand/expand.mjs). The
7
- * shared analysis core lives in ./_adapter.mjs. `layout` has real subcommands,
8
- * so there is no flag-dispatch here — the CLI calls the leaf it wants.
9
- *
10
- * @input layout expressions (+ options), per leaf
11
- * @output {type, data} envelopes: layout.expand / layout.check / layout.grammar
12
- * @position api — command barrel over the expand/check/grammar leaves
13
- */
14
-
15
- export {layoutExpand} from './expand/expand.mjs';
16
- export {layoutCheck} from './check/check.mjs';
17
- export {layoutGrammar} from './grammar/grammar.mjs';