bejamas 0.4.1 → 0.5.0
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 +8 -1
- package/dist/{generate-mdx-Ce7A9Uxe.js → generate-mdx-Bd_qGcMg.js} +82 -40
- package/dist/generate-mdx-Bd_qGcMg.js.map +1 -0
- package/dist/index.js +598 -249
- package/dist/index.js.map +1 -1
- package/dist/{utils-CyYWo_qS.js → utils-BEqgES6q.js} +1389 -1043
- package/dist/utils-BEqgES6q.js.map +1 -0
- package/package.json +16 -16
- package/src/tailwind.css +535 -3
- package/dist/generate-mdx-Ce7A9Uxe.js.map +0 -1
- package/dist/utils-CyYWo_qS.js.map +0 -1
package/README.md
CHANGED
|
@@ -28,9 +28,16 @@ npx bejamas add [component]
|
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
npx bejamas add button
|
|
31
|
+
npx bejamas add navigation-headers-01
|
|
32
|
+
npx bejamas add @bejamas/footer-01
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
Blocks are installed under `src/components/blocks/<block-id>` together with
|
|
36
|
+
their required UI components. In a monorepo, run the command from the app so
|
|
37
|
+
the block lands in the app while its UI dependencies go to the shared UI
|
|
38
|
+
package.
|
|
39
|
+
|
|
40
|
+
You can also run the command without any arguments to view a list of all available components and blocks:
|
|
34
41
|
|
|
35
42
|
```bash
|
|
36
43
|
npx bejamas add
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as extractComponentTagsFromMDX, c as extractPropsFromDeclaredProps, ct as __require, d as parseJsDocMetadata, f as resolveOutDir, g as spinner, h as toIdentifier, i as discoverExamples, l as normalizeBlockMDX, m as slugify, n as createSourceFileFromFrontmatter, o as extractFrontmatter, p as resolveUiRoot, r as detectHasImportTopLevel, s as extractPropsFromAstroProps, t as RESERVED_COMPONENTS, u as normalizeUsageMDX, v as getConfig, x as logger } from "./utils-BEqgES6q.js";
|
|
2
2
|
import { dirname, extname, join, relative } from "path";
|
|
3
3
|
import { existsSync, mkdirSync } from "fs";
|
|
4
4
|
import { readFile, readdir, writeFile } from "fs/promises";
|
|
@@ -105,7 +105,7 @@ function decodeEscapedScriptTags(source) {
|
|
|
105
105
|
if (!source || !source.length) return source;
|
|
106
106
|
return source.replace(/<script>/gi, "<script>").replace(/<\/script>/gi, "<\/script>");
|
|
107
107
|
}
|
|
108
|
-
const CONSOLE_SCRIPT_FENCE_LANGS = new Set([
|
|
108
|
+
const CONSOLE_SCRIPT_FENCE_LANGS = /* @__PURE__ */ new Set([
|
|
109
109
|
"js",
|
|
110
110
|
"ts",
|
|
111
111
|
"javascript",
|
|
@@ -169,7 +169,7 @@ function extractFirstAstroFence(body) {
|
|
|
169
169
|
const astroFenceIndex = fences.findIndex((fence) => fence.lang === "astro");
|
|
170
170
|
if (astroFenceIndex === -1) return null;
|
|
171
171
|
const astroFence = fences[astroFenceIndex];
|
|
172
|
-
const consumedFenceIndexes = new Set([astroFenceIndex]);
|
|
172
|
+
const consumedFenceIndexes = /* @__PURE__ */ new Set([astroFenceIndex]);
|
|
173
173
|
let companionSourceMD = "";
|
|
174
174
|
let consoleScripts = [];
|
|
175
175
|
let companionIntroMD = "";
|
|
@@ -364,8 +364,8 @@ function extractComponentTagsFromExamplesSections(sections) {
|
|
|
364
364
|
/**
|
|
365
365
|
* Check if an import path uses the new barrel export pattern (no .astro extension)
|
|
366
366
|
*/
|
|
367
|
-
function isBarrelImport(path
|
|
368
|
-
return !path
|
|
367
|
+
function isBarrelImport(path) {
|
|
368
|
+
return !path.endsWith(".astro");
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
371
|
* Convert a PascalCase component name to its folder path (kebab-case).
|
|
@@ -384,7 +384,12 @@ function componentToFolder(name) {
|
|
|
384
384
|
"LinkGroup",
|
|
385
385
|
"RadioGroup",
|
|
386
386
|
"ButtonGroup",
|
|
387
|
-
"StickySurface"
|
|
387
|
+
"StickySurface",
|
|
388
|
+
"DropdownMenu",
|
|
389
|
+
"NavigationMenu",
|
|
390
|
+
"ContextMenu",
|
|
391
|
+
"HoverCard",
|
|
392
|
+
"ToggleGroup"
|
|
388
393
|
].sort((a, b) => b.length - a.length);
|
|
389
394
|
for (const family of sortedFamilies) if (name === family || name.startsWith(family)) return family.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
390
395
|
const baseMatch = name.match(/^[A-Z][a-z]*/);
|
|
@@ -394,8 +399,6 @@ function resolveComponentFolder(name, componentFolderMap) {
|
|
|
394
399
|
if (!componentFolderMap) return componentToFolder(name);
|
|
395
400
|
const direct = componentFolderMap[name];
|
|
396
401
|
if (direct && direct.length) return direct;
|
|
397
|
-
const prefixMatch = Object.keys(componentFolderMap).filter((key) => name.startsWith(key)).sort((a, b) => b.length - a.length)[0];
|
|
398
|
-
if (prefixMatch) return componentFolderMap[prefixMatch];
|
|
399
402
|
return componentToFolder(name);
|
|
400
403
|
}
|
|
401
404
|
/**
|
|
@@ -419,6 +422,10 @@ function generateBarrelImports(components, componentsAlias, componentFolderMap)
|
|
|
419
422
|
const sortedFolders = Array.from(groups.keys()).sort();
|
|
420
423
|
for (const folder of sortedFolders) {
|
|
421
424
|
const names = groups.get(folder).sort();
|
|
425
|
+
if (folder.endsWith(".astro")) {
|
|
426
|
+
for (const name of names) lines.push(`import ${name} from '${componentsAlias}/${folder}';`);
|
|
427
|
+
continue;
|
|
428
|
+
}
|
|
422
429
|
lines.push(`import { ${names.join(", ")} } from '${componentsAlias}/${folder}';`);
|
|
423
430
|
}
|
|
424
431
|
return lines;
|
|
@@ -431,15 +438,23 @@ function generateDefaultImports(components, componentsAlias) {
|
|
|
431
438
|
}
|
|
432
439
|
function buildMdx(params) {
|
|
433
440
|
const { importName, importPath, title, description, descriptionBodyMDX, usageMDX, hasImport, propsList, propsTable, examples, examplesSections, componentFolderMap, autoImports, lucideIcons, primaryExampleMDX, componentSource, commandName, figmaUrl, componentsAlias, namedExports, apiMDX } = params;
|
|
441
|
+
const available = params.availableComponents ? new Set(params.availableComponents) : null;
|
|
442
|
+
const missingFromNames = (names) => names.filter((name) => available && !available.has(name) && !RESERVED_COMPONENTS.has(name) && !/Icon$/.test(name));
|
|
443
|
+
const missingFromSnippet = (snippet) => missingFromNames([...new Set([...snippet.matchAll(/<([A-Z][A-Za-z0-9_]*)\b/g)].map((match) => match[1]))]);
|
|
444
|
+
const missingNotice = (names) => {
|
|
445
|
+
return `> Preview unavailable. Run \`bejamas add ${[...new Set(names.map((name) => resolveComponentFolder(name, componentFolderMap)))].sort().join(" ")}\` to install the required components, then regenerate the docs.`;
|
|
446
|
+
};
|
|
434
447
|
const useBarrelPattern = isBarrelImport(importPath);
|
|
435
448
|
const sortedLucide = (lucideIcons ?? []).slice().sort();
|
|
436
449
|
const externalTopImports = [`import { Tabs as DocsTabs, TabItem as DocsTabItem } from '@astrojs/starlight/components';`, sortedLucide.length ? `import { ${sortedLucide.join(", ")} } from '@lucide/astro';` : null].filter((v) => v != null).slice().sort((a, b) => String(a).localeCompare(String(b)));
|
|
437
|
-
const sortedUiAuto = (autoImports ?? []).slice().sort();
|
|
438
|
-
const uiAutoLines = useBarrelPattern ? generateBarrelImports(sortedUiAuto, componentsAlias, componentFolderMap) : generateDefaultImports(sortedUiAuto, componentsAlias);
|
|
439
|
-
const exampleLines = (examples ?? []).map((ex) => `import ${ex.importName} from '${ex.importPath}';`).sort((a, b) => a.localeCompare(b));
|
|
450
|
+
const sortedUiAuto = (autoImports ?? []).filter((name) => !available || available.has(name)).slice().sort();
|
|
451
|
+
const uiAutoLines = useBarrelPattern || componentFolderMap ? generateBarrelImports(sortedUiAuto, componentsAlias, componentFolderMap) : generateDefaultImports(sortedUiAuto, componentsAlias);
|
|
452
|
+
const exampleLines = (examples ?? []).filter((ex) => !missingFromSnippet(ex.source).length).map((ex) => `import ${ex.importName} from '${ex.importPath}';`).sort((a, b) => a.localeCompare(b));
|
|
440
453
|
let mainImportLine = null;
|
|
441
|
-
if (!hasImport)
|
|
442
|
-
|
|
454
|
+
if (!hasImport) {
|
|
455
|
+
if (useBarrelPattern) mainImportLine = `import { ${[importName, ...namedExports ?? []].sort().join(", ")} } from '${importPath}';`;
|
|
456
|
+
else mainImportLine = `import ${importName} from '${importPath}';`;
|
|
457
|
+
}
|
|
443
458
|
const internalTopImports = [
|
|
444
459
|
mainImportLine,
|
|
445
460
|
...uiAutoLines,
|
|
@@ -450,7 +465,7 @@ function buildMdx(params) {
|
|
|
450
465
|
externalTopImports.length && internalTopImports.length ? "" : null,
|
|
451
466
|
...internalTopImports
|
|
452
467
|
].filter((v) => v !== null && v !== void 0);
|
|
453
|
-
const extractTags
|
|
468
|
+
const extractTags = (snippet) => {
|
|
454
469
|
const found = /* @__PURE__ */ new Set();
|
|
455
470
|
const tagRegex = /<([A-Z][A-Za-z0-9_]*)\b/g;
|
|
456
471
|
let m;
|
|
@@ -459,7 +474,7 @@ function buildMdx(params) {
|
|
|
459
474
|
};
|
|
460
475
|
const buildSnippetImportLines = (snippet) => {
|
|
461
476
|
if (!snippet || !snippet.length) return [];
|
|
462
|
-
const used = extractTags
|
|
477
|
+
const used = extractTags(snippet);
|
|
463
478
|
const usedIcons = sortedLucide.filter((n) => used.has(n));
|
|
464
479
|
const usedUi = (autoImports ?? []).filter((n) => used.has(n));
|
|
465
480
|
const includeMain = !hasImport && used.has(importName);
|
|
@@ -475,7 +490,7 @@ function buildMdx(params) {
|
|
|
475
490
|
if (usedUi.length > 0) internal.push(...generateBarrelImports(usedUi, componentsAlias, componentFolderMap));
|
|
476
491
|
} else {
|
|
477
492
|
if (includeMain) internal.push(`import ${importName} from '${importPath}';`);
|
|
478
|
-
internal.push(...usedUi
|
|
493
|
+
internal.push(...componentFolderMap ? generateBarrelImports(usedUi, componentsAlias, componentFolderMap) : generateDefaultImports(usedUi, componentsAlias));
|
|
479
494
|
}
|
|
480
495
|
const externalSorted = external.slice().sort((a, b) => a.localeCompare(b));
|
|
481
496
|
const internalSorted = internal.slice().sort((a, b) => a.localeCompare(b));
|
|
@@ -541,13 +556,15 @@ function buildMdx(params) {
|
|
|
541
556
|
const { enableConsolePanel = false, consoleScripts = [] } = options;
|
|
542
557
|
const extracted = extractInlineScripts(snippet);
|
|
543
558
|
const resolvedConsoleScripts = enableConsolePanel && consoleScripts.length ? consoleScripts : enableConsolePanel ? extracted.scripts : [];
|
|
544
|
-
const
|
|
559
|
+
const withoutComments = extracted.markup.replace(/<!--([\s\S]*?)-->/g, "{/*$1*/}");
|
|
560
|
+
const withConvertedParagraphs = convertParagraphsWithComponents(withoutComments);
|
|
545
561
|
if (/<p[\s>]/i.test(withConvertedParagraphs)) return {
|
|
546
562
|
markup: normalizeInlineWhitespace(withConvertedParagraphs),
|
|
547
563
|
scripts: resolvedConsoleScripts
|
|
548
564
|
};
|
|
565
|
+
const normalized = normalizeInlineWhitespace(withConvertedParagraphs);
|
|
549
566
|
return {
|
|
550
|
-
markup: wrapTextNodes(
|
|
567
|
+
markup: wrapTextNodes(normalized),
|
|
551
568
|
scripts: resolvedConsoleScripts
|
|
552
569
|
};
|
|
553
570
|
};
|
|
@@ -669,6 +686,8 @@ function buildMdx(params) {
|
|
|
669
686
|
return parts.join("\n");
|
|
670
687
|
};
|
|
671
688
|
const renderPreviewBlock = (snippet, options = {}) => {
|
|
689
|
+
const missing = missingFromSnippet(snippet);
|
|
690
|
+
if (missing.length) return missingNotice(missing);
|
|
672
691
|
const { enableConsolePanel = false } = options;
|
|
673
692
|
const preparedPreview = toMdxPreview(snippet, options);
|
|
674
693
|
if (!preparedPreview.markup || !preparedPreview.markup.length) return "";
|
|
@@ -691,6 +710,11 @@ ${preparedPreview.markup}
|
|
|
691
710
|
};
|
|
692
711
|
const renderAstroPreviewsInMarkdown = (block, config = {}) => {
|
|
693
712
|
if (!block || !block.length) return block;
|
|
713
|
+
const missingRaw = missingFromNames(extractComponentTagsFromPreviewMarkdown(block, {
|
|
714
|
+
defaultPreview: false,
|
|
715
|
+
allowForcedPreview: false
|
|
716
|
+
}));
|
|
717
|
+
if (missingRaw.length) return `${missingNotice(missingRaw)}\n\n\`\`\`\`mdx\n${block}\n\`\`\`\``;
|
|
694
718
|
const { defaultPreview = true, allowForcedPreview = true } = config;
|
|
695
719
|
const lines = block.split("\n");
|
|
696
720
|
const out = [];
|
|
@@ -818,7 +842,7 @@ ${(() => {
|
|
|
818
842
|
const renderExampleItem = (headingLevel, headingTitle, body) => {
|
|
819
843
|
const prepared = prepareExampleContent(body);
|
|
820
844
|
const blocks = [`${headingLevel} ${headingTitle}`];
|
|
821
|
-
if (prepared.descriptionMD && prepared.descriptionMD.length) blocks.push(prepared.descriptionMD);
|
|
845
|
+
if (prepared.descriptionMD && prepared.descriptionMD.length) blocks.push(renderAstroPreviewsInMarkdown(prepared.descriptionMD));
|
|
822
846
|
if (prepared.snippet && prepared.snippet.length && prepared.sourceCode && prepared.sourceCode.length && !prepared.skipPreview) blocks.push(renderPreviewBlock(prepared.snippet, {
|
|
823
847
|
enableConsolePanel: prepared.enableConsolePanel,
|
|
824
848
|
consoleScripts: prepared.consoleScripts
|
|
@@ -834,7 +858,7 @@ ${sourceBlock}
|
|
|
834
858
|
\`\`\``);
|
|
835
859
|
if (prepared.companionIntroMD && prepared.companionIntroMD.length && !prepared.mergeCompanionWithSource) blocks.push(prepared.companionIntroMD);
|
|
836
860
|
if (prepared.companionSourceMD && prepared.companionSourceMD.length && !prepared.mergeCompanionWithSource) blocks.push(renderCompanionSourceMD(prepared.companionSourceMD));
|
|
837
|
-
if (prepared.trailingDescriptionMD && prepared.trailingDescriptionMD.length) blocks.push(prepared.trailingDescriptionMD);
|
|
861
|
+
if (prepared.trailingDescriptionMD && prepared.trailingDescriptionMD.length) blocks.push(renderAstroPreviewsInMarkdown(prepared.trailingDescriptionMD));
|
|
838
862
|
}
|
|
839
863
|
return blocks.join("\n\n");
|
|
840
864
|
};
|
|
@@ -845,7 +869,7 @@ ${sourceBlock}
|
|
|
845
869
|
const sectionParts = [];
|
|
846
870
|
const hasSectionTitle = !!(section.title && section.title.length);
|
|
847
871
|
if (hasSectionTitle) sectionParts.push(`### ${section.title}`);
|
|
848
|
-
if (section.introMD && section.introMD.length) sectionParts.push(section.introMD);
|
|
872
|
+
if (section.introMD && section.introMD.length) sectionParts.push(renderAstroPreviewsInMarkdown(section.introMD));
|
|
849
873
|
if (section.items && section.items.length) {
|
|
850
874
|
const itemHeadingLevel = hasSectionTitle ? "####" : "###";
|
|
851
875
|
for (const item of section.items) sectionParts.push(renderExampleItem(itemHeadingLevel, item.title, item.body));
|
|
@@ -862,9 +886,9 @@ ${sourceBlock}
|
|
|
862
886
|
}
|
|
863
887
|
if (examples && examples.length) for (const ex of examples) renderedExampleSections.push(`### ${ex.title}
|
|
864
888
|
|
|
865
|
-
|
|
889
|
+
${missingFromSnippet(ex.source).length ? missingNotice(missingFromSnippet(ex.source)) : `<div class="not-content">
|
|
866
890
|
<${ex.importName} />
|
|
867
|
-
</div
|
|
891
|
+
</div>`}
|
|
868
892
|
|
|
869
893
|
\`\`\`astro
|
|
870
894
|
${ex.source}
|
|
@@ -948,15 +972,16 @@ ${ex.source}
|
|
|
948
972
|
*/
|
|
949
973
|
async function discoverComponents(componentsDir) {
|
|
950
974
|
const entries = [];
|
|
951
|
-
const dirEntries = await readdir(componentsDir, { withFileTypes: true });
|
|
975
|
+
const dirEntries = (await readdir(componentsDir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
952
976
|
for (const entry of dirEntries) if (entry.isDirectory()) {
|
|
953
977
|
const folderPath = join(componentsDir, entry.name);
|
|
954
978
|
const indexPath = join(folderPath, "index.ts");
|
|
955
979
|
if (existsSync(indexPath)) {
|
|
956
|
-
const
|
|
980
|
+
const localExports = parseBarrelExports(await readFile(indexPath, "utf-8")).filter(({ file }) => dirname(join(folderPath, file)) === folderPath && existsSync(join(folderPath, file)));
|
|
981
|
+
const namedExports = localExports.map(({ name }) => name);
|
|
957
982
|
const mainComponentName = findMainComponent(namedExports, entry.name);
|
|
958
983
|
if (mainComponentName) {
|
|
959
|
-
const mainFilePath = join(folderPath,
|
|
984
|
+
const mainFilePath = join(folderPath, localExports.find(({ name }) => name === mainComponentName).file);
|
|
960
985
|
if (existsSync(mainFilePath)) {
|
|
961
986
|
const subComponents = namedExports.filter((n) => n !== mainComponentName);
|
|
962
987
|
entries.push({
|
|
@@ -979,12 +1004,17 @@ async function discoverComponents(componentsDir) {
|
|
|
979
1004
|
namedExports: []
|
|
980
1005
|
});
|
|
981
1006
|
}
|
|
982
|
-
|
|
1007
|
+
const nestedNames = new Set(entries.filter((entry) => entry.isFolder).map((entry) => entry.name));
|
|
1008
|
+
return entries.filter((entry) => entry.isFolder || !nestedNames.has(entry.name));
|
|
983
1009
|
}
|
|
984
1010
|
function buildComponentFolderMap(components) {
|
|
985
1011
|
const map = {};
|
|
986
1012
|
for (const component of components) {
|
|
987
|
-
if (!component.isFolder
|
|
1013
|
+
if (!component.isFolder) {
|
|
1014
|
+
map[component.name] = `${component.name}.astro`;
|
|
1015
|
+
continue;
|
|
1016
|
+
}
|
|
1017
|
+
if (!component.folderName) continue;
|
|
988
1018
|
map[component.name] = component.folderName;
|
|
989
1019
|
for (const sub of component.namedExports) map[sub] = component.folderName;
|
|
990
1020
|
}
|
|
@@ -998,9 +1028,12 @@ function buildComponentFolderMap(components) {
|
|
|
998
1028
|
*/
|
|
999
1029
|
function parseBarrelExports(content) {
|
|
1000
1030
|
const exports = [];
|
|
1001
|
-
const exportRegex = /export\s*\{\s*default\s+as\s+(\w+)\s*\}/g;
|
|
1031
|
+
const exportRegex = /export\s*\{\s*default\s+as\s+(\w+)\s*\}\s*from\s*["'](\.\/[^"']+\.astro)["']/g;
|
|
1002
1032
|
let match;
|
|
1003
|
-
while ((match = exportRegex.exec(content)) !== null) exports.push(
|
|
1033
|
+
while ((match = exportRegex.exec(content)) !== null) exports.push({
|
|
1034
|
+
name: match[1],
|
|
1035
|
+
file: match[2]
|
|
1036
|
+
});
|
|
1004
1037
|
return exports;
|
|
1005
1038
|
}
|
|
1006
1039
|
/**
|
|
@@ -1020,7 +1053,7 @@ async function main() {
|
|
|
1020
1053
|
const config = await getConfig(cwd);
|
|
1021
1054
|
const componentsAlias = (config?.aliases?.ui || config?.aliases?.components || "@bejamas/ui/components").replace(/\/$/, "");
|
|
1022
1055
|
const componentsDirFromConfig = config?.resolvedPaths?.ui || config?.resolvedPaths?.components;
|
|
1023
|
-
let uiRoot = resolveUiRoot(cwd);
|
|
1056
|
+
let uiRoot = componentsDirFromConfig ? dirname(dirname(componentsDirFromConfig)) : resolveUiRoot(cwd);
|
|
1024
1057
|
let componentsDir = join(uiRoot, "src", "components");
|
|
1025
1058
|
if (componentsDirFromConfig) {
|
|
1026
1059
|
componentsDir = componentsDirFromConfig;
|
|
@@ -1037,6 +1070,8 @@ async function main() {
|
|
|
1037
1070
|
}
|
|
1038
1071
|
const components = await discoverComponents(componentsDir);
|
|
1039
1072
|
const componentFolderMap = buildComponentFolderMap(components);
|
|
1073
|
+
const availableComponents = Object.keys(componentFolderMap);
|
|
1074
|
+
const rewriteAliases = (source) => source.replace(/@bejamas\/ui\/components(?=[/"'])/g, componentsAlias).replace(/@bejamas\/(?:ui|registry)\/lib\/utils(?=["'])/g, config?.aliases?.utils ?? "@/lib/utils").replace(/@bejamas\/(?:ui|registry)\/lib(?=[/"'])/g, config?.aliases?.lib ?? "@/lib");
|
|
1040
1075
|
if (DEBUG) {
|
|
1041
1076
|
logger.info(`[docs-generator] components found: ${components.length}`);
|
|
1042
1077
|
if (components.length) logger.info(`[docs-generator] first few: ${components.slice(0, 5).map((c) => c.name).join(", ")}`);
|
|
@@ -1049,7 +1084,7 @@ async function main() {
|
|
|
1049
1084
|
const astroFile = await readFile(filePath, "utf-8");
|
|
1050
1085
|
const frontmatterCode = extractFrontmatter(astroFile);
|
|
1051
1086
|
const sourceFile = createSourceFileFromFrontmatter(frontmatterCode);
|
|
1052
|
-
const meta = parseJsDocMetadata(frontmatterCode);
|
|
1087
|
+
const meta = parseJsDocMetadata(rewriteAliases(frontmatterCode));
|
|
1053
1088
|
const declaredProps = extractPropsFromDeclaredProps(sourceFile);
|
|
1054
1089
|
const destructuredProps = extractPropsFromAstroProps(sourceFile);
|
|
1055
1090
|
const defaultsMap = /* @__PURE__ */ new Map();
|
|
@@ -1081,9 +1116,10 @@ async function main() {
|
|
|
1081
1116
|
if (parsedExamplesSections.length === 0) {
|
|
1082
1117
|
exampleRelPaths = await discoverExamples(filePath, componentsDir);
|
|
1083
1118
|
examples = (exampleRelPaths || []).map((rel) => {
|
|
1084
|
-
const
|
|
1119
|
+
const posixRel = rel.split(__require("path").sep).join(__require("path").posix.sep);
|
|
1120
|
+
const importPathEx = `${componentsAlias}/${posixRel}`;
|
|
1085
1121
|
const abs = join(componentsDir, rel);
|
|
1086
|
-
const source = __require("fs").readFileSync(abs, "utf-8");
|
|
1122
|
+
const source = rewriteAliases(__require("fs").readFileSync(abs, "utf-8"));
|
|
1087
1123
|
const base = toIdentifier(__require("path").basename(rel, __require("path").extname(rel)));
|
|
1088
1124
|
return {
|
|
1089
1125
|
importName: `${pascal}${base}`,
|
|
@@ -1101,7 +1137,7 @@ async function main() {
|
|
|
1101
1137
|
defaultPreview: false,
|
|
1102
1138
|
allowForcedPreview: false
|
|
1103
1139
|
}).filter((n) => n !== pascal);
|
|
1104
|
-
const autoSet = new Set([
|
|
1140
|
+
const autoSet = /* @__PURE__ */ new Set([
|
|
1105
1141
|
...usedInUsage,
|
|
1106
1142
|
...usedInDescription,
|
|
1107
1143
|
...usedInExamples,
|
|
@@ -1110,9 +1146,12 @@ async function main() {
|
|
|
1110
1146
|
]);
|
|
1111
1147
|
const usedNamedExports = isFolder ? namedExports.filter((n) => autoSet.has(n)) : [];
|
|
1112
1148
|
if (isFolder) for (const n of namedExports) autoSet.delete(n);
|
|
1113
|
-
const autoImports = Array.from(autoSet).filter((name) => !RESERVED_COMPONENTS.has(name))
|
|
1114
|
-
const
|
|
1115
|
-
const
|
|
1149
|
+
const autoImports = Array.from(autoSet).filter((name) => !RESERVED_COMPONENTS.has(name));
|
|
1150
|
+
const isLucideIcon = (name) => /Icon$/.test(name) && !componentFolderMap[name];
|
|
1151
|
+
const lucideIcons = autoImports.filter(isLucideIcon);
|
|
1152
|
+
const uiAutoImports = autoImports.filter((name) => !isLucideIcon(name));
|
|
1153
|
+
const missingComponents = uiAutoImports.filter((name) => !availableComponents.includes(name));
|
|
1154
|
+
if (missingComponents.length) logger.warn(`${slug}.mdx: previews require ${missingComponents.sort().join(", ")}; keeping their source examples without executing them.`);
|
|
1116
1155
|
const mdx = buildMdx({
|
|
1117
1156
|
importName,
|
|
1118
1157
|
importPath,
|
|
@@ -1125,6 +1164,7 @@ async function main() {
|
|
|
1125
1164
|
examples,
|
|
1126
1165
|
examplesSections: parsedExamplesSections,
|
|
1127
1166
|
componentFolderMap,
|
|
1167
|
+
availableComponents,
|
|
1128
1168
|
autoImports: uiAutoImports,
|
|
1129
1169
|
lucideIcons,
|
|
1130
1170
|
primaryExampleMDX,
|
|
@@ -1145,7 +1185,9 @@ async function main() {
|
|
|
1145
1185
|
}
|
|
1146
1186
|
spin.succeed(`Created ${generatedCount} file${generatedCount === 1 ? "" : "s"}:`);
|
|
1147
1187
|
components.map((c) => {
|
|
1148
|
-
|
|
1188
|
+
const slug = slugify(c.name);
|
|
1189
|
+
const outFile = join(outDir, `${slug}.mdx`);
|
|
1190
|
+
return relative(cwd, outFile);
|
|
1149
1191
|
}).sort((a, b) => a.localeCompare(b)).forEach((p) => {
|
|
1150
1192
|
logger.log(` - ${p}`);
|
|
1151
1193
|
});
|
|
@@ -1161,4 +1203,4 @@ if (process.env.BEJAMAS_SKIP_AUTO_RUN !== "1" && process.env.BEJAMAS_SKIP_AUTO_R
|
|
|
1161
1203
|
|
|
1162
1204
|
//#endregion
|
|
1163
1205
|
export { runDocsGenerator };
|
|
1164
|
-
//# sourceMappingURL=generate-mdx-
|
|
1206
|
+
//# sourceMappingURL=generate-mdx-Bd_qGcMg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-mdx-Bd_qGcMg.js","names":["titleEx"],"sources":["../src/docs/generate-mdx/examples.ts","../src/docs/generate-mdx/mdx-builder.ts","../src/docs/generate-mdx/index.ts"],"sourcesContent":["export interface ParsedExampleItem {\n title: string;\n body: string;\n}\n\nexport interface ParsedExampleSection {\n /**\n * Null means \"implicit section\" (no explicit ## heading in @examples).\n */\n title: string | null;\n /**\n * Markdown text that appears between a ## section heading and the first ### item.\n * For implicit sections, this is content before the first ### heading.\n */\n introMD: string;\n items: ParsedExampleItem[];\n}\n\nexport interface PreparedExampleContent {\n descriptionMD: string;\n /**\n * Renderable snippet used in preview (markup only).\n */\n snippet: string;\n /**\n * Source code shown in the code block.\n */\n sourceCode: string;\n /**\n * True when source came from an explicit ```astro fenced block.\n */\n sourceFromFence: boolean;\n /**\n * True when the fenced astro block includes the `nopreview` flag.\n */\n skipPreview: boolean;\n /**\n * True when the fenced astro block includes the `console` flag.\n */\n enableConsolePanel: boolean;\n /**\n * Explicit console scripts sourced from an adjacent JS/TS fence.\n */\n consoleScripts: string[];\n /**\n * Raw markdown for a paired source fence that should render after the astro block.\n */\n companionSourceMD: string;\n /**\n * Markdown that appears between the astro fence and its paired JS/TS fence.\n */\n companionIntroMD: string;\n /**\n * Markdown that appears after a paired JS/TS fence.\n */\n trailingDescriptionMD: string;\n /**\n * True when the paired JS/TS fence had no prose between it and the astro fence.\n */\n mergeCompanionWithSource: boolean;\n}\n\nexport interface FenceInfo {\n lang: string;\n flags: Set<string>;\n}\n\ninterface PreviewRenderConfig {\n defaultPreview?: boolean;\n allowForcedPreview?: boolean;\n}\n\ntype MutableSection = {\n title: string | null;\n intro: string[];\n items: Array<{ title: string; body: string[] }>;\n};\n\ntype MutableItem = { title: string; body: string[] };\n\nfunction createImplicitSection(): MutableSection {\n return { title: null, intro: [], items: [] };\n}\n\nfunction normalizeSection(section: MutableSection): ParsedExampleSection {\n return {\n title: section.title,\n introMD: section.intro.join(\"\\n\").trim(),\n items: section.items.map((item) => ({\n title: item.title,\n body: item.body.join(\"\\n\").trim(),\n })),\n };\n}\n\nfunction pushItem(section: MutableSection | null, item: MutableItem | null): void {\n if (!section || !item) return;\n if (!item.title.trim().length && !item.body.join(\"\\n\").trim().length) return;\n section.items.push(item);\n}\n\nfunction pushSection(\n sections: ParsedExampleSection[],\n section: MutableSection | null,\n): void {\n if (!section) return;\n const normalized = normalizeSection(section);\n if (\n !normalized.title &&\n !normalized.introMD.length &&\n normalized.items.length === 0\n ) {\n return;\n }\n sections.push(normalized);\n}\n\nfunction extractHeading(line: string, level: 2 | 3): string | null {\n const pattern = level === 2 ? /^##(?!#)\\s+(.+)$/ : /^###(?!#)\\s+(.+)$/;\n const match = line.trim().match(pattern);\n return match ? match[1].trim() : null;\n}\n\nfunction splitDescriptionAndSnippetRaw(body: string): {\n descriptionMD: string;\n snippet: string;\n} {\n if (!body || !body.trim().length) return { descriptionMD: \"\", snippet: \"\" };\n const lines = body.split(\"\\n\");\n let snippetStartIdx = -1;\n for (let i = 0; i < lines.length; i += 1) {\n const ln = lines[i];\n if (!ln.trim().length) continue;\n if (/^\\s*[<{]/.test(ln)) {\n snippetStartIdx = i;\n break;\n }\n }\n if (snippetStartIdx <= 0) {\n return { descriptionMD: \"\", snippet: body.trim() };\n }\n return {\n descriptionMD: lines.slice(0, snippetStartIdx).join(\"\\n\").trim(),\n snippet: lines.slice(snippetStartIdx).join(\"\\n\").trim(),\n };\n}\n\nfunction splitAstroFrontmatter(sourceCode: string): {\n frontmatter: string;\n markup: string;\n} {\n const match = sourceCode.match(/^---\\n([\\s\\S]*?)\\n---\\n?([\\s\\S]*)$/);\n if (!match) {\n return { frontmatter: \"\", markup: sourceCode.trim() };\n }\n return {\n frontmatter: match[1].trim(),\n markup: match[2].trim(),\n };\n}\n\nfunction stripFrontmatterComments(frontmatter: string): string {\n if (!frontmatter || !frontmatter.length) return \"\";\n return frontmatter\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\\n\")\n .replace(/^[ \\t]*\\/\\/.*$/gm, \"\")\n .trim();\n}\n\nfunction isImportOnlyFrontmatter(frontmatter: string): boolean {\n const cleaned = stripFrontmatterComments(frontmatter);\n if (!cleaned.length) return true;\n\n let remaining = cleaned;\n const importFromPattern =\n /(?:^|\\n)\\s*import\\s+(?:type\\s+)?[\\s\\S]*?\\s+from\\s+['\"][^'\"]+['\"]\\s*;?(?=\\n|$)/g;\n const importSideEffectPattern =\n /(?:^|\\n)\\s*import\\s+['\"][^'\"]+['\"]\\s*;?(?=\\n|$)/g;\n const exportFromPattern =\n /(?:^|\\n)\\s*export\\s+(?:\\*\\s+from|\\{[\\s\\S]*?\\}\\s+from)\\s+['\"][^'\"]+['\"]\\s*;?(?=\\n|$)/g;\n\n remaining = remaining\n .replace(importFromPattern, \"\\n\")\n .replace(importSideEffectPattern, \"\\n\")\n .replace(exportFromPattern, \"\\n\")\n .trim();\n\n return remaining.replace(/[;\\s]/g, \"\").length === 0;\n}\n\nfunction isAstroFrontmatterPreviewUnsafe(frontmatter: string): boolean {\n const cleaned = stripFrontmatterComments(frontmatter);\n if (!cleaned.length) return false;\n\n const runtimeTokenPattern =\n /\\b(?:const|let|var|function|class|if|for|while|switch|try|catch|return|throw|await|new)\\b|=>|Astro\\./;\n if (runtimeTokenPattern.test(cleaned)) return true;\n\n return !isImportOnlyFrontmatter(cleaned);\n}\n\nexport function parseFenceInfo(infoRaw: string): FenceInfo {\n const parts = (infoRaw || \"\")\n .trim()\n .split(/\\s+/)\n .filter((v) => v.length)\n .map((v) => v.toLowerCase());\n if (!parts.length) return { lang: \"\", flags: new Set<string>() };\n const [lang, ...flags] = parts;\n return { lang, flags: new Set(flags) };\n}\n\nexport function decodeEscapedScriptTags(source: string): string {\n if (!source || !source.length) return source;\n return source\n .replace(/<script>/gi, \"<script>\")\n .replace(/<\\/script>/gi, \"</script>\");\n}\n\ntype ParsedFenceBlock = {\n openLine: string;\n closeLine: string;\n lang: string;\n flags: Set<string>;\n body: string;\n startLine: number;\n endLine: number;\n};\n\nconst CONSOLE_SCRIPT_FENCE_LANGS = new Set([\n \"js\",\n \"ts\",\n \"javascript\",\n \"typescript\",\n]);\n\nfunction parseFenceBlocks(body: string): {\n lines: string[];\n fences: ParsedFenceBlock[];\n} {\n const lines = body.split(\"\\n\");\n const fences: ParsedFenceBlock[] = [];\n let active:\n | {\n startLine: number;\n openLine: string;\n lang: string;\n flags: Set<string>;\n bodyLines: string[];\n }\n | null = null;\n\n for (let i = 0; i < lines.length; i += 1) {\n const line = lines[i];\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"```\")) {\n if (active) active.bodyLines.push(line);\n continue;\n }\n\n if (!active) {\n const parsed = parseFenceInfo(trimmed.slice(3).trim());\n active = {\n startLine: i,\n openLine: line,\n lang: parsed.lang,\n flags: parsed.flags,\n bodyLines: [],\n };\n continue;\n }\n\n fences.push({\n openLine: active.openLine,\n closeLine: line,\n lang: active.lang,\n flags: active.flags,\n body: active.bodyLines.join(\"\\n\"),\n startLine: active.startLine,\n endLine: i,\n });\n active = null;\n }\n\n return { lines, fences };\n}\n\nfunction serializeFenceBlock(fence: ParsedFenceBlock): string {\n const parts = [fence.openLine];\n if (fence.body.length) parts.push(fence.body);\n parts.push(fence.closeLine);\n return parts.join(\"\\n\");\n}\n\nfunction buildRemainingMarkdown(\n lines: string[],\n fences: ParsedFenceBlock[],\n consumedFenceIndexes: Set<number>,\n): string {\n const skippedLines = new Set<number>();\n for (const [index, fence] of fences.entries()) {\n if (!consumedFenceIndexes.has(index)) continue;\n for (let line = fence.startLine; line <= fence.endLine; line += 1) {\n skippedLines.add(line);\n }\n }\n\n return lines\n .filter((_, index) => !skippedLines.has(index))\n .join(\"\\n\")\n .trim();\n}\n\nfunction extractFirstAstroFence(body: string): {\n sourceCode: string;\n descriptionMD: string;\n skipPreview: boolean;\n enableConsolePanel: boolean;\n consoleScripts: string[];\n companionSourceMD: string;\n companionIntroMD: string;\n trailingDescriptionMD: string;\n mergeCompanionWithSource: boolean;\n} | null {\n if (!body || !body.trim().length) return null;\n const { lines, fences } = parseFenceBlocks(body);\n const astroFenceIndex = fences.findIndex((fence) => fence.lang === \"astro\");\n if (astroFenceIndex === -1) return null;\n\n const astroFence = fences[astroFenceIndex];\n const consumedFenceIndexes = new Set<number>([astroFenceIndex]);\n let companionSourceMD = \"\";\n let consoleScripts: string[] = [];\n let companionIntroMD = \"\";\n let trailingDescriptionMD = \"\";\n let mergeCompanionWithSource = false;\n\n if (astroFence.flags.has(\"console\")) {\n const nextFence = fences[astroFenceIndex + 1];\n if (nextFence && CONSOLE_SCRIPT_FENCE_LANGS.has(nextFence.lang)) {\n consumedFenceIndexes.add(astroFenceIndex + 1);\n companionSourceMD = serializeFenceBlock(nextFence);\n companionIntroMD = lines\n .slice(astroFence.endLine + 1, nextFence.startLine)\n .join(\"\\n\")\n .trim();\n trailingDescriptionMD = lines.slice(nextFence.endLine + 1).join(\"\\n\").trim();\n mergeCompanionWithSource = companionIntroMD.length === 0;\n const normalizedScript = nextFence.body.trim();\n if (normalizedScript.length) {\n consoleScripts = [normalizedScript];\n }\n }\n }\n\n const descriptionMD = companionSourceMD.length\n ? lines.slice(0, astroFence.startLine).join(\"\\n\").trim()\n : buildRemainingMarkdown(lines, fences, consumedFenceIndexes);\n\n return {\n sourceCode: decodeEscapedScriptTags(astroFence.body.trim()),\n descriptionMD,\n skipPreview: astroFence.flags.has(\"nopreview\"),\n enableConsolePanel: astroFence.flags.has(\"console\"),\n consoleScripts,\n companionSourceMD,\n companionIntroMD,\n trailingDescriptionMD,\n mergeCompanionWithSource,\n };\n}\n\nexport function parseExamplesSections(examplesMDX: string): ParsedExampleSection[] {\n if (!examplesMDX || !examplesMDX.trim().length) return [];\n\n const sections: ParsedExampleSection[] = [];\n const lines = examplesMDX.split(\"\\n\");\n let currentSection: MutableSection | null = null;\n let currentItem: MutableItem | null = null;\n let inFence = false;\n\n for (const line of lines) {\n const trimmed = line.trim();\n\n if (trimmed.startsWith(\"```\")) {\n inFence = !inFence;\n if (!currentSection) currentSection = createImplicitSection();\n if (currentItem) currentItem.body.push(line);\n else currentSection.intro.push(line);\n continue;\n }\n\n if (!inFence) {\n const h2 = extractHeading(line, 2);\n if (h2) {\n pushItem(currentSection, currentItem);\n currentItem = null;\n pushSection(sections, currentSection);\n currentSection = { title: h2, intro: [], items: [] };\n continue;\n }\n\n const h3 = extractHeading(line, 3);\n if (h3) {\n if (!currentSection) currentSection = createImplicitSection();\n pushItem(currentSection, currentItem);\n currentItem = { title: h3, body: [] };\n continue;\n }\n }\n\n if (!currentSection) currentSection = createImplicitSection();\n if (currentItem) currentItem.body.push(line);\n else currentSection.intro.push(line);\n }\n\n pushItem(currentSection, currentItem);\n pushSection(sections, currentSection);\n return sections;\n}\n\nexport function prepareExampleContent(body: string): PreparedExampleContent {\n if (!body || !body.trim().length) {\n return {\n descriptionMD: \"\",\n snippet: \"\",\n sourceCode: \"\",\n sourceFromFence: false,\n skipPreview: false,\n enableConsolePanel: false,\n consoleScripts: [],\n companionSourceMD: \"\",\n companionIntroMD: \"\",\n trailingDescriptionMD: \"\",\n mergeCompanionWithSource: false,\n };\n }\n\n const fenced = extractFirstAstroFence(body);\n if (fenced) {\n const { frontmatter, markup } = splitAstroFrontmatter(fenced.sourceCode);\n const unsafeFrontmatter = isAstroFrontmatterPreviewUnsafe(frontmatter);\n return {\n descriptionMD: fenced.descriptionMD,\n snippet: markup,\n sourceCode: fenced.sourceCode,\n sourceFromFence: true,\n skipPreview: fenced.skipPreview || unsafeFrontmatter,\n enableConsolePanel: fenced.enableConsolePanel,\n consoleScripts: fenced.consoleScripts,\n companionSourceMD: fenced.companionSourceMD,\n companionIntroMD: fenced.companionIntroMD,\n trailingDescriptionMD: fenced.trailingDescriptionMD,\n mergeCompanionWithSource: fenced.mergeCompanionWithSource,\n };\n }\n\n const split = splitDescriptionAndSnippetRaw(body);\n return {\n descriptionMD: split.descriptionMD,\n snippet: split.snippet,\n sourceCode: split.snippet,\n sourceFromFence: false,\n skipPreview: false,\n enableConsolePanel: false,\n consoleScripts: [],\n companionSourceMD: \"\",\n companionIntroMD: \"\",\n trailingDescriptionMD: \"\",\n mergeCompanionWithSource: false,\n };\n}\n\nfunction extractTags(block: string): string[] {\n if (!block || !block.length) return [];\n const found = new Set<string>();\n const tagRegex = /<([A-Z][A-Za-z0-9_]*)\\b/g;\n let match: RegExpExecArray | null;\n while ((match = tagRegex.exec(block)) !== null) {\n found.add(match[1]);\n }\n return Array.from(found);\n}\n\nexport function extractComponentTagsFromPreviewMarkdown(\n block: string,\n config: PreviewRenderConfig = {},\n): string[] {\n if (!block || !block.length) return [];\n const { defaultPreview = true, allowForcedPreview = true } = config;\n const found = new Set<string>();\n const lines = block.split(\"\\n\");\n let inFence = false;\n let fenceOpen = \"\";\n let currentFenceLang = \"\";\n let currentFenceFlags = new Set<string>();\n const fenceBody: string[] = [];\n\n for (const line of lines) {\n const trimmed = line.trim();\n if (trimmed.startsWith(\"```\")) {\n if (!inFence) {\n inFence = true;\n fenceOpen = line;\n const parsed = parseFenceInfo(trimmed.slice(3).trim());\n currentFenceLang = parsed.lang;\n currentFenceFlags = parsed.flags;\n fenceBody.length = 0;\n continue;\n }\n\n if (currentFenceLang === \"astro\") {\n const sourceCode = fenceBody.join(\"\\n\").trim();\n const prepared = prepareExampleContent(\n `${fenceOpen}\\n${sourceCode}\\n${line}`,\n );\n const hasForcedPreviewFlag =\n currentFenceFlags.has(\"preview\") || currentFenceFlags.has(\"console\");\n const shouldPreview =\n !prepared.skipPreview &&\n (defaultPreview || (allowForcedPreview && hasForcedPreviewFlag));\n if (shouldPreview) {\n for (const tag of extractTags(prepared.snippet)) found.add(tag);\n }\n }\n\n inFence = false;\n fenceOpen = \"\";\n currentFenceLang = \"\";\n currentFenceFlags = new Set<string>();\n fenceBody.length = 0;\n continue;\n }\n\n if (inFence) {\n fenceBody.push(line);\n continue;\n }\n\n for (const tag of extractTags(line)) found.add(tag);\n }\n\n return Array.from(found);\n}\n\nexport function extractComponentTagsFromExamplesSections(\n sections: ParsedExampleSection[],\n): string[] {\n if (!sections?.length) return [];\n const found = new Set<string>();\n for (const section of sections) {\n for (const tag of extractComponentTagsFromPreviewMarkdown(section.introMD)) {\n found.add(tag);\n }\n for (const item of section.items) {\n const prepared = prepareExampleContent(item.body);\n if (prepared.skipPreview) continue;\n for (const tag of extractTags(prepared.snippet)) found.add(tag);\n }\n }\n return Array.from(found);\n}\n","import {\n decodeEscapedScriptTags,\n extractComponentTagsFromPreviewMarkdown,\n parseFenceInfo,\n prepareExampleContent,\n type ParsedExampleSection,\n} from \"./examples\";\n\nimport { RESERVED_COMPONENTS } from \"./utils\";\n\n/**\n * Check if an import path uses the new barrel export pattern (no .astro extension)\n */\nfunction isBarrelImport(path: string): boolean {\n return !path.endsWith(\".astro\");\n}\n\n/**\n * Convert a PascalCase component name to its folder path (kebab-case).\n * Examples:\n * - \"Card\" → \"card\"\n * - \"CardHeader\" → \"card\"\n * - \"InputGroup\" → \"input-group\"\n * - \"InputGroupAddon\" → \"input-group\"\n * - \"StickySurface\" → \"sticky-surface\"\n * - \"RadioGroup\" → \"radio-group\"\n * - \"RadioGroupItem\" → \"radio-group\"\n */\nfunction componentToFolder(name: string): string {\n // Known multi-word component families (in PascalCase order)\n // These map to kebab-case folder names\n const multiWordFamilies = [\n \"InputGroup\",\n \"LinkGroup\",\n \"RadioGroup\",\n \"ButtonGroup\",\n \"StickySurface\",\n \"DropdownMenu\",\n \"NavigationMenu\",\n \"ContextMenu\",\n \"HoverCard\",\n \"ToggleGroup\",\n ];\n\n // Check for multi-word families first (order matters - longer matches first)\n const sortedFamilies = multiWordFamilies.sort((a, b) => b.length - a.length);\n for (const family of sortedFamilies) {\n if (name === family || name.startsWith(family)) {\n // InputGroup → input-group\n return family.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n }\n }\n\n // For regular names, extract the base component (first PascalCase word)\n // CardHeader → Card → card\n // AvatarFallback → Avatar → avatar\n const baseMatch = name.match(/^[A-Z][a-z]*/);\n return baseMatch ? baseMatch[0].toLowerCase() : name.toLowerCase();\n}\n\nfunction resolveComponentFolder(\n name: string,\n componentFolderMap?: Record<string, string>,\n): string {\n if (!componentFolderMap) return componentToFolder(name);\n const direct = componentFolderMap[name];\n if (direct && direct.length) return direct;\n\n return componentToFolder(name);\n}\n\n/**\n * Group component names by their folder path\n */\nfunction groupComponentsByFolder(\n components: string[],\n componentFolderMap?: Record<string, string>,\n): Map<string, string[]> {\n const groups = new Map<string, string[]>();\n for (const comp of components) {\n const folder = resolveComponentFolder(comp, componentFolderMap);\n if (!groups.has(folder)) {\n groups.set(folder, []);\n }\n groups.get(folder)!.push(comp);\n }\n return groups;\n}\n\n/**\n * Generate import lines for UI components using the barrel import pattern\n */\nfunction generateBarrelImports(\n components: string[],\n componentsAlias: string,\n componentFolderMap?: Record<string, string>,\n): string[] {\n const groups = groupComponentsByFolder(components, componentFolderMap);\n const lines: string[] = [];\n\n // Sort folders alphabetically for consistent output\n const sortedFolders = Array.from(groups.keys()).sort();\n\n for (const folder of sortedFolders) {\n const names = groups.get(folder)!.sort();\n if (folder.endsWith(\".astro\")) {\n for (const name of names)\n lines.push(`import ${name} from '${componentsAlias}/${folder}';`);\n continue;\n }\n lines.push(\n `import { ${names.join(\", \")} } from '${componentsAlias}/${folder}';`,\n );\n }\n\n return lines;\n}\n\n/**\n * Generate import lines for UI components using the old default import pattern\n */\nfunction generateDefaultImports(\n components: string[],\n componentsAlias: string,\n): string[] {\n return components\n .slice()\n .sort()\n .map((name) => `import ${name} from '${componentsAlias}/${name}.astro';`);\n}\n\nexport function buildMdx(params: {\n importName: string;\n importPath: string;\n title: string;\n description: string;\n descriptionBodyMDX?: string;\n figmaUrl?: string;\n usageMDX: string;\n hasImport: boolean;\n propsList: string;\n propsTable?: Array<{\n name: string;\n type?: string;\n required?: boolean;\n defaultValue?: string | null;\n description?: string | null;\n }>;\n examples: Array<{\n importName: string;\n importPath: string;\n title: string;\n source: string;\n }>;\n examplesSections: ParsedExampleSection[];\n componentFolderMap?: Record<string, string>;\n availableComponents?: string[];\n autoImports: string[];\n lucideIcons: string[];\n primaryExampleMDX: string;\n componentSource: string;\n commandName: string;\n componentsAlias: string;\n /**\n * Optional: additional named exports from the main component's barrel.\n * Used when the main component has subcomponents (e.g., Card, CardHeader, CardTitle).\n * If provided, these will be included in the main import statement.\n */\n namedExports?: string[];\n /**\n * Optional: API reference documentation (events, programmatic control, data attributes).\n */\n apiMDX?: string;\n}): string {\n const {\n importName,\n importPath,\n title,\n description,\n descriptionBodyMDX,\n usageMDX,\n hasImport,\n propsList,\n propsTable,\n examples,\n examplesSections,\n componentFolderMap,\n autoImports,\n lucideIcons,\n primaryExampleMDX,\n componentSource,\n commandName,\n figmaUrl,\n componentsAlias,\n namedExports,\n apiMDX,\n } = params;\n\n const available = params.availableComponents\n ? new Set(params.availableComponents)\n : null;\n const missingFromNames = (names: string[]) =>\n names.filter(\n (name) =>\n available &&\n !available.has(name) &&\n !RESERVED_COMPONENTS.has(name) &&\n !/Icon$/.test(name),\n );\n const missingFromSnippet = (snippet: string) =>\n missingFromNames([\n ...new Set(\n [...snippet.matchAll(/<([A-Z][A-Za-z0-9_]*)\\b/g)].map(\n (match) => match[1],\n ),\n ),\n ]);\n const missingNotice = (names: string[]) => {\n const components = [\n ...new Set(\n names.map((name) => resolveComponentFolder(name, componentFolderMap)),\n ),\n ].sort();\n return `> Preview unavailable. Run \\`bejamas add ${components.join(\" \")}\\` to install the required components, then regenerate the docs.`;\n };\n\n // Detect if we should use the new barrel import pattern\n const useBarrelPattern = isBarrelImport(importPath);\n\n const sortedLucide = (lucideIcons ?? []).slice().sort();\n const lucideTopLine = sortedLucide.length\n ? `import { ${sortedLucide.join(\", \")} } from '@lucide/astro';`\n : null;\n const externalTopImports = [\n `import { Tabs as DocsTabs, TabItem as DocsTabItem } from '@astrojs/starlight/components';`,\n lucideTopLine,\n ]\n .filter((v) => v != null)\n .slice()\n .sort((a, b) => String(a).localeCompare(String(b)));\n\n const sortedUiAuto = (autoImports ?? [])\n .filter((name) => !available || available.has(name))\n .slice()\n .sort();\n\n // Generate UI component imports based on pattern\n const uiAutoLines =\n useBarrelPattern || componentFolderMap\n ? generateBarrelImports(sortedUiAuto, componentsAlias, componentFolderMap)\n : generateDefaultImports(sortedUiAuto, componentsAlias);\n\n const exampleLines = (examples ?? [])\n .filter((ex) => !missingFromSnippet(ex.source).length)\n .map((ex) => `import ${ex.importName} from '${ex.importPath}';`)\n .sort((a, b) => a.localeCompare(b));\n\n // Build main component import\n let mainImportLine: string | null = null;\n if (!hasImport) {\n if (useBarrelPattern) {\n // New pattern: named exports\n const exports = [importName, ...(namedExports ?? [])].sort();\n mainImportLine = `import { ${exports.join(\", \")} } from '${importPath}';`;\n } else {\n // Old pattern: default export\n mainImportLine = `import ${importName} from '${importPath}';`;\n }\n }\n\n const internalTopImports = [mainImportLine, ...uiAutoLines, ...exampleLines]\n .filter((v) => v != null)\n .slice()\n .sort((a, b) => String(a).localeCompare(String(b)));\n\n const importLines = [\n ...externalTopImports,\n externalTopImports.length && internalTopImports.length ? \"\" : null,\n ...internalTopImports,\n ].filter((v) => v !== null && v !== undefined);\n\n // Helper: build per-snippet imports so code fences are minimal and copy-pasteable\n const extractTags = (snippet: string): Set<string> => {\n const found = new Set<string>();\n const tagRegex = /<([A-Z][A-Za-z0-9_]*)\\b/g;\n let m: RegExpExecArray | null;\n while ((m = tagRegex.exec(snippet)) !== null) {\n found.add(m[1]);\n }\n return found;\n };\n\n const buildSnippetImportLines = (snippet: string): string[] => {\n if (!snippet || !snippet.length) return [];\n const used = extractTags(snippet);\n const usedIcons = sortedLucide.filter((n) => used.has(n));\n\n // Find UI components used in snippet\n const usedUi = (autoImports ?? []).filter((n) => used.has(n));\n\n // Check if main component (and its subcomponents) are used\n const includeMain = !hasImport && used.has(importName);\n\n // For new pattern, also check for subcomponents from the main barrel\n const usedNamedExports =\n useBarrelPattern && namedExports\n ? namedExports.filter((n) => used.has(n))\n : [];\n\n const external: string[] = [];\n if (usedIcons.length) {\n external.push(`import { ${usedIcons.join(\", \")} } from '@lucide/astro';`);\n }\n\n const internal: string[] = [];\n\n if (useBarrelPattern) {\n // New pattern: group by folder and use named imports\n\n // Main component and its subcomponents\n if (includeMain || usedNamedExports.length > 0) {\n const mainExports = [\n ...(includeMain ? [importName] : []),\n ...usedNamedExports,\n ].sort();\n internal.push(\n `import { ${mainExports.join(\", \")} } from '${importPath}';`,\n );\n }\n\n // Other UI components grouped by folder\n if (usedUi.length > 0) {\n internal.push(\n ...generateBarrelImports(usedUi, componentsAlias, componentFolderMap),\n );\n }\n } else {\n // Old pattern: default imports\n if (includeMain) {\n internal.push(`import ${importName} from '${importPath}';`);\n }\n internal.push(\n ...(componentFolderMap\n ? generateBarrelImports(usedUi, componentsAlias, componentFolderMap)\n : generateDefaultImports(usedUi, componentsAlias)),\n );\n }\n\n const externalSorted = external.slice().sort((a, b) => a.localeCompare(b));\n const internalSorted = internal.slice().sort((a, b) => a.localeCompare(b));\n return [\n ...externalSorted,\n externalSorted.length && internalSorted.length ? \"\" : null,\n ...internalSorted,\n ].filter((v) => v !== null && v !== undefined) as string[];\n };\n\n let consolePreviewCounter = 0;\n\n const wrapTextNodes = (snippet: string): string => {\n if (!snippet) return snippet;\n return snippet.replace(/>([^<]+)</g, (match, inner) => {\n const trimmed = inner.trim();\n if (!trimmed.length) return match;\n // Skip if the entire trimmed content is a JSX expression\n if (/^\\{[\\s\\S]*\\}$/.test(trimmed)) return match;\n // Skip if the content already contains JSX expressions (e.g., \"Use{\\\" \\\"}\" or mixed content)\n // This prevents double-wrapping and breaking inline JSX whitespace expressions\n if (/\\{[^}]*\\}/.test(inner)) return match;\n return `>{${JSON.stringify(inner)}}<`;\n });\n };\n\n /**\n * Normalize whitespace in preview content.\n * This collapses ALL newlines and multiple spaces into single spaces to prevent\n * MDX parsing issues. In particular, a '>' at the start of a line is interpreted\n * as a block quote marker by MDX, which causes \"Unexpected lazy line\" errors.\n */\n const normalizeInlineWhitespace = (snippet: string): string => {\n if (!snippet) return snippet;\n // Collapse ALL newlines and multiple whitespace into single spaces\n // This prevents MDX from interpreting '>' at start of line as block quote\n return snippet.replace(/\\s+/g, \" \").trim();\n };\n\n /**\n * Convert <p> tags that contain component tags to <span> tags.\n * This is necessary because components may render as block elements (like <div>),\n * and HTML doesn't allow block elements inside <p>. The browser would automatically\n * close the <p> before any block element, breaking the layout.\n */\n const convertParagraphsWithComponents = (snippet: string): string => {\n if (!snippet) return snippet;\n // Detect if a <p> tag contains component tags (PascalCase like <KbdGroup>)\n // If so, convert <p> to <span> to allow block-level children\n return snippet.replace(\n /<p(\\s[^>]*)?>([^]*?)<\\/p>/gi,\n (match, attrs, content) => {\n // Check if content contains component tags (PascalCase)\n if (/<[A-Z][A-Za-z0-9]*/.test(content)) {\n // Convert to span with inline-block display to preserve paragraph-like behavior\n const spanAttrs = attrs || \"\";\n return `<span${spanAttrs} style=\"display:block\">${content}</span>`;\n }\n return match;\n },\n );\n };\n\n type PreviewRenderOptions = {\n enableConsolePanel?: boolean;\n consoleScripts?: string[];\n };\n\n type MarkdownPreviewConfig = {\n defaultPreview?: boolean;\n allowForcedPreview?: boolean;\n };\n\n const extractInlineScripts = (\n snippet: string,\n ): {\n markup: string;\n scripts: string[];\n } => {\n if (!snippet) return { markup: snippet, scripts: [] };\n const scripts: string[] = [];\n const markup = snippet.replace(\n /<script\\b[^>]*>([\\s\\S]*?)<\\/script>/gi,\n (_, scriptBody: string) => {\n scripts.push((scriptBody || \"\").trim());\n return \"\";\n },\n );\n return { markup, scripts };\n };\n\n const toMdxPreview = (\n snippet: string,\n options: PreviewRenderOptions = {},\n ): { markup: string; scripts: string[] } => {\n if (!snippet) return { markup: \"\", scripts: [] };\n const { enableConsolePanel = false, consoleScripts = [] } = options;\n const extracted = extractInlineScripts(snippet);\n const resolvedConsoleScripts =\n enableConsolePanel && consoleScripts.length\n ? consoleScripts\n : enableConsolePanel\n ? extracted.scripts\n : [];\n const withoutScripts = extracted.markup;\n // Convert HTML comments to MDX comment blocks for preview sections\n const withoutComments = withoutScripts.replace(\n /<!--([\\s\\S]*?)-->/g,\n \"{/*$1*/}\",\n );\n // Convert <p> tags containing components to <span> to avoid HTML validity issues\n const withConvertedParagraphs =\n convertParagraphsWithComponents(withoutComments);\n // If the snippet contains user-defined <p> elements, preserve structure as-is\n if (/<p[\\s>]/i.test(withConvertedParagraphs)) {\n return {\n markup: normalizeInlineWhitespace(withConvertedParagraphs),\n scripts: resolvedConsoleScripts,\n };\n }\n // Normalize whitespace to prevent MDX from splitting inline text into paragraphs\n const normalized = normalizeInlineWhitespace(withConvertedParagraphs);\n return {\n markup: wrapTextNodes(normalized),\n scripts: resolvedConsoleScripts,\n };\n };\n\n const buildConsoleRuntimeSource = (\n rootId: string,\n panelId: string,\n userScript: string,\n ): string => {\n const serializedRootId = JSON.stringify(rootId);\n const serializedPanelId = JSON.stringify(panelId);\n const serializedUserScript = JSON.stringify(userScript);\n\n return `(function () {\n var root = document.getElementById(${serializedRootId});\n var panel = document.getElementById(${serializedPanelId});\n if (!root || !panel) return;\n\n var placeholder = panel.textContent || \"Waiting for logs...\";\n var hasLogs = false;\n\n var toText = function (value) {\n if (typeof value === \"string\") return value;\n if (value === undefined) return \"undefined\";\n if (value === null) return \"null\";\n try {\n return JSON.stringify(value);\n } catch (_error) {\n return String(value);\n }\n };\n\n var append = function (level, args) {\n var stamp = new Date().toLocaleTimeString();\n var body = Array.prototype.map.call(args, toText).join(\" \");\n var line = \"[\" + stamp + \"] \" + String(level).toUpperCase() + \": \" + body;\n var current = panel.textContent || \"\";\n if (!hasLogs && current.trim() === placeholder.trim()) {\n panel.textContent = line;\n } else {\n panel.textContent = current ? current + \"\\\\n\" + line : line;\n }\n hasLogs = true;\n panel.scrollTop = panel.scrollHeight;\n };\n\n var methods = [\"log\", \"info\", \"warn\", \"error\"];\n var proxyConsole = Object.create(console);\n for (var i = 0; i < methods.length; i += 1) {\n (function (methodName) {\n var fallback = typeof console.log === \"function\" ? console.log.bind(console) : function () {};\n var original =\n typeof console[methodName] === \"function\"\n ? console[methodName].bind(console)\n : fallback;\n proxyConsole[methodName] = function () {\n var args = Array.prototype.slice.call(arguments);\n original.apply(console, args);\n append(methodName, args);\n };\n })(methods[i]);\n }\n\n try {\n var run = new Function(\"console\", \"root\", \"panel\", ${serializedUserScript});\n run(proxyConsole, root, panel);\n } catch (error) {\n var fallbackError = typeof console.error === \"function\" ? console.error.bind(console) : function () {};\n fallbackError(error);\n append(\"error\", [error]);\n }\n})();`;\n };\n\n const renderConsoleScripts = (\n rootId: string,\n panelId: string,\n scripts: string[],\n ): string => {\n if (!scripts.length) return \"\";\n return scripts\n .filter((script) => script && script.trim().length)\n .map((script) => {\n const runtimeSource = buildConsoleRuntimeSource(\n rootId,\n panelId,\n script,\n );\n const encoded = encodeURIComponent(runtimeSource);\n return `<script type=\"module\" src=\"data:text/javascript;charset=utf-8,${encoded}\"></script>`;\n })\n .join(\"\\n\");\n };\n\n const renderCompanionSourceMD = (sourceMD: string): string => {\n if (!sourceMD || !sourceMD.trim().length) return \"\";\n const normalizedSourceMD = sourceMD.trim();\n const match = normalizedSourceMD.match(\n /^```(\\S*)([^\\n]*)\\n([\\s\\S]*?)\\n```$/,\n );\n if (!match) return sourceMD;\n\n const [, langRaw = \"\", flagsRaw = \"\", body = \"\"] = match;\n const lang = langRaw.trim().toLowerCase();\n if (![\"js\", \"ts\", \"javascript\", \"typescript\"].includes(lang)) {\n return sourceMD;\n }\n\n const astroInfo = [\"astro\", flagsRaw.trim()].filter(Boolean).join(\" \");\n const scriptBody = body.replace(/\\s+$/, \"\");\n return [\n `\\`\\`\\`${astroInfo}`,\n \"<script>\",\n scriptBody,\n \"</script>\",\n \"```\",\n ].join(\"\\n\");\n };\n\n const extractCompanionScriptBody = (sourceMD: string): string => {\n if (!sourceMD || !sourceMD.trim().length) return \"\";\n const normalizedSourceMD = sourceMD.trim();\n const match = normalizedSourceMD.match(\n /^```(\\S*)([^\\n]*)\\n([\\s\\S]*?)\\n```$/,\n );\n if (!match) return \"\";\n\n const [, langRaw = \"\", , body = \"\"] = match;\n const lang = langRaw.trim().toLowerCase();\n if (![\"js\", \"ts\", \"javascript\", \"typescript\"].includes(lang)) {\n return \"\";\n }\n\n return body.replace(/\\s+$/, \"\");\n };\n\n const renderMergedAstroSourceMD = (\n fenceOpen: string,\n sourceBody: string,\n companionSourceMD: string,\n ): string => {\n const scriptBody = extractCompanionScriptBody(companionSourceMD);\n if (!scriptBody.length) {\n return [fenceOpen, sourceBody, \"```\"].filter(Boolean).join(\"\\n\");\n }\n\n const normalizedSourceBody = sourceBody.replace(/\\s+$/, \"\");\n const parts = [fenceOpen];\n if (normalizedSourceBody.length) {\n parts.push(normalizedSourceBody, \"\");\n }\n parts.push(\"<script>\", scriptBody, \"</script>\", \"```\");\n return parts.join(\"\\n\");\n };\n\n const renderPreviewBlock = (\n snippet: string,\n options: PreviewRenderOptions = {},\n ): string => {\n const missing = missingFromSnippet(snippet);\n if (missing.length) return missingNotice(missing);\n const { enableConsolePanel = false } = options;\n const preparedPreview = toMdxPreview(snippet, options);\n if (!preparedPreview.markup || !preparedPreview.markup.length) return \"\";\n\n if (!enableConsolePanel) {\n return `<div class=\"not-content sl-bejamas-component-preview flex justify-center px-4 md:px-10 py-12 border border-border rounded-t-lg min-h-72 items-center\">\n${preparedPreview.markup}\n</div>`;\n }\n\n consolePreviewCounter += 1;\n const rootId = `sl-bejamas-console-preview-${consolePreviewCounter}`;\n const panelId = `${rootId}-output`;\n const scriptTags = renderConsoleScripts(\n rootId,\n panelId,\n preparedPreview.scripts,\n );\n const parts = [\n `<div id=\"${rootId}\" class=\"not-content sl-bejamas-component-preview flex justify-center px-4 md:px-10 py-12 border border-border rounded-t-lg min-h-72 items-center\">`,\n preparedPreview.markup,\n \"</div>\",\n `<div class=\"not-content sl-bejamas-console-log-shell px-4 md:px-10 py-4 border border-border border-t-0\">`,\n `<pre id=\"${panelId}\" data-slot=\"event-log\" class=\"sl-bejamas-console-log w-full p-3 rounded-md bg-muted text-xs font-mono text-muted-foreground min-h-[80px] max-h-[200px] overflow-y-auto\">Waiting for logs...</pre>`,\n scriptTags && scriptTags.length ? scriptTags : null,\n \"</div>\",\n ].filter((part) => part !== null) as string[];\n\n return parts.join(\"\\n\");\n };\n\n const renderAstroPreviewsInMarkdown = (\n block: string,\n config: MarkdownPreviewConfig = {},\n ): string => {\n if (!block || !block.length) return block;\n const missingRaw = missingFromNames(\n extractComponentTagsFromPreviewMarkdown(block, {\n defaultPreview: false,\n allowForcedPreview: false,\n }),\n );\n if (missingRaw.length)\n return `${missingNotice(missingRaw)}\\n\\n\\`\\`\\`\\`mdx\\n${block}\\n\\`\\`\\`\\``;\n const { defaultPreview = true, allowForcedPreview = true } = config;\n\n const lines = block.split(\"\\n\");\n const out: string[] = [];\n let inFence = false;\n let fenceOpen = \"\";\n let currentFenceLang = \"\";\n let currentFenceFlags = new Set<string>();\n const fenceBody: string[] = [];\n\n const findCompanionConsoleFence = (\n startIndex: number,\n ): { start: number; end: number } | null => {\n let index = startIndex;\n while (index < lines.length) {\n const currentLine = lines[index];\n const trimmedLine = currentLine.trim();\n if (!trimmedLine.length || !trimmedLine.startsWith(\"```\")) {\n index += 1;\n continue;\n }\n\n const parsed = parseFenceInfo(trimmedLine.slice(3).trim());\n if (![\"js\", \"ts\", \"javascript\", \"typescript\"].includes(parsed.lang)) {\n return null;\n }\n\n let end = index + 1;\n while (end < lines.length) {\n if (lines[end].trim().startsWith(\"```\")) {\n return { start: index, end };\n }\n end += 1;\n }\n\n return null;\n }\n return null;\n };\n\n for (let lineIndex = 0; lineIndex < lines.length; lineIndex += 1) {\n const line = lines[lineIndex];\n const trimmed = line.trim();\n if (trimmed.startsWith(\"```\")) {\n if (!inFence) {\n inFence = true;\n fenceOpen = line;\n const parsed = parseFenceInfo(trimmed.slice(3).trim());\n currentFenceLang = parsed.lang;\n currentFenceFlags = parsed.flags;\n fenceBody.length = 0;\n continue;\n }\n\n if (currentFenceLang === \"astro\") {\n const sourceCode = decodeEscapedScriptTags(\n fenceBody.join(\"\\n\").trim(),\n );\n const companionConsoleFence = currentFenceFlags.has(\"console\")\n ? findCompanionConsoleFence(lineIndex + 1)\n : null;\n const companionMarkdown = companionConsoleFence\n ? lines\n .slice(lineIndex + 1, companionConsoleFence.end + 1)\n .join(\"\\n\")\n : \"\";\n const prepared = prepareExampleContent(\n companionMarkdown.length\n ? `${fenceOpen}\\n${sourceCode}\\n${line}\\n${companionMarkdown}`\n : `${fenceOpen}\\n${sourceCode}\\n${line}`,\n );\n const hasForcedPreviewFlag =\n currentFenceFlags.has(\"preview\") ||\n currentFenceFlags.has(\"console\");\n const shouldPreview =\n !prepared.skipPreview &&\n (defaultPreview || (allowForcedPreview && hasForcedPreviewFlag));\n if (prepared.snippet && prepared.snippet.length && shouldPreview) {\n const previewBlock = renderPreviewBlock(prepared.snippet, {\n enableConsolePanel: prepared.enableConsolePanel,\n consoleScripts: prepared.consoleScripts,\n });\n if (previewBlock.length) {\n out.push(previewBlock);\n }\n out.push(\"\");\n }\n }\n\n if (currentFenceLang === \"astro\") {\n const normalizedFenceBody = decodeEscapedScriptTags(\n fenceBody.join(\"\\n\"),\n );\n const companionConsoleFence = currentFenceFlags.has(\"console\")\n ? findCompanionConsoleFence(lineIndex + 1)\n : null;\n const companionMarkdown = companionConsoleFence\n ? lines\n .slice(lineIndex + 1, companionConsoleFence.end + 1)\n .join(\"\\n\")\n : \"\";\n const prepared = companionMarkdown.length\n ? prepareExampleContent(\n `${fenceOpen}\\n${normalizedFenceBody}\\n${line}\\n${companionMarkdown}`,\n )\n : null;\n\n if (\n prepared?.companionSourceMD &&\n prepared.companionSourceMD.length &&\n prepared.mergeCompanionWithSource\n ) {\n out.push(\n renderMergedAstroSourceMD(\n fenceOpen,\n normalizedFenceBody,\n prepared.companionSourceMD,\n ),\n );\n if (companionConsoleFence) {\n lineIndex = companionConsoleFence.end;\n }\n } else {\n out.push(fenceOpen);\n if (normalizedFenceBody.length) {\n out.push(...normalizedFenceBody.split(\"\\n\"));\n }\n out.push(line);\n\n if (\n prepared?.companionSourceMD &&\n prepared.companionSourceMD.length &&\n companionConsoleFence\n ) {\n const companionIntro = lines\n .slice(lineIndex + 1, companionConsoleFence.start)\n .join(\"\\n\");\n if (companionIntro.length) {\n out.push(companionIntro);\n }\n out.push(renderCompanionSourceMD(prepared.companionSourceMD));\n lineIndex = companionConsoleFence.end;\n }\n }\n } else {\n out.push(fenceOpen);\n if (fenceBody.length) {\n out.push(...fenceBody);\n }\n out.push(line);\n }\n\n inFence = false;\n fenceOpen = \"\";\n currentFenceLang = \"\";\n currentFenceFlags = new Set<string>();\n fenceBody.length = 0;\n continue;\n }\n\n if (inFence) {\n fenceBody.push(line);\n continue;\n }\n\n out.push(line);\n }\n\n if (inFence) {\n out.push(fenceOpen);\n if (currentFenceLang === \"astro\") {\n const normalizedFenceBody = decodeEscapedScriptTags(\n fenceBody.join(\"\\n\"),\n );\n if (normalizedFenceBody.length) {\n out.push(...normalizedFenceBody.split(\"\\n\"));\n }\n } else if (fenceBody.length) {\n out.push(...fenceBody);\n }\n }\n\n return out.join(\"\\n\").trim();\n };\n\n const renderedDescriptionBodyMDX = renderAstroPreviewsInMarkdown(\n descriptionBodyMDX || \"\",\n );\n const renderedUsageMDX = renderAstroPreviewsInMarkdown(usageMDX || \"\", {\n defaultPreview: false,\n });\n const renderedApiMDX = renderAstroPreviewsInMarkdown(apiMDX || \"\", {\n defaultPreview: false,\n allowForcedPreview: false,\n });\n\n const primaryExampleSection =\n primaryExampleMDX && primaryExampleMDX.length\n ? `${renderPreviewBlock(primaryExampleMDX)}\n\n\\`\\`\\`astro\n${(() => {\n const lines = buildSnippetImportLines(primaryExampleMDX);\n return lines.length ? `---\\n${lines.join(\"\\n\")}\\n---\\n\\n` : \"\";\n})()}${primaryExampleMDX}\n\\`\\`\\``\n : null;\n\n const renderExampleItem = (\n headingLevel: \"###\" | \"####\",\n headingTitle: string,\n body: string,\n ): string => {\n const prepared = prepareExampleContent(body);\n const titleLine = `${headingLevel} ${headingTitle}`;\n const blocks: string[] = [titleLine];\n if (prepared.descriptionMD && prepared.descriptionMD.length) {\n blocks.push(renderAstroPreviewsInMarkdown(prepared.descriptionMD));\n }\n\n if (\n prepared.snippet &&\n prepared.snippet.length &&\n prepared.sourceCode &&\n prepared.sourceCode.length &&\n !prepared.skipPreview\n ) {\n blocks.push(\n renderPreviewBlock(prepared.snippet, {\n enableConsolePanel: prepared.enableConsolePanel,\n consoleScripts: prepared.consoleScripts,\n }),\n );\n }\n\n if (prepared.sourceCode && prepared.sourceCode.length) {\n const sourceBlock = prepared.sourceFromFence\n ? prepared.sourceCode\n : `${(() => {\n const lines = buildSnippetImportLines(prepared.sourceCode);\n return lines.length ? `---\\n${lines.join(\"\\n\")}\\n---\\n\\n` : \"\";\n })()}${prepared.sourceCode}`;\n if (\n prepared.companionSourceMD &&\n prepared.companionSourceMD.length &&\n prepared.mergeCompanionWithSource\n ) {\n blocks.push(\n renderMergedAstroSourceMD(\n \"```astro\",\n sourceBlock,\n prepared.companionSourceMD,\n ),\n );\n } else {\n blocks.push(`\\`\\`\\`astro\n${sourceBlock}\n\\`\\`\\``);\n }\n if (\n prepared.companionIntroMD &&\n prepared.companionIntroMD.length &&\n !prepared.mergeCompanionWithSource\n ) {\n blocks.push(prepared.companionIntroMD);\n }\n if (\n prepared.companionSourceMD &&\n prepared.companionSourceMD.length &&\n !prepared.mergeCompanionWithSource\n ) {\n blocks.push(renderCompanionSourceMD(prepared.companionSourceMD));\n }\n if (\n prepared.trailingDescriptionMD &&\n prepared.trailingDescriptionMD.length\n ) {\n blocks.push(\n renderAstroPreviewsInMarkdown(prepared.trailingDescriptionMD),\n );\n }\n }\n\n return blocks.join(\"\\n\\n\");\n };\n\n const renderedExampleSections: string[] = [];\n if (examplesSections && examplesSections.length) {\n let implicitExampleCounter = 1;\n\n for (const section of examplesSections) {\n const sectionParts: string[] = [];\n const hasSectionTitle = !!(section.title && section.title.length);\n if (hasSectionTitle) {\n sectionParts.push(`### ${section.title}`);\n }\n\n if (section.introMD && section.introMD.length) {\n sectionParts.push(renderAstroPreviewsInMarkdown(section.introMD));\n }\n\n if (section.items && section.items.length) {\n const itemHeadingLevel: \"###\" | \"####\" = hasSectionTitle\n ? \"####\"\n : \"###\";\n for (const item of section.items) {\n sectionParts.push(\n renderExampleItem(itemHeadingLevel, item.title, item.body),\n );\n }\n } else if (\n !hasSectionTitle &&\n section.introMD &&\n section.introMD.length\n ) {\n const prepared = prepareExampleContent(section.introMD);\n if (prepared.snippet && prepared.snippet.length) {\n sectionParts.length = 0;\n sectionParts.push(\n renderExampleItem(\n \"###\",\n `Example ${implicitExampleCounter}`,\n section.introMD,\n ),\n );\n implicitExampleCounter += 1;\n }\n }\n\n if (sectionParts.length) {\n renderedExampleSections.push(sectionParts.join(\"\\n\\n\").trim());\n }\n }\n }\n if (examples && examples.length) {\n for (const ex of examples) {\n renderedExampleSections.push(\n `### ${ex.title}\n\n${\n missingFromSnippet(ex.source).length\n ? missingNotice(missingFromSnippet(ex.source))\n : `<div class=\"not-content\">\n <${ex.importName} />\n</div>`\n}\n\n\\`\\`\\`astro\n${ex.source}\n\\`\\`\\``,\n );\n }\n }\n\n const formatDefault = (val: unknown): string => {\n if (val == null) return \"\";\n let raw = String(val).trim();\n if (!raw.length) return \"\";\n // Normalize curly quotes to ASCII\n raw = raw\n .replace(/[\\u201C\\u201D\\u201E\\u201F]/g, '\"')\n .replace(/[\\u2018\\u2019]/g, \"'\");\n const isSingleQuoted = /^'[^']*'$/.test(raw);\n const isDoubleQuoted = /^\"[^\"]*\"$/.test(raw);\n const isBacktickSimple = /^`[^`]*`$/.test(raw) && raw.indexOf(\"${\") === -1;\n\n let content = raw;\n if (isSingleQuoted || isDoubleQuoted || isBacktickSimple) {\n const inner = raw.slice(1, -1);\n // Re-quote with standard double quotes\n content = `\"${inner}\"`;\n }\n // Escape table pipes\n content = content.replace(/\\|/g, \"\\\\|\");\n // Choose a backtick fence that doesn't appear in content\n const hasTick = content.includes(\"`\");\n const hasDoubleTick = content.includes(\"``\");\n const fence = !hasTick ? \"`\" : !hasDoubleTick ? \"``\" : \"```\";\n return `${fence}${content}${fence}`;\n };\n\n const installationSection = `## Installation\n\n<DocsTabs syncKey=\"pkg\">\n <DocsTabItem label=\"bun\">\n \\`\\`\\`bash\n bunx bejamas add ${commandName}\n \\`\\`\\`\n </DocsTabItem>\n <DocsTabItem label=\"npm\">\n \\`\\`\\`bash\n npx bejamas add ${commandName}\n \\`\\`\\`\n </DocsTabItem>\n <DocsTabItem label=\"pnpm\">\n \\`\\`\\`bash\n pnpm dlx bejamas add ${commandName}\n \\`\\`\\`\n </DocsTabItem>\n <DocsTabItem label=\"yarn\">\n \\`\\`\\`bash\n yarn dlx bejamas add ${commandName}\n \\`\\`\\`\n </DocsTabItem>\n</DocsTabs>`;\n\n const serializeFrontmatter = (\n label: string,\n value?: string,\n ): string | null => {\n if (!value || !value.length) return null;\n return `${label}: ${JSON.stringify(value)}`;\n };\n\n const lines = [\n \"---\",\n serializeFrontmatter(\"title\", title),\n serializeFrontmatter(\"description\", description),\n serializeFrontmatter(\"figmaUrl\", figmaUrl),\n \"---\",\n \"\",\n ...importLines,\n importLines.length ? \"\" : null,\n renderedDescriptionBodyMDX && renderedDescriptionBodyMDX.length\n ? renderedDescriptionBodyMDX\n : null,\n renderedDescriptionBodyMDX && renderedDescriptionBodyMDX.length ? \"\" : null,\n primaryExampleSection,\n primaryExampleSection ? \"\" : null,\n installationSection,\n \"\",\n renderedUsageMDX && renderedUsageMDX.length\n ? `## Usage\\n\\n${renderedUsageMDX}`\n : null,\n \"\",\n propsTable && propsTable.length\n ? `## Props\\n\\n| Prop | Type | Default |\\n|---|---|---|\\n${propsTable\n .map(\n (p) =>\n `| <code>${p.name}</code> | \\`${(p.type || \"\").replace(/\\|/g, \"\\\\|\")}\\` | ${formatDefault(p.defaultValue)} |`,\n )\n .join(\"\\n\")}`\n : propsList\n ? `## Props\\n\\n${propsList}`\n : null,\n (propsTable && propsTable.length) || propsList ? \"\" : null,\n renderedExampleSections.length\n ? `## Examples\\n\\n` + renderedExampleSections.join(\"\\n\\n\")\n : null,\n renderedExampleSections.length ? \"\" : null,\n renderedApiMDX && renderedApiMDX.length\n ? `## API Reference\\n\\n${renderedApiMDX}`\n : null,\n ].filter((v) => v !== null && v !== undefined);\n\n return lines.join(\"\\n\").trim() + \"\\n\";\n}\n","import { mkdirSync, existsSync } from \"fs\";\nimport { readdir, readFile, writeFile } from \"fs/promises\";\nimport { join, extname, dirname, relative, basename } from \"path\";\nimport {\n RESERVED_COMPONENTS,\n slugify,\n extractFrontmatter,\n toIdentifier,\n parseJsDocMetadata,\n extractPropsFromAstroProps,\n extractPropsFromDeclaredProps,\n resolveUiRoot,\n resolveOutDir,\n normalizeUsageMDX,\n normalizeBlockMDX,\n detectHasImportTopLevel,\n discoverExamples,\n extractComponentTagsFromMDX,\n createSourceFileFromFrontmatter,\n} from \"./utils\";\nimport {\n parseExamplesSections,\n extractComponentTagsFromPreviewMarkdown,\n extractComponentTagsFromExamplesSections,\n} from \"./examples\";\nimport { buildMdx } from \"./mdx-builder\";\nimport { logger } from \"@/src/utils/logger\";\nimport { spinner } from \"@/src/utils/spinner\";\nimport { getConfig } from \"@/src/utils/get-config\";\n\ninterface ComponentEntry {\n /** The main component name (PascalCase), e.g., \"Card\" */\n name: string;\n /** Path to the main .astro file */\n filePath: string;\n /** The folder name (lowercase/kebab-case), e.g., \"card\" */\n folderName: string;\n /** Whether this is a folder-based component with barrel exports */\n isFolder: boolean;\n /** List of subcomponent names exported from the barrel, e.g., [\"CardHeader\", \"CardTitle\"] */\n namedExports: string[];\n}\n\n/**\n * Discover components in the components directory.\n * Supports both:\n * - Old pattern: flat .astro files in components/\n * - New pattern: folders with index.ts barrel exports\n */\nasync function discoverComponents(\n componentsDir: string,\n): Promise<ComponentEntry[]> {\n const entries: ComponentEntry[] = [];\n const dirEntries = (\n await readdir(componentsDir, { withFileTypes: true })\n ).sort((a, b) => a.name.localeCompare(b.name));\n\n for (const entry of dirEntries) {\n if (entry.isDirectory()) {\n // New pattern: folder with barrel exports\n const folderPath = join(componentsDir, entry.name);\n const indexPath = join(folderPath, \"index.ts\");\n\n if (existsSync(indexPath)) {\n // Parse the barrel file to find exports\n const indexContent = await readFile(indexPath, \"utf-8\");\n const localExports = parseBarrelExports(indexContent).filter(\n ({ file }) =>\n dirname(join(folderPath, file)) === folderPath &&\n existsSync(join(folderPath, file)),\n );\n const namedExports = localExports.map(({ name }) => name);\n\n // Find the main component (first export or the one matching folder name)\n const mainComponentName = findMainComponent(namedExports, entry.name);\n\n if (mainComponentName) {\n const mainFilePath = join(\n folderPath,\n localExports.find(({ name }) => name === mainComponentName)!.file,\n );\n\n if (existsSync(mainFilePath)) {\n // Filter out the main component from namedExports (it will be imported separately)\n const subComponents = namedExports.filter(\n (n) => n !== mainComponentName,\n );\n\n entries.push({\n name: mainComponentName,\n filePath: mainFilePath,\n folderName: entry.name,\n isFolder: true,\n namedExports: subComponents,\n });\n }\n }\n }\n } else if (\n entry.isFile() &&\n extname(entry.name).toLowerCase() === \".astro\"\n ) {\n // Old pattern: flat .astro file\n const componentName = entry.name.replace(/\\.astro$/i, \"\");\n entries.push({\n name: componentName,\n filePath: join(componentsDir, entry.name),\n folderName: \"\",\n isFolder: false,\n namedExports: [],\n });\n }\n }\n\n // Prefer the nested component if an older installer left a flat duplicate.\n const nestedNames = new Set(\n entries.filter((entry) => entry.isFolder).map((entry) => entry.name),\n );\n return entries.filter(\n (entry) => entry.isFolder || !nestedNames.has(entry.name),\n );\n}\n\nfunction buildComponentFolderMap(\n components: ComponentEntry[],\n): Record<string, string> {\n const map: Record<string, string> = {};\n for (const component of components) {\n if (!component.isFolder) {\n map[component.name] = `${component.name}.astro`;\n continue;\n }\n if (!component.folderName) continue;\n map[component.name] = component.folderName;\n for (const sub of component.namedExports) {\n map[sub] = component.folderName;\n }\n }\n return map;\n}\n\n/**\n * Parse a barrel (index.ts) file to extract named exports.\n * Handles patterns like:\n * - export { default as Card } from \"./Card.astro\";\n * - export { default as CardHeader } from \"./CardHeader.astro\";\n */\nfunction parseBarrelExports(content: string): { name: string; file: string }[] {\n const exports: { name: string; file: string }[] = [];\n\n // Match: export { default as ComponentName } from \"...\"\n const exportRegex =\n /export\\s*\\{\\s*default\\s+as\\s+(\\w+)\\s*\\}\\s*from\\s*[\"'](\\.\\/[^\"']+\\.astro)[\"']/g;\n let match: RegExpExecArray | null;\n\n while ((match = exportRegex.exec(content)) !== null) {\n exports.push({ name: match[1], file: match[2] });\n }\n\n return exports;\n}\n\n/**\n * Find the main component from a list of exports.\n * The main component is typically the one that matches the folder name (PascalCase).\n */\nfunction findMainComponent(\n exports: string[],\n folderName: string,\n): string | null {\n if (exports.length === 0) return null;\n\n // Convert folder name to PascalCase for comparison\n // e.g., \"card\" -> \"Card\", \"input-group\" -> \"InputGroup\"\n const expectedName = folderName\n .split(\"-\")\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join(\"\");\n\n // First, try to find exact match\n const exactMatch = exports.find((e) => e === expectedName);\n if (exactMatch) return exactMatch;\n\n // Otherwise, return the first export (usually the main component)\n return exports[0];\n}\n\nasync function main() {\n const DEBUG =\n process.env.BEJAMAS_DEBUG === \"1\" || process.env.BEJAMAS_DEBUG === \"true\";\n const cwd =\n process.env.BEJAMAS_DOCS_CWD && process.env.BEJAMAS_DOCS_CWD.length\n ? (process.env.BEJAMAS_DOCS_CWD as string)\n : process.cwd();\n const config = await getConfig(cwd);\n const componentsAlias = (\n config?.aliases?.ui ||\n config?.aliases?.components ||\n \"@bejamas/ui/components\"\n ).replace(/\\/$/, \"\");\n const componentsDirFromConfig =\n config?.resolvedPaths?.ui || config?.resolvedPaths?.components;\n let uiRoot = componentsDirFromConfig\n ? dirname(dirname(componentsDirFromConfig))\n : resolveUiRoot(cwd);\n let componentsDir = join(uiRoot, \"src\", \"components\");\n if (componentsDirFromConfig) {\n componentsDir = componentsDirFromConfig;\n uiRoot = dirname(dirname(componentsDirFromConfig));\n }\n if (!existsSync(componentsDir)) {\n // Fallback to ui package components if the configured path is missing.\n componentsDir = join(uiRoot, \"src\", \"components\");\n }\n const outDir = resolveOutDir(cwd);\n mkdirSync(outDir, { recursive: true });\n\n if (DEBUG) {\n logger.info(`[docs-generator] cwd: ${cwd}`);\n logger.info(`[docs-generator] uiRoot: ${uiRoot}`);\n logger.info(`[docs-generator] componentsDir: ${componentsDir}`);\n logger.info(`[docs-generator] outDir: ${outDir}`);\n }\n\n // Discover all components (both flat files and folders)\n const components = await discoverComponents(componentsDir);\n const componentFolderMap = buildComponentFolderMap(components);\n const availableComponents = Object.keys(componentFolderMap);\n const rewriteAliases = (source: string) =>\n source\n .replace(/@bejamas\\/ui\\/components(?=[/\"'])/g, componentsAlias)\n .replace(\n /@bejamas\\/(?:ui|registry)\\/lib\\/utils(?=[\"'])/g,\n config?.aliases?.utils ?? \"@/lib/utils\",\n )\n .replace(\n /@bejamas\\/(?:ui|registry)\\/lib(?=[/\"'])/g,\n config?.aliases?.lib ?? \"@/lib\",\n );\n\n if (DEBUG) {\n logger.info(`[docs-generator] components found: ${components.length}`);\n if (components.length) {\n logger.info(\n `[docs-generator] first few: ${components\n .slice(0, 5)\n .map((c) => c.name)\n .join(\", \")}`,\n );\n }\n }\n\n let generatedCount = 0;\n const total = components.length;\n const spin = spinner(`Generating docs (0/${total})`).start();\n\n for (const component of components) {\n const {\n name: pascal,\n filePath,\n folderName,\n isFolder,\n namedExports,\n } = component;\n\n const astroFile = await readFile(filePath, \"utf-8\");\n const frontmatterCode = extractFrontmatter(astroFile);\n const sourceFile = createSourceFileFromFrontmatter(frontmatterCode);\n const meta = parseJsDocMetadata(rewriteAliases(frontmatterCode));\n const declaredProps = extractPropsFromDeclaredProps(sourceFile);\n const destructuredProps = extractPropsFromAstroProps(sourceFile);\n\n // Build props table preferring declared types; merge defaults from destructuring\n const defaultsMap = new Map<string, string | null>();\n for (const p of destructuredProps) {\n if (p.name && p.hasDefault) {\n defaultsMap.set(p.name, p.defaultValue || null);\n }\n }\n\n const propsTable = (declaredProps.length ? declaredProps : []).map((p) => ({\n name: p.name,\n type: p.type,\n required: !p.optional,\n defaultValue: defaultsMap.has(p.name) ? defaultsMap.get(p.name)! : null,\n }));\n\n const slug = slugify(pascal);\n const title = meta.title || meta.name || pascal;\n const description = meta.description || \"\";\n const descriptionBodyMDX = (meta as any).descriptionBodyMDX || \"\";\n const figmaUrl = (meta as any).figmaUrl || \"\";\n // Do not display props if there is no declared Props\n const propsList = \"\";\n\n const importName = pascal;\n // Use folder-based barrel import for new pattern, file-based for old pattern\n const importPath = isFolder\n ? `${componentsAlias}/${folderName}`\n : `${componentsAlias}/${pascal}.astro`;\n\n const { text: usageMDX, hasImport: hasImportUsage } = normalizeUsageMDX(\n meta.usageMDX || \"\",\n pascal,\n );\n const primaryExampleMDX = normalizeBlockMDX(\n meta.primaryExampleMDX || \"\",\n ).trim();\n const examplesMDX = normalizeBlockMDX(meta.examplesMDX || \"\").trim();\n const apiMDX = normalizeBlockMDX(meta.apiMDX || \"\").trim();\n const hasImportExamples = detectHasImportTopLevel(examplesMDX, pascal);\n const hasImportPrimary = detectHasImportTopLevel(primaryExampleMDX, pascal);\n const hasImport = hasImportUsage || hasImportExamples || hasImportPrimary;\n\n let exampleRelPaths: string[] = [];\n let examples: Array<{\n importName: string;\n importPath: string;\n title: string;\n source: string;\n }> = [];\n const parsedExamplesSections = parseExamplesSections(examplesMDX);\n if (parsedExamplesSections.length === 0) {\n exampleRelPaths = await discoverExamples(filePath, componentsDir);\n examples = (exampleRelPaths || []).map((rel) => {\n const posixRel = rel\n .split(require(\"path\").sep)\n .join(require(\"path\").posix.sep);\n const importPathEx = `${componentsAlias}/${posixRel}`;\n const abs = join(componentsDir, rel);\n const source = rewriteAliases(require(\"fs\").readFileSync(abs, \"utf-8\"));\n const base = toIdentifier(\n require(\"path\").basename(rel, require(\"path\").extname(rel)),\n );\n const importNameEx = `${pascal}${base}`;\n const titleEx = base;\n return {\n importName: importNameEx,\n importPath: importPathEx,\n title: titleEx,\n source,\n };\n });\n }\n\n const usedInUsage = extractComponentTagsFromPreviewMarkdown(usageMDX, {\n defaultPreview: false,\n }).filter((n) => n !== pascal);\n const usedInDescription = extractComponentTagsFromPreviewMarkdown(\n descriptionBodyMDX,\n ).filter((n) => n !== pascal);\n const usedInExamples = extractComponentTagsFromExamplesSections(\n parsedExamplesSections,\n ).filter((n) => n !== pascal);\n const usedInPrimary = extractComponentTagsFromMDX(primaryExampleMDX).filter(\n (n) => n !== pascal,\n );\n const usedInApi = extractComponentTagsFromPreviewMarkdown(apiMDX, {\n defaultPreview: false,\n allowForcedPreview: false,\n }).filter((n) => n !== pascal);\n const autoSet = new Set<string>([\n ...usedInUsage,\n ...usedInDescription,\n ...usedInExamples,\n ...usedInPrimary,\n ...usedInApi,\n ]);\n\n // For folder-based components, add subcomponents used in examples to namedExports\n const usedNamedExports = isFolder\n ? namedExports.filter((n) => autoSet.has(n))\n : [];\n\n // Remove subcomponents from autoSet (they'll be included via namedExports)\n if (isFolder) {\n for (const n of namedExports) {\n autoSet.delete(n);\n }\n }\n\n const autoImports = Array.from(autoSet).filter(\n (name) => !RESERVED_COMPONENTS.has(name),\n );\n\n // Installed UI exports take precedence over the Lucide naming convention.\n const isLucideIcon = (name: string) =>\n /Icon$/.test(name) && !componentFolderMap[name];\n const lucideIcons = autoImports.filter(isLucideIcon);\n const uiAutoImports = autoImports.filter((name) => !isLucideIcon(name));\n\n const missingComponents = uiAutoImports.filter(\n (name) => !availableComponents.includes(name),\n );\n if (missingComponents.length) {\n logger.warn(\n `${slug}.mdx: previews require ${missingComponents.sort().join(\", \")}; keeping their source examples without executing them.`,\n );\n }\n\n const mdx = buildMdx({\n importName,\n importPath,\n title,\n description,\n usageMDX,\n hasImport,\n propsList,\n propsTable,\n examples,\n examplesSections: parsedExamplesSections,\n componentFolderMap,\n availableComponents,\n autoImports: uiAutoImports,\n lucideIcons,\n primaryExampleMDX,\n componentSource: astroFile.trim(),\n commandName: slug,\n figmaUrl,\n descriptionBodyMDX,\n componentsAlias,\n // Pass subcomponents as named exports for folder-based components\n namedExports: isFolder ? usedNamedExports : undefined,\n apiMDX,\n });\n const outFile = join(outDir, `${slug}.mdx`);\n mkdirSync(dirname(outFile), { recursive: true });\n await writeFile(outFile, mdx, \"utf-8\");\n generatedCount += 1;\n spin.text = `Generating docs (${generatedCount}/${total}) - ${title}`;\n if (DEBUG) logger.info(`Generated ${outFile}`);\n }\n spin.succeed(\n `Created ${generatedCount} file${generatedCount === 1 ? \"\" : \"s\"}:`,\n );\n // log all files with relative paths, sorted alphabetically\n const relPaths = components\n .map((c) => {\n const slug = slugify(c.name);\n const outFile = join(outDir, `${slug}.mdx`);\n return relative(cwd, outFile);\n })\n .sort((a, b) => a.localeCompare(b));\n relPaths.forEach((p) => {\n logger.log(` - ${p}`);\n });\n logger.break();\n}\n\nexport async function runDocsGenerator(): Promise<void> {\n await main();\n}\n\nif (\n process.env.BEJAMAS_SKIP_AUTO_RUN !== \"1\" &&\n process.env.BEJAMAS_SKIP_AUTO_RUN !== \"true\"\n) {\n runDocsGenerator().catch((err) => {\n logger.error(String(err));\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;AAgFA,SAAS,wBAAwC;CAC/C,OAAO;EAAE,OAAO;EAAM,OAAO,CAAC;EAAG,OAAO,CAAC;CAAE;AAC7C;AAEA,SAAS,iBAAiB,SAA+C;CACvE,OAAO;EACL,OAAO,QAAQ;EACf,SAAS,QAAQ,MAAM,KAAK,IAAI,CAAC,CAAC,KAAK;EACvC,OAAO,QAAQ,MAAM,KAAK,UAAU;GAClC,OAAO,KAAK;GACZ,MAAM,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK;EAClC,EAAE;CACJ;AACF;AAEA,SAAS,SAAS,SAAgC,MAAgC;CAChF,IAAI,CAAC,WAAW,CAAC,MAAM;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