logicstamp-context 0.2.4 → 0.2.6
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/LLM_CONTEXT.md +2 -2
- package/README.md +28 -19
- package/dist/cli/commands/compare.d.ts.map +1 -1
- package/dist/cli/commands/compare.js +120 -13
- package/dist/cli/commands/compare.js.map +1 -1
- package/dist/cli/commands/context/fileWriter.d.ts.map +1 -1
- package/dist/cli/commands/context/fileWriter.js +68 -6
- package/dist/cli/commands/context/fileWriter.js.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.d.ts.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.js +12 -4
- package/dist/cli/commands/context/tokenEstimator.js.map +1 -1
- package/dist/cli/commands/context.d.ts.map +1 -1
- package/dist/cli/commands/context.js +71 -2
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +84 -8
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/handlers/compareHandler.d.ts.map +1 -1
- package/dist/cli/handlers/compareHandler.js +123 -9
- package/dist/cli/handlers/compareHandler.js.map +1 -1
- package/dist/core/astParser/detectors.d.ts.map +1 -1
- package/dist/core/astParser/detectors.js +130 -57
- package/dist/core/astParser/detectors.js.map +1 -1
- package/dist/core/astParser/extractors/componentExtractor.d.ts.map +1 -1
- package/dist/core/astParser/extractors/componentExtractor.js +89 -20
- package/dist/core/astParser/extractors/componentExtractor.js.map +1 -1
- package/dist/core/astParser/extractors/eventExtractor.d.ts.map +1 -1
- package/dist/core/astParser/extractors/eventExtractor.js +83 -28
- package/dist/core/astParser/extractors/eventExtractor.js.map +1 -1
- package/dist/core/astParser/extractors/propExtractor.d.ts.map +1 -1
- package/dist/core/astParser/extractors/propExtractor.js +142 -51
- package/dist/core/astParser/extractors/propExtractor.js.map +1 -1
- package/dist/core/astParser/extractors/stateExtractor.d.ts.map +1 -1
- package/dist/core/astParser/extractors/stateExtractor.js +95 -44
- package/dist/core/astParser/extractors/stateExtractor.js.map +1 -1
- package/dist/core/astParser.d.ts +4 -1
- package/dist/core/astParser.d.ts.map +1 -1
- package/dist/core/astParser.js +183 -26
- package/dist/core/astParser.js.map +1 -1
- package/dist/core/contractBuilder.d.ts.map +1 -1
- package/dist/core/contractBuilder.js +11 -15
- package/dist/core/contractBuilder.js.map +1 -1
- package/dist/core/manifest.d.ts.map +1 -1
- package/dist/core/manifest.js +82 -4
- package/dist/core/manifest.js.map +1 -1
- package/dist/core/pack/loader.d.ts.map +1 -1
- package/dist/core/pack/loader.js +22 -2
- package/dist/core/pack/loader.js.map +1 -1
- package/dist/core/pack.d.ts.map +1 -1
- package/dist/core/pack.js +57 -1
- package/dist/core/pack.js.map +1 -1
- package/dist/core/styleExtractor/index.d.ts +1 -0
- package/dist/core/styleExtractor/index.d.ts.map +1 -1
- package/dist/core/styleExtractor/index.js +1 -0
- package/dist/core/styleExtractor/index.js.map +1 -1
- package/dist/core/styleExtractor/layout.d.ts +13 -2
- package/dist/core/styleExtractor/layout.d.ts.map +1 -1
- package/dist/core/styleExtractor/layout.js +135 -65
- package/dist/core/styleExtractor/layout.js.map +1 -1
- package/dist/core/styleExtractor/material.d.ts.map +1 -1
- package/dist/core/styleExtractor/material.js +291 -66
- package/dist/core/styleExtractor/material.js.map +1 -1
- package/dist/core/styleExtractor/motion.d.ts +2 -2
- package/dist/core/styleExtractor/motion.d.ts.map +1 -1
- package/dist/core/styleExtractor/motion.js +425 -56
- package/dist/core/styleExtractor/motion.js.map +1 -1
- package/dist/core/styleExtractor/radix.d.ts +29 -0
- package/dist/core/styleExtractor/radix.d.ts.map +1 -0
- package/dist/core/styleExtractor/radix.js +315 -0
- package/dist/core/styleExtractor/radix.js.map +1 -0
- package/dist/core/styleExtractor/scss.d.ts.map +1 -1
- package/dist/core/styleExtractor/scss.js +37 -23
- package/dist/core/styleExtractor/scss.js.map +1 -1
- package/dist/core/styleExtractor/shadcn.d.ts +20 -0
- package/dist/core/styleExtractor/shadcn.d.ts.map +1 -0
- package/dist/core/styleExtractor/shadcn.js +345 -0
- package/dist/core/styleExtractor/shadcn.js.map +1 -0
- package/dist/core/styleExtractor/styleExtractor.d.ts.map +1 -1
- package/dist/core/styleExtractor/styleExtractor.js +267 -89
- package/dist/core/styleExtractor/styleExtractor.js.map +1 -1
- package/dist/core/styleExtractor/styled.d.ts +1 -1
- package/dist/core/styleExtractor/styled.d.ts.map +1 -1
- package/dist/core/styleExtractor/styled.js +308 -23
- package/dist/core/styleExtractor/styled.js.map +1 -1
- package/dist/core/styleExtractor/tailwind.d.ts +21 -3
- package/dist/core/styleExtractor/tailwind.d.ts.map +1 -1
- package/dist/core/styleExtractor/tailwind.js +279 -46
- package/dist/core/styleExtractor/tailwind.js.map +1 -1
- package/dist/types/UIFContract.d.ts +34 -0
- package/dist/types/UIFContract.d.ts.map +1 -1
- package/dist/types/UIFContract.js.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +41 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/debug.d.ts +12 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +16 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/fsx.d.ts +2 -1
- package/dist/utils/fsx.d.ts.map +1 -1
- package/dist/utils/fsx.js +99 -28
- package/dist/utils/fsx.js.map +1 -1
- package/dist/utils/gitignore.d.ts.map +1 -1
- package/dist/utils/gitignore.js +28 -1
- package/dist/utils/gitignore.js.map +1 -1
- package/package.json +1 -1
- package/schema/logicstamp.context.schema.json +26 -1
|
@@ -1,31 +1,316 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Styled-components/Emotion extractor - Extracts CSS-in-JS library usage
|
|
3
3
|
*/
|
|
4
|
+
import { SyntaxKind } from 'ts-morph';
|
|
5
|
+
import { debugError } from '../../utils/debug.js';
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Check if styled is imported from styled-components or emotion libraries
|
|
8
|
+
*/
|
|
9
|
+
function hasStyledImport(source) {
|
|
10
|
+
try {
|
|
11
|
+
for (const imp of source.getImportDeclarations()) {
|
|
12
|
+
try {
|
|
13
|
+
const module = imp.getModuleSpecifierValue();
|
|
14
|
+
if (module === 'styled-components' ||
|
|
15
|
+
module === '@emotion/styled' ||
|
|
16
|
+
module === '@emotion/react') {
|
|
17
|
+
const named = imp.getNamedImports();
|
|
18
|
+
const defaultImport = imp.getDefaultImport();
|
|
19
|
+
if (defaultImport && defaultImport.getText() === 'styled') {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
for (const n of named) {
|
|
23
|
+
if (n.getName() === 'styled') {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Continue checking other imports
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Return false on unexpected errors - outer try/catch will handle logging
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extract styled-components/emotion styled declarations using AST
|
|
6
42
|
*/
|
|
7
43
|
export function extractStyledComponents(source) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
try {
|
|
45
|
+
const components = new Set();
|
|
46
|
+
let hasTheme = false;
|
|
47
|
+
let hasCssProps = false;
|
|
48
|
+
// Check if styled is imported from valid sources (styled-components/emotion)
|
|
49
|
+
let hasValidStyledImport = false;
|
|
50
|
+
try {
|
|
51
|
+
hasValidStyledImport = hasStyledImport(source);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// If import check fails, continue without styled import validation
|
|
55
|
+
}
|
|
56
|
+
// Find all tagged template expressions (e.g., styled.div`...` or styled(Component)`...`)
|
|
57
|
+
let taggedTemplates = [];
|
|
58
|
+
try {
|
|
59
|
+
taggedTemplates = source.getDescendantsOfKind(SyntaxKind.TaggedTemplateExpression);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
debugError('styled', 'extractStyledComponents', {
|
|
63
|
+
error: error instanceof Error ? error.message : String(error),
|
|
64
|
+
context: 'getTaggedTemplateExpressions',
|
|
65
|
+
});
|
|
66
|
+
// Keep taggedTemplates = [] and continue to theme/useTheme/css checks
|
|
67
|
+
}
|
|
68
|
+
for (const taggedTemplate of taggedTemplates) {
|
|
69
|
+
try {
|
|
70
|
+
const tag = taggedTemplate.getTag();
|
|
71
|
+
const template = taggedTemplate.getTemplate();
|
|
72
|
+
// Check if this is a styled component pattern (only if styled is from valid sources)
|
|
73
|
+
if (hasValidStyledImport) {
|
|
74
|
+
const componentName = extractStyledComponentName(tag);
|
|
75
|
+
if (componentName) {
|
|
76
|
+
components.add(componentName);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check for theme usage in template literals
|
|
80
|
+
if (!hasTheme) {
|
|
81
|
+
try {
|
|
82
|
+
if (containsThemeUsage(template)) {
|
|
83
|
+
hasTheme = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Continue if theme check fails for this template
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Continue processing other tagged templates
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Check for useTheme() hook calls
|
|
96
|
+
if (!hasTheme) {
|
|
97
|
+
let callExpressions = [];
|
|
98
|
+
try {
|
|
99
|
+
callExpressions = source.getDescendantsOfKind(SyntaxKind.CallExpression);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
debugError('styled', 'extractStyledComponents', {
|
|
103
|
+
error: error instanceof Error ? error.message : String(error),
|
|
104
|
+
context: 'getCallExpressions',
|
|
105
|
+
});
|
|
106
|
+
// Continue with empty array
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
for (const callExpr of callExpressions) {
|
|
110
|
+
try {
|
|
111
|
+
const expr = callExpr.getExpression();
|
|
112
|
+
if (expr.getKind() === SyntaxKind.Identifier && expr.getText() === 'useTheme') {
|
|
113
|
+
hasTheme = true;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Continue checking other call expressions
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// Continue if call expression processing fails
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Check for css prop usage in JSX
|
|
127
|
+
if (!hasCssProps) {
|
|
128
|
+
let jsxElements = [];
|
|
129
|
+
try {
|
|
130
|
+
jsxElements = [
|
|
131
|
+
...source.getDescendantsOfKind(SyntaxKind.JsxElement),
|
|
132
|
+
...source.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
debugError('styled', 'extractStyledComponents', {
|
|
137
|
+
error: error instanceof Error ? error.message : String(error),
|
|
138
|
+
context: 'getJsxElements',
|
|
139
|
+
});
|
|
140
|
+
// Continue with empty array
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
for (const element of jsxElements) {
|
|
144
|
+
try {
|
|
145
|
+
const openingElement = 'getOpeningElement' in element
|
|
146
|
+
? element.getOpeningElement()
|
|
147
|
+
: element;
|
|
148
|
+
const attributes = openingElement.getAttributes();
|
|
149
|
+
for (const attr of attributes) {
|
|
150
|
+
if (attr.getKind() !== SyntaxKind.JsxAttribute)
|
|
151
|
+
continue;
|
|
152
|
+
const jsxAttr = attr;
|
|
153
|
+
const attrName = jsxAttr.getNameNode().getText();
|
|
154
|
+
if (attrName === 'css') {
|
|
155
|
+
hasCssProps = true;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (hasCssProps)
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// Continue checking other JSX elements
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// Continue if JSX processing fails
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
components: Array.from(components).sort().slice(0, 10),
|
|
173
|
+
hasTheme,
|
|
174
|
+
hasCssProps,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
debugError('styled', 'extractStyledComponents', {
|
|
179
|
+
error: error instanceof Error ? error.message : String(error),
|
|
180
|
+
});
|
|
181
|
+
return {
|
|
182
|
+
components: [],
|
|
183
|
+
hasTheme: false,
|
|
184
|
+
hasCssProps: false,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Extract component name from styled component tag
|
|
190
|
+
* Handles styled.div`...`, styled(Component)`...`, and styled('div')`...` patterns
|
|
191
|
+
*/
|
|
192
|
+
function extractStyledComponentName(tag) {
|
|
193
|
+
try {
|
|
194
|
+
// Pattern 1: styled.div`...` (PropertyAccessExpression)
|
|
195
|
+
if (tag.getKind() === SyntaxKind.PropertyAccessExpression) {
|
|
196
|
+
const propAccess = tag.asKindOrThrow(SyntaxKind.PropertyAccessExpression);
|
|
197
|
+
const expression = propAccess.getExpression();
|
|
198
|
+
const name = propAccess.getNameNode().getText();
|
|
199
|
+
// Check if expression is 'styled'
|
|
200
|
+
if (expression.getKind() === SyntaxKind.Identifier && expression.getText() === 'styled') {
|
|
201
|
+
return name;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Pattern 2: styled(Component)`...` or styled('div')`...` (CallExpression)
|
|
205
|
+
if (tag.getKind() === SyntaxKind.CallExpression) {
|
|
206
|
+
const callExpr = tag.asKindOrThrow(SyntaxKind.CallExpression);
|
|
207
|
+
const expression = callExpr.getExpression();
|
|
208
|
+
// Check if it's styled(...)
|
|
209
|
+
if (expression.getKind() === SyntaxKind.Identifier && expression.getText() === 'styled') {
|
|
210
|
+
const args = callExpr.getArguments();
|
|
211
|
+
if (args.length > 0) {
|
|
212
|
+
const firstArg = args[0];
|
|
213
|
+
// Extract identifier name from argument
|
|
214
|
+
if (firstArg.getKind() === SyntaxKind.Identifier) {
|
|
215
|
+
return firstArg.getText();
|
|
216
|
+
}
|
|
217
|
+
// Handle PropertyAccessExpression like styled(Some.Component)
|
|
218
|
+
if (firstArg.getKind() === SyntaxKind.PropertyAccessExpression) {
|
|
219
|
+
const propAccess = firstArg.asKindOrThrow(SyntaxKind.PropertyAccessExpression);
|
|
220
|
+
return propAccess.getNameNode().getText();
|
|
221
|
+
}
|
|
222
|
+
// Handle string literals like styled('div') or styled("section")
|
|
223
|
+
if (firstArg.getKind() === SyntaxKind.StringLiteral) {
|
|
224
|
+
const str = firstArg.asKindOrThrow(SyntaxKind.StringLiteral);
|
|
225
|
+
return str.getLiteralText();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// Return null on unexpected errors - outer try/catch will handle logging
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Check if a template literal contains theme usage
|
|
239
|
+
* Looks for patterns like ${props => props.theme.colors.primary}
|
|
240
|
+
*/
|
|
241
|
+
function containsThemeUsage(template) {
|
|
242
|
+
try {
|
|
243
|
+
// For NoSubstitutionTemplateLiteral, check for theme. in literal text
|
|
244
|
+
// (NoSubstitutionTemplateLiteral can't contain ${}, so just check for theme.)
|
|
245
|
+
if (template.getKind() === SyntaxKind.NoSubstitutionTemplateLiteral) {
|
|
246
|
+
const text = template.getLiteralText?.() ?? template.getText();
|
|
247
|
+
return /theme\./.test(text);
|
|
248
|
+
}
|
|
249
|
+
// For TemplateExpression, check all template spans for theme references
|
|
250
|
+
if (template.getKind() === SyntaxKind.TemplateExpression) {
|
|
251
|
+
const templateExpr = template.asKindOrThrow(SyntaxKind.TemplateExpression);
|
|
252
|
+
// Check head for theme references
|
|
253
|
+
const headText = templateExpr.getHead().getText();
|
|
254
|
+
if (/theme\./.test(headText)) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
// Check each span's expression for theme references
|
|
258
|
+
for (const span of templateExpr.getTemplateSpans()) {
|
|
259
|
+
try {
|
|
260
|
+
const expression = span.getExpression();
|
|
261
|
+
// Recursively check the expression for theme references
|
|
262
|
+
if (containsThemeInExpression(expression)) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
// Check literal part for theme references
|
|
266
|
+
const literalText = span.getLiteral().getText();
|
|
267
|
+
if (/theme\./.test(literalText)) {
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
// Continue checking other spans
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
// Return false on unexpected errors - outer try/catch will handle logging
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Recursively check if an expression contains theme references
|
|
285
|
+
* Optimized to only check identifiers and property access expressions
|
|
286
|
+
*/
|
|
287
|
+
function containsThemeInExpression(node) {
|
|
288
|
+
try {
|
|
289
|
+
// Only check identifiers and property access expressions for theme references
|
|
290
|
+
// This avoids calling getText() on every node recursively
|
|
291
|
+
if (node.getKind() === SyntaxKind.Identifier ||
|
|
292
|
+
node.getKind() === SyntaxKind.PropertyAccessExpression) {
|
|
293
|
+
const text = node.getText();
|
|
294
|
+
if (/theme\./.test(text)) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// Recursively check child nodes
|
|
299
|
+
for (const child of node.getChildren()) {
|
|
300
|
+
try {
|
|
301
|
+
if (containsThemeInExpression(child)) {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
// Continue checking other children
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// Return false on unexpected errors - outer try/catch will handle logging
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
30
315
|
}
|
|
31
316
|
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/core/styleExtractor/styled.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"styled.js","sourceRoot":"","sources":["../../../src/core/styleExtractor/styled.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAc,UAAU,EAAkI,MAAM,UAAU,CAAC;AAClL,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,SAAS,eAAe,CAAC,MAAkB;IACzC,IAAI,CAAC;QACH,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,qBAAqB,EAAE,EAAE,CAAC;YACjD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,GAAG,CAAC,uBAAuB,EAAE,CAAC;gBAC7C,IACE,MAAM,KAAK,mBAAmB;oBAC9B,MAAM,KAAK,iBAAiB;oBAC5B,MAAM,KAAK,gBAAgB,EAC3B,CAAC;oBACD,MAAM,KAAK,GAAG,GAAG,CAAC,eAAe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QACP,0EAA0E;QAC1E,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tailwind CSS extractor - Extracts and categorizes Tailwind utility classes
|
|
3
3
|
*/
|
|
4
|
+
import { SourceFile } from 'ts-morph';
|
|
4
5
|
/**
|
|
5
|
-
* Extract Tailwind classes from className attributes in JSX
|
|
6
|
+
* Extract Tailwind classes from className attributes in JSX (AST-based)
|
|
7
|
+
*
|
|
8
|
+
* Uses AST traversal to extract classes from:
|
|
9
|
+
* - Literal strings: className="flex p-4"
|
|
10
|
+
* - Template literals: className={`flex ${variable}`} (static segments extracted)
|
|
11
|
+
* - Function calls: className={cn('flex', isActive && 'bg-blue')}
|
|
12
|
+
* - Conditional expressions: className={isActive && 'bg-blue'}
|
|
13
|
+
*
|
|
14
|
+
* Note: Template literals are partially analyzed – static segments are extracted,
|
|
15
|
+
* dynamic expressions within ${} are ignored.
|
|
16
|
+
*
|
|
17
|
+
* Falls back to regex extraction for source text if AST is not available.
|
|
6
18
|
*/
|
|
7
|
-
export declare function extractTailwindClasses(
|
|
19
|
+
export declare function extractTailwindClasses(source: SourceFile | string): string[];
|
|
8
20
|
/**
|
|
9
21
|
* Categorize Tailwind utility classes
|
|
22
|
+
*
|
|
23
|
+
* Returns a record mapping category names to arrays of class names (JSON-ready).
|
|
24
|
+
* Each class is categorized based on its base utility (after stripping variant prefixes).
|
|
10
25
|
*/
|
|
11
|
-
export declare function categorizeTailwindClasses(classes: string[]): Record<string,
|
|
26
|
+
export declare function categorizeTailwindClasses(classes: string[]): Record<string, string[]>;
|
|
12
27
|
/**
|
|
13
28
|
* Extract responsive breakpoints used in the component
|
|
29
|
+
*
|
|
30
|
+
* Finds breakpoints anywhere in class names, not just at the start.
|
|
31
|
+
* Handles cases like hover:sm:bg-red-500 (though uncommon in practice).
|
|
14
32
|
*/
|
|
15
33
|
export declare function extractBreakpoints(classes: string[]): string[];
|
|
16
34
|
//# sourceMappingURL=tailwind.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../../src/core/styleExtractor/tailwind.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../../src/core/styleExtractor/tailwind.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAkE,MAAM,UAAU,CAAC;AAiDtG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,CA8D5E;AA0ID;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA2C1B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAsB9D"}
|