logicstamp-context 0.6.0 → 0.7.1
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 +67 -20
- package/README.md +68 -33
- package/dist/cli/commands/clean.d.ts +2 -2
- package/dist/cli/commands/clean.js +2 -2
- package/dist/cli/commands/compare.js +1 -1
- package/dist/cli/commands/compare.js.map +1 -1
- package/dist/cli/commands/context/configManager.js +2 -2
- package/dist/cli/commands/context/configManager.js.map +1 -1
- package/dist/cli/commands/context/contractBuilder.d.ts +1 -0
- package/dist/cli/commands/context/contractBuilder.d.ts.map +1 -1
- package/dist/cli/commands/context/contractBuilder.js +1 -1
- package/dist/cli/commands/context/contractBuilder.js.map +1 -1
- package/dist/cli/commands/context/fileWriter.d.ts +11 -0
- package/dist/cli/commands/context/fileWriter.d.ts.map +1 -1
- package/dist/cli/commands/context/fileWriter.js +52 -4
- package/dist/cli/commands/context/fileWriter.js.map +1 -1
- package/dist/cli/commands/context/index.d.ts +20 -2
- package/dist/cli/commands/context/index.d.ts.map +1 -1
- package/dist/cli/commands/context/index.js +22 -2
- package/dist/cli/commands/context/index.js.map +1 -1
- package/dist/cli/commands/context/statsCalculator.d.ts +1 -1
- package/dist/cli/commands/context/statsCalculator.js +4 -4
- package/dist/cli/commands/context/statsCalculator.js.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.d.ts.map +1 -1
- package/dist/cli/commands/context/tokenEstimator.js +10 -7
- package/dist/cli/commands/context/tokenEstimator.js.map +1 -1
- package/dist/cli/commands/context/{incrementalWatch.d.ts → watchMode/incrementalWatch.d.ts} +6 -6
- package/dist/cli/commands/context/watchMode/incrementalWatch.d.ts.map +1 -0
- package/dist/cli/commands/context/{incrementalWatch.js → watchMode/incrementalWatch.js} +107 -45
- package/dist/cli/commands/context/watchMode/incrementalWatch.js.map +1 -0
- package/dist/cli/commands/context/watchMode/index.d.ts +12 -0
- package/dist/cli/commands/context/watchMode/index.d.ts.map +1 -0
- package/dist/cli/commands/context/watchMode/index.js +12 -0
- package/dist/cli/commands/context/watchMode/index.js.map +1 -0
- package/dist/cli/commands/context/{watchDiff.d.ts → watchMode/watchDiff.d.ts} +2 -2
- package/dist/cli/commands/context/watchMode/watchDiff.d.ts.map +1 -0
- package/dist/cli/commands/context/{watchDiff.js → watchMode/watchDiff.js} +1 -1
- package/dist/cli/commands/context/watchMode/watchDiff.js.map +1 -0
- package/dist/cli/commands/context/watchMode/watchMode.d.ts +10 -0
- package/dist/cli/commands/context/watchMode/watchMode.d.ts.map +1 -0
- package/dist/cli/commands/context/{watchMode.js → watchMode/watchMode.js} +127 -30
- package/dist/cli/commands/context/watchMode/watchMode.js.map +1 -0
- package/dist/cli/commands/context.d.ts +3 -1
- package/dist/cli/commands/context.d.ts.map +1 -1
- package/dist/cli/commands/context.js +17 -11
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/init.js +7 -7
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/security.d.ts +1 -1
- package/dist/cli/commands/security.js +1 -1
- package/dist/cli/commands/style.d.ts +2 -2
- package/dist/cli/commands/style.js +2 -2
- package/dist/cli/commands/validate.d.ts +1 -1
- package/dist/cli/commands/validate.js +2 -2
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/handlers/compareHandler.d.ts +1 -1
- package/dist/cli/handlers/compareHandler.js +5 -5
- package/dist/cli/handlers/compareHandler.js.map +1 -1
- package/dist/cli/handlers/contextHandler.d.ts +1 -1
- package/dist/cli/handlers/contextHandler.js +2 -2
- package/dist/cli/handlers/contextHandler.js.map +1 -1
- package/dist/cli/handlers/styleHandler.js +1 -1
- package/dist/cli/handlers/styleHandler.js.map +1 -1
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +16 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/parser/argumentParser.d.ts +1 -1
- package/dist/cli/parser/argumentParser.d.ts.map +1 -1
- package/dist/cli/parser/argumentParser.js +12 -1
- package/dist/cli/parser/argumentParser.js.map +1 -1
- package/dist/cli/parser/helpText.d.ts.map +1 -1
- package/dist/cli/parser/helpText.js +51 -38
- package/dist/cli/parser/helpText.js.map +1 -1
- package/dist/cli/stamp.d.ts +2 -2
- package/dist/cli/stamp.js +3 -3
- package/dist/cli/stamp.js.map +1 -1
- package/dist/core/pack/loader.d.ts +2 -0
- package/dist/core/pack/loader.d.ts.map +1 -1
- package/dist/core/pack/loader.js +17 -1
- package/dist/core/pack/loader.js.map +1 -1
- package/dist/extractors/react/propExtractor.d.ts.map +1 -1
- package/dist/extractors/react/propExtractor.js +164 -217
- package/dist/extractors/react/propExtractor.js.map +1 -1
- package/dist/extractors/styling/styleExtractor.d.ts +5 -2
- package/dist/extractors/styling/styleExtractor.d.ts.map +1 -1
- package/dist/extractors/styling/styleExtractor.js +177 -5
- package/dist/extractors/styling/styleExtractor.js.map +1 -1
- package/dist/types/UIFContract.d.ts +27 -4
- package/dist/types/UIFContract.d.ts.map +1 -1
- package/dist/types/UIFContract.js.map +1 -1
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +14 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/fileLock.d.ts.map +1 -1
- package/dist/utils/fileLock.js +3 -0
- package/dist/utils/fileLock.js.map +1 -1
- package/package.json +2 -2
- package/schema/logicstamp.context.schema.json +70 -9
- package/dist/cli/commands/context/incrementalWatch.d.ts.map +0 -1
- package/dist/cli/commands/context/incrementalWatch.js.map +0 -1
- package/dist/cli/commands/context/watchDiff.d.ts.map +0 -1
- package/dist/cli/commands/context/watchDiff.js.map +0 -1
- package/dist/cli/commands/context/watchMode.d.ts +0 -10
- package/dist/cli/commands/context/watchMode.d.ts.map +0 -1
- package/dist/cli/commands/context/watchMode.js.map +0 -1
|
@@ -8,22 +8,157 @@ import { hasExportedHooks, extractHookParameters } from './hookParameterExtracto
|
|
|
8
8
|
// TypeScript TypeFlags.Undefined constant (0x4000 = 16384)
|
|
9
9
|
// Used for checking if a union type includes undefined
|
|
10
10
|
const TYPEFLAG_UNDEFINED = 16384; // ts.TypeFlags.Undefined
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a function call in a try-catch, returning a default value on error.
|
|
13
|
+
* Use this to simplify error handling for operations that may fail but shouldn't
|
|
14
|
+
* stop processing of other items.
|
|
15
|
+
*/
|
|
16
|
+
function safeExtract(fn, defaultValue, errorContext) {
|
|
17
|
+
try {
|
|
18
|
+
return fn();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (errorContext) {
|
|
22
|
+
debugError('propExtractor', 'extractProps', {
|
|
23
|
+
filePath: errorContext.filePath,
|
|
24
|
+
error: error instanceof Error ? error.message : String(error),
|
|
25
|
+
context: errorContext.context,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
11
31
|
/**
|
|
12
32
|
* Safely get TypeScript type flags from a ts-morph Type
|
|
13
33
|
* Accesses the underlying TypeScript compiler type to get flags
|
|
14
34
|
*/
|
|
15
35
|
function getTypeFlags(type) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
const compilerType = type.compilerType;
|
|
37
|
+
if (compilerType && typeof compilerType.flags === 'number') {
|
|
38
|
+
return compilerType.flags;
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if a union type includes undefined
|
|
44
|
+
*/
|
|
45
|
+
function isUndefinedType(type) {
|
|
46
|
+
const flags = getTypeFlags(type);
|
|
47
|
+
if ((flags & TYPEFLAG_UNDEFINED) !== 0) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return type.getText() === 'undefined';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a union type contains undefined and extract the non-undefined type text
|
|
54
|
+
* Returns { hasUndefined, typeText } where typeText excludes undefined
|
|
55
|
+
*/
|
|
56
|
+
function analyzeUnionForUndefined(propType) {
|
|
57
|
+
if (!propType.isUnion()) {
|
|
58
|
+
return { hasUndefined: false, typeText: propType.getText() };
|
|
59
|
+
}
|
|
60
|
+
const unionTypes = propType.getUnionTypes();
|
|
61
|
+
const hasUndefined = unionTypes.some(isUndefinedType);
|
|
62
|
+
if (!hasUndefined) {
|
|
63
|
+
return { hasUndefined: false, typeText: propType.getText() };
|
|
64
|
+
}
|
|
65
|
+
const typeText = unionTypes
|
|
66
|
+
.filter(ut => !isUndefinedType(ut))
|
|
67
|
+
.map(ut => ut.getText())
|
|
68
|
+
.join(' | ');
|
|
69
|
+
return { hasUndefined: true, typeText };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Extract a single prop from an interface property
|
|
73
|
+
*/
|
|
74
|
+
function extractInterfaceProp(prop) {
|
|
75
|
+
const name = prop.getName();
|
|
76
|
+
let isOptional = prop.hasQuestionToken();
|
|
77
|
+
let type = prop.getType().getText();
|
|
78
|
+
let didRebuildFromUnion = false;
|
|
79
|
+
// Check for union-with-undefined (some people write foo: string | undefined without ?)
|
|
80
|
+
if (!isOptional) {
|
|
81
|
+
const analysis = analyzeUnionForUndefined(prop.getType());
|
|
82
|
+
if (analysis.hasUndefined) {
|
|
83
|
+
isOptional = true;
|
|
84
|
+
type = analysis.typeText;
|
|
85
|
+
didRebuildFromUnion = true;
|
|
21
86
|
}
|
|
22
87
|
}
|
|
23
|
-
|
|
24
|
-
|
|
88
|
+
// If optional but we didn't rebuild from union types, strip undefined from type text
|
|
89
|
+
if (isOptional && !didRebuildFromUnion) {
|
|
90
|
+
type = stripUndefinedFromUnionText(type);
|
|
25
91
|
}
|
|
26
|
-
return
|
|
92
|
+
return { name, propType: normalizePropType(type, isOptional) };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extract props from a single interface declaration
|
|
96
|
+
*/
|
|
97
|
+
function extractPropsFromInterface(iface, filePath) {
|
|
98
|
+
const props = {};
|
|
99
|
+
if (!/Props$/i.test(iface.getName())) {
|
|
100
|
+
return props;
|
|
101
|
+
}
|
|
102
|
+
for (const prop of iface.getProperties()) {
|
|
103
|
+
const result = safeExtract(() => extractInterfaceProp(prop), null, { filePath, context: 'props-interface-property' });
|
|
104
|
+
if (result) {
|
|
105
|
+
props[result.name] = result.propType;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return props;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Extract a single prop from a type alias property symbol
|
|
112
|
+
*/
|
|
113
|
+
function extractTypeAliasProp(prop, typeAlias) {
|
|
114
|
+
const name = prop.getName();
|
|
115
|
+
let isOptional = false;
|
|
116
|
+
let propType = prop.getTypeAtLocation(typeAlias).getText();
|
|
117
|
+
let didRebuildFromUnion = false;
|
|
118
|
+
// Method 1: Check if type is a union that includes undefined
|
|
119
|
+
const propTypeObj = prop.getTypeAtLocation(typeAlias);
|
|
120
|
+
const analysis = analyzeUnionForUndefined(propTypeObj);
|
|
121
|
+
if (analysis.hasUndefined) {
|
|
122
|
+
isOptional = true;
|
|
123
|
+
propType = analysis.typeText;
|
|
124
|
+
didRebuildFromUnion = true;
|
|
125
|
+
}
|
|
126
|
+
// Method 2: Check declarations for question token (AST method)
|
|
127
|
+
if (!isOptional) {
|
|
128
|
+
const declarations = prop.getDeclarations();
|
|
129
|
+
isOptional = declarations.some((decl) => {
|
|
130
|
+
if (Node.isPropertySignature(decl)) {
|
|
131
|
+
return decl.hasQuestionToken();
|
|
132
|
+
}
|
|
133
|
+
if (Node.isPropertyDeclaration(decl)) {
|
|
134
|
+
return decl.hasQuestionToken();
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// If optional but we didn't rebuild from union types, strip undefined from type text
|
|
140
|
+
if (isOptional && !didRebuildFromUnion) {
|
|
141
|
+
propType = stripUndefinedFromUnionText(propType);
|
|
142
|
+
}
|
|
143
|
+
return { name, propType: normalizePropType(propType, isOptional) };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Extract props from a single type alias declaration
|
|
147
|
+
*/
|
|
148
|
+
function extractPropsFromTypeAlias(typeAlias, filePath) {
|
|
149
|
+
const props = {};
|
|
150
|
+
if (!/Props$/i.test(typeAlias.getName())) {
|
|
151
|
+
return props;
|
|
152
|
+
}
|
|
153
|
+
const type = typeAlias.getType();
|
|
154
|
+
const properties = type.getProperties();
|
|
155
|
+
for (const prop of properties) {
|
|
156
|
+
const result = safeExtract(() => extractTypeAliasProp(prop, typeAlias), null, { filePath, context: 'props-typealias-property' });
|
|
157
|
+
if (result) {
|
|
158
|
+
props[result.name] = result.propType;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return props;
|
|
27
162
|
}
|
|
28
163
|
/**
|
|
29
164
|
* Extract component props from TypeScript interfaces/types
|
|
@@ -32,216 +167,28 @@ function getTypeFlags(type) {
|
|
|
32
167
|
export function extractProps(source) {
|
|
33
168
|
const props = {};
|
|
34
169
|
const filePath = source.getFilePath?.() ?? 'unknown';
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (/Props$/i.test(iface.getName())) {
|
|
41
|
-
iface.getProperties().forEach((prop) => {
|
|
42
|
-
try {
|
|
43
|
-
const name = prop.getName();
|
|
44
|
-
let isOptional = prop.hasQuestionToken();
|
|
45
|
-
let type = prop.getType().getText();
|
|
46
|
-
let didRebuildFromUnion = false;
|
|
47
|
-
// Also check for union-with-undefined (some people write foo: string | undefined without ?)
|
|
48
|
-
if (!isOptional) {
|
|
49
|
-
try {
|
|
50
|
-
const propType = prop.getType();
|
|
51
|
-
if (propType.isUnion()) {
|
|
52
|
-
const unionTypes = propType.getUnionTypes();
|
|
53
|
-
const hasUndefined = unionTypes.some(ut => {
|
|
54
|
-
try {
|
|
55
|
-
const flags = getTypeFlags(ut);
|
|
56
|
-
if ((flags & TYPEFLAG_UNDEFINED) !== 0) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
// Fallback to string check if flags not available
|
|
62
|
-
}
|
|
63
|
-
const text = ut.getText();
|
|
64
|
-
return text === 'undefined';
|
|
65
|
-
});
|
|
66
|
-
if (hasUndefined) {
|
|
67
|
-
isOptional = true;
|
|
68
|
-
// Normalize type text by removing undefined from union (handles any position)
|
|
69
|
-
type = unionTypes
|
|
70
|
-
.filter(ut => {
|
|
71
|
-
const flags = getTypeFlags(ut);
|
|
72
|
-
if ((flags & TYPEFLAG_UNDEFINED) !== 0) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
return ut.getText() !== 'undefined';
|
|
76
|
-
})
|
|
77
|
-
.map(ut => ut.getText())
|
|
78
|
-
.join(' | ');
|
|
79
|
-
didRebuildFromUnion = true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
// Fallback if union check fails
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// If optional but we didn't rebuild from union types, strip undefined from type text
|
|
88
|
-
// This handles cases like "foo?: undefined | string" where ? token made us skip union logic
|
|
89
|
-
if (isOptional && !didRebuildFromUnion) {
|
|
90
|
-
type = stripUndefinedFromUnionText(type);
|
|
91
|
-
}
|
|
92
|
-
props[name] = normalizePropType(type, isOptional);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
debugError('propExtractor', 'extractProps', {
|
|
96
|
-
filePath,
|
|
97
|
-
error: error instanceof Error ? error.message : String(error),
|
|
98
|
-
context: 'props-interface-property',
|
|
99
|
-
});
|
|
100
|
-
// Continue with next property
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
debugError('propExtractor', 'extractProps', {
|
|
107
|
-
filePath,
|
|
108
|
-
error: error instanceof Error ? error.message : String(error),
|
|
109
|
-
context: 'props-interface',
|
|
110
|
-
});
|
|
111
|
-
// Continue with next interface
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
debugError('propExtractor', 'extractProps', {
|
|
117
|
-
filePath,
|
|
118
|
-
error: error instanceof Error ? error.message : String(error),
|
|
119
|
-
context: 'props-interfaces-batch',
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
// Look for type aliases ending with Props
|
|
123
|
-
try {
|
|
124
|
-
source.getTypeAliases().forEach((typeAlias) => {
|
|
125
|
-
try {
|
|
126
|
-
if (/Props$/i.test(typeAlias.getName())) {
|
|
127
|
-
const type = typeAlias.getType();
|
|
128
|
-
const properties = type.getProperties();
|
|
129
|
-
properties.forEach((prop) => {
|
|
130
|
-
try {
|
|
131
|
-
const name = prop.getName();
|
|
132
|
-
// Check if optional using TypeScript's type system
|
|
133
|
-
let isOptional = false;
|
|
134
|
-
let propType = prop.getTypeAtLocation(typeAlias).getText();
|
|
135
|
-
let didRebuildFromUnion = false;
|
|
136
|
-
// Method 1: Check if type is a union that includes undefined
|
|
137
|
-
// Use type flags instead of string matching to avoid false positives
|
|
138
|
-
try {
|
|
139
|
-
const propTypeObj = prop.getTypeAtLocation(typeAlias);
|
|
140
|
-
if (propTypeObj.isUnion()) {
|
|
141
|
-
const unionTypes = propTypeObj.getUnionTypes();
|
|
142
|
-
const hasUndefined = unionTypes.some(ut => {
|
|
143
|
-
// Check type flags for undefined (more robust than string matching)
|
|
144
|
-
const flags = getTypeFlags(ut);
|
|
145
|
-
if ((flags & TYPEFLAG_UNDEFINED) !== 0) {
|
|
146
|
-
return true;
|
|
147
|
-
}
|
|
148
|
-
// Fallback: exact string match only (avoid false positives like SomeUndefinedType)
|
|
149
|
-
const text = ut.getText();
|
|
150
|
-
return text === 'undefined';
|
|
151
|
-
});
|
|
152
|
-
if (hasUndefined) {
|
|
153
|
-
isOptional = true;
|
|
154
|
-
// Normalize type text by removing undefined from union (handles any position)
|
|
155
|
-
// This ensures consistent output: undefined | string and string | undefined both become string
|
|
156
|
-
propType = unionTypes
|
|
157
|
-
.filter(ut => {
|
|
158
|
-
const flags = getTypeFlags(ut);
|
|
159
|
-
if ((flags & TYPEFLAG_UNDEFINED) !== 0) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
return ut.getText() !== 'undefined';
|
|
163
|
-
})
|
|
164
|
-
.map(ut => ut.getText())
|
|
165
|
-
.join(' | ');
|
|
166
|
-
didRebuildFromUnion = true;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
catch {
|
|
171
|
-
// Fallback if union check fails
|
|
172
|
-
}
|
|
173
|
-
// Method 2: Check declarations for question token (AST method)
|
|
174
|
-
if (!isOptional) {
|
|
175
|
-
const declarations = prop.getDeclarations();
|
|
176
|
-
isOptional = declarations.some((decl) => {
|
|
177
|
-
// Use AST method to check for question token
|
|
178
|
-
// PropertySignature and PropertyDeclaration both have hasQuestionToken()
|
|
179
|
-
if (Node.isPropertySignature(decl)) {
|
|
180
|
-
return decl.hasQuestionToken();
|
|
181
|
-
}
|
|
182
|
-
if (Node.isPropertyDeclaration(decl)) {
|
|
183
|
-
return decl.hasQuestionToken();
|
|
184
|
-
}
|
|
185
|
-
return false;
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
// If optional but we didn't rebuild from union types, strip undefined from type text
|
|
189
|
-
// This handles cases like "foo?: undefined | string" where ? token made us skip union logic
|
|
190
|
-
// Also handles "foo?: string | number" where union exists but doesn't contain undefined
|
|
191
|
-
if (isOptional && !didRebuildFromUnion) {
|
|
192
|
-
propType = stripUndefinedFromUnionText(propType);
|
|
193
|
-
}
|
|
194
|
-
props[name] = normalizePropType(propType, isOptional);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
debugError('propExtractor', 'extractProps', {
|
|
198
|
-
filePath,
|
|
199
|
-
error: error instanceof Error ? error.message : String(error),
|
|
200
|
-
context: 'props-typealias-property',
|
|
201
|
-
});
|
|
202
|
-
// Continue with next property
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
debugError('propExtractor', 'extractProps', {
|
|
209
|
-
filePath,
|
|
210
|
-
error: error instanceof Error ? error.message : String(error),
|
|
211
|
-
context: 'props-typealias',
|
|
212
|
-
});
|
|
213
|
-
// Continue with next type alias
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
debugError('propExtractor', 'extractProps', {
|
|
219
|
-
filePath,
|
|
220
|
-
error: error instanceof Error ? error.message : String(error),
|
|
221
|
-
context: 'props-typealiases-batch',
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
// Always try to extract hook parameters if there are exported hooks
|
|
225
|
-
// This ensures hook parameters are captured even if there's a Props interface
|
|
226
|
-
// Props take priority on conflicts (if a prop exists in both, Props value is kept)
|
|
227
|
-
// Quick check: only extract if there might be exported hooks (performance optimization)
|
|
228
|
-
if (hasExportedHooks(source)) {
|
|
229
|
-
const hookParams = extractHookParameters(source);
|
|
230
|
-
if (Object.keys(hookParams).length > 0) {
|
|
231
|
-
// Merge hook parameters with Props, with Props taking priority on conflicts
|
|
232
|
-
// Save original props to preserve Props values, then merge hookParams, then restore Props
|
|
233
|
-
const originalProps = { ...props };
|
|
234
|
-
Object.assign(props, hookParams);
|
|
235
|
-
Object.assign(props, originalProps); // Props override any conflicting hook parameters
|
|
236
|
-
}
|
|
237
|
-
}
|
|
170
|
+
// Extract props from interfaces ending with Props
|
|
171
|
+
const interfaces = safeExtract(() => source.getInterfaces(), [], { filePath, context: 'props-interfaces-batch' });
|
|
172
|
+
for (const iface of interfaces) {
|
|
173
|
+
const ifaceProps = safeExtract(() => extractPropsFromInterface(iface, filePath), {}, { filePath, context: 'props-interface' });
|
|
174
|
+
Object.assign(props, ifaceProps);
|
|
238
175
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
176
|
+
// Extract props from type aliases ending with Props
|
|
177
|
+
const typeAliases = safeExtract(() => source.getTypeAliases(), [], { filePath, context: 'props-typealiases-batch' });
|
|
178
|
+
for (const typeAlias of typeAliases) {
|
|
179
|
+
const typeAliasProps = safeExtract(() => extractPropsFromTypeAlias(typeAlias, filePath), {}, { filePath, context: 'props-typealias' });
|
|
180
|
+
Object.assign(props, typeAliasProps);
|
|
181
|
+
}
|
|
182
|
+
// Extract hook parameters if there are exported hooks
|
|
183
|
+
// Props take priority on conflicts (if a prop exists in both, Props value is kept)
|
|
184
|
+
if (hasExportedHooks(source)) {
|
|
185
|
+
const hookParams = extractHookParameters(source);
|
|
186
|
+
if (Object.keys(hookParams).length > 0) {
|
|
187
|
+
// Merge hook parameters with Props, with Props taking priority on conflicts
|
|
188
|
+
const originalProps = { ...props };
|
|
189
|
+
Object.assign(props, hookParams);
|
|
190
|
+
Object.assign(props, originalProps); // Props override any conflicting hook parameters
|
|
191
|
+
}
|
|
245
192
|
}
|
|
246
193
|
return props;
|
|
247
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propExtractor.js","sourceRoot":"","sources":["../../../src/extractors/react/propExtractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAc,IAAI,
|
|
1
|
+
{"version":3,"file":"propExtractor.js","sourceRoot":"","sources":["../../../src/extractors/react/propExtractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAc,IAAI,EAAgG,MAAM,UAAU,CAAC;AAE1I,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACjG,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,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yB,CAAC,SAAS,EAAE,QAAQ,CAAC,EACpD,EAAE,EACF,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,EAAE,CACzC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IACvC,CAAC;IAED,sDAAsD;IACtD,mFAAmF;IACnF,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,4EAA4E;YAC5E,MAAM,aAAa,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;YACnC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YACjC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,iDAAiD;QACxF,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yDAAyD;AACzD,+EAA+E;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* Orchestrates extraction of style metadata from TypeScript components
|
|
4
4
|
*/
|
|
5
5
|
import { SourceFile } from 'ts-morph';
|
|
6
|
-
import type { StyleMetadata } from '../../types/UIFContract.js';
|
|
6
|
+
import type { StyleMetadata, StyleMode } from '../../types/UIFContract.js';
|
|
7
7
|
/**
|
|
8
8
|
* Extract style metadata from a source file
|
|
9
|
+
* @param source - The source file to extract from
|
|
10
|
+
* @param filePath - The file path for error reporting
|
|
11
|
+
* @param mode - Style extraction mode: 'lean' (default) or 'full'
|
|
9
12
|
*/
|
|
10
|
-
export declare function extractStyleMetadata(source: SourceFile, filePath: string): Promise<StyleMetadata | undefined>;
|
|
13
|
+
export declare function extractStyleMetadata(source: SourceFile, filePath: string, mode?: StyleMode): Promise<StyleMetadata | undefined>;
|
|
11
14
|
//# sourceMappingURL=styleExtractor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleExtractor.d.ts","sourceRoot":"","sources":["../../../src/extractors/styling/styleExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAyF,MAAM,UAAU,CAAC;AAC7H,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"styleExtractor.d.ts","sourceRoot":"","sources":["../../../src/extractors/styling/styleExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAyF,MAAM,UAAU,CAAC;AAC7H,OAAO,KAAK,EAAE,aAAa,EAAgB,SAAS,EAAgD,MAAM,4BAA4B,CAAC;AAcvI;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,SAAkB,GACvB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAuEpC"}
|