react-performance-advisor 1.0.7 → 1.0.9

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/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # ⚡ React Performance Advisor
2
+
3
+ > An enterprise-grade React performance monitoring tool powered by AI.
4
+
5
+ **React Performance Advisor** acts as an "X-ray machine" for your React applications. It hooks directly into React's native rendering engine to catch unnecessary re-renders, prop instability, and main-thread blocking — then uses AI to instantly write the code to fix them.
6
+
7
+ ---
8
+
9
+ ## ✨ Features
10
+
11
+ - 🧠 **AI-Powered Diagnosis** — Automatically streams context (render counts, lag time, changed props) to AI to generate exact `useMemo`, `useCallback`, or `React.memo` code fixes.
12
+ - ⏱️ **Millisecond Lag Tracking** — Utilizes React's native `<Profiler>` to catch components taking >16ms to render, identifying main-thread blocking.
13
+ - 🔍 **Deep Prop Tracking** — Performs strict equality checks to catch "Object/Function Reference Traps" causing silent cascading re-renders.
14
+ - 📦 **Smart Aggregation** — Groups identical bugs across massive lists/grids into a single, clean UI warning to prevent log spam.
15
+ - 🔒 **Secure & Local** — Your API key is stored securely in your browser's Local Storage. It never touches your source code.
16
+
17
+ ---
18
+
19
+ ## 📦 Installation
20
+
21
+ ```bash
22
+ npm install react-performance-advisor
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 🚀 Quick Start
28
+
29
+ ### 1. Wrap your suspect components
30
+
31
+ Import `PerformanceAdvisor` and wrap it around any component you want to monitor. Give it a unique `id`.
32
+
33
+ ```tsx
34
+ import { PerformanceAdvisor } from 'react-performance-advisor';
35
+ import { MyHeavyComponent } from './MyHeavyComponent';
36
+
37
+ function App() {
38
+ return (
39
+ <div>
40
+ <h1>My Dashboard</h1>
41
+
42
+ {/* Wrap the component you want to monitor */}
43
+ <PerformanceAdvisor id="HeavyDashboard">
44
+ <MyHeavyComponent data={someData} />
45
+ </PerformanceAdvisor>
46
+ </div>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### 2. Add the AI Panel
52
+
53
+ Drop the `PerformanceAdvisorPanel` anywhere in your top-level `App.tsx` file.
54
+
55
+ ```tsx
56
+ import { PerformanceAdvisorPanel } from 'react-performance-advisor';
57
+
58
+ function App() {
59
+ return (
60
+ <div>
61
+ {/* ... your app code ... */}
62
+
63
+ {/* Drop the panel at the bottom of your app */}
64
+ <PerformanceAdvisorPanel />
65
+ </div>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### 3. Diagnose!
71
+
72
+ 1. Run your app in **development mode**.
73
+ 2. Interact with your app — if a monitored component re-renders unnecessarily or lags, a warning will appear in the floating panel.
74
+ 3. Click **"✨ Ask AI How to Fix This"**.
75
+ 4. Enter your API key when prompted (it will be saved locally).
76
+ 5. Copy and paste the AI's optimized code directly into your editor!
77
+
78
+ ---
79
+
80
+ ## ⚠️ Note on React Strict Mode
81
+
82
+ If you are running React 18+ in Development Mode with `<React.StrictMode>`, React intentionally double-renders components to catch side effects. This tool will accurately report both renders.
83
+
84
+ To see true single-render metrics, temporarily disable Strict Mode in your `main.tsx` or `index.tsx`:
85
+
86
+ ```tsx
87
+ // Before
88
+ root.render(
89
+ <React.StrictMode>
90
+ <App />
91
+ </React.StrictMode>
92
+ );
93
+
94
+ // After (for profiling)
95
+ root.render(<App />);
96
+ ```
97
+
98
+ ---
99
+
100
+ ## 🛠️ How It Works
101
+
102
+ | Step | What Happens |
103
+ |------|-------------|
104
+ | **Wrap** | `<PerformanceAdvisor>` attaches React's native `<Profiler>` API to your component |
105
+ | **Detect** | On every re-render, it checks render duration and performs deep prop diffing |
106
+ | **Report** | Issues are aggregated and surfaced in the floating `<PerformanceAdvisorPanel>` |
107
+ | **Fix** | One click sends the context to AI, which streams back ready-to-paste code |
108
+
109
+ ---
110
+
111
+ ## 📄 License
112
+
113
+ MIT © React Performance Advisor Contributors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-performance-advisor",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/publish.yml ADDED
@@ -0,0 +1,36 @@
1
+ name: Publish to npm
2
+
3
+ # This tells GitHub to run this script whenever you publish a new Release on GitHub
4
+ on:
5
+ release:
6
+ types: [published]
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ # These permissions are REQUIRED for npm's Trusted Publishers (OIDC) to work securely
13
+ permissions:
14
+ contents: read
15
+ id-token: write
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Setup Node.js
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: '20.x'
25
+ registry-url: 'https://registry.npmjs.org'
26
+
27
+ - name: Install dependencies
28
+ run: npm ci
29
+
30
+ - name: Build the package
31
+ run: npm run build
32
+
33
+ - name: Publish to npm
34
+ run: npm publish --provenance --access public
35
+ env:
36
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/readme.md DELETED
Binary file