vibe-design-system 2.8.19 → 2.8.20
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 +1 -1
- package/vds-core-template/scan.mjs +48 -0
package/package.json
CHANGED
|
@@ -1843,8 +1843,22 @@ function extractColorUsage(colorNames) {
|
|
|
1843
1843
|
usage[name] = { bg: 0, text: 0, border: 0, other: 0, topFiles: new Map() };
|
|
1844
1844
|
}
|
|
1845
1845
|
|
|
1846
|
+
// Build reverse lookup: lowercase hex → color name (for arbitrary-* and inline-* tokens)
|
|
1847
|
+
// e.g. "arbitrary-4f46e5" → hex key "4f46e5"
|
|
1848
|
+
const hexToName = new Map();
|
|
1849
|
+
for (const name of colorNames) {
|
|
1850
|
+
if (name.startsWith("arbitrary-") || name.startsWith("inline-")) {
|
|
1851
|
+
const hexKey = name.replace(/^(arbitrary|inline)-/, "").toLowerCase();
|
|
1852
|
+
hexToName.set(hexKey, name);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1846
1856
|
// Single-pass regex: matches bg-primary, text-card-foreground, border-chart-1, etc.
|
|
1847
1857
|
const colorUtilRe = /\b(bg|text|border|fill|stroke|ring|from|to|via|outline)-([\w][\w-]*)/g;
|
|
1858
|
+
// Bracket-notation: bg-[#4F46E5], text-[#4f46e5/80], etc.
|
|
1859
|
+
const bracketHexRe = /\b(bg|text|border|fill|stroke|ring|from|to|via|outline)-\[#([0-9a-fA-F]{3,8})(?:\/[\d.]+)?\]/g;
|
|
1860
|
+
// Inline style hex colors: color:"#4F46E5", backgroundColor:'#4f46e5', etc.
|
|
1861
|
+
const inlineHexRe = /(?:color|(?:background|border|fill|stroke|ring)(?:Color)?)\s*[:=]\s*['"]#([0-9a-fA-F]{3,8})['"]/g;
|
|
1848
1862
|
|
|
1849
1863
|
for (const rel of files) {
|
|
1850
1864
|
if (rel.includes("stories")) continue;
|
|
@@ -1855,6 +1869,7 @@ function extractColorUsage(colorNames) {
|
|
|
1855
1869
|
const componentName = path.basename(rel).replace(/\.(tsx|jsx|ts|js)$/, "");
|
|
1856
1870
|
|
|
1857
1871
|
let m;
|
|
1872
|
+
// ── Token-based utilities (bg-primary, text-muted-foreground, …) ──
|
|
1858
1873
|
const reCopy = new RegExp(colorUtilRe.source, "g");
|
|
1859
1874
|
while ((m = reCopy.exec(content)) !== null) {
|
|
1860
1875
|
const prefix = m[1];
|
|
@@ -1866,6 +1881,39 @@ function extractColorUsage(colorNames) {
|
|
|
1866
1881
|
else usage[token].other++;
|
|
1867
1882
|
usage[token].topFiles.set(componentName, (usage[token].topFiles.get(componentName) || 0) + 1);
|
|
1868
1883
|
}
|
|
1884
|
+
|
|
1885
|
+
// ── Bracket-notation hex utilities (bg-[#4F46E5], …) ──
|
|
1886
|
+
if (hexToName.size > 0) {
|
|
1887
|
+
const brCopy = new RegExp(bracketHexRe.source, "gi");
|
|
1888
|
+
while ((m = brCopy.exec(content)) !== null) {
|
|
1889
|
+
const prefix = m[1].toLowerCase();
|
|
1890
|
+
const hexKey = m[2].toLowerCase();
|
|
1891
|
+
// Normalise 3-char hex → 6-char for matching
|
|
1892
|
+
const normalKey = hexKey.length === 3
|
|
1893
|
+
? hexKey[0] + hexKey[0] + hexKey[1] + hexKey[1] + hexKey[2] + hexKey[2]
|
|
1894
|
+
: hexKey;
|
|
1895
|
+
const name = hexToName.get(normalKey) || hexToName.get(hexKey);
|
|
1896
|
+
if (!name) continue;
|
|
1897
|
+
if (prefix === "bg") usage[name].bg++;
|
|
1898
|
+
else if (prefix === "text") usage[name].text++;
|
|
1899
|
+
else if (prefix === "border") usage[name].border++;
|
|
1900
|
+
else usage[name].other++;
|
|
1901
|
+
usage[name].topFiles.set(componentName, (usage[name].topFiles.get(componentName) || 0) + 1);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
// ── Inline style hex colors (color: "#4F46E5") ──
|
|
1905
|
+
const inCopy = new RegExp(inlineHexRe.source, "gi");
|
|
1906
|
+
while ((m = inCopy.exec(content)) !== null) {
|
|
1907
|
+
const hexKey = m[1].toLowerCase();
|
|
1908
|
+
const normalKey = hexKey.length === 3
|
|
1909
|
+
? hexKey[0] + hexKey[0] + hexKey[1] + hexKey[1] + hexKey[2] + hexKey[2]
|
|
1910
|
+
: hexKey;
|
|
1911
|
+
const name = hexToName.get(normalKey) || hexToName.get(hexKey);
|
|
1912
|
+
if (!name) continue;
|
|
1913
|
+
usage[name].other++;
|
|
1914
|
+
usage[name].topFiles.set(componentName, (usage[name].topFiles.get(componentName) || 0) + 1);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1869
1917
|
}
|
|
1870
1918
|
|
|
1871
1919
|
const result = {};
|