react-state-flow 0.0.3 → 0.1.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/LICENSE +21 -0
- package/README.md +56 -18
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +139 -75978
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +65 -0
- package/dist/parser/parse-file.d.ts +8 -0
- package/dist/parser/parse-file.d.ts.map +1 -0
- package/dist/parser/parse-file.js +251 -0
- package/dist/parser/types.d.ts +23 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js +1 -0
- package/dist/runtime/index.d.ts +22 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +109 -0
- package/package.json +35 -9
- package/ui/dist/assets/index-VkAtFIbS.js +62 -0
- package/{dist/ui → ui/dist}/index.html +1 -1
- package/dist/ui/assets/index-CMEcbN2L.js +0 -62
- /package/{dist/ui → ui/dist}/assets/index-BZV40eAE.css +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HoangSonDeveloper
|
|
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, subject to 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/README.md
CHANGED
|
@@ -1,41 +1,79 @@
|
|
|
1
1
|
# react-state-flow
|
|
2
2
|
|
|
3
|
-
Visualize
|
|
3
|
+
Visualize React component state and re-render flow in real time.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Parses your React codebase into an interactive graph, then overlays live render data from your running app — so you can see which components re-render, how often, and how state flows through the tree.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
1. **Static analysis** — scans your source files and builds a component graph (components, contexts, parent-child relationships)
|
|
10
|
+
2. **Runtime instrumentation** — hooks into React DevTools to capture render events without modifying your components
|
|
11
|
+
3. **Live visualization** — renders an interactive graph in the browser, updated in real time as your app runs
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## Installation
|
|
10
14
|
|
|
11
15
|
```bash
|
|
12
|
-
|
|
16
|
+
npm install react-state-flow
|
|
13
17
|
```
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Step 1 — Add runtime instrumentation
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
Import at the very top of your `main.tsx` (before React mounts):
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
```ts
|
|
26
|
+
import 'react-state-flow/runtime'
|
|
27
|
+
import { StrictMode } from 'react'
|
|
28
|
+
import { createRoot } from 'react-dom/client'
|
|
29
|
+
import App from './App'
|
|
30
|
+
|
|
31
|
+
createRoot(document.getElementById('root')!).render(
|
|
32
|
+
<StrictMode>
|
|
33
|
+
<App />
|
|
34
|
+
</StrictMode>
|
|
35
|
+
)
|
|
36
|
+
```
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
The runtime is automatically disabled in production (`NODE_ENV=production` or Vite's `MODE=production`), so this import is safe to commit.
|
|
39
|
+
|
|
40
|
+
### Step 2 — Run the CLI
|
|
22
41
|
|
|
23
42
|
```bash
|
|
24
|
-
|
|
43
|
+
npx react-state-flow ./src
|
|
25
44
|
```
|
|
26
45
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
46
|
+
The browser opens automatically at `http://localhost:7272` with your component graph. Start your app and the graph updates live as components render.
|
|
47
|
+
|
|
48
|
+
## CLI
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
react-state-flow [directory]
|
|
30
52
|
```
|
|
31
53
|
|
|
32
|
-
|
|
54
|
+
| Argument | Default | Description |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `directory` | `.` | Path to your React source directory |
|
|
57
|
+
|
|
58
|
+
The CLI runs on port `7272`. Your app's Vite dev server can run on any other port.
|
|
59
|
+
|
|
60
|
+
## What the graph shows
|
|
61
|
+
|
|
62
|
+
- **Component nodes** — each React function component, with its `useState`/`useReducer` state slots listed
|
|
63
|
+
- **Context nodes** — each `createContext` call
|
|
64
|
+
- **Parent-child edges** — JSX render relationships between components
|
|
65
|
+
- **Context provision edges** — which component renders a `Context.Provider`
|
|
66
|
+
- **Context subscription edges** — which components call `useContext`
|
|
67
|
+
- **Render counts** — live badge on each node showing how many times it has rendered
|
|
68
|
+
- **Render flash** — green highlight for 800ms after a component re-renders
|
|
69
|
+
|
|
70
|
+
The graph updates automatically when you save source files (no restart needed).
|
|
33
71
|
|
|
34
72
|
## Requirements
|
|
35
73
|
|
|
36
|
-
- Node 18+
|
|
37
|
-
- React
|
|
74
|
+
- Node.js 18+
|
|
75
|
+
- React 16.8+ (hooks required for DevTools hook support)
|
|
38
76
|
|
|
39
|
-
##
|
|
77
|
+
## License
|
|
40
78
|
|
|
41
|
-
|
|
79
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|