@astryxdesign/cli 0.6.5-canary.fcd44d1 → 0.6.5-vanilla-poc.b2a96ac

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 (152) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +34 -1
  3. package/api/_vanilla-assets.d.mts +10 -0
  4. package/api/_vanilla-assets.mjs +59 -0
  5. package/api/component/_adapter.d.mts +37 -0
  6. package/api/component/_adapter.mjs +80 -1
  7. package/api/component/component.d.mts +9 -1
  8. package/api/component/component.doc.mjs +45 -4
  9. package/api/component/component.mjs +78 -0
  10. package/api/component/component.type.d.mts +8 -0
  11. package/api/component/component.type.mjs +6 -0
  12. package/api/component/html/html.d.mts +12 -0
  13. package/api/component/html/html.doc.d.mts +5 -0
  14. package/api/component/html/html.doc.mjs +66 -0
  15. package/api/component/html/html.mjs +25 -0
  16. package/api/component/html/html.test.mjs +61 -0
  17. package/api/component/html/html.type.d.mts +23 -0
  18. package/api/component/html/html.type.mjs +27 -0
  19. package/api/component/web-components/web-components.d.mts +12 -0
  20. package/api/component/web-components/web-components.doc.d.mts +5 -0
  21. package/api/component/web-components/web-components.doc.mjs +70 -0
  22. package/api/component/web-components/web-components.mjs +32 -0
  23. package/api/component/web-components/web-components.test.mjs +50 -0
  24. package/api/component/web-components/web-components.type.d.mts +23 -0
  25. package/api/component/web-components/web-components.type.mjs +27 -0
  26. package/api/index.d.mts +8 -0
  27. package/api/index.mjs +8 -0
  28. package/api/template/_adapter.d.mts +38 -0
  29. package/api/template/_adapter.mjs +90 -0
  30. package/api/template/html/html.d.mts +17 -0
  31. package/api/template/html/html.doc.d.mts +5 -0
  32. package/api/template/html/html.doc.mjs +72 -0
  33. package/api/template/html/html.mjs +61 -0
  34. package/api/template/html/html.test.mjs +71 -0
  35. package/api/template/html/html.type.d.mts +26 -0
  36. package/api/template/html/html.type.mjs +28 -0
  37. package/api/template/template.d.mts +6 -0
  38. package/api/template/template.doc.mjs +56 -4
  39. package/api/template/template.mjs +82 -0
  40. package/api/template/template.type.d.mts +12 -0
  41. package/api/template/template.type.mjs +7 -0
  42. package/api/template/web-components/web-components.d.mts +13 -0
  43. package/api/template/web-components/web-components.doc.d.mts +5 -0
  44. package/api/template/web-components/web-components.doc.mjs +69 -0
  45. package/api/template/web-components/web-components.mjs +51 -0
  46. package/api/template/web-components/web-components.test.mjs +73 -0
  47. package/api/template/web-components/web-components.type.d.mts +26 -0
  48. package/api/template/web-components/web-components.type.mjs +28 -0
  49. package/assets/vanilla/elements-markup/Avatar.html +27 -0
  50. package/assets/vanilla/elements-markup/Badge.html +16 -0
  51. package/assets/vanilla/elements-markup/Banner.html +32 -0
  52. package/assets/vanilla/elements-markup/Breadcrumbs.html +23 -0
  53. package/assets/vanilla/elements-markup/Button.html +25 -0
  54. package/assets/vanilla/elements-markup/Card.html +24 -0
  55. package/assets/vanilla/elements-markup/CheckboxInput.html +28 -0
  56. package/assets/vanilla/elements-markup/Collapsible.html +26 -0
  57. package/assets/vanilla/elements-markup/DateInput.html +28 -0
  58. package/assets/vanilla/elements-markup/Dialog.html +33 -0
  59. package/assets/vanilla/elements-markup/Divider.html +20 -0
  60. package/assets/vanilla/elements-markup/DropdownMenu.html +26 -0
  61. package/assets/vanilla/elements-markup/EmptyState.html +27 -0
  62. package/assets/vanilla/elements-markup/Heading.html +18 -0
  63. package/assets/vanilla/elements-markup/HoverCard.html +29 -0
  64. package/assets/vanilla/elements-markup/Layout.html +28 -0
  65. package/assets/vanilla/elements-markup/Lightbox.html +33 -0
  66. package/assets/vanilla/elements-markup/Link.html +23 -0
  67. package/assets/vanilla/elements-markup/NumberInput.html +34 -0
  68. package/assets/vanilla/elements-markup/ProgressBar.html +22 -0
  69. package/assets/vanilla/elements-markup/RadioList.html +28 -0
  70. package/assets/vanilla/elements-markup/Selector.html +34 -0
  71. package/assets/vanilla/elements-markup/SideNav.html +32 -0
  72. package/assets/vanilla/elements-markup/Skeleton.html +18 -0
  73. package/assets/vanilla/elements-markup/Slider.html +31 -0
  74. package/assets/vanilla/elements-markup/Stack.html +33 -0
  75. package/assets/vanilla/elements-markup/StatusDot.html +19 -0
  76. package/assets/vanilla/elements-markup/Switch.html +28 -0
  77. package/assets/vanilla/elements-markup/Tab.html +18 -0
  78. package/assets/vanilla/elements-markup/TabList.html +31 -0
  79. package/assets/vanilla/elements-markup/Table.html +31 -0
  80. package/assets/vanilla/elements-markup/Text.html +24 -0
  81. package/assets/vanilla/elements-markup/TextArea.html +32 -0
  82. package/assets/vanilla/elements-markup/TextInput.html +39 -0
  83. package/assets/vanilla/elements-markup/Theme.html +16 -0
  84. package/assets/vanilla/elements-markup/TimeInput.html +29 -0
  85. package/assets/vanilla/elements-markup/Toast.html +22 -0
  86. package/assets/vanilla/elements-markup/Tooltip.html +30 -0
  87. package/assets/vanilla/elements-markup/TopNav.html +29 -0
  88. package/assets/vanilla/elements-markup/Typeahead.html +31 -0
  89. package/assets/vanilla/elements-templates/dashboard.html +167 -0
  90. package/assets/vanilla/elements-templates/detail-page.html +145 -0
  91. package/assets/vanilla/elements-templates/form-two-column.html +135 -0
  92. package/assets/vanilla/elements-templates/kanban-board.html +141 -0
  93. package/assets/vanilla/elements-templates/login.html +100 -0
  94. package/assets/vanilla/elements-templates/product-detail.html +128 -0
  95. package/assets/vanilla/elements-templates/settings.html +130 -0
  96. package/assets/vanilla/elements-templates/shell-side-nav.html +160 -0
  97. package/assets/vanilla/elements-templates/table-filter.html +154 -0
  98. package/assets/vanilla/markup/Avatar.html +24 -0
  99. package/assets/vanilla/markup/Badge.html +12 -0
  100. package/assets/vanilla/markup/Banner.html +49 -0
  101. package/assets/vanilla/markup/Breadcrumbs.html +38 -0
  102. package/assets/vanilla/markup/Button.html +17 -0
  103. package/assets/vanilla/markup/Card.html +16 -0
  104. package/assets/vanilla/markup/CheckboxInput.html +45 -0
  105. package/assets/vanilla/markup/Collapsible.html +9 -0
  106. package/assets/vanilla/markup/DateInput.html +42 -0
  107. package/assets/vanilla/markup/Dialog.html +45 -0
  108. package/assets/vanilla/markup/Divider.html +9 -0
  109. package/assets/vanilla/markup/DropdownMenu.html +30 -0
  110. package/assets/vanilla/markup/EmptyState.html +41 -0
  111. package/assets/vanilla/markup/Heading.html +9 -0
  112. package/assets/vanilla/markup/HoverCard.html +59 -0
  113. package/assets/vanilla/markup/Layout.html +35 -0
  114. package/assets/vanilla/markup/Lightbox.html +107 -0
  115. package/assets/vanilla/markup/Link.html +6 -0
  116. package/assets/vanilla/markup/NumberInput.html +55 -0
  117. package/assets/vanilla/markup/ProgressBar.html +37 -0
  118. package/assets/vanilla/markup/RadioList.html +90 -0
  119. package/assets/vanilla/markup/Selector.html +92 -0
  120. package/assets/vanilla/markup/SideNav.html +82 -0
  121. package/assets/vanilla/markup/Skeleton.html +26 -0
  122. package/assets/vanilla/markup/Slider.html +65 -0
  123. package/assets/vanilla/markup/Stack.html +13 -0
  124. package/assets/vanilla/markup/StatusDot.html +22 -0
  125. package/assets/vanilla/markup/Switch.html +47 -0
  126. package/assets/vanilla/markup/TabList.html +56 -0
  127. package/assets/vanilla/markup/Table.html +75 -0
  128. package/assets/vanilla/markup/Text.html +9 -0
  129. package/assets/vanilla/markup/TextArea.html +37 -0
  130. package/assets/vanilla/markup/TextInput.html +30 -0
  131. package/assets/vanilla/markup/Theme.html +29 -0
  132. package/assets/vanilla/markup/TimeInput.html +43 -0
  133. package/assets/vanilla/markup/Toast.html +42 -0
  134. package/assets/vanilla/markup/Tooltip.html +18 -0
  135. package/assets/vanilla/markup/TopNav.html +37 -0
  136. package/assets/vanilla/markup/Typeahead.html +60 -0
  137. package/assets/vanilla/templates/dashboard.html +462 -0
  138. package/assets/vanilla/templates/detail-page.html +536 -0
  139. package/assets/vanilla/templates/form-two-column.html +438 -0
  140. package/assets/vanilla/templates/kanban-board.html +443 -0
  141. package/assets/vanilla/templates/login.html +199 -0
  142. package/assets/vanilla/templates/product-detail.html +335 -0
  143. package/assets/vanilla/templates/settings.html +374 -0
  144. package/assets/vanilla/templates/shell-side-nav.html +440 -0
  145. package/assets/vanilla/templates/table-filter.html +514 -0
  146. package/clients/cli/commands/component/index.mjs +33 -1
  147. package/clients/cli/commands/component.doc.mjs +23 -2
  148. package/clients/cli/commands/template.doc.mjs +31 -3
  149. package/clients/cli/commands/template.mjs +37 -2
  150. package/clients/cli/commands/vanilla-html.test.mjs +245 -0
  151. package/foundation/response/response-types.doc.mjs +38 -0
  152. package/package.json +11 -9
package/CHANGELOG.md CHANGED
@@ -17,16 +17,19 @@
17
17
  One source file that four codemods each changed was reported as four files changed, so `filesChanged` matched `transformsApplied` and the documented meaning, "Total files changed", was not true. The human summary said the same thing: "Found 4 changes across 4 files" for one file.
18
18
 
19
19
  `filesChanged` is now the count of distinct files. `transformsApplied` is unchanged: a code or config codemod counts once for each file it changed, and a project codemod counts once. A file that both a core codemod and an integration codemod changed counts once in `filesChanged`.
20
+
20
21
  - A parse error prints the Astryx error format in text mode.
21
22
  `astryx theme list --lang zh-Hans` printed Commander's own line — `error: option '--lang <locale>' argument 'zh-Hans' is invalid…` — while every other CLI error prints `Error: …`. `--json` was already correct (`ERR_INVALID_LANG`), so the two modes agreed only on the exit code.
22
23
 
23
24
  Commander writes that line before any Astryx code runs, so the JSON shim — the one place that already sees every parse failure — now suppresses it and writes the Astryx line itself, from the same message, for both modes. Every parse failure is covered: unknown option, unknown command, missing argument, and an invalid value for a global option. `--help` and `--version` are untouched and still exit 0.
25
+
24
26
  - The CLI reference now matches what the commands do. Every `--help` ends with the command's examples and a `More:` line that names its full docs page. Function docs show each parameter's default, mark required parameters, list the error codes each function throws, and use examples that run. The response-type list adds `help`, `version`, and `upgrade.registry`, and `astryx manifest` now lists `upgrade.registry` for `upgrade`. The `--zh`, `--dense`, `--lang`, and `--detail` descriptions name the commands they change, and command summaries say when to use each command. When `astryx template` refuses to overwrite a file, it now says to re-run with `--overwrite` (or `-f`). The `upgrade` command page (`astryx docs cli/commands/upgrade`) now explains which files codemods never edit, what happens when one of them needs a change, and how to regenerate it.
25
27
  - `astryx integration pack --check` now checks the tarball when a `prepack`, `prepare`, or `postpack` script prints to stdout. Before, any lifecycle output made the check fail with "npm pack produced unparseable JSON output" before it looked at the tarball. A failing lifecycle script still fails the check, and its output stays in the `pack_failed` message.
26
28
  - `astryx doctor integration docs` fails when a namespace doc or a placement fails, as its help says.
27
29
  Such a failure hides the doc from the docs tree, so it now exits 1 with an `invalid_doc_graph` error instead of a warning. A link that names no doc still only warns, since it prints as written. `doctor integration docs` and `doctor integration components` also no longer print an `[ok]` line after a check that failed.
28
30
 
29
31
  A mistyped subcommand under `doctor` now fails and lists the subcommands the group has: `astryx doctor integrations` used to run the project checks, and `astryx doctor integration bogus` exited 0 in text though it exited 1 with `--json`.
32
+
30
33
  - A package that ships a theme, or a doc section with an `id`, now declares the CLI that can read it.
31
34
  A stable CLI before 0.7.0 rejects both: it cannot read the typed theme descriptors that `astryx integration add theme` writes, and it rejects a section `id`. Either way it hides the package's themes or doc topics with no warning. `astryx integration add theme` now adds `"@astryxdesign/cli": ">=0.7.0"` to `peerDependencies`, marked optional, and `astryx integration verify` fails with `themes_need_cli` or `section_ids_need_cli` when a package needs that peer range and does not declare it.
32
35
  - `astryx integration verify` resolves every public import in the packed package, not in your source folder.
package/README.md CHANGED
@@ -15,6 +15,31 @@ npx @astryxdesign/cli template --list
15
15
 
16
16
  Once it's a project dependency (`npm install -D @astryxdesign/cli`), drop the scope and use the shorter `astryx` — e.g. `npx astryx component Button` or `pnpm exec astryx component Button`. Bare `astryx` resolves to an unrelated npm package until the CLI is installed, so prefer the scoped form above for first-run/one-off use.
17
17
 
18
+ ## Install the preview CLI
19
+
20
+ Install the self-contained vanilla HTML preview from its immutable commit:
21
+
22
+ ```bash
23
+ npm install -g https://cdn.jsdelivr.net/gh/facebook/astryx@ce7b98c3c01705bb8d71b96861828bfbc07283ac/packages/vanilla/dist/cli/astryx-cli-vanilla.tgz
24
+ ```
25
+
26
+ The preview package is `@astryxdesign/cli@0.6.5-vanilla.b32f55c9b`; it is not published to npm.
27
+
28
+ ## Choosing a framework
29
+
30
+ `component` and `template` default to the React catalog. Use `--framework html`
31
+ for the no-build vanilla markup, or `--framework web-components` for the
32
+ custom-element markup. Both alternatives support named reads and `--list`:
33
+
34
+ ```bash
35
+ astryx component Button --framework html
36
+ astryx component Button --framework web-components
37
+ astryx template dashboard --framework html
38
+ astryx template dashboard --framework web-components
39
+ ```
40
+
41
+ `--html` remains a deprecated alias for `--framework html`.
42
+
18
43
  ## Reading the CLI's own docs
19
44
 
20
45
  The CLI documents itself, so these commands print what the installed version does:
@@ -93,7 +118,7 @@ Options:
93
118
  | `layout` | Generate XDS layouts from compressed expressions (XLE/XLO) |
94
119
  | `search` | Search components, hooks, docs, and templates in one ranked list |
95
120
  | `swizzle` | Copy component source for customization |
96
- | `template` | List, show, or scaffold page and block templates |
121
+ | `template` | List, show, scaffold, or render page and block templates |
97
122
  | `theme` | Create and build themes: add a shipped one, compile to CSS, or list what a theme can override |
98
123
  | `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
99
124
 
@@ -431,6 +456,10 @@ Every response has a `type` discriminant. The full set is below (generated from
431
456
  | `component.detail.source` | One component's source file, as {component, source}. |
432
457
  | `component.detail.showcase` | One component's showcase example, as {component, aspectRatio, source}. |
433
458
  | `component.detail.blocks` | One component's example blocks, as {component, showcase, examples, related} of BlockEntry. |
459
+ | `component.html.list` | The sorted packages/vanilla/markup files as {name, file}. |
460
+ | `component.html` | One vanilla component markup file as {component, file, source}, preserving docs and variant comments verbatim. |
461
+ | `component.web-components.list` | The sorted packages/vanilla/elements-markup files as {name, file}. |
462
+ | `component.web-components` | One vanilla web-component markup file as {component, file, source}, preserving generated docs and variant comments verbatim. |
434
463
  | `docs.list` | All reference-doc topics as DocsListEntry[] ({topic, description, package, replaces?}), in read order; meta.namespaces lists the docs tree's top-level namespaces, and meta.notLoaded each package whose docs did not load. |
435
464
  | `docs.detail` | One topic's full ReferenceDoc (the JSON read of a topic, --full, --dense, or a topic with one section), with token-ref blocks inlined, plus links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
436
465
  | `docs.index` | One topic's section index, the text read of a topic with more than one section (and --index): the topic's name, title, and description, plus sections, each {id, title, summary} (pass the id as the section argument; summary is the section's one-line summary), and links ({up, previous, next}: the commands that open the level it sits in and its neighbors there). |
@@ -455,6 +484,10 @@ Every response has a `type` discriminant. The full set is below (generated from
455
484
  | `template.skeleton` | A layout skeleton (structural tags with spatial annotations) plus the template's description and the components it composes. |
456
485
  | `template.copy` | A scaffold receipt: template id, output directory, written file name, file count, and demoMediaReplaced (how many Astryx demo media references were replaced with placeholders for you to swap for your own media). |
457
486
  | `template.cdn` | A write receipt for the no-build-step CDN starter page: the path (relative to cwd), the Astryx version every CDN URL was pinned to, whether it was written, and the reason it was not. `exists` when a file was already there, which is a success. |
487
+ | `template.html.list` | The sorted packages/vanilla/templates files as {id, file}. |
488
+ | `template.html` | One vanilla standalone page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
489
+ | `template.web-components.list` | The sorted packages/vanilla/elements-templates files as {id, file}. |
490
+ | `template.web-components` | One vanilla web-component page as {template, file, cdnRef, cdnBase, source}, with every CDN placeholder substituted. |
458
491
  | `hook.list` | The hook catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of hook names, brief entries, or a full HookDoc per entry. |
459
492
  | `hook.detail` | One hook's full authored HookDoc. |
460
493
  | `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). |
@@ -0,0 +1,10 @@
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
+ * Prefer live checkout assets while developing, then fall back to the generated
6
+ * copy included in the published CLI package.
7
+ * @param {string} cwd
8
+ * @returns {string}
9
+ */
10
+ export function requireVanillaAssetsDir(cwd: string): string;
@@ -0,0 +1,59 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Resolves vanilla framework assets from the source checkout or the CLI bundle.
5
+ *
6
+ * @input A caller working directory.
7
+ * @output The checkout's packages/vanilla directory when present, otherwise the
8
+ * generated assets/vanilla copy shipped with @astryxdesign/cli.
9
+ * @position Shared environment adapter used only by the component and template
10
+ * vanilla framework adapters so installed and source-checkout behavior agree.
11
+ */
12
+
13
+ import * as fs from 'node:fs';
14
+ import * as path from 'node:path';
15
+ import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
16
+ import {AstryxError} from './error.mjs';
17
+
18
+ const BUNDLED_VANILLA_DIR = path.resolve(
19
+ import.meta.dirname,
20
+ '../assets/vanilla',
21
+ );
22
+
23
+ /** @param {string} candidate @returns {boolean} */
24
+ function isDirectory(candidate) {
25
+ return fs.existsSync(candidate) && fs.statSync(candidate).isDirectory();
26
+ }
27
+
28
+ /** @param {string} cwd @returns {string | null} */
29
+ function findCheckoutVanillaDir(cwd) {
30
+ let cursor = path.resolve(cwd);
31
+ while (true) {
32
+ const direct =
33
+ path.basename(cursor) === 'vanilla' &&
34
+ path.basename(path.dirname(cursor)) === 'packages'
35
+ ? cursor
36
+ : path.join(cursor, 'packages', 'vanilla');
37
+ if (isDirectory(direct)) return direct;
38
+ const parent = path.dirname(cursor);
39
+ if (parent === cursor) return null;
40
+ cursor = parent;
41
+ }
42
+ }
43
+
44
+ /**
45
+ * Prefer live checkout assets while developing, then fall back to the generated
46
+ * copy included in the published CLI package.
47
+ * @param {string} cwd
48
+ * @returns {string}
49
+ */
50
+ export function requireVanillaAssetsDir(cwd) {
51
+ const checkoutDir = findCheckoutVanillaDir(cwd);
52
+ if (checkoutDir) return checkoutDir;
53
+ if (isDirectory(BUNDLED_VANILLA_DIR)) return BUNDLED_VANILLA_DIR;
54
+ throw new AstryxError(
55
+ `Could not find vanilla framework assets from "${cwd}" or in the installed CLI`,
56
+ undefined,
57
+ ERROR_CODES.ERR_FILE_NOT_FOUND,
58
+ );
59
+ }
@@ -60,6 +60,43 @@
60
60
  * @returns {string}
61
61
  */
62
62
  export function requireCoreDir(cwd: string): string;
63
+ /**
64
+ * List the component markup files for a vanilla framework.
65
+ * @param {string} cwd
66
+ * @param {'html'|'web-components'} framework
67
+ * @returns {{name: string, file: string}[]}
68
+ */
69
+ export function listVanillaComponentMarkup(cwd: string, framework: "html" | "web-components"): {
70
+ name: string;
71
+ file: string;
72
+ }[];
73
+ /** @param {string} cwd @returns {{name: string, file: string}[]} */
74
+ export function listVanillaComponentHtml(cwd: string): {
75
+ name: string;
76
+ file: string;
77
+ }[];
78
+ /**
79
+ * Read one exact component markup file without permitting path traversal.
80
+ * @param {string} name
81
+ * @param {string} cwd
82
+ * @param {'html'|'web-components'} framework
83
+ * @returns {{component: string, file: string, source: string}}
84
+ */
85
+ export function readVanillaComponentMarkup(name: string, cwd: string, framework: "html" | "web-components"): {
86
+ component: string;
87
+ file: string;
88
+ source: string;
89
+ };
90
+ /**
91
+ * @param {string} name
92
+ * @param {string} cwd
93
+ * @returns {{component: string, file: string, source: string}}
94
+ */
95
+ export function readVanillaComponentHtml(name: string, cwd: string): {
96
+ component: string;
97
+ file: string;
98
+ source: string;
99
+ };
63
100
  /**
64
101
  * Load the configured integrations for `cwd`, swallowing any config errors so
65
102
  * component discovery never hard-fails on a malformed/absent integration. An
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * @file Shared resolver for the `component` command leaves.
5
5
  *
6
- * @input a component name (+ cwd / package scope) and doc-load options
6
+ * @input a component name (+ cwd / package scope) and doc-load options;
7
+ * vanilla HTML reads resolve checkout assets before the bundled copy
7
8
  * @output resolved subjects the leaves project into their one `{type, data}`
8
9
  * envelope — owners across core/integration, the scoped/legacy/fuzzy
9
10
  * resolution, and the doc-loading / prop-extraction / ownership shaping
@@ -40,6 +41,7 @@ import {Project} from '../../foundation/config/project.mjs';
40
41
  import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
41
42
  import {searchComponents} from '../../foundation/text/string-utils.mjs';
42
43
  import {AstryxError} from '../error.mjs';
44
+ import {requireVanillaAssetsDir} from '../_vanilla-assets.mjs';
43
45
 
44
46
  export {CORE_PACKAGE};
45
47
 
@@ -120,6 +122,83 @@ export function requireCoreDir(cwd) {
120
122
  return coreDir;
121
123
  }
122
124
 
125
+ /**
126
+ * List the component markup files for a vanilla framework.
127
+ * @param {string} cwd
128
+ * @param {'html'|'web-components'} framework
129
+ * @returns {{name: string, file: string}[]}
130
+ */
131
+ export function listVanillaComponentMarkup(cwd, framework) {
132
+ const assetDir =
133
+ framework === 'web-components' ? 'elements-markup' : 'markup';
134
+ const markupDir = path.join(requireVanillaAssetsDir(cwd), assetDir);
135
+ if (!fs.existsSync(markupDir)) return [];
136
+ return fs
137
+ .readdirSync(markupDir, {withFileTypes: true})
138
+ .filter(entry => entry.isFile() && entry.name.endsWith('.html'))
139
+ .map(entry => ({
140
+ name: entry.name.slice(0, -'.html'.length),
141
+ file: entry.name,
142
+ }))
143
+ .sort((a, b) => a.name.localeCompare(b.name));
144
+ }
145
+
146
+ /** @param {string} cwd @returns {{name: string, file: string}[]} */
147
+ export function listVanillaComponentHtml(cwd) {
148
+ return listVanillaComponentMarkup(cwd, 'html');
149
+ }
150
+
151
+ /**
152
+ * Read one exact component markup file without permitting path traversal.
153
+ * @param {string} name
154
+ * @param {string} cwd
155
+ * @param {'html'|'web-components'} framework
156
+ * @returns {{component: string, file: string, source: string}}
157
+ */
158
+ export function readVanillaComponentMarkup(name, cwd, framework) {
159
+ const entries = listVanillaComponentMarkup(cwd, framework);
160
+ if (!/^[A-Za-z][A-Za-z0-9]*$/.test(name)) {
161
+ throw new AstryxError(
162
+ `Invalid vanilla component name "${name}"`,
163
+ undefined,
164
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
165
+ );
166
+ }
167
+ const match = entries.find(entry => entry.name === name);
168
+ const label = framework === 'web-components' ? 'web-component' : 'HTML';
169
+ if (!match) {
170
+ throw new AstryxError(
171
+ `No vanilla ${label} markup found for component "${name}"`,
172
+ entries.map(entry => ({
173
+ name: entry.name,
174
+ reason: `vanilla ${label} component`,
175
+ })),
176
+ ERROR_CODES.ERR_UNKNOWN_COMPONENT,
177
+ );
178
+ }
179
+ const assetDir =
180
+ framework === 'web-components' ? 'elements-markup' : 'markup';
181
+ const filePath = path.join(
182
+ requireVanillaAssetsDir(cwd),
183
+ assetDir,
184
+ match.file,
185
+ );
186
+ return {
187
+ component: name,
188
+ file: match.file,
189
+ source: fs.readFileSync(filePath, 'utf8'),
190
+ };
191
+ }
192
+
193
+ /**
194
+ * @param {string} name
195
+ * @param {string} cwd
196
+ * @returns {{component: string, file: string, source: string}}
197
+ */
198
+ export function readVanillaComponentHtml(name, cwd) {
199
+ return readVanillaComponentMarkup(name, cwd, 'html');
200
+ }
201
+
123
202
  /**
124
203
  * Load the configured integrations for `cwd`, swallowing any config errors so
125
204
  * component discovery never hard-fails on a malformed/absent integration. An
@@ -12,6 +12,8 @@
12
12
  * @param {boolean} [options.source]
13
13
  * @param {boolean} [options.showcase]
14
14
  * @param {boolean} [options.blocks]
15
+ * @param {boolean} [options.html] - Deprecated alias for framework='html'.
16
+ * @param {'react'|'html'|'web-components'} [options.framework] - Output framework; defaults to react.
15
17
  * @param {'full'|'compact'|'brief'} [options.detail] - Defaults to 'full' for a single component, 'brief' for list views (list/category/no name), matching the CLI.
16
18
  * @param {string} [options.lang]
17
19
  * @param {boolean} [options.zh]
@@ -24,6 +26,10 @@
24
26
  * | import('./component.type.mjs').ComponentDetailSourceResponse
25
27
  * | import('./component.type.mjs').ComponentDetailShowcaseResponse
26
28
  * | import('./component.type.mjs').ComponentDetailBlocksResponse
29
+ * | import('./html/html.type.mjs').ComponentHtmlListResponse
30
+ * | import('./html/html.type.mjs').ComponentHtmlResponse
31
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsListResponse
32
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsResponse
27
33
  * )>}
28
34
  */
29
35
  export function component(name?: string | string[], options?: {
@@ -35,10 +41,12 @@ export function component(name?: string | string[], options?: {
35
41
  source?: boolean | undefined;
36
42
  showcase?: boolean | undefined;
37
43
  blocks?: boolean | undefined;
44
+ html?: boolean | undefined;
45
+ framework?: "react" | "html" | "web-components" | undefined;
38
46
  detail?: "compact" | "full" | "brief" | undefined;
39
47
  lang?: string | undefined;
40
48
  zh?: boolean | undefined;
41
49
  dense?: boolean | undefined;
42
- }): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").ComponentBatchResponse | import("./component.type.mjs").ComponentDetailResponse | import("./component.type.mjs").ComponentDetailPropsResponse | import("./component.type.mjs").ComponentDetailSourceResponse | import("./component.type.mjs").ComponentDetailShowcaseResponse | import("./component.type.mjs").ComponentDetailBlocksResponse)>;
50
+ }): Promise<(import("./component.type.mjs").ComponentListResponse | import("./component.type.mjs").ComponentBatchResponse | import("./component.type.mjs").ComponentDetailResponse | import("./component.type.mjs").ComponentDetailPropsResponse | import("./component.type.mjs").ComponentDetailSourceResponse | import("./component.type.mjs").ComponentDetailShowcaseResponse | import("./component.type.mjs").ComponentDetailBlocksResponse | import("./html/html.type.mjs").ComponentHtmlListResponse | import("./html/html.type.mjs").ComponentHtmlResponse | import("./web-components/web-components.type.mjs").ComponentWebComponentsListResponse | import("./web-components/web-components.type.mjs").ComponentWebComponentsResponse)>;
43
51
  /** Maximum selectors accepted before any component resolution starts. */
44
52
  export const COMPONENT_BATCH_SELECTOR_LIMIT: 100;
@@ -15,16 +15,18 @@ export const doc = {
15
15
  namespace: 'cli/api',
16
16
  displayName: 'component()',
17
17
  summary:
18
- 'Resolve one or several components by name, or list the catalog, with optional focused slices (props, source, showcase, blocks).',
18
+ 'Resolve components by name, list the catalog, or read vanilla HTML/web-component markup, with optional focused slices (props, source, showcase, blocks).',
19
19
  description:
20
20
  'Routes on its arguments: one string resolves that component across core and ' +
21
21
  'integration packages; an array returns one ordered result row per selector at ' +
22
22
  'every array length; and no name returns the catalog grouped by category. ' +
23
23
  'Boolean flags narrow each resolved component to just its props, source, ' +
24
- 'showcase, or example blocks.',
24
+ 'showcase, or example blocks. The framework option selects React docs (default), ' +
25
+ 'vanilla HTML markup, or vanilla web-component markup. The html option is a ' +
26
+ 'deprecated alias for framework=html.',
25
27
  importPath: '@astryxdesign/cli/api',
26
28
  signature:
27
- 'component(name?: string | string[], options?: ComponentOptions): Promise<ComponentListResponse | ComponentBatchResponse | ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse>',
29
+ 'component(name?: string | string[], options?: ComponentOptions): Promise<ComponentListResponse | ComponentBatchResponse | ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse | ComponentHtmlListResponse | ComponentHtmlResponse | ComponentWebComponentsListResponse | ComponentWebComponentsResponse>',
28
30
  keywords: [
29
31
  'component',
30
32
  'components',
@@ -85,6 +87,18 @@ export const doc = {
85
87
  description:
86
88
  "Return the component's example blocks (showcase, examples, related).",
87
89
  },
90
+ {
91
+ name: 'options.framework',
92
+ type: "'react' | 'html' | 'web-components'",
93
+ description:
94
+ 'Choose React component docs (default), vanilla HTML markup, or vanilla web-component markup.',
95
+ default: "'react'",
96
+ },
97
+ {
98
+ name: 'options.html',
99
+ type: 'boolean',
100
+ description: 'Deprecated alias for options.framework=html.',
101
+ },
88
102
  {
89
103
  name: 'options.detail',
90
104
  type: "'full' | 'compact' | 'brief'",
@@ -143,11 +157,30 @@ export const doc = {
143
157
  description:
144
158
  "The component's example blocks, as {component, showcase, examples, related} of BlockEntry.",
145
159
  },
160
+ {
161
+ type: 'component.html.list',
162
+ description: 'The sorted vanilla component markup files as {name, file}.',
163
+ },
164
+ {
165
+ type: 'component.html',
166
+ description:
167
+ 'One vanilla markup file as {component, file, source}; source includes its docs and variant comments verbatim.',
168
+ },
169
+ {
170
+ type: 'component.web-components.list',
171
+ description:
172
+ 'The sorted vanilla web-component markup files as {name, file}.',
173
+ },
174
+ {
175
+ type: 'component.web-components',
176
+ description:
177
+ 'One vanilla web-component markup file as {component, file, source}.',
178
+ },
146
179
  ],
147
180
  throws: [
148
181
  {
149
182
  code: 'ERR_INVALID_ARGUMENT',
150
- when: 'a selector array has more than 100 entries, a package-shaped selector has no component item, or its package conflicts with options.package',
183
+ when: 'the framework is unknown; html and framework are combined; a selector array has more than 100 entries; a package-shaped selector has no component item; its package conflicts with options.package; or a vanilla framework is missing its required name/list shape or combined with another projection',
151
184
  },
152
185
  {
153
186
  code: 'ERR_INVALID_DETAIL',
@@ -200,6 +233,14 @@ export const doc = {
200
233
  code: "await component(['Button', 'Badge']);",
201
234
  },
202
235
  {label: 'Props only', code: "await component('Button', {props: true});"},
236
+ {
237
+ label: 'Vanilla HTML',
238
+ code: "await component('Button', {framework: 'html'});",
239
+ },
240
+ {
241
+ label: 'Vanilla web component',
242
+ code: "await component('Button', {framework: 'web-components'});",
243
+ },
203
244
  {
204
245
  label: 'Browse one group',
205
246
  code: "await component(undefined, {category: 'Layout', detail: 'compact'});",
@@ -35,6 +35,10 @@ import {componentDetailProps} from './detail/props/props.mjs';
35
35
  import {componentDetailSource} from './detail/source/source.mjs';
36
36
  import {componentDetailShowcase} from './detail/showcase/showcase.mjs';
37
37
  import {componentDetailBlocks} from './detail/blocks/blocks.mjs';
38
+ import {componentHtml} from './html/html.mjs';
39
+ import {componentWebComponents} from './web-components/web-components.mjs';
40
+
41
+ const FRAMEWORKS = ['react', 'html', 'web-components'];
38
42
 
39
43
  /** Maximum selectors accepted before any component resolution starts. */
40
44
  export const COMPONENT_BATCH_SELECTOR_LIMIT = 100;
@@ -238,6 +242,8 @@ async function componentBatch(selectors, options, coreDir) {
238
242
  * @param {boolean} [options.source]
239
243
  * @param {boolean} [options.showcase]
240
244
  * @param {boolean} [options.blocks]
245
+ * @param {boolean} [options.html] - Deprecated alias for framework='html'.
246
+ * @param {'react'|'html'|'web-components'} [options.framework] - Output framework; defaults to react.
241
247
  * @param {'full'|'compact'|'brief'} [options.detail] - Defaults to 'full' for a single component, 'brief' for list views (list/category/no name), matching the CLI.
242
248
  * @param {string} [options.lang]
243
249
  * @param {boolean} [options.zh]
@@ -250,6 +256,10 @@ async function componentBatch(selectors, options, coreDir) {
250
256
  * | import('./component.type.mjs').ComponentDetailSourceResponse
251
257
  * | import('./component.type.mjs').ComponentDetailShowcaseResponse
252
258
  * | import('./component.type.mjs').ComponentDetailBlocksResponse
259
+ * | import('./html/html.type.mjs').ComponentHtmlListResponse
260
+ * | import('./html/html.type.mjs').ComponentHtmlResponse
261
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsListResponse
262
+ * | import('./web-components/web-components.type.mjs').ComponentWebComponentsResponse
253
263
  * )>}
254
264
  */
255
265
  export async function component(name, options = {}) {
@@ -262,6 +272,8 @@ export async function component(name, options = {}) {
262
272
  source = false,
263
273
  showcase = false,
264
274
  blocks = false,
275
+ html = false,
276
+ framework,
265
277
  detail: detailOption,
266
278
  lang = null,
267
279
  zh = false,
@@ -271,6 +283,72 @@ export async function component(name, options = {}) {
271
283
  const selectorList = Array.isArray(name) ? name : null;
272
284
  const noName = selectorList == null && !name;
273
285
 
286
+ if (framework !== undefined && !FRAMEWORKS.includes(framework)) {
287
+ throw new AstryxError(
288
+ `Unknown framework "${String(framework)}". Valid frameworks: ${FRAMEWORKS.join(', ')}`,
289
+ undefined,
290
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
291
+ );
292
+ }
293
+ if (html && framework !== undefined) {
294
+ throw new AstryxError(
295
+ '--html cannot be combined with --framework; use --framework html instead',
296
+ undefined,
297
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
298
+ );
299
+ }
300
+ const selectedFramework = html ? 'html' : (framework ?? 'react');
301
+
302
+ if (selectedFramework !== 'react') {
303
+ const frameworkFlag = html ? '--html' : `--framework ${selectedFramework}`;
304
+ const incompatible = [
305
+ category != null ? '--category' : null,
306
+ packageScope ? '--package' : null,
307
+ props ? '--props' : null,
308
+ source ? '--source' : null,
309
+ showcase ? '--showcase' : null,
310
+ blocks ? '--blocks' : null,
311
+ ].filter(Boolean);
312
+ if (incompatible.length > 0) {
313
+ throw new AstryxError(
314
+ `${frameworkFlag} cannot be combined with ${incompatible.join(', ')}`,
315
+ undefined,
316
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
317
+ );
318
+ }
319
+ if (selectorList) {
320
+ throw new AstryxError(
321
+ `${frameworkFlag} accepts exactly one component name, or --list with no name`,
322
+ undefined,
323
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
324
+ );
325
+ }
326
+ if (list && name) {
327
+ throw new AstryxError(
328
+ `--list ${frameworkFlag} cannot be combined with a component name`,
329
+ undefined,
330
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
331
+ );
332
+ }
333
+ if (!list && !name) {
334
+ throw new AstryxError(
335
+ `${frameworkFlag} requires a component name or --list`,
336
+ undefined,
337
+ ERROR_CODES.ERR_INVALID_ARGUMENT,
338
+ );
339
+ }
340
+ const vanillaOptions = {cwd, list};
341
+ return selectedFramework === 'html'
342
+ ? componentHtml(
343
+ typeof name === 'string' ? name : undefined,
344
+ vanillaOptions,
345
+ )
346
+ : componentWebComponents(
347
+ typeof name === 'string' ? name : undefined,
348
+ vanillaOptions,
349
+ );
350
+ }
351
+
274
352
  // Default detail level mirrors the CLI (see commands/component/index.mjs):
275
353
  // single-component views default to 'full', list-style views (--list,
276
354
  // --category, or no name) default to 'brief' (scannable name lists).
@@ -181,6 +181,14 @@ export type ComponentOptions = {
181
181
  * List example blocks for the component: showcase, examples, and related.
182
182
  */
183
183
  blocks?: boolean | undefined;
184
+ /**
185
+ * Deprecated alias for framework='html'.
186
+ */
187
+ html?: boolean | undefined;
188
+ /**
189
+ * Output framework; defaults to react.
190
+ */
191
+ framework?: "react" | "html" | "web-components" | undefined;
184
192
  detail?: "compact" | "full" | "brief" | undefined;
185
193
  lang?: string | undefined;
186
194
  zh?: boolean | undefined;
@@ -26,6 +26,10 @@
26
26
  * astryx --json component Button --source -> component.detail.source
27
27
  * astryx --json component Button --showcase -> component.detail.showcase
28
28
  * astryx --json component Button --blocks -> component.detail.blocks
29
+ * astryx --json component --list --framework html -> component.html.list
30
+ * astryx --json component Button --framework html -> component.html
31
+ * astryx --json component --list --framework web-components -> component.web-components.list
32
+ * astryx --json component Button --framework web-components -> component.web-components
29
33
  * (not found) -> CLIError
30
34
  */
31
35
 
@@ -186,6 +190,8 @@
186
190
  * @property {boolean} [source]
187
191
  * @property {boolean} [showcase]
188
192
  * @property {boolean} [blocks] List example blocks for the component: showcase, examples, and related.
193
+ * @property {boolean} [html] Deprecated alias for framework='html'.
194
+ * @property {'react'|'html'|'web-components'} [framework] Output framework; defaults to react.
189
195
  * @property {'full' | 'compact' | 'brief'} [detail]
190
196
  * @property {string} [lang]
191
197
  * @property {boolean} [zh]
@@ -0,0 +1,12 @@
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
+ * @param {string|undefined} name
6
+ * @param {{cwd?: string, list?: boolean}} [options]
7
+ * @returns {import('./html.type.mjs').ComponentHtmlResponse | import('./html.type.mjs').ComponentHtmlListResponse}
8
+ */
9
+ export function componentHtml(name: string | undefined, options?: {
10
+ cwd?: string;
11
+ list?: boolean;
12
+ }): import("./html.type.mjs").ComponentHtmlResponse | import("./html.type.mjs").ComponentHtmlListResponse;
@@ -0,0 +1,5 @@
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
+ /** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
5
+ export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;