@perfonext/render-mcp 0.1.0 → 0.3.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.
Files changed (49) hide show
  1. package/README.md +77 -22
  2. package/dist/index.js +11 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/ingest/server.d.ts +53 -0
  5. package/dist/ingest/server.d.ts.map +1 -0
  6. package/dist/ingest/server.js +211 -0
  7. package/dist/ingest/server.js.map +1 -0
  8. package/dist/parser/analysis.d.ts +7 -2
  9. package/dist/parser/analysis.d.ts.map +1 -1
  10. package/dist/parser/analysis.js +359 -3
  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 +48 -2
  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 +114 -0
  18. package/dist/parser/react-scan-lite.js.map +1 -0
  19. package/dist/parser/types.d.ts +75 -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/compare-renders.d.ts +3 -0
  26. package/dist/tools/compare-renders.d.ts.map +1 -0
  27. package/dist/tools/compare-renders.js +50 -0
  28. package/dist/tools/compare-renders.js.map +1 -0
  29. package/dist/tools/get-captured-renders.d.ts +3 -0
  30. package/dist/tools/get-captured-renders.d.ts.map +1 -0
  31. package/dist/tools/get-captured-renders.js +77 -0
  32. package/dist/tools/get-captured-renders.js.map +1 -0
  33. package/dist/tools/get-hot-commits.d.ts.map +1 -1
  34. package/dist/tools/get-hot-commits.js +3 -2
  35. package/dist/tools/get-hot-commits.js.map +1 -1
  36. package/dist/tools/get-render-summary.js +1 -1
  37. package/dist/tools/get-render-summary.js.map +1 -1
  38. package/dist/tools/load-render-profile.d.ts.map +1 -1
  39. package/dist/tools/load-render-profile.js +3 -1
  40. package/dist/tools/load-render-profile.js.map +1 -1
  41. package/dist/tools/run-render-capture.d.ts +3 -0
  42. package/dist/tools/run-render-capture.d.ts.map +1 -0
  43. package/dist/tools/run-render-capture.js +59 -0
  44. package/dist/tools/run-render-capture.js.map +1 -0
  45. package/dist/tools/stop-render-capture.d.ts +3 -0
  46. package/dist/tools/stop-render-capture.d.ts.map +1 -0
  47. package/dist/tools/stop-render-capture.js +61 -0
  48. package/dist/tools/stop-render-capture.js.map +1 -0
  49. package/package.json +2 -2
package/README.md CHANGED
@@ -2,28 +2,81 @@
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
10
- - summarizes commits and the most expensive components
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
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
25
  - highlights components with repeated rerenders using deterministic heuristics, evidence signals, and confidence levels
14
- - keeps the loaded profiles in memory so an MCP client can iterate without re-reading the file
26
+ - compares two render profiles to surface regressions and improvements
27
+ - keeps profiles in memory so Copilot can iterate without re-loading
15
28
 
16
29
  ## Tools
17
30
 
31
+ ### Entry point
32
+
33
+ | Tool | Description |
34
+ |------|-------------|
35
+ | `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. |
36
+
37
+ ### Live capture
38
+
39
+ | Tool | Description |
40
+ |------|-------------|
41
+ | `run_render_capture` | Called after instrumentation is wired up. Accepts `method: "manual-interaction" \| "test-suite"`. Returns focused instructions for whichever method the user picks. |
42
+ | `stop_render_capture` | Stop the session, finalize buffered events into a profile, and return a `profileId` for analysis |
43
+ | `get_captured_renders` | Optional diagnostic: peek at session progress without stopping (commit count, unknown events). Only call if something seems wrong. |
44
+
45
+ ### Analysis
46
+
18
47
  | Tool | Description |
19
48
  |------|-------------|
20
- | `load_render_profile` | Parse and load an exported React Profiler JSON file from disk |
21
- | `get_render_summary` | Summarize a loaded profile, including top components by render cost and the hottest commits |
49
+ | `load_render_profile` | Parse and load an exported React DevTools Profiler JSON file from disk (manual path entry point) |
50
+ | `get_render_summary` | Summarize a loaded profile: top components by render cost, hottest commits, and detected render issues |
22
51
  | `get_hot_commits` | Rank the most expensive commits and show the top components inside each spike |
23
52
  | `get_slow_components` | Rank the slowest components by total actual render time |
24
- | `get_rerender_causes` | Explain likely rerender causes using profile-derived heuristics, evidence, confidence, and a documented score |
53
+ | `get_rerender_causes` | Explain rerender causes with evidence, confidence, and a risk score |
54
+ | `compare_renders` | Diff two loaded render profiles and rank regressions, improvements, additions, and removals |
55
+
56
+ ## Quickstart
57
+
58
+ Ask Copilot: *"Run a render analysis on my app."*
59
+
60
+ Copilot calls `begin_render_analysis` and asks you to choose:
61
+
62
+ **Option A — Live capture (recommended)**
63
+
64
+ Copilot will:
65
+ 1. Start a capture session (ingest server on `127.0.0.1:7721`)
66
+ 2. Install `react-scan` as a devDependency if not present
67
+ 3. Write `instrumentation-client.js` at your project root with the session snippet
68
+ 4. Import it from your app's client-side entry point
69
+ 5. Ask whether you want to interact manually or run a test suite (`run_render_capture`)
70
+ 6. Stop the session and run analysis
25
71
 
26
- `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.
72
+ 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.
73
+
74
+ **Option B — Manual DevTools export**
75
+
76
+ 1. Open React DevTools in the browser → Profiler tab → Record
77
+ 2. Interact with the app
78
+ 3. Export the JSON and share the file path
79
+ 4. Copilot calls `load_render_profile({ filePath: "..." })`
27
80
 
28
81
  ## Rerender Score Contract
29
82
 
@@ -40,17 +93,19 @@
40
93
  - `high`: three or more independent signals
41
94
  - `evidence[]`: machine-readable signals such as repeated updates, nested-update propagation, wide commit spread, or high actual-vs-self duration ratio
42
95
 
43
- Current score inputs are:
96
+ The score ranks investigation order, not exact root cause.
44
97
 
45
- - repeated update-phase renders
46
- - nested update propagation
47
- - appearance across many commits
48
- - high actual-vs-self duration ratio
98
+ ## Example Copilot Prompts
49
99
 
50
- 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.
100
+ - "Run a render analysis on my app."
101
+ - "Stop the capture and show me the slowest components."
102
+ - "Which components are re-rendering the most and why?"
103
+ - "Compare this run to the profile I captured before the refactor."
104
+ - "I already have a React DevTools export — load it and tell me what's slow."
51
105
 
52
106
  ## Install
53
107
 
108
+
54
109
  Run directly with `npx`:
55
110
 
56
111
  ```bash
@@ -67,7 +122,7 @@ The executable command remains `perfonext-render-mcp` after installation.
67
122
 
68
123
  ## MCP Configuration
69
124
 
70
- Add this server to VS Code settings:
125
+ Add to your VS Code `settings.json`:
71
126
 
72
127
  ```json
73
128
  {
@@ -82,14 +137,14 @@ Add this server to VS Code settings:
82
137
  }
83
138
  ```
84
139
 
85
- Local workspace MCP config is also included in `.vscode/mcp.json` for development.
86
-
87
140
  ## Example Copilot Prompts
88
141
 
89
- - "Load the React Profiler export at `./profile.json` and summarize the hottest components."
90
- - "Show me the hottest commits in `./profile.json` and which components dominated each spike."
91
- - "Which components are consuming the most render time in this Next.js profile?"
92
- - "Show me the likely rerender causes for the slowest components, including evidence and confidence."
142
+ - "Run a render analysis on my app."
143
+ - "Stop the capture and show me the slowest components."
144
+ - "Which components are re-rendering the most and why?"
145
+ - "Compare this run to the profile I captured before the refactor."
146
+ - "I already have a React DevTools export — load it and tell me what's slow."
147
+ - "Show me the hottest commits and which components dominated each spike."
93
148
 
94
149
  ## Development
95
150
 
@@ -99,7 +154,7 @@ npm run build
99
154
  npm test
100
155
  ```
101
156
 
102
- Sample fixtures for local validation live under `tests/fixtures/`.
157
+ Sample fixtures live under `tests/fixtures/`.
103
158
 
104
159
  ## License
105
160
 
package/dist/index.js CHANGED
@@ -2,19 +2,29 @@
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { registerLoadRenderProfile } from './tools/load-render-profile.js';
5
+ import { registerCompareRenders } from './tools/compare-renders.js';
5
6
  import { registerGetRenderSummary } from './tools/get-render-summary.js';
6
7
  import { registerGetHotCommits } from './tools/get-hot-commits.js';
7
8
  import { registerGetSlowComponents } from './tools/get-slow-components.js';
8
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';
9
14
  const server = new McpServer({
10
15
  name: 'perfonext-render-mcp',
11
- version: '0.1.0',
16
+ version: '0.3.0',
12
17
  });
13
18
  registerLoadRenderProfile(server);
19
+ registerCompareRenders(server);
14
20
  registerGetRenderSummary(server);
15
21
  registerGetHotCommits(server);
16
22
  registerGetSlowComponents(server);
17
23
  registerGetRerenderCauses(server);
24
+ registerBeginRenderAnalysis(server);
25
+ registerRunRenderCapture(server);
26
+ registerStopRenderCapture(server);
27
+ registerGetCapturedRenders(server);
18
28
  const transport = new StdioServerTransport();
19
29
  await server.connect(transport);
20
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,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,wBAAwB,CAAC,MAAM,CAAC,CAAC;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AC;AAClC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAClC,2BAA2B,CAAC,MAAM,CAAC,CAAC;AACpC,wBAAwB,CAAC,MAAM,CAAC,CAAC;AACjC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAClC,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAEnC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -0,0 +1,53 @@
1
+ export interface ReactScanChangeDescription {
2
+ props?: string[] | null;
3
+ state?: string[] | null;
4
+ context?: string[] | null;
5
+ hooks?: string[] | null;
6
+ isFirstMount?: boolean;
7
+ }
8
+ export interface ReactScanSource {
9
+ fileName: string;
10
+ lineNumber: number;
11
+ columnNumber: number;
12
+ }
13
+ export interface ReactScanFiberEvent {
14
+ fiberId: number;
15
+ name: string;
16
+ depth: number;
17
+ actualDuration: number;
18
+ selfDuration?: number;
19
+ changeDescription?: ReactScanChangeDescription | null;
20
+ source?: ReactScanSource | null;
21
+ parentId?: number | null;
22
+ }
23
+ export interface ReactScanCommitEvent {
24
+ type: 'commit';
25
+ sessionId: string;
26
+ commitIndex: number;
27
+ rootId: number;
28
+ duration: number;
29
+ timestamp: number;
30
+ priorityName?: string;
31
+ laneLabels?: string[];
32
+ updaterNames?: string[];
33
+ fibers: ReactScanFiberEvent[];
34
+ }
35
+ export interface CaptureSession {
36
+ sessionId: string;
37
+ endpoint: string;
38
+ status: 'active' | 'stopped';
39
+ commits: ReactScanCommitEvent[];
40
+ profilingAvailable: boolean | null;
41
+ startTime: number;
42
+ /** Count of POST bodies that had no recognizable react-scan/lite `message` field.
43
+ * A non-zero value with zero commits usually means the instrumentation snippet
44
+ * is not wired correctly (e.g. the import path is wrong or the file runs server-side). */
45
+ unknownEvents: number;
46
+ }
47
+ export declare function createCaptureSession(): Promise<CaptureSession>;
48
+ export declare function getCaptureSession(sessionId: string): CaptureSession | undefined;
49
+ export declare function stopCaptureSession(sessionId: string): CaptureSession | undefined;
50
+ /** Remove a session from memory once its profile has been stored. */
51
+ export declare function deleteCaptureSession(sessionId: string): void;
52
+ export declare function getServerPort(): number | null;
53
+ //# 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,EAAE,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACtD,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B;AAoGD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC7B,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,kBAAkB,EAAE,OAAO,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,211 @@
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
+ } : null,
18
+ source: (raw.source && typeof raw.source === 'object') ? raw.source : null,
19
+ parentId: null,
20
+ };
21
+ }
22
+ function parseOneEvent(raw, commitIndex, urlSessionId) {
23
+ if (!raw || typeof raw !== 'object')
24
+ return null;
25
+ const r = raw;
26
+ // ── Native react-scan/lite endpoint format ────────────────────────────────
27
+ // Body: { message: LiteEventKind, data: {...}, sessionId, timestamp }
28
+ if (typeof r.message === 'string') {
29
+ const data = (r.data && typeof r.data === 'object') ? r.data : {};
30
+ const ts = typeof r.timestamp === 'number' ? r.timestamp : Date.now();
31
+ if (r.message === 'commit') {
32
+ const tree = Array.isArray(data.tree) ? data.tree : [];
33
+ const fibers = tree.map(normalizeFiber);
34
+ // Use root-depth fiber's actualDuration as commit duration; fall back to sum.
35
+ const rootFiber = fibers.find(f => f.depth === 0);
36
+ const duration = rootFiber?.actualDuration ?? fibers.reduce((s, f) => s + f.actualDuration, 0);
37
+ return {
38
+ kind: 'commit',
39
+ event: {
40
+ type: 'commit',
41
+ sessionId: urlSessionId, // always use URL sessionId — never trust the body
42
+ commitIndex,
43
+ rootId: typeof data.rendererId === 'number' ? data.rendererId : 1,
44
+ duration,
45
+ timestamp: ts,
46
+ priorityName: typeof data.priorityName === 'string' ? data.priorityName : undefined,
47
+ laneLabels: Array.isArray(data.laneLabels) ? data.laneLabels : undefined,
48
+ updaterNames: [],
49
+ fibers,
50
+ },
51
+ };
52
+ }
53
+ if (r.message === 'profiling-hooks-status') {
54
+ return { kind: 'status', available: data.available === true };
55
+ }
56
+ return null; // other event kinds (render-start, post-commit, fiber-unmount, etc.) — expected noise
57
+ }
58
+ return null; // no `message` field — not a react-scan/lite payload
59
+ }
60
+ // ---------------------------------------------------------------------------
61
+ // Singleton HTTP server state
62
+ // ---------------------------------------------------------------------------
63
+ const sessions = new Map();
64
+ let httpServer = null;
65
+ let serverPort = null;
66
+ // ---------------------------------------------------------------------------
67
+ // Internal helpers
68
+ // ---------------------------------------------------------------------------
69
+ function readBody(req) {
70
+ return new Promise((resolve, reject) => {
71
+ const chunks = [];
72
+ req.on('data', (chunk) => chunks.push(chunk));
73
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf-8')));
74
+ req.on('error', reject);
75
+ });
76
+ }
77
+ function handleRequest(req, res) {
78
+ res.setHeader('Access-Control-Allow-Origin', '*');
79
+ res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
80
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
81
+ if (req.method === 'OPTIONS') {
82
+ res.writeHead(204);
83
+ res.end();
84
+ return;
85
+ }
86
+ const url = req.url ?? '';
87
+ const match = url.match(/^\/ingest\/([^/]+)$/);
88
+ if (!match || req.method !== 'POST') {
89
+ res.writeHead(404);
90
+ res.end(JSON.stringify({ error: 'not found' }));
91
+ return;
92
+ }
93
+ const sessionId = decodeURIComponent(match[1]);
94
+ const session = sessions.get(sessionId);
95
+ if (!session) {
96
+ res.writeHead(404);
97
+ res.end(JSON.stringify({ error: 'session not found' }));
98
+ return;
99
+ }
100
+ if (session.status !== 'active') {
101
+ res.writeHead(410);
102
+ res.end(JSON.stringify({ error: 'session already stopped' }));
103
+ return;
104
+ }
105
+ readBody(req)
106
+ .then(body => {
107
+ let rawEvents;
108
+ try {
109
+ const parsed = JSON.parse(body);
110
+ rawEvents = Array.isArray(parsed) ? parsed : [parsed];
111
+ }
112
+ catch {
113
+ res.writeHead(400);
114
+ res.end(JSON.stringify({ error: 'invalid JSON' }));
115
+ return;
116
+ }
117
+ let received = 0;
118
+ for (const raw of rawEvents) {
119
+ const normalized = parseOneEvent(raw, session.commits.length, sessionId);
120
+ if (!normalized) {
121
+ if (raw && typeof raw === 'object' && !('message' in raw)) {
122
+ session.unknownEvents++;
123
+ }
124
+ continue;
125
+ }
126
+ received++;
127
+ if (normalized.kind === 'commit') {
128
+ session.commits.push(normalized.event);
129
+ }
130
+ else if (normalized.kind === 'status') {
131
+ session.profilingAvailable = normalized.available;
132
+ }
133
+ }
134
+ res.writeHead(200);
135
+ res.end(JSON.stringify({ ok: true, received }));
136
+ })
137
+ .catch(() => {
138
+ res.writeHead(500);
139
+ res.end(JSON.stringify({ error: 'internal error' }));
140
+ });
141
+ }
142
+ // Default port 7721; override with PERFONEXT_INGEST_PORT.
143
+ const _rawPort = parseInt(process.env.PERFONEXT_INGEST_PORT ?? '7721', 10);
144
+ if (!Number.isFinite(_rawPort) || _rawPort < 1 || _rawPort > 65535) {
145
+ throw new Error(`PERFONEXT_INGEST_PORT must be a number between 1 and 65535 (got: "${process.env.PERFONEXT_INGEST_PORT}")`);
146
+ }
147
+ const INGEST_PORT = _rawPort;
148
+ function startHttpServer() {
149
+ return new Promise((resolve, reject) => {
150
+ const server = createServer(handleRequest);
151
+ // Bind to loopback only — no external exposure.
152
+ server.listen(INGEST_PORT, '127.0.0.1', () => {
153
+ const addr = server.address();
154
+ if (!addr || typeof addr === 'string') {
155
+ reject(new Error('Unexpected server address'));
156
+ return;
157
+ }
158
+ httpServer = server;
159
+ serverPort = addr.port;
160
+ resolve(addr.port);
161
+ });
162
+ server.on('error', (err) => {
163
+ if (err.code === 'EADDRINUSE') {
164
+ reject(new Error(`Ingest server port ${INGEST_PORT} is already in use. ` +
165
+ 'Free the port or set PERFONEXT_INGEST_PORT to a different value.'));
166
+ }
167
+ else {
168
+ reject(err);
169
+ }
170
+ });
171
+ });
172
+ }
173
+ // ---------------------------------------------------------------------------
174
+ // Public API
175
+ // ---------------------------------------------------------------------------
176
+ export async function createCaptureSession() {
177
+ if (!httpServer) {
178
+ await startHttpServer();
179
+ }
180
+ const sessionId = randomUUID();
181
+ const endpoint = `http://127.0.0.1:${serverPort}/ingest/${sessionId}`;
182
+ const session = {
183
+ sessionId,
184
+ endpoint,
185
+ status: 'active',
186
+ commits: [],
187
+ profilingAvailable: null,
188
+ startTime: Date.now(),
189
+ unknownEvents: 0,
190
+ };
191
+ sessions.set(sessionId, session);
192
+ return session;
193
+ }
194
+ export function getCaptureSession(sessionId) {
195
+ return sessions.get(sessionId);
196
+ }
197
+ export function stopCaptureSession(sessionId) {
198
+ const session = sessions.get(sessionId);
199
+ if (!session)
200
+ return undefined;
201
+ session.status = 'stopped';
202
+ return session;
203
+ }
204
+ /** Remove a session from memory once its profile has been stored. */
205
+ export function deleteCaptureSession(sessionId) {
206
+ sessions.delete(sessionId);
207
+ }
208
+ export function getServerPort() {
209
+ return serverPort;
210
+ }
211
+ //# 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;AAsEzC,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,Q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B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { HotCommitSummary, ParsedRenderProfile, RenderSummaryEntry, RerenderCause } from './types.js';
2
- export declare function getHotCommits(profile: ParsedRenderProfile, limit?: number, componentLimit?: number): HotCommitSummary[];
1
+ import type { CommitBreakdown, HotCommitSummary, ParsedRenderProfile, RenderComparison, RenderIssue, RenderPropagationPath, RenderSummaryEntry, RerenderCause } from './types.js';
2
+ export declare function getHotCommits(profile: ParsedRenderProfile, limit?: number, componentLimit?: number, priorityLevel?: string): HotCommitSummary[];
3
3
  export declare function getRenderSummary(profile: ParsedRenderProfile, limit?: number): {
4
4
  profileId: string;
5
5
  filename: string;
@@ -11,7 +11,12 @@ export declare function getRenderSummary(profile: ParsedRenderProfile, limit?: n
11
11
  totalRenderDuration: number;
12
12
  topComponents: RenderSummaryEntry[];
13
13
  hotCommits: HotCommitSummary[];
14
+ issues: RenderIssue[];
14
15
  };
15
16
  export declare function getSlowComponents(profile: ParsedRenderProfile, limit?: number, sortBy?: 'total' | 'average' | 'max', minDuration?: number): RenderSummaryEntry[];
16
17
  export declare function getRerenderCauses(profile: ParsedRenderProfile, limit?: number, minDuration?: number): RerenderCause[];
18
+ export declare function getCommitBreakdown(profile: ParsedRenderProfile, commitIndex: number, componentLimit?: number): CommitBreakdown | null;
19
+ export declare function traceRenderPropagation(profile: ParsedRenderProfile, commitIndex: number, limit?: number): RenderPropagationPath[];
20
+ export declare function detectRenderIssues(profile: ParsedRenderProfile, limit?: number): RenderIssue[];
21
+ export declare function compareRenders(baseProfile: ParsedRenderProfile, currentProfile: ParsedRenderProfile, limit?: number, minDelta?: number): RenderComparison;
17
22
  //# sourceMappingURL=analysis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/parser/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mBAAmB,EAEnB,kBAAkB,EAClB,aAAa,EAId,MAAM,YAAY,CAAC;AA2DpB,wBAAgB,aAAa,CAC3B,OAAO,EAAE,mBAAmB,EAC5B,KAAK,SAAK,EACV,cAAc,SAAI,GACjB,gBAAgB,EAAE,CAuBpB;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,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,kBAAkB,EAAE,CAAC;IACpC,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAaA;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,mBAAmB,EAC5B,KAAK,SAAK,EACV,MAAM,GAAE,OAAO,GAAG,SAAS,GAAG,KAAe,EAC7C,WAAW,SAAI,GACd,kBAAkB,EAAE,CA0BtB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,SAAK,EAAE,WAAW,SAAI,GAAG,aAAa,EAAE,CA6I5G"}
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,YAA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