bejamas 0.4.0 → 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 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
- You can also run the command without any arguments to view a list of all available components:
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 { _ as getConfig, a as extractComponentTagsFromMDX, b as logger, c as extractPropsFromDeclaredProps, 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, st as __require, t as RESERVED_COMPONENTS, u as normalizeUsageMDX } from "./utils-otwzm7kH.js";
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(/&lt;script&gt;/gi, "<script>").replace(/&lt;\/script&gt;/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 = "";
@@ -304,7 +304,7 @@ function extractTags(block) {
304
304
  }
305
305
  function extractComponentTagsFromPreviewMarkdown(block, config = {}) {
306
306
  if (!block || !block.length) return [];
307
- const { defaultPreview = true } = config;
307
+ const { defaultPreview = true, allowForcedPreview = true } = config;
308
308
  const found = /* @__PURE__ */ new Set();
309
309
  const lines = block.split("\n");
310
310
  let inFence = false;
@@ -328,7 +328,7 @@ function extractComponentTagsFromPreviewMarkdown(block, config = {}) {
328
328
  const sourceCode = fenceBody.join("\n").trim();
329
329
  const prepared = prepareExampleContent(`${fenceOpen}\n${sourceCode}\n${line}`);
330
330
  const hasForcedPreviewFlag = currentFenceFlags.has("preview") || currentFenceFlags.has("console");
331
- if (!prepared.skipPreview && (defaultPreview || hasForcedPreviewFlag)) for (const tag of extractTags(prepared.snippet)) found.add(tag);
331
+ if (!prepared.skipPreview && (defaultPreview || allowForcedPreview && hasForcedPreviewFlag)) for (const tag of extractTags(prepared.snippet)) found.add(tag);
332
332
  }
333
333
  inFence = false;
334
334
  fenceOpen = "";
@@ -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$1) {
368
- return !path$1.endsWith(".astro");
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) if (useBarrelPattern) mainImportLine = `import { ${[importName, ...namedExports ?? []].sort().join(", ")} } from '${importPath}';`;
442
- else mainImportLine = `import ${importName} from '${importPath}';`;
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$1 = (snippet) => {
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$1(snippet);
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.slice().sort().map((name) => `import ${name} from '${componentsAlias}/${name}.astro';`));
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 withConvertedParagraphs = convertParagraphsWithComponents(extracted.markup.replace(/<!--([\s\S]*?)-->/g, "{/*$1*/}"));
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(normalizeInlineWhitespace(withConvertedParagraphs)),
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,7 +710,12 @@ ${preparedPreview.markup}
691
710
  };
692
711
  const renderAstroPreviewsInMarkdown = (block, config = {}) => {
693
712
  if (!block || !block.length) return block;
694
- const { defaultPreview = true } = config;
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\`\`\`\``;
718
+ const { defaultPreview = true, allowForcedPreview = true } = config;
695
719
  const lines = block.split("\n");
696
720
  const out = [];
697
721
  let inFence = false;
@@ -745,7 +769,7 @@ ${preparedPreview.markup}
745
769
  const companionMarkdown = companionConsoleFence ? lines.slice(lineIndex + 1, companionConsoleFence.end + 1).join("\n") : "";
746
770
  const prepared = prepareExampleContent(companionMarkdown.length ? `${fenceOpen}\n${sourceCode}\n${line}\n${companionMarkdown}` : `${fenceOpen}\n${sourceCode}\n${line}`);
747
771
  const hasForcedPreviewFlag = currentFenceFlags.has("preview") || currentFenceFlags.has("console");
748
- const shouldPreview = !prepared.skipPreview && (defaultPreview || hasForcedPreviewFlag);
772
+ const shouldPreview = !prepared.skipPreview && (defaultPreview || allowForcedPreview && hasForcedPreviewFlag);
749
773
  if (prepared.snippet && prepared.snippet.length && shouldPreview) {
750
774
  const previewBlock = renderPreviewBlock(prepared.snippet, {
751
775
  enableConsolePanel: prepared.enableConsolePanel,
@@ -803,7 +827,10 @@ ${preparedPreview.markup}
803
827
  };
804
828
  const renderedDescriptionBodyMDX = renderAstroPreviewsInMarkdown(descriptionBodyMDX || "");
805
829
  const renderedUsageMDX = renderAstroPreviewsInMarkdown(usageMDX || "", { defaultPreview: false });
806
- const renderedApiMDX = renderAstroPreviewsInMarkdown(apiMDX || "");
830
+ const renderedApiMDX = renderAstroPreviewsInMarkdown(apiMDX || "", {
831
+ defaultPreview: false,
832
+ allowForcedPreview: false
833
+ });
807
834
  const primaryExampleSection = primaryExampleMDX && primaryExampleMDX.length ? `${renderPreviewBlock(primaryExampleMDX)}
808
835
 
809
836
  \`\`\`astro
@@ -815,7 +842,7 @@ ${(() => {
815
842
  const renderExampleItem = (headingLevel, headingTitle, body) => {
816
843
  const prepared = prepareExampleContent(body);
817
844
  const blocks = [`${headingLevel} ${headingTitle}`];
818
- if (prepared.descriptionMD && prepared.descriptionMD.length) blocks.push(prepared.descriptionMD);
845
+ if (prepared.descriptionMD && prepared.descriptionMD.length) blocks.push(renderAstroPreviewsInMarkdown(prepared.descriptionMD));
819
846
  if (prepared.snippet && prepared.snippet.length && prepared.sourceCode && prepared.sourceCode.length && !prepared.skipPreview) blocks.push(renderPreviewBlock(prepared.snippet, {
820
847
  enableConsolePanel: prepared.enableConsolePanel,
821
848
  consoleScripts: prepared.consoleScripts
@@ -831,7 +858,7 @@ ${sourceBlock}
831
858
  \`\`\``);
832
859
  if (prepared.companionIntroMD && prepared.companionIntroMD.length && !prepared.mergeCompanionWithSource) blocks.push(prepared.companionIntroMD);
833
860
  if (prepared.companionSourceMD && prepared.companionSourceMD.length && !prepared.mergeCompanionWithSource) blocks.push(renderCompanionSourceMD(prepared.companionSourceMD));
834
- if (prepared.trailingDescriptionMD && prepared.trailingDescriptionMD.length) blocks.push(prepared.trailingDescriptionMD);
861
+ if (prepared.trailingDescriptionMD && prepared.trailingDescriptionMD.length) blocks.push(renderAstroPreviewsInMarkdown(prepared.trailingDescriptionMD));
835
862
  }
836
863
  return blocks.join("\n\n");
837
864
  };
@@ -842,7 +869,7 @@ ${sourceBlock}
842
869
  const sectionParts = [];
843
870
  const hasSectionTitle = !!(section.title && section.title.length);
844
871
  if (hasSectionTitle) sectionParts.push(`### ${section.title}`);
845
- if (section.introMD && section.introMD.length) sectionParts.push(section.introMD);
872
+ if (section.introMD && section.introMD.length) sectionParts.push(renderAstroPreviewsInMarkdown(section.introMD));
846
873
  if (section.items && section.items.length) {
847
874
  const itemHeadingLevel = hasSectionTitle ? "####" : "###";
848
875
  for (const item of section.items) sectionParts.push(renderExampleItem(itemHeadingLevel, item.title, item.body));
@@ -859,9 +886,9 @@ ${sourceBlock}
859
886
  }
860
887
  if (examples && examples.length) for (const ex of examples) renderedExampleSections.push(`### ${ex.title}
861
888
 
862
- <div class="not-content">
889
+ ${missingFromSnippet(ex.source).length ? missingNotice(missingFromSnippet(ex.source)) : `<div class="not-content">
863
890
  <${ex.importName} />
864
- </div>
891
+ </div>`}
865
892
 
866
893
  \`\`\`astro
867
894
  ${ex.source}
@@ -945,15 +972,16 @@ ${ex.source}
945
972
  */
946
973
  async function discoverComponents(componentsDir) {
947
974
  const entries = [];
948
- const dirEntries = await readdir(componentsDir, { withFileTypes: true });
975
+ const dirEntries = (await readdir(componentsDir, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name));
949
976
  for (const entry of dirEntries) if (entry.isDirectory()) {
950
977
  const folderPath = join(componentsDir, entry.name);
951
978
  const indexPath = join(folderPath, "index.ts");
952
979
  if (existsSync(indexPath)) {
953
- const namedExports = parseBarrelExports(await readFile(indexPath, "utf-8"));
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);
954
982
  const mainComponentName = findMainComponent(namedExports, entry.name);
955
983
  if (mainComponentName) {
956
- const mainFilePath = join(folderPath, `${mainComponentName}.astro`);
984
+ const mainFilePath = join(folderPath, localExports.find(({ name }) => name === mainComponentName).file);
957
985
  if (existsSync(mainFilePath)) {
958
986
  const subComponents = namedExports.filter((n) => n !== mainComponentName);
959
987
  entries.push({
@@ -976,12 +1004,17 @@ async function discoverComponents(componentsDir) {
976
1004
  namedExports: []
977
1005
  });
978
1006
  }
979
- return entries;
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));
980
1009
  }
981
1010
  function buildComponentFolderMap(components) {
982
1011
  const map = {};
983
1012
  for (const component of components) {
984
- if (!component.isFolder || !component.folderName) continue;
1013
+ if (!component.isFolder) {
1014
+ map[component.name] = `${component.name}.astro`;
1015
+ continue;
1016
+ }
1017
+ if (!component.folderName) continue;
985
1018
  map[component.name] = component.folderName;
986
1019
  for (const sub of component.namedExports) map[sub] = component.folderName;
987
1020
  }
@@ -995,9 +1028,12 @@ function buildComponentFolderMap(components) {
995
1028
  */
996
1029
  function parseBarrelExports(content) {
997
1030
  const exports = [];
998
- 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;
999
1032
  let match;
1000
- while ((match = exportRegex.exec(content)) !== null) exports.push(match[1]);
1033
+ while ((match = exportRegex.exec(content)) !== null) exports.push({
1034
+ name: match[1],
1035
+ file: match[2]
1036
+ });
1001
1037
  return exports;
1002
1038
  }
1003
1039
  /**
@@ -1017,7 +1053,7 @@ async function main() {
1017
1053
  const config = await getConfig(cwd);
1018
1054
  const componentsAlias = (config?.aliases?.ui || config?.aliases?.components || "@bejamas/ui/components").replace(/\/$/, "");
1019
1055
  const componentsDirFromConfig = config?.resolvedPaths?.ui || config?.resolvedPaths?.components;
1020
- let uiRoot = resolveUiRoot(cwd);
1056
+ let uiRoot = componentsDirFromConfig ? dirname(dirname(componentsDirFromConfig)) : resolveUiRoot(cwd);
1021
1057
  let componentsDir = join(uiRoot, "src", "components");
1022
1058
  if (componentsDirFromConfig) {
1023
1059
  componentsDir = componentsDirFromConfig;
@@ -1034,6 +1070,8 @@ async function main() {
1034
1070
  }
1035
1071
  const components = await discoverComponents(componentsDir);
1036
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");
1037
1075
  if (DEBUG) {
1038
1076
  logger.info(`[docs-generator] components found: ${components.length}`);
1039
1077
  if (components.length) logger.info(`[docs-generator] first few: ${components.slice(0, 5).map((c) => c.name).join(", ")}`);
@@ -1046,7 +1084,7 @@ async function main() {
1046
1084
  const astroFile = await readFile(filePath, "utf-8");
1047
1085
  const frontmatterCode = extractFrontmatter(astroFile);
1048
1086
  const sourceFile = createSourceFileFromFrontmatter(frontmatterCode);
1049
- const meta = parseJsDocMetadata(frontmatterCode);
1087
+ const meta = parseJsDocMetadata(rewriteAliases(frontmatterCode));
1050
1088
  const declaredProps = extractPropsFromDeclaredProps(sourceFile);
1051
1089
  const destructuredProps = extractPropsFromAstroProps(sourceFile);
1052
1090
  const defaultsMap = /* @__PURE__ */ new Map();
@@ -1078,9 +1116,10 @@ async function main() {
1078
1116
  if (parsedExamplesSections.length === 0) {
1079
1117
  exampleRelPaths = await discoverExamples(filePath, componentsDir);
1080
1118
  examples = (exampleRelPaths || []).map((rel) => {
1081
- const importPathEx = `${componentsAlias}/${rel.split(__require("path").sep).join(__require("path").posix.sep)}`;
1119
+ const posixRel = rel.split(__require("path").sep).join(__require("path").posix.sep);
1120
+ const importPathEx = `${componentsAlias}/${posixRel}`;
1082
1121
  const abs = join(componentsDir, rel);
1083
- const source = __require("fs").readFileSync(abs, "utf-8");
1122
+ const source = rewriteAliases(__require("fs").readFileSync(abs, "utf-8"));
1084
1123
  const base = toIdentifier(__require("path").basename(rel, __require("path").extname(rel)));
1085
1124
  return {
1086
1125
  importName: `${pascal}${base}`,
@@ -1094,8 +1133,11 @@ async function main() {
1094
1133
  const usedInDescription = extractComponentTagsFromPreviewMarkdown(descriptionBodyMDX).filter((n) => n !== pascal);
1095
1134
  const usedInExamples = extractComponentTagsFromExamplesSections(parsedExamplesSections).filter((n) => n !== pascal);
1096
1135
  const usedInPrimary = extractComponentTagsFromMDX(primaryExampleMDX).filter((n) => n !== pascal);
1097
- const usedInApi = extractComponentTagsFromPreviewMarkdown(apiMDX).filter((n) => n !== pascal);
1098
- const autoSet = new Set([
1136
+ const usedInApi = extractComponentTagsFromPreviewMarkdown(apiMDX, {
1137
+ defaultPreview: false,
1138
+ allowForcedPreview: false
1139
+ }).filter((n) => n !== pascal);
1140
+ const autoSet = /* @__PURE__ */ new Set([
1099
1141
  ...usedInUsage,
1100
1142
  ...usedInDescription,
1101
1143
  ...usedInExamples,
@@ -1104,9 +1146,12 @@ async function main() {
1104
1146
  ]);
1105
1147
  const usedNamedExports = isFolder ? namedExports.filter((n) => autoSet.has(n)) : [];
1106
1148
  if (isFolder) for (const n of namedExports) autoSet.delete(n);
1107
- const autoImports = Array.from(autoSet).filter((name) => !RESERVED_COMPONENTS.has(name)).filter((name) => true);
1108
- const lucideIcons = autoImports.filter((n) => /Icon$/.test(n));
1109
- const uiAutoImports = autoImports.filter((n) => !/Icon$/.test(n));
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.`);
1110
1155
  const mdx = buildMdx({
1111
1156
  importName,
1112
1157
  importPath,
@@ -1119,6 +1164,7 @@ async function main() {
1119
1164
  examples,
1120
1165
  examplesSections: parsedExamplesSections,
1121
1166
  componentFolderMap,
1167
+ availableComponents,
1122
1168
  autoImports: uiAutoImports,
1123
1169
  lucideIcons,
1124
1170
  primaryExampleMDX,
@@ -1139,7 +1185,9 @@ async function main() {
1139
1185
  }
1140
1186
  spin.succeed(`Created ${generatedCount} file${generatedCount === 1 ? "" : "s"}:`);
1141
1187
  components.map((c) => {
1142
- return relative(cwd, join(outDir, `${slugify(c.name)}.mdx`));
1188
+ const slug = slugify(c.name);
1189
+ const outFile = join(outDir, `${slug}.mdx`);
1190
+ return relative(cwd, outFile);
1143
1191
  }).sort((a, b) => a.localeCompare(b)).forEach((p) => {
1144
1192
  logger.log(` - ${p}`);
1145
1193
  });
@@ -1155,4 +1203,4 @@ if (process.env.BEJAMAS_SKIP_AUTO_RUN !== "1" && process.env.BEJAMAS_SKIP_AUTO_R
1155
1203
 
1156
1204
  //#endregion
1157
1205
  export { runDocsGenerator };
1158
- //# sourceMappingURL=generate-mdx-oWy6Hzgd.js.map
1206
+ //# sourceMappingURL=generate-mdx-Bd_qGcMg.js.map