react-dev-profiler 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/README.md +111 -0
- package/dist/index.cjs +628 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +179 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +601 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Frederic Denis (billywild87)
|
|
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
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# react-dev-profiler
|
|
2
|
+
|
|
3
|
+
Real-time React performance monitoring for development. Zero overhead in production.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## What it does
|
|
9
|
+
|
|
10
|
+
Wrap any part of your React app with `<DevProfiler>` and get a floating panel that shows:
|
|
11
|
+
|
|
12
|
+
- **Frame time & FPS** — rolling graph with min/max/P99 stats
|
|
13
|
+
- **Renders per second** — how often React commits
|
|
14
|
+
- **React Profiler** — actual vs. base render duration, memoization gains
|
|
15
|
+
- **DOM** — node count, mutation count, element dimensions
|
|
16
|
+
- **Memory** — JS heap usage (Chrome only)
|
|
17
|
+
- **Long tasks** — browser tasks exceeding 50 ms
|
|
18
|
+
- **Visual flash** — brief outline pulse on DOM mutations
|
|
19
|
+
- **Data export** — copy all stats as JSON to your clipboard
|
|
20
|
+
- **Draggable panel** — grab the header and move it anywhere
|
|
21
|
+
|
|
22
|
+
Toggle it with **Ctrl+I** (or **Cmd+I** on Mac). In production, the component renders nothing — zero runtime cost.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install react-dev-profiler
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { DevProfiler } from 'react-dev-profiler'
|
|
34
|
+
|
|
35
|
+
function App() {
|
|
36
|
+
return (
|
|
37
|
+
<DevProfiler>
|
|
38
|
+
<YourApp />
|
|
39
|
+
</DevProfiler>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That's it. Open your app in dev mode and press **Ctrl+I**.
|
|
45
|
+
|
|
46
|
+
### Position the panel
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<DevProfiler position="top-right">
|
|
50
|
+
<YourApp />
|
|
51
|
+
</DevProfiler>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Multiple instances
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<DevProfiler id="sidebar" position="top-left">
|
|
58
|
+
<Sidebar />
|
|
59
|
+
</DevProfiler>
|
|
60
|
+
|
|
61
|
+
<DevProfiler id="main" position="bottom-right">
|
|
62
|
+
<MainContent />
|
|
63
|
+
</DevProfiler>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
When more than one instance is active, each panel shows its ID as a badge.
|
|
67
|
+
|
|
68
|
+
## Requirements
|
|
69
|
+
|
|
70
|
+
- React 18+
|
|
71
|
+
- Any bundler (Vite, webpack, Next.js, Astro, etc.)
|
|
72
|
+
|
|
73
|
+
## How it works
|
|
74
|
+
|
|
75
|
+
`<DevProfiler>` wraps your children with React's built-in `<Profiler>` component and layers on a few browser APIs:
|
|
76
|
+
|
|
77
|
+
| API | What it measures |
|
|
78
|
+
| ----------------------- | ----------------------------- |
|
|
79
|
+
| `requestAnimationFrame` | Frame timing & FPS |
|
|
80
|
+
| `MutationObserver` | DOM mutations & node count |
|
|
81
|
+
| `PerformanceObserver` | Long tasks (>50 ms) |
|
|
82
|
+
| `performance.memory` | JS heap size (Chrome only) |
|
|
83
|
+
| `ResizeObserver` | Element dimensions & position |
|
|
84
|
+
|
|
85
|
+
All observers are created lazily (only when the panel is open) and cleaned up on close.
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### `<DevProfiler>`
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Default | Description |
|
|
92
|
+
| ---------- | --------------- | --------------- | ---------------------------------------- |
|
|
93
|
+
| `children` | `ReactNode` | — | The subtree to profile |
|
|
94
|
+
| `position` | `PanelPosition` | `'bottom-left'` | Where to anchor the panel |
|
|
95
|
+
| `id` | `string` | auto-generated | Instance label (shown with multi-panels) |
|
|
96
|
+
|
|
97
|
+
### `PanelPosition`
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
type PanelPosition = 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Exported types
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import type { DevStats, ReactProfilerData, PanelPosition } from 'react-dev-profiler'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT — Frederic Denis ([billywild87](https://github.com/billywild87))
|