vibe-design-system 2.5.21 → 2.5.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.5.21",
3
+ "version": "2.5.23",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -478,22 +478,36 @@ const REACTNODE_PLACEHOLDER_TEXT = {
478
478
  children: "Example content",
479
479
  };
480
480
 
481
- /** Recursive list of .tsx file paths under dir (relative to dir). */
482
- function getAllTsxUnderDir(dir) {
481
+ /** Recursive list of .tsx/.jsx file paths under dir (relative to dir). Index.tsx / index.tsx first for deterministic "first usage". */
482
+ function getAllTsxJsxUnderDir(dir) {
483
483
  if (!fs.existsSync(dir)) return [];
484
484
  const out = [];
485
485
  const entries = fs.readdirSync(dir, { withFileTypes: true });
486
486
  for (const e of entries) {
487
487
  const full = path.join(dir, e.name);
488
488
  if (e.isDirectory()) {
489
- out.push(...getAllTsxUnderDir(full).map((r) => path.join(e.name, r)));
490
- } else if (e.isFile() && e.name.endsWith(".tsx")) {
489
+ out.push(...getAllTsxJsxUnderDir(full).map((r) => path.join(e.name, r)));
490
+ } else if (e.isFile() && (e.name.endsWith(".tsx") || e.name.endsWith(".jsx"))) {
491
491
  out.push(e.name);
492
492
  }
493
493
  }
494
+ out.sort((a, b) => {
495
+ const baseA = path.basename(a, path.extname(a));
496
+ const baseB = path.basename(b, path.extname(b));
497
+ const isIndexA = baseA === "Index" || baseA === "index";
498
+ const isIndexB = baseB === "Index" || baseB === "index";
499
+ if (isIndexA && !isIndexB) return -1;
500
+ if (!isIndexA && isIndexB) return 1;
501
+ return a.localeCompare(b);
502
+ });
494
503
  return out;
495
504
  }
496
505
 
506
+ /** @deprecated Use getAllTsxJsxUnderDir. Kept for compatibility. */
507
+ function getAllTsxUnderDir(dir) {
508
+ return getAllTsxJsxUnderDir(dir);
509
+ }
510
+
497
511
  /** Extract prop="value" and prop='value' and prop={"value"} from JSX tag content. Returns { propName: "value", ... }. */
498
512
  function extractPropsFromJsxTagContent(tagContent) {
499
513
  const props = {};
@@ -546,7 +560,7 @@ function buildMockArrayItems(componentSource, itemTypeName, propName) {
546
560
  return items;
547
561
  }
548
562
 
549
- /** Find first real usage of component in src/pages or src/app; return { propName: "literalValue", ... } or null. */
563
+ /** Find first real usage of component in src/pages or src/app (Index.tsx preferred); return { propName: "literalValue", ... } or null. */
550
564
  function findComponentUsageInPages(componentName, projectRoot) {
551
565
  const srcDir = path.join(projectRoot, "src");
552
566
  const pagesDir = path.join(srcDir, "pages");
@@ -557,7 +571,7 @@ function findComponentUsageInPages(componentName, projectRoot) {
557
571
  const escapedName = componentName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
558
572
  const tagOpenRe = new RegExp(`<${escapedName}\\s+([\\s\\S]*?)\\s*\\/?>`, "m");
559
573
  for (const dir of dirs) {
560
- const files = getAllTsxUnderDir(dir);
574
+ const files = getAllTsxJsxUnderDir(dir);
561
575
  for (const rel of files) {
562
576
  const fullPath = path.join(dir, rel);
563
577
  try {
@@ -596,9 +610,10 @@ function buildDefaultArgsForRequiredProps(props, usageFromPages = null, componen
596
610
  const name = p.name;
597
611
  const required = p.required === true;
598
612
  if (/ReactNode|React\.ReactNode/.test(type)) {
599
- const text = REACTNODE_PLACEHOLDER_TEXT[name] || componentPlaceholders[name] || "Content";
600
- argLines.push(` ${name}: React.createElement('p', null, ${JSON.stringify(text)}),`);
601
- needReact = true;
613
+ const text = fromPages[name] != null && typeof fromPages[name] === "string"
614
+ ? fromPages[name]
615
+ : (REACTNODE_PLACEHOLDER_TEXT[name] || componentPlaceholders[name] || "Content");
616
+ argLines.push(` ${name}: ${JSON.stringify(text)},`);
602
617
  added.add(name);
603
618
  continue;
604
619
  }