|
1 | 1 | # Web Component Analyzer |
2 | 2 |
|
3 | | -Visualize the internal structure of frontend components through Data Flow Diagrams (DFD). |
4 | | - |
5 | | -**Supported Frameworks:** React, Vue 3 (Composition API with `<script setup>`) |
6 | | - |
7 | | -## Monorepo Structure |
8 | | - |
9 | | -This project uses pnpm workspaces to manage multiple packages: |
10 | | - |
| 3 | +Visualize the internal structure of frontend components through Data Flow Diagrams (DFD) like the following mermaid.js style. |
| 4 | + |
| 5 | +```mermaid |
| 6 | +%%{init: {'theme': 'base', 'themeVariables': {'fontFamily': 'Comic Sans MS, cursive'}, 'flowchart': {'curve': 'basis', 'padding': 20}}}%% |
| 7 | +flowchart LR |
| 8 | + subgraph InputProps["Input Props"] |
| 9 | + direction TB |
| 10 | + prop_0("name") |
| 11 | + prop_1("greeting") |
| 12 | + end |
| 13 | + state_2[("count")] |
| 14 | + process_3[["handleClick"]] |
| 15 | + jsx_element_0["h1"] |
| 16 | + jsx_element_1["p"] |
| 17 | + jsx_element_2["button"] |
| 18 | + subgraph subgraph_0["JSX Output"] |
| 19 | + direction TB |
| 20 | + jsx_element_0@{ shape: hex, label: "<h1>" } |
| 21 | + jsx_element_1@{ shape: hex, label: "<p>" } |
| 22 | + jsx_element_2@{ shape: hex, label: "<button>" } |
| 23 | + end |
| 24 | + prop_1 eprop_1_jsx_element_0@-->|"display"| jsx_element_0 |
| 25 | + eprop_1_jsx_element_0@{ animate: true } |
| 26 | + prop_0 eprop_0_jsx_element_0@-->|"display"| jsx_element_0 |
| 27 | + eprop_0_jsx_element_0@{ animate: true } |
| 28 | + state_2 estate_2_jsx_element_1@-->|"display"| jsx_element_1 |
| 29 | + estate_2_jsx_element_1@{ animate: true } |
| 30 | + jsx_element_2 ejsx_element_2_process_3@-->|"onClick"| process_3 |
| 31 | + ejsx_element_2_process_3@{ animate: true } |
| 32 | + state_2 estate_2_process_3@-->|"reads"| process_3 |
| 33 | + estate_2_process_3@{ animate: true } |
| 34 | + process_3 eprocess_3_state_2@-->|"writes"| state_2 |
| 35 | + eprocess_3_state_2@{ animate: true } |
| 36 | +
|
| 37 | + %% Styling |
| 38 | + classDef inputProp fill:#E3F2FD,stroke:#2196F3,stroke-width:2px |
| 39 | + classDef outputProp fill:#FFF3E0,stroke:#FF9800,stroke-width:2px |
| 40 | + classDef process fill:#F3E5F5,stroke:#9C27B0,stroke-width:3px |
| 41 | + classDef dataStore fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px |
| 42 | + classDef libraryHook fill:#C8E6C9,stroke:#388E3C,stroke-width:2px |
| 43 | + classDef jsxElement fill:#FFF3E0,stroke:#FF9800,stroke-width:2px |
| 44 | + classDef contextData fill:#E1F5FE,stroke:#0288D1,stroke-width:2px |
| 45 | + classDef contextFunction fill:#FFF9C4,stroke:#F57C00,stroke-width:2px |
| 46 | + classDef exportedHandler fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px |
| 47 | + class prop_0 inputProp |
| 48 | + class prop_1 inputProp |
| 49 | + class state_2 dataStore |
| 50 | + class process_3 process |
| 51 | + class jsx_element_0 jsxElement |
| 52 | + class jsx_element_1 jsxElement |
| 53 | + class jsx_element_2 jsxElement |
11 | 54 | ``` |
12 | | -packages/ |
13 | | -├── analyzer/ # Core parsing and analysis logic (platform-independent) |
14 | | -├── extension/ # VS Code extension |
15 | | -└── web/ # Web application (GitHub Pages) |
16 | | -``` |
17 | | - |
18 | | -## Getting Started |
19 | | - |
20 | | -### Prerequisites |
21 | | - |
22 | | -- Node.js 22.x |
23 | | -- pnpm 9.x |
24 | | - |
25 | | -### Installation |
26 | | - |
27 | | -```bash |
28 | | -pnpm install |
29 | | -``` |
30 | | - |
31 | | -### Development |
32 | | - |
33 | | -```bash |
34 | | -# Build all packages |
35 | | -pnpm build |
36 | | - |
37 | | -# Watch mode for all packages |
38 | | -pnpm dev |
39 | | - |
40 | | -# Run linter |
41 | | -pnpm lint |
42 | | - |
43 | | -# Run tests |
44 | | -pnpm test |
45 | | -``` |
46 | | - |
47 | | -### Package-specific Commands |
48 | | - |
49 | | -```bash |
50 | | -# Build analyzer only |
51 | | -pnpm --filter @web-component-analyzer/analyzer run build |
52 | | - |
53 | | -# Build extension only |
54 | | -pnpm --filter web-component-analyzer run build |
55 | | - |
56 | | -# Build web app only |
57 | | -pnpm --filter @web-component-analyzer/web run build |
58 | | - |
59 | | -# Start web dev server |
60 | | -pnpm --filter @web-component-analyzer/web run dev |
61 | | -``` |
62 | | - |
63 | | -## Packages |
64 | | - |
65 | | -### @web-component-analyzer/analyzer |
66 | 55 |
|
67 | | -Core parsing and analysis logic for React and Vue 3 components. Platform-independent TypeScript library. |
| 56 | +## How To Use |
| 57 | + |
| 58 | +Install extension |
| 59 | + |
| 60 | +Launch command `Show Component DFD` from command palette. |
| 61 | + |
| 62 | +## Supported Frameworks |
| 63 | + |
| 64 | +* React |
| 65 | + * Router |
| 66 | + * Next.js |
| 67 | + * TanStack Router |
| 68 | + * React Router |
| 69 | + * Query |
| 70 | + * SWR |
| 71 | + * TanStack Query |
| 72 | + * Apollo |
| 73 | + * tRPC |
| 74 | + * Data Store |
| 75 | + * Zustand |
| 76 | + * Jotai |
| 77 | + * MobX |
| 78 | + * From |
| 79 | + * React Hook Form |
| 80 | +* Vue 3 (Composition API with `<script setup>`) |
| 81 | + * Vue Router |
| 82 | + * Pinia |
| 83 | +* Svelte5 |
| 84 | + * SvelteKit router |
68 | 85 |
|
69 | | -- AST parsing using SWC |
70 | | -- Component analysis (props, state, hooks, composables, etc.) |
71 | | -- DFD data generation |
72 | | -- Support for React hooks and Vue 3 Composition API |
73 | | -- Third-party library adapters (Vue Router, Pinia, React Router, SWR, TanStack Query, etc.) |
74 | | - |
75 | | -### web-component-analyzer (extension) |
76 | | - |
77 | | -VS Code extension that provides: |
78 | | - |
79 | | -- Command palette integration |
80 | | -- Webview-based DFD visualization |
81 | | -- Real-time component analysis |
82 | | -- Mermaid diagram rendering |
83 | | - |
84 | | -### @web-component-analyzer/web |
85 | | - |
86 | | -Browser-based web application for analyzing React and Vue 3 components: |
87 | | - |
88 | | -- **Interactive Code Editor**: Monaco Editor with syntax highlighting |
89 | | -- **Real-Time Visualization**: See DFD updates as you type |
90 | | -- **Sample Components**: 10+ examples demonstrating different patterns (React hooks, Vue composables, etc.) |
91 | | -- **Framework Support**: React (JSX/TSX) and Vue 3 (SFC with `<script setup>`) |
92 | | -- **URL Sharing**: Share component code via compressed URLs |
93 | | -- **Themed Interface**: Light (Easter) and dark (Halloween) modes with decorations |
94 | | -- **No Installation**: Runs entirely in the browser |
95 | | - |
96 | | -**🚀 [Try the Live Demo](https://[your-username].github.io/web-component-analyzer/)** |
97 | | - |
98 | | -Deployed to GitHub Pages with automatic deployment via GitHub Actions. |
99 | | - |
100 | | -## Development Workflow |
101 | | - |
102 | | -1. Make changes to `packages/analyzer` for core logic |
103 | | -2. Test in `packages/extension` for VS Code integration |
104 | | -3. Test in `packages/web` for web UI |
105 | | - |
106 | | -Changes to the analyzer package are automatically reflected in both extension and web packages through workspace references. |
107 | | - |
108 | | -## Publishing |
109 | | - |
110 | | -### VS Code Extension |
111 | | - |
112 | | -```bash |
113 | | -cd packages/extension |
114 | | -pnpm run vscode:prepublish |
115 | | -vsce package |
116 | | -``` |
117 | | - |
118 | | -### Web Application |
119 | | - |
120 | | -GitHub Actions automatically deploys to GitHub Pages on push to main branch. |
121 | | - |
122 | | -## Documentation |
123 | | - |
124 | | -- **[Vue 3 Support Guide](docs/vue-support.md)** - Comprehensive guide for Vue 3 Composition API support |
125 | | -- **[React Support](packages/extension/README.md)** - React hooks and patterns |
126 | | - |
127 | | -## Framework Support |
128 | | - |
129 | | -### React |
130 | | -- ✅ Functional components with hooks |
131 | | -- ✅ Props and state management |
132 | | -- ✅ Context API |
133 | | -- ✅ Third-party libraries (React Router, SWR, TanStack Query, Zustand, Jotai, MobX, etc.) |
134 | | - |
135 | | -### Vue 3 |
136 | | -- ✅ Composition API with `<script setup>` |
137 | | -- ✅ Props (`defineProps`) |
138 | | -- ✅ Reactive state (`ref`, `reactive`, `computed`) |
139 | | -- ✅ Composables and lifecycle hooks |
140 | | -- ✅ Event emits (`defineEmits`) |
141 | | -- ✅ Template directives (v-bind, v-on, v-model, v-if, v-for, etc.) |
142 | | -- ✅ Vue Router integration |
143 | | -- ✅ Pinia state management |
144 | | -- ❌ Options API (not supported) |
| 86 | +## License |
145 | 87 |
|
146 | | -See the [Vue 3 Support Guide](docs/vue-support.md) for detailed documentation. |
| 88 | +Apache2 |
147 | 89 |
|
148 | | -## License |
| 90 | +## Known Issues |
149 | 91 |
|
150 | | -MIT |
| 92 | +* DFD nodes are clickable and navigate to source code positions. But locations are sometimes wrong. |
0 commit comments