@perfonext/render-mcp 0.2.0 → 0.3.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.
Files changed (43) hide show
  1. package/README.md +91 -27
  2. package/dist/index.js +9 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/ingest/server.d.ts +54 -0
  5. package/dist/ingest/server.d.ts.map +1 -0
  6. package/dist/ingest/server.js +212 -0
  7. package/dist/ingest/server.js.map +1 -0
  8. package/dist/parser/analysis.d.ts +4 -0
  9. package/dist/parser/analysis.d.ts.map +1 -1
  10. package/dist/parser/analysis.js +71 -6
  11. package/dist/parser/analysis.js.map +1 -1
  12. package/dist/parser/react-profile.d.ts.map +1 -1
  13. package/dist/parser/react-profile.js +1 -0
  14. package/dist/parser/react-profile.js.map +1 -1
  15. package/dist/parser/react-scan-lite.d.ts +8 -0
  16. package/dist/parser/react-scan-lite.d.ts.map +1 -0
  17. package/dist/parser/react-scan-lite.js +173 -0
  18. package/dist/parser/react-scan-lite.js.map +1 -0
  19. package/dist/parser/types.d.ts +23 -0
  20. package/dist/parser/types.d.ts.map +1 -1
  21. package/dist/tools/begin-render-analysis.d.ts +3 -0
  22. package/dist/tools/begin-render-analysis.d.ts.map +1 -0
  23. package/dist/tools/begin-render-analysis.js +69 -0
  24. package/dist/tools/begin-render-analysis.js.map +1 -0
  25. package/dist/tools/get-captured-renders.d.ts +3 -0
  26. package/dist/tools/get-captured-renders.d.ts.map +1 -0
  27. package/dist/tools/get-captured-renders.js +77 -0
  28. package/dist/tools/get-captured-renders.js.map +1 -0
  29. package/dist/tools/get-rerender-causes.d.ts.map +1 -1
  30. package/dist/tools/get-rerender-causes.js +8 -13
  31. package/dist/tools/get-rerender-causes.js.map +1 -1
  32. package/dist/tools/load-render-profile.d.ts.map +1 -1
  33. package/dist/tools/load-render-profile.js +3 -1
  34. package/dist/tools/load-render-profile.js.map +1 -1
  35. package/dist/tools/run-render-capture.d.ts +3 -0
  36. package/dist/tools/run-render-capture.d.ts.map +1 -0
  37. package/dist/tools/run-render-capture.js +61 -0
  38. package/dist/tools/run-render-capture.js.map +1 -0
  39. package/dist/tools/stop-render-capture.d.ts +3 -0
  40. package/dist/tools/stop-render-capture.d.ts.map +1 -0
  41. package/dist/tools/stop-render-capture.js +63 -0
  42. package/dist/tools/stop-render-capture.js.map +1 -0
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -2,38 +2,100 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@perfonext/render-mcp)](https://www.npmjs.com/package/@perfonext/render-mcp)
4
4
 
5
- `perfonext-render-mcp` is an MCP server for loading and analyzing React DevTools Profiler exports captured from Next.js apps. It gives GitHub Copilot and other MCP clients structured render data they can reason over instead of forcing the model to inspect raw profiler JSON.
5
+ `perfonext-render-mcp` is an MCP server for analyzing React render behavior in Next.js apps and applying fixes
6
+ in the editor. It is the **agent companion** to React DevTools Profiler and `react-scan` — best at
7
+ machine-readable summaries, exact rerender-cause attribution, source-aware follow-up, and diffing.
8
+
9
+ The loop is **collect → analyze → fix**, all locally:
10
+
11
+ - **collect** — choose live capture (react-scan/lite streams events in real time) or manual DevTools export
12
+ - **analyze** — the MCP returns structured, machine-readable evidence: component costs, rerender causes, commit breakdowns, and regressions
13
+ - **fix** — Copilot uses that evidence to propose and apply concrete code changes
14
+
15
+ > **Note:** while a live capture session is active, React DevTools Timeline Profiler will not receive events
16
+ > (react-scan/lite takes over the profiling channel). Calling `stop_render_capture` restores it.
6
17
 
7
18
  ## What It Does
8
19
 
9
- - loads exported React Profiler JSON files from Next.js apps
20
+ - **live capture** streams per-commit fiber events from a running React app directly into the MCP over a local HTTP endpoint; no manual export required
21
+ - **manual export** — loads exported React DevTools Profiler JSON files as an alternative input path
10
22
  - summarizes commits, the most expensive components, and detected render issues in one call
11
23
  - ranks the hottest commits and shows the top components inside each spike
12
24
  - identifies the slowest components by total render cost
13
- - highlights components with repeated rerenders using deterministic heuristics, evidence signals, and confidence levels
25
+ - highlights components with repeated rerenders, reporting the **exact** changed props/state/hooks when live
26
+ capture provides `changeDescription` data, and falling back to deterministic heuristics otherwise
27
+ - annotates ranked components with their source file and line when available
28
+ - filters DOM host elements (`div`, `span`, …) and unnamed components out of ranked output so findings stay actionable
14
29
  - compares two render profiles to surface regressions and improvements
15
- - keeps the loaded profiles in memory so an MCP client can iterate without re-reading the file
30
+ - keeps profiles in memory so Copilot can iterate without re-loading
16
31
 
17
32
  ## Tools
18
33
 
34
+ ### Entry point
35
+
36
+ | Tool | Description |
37
+ |------|-------------|
38
+ | `begin_render_analysis` | Entry point. Accepts `approach: "live" \| "manual"`. For `live`: starts a capture session and returns the instrumentation snippet. For `manual`: returns React DevTools Profiler export steps. |
39
+
40
+ ### Live capture
41
+
42
+ | Tool | Description |
43
+ |------|-------------|
44
+ | `run_render_capture` | Called after instrumentation is wired up. Accepts `method: "manual-interaction" \| "test-suite"`. Returns focused instructions for whichever method the user picks. Test suites must run **headed** (e.g. `playwright test --headed`) so React profiling hooks activate. |
45
+ | `stop_render_capture` | Stop the session, finalize buffered events into a profile, and return a `profileId` plus `dataQuality` (`exact` \| `heuristic`) for analysis |
46
+ | `get_captured_renders` | Optional diagnostic: peek at session progress without stopping (commit count, unknown events). Only call if something seems wrong. |
47
+
48
+ ### Analysis
49
+
19
50
  | Tool | Description |
20
51
  |------|-------------|
21
- | `load_render_profile` | Parse and load an exported React Profiler JSON file from disk |
22
- | `get_render_summary` | Summarize a loaded profile: top components by render cost, hottest commits, and detected render issues (rerender storms, commit spikes) |
52
+ | `load_render_profile` | Parse and load an exported React DevTools Profiler JSON file from disk (manual path entry point) |
53
+ | `get_render_summary` | Summarize a loaded profile: top components by render cost, hottest commits, and detected render issues |
23
54
  | `get_hot_commits` | Rank the most expensive commits and show the top components inside each spike |
24
55
  | `get_slow_components` | Rank the slowest components by total actual render time |
25
- | `get_rerender_causes` | Explain likely rerender causes using profile-derived heuristics, evidence, confidence, and a documented score |
56
+ | `get_rerender_causes` | Explain rerender causes with evidence, confidence, and a risk score. Reports exact changed props/state/hooks when `changeDescription` data is present (`dataQuality: "exact"`), heuristics otherwise |
26
57
  | `compare_renders` | Diff two loaded render profiles and rank regressions, improvements, additions, and removals |
27
58
 
28
- `get_rerender_causes` is heuristic by design. It works from structural signals in the profiler export — update frequency, nested update propagation, commit spread, and self-intensive renders. When you record with **"Record why each component rendered"** enabled in React DevTools Profiler settings, the export includes richer `changeDescriptions` data; future versions of this tool will parse that field to surface exact prop/state/context diffs natively.
59
+ ## Quickstart
60
+
61
+ Ask Copilot: *"Run a render analysis on my app."*
62
+
63
+ Copilot calls `begin_render_analysis` and asks you to choose:
64
+
65
+ **Option A — Live capture (recommended)**
66
+
67
+ Copilot will:
68
+ 1. Start a capture session (ingest server on `127.0.0.1:7721`)
69
+ 2. Install `react-scan` as a devDependency if not present
70
+ 3. Write `instrumentation-client.js` at your project root with the session snippet
71
+ 4. Import it from your app's client-side entry point
72
+ 5. Ask whether you want to interact manually or run a test suite (`run_render_capture`)
73
+ 6. Stop the session and run analysis
74
+
75
+ > Running a test suite? Launch it **headed** (e.g. `playwright test --headed`). A headless browser does not
76
+ > expose the React DevTools profiling channel, so `changeDescription` data is unavailable and causes fall back
77
+ > to heuristics (`dataQuality: "heuristic"`).
29
78
 
30
- `get_render_summary` includes an `issues` field with up to 5 detected render issues (commit spikes and rerender storms) so you get actionable findings in the same call as the summary.
79
+ The ingest server runs on a **fixed port (7721)**. Only the `sessionId` line in `instrumentation-client.js` changes between sessions the file does not need to be re-wired each time.
80
+
81
+ **Option B — Manual DevTools export**
82
+
83
+ 1. Open React DevTools in the browser → Profiler tab → Record
84
+ 2. Interact with the app
85
+ 3. Export the JSON and share the file path
86
+ 4. Copilot calls `load_render_profile({ filePath: "..." })`
31
87
 
32
88
  ## Rerender Score Contract
33
89
 
34
- `get_rerender_causes` returns a `score`, `scoreBand`, `confidence`, and `evidence[]` for each component.
90
+ `get_rerender_causes` returns a `dataQuality`, and per component a `score`, `scoreBand`, `confidence`,
91
+ `evidence[]`, and (when known) a `source` file/line.
35
92
 
36
- - `score`: a `0-10` heuristic rerender-risk score
93
+ - `dataQuality`:
94
+ - `exact`: at least one fiber carried real `changeDescription` data (live capture in a headed browser), so
95
+ causes name the specific props/state/hooks that changed
96
+ - `heuristic`: no diff data available (DevTools JSON export, or a headless run), so causes are inferred from
97
+ render patterns
98
+ - `score`: a `0-10` rerender-risk score
37
99
  - `scoreBand`:
38
100
  - `low`: `0.0-2.9`
39
101
  - `medium`: `3.0-5.9`
@@ -42,19 +104,22 @@
42
104
  - `low`: one weak signal or only fallback export evidence
43
105
  - `medium`: two independent signals
44
106
  - `high`: three or more independent signals
45
- - `evidence[]`: machine-readable signals such as repeated updates, nested-update propagation, wide commit spread, or high actual-vs-self duration ratio
107
+ - `evidence[]`: machine-readable signals such as exact change descriptions, repeated updates, nested-update
108
+ propagation, wide commit spread, or high actual-vs-self duration ratio
46
109
 
47
- Current score inputs are:
110
+ The score ranks investigation order, not exact root cause.
48
111
 
49
- - repeated update-phase renders
50
- - nested update propagation
51
- - appearance across many commits
52
- - high actual-vs-self duration ratio
112
+ ## Example Copilot Prompts
53
113
 
54
- The score is meant to help rank investigation order, not to claim exact root cause. Enable **"Record why each component rendered"** in React DevTools Profiler settings before recording to capture richer change metadata in the export.
114
+ - "Run a render analysis on my app."
115
+ - "Stop the capture and show me the slowest components."
116
+ - "Which components are re-rendering the most and why?"
117
+ - "Compare this run to the profile I captured before the refactor."
118
+ - "I already have a React DevTools export — load it and tell me what's slow."
55
119
 
56
120
  ## Install
57
121
 
122
+
58
123
  Run directly with `npx`:
59
124
 
60
125
  ```bash
@@ -71,7 +136,7 @@ The executable command remains `perfonext-render-mcp` after installation.
71
136
 
72
137
  ## MCP Configuration
73
138
 
74
- Add this server to VS Code settings:
139
+ Add to your VS Code `settings.json`:
75
140
 
76
141
  ```json
77
142
  {
@@ -86,15 +151,14 @@ Add this server to VS Code settings:
86
151
  }
87
152
  ```
88
153
 
89
- Local workspace MCP config is also included in `.vscode/mcp.json` for development.
90
-
91
154
  ## Example Copilot Prompts
92
155
 
93
- - "Load the React Profiler export at `./profile.json` and summarize the hottest components."
94
- - "Show me the hottest commits in `./profile.json` and which components dominated each spike."
95
- - "Compare `before.json` and `after.json` and tell me which components regressed."
96
- - "Which components are consuming the most render time in this Next.js profile?"
97
- - "Show me the likely rerender causes for the slowest components, including evidence and confidence."
156
+ - "Run a render analysis on my app."
157
+ - "Stop the capture and show me the slowest components."
158
+ - "Which components are re-rendering the most and why?"
159
+ - "Compare this run to the profile I captured before the refactor."
160
+ - "I already have a React DevTools export load it and tell me what's slow."
161
+ - "Show me the hottest commits and which components dominated each spike."
98
162
 
99
163
  ## Development
100
164
 
@@ -104,7 +168,7 @@ npm run build
104
168
  npm test
105
169
  ```
106
170
 
107
- Sample fixtures for local validation live under `tests/fixtures/`.
171
+ Sample fixtures live under `tests/fixtures/`.
108
172
 
109
173
  ## License
110
174
 
package/dist/index.js CHANGED
@@ -7,9 +7,13 @@ import { registerGetRenderSummary } from './tools/get-render-summary.js';
7
7
  import { registerGetHotCommits } from './tools/get-hot-commits.js';
8
8
  import { registerGetSlowComponents } from './tools/get-slow-components.js';
9
9
  import { registerGetRerenderCauses } from './tools/get-rerender-causes.js';
10
+ import { registerBeginRenderAnalysis } from './tools/begin-render-analysis.js';
11
+ import { registerRunRenderCapture } from './tools/run-render-capture.js';
12
+ import { registerStopRenderCapture } from './tools/stop-render-capture.js';
13
+ import { registerGetCapturedRenders } from './tools/get-captured-renders.js';
10
14
  const server = new McpServer({
11
15
  name: 'perfonext-render-mcp',
12
- version: '0.2.0',
16
+ version: '0.3.0',
13
17
  });
14
18
  registerLoadRenderProfile(server);
15
19
  registerCompareRenders(server);
@@ -17,6 +21,10 @@ registerGetRenderSummary(server);
17
21
  registerGetHotCommits(server);
18
22
  registerGetSlowComponents(server);
19
23
  registerGetRerenderCauses(server);
24
+ registerBeginRenderAnalysis(server);
25
+ registerRunRenderCapture(server);
26
+ registerStopRenderCapture(server);
27
+ registerGetCapturedRenders(server);
20
28
  const transport = new StdioServerTransport();
21
29
  await server.connect(transport);
22
30
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAClC,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC/B,wBAAwB,CAAC,MAAM,CAAC,CAAC;AACjC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC9B,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAClC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAElC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2C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| null;
4
+ context?: string[] | null;
5
+ hooks?: string[] | null;
6
+ parent?: boolean;
7
+ isFirstMount?: boolean;
8
+ }
9
+ export interface ReactScanSource {
10
+ fileName: string;
11
+ lineNumber: number;
12
+ columnNumber: number;
13
+ }
14
+ export interface ReactScanFiberEvent {
15
+ fiberId: number;
16
+ name: string;
17
+ depth: number;
18
+ actualDuration: number;
19
+ selfDuration?: number;
20
+ changeDescription?: ReactScanChangeDescription | null;
21
+ source?: ReactScanSource | null;
22
+ parentId?: number | null;
23
+ }
24
+ export interface ReactScanCommitEvent {
25
+ type: 'commit';
26
+ sessionId: string;
27
+ commitIndex: number;
28
+ rootId: number;
29
+ duration: number;
30
+ timestamp: number;
31
+ priorityName?: string;
32
+ laneLabels?: string[];
33
+ updaterNames?: string[];
34
+ fibers: ReactScanFiberEvent[];
35
+ }
36
+ export interface CaptureSession {
37
+ sessionId: string;
38
+ endpoint: string;
39
+ status: 'active' | 'stopped';
40
+ commits: ReactScanCommitEvent[];
41
+ profilingAvailable: boolean | null;
42
+ startTime: number;
43
+ /** Count of POST bodies that had no recognizable react-scan/lite `message` field.
44
+ * A non-zero value with zero commits usually means the instrumentation snippet
45
+ * is not wired correctly (e.g. the import path is wrong or the file runs server-side). */
46
+ unknownEvents: number;
47
+ }
48
+ export declare function createCaptureSession(): Promise<CaptureSession>;
49
+ export declare function getCaptureSession(sessionId: string): CaptureSession | undefined;
50
+ export declare function stopCaptureSession(sessionId: string): CaptureSession | undefined;
51
+ /** Remove a session from memory once its profile has been stored. */
52
+ export declare function deleteCaptureSession(sessionId: string): void;
53
+ export declare function getServerPort(): number | null;
54
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/ingest/server.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,EAA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AO,GAAG,IAAI,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB;;+FAE2F;IAC3F,aAAa,EAAE,MAAM,CAAC;CACvB;AAuID,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC,CAoBpE;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE/E;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAKhF;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAE7C"}
@@ -0,0 +1,212 @@
1
+ import { createServer } from 'node:http';
2
+ import { randomUUID } from 'node:crypto';
3
+ function normalizeFiber(raw) {
4
+ const cd = raw.changeDescription ?? null;
5
+ return {
6
+ fiberId: typeof raw.fiberId === 'number' ? raw.fiberId : 0,
7
+ name: (typeof raw.name === 'string' && raw.name.trim()) ? raw.name.trim() : '(anonymous)',
8
+ depth: typeof raw.depth === 'number' ? raw.depth : 0,
9
+ actualDuration: typeof raw.actualDuration === 'number' ? raw.actualDuration : 0,
10
+ selfDuration: typeof raw.selfBaseDuration === 'number' ? raw.selfBaseDuration : 0,
11
+ changeDescription: cd != null ? {
12
+ isFirstMount: cd.isFirstMount ?? false,
13
+ props: cd.props ?? null,
14
+ state: cd.state ? ['state'] : null,
15
+ context: cd.context ? ['context'] : null,
16
+ hooks: cd.hooks?.map((i) => `hook[${i}]`) ?? null,
17
+ parent: cd.parent ?? false,
18
+ } : null,
19
+ source: (raw.source && typeof raw.source === 'object') ? raw.source : null,
20
+ parentId: null,
21
+ };
22
+ }
23
+ function parseOneEvent(raw, commitIndex, urlSessionId) {
24
+ if (!raw || typeof raw !== 'object')
25
+ return null;
26
+ const r = raw;
27
+ // ── Native react-scan/lite endpoint format ────────────────────────────────
28
+ // Body: { message: LiteEventKind, data: {...}, sessionId, timestamp }
29
+ if (typeof r.message === 'string') {
30
+ const data = (r.data && typeof r.data === 'object') ? r.data : {};
31
+ const ts = typeof r.timestamp === 'number' ? r.timestamp : Date.now();
32
+ if (r.message === 'commit') {
33
+ const tree = Array.isArray(data.tree) ? data.tree : [];
34
+ const fibers = tree.map(normalizeFiber);
35
+ // Use root-depth fiber's actualDuration as commit duration; fall back to sum.
36
+ const rootFiber = fibers.find(f => f.depth === 0);
37
+ const duration = rootFiber?.actualDuration ?? fibers.reduce((s, f) => s + f.actualDuration, 0);
38
+ return {
39
+ kind: 'commit',
40
+ event: {
41
+ type: 'commit',
42
+ sessionId: urlSessionId, // always use URL sessionId — never trust the body
43
+ commitIndex,
44
+ rootId: typeof data.rendererId === 'number' ? data.rendererId : 1,
45
+ duration,
46
+ timestamp: ts,
47
+ priorityName: typeof data.priorityName === 'string' ? data.priorityName : undefined,
48
+ laneLabels: Array.isArray(data.laneLabels) ? data.laneLabels : undefined,
49
+ updaterNames: [],
50
+ fibers,
51
+ },
52
+ };
53
+ }
54
+ if (r.message === 'profiling-hooks-status') {
55
+ return { kind: 'status', available: data.available === true };
56
+ }
57
+ return null; // other event kinds (render-start, post-commit, fiber-unmount, etc.) — expected noise
58
+ }
59
+ return null; // no `message` field — not a react-scan/lite payload
60
+ }
61
+ // ---------------------------------------------------------------------------
62
+ // Singleton HTTP server state
63
+ // ---------------------------------------------------------------------------
64
+ const sessions = new Map();
65
+ let httpServer = null;
66
+ let serverPort = null;
67
+ // ---------------------------------------------------------------------------
68
+ // Internal helpers
69
+ // ---------------------------------------------------------------------------
70
+ function readBody(req) {
71
+ return new Promise((resolve, reject) => {
72
+ const chunks = [];
73
+ req.on('data', (chunk) => chunks.push(chunk));
74
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
75
+ req.on('error', reject);
76
+ });
77
+ }
78
+ function handleRequest(req, res) {
79
+ res.setHeader('Access-Control-Allow-Origin', '*');
80
+ res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
81
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
82
+ if (req.method === 'OPTIONS') {
83
+ res.writeHead(204);
84
+ res.end();
85
+ return;
86
+ }
87
+ const url = req.url ?? '';
88
+ const match = url.match(/^\/ingest\/([^/]+)$/);
89
+ if (!match || req.method !== 'POST') {
90
+ res.writeHead(404);
91
+ res.end(JSON.stringify({ error: 'not found' }));
92
+ return;
93
+ }
94
+ const sessionId = decodeURIComponent(match[1]);
95
+ const session = sessions.get(sessionId);
96
+ if (!session) {
97
+ res.writeHead(404);
98
+ res.end(JSON.stringify({ error: 'session not found' }));
99
+ return;
100
+ }
101
+ if (session.status !== 'active') {
102
+ res.writeHead(410);
103
+ res.end(JSON.stringify({ error: 'session already stopped' }));
104
+ return;
105
+ }
106
+ readBody(req)
107
+ .then(body => {
108
+ let rawEvents;
109
+ try {
110
+ const parsed = JSON.parse(body);
111
+ rawEvents = Array.isArray(parsed) ? parsed : [parsed];
112
+ }
113
+ catch {
114
+ res.writeHead(400);
115
+ res.end(JSON.stringify({ error: 'invalid JSON' }));
116
+ return;
117
+ }
118
+ let received = 0;
119
+ for (const raw of rawEvents) {
120
+ const normalized = parseOneEvent(raw, session.commits.length, sessionId);
121
+ if (!normalized) {
122
+ if (raw && typeof raw === 'object' && !('message' in raw)) {
123
+ session.unknownEvents++;
124
+ }
125
+ continue;
126
+ }
127
+ received++;
128
+ if (normalized.kind === 'commit') {
129
+ session.commits.push(normalized.event);
130
+ }
131
+ else if (normalized.kind === 'status') {
132
+ session.profilingAvailable = normalized.available;
133
+ }
134
+ }
135
+ res.writeHead(200);
136
+ res.end(JSON.stringify({ ok: true, received }));
137
+ })
138
+ .catch(() => {
139
+ res.writeHead(500);
140
+ res.end(JSON.stringify({ error: 'internal error' }));
141
+ });
142
+ }
143
+ // Default port 7721; override with PERFONEXT_INGEST_PORT.
144
+ const _rawPort = parseInt(process.env.PERFONEXT_INGEST_PORT ?? '7721', 10);
145
+ if (!Number.isFinite(_rawPort) || _rawPort < 1 || _rawPort > 65535) {
146
+ throw new Error(`PERFONEXT_INGEST_PORT must be a number between 1 and 65535 (got: "${process.env.PERFONEXT_INGEST_PORT}")`);
147
+ }
148
+ const INGEST_PORT = _rawPort;
149
+ function startHttpServer() {
150
+ return new Promise((resolve, reject) => {
151
+ const server = createServer(handleRequest);
152
+ // Bind to loopback only — no external exposure.
153
+ server.listen(INGEST_PORT, '127.0.0.1', () => {
154
+ const addr = server.address();
155
+ if (!addr || typeof addr === 'string') {
156
+ reject(new Error('Unexpected server address'));
157
+ return;
158
+ }
159
+ httpServer = server;
160
+ serverPort = addr.port;
161
+ resolve(addr.port);
162
+ });
163
+ server.on('error', (err) => {
164
+ if (err.code === 'EADDRINUSE') {
165
+ reject(new Error(`Ingest server port ${INGEST_PORT} is already in use. ` +
166
+ 'Free the port or set PERFONEXT_INGEST_PORT to a different value.'));
167
+ }
168
+ else {
169
+ reject(err);
170
+ }
171
+ });
172
+ });
173
+ }
174
+ // ---------------------------------------------------------------------------
175
+ // Public API
176
+ // ---------------------------------------------------------------------------
177
+ export async function createCaptureSession() {
178
+ if (!httpServer) {
179
+ await startHttpServer();
180
+ }
181
+ const sessionId = randomUUID();
182
+ const endpoint = `http://127.0.0.1:${serverPort}/ingest/${sessionId}`;
183
+ const session = {
184
+ sessionId,
185
+ endpoint,
186
+ status: 'active',
187
+ commits: [],
188
+ profilingAvailable: null,
189
+ startTime: Date.now(),
190
+ unknownEvents: 0,
191
+ };
192
+ sessions.set(sessionId, session);
193
+ return session;
194
+ }
195
+ export function getCaptureSession(sessionId) {
196
+ return sessions.get(sessionId);
197
+ }
198
+ export function stopCaptureSession(sessionId) {
199
+ const session = sessions.get(sessionId);
200
+ if (!session)
201
+ return undefined;
202
+ session.status = 'stopped';
203
+ return session;
204
+ }
205
+ /** Remove a session from memory once its profile has been stored. */
206
+ export function deleteCaptureSession(sessionId) {
207
+ sessions.delete(sessionId);
208
+ }
209
+ export function getServerPort() {
210
+ return serverPort;
211
+ }
212
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/ingest/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuEzC,SAAS,cAAc,CAAC,GAAa;IACnC,MAAM,EAAE,GAAG,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC;IACzC,OAAO;QACL,OAAO,EAAE,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1D,IAAI,EAAE,CAAC,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,aAAa;QACzF,KAAK,EAAE,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpD,cAAc,EAAE,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAC/E,YAAY,EAAE,OAAO,GAAG,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACjF,iBAAiB,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;YAC9B,YAAY,EAAE,EAAE,CAAC,YAAY,IAAI,KAAK;YACtC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI;YACvB,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAA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Summary, ParsedRenderProfile, RenderComparison, RenderIssue, RenderPropagationPath, RenderSummaryEntry, RerenderCause } from './types.js';
2
+ /** Returns true for named React components that appear in ranked analysis output. */
3
+ export declare function isAnalyzableComponent(name: string): boolean;
2
4
  export declare function getHotCommits(profile: ParsedRenderProfile, limit?: number, componentLimit?: number, priorityLevel?: string): HotCommitSummary[];
3
5
  export declare function getRenderSummary(profile: ParsedRenderProfile, limit?: number): {
4
6
  profileId: string;
@@ -12,6 +14,8 @@ export declare function getRenderSummary(profile: ParsedRenderProfile, limit?: n
12
14
  topComponents: RenderSummaryEntry[];
13
15
  hotCommits: HotCommitSummary[];
14
16
  issues: RenderIssue[];
17
+ warnings: string[];
18
+ dataQuality: 'heuristic' | 'exact';
15
19
  };
16
20
  export declare function getSlowComponents(profile: ParsedRenderProfile, limit?: number, sortBy?: 'total' | 'average' | 'max', minDuration?: number): RenderSummaryEntry[];
17
21
  export declare function getRerenderCauses(profile: ParsedRenderProfile, limit?: number, minDuration?: number): RerenderCause[];
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/parser/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAIf,gBAAgB,EAChB,mBAAmB,EAEnB,gBAAgB,EAEhB,WAAW,EAGX,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EAId,MAAM,YAAY,CAAC;AAwFpB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,mBAAmB,EAC5B,KAAK,SAAK,EACV,cAAc,SAAI,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,EAAE,CAsBpB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,SAAK,GAAG;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW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