@schemyx/mcp 0.1.3 → 0.1.4
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/dist/codebase-scanner/bundle.js +182 -0
- package/dist/codebase-scanner/bundle.js.map +1 -1
- package/dist/codebase-scanner/extractors.d.ts +1 -0
- package/dist/codebase-scanner/extractors.js +52 -0
- package/dist/codebase-scanner/extractors.js.map +1 -1
- package/dist/codebase-scanner/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ export declare function extractCssVariableReferences(content: string): string[];
|
|
|
37
37
|
export declare function extractClassReferences(content: string, classExpressions?: ClassExpression[]): string[];
|
|
38
38
|
export declare function extractClassExpressions(content: string): ClassExpression[];
|
|
39
39
|
export declare function extractComponentStyleDefinitions(content: string): ComponentStyleDefinition[];
|
|
40
|
+
export declare function readJsxClassSources(source: string): string[];
|
|
40
41
|
export declare function extractThemeTokens(relPath: string, content: string): ThemeToken[];
|
|
41
42
|
export declare function extractInlineStyles(content: string): InlineStyle[];
|
|
42
43
|
interface OpeningTagInfo {
|
|
@@ -32,6 +32,7 @@ exports.extractCssVariableReferences = extractCssVariableReferences;
|
|
|
32
32
|
exports.extractClassReferences = extractClassReferences;
|
|
33
33
|
exports.extractClassExpressions = extractClassExpressions;
|
|
34
34
|
exports.extractComponentStyleDefinitions = extractComponentStyleDefinitions;
|
|
35
|
+
exports.readJsxClassSources = readJsxClassSources;
|
|
35
36
|
exports.extractThemeTokens = extractThemeTokens;
|
|
36
37
|
exports.extractInlineStyles = extractInlineStyles;
|
|
37
38
|
exports.nearestCssSelector = nearestCssSelector;
|
|
@@ -813,6 +814,7 @@ function extractClassExpressions(content) {
|
|
|
813
814
|
function extractComponentStyleDefinitions(content) {
|
|
814
815
|
const definitions = [];
|
|
815
816
|
const cvaPattern = /(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*cva\s*\(/g;
|
|
817
|
+
const forwardRefPattern = /(?:export\s+)?(?:const|let|var)\s+([A-Z][A-Za-z0-9_$]*)\s*=\s*(?:React\.)?forwardRef\b/g;
|
|
816
818
|
for (const match of content.matchAll(cvaPattern)) {
|
|
817
819
|
if (isInsideQuotedString(content, match.index ?? 0)) {
|
|
818
820
|
continue;
|
|
@@ -841,6 +843,37 @@ function extractComponentStyleDefinitions(content) {
|
|
|
841
843
|
source: (0, utils_1.truncate)(call, 2200),
|
|
842
844
|
});
|
|
843
845
|
}
|
|
846
|
+
for (const match of content.matchAll(forwardRefPattern)) {
|
|
847
|
+
if (isInsideQuotedString(content, match.index ?? 0)) {
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
const forwardRefIndex = content.indexOf('forwardRef', match.index ?? 0);
|
|
851
|
+
const call = readBalancedCall(content, forwardRefIndex);
|
|
852
|
+
if (!call) {
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
const classSources = readJsxClassSources(call);
|
|
856
|
+
const styleHelper = readPrimaryClassHelperUsage(call);
|
|
857
|
+
const baseClasses = (0, utils_1.unique)(classSources.flatMap((classSource) => analyzeClassSource(classSource).defaultClasses));
|
|
858
|
+
const classes = (0, utils_1.unique)([
|
|
859
|
+
...classSources.flatMap((classSource) => analyzeClassSource(classSource).classes),
|
|
860
|
+
...baseClasses,
|
|
861
|
+
]);
|
|
862
|
+
if (!classes.length && !styleHelper) {
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
865
|
+
definitions.push({
|
|
866
|
+
name: match[1],
|
|
867
|
+
kind: 'component-wrapper',
|
|
868
|
+
line: (0, utils_1.lineNumberAt)(content, match.index ?? 0),
|
|
869
|
+
baseClasses,
|
|
870
|
+
variants: {},
|
|
871
|
+
defaultVariants: {},
|
|
872
|
+
classes,
|
|
873
|
+
...(styleHelper ? { styleHelper: styleHelper.name } : {}),
|
|
874
|
+
source: (0, utils_1.truncate)(call, 2200),
|
|
875
|
+
});
|
|
876
|
+
}
|
|
844
877
|
for (const match of content.matchAll(/(?:export\s+)?(?:const|let|var)\s+([A-Za-z_$][\w$]*(?:Classes|ClassNames|Styles|Variants|Config|Map))\s*=\s*\{/g)) {
|
|
845
878
|
if (isInsideQuotedString(content, match.index ?? 0)) {
|
|
846
879
|
continue;
|
|
@@ -867,6 +900,25 @@ function extractComponentStyleDefinitions(content) {
|
|
|
867
900
|
}
|
|
868
901
|
return (0, utils_1.uniqueBy)(definitions, (definition) => `${definition.name}:${definition.line}`).slice(0, 80);
|
|
869
902
|
}
|
|
903
|
+
function readJsxClassSources(source) {
|
|
904
|
+
const sources = [];
|
|
905
|
+
for (const pattern of [
|
|
906
|
+
/\bclass(?:Name)?\s*=\s*(["'`])([\s\S]*?)\1/g,
|
|
907
|
+
/\bclass(?:Name)?\s*=\s*\{\s*(["'`])([\s\S]*?)\1\s*\}/g,
|
|
908
|
+
]) {
|
|
909
|
+
for (const match of source.matchAll(pattern)) {
|
|
910
|
+
sources.push(match[2] ?? match[1] ?? '');
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
for (const match of source.matchAll(/\bclass(?:Name)?\s*=\s*\{/g)) {
|
|
914
|
+
const openIndex = source.indexOf('{', match.index ?? 0);
|
|
915
|
+
const block = readBalancedBlock(source, openIndex);
|
|
916
|
+
if (block) {
|
|
917
|
+
sources.push(block.slice(1, -1));
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return (0, utils_1.unique)(sources.filter(Boolean)).slice(0, 24);
|
|
921
|
+
}
|
|
870
922
|
function extractThemeTokens(relPath, content) {
|
|
871
923
|
const shouldExtract = /(?:theme|token|tailwind|config|globals|styles?|css|scss)/i.test(relPath) ||
|
|
872
924
|
/--[a-zA-Z0-9-_]+\s*:/.test(content);
|