jsx-prop-lookup-mcp-server 1.0.0
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/LICENSE +21 -0
- package/PUBLISH.md +53 -0
- package/README.md +99 -0
- package/RELEASE_NOTES.md +38 -0
- package/USAGE.md +66 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-analyzer.d.ts +37 -0
- package/dist/jsx-analyzer.d.ts.map +1 -0
- package/dist/jsx-analyzer.js +274 -0
- package/dist/jsx-analyzer.js.map +1 -0
- package/examples/sample-components/App.tsx +52 -0
- package/examples/sample-components/Button.tsx +31 -0
- package/examples/sample-components/Card.tsx +32 -0
- package/mcp-config.json +9 -0
- package/package.json +35 -0
- package/src/index.ts +183 -0
- package/src/jsx-analyzer.ts +361 -0
- package/tsconfig.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 JSX Prop Lookup MCP Server
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, so the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/PUBLISH.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Publishing Guide
|
|
2
|
+
|
|
3
|
+
## Git Repository Setup
|
|
4
|
+
|
|
5
|
+
1. **Create GitHub repository:**
|
|
6
|
+
```bash
|
|
7
|
+
# Go to GitHub and create a new repository named: jsx-prop-lookup-mcp-server
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Add remote and push:**
|
|
11
|
+
```bash
|
|
12
|
+
git remote add origin https://github.com/YOUR_USERNAME/jsx-prop-lookup-mcp-server.git
|
|
13
|
+
git branch -M main
|
|
14
|
+
git push -u origin main
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## NPM Publishing
|
|
18
|
+
|
|
19
|
+
1. **Login to NPM:**
|
|
20
|
+
```bash
|
|
21
|
+
npm login
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
2. **Update package.json with your GitHub username:**
|
|
25
|
+
- Replace `your-username` in the repository URLs with your actual GitHub username
|
|
26
|
+
|
|
27
|
+
3. **Publish to NPM:**
|
|
28
|
+
```bash
|
|
29
|
+
npm publish
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## MCP Registry (Optional)
|
|
33
|
+
|
|
34
|
+
Consider submitting to the MCP server registry once it's available.
|
|
35
|
+
|
|
36
|
+
## Post-Publishing
|
|
37
|
+
|
|
38
|
+
1. **Update README with installation instructions:**
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g jsx-prop-lookup-mcp-server
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
2. **Create GitHub release:**
|
|
44
|
+
- Tag version v1.0.0
|
|
45
|
+
- Include release notes
|
|
46
|
+
|
|
47
|
+
## Current Status
|
|
48
|
+
|
|
49
|
+
✅ Code committed to git
|
|
50
|
+
✅ Built successfully
|
|
51
|
+
✅ Ready for publishing
|
|
52
|
+
|
|
53
|
+
**Next steps:** Update GitHub username in package.json and push to your repository!
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# JSX Prop Lookup MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that analyzes JSX prop usage in React/TypeScript codebases using AST parsing.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **AST-based Analysis**: Uses Babel parser for accurate JSX/TSX parsing
|
|
8
|
+
- **Prop Usage Tracking**: Find where props are used across components
|
|
9
|
+
- **Component Analysis**: Analyze prop definitions and usage patterns
|
|
10
|
+
- **TypeScript Support**: Includes TypeScript interface analysis
|
|
11
|
+
- **Multiple Search Options**: Search by component, prop name, or analyze entire directories
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install
|
|
17
|
+
npm run build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
The server provides three main tools:
|
|
23
|
+
|
|
24
|
+
### 1. `analyze_jsx_props`
|
|
25
|
+
Analyze JSX prop usage in files or directories.
|
|
26
|
+
|
|
27
|
+
**Parameters:**
|
|
28
|
+
- `path` (required): File or directory path to analyze
|
|
29
|
+
- `componentName` (optional): Specific component name to analyze
|
|
30
|
+
- `propName` (optional): Specific prop name to search for
|
|
31
|
+
- `includeTypes` (optional): Include TypeScript type information (default: true)
|
|
32
|
+
|
|
33
|
+
### 2. `find_prop_usage`
|
|
34
|
+
Find all usages of a specific prop across JSX files.
|
|
35
|
+
|
|
36
|
+
**Parameters:**
|
|
37
|
+
- `propName` (required): Name of the prop to search for
|
|
38
|
+
- `directory` (optional): Directory to search in (default: ".")
|
|
39
|
+
- `componentName` (optional): Limit search to specific component
|
|
40
|
+
|
|
41
|
+
### 3. `get_component_props`
|
|
42
|
+
Get all props used by a specific component.
|
|
43
|
+
|
|
44
|
+
**Parameters:**
|
|
45
|
+
- `componentName` (required): Name of the component to analyze
|
|
46
|
+
- `directory` (optional): Directory to search in (default: ".")
|
|
47
|
+
|
|
48
|
+
## Example Output
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"summary": {
|
|
53
|
+
"totalFiles": 5,
|
|
54
|
+
"totalComponents": 3,
|
|
55
|
+
"totalProps": 12
|
|
56
|
+
},
|
|
57
|
+
"components": [
|
|
58
|
+
{
|
|
59
|
+
"componentName": "Button",
|
|
60
|
+
"file": "./src/Button.tsx",
|
|
61
|
+
"props": [
|
|
62
|
+
{
|
|
63
|
+
"propName": "onClick",
|
|
64
|
+
"componentName": "Button",
|
|
65
|
+
"file": "./src/Button.tsx",
|
|
66
|
+
"line": 5,
|
|
67
|
+
"column": 10
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"propsInterface": "ButtonProps"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"propUsages": [
|
|
74
|
+
{
|
|
75
|
+
"propName": "className",
|
|
76
|
+
"componentName": "Button",
|
|
77
|
+
"file": "./src/App.tsx",
|
|
78
|
+
"line": 15,
|
|
79
|
+
"column": 20,
|
|
80
|
+
"value": "btn-primary"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Supported File Types
|
|
87
|
+
|
|
88
|
+
- `.js` - JavaScript
|
|
89
|
+
- `.jsx` - JavaScript with JSX
|
|
90
|
+
- `.ts` - TypeScript
|
|
91
|
+
- `.tsx` - TypeScript with JSX
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm run dev # Run in development mode
|
|
97
|
+
npm run build # Build for production
|
|
98
|
+
npm start # Run built version
|
|
99
|
+
```
|
package/RELEASE_NOTES.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Release Notes
|
|
2
|
+
|
|
3
|
+
## v1.0.0 - Initial Release
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
- ✅ **Complete MCP Server** for JSX prop analysis using AST parsing
|
|
7
|
+
- ✅ **Three Analysis Tools**:
|
|
8
|
+
- `analyze_jsx_props` - Comprehensive prop analysis
|
|
9
|
+
- `find_prop_usage` - Search specific prop usage
|
|
10
|
+
- `get_component_props` - Extract component props
|
|
11
|
+
- ✅ **React/TypeScript Support** - Full JSX/TSX parsing
|
|
12
|
+
- ✅ **Babel AST Parser** - Accurate code analysis
|
|
13
|
+
- ✅ **TypeScript Interface Detection** - Prop type information
|
|
14
|
+
- ✅ **Spread Operator Handling** - `...rest` and `...spread` props
|
|
15
|
+
- ✅ **Location Tracking** - Line/column information for all findings
|
|
16
|
+
- ✅ **Prop Value Extraction** - String literals, expressions, identifiers
|
|
17
|
+
|
|
18
|
+
### Technical Details
|
|
19
|
+
- Built with MCP SDK v0.4.0
|
|
20
|
+
- Babel parser with comprehensive plugin support
|
|
21
|
+
- TypeScript compilation target: ES2022
|
|
22
|
+
- Node.js ESM modules
|
|
23
|
+
|
|
24
|
+
### Tested With
|
|
25
|
+
- React functional components
|
|
26
|
+
- TypeScript interfaces
|
|
27
|
+
- Arrow functions and function declarations
|
|
28
|
+
- JSX prop destructuring
|
|
29
|
+
- Spread operators
|
|
30
|
+
- Complex component hierarchies
|
|
31
|
+
|
|
32
|
+
### Ready For
|
|
33
|
+
- Production use
|
|
34
|
+
- Integration with MCP clients
|
|
35
|
+
- Large React codebases
|
|
36
|
+
- Development tooling
|
|
37
|
+
|
|
38
|
+
**Installation:** `npm install jsx-prop-lookup-mcp-server`
|
package/USAGE.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# JSX Prop Lookup MCP Server Usage Guide
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
1. **Install dependencies:**
|
|
6
|
+
```bash
|
|
7
|
+
npm install
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
2. **Build the server:**
|
|
11
|
+
```bash
|
|
12
|
+
npm run build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
3. **Test the server:**
|
|
16
|
+
```bash
|
|
17
|
+
npm start
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Example Usage
|
|
21
|
+
|
|
22
|
+
The server successfully analyzes JSX prop usage as demonstrated with the sample components:
|
|
23
|
+
|
|
24
|
+
### Sample Analysis Results
|
|
25
|
+
|
|
26
|
+
**Button Component Props:**
|
|
27
|
+
- `children`, `onClick`, `disabled`, `variant`, `className`, `...rest`
|
|
28
|
+
- Includes TypeScript interface: `ButtonProps`
|
|
29
|
+
|
|
30
|
+
**onClick Prop Usage Found:**
|
|
31
|
+
- Button component definition (parameter destructuring)
|
|
32
|
+
- Button JSX element usage in App component
|
|
33
|
+
- Native button element in Button component
|
|
34
|
+
|
|
35
|
+
**Key Features Demonstrated:**
|
|
36
|
+
- ✅ AST-based parsing of JSX/TSX files
|
|
37
|
+
- ✅ Component prop extraction from function parameters
|
|
38
|
+
- ✅ JSX element prop usage tracking
|
|
39
|
+
- ✅ TypeScript interface detection
|
|
40
|
+
- ✅ Spread operator handling
|
|
41
|
+
- ✅ Line/column location tracking
|
|
42
|
+
- ✅ Prop value extraction (strings, expressions)
|
|
43
|
+
|
|
44
|
+
## MCP Integration
|
|
45
|
+
|
|
46
|
+
Add to your MCP client configuration:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"jsx-prop-lookup": {
|
|
52
|
+
"command": "node",
|
|
53
|
+
"args": ["dist/index.js"],
|
|
54
|
+
"cwd": "/path/to/jsx-prop-lookup-mcp-server"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Available Tools
|
|
61
|
+
|
|
62
|
+
1. **analyze_jsx_props** - Comprehensive analysis of JSX props in files/directories
|
|
63
|
+
2. **find_prop_usage** - Find specific prop usage across codebase
|
|
64
|
+
3. **get_component_props** - Get all props for a specific component
|
|
65
|
+
|
|
66
|
+
The server is ready for production use!
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { JSXPropAnalyzer } from './jsx-analyzer.js';
|
|
6
|
+
const server = new Server({
|
|
7
|
+
name: 'jsx-prop-lookup-server',
|
|
8
|
+
version: '1.0.0',
|
|
9
|
+
capabilities: {
|
|
10
|
+
tools: {},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
const analyzer = new JSXPropAnalyzer();
|
|
14
|
+
// List available tools
|
|
15
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
16
|
+
return {
|
|
17
|
+
tools: [
|
|
18
|
+
{
|
|
19
|
+
name: 'analyze_jsx_props',
|
|
20
|
+
description: 'Analyze JSX prop usage in files or directories',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
path: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'File or directory path to analyze',
|
|
27
|
+
},
|
|
28
|
+
componentName: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'Optional: specific component name to analyze',
|
|
31
|
+
},
|
|
32
|
+
propName: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Optional: specific prop name to search for',
|
|
35
|
+
},
|
|
36
|
+
includeTypes: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
description: 'Include TypeScript type information',
|
|
39
|
+
default: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
required: ['path'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'find_prop_usage',
|
|
47
|
+
description: 'Find all usages of a specific prop across JSX files',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
propName: {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: 'Name of the prop to search for',
|
|
54
|
+
},
|
|
55
|
+
directory: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'Directory to search in',
|
|
58
|
+
default: '.',
|
|
59
|
+
},
|
|
60
|
+
componentName: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Optional: limit search to specific component',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ['propName'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'get_component_props',
|
|
70
|
+
description: 'Get all props used by a specific component',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
componentName: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: 'Name of the component to analyze',
|
|
77
|
+
},
|
|
78
|
+
directory: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'Directory to search in',
|
|
81
|
+
default: '.',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
required: ['componentName'],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
// Handle tool calls
|
|
91
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
92
|
+
const { name, arguments: args } = request.params;
|
|
93
|
+
if (!args) {
|
|
94
|
+
throw new Error('Missing arguments');
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
switch (name) {
|
|
98
|
+
case 'analyze_jsx_props': {
|
|
99
|
+
const result = await analyzer.analyzeProps(args.path, args.componentName, args.propName, args.includeTypes ?? true);
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: 'text',
|
|
104
|
+
text: JSON.stringify(result, null, 2),
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
case 'find_prop_usage': {
|
|
110
|
+
const result = await analyzer.findPropUsage(args.propName, args.directory ?? '.', args.componentName);
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: 'text',
|
|
115
|
+
text: JSON.stringify(result, null, 2),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
case 'get_component_props': {
|
|
121
|
+
const result = await analyzer.getComponentProps(args.componentName, args.directory ?? '.');
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: 'text',
|
|
126
|
+
text: JSON.stringify(result, null, 2),
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
default:
|
|
132
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return {
|
|
137
|
+
content: [
|
|
138
|
+
{
|
|
139
|
+
type: 'text',
|
|
140
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
isError: true,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
async function main() {
|
|
148
|
+
const transport = new StdioServerTransport();
|
|
149
|
+
await server.connect(transport);
|
|
150
|
+
console.error('JSX Prop Lookup MCP Server running on stdio');
|
|
151
|
+
}
|
|
152
|
+
main().catch((error) => {
|
|
153
|
+
console.error('Server error:', error);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;KACV;CACF,CACF,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;AAEvC,uBAAuB;AACvB,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IAC1D,OAAO;QACL,KAAK,EAAE;YACL;gBACE,IAAI,EAAE,mBAAmB;gBACzB,WAAW,EAAE,gDAAgD;gBAC7D,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE;4BACJ,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,mCAAmC;yBACjD;wBACD,aAAa,EAAE;4BACb,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,8CAA8C;yBAC5D;wBACD,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,4CAA4C;yBAC1D;wBACD,YAAY,EAAE;4BACZ,IAAI,E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AC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACzE;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;AAC/D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface PropUsage {
|
|
2
|
+
propName: string;
|
|
3
|
+
componentName: string;
|
|
4
|
+
file: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
value?: string;
|
|
8
|
+
isSpread?: boolean;
|
|
9
|
+
type?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ComponentAnalysis {
|
|
12
|
+
componentName: string;
|
|
13
|
+
file: string;
|
|
14
|
+
props: PropUsage[];
|
|
15
|
+
propsInterface?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AnalysisResult {
|
|
18
|
+
summary: {
|
|
19
|
+
totalFiles: number;
|
|
20
|
+
totalComponents: number;
|
|
21
|
+
totalProps: number;
|
|
22
|
+
};
|
|
23
|
+
components: ComponentAnalysis[];
|
|
24
|
+
propUsages: PropUsage[];
|
|
25
|
+
}
|
|
26
|
+
export declare class JSXPropAnalyzer {
|
|
27
|
+
private readonly supportedExtensions;
|
|
28
|
+
analyzeProps(path: string, componentName?: string, propName?: string, includeTypes?: boolean): Promise<AnalysisResult>;
|
|
29
|
+
findPropUsage(propName: string, directory?: string, componentName?: string): Promise<PropUsage[]>;
|
|
30
|
+
getComponentProps(componentName: string, directory?: string): Promise<ComponentAnalysis[]>;
|
|
31
|
+
private getFiles;
|
|
32
|
+
private analyzeFile;
|
|
33
|
+
private findPropsInFunctionBody;
|
|
34
|
+
private analyzeObjectPattern;
|
|
35
|
+
private analyzeJSXElement;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=jsx-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-analyzer.d.ts","sourceRoot":"","sources":["../src/jsx-analyzer.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE;QACP,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,qBAAa,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