agent-react-devtools 0.0.0 → 0.1.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/CHANGELOG.md +34 -0
- package/dist/cli.js +584 -0
- package/dist/cli.js.map +1 -0
- package/dist/daemon.js +1091 -0
- package/dist/daemon.js.map +1 -0
- package/package.json +35 -1
- package/src/__tests__/cli-parser.test.ts +76 -0
- package/src/__tests__/component-tree.test.ts +229 -0
- package/src/__tests__/formatters.test.ts +189 -0
- package/src/__tests__/profiler.test.ts +264 -0
- package/src/cli.ts +315 -0
- package/src/component-tree.ts +495 -0
- package/src/daemon-client.ts +144 -0
- package/src/daemon.ts +275 -0
- package/src/devtools-bridge.ts +391 -0
- package/src/formatters.ts +270 -0
- package/src/profiler.ts +356 -0
- package/src/types.ts +126 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +17 -0
- package/vitest.config.ts +7 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// ── Component Tree ──
|
|
2
|
+
|
|
3
|
+
export type ComponentType =
|
|
4
|
+
| 'function'
|
|
5
|
+
| 'class'
|
|
6
|
+
| 'host'
|
|
7
|
+
| 'memo'
|
|
8
|
+
| 'forwardRef'
|
|
9
|
+
| 'profiler'
|
|
10
|
+
| 'suspense'
|
|
11
|
+
| 'context'
|
|
12
|
+
| 'other';
|
|
13
|
+
|
|
14
|
+
export interface ComponentNode {
|
|
15
|
+
id: number;
|
|
16
|
+
displayName: string;
|
|
17
|
+
type: ComponentType;
|
|
18
|
+
key: string | null;
|
|
19
|
+
parentId: number | null;
|
|
20
|
+
children: number[];
|
|
21
|
+
/** Renderer that owns this node */
|
|
22
|
+
rendererId: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface InspectedElement {
|
|
26
|
+
id: number;
|
|
27
|
+
displayName: string;
|
|
28
|
+
type: ComponentType;
|
|
29
|
+
key: string | null;
|
|
30
|
+
props: Record<string, unknown>;
|
|
31
|
+
state: Record<string, unknown> | null;
|
|
32
|
+
hooks: HookInfo[] | null;
|
|
33
|
+
renderedAt: number | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface HookInfo {
|
|
37
|
+
name: string;
|
|
38
|
+
value: unknown;
|
|
39
|
+
subHooks?: HookInfo[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ── Profiling ──
|
|
43
|
+
|
|
44
|
+
export interface ProfilingSession {
|
|
45
|
+
name: string;
|
|
46
|
+
startedAt: number;
|
|
47
|
+
stoppedAt: number | null;
|
|
48
|
+
commits: ProfilingCommit[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ProfilingCommit {
|
|
52
|
+
timestamp: number;
|
|
53
|
+
duration: number;
|
|
54
|
+
fiberActualDurations: Map<number, number>;
|
|
55
|
+
fiberSelfDurations: Map<number, number>;
|
|
56
|
+
changeDescriptions: Map<number, ChangeDescription>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ChangeDescription {
|
|
60
|
+
didHooksChange: boolean;
|
|
61
|
+
isFirstMount: boolean;
|
|
62
|
+
props: string[] | null;
|
|
63
|
+
state: string[] | null;
|
|
64
|
+
hooks: number[] | null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ComponentRenderReport {
|
|
68
|
+
id: number;
|
|
69
|
+
displayName: string;
|
|
70
|
+
renderCount: number;
|
|
71
|
+
totalDuration: number;
|
|
72
|
+
avgDuration: number;
|
|
73
|
+
maxDuration: number;
|
|
74
|
+
causes: RenderCause[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type RenderCause =
|
|
78
|
+
| 'props-changed'
|
|
79
|
+
| 'state-changed'
|
|
80
|
+
| 'hooks-changed'
|
|
81
|
+
| 'parent-rendered'
|
|
82
|
+
| 'force-update'
|
|
83
|
+
| 'first-mount';
|
|
84
|
+
|
|
85
|
+
// ── IPC Commands ──
|
|
86
|
+
|
|
87
|
+
export type IpcCommand =
|
|
88
|
+
| { type: 'ping' }
|
|
89
|
+
| { type: 'status' }
|
|
90
|
+
| { type: 'get-tree'; depth?: number }
|
|
91
|
+
| { type: 'get-component'; id: number | string }
|
|
92
|
+
| { type: 'find'; name: string; exact?: boolean }
|
|
93
|
+
| { type: 'count' }
|
|
94
|
+
| { type: 'profile-start'; name?: string }
|
|
95
|
+
| { type: 'profile-stop' }
|
|
96
|
+
| { type: 'profile-report'; componentId: number | string }
|
|
97
|
+
| { type: 'profile-slow'; limit?: number }
|
|
98
|
+
| { type: 'profile-rerenders'; limit?: number }
|
|
99
|
+
| { type: 'profile-timeline'; limit?: number }
|
|
100
|
+
| { type: 'profile-commit'; index: number; limit?: number };
|
|
101
|
+
|
|
102
|
+
export interface IpcResponse {
|
|
103
|
+
ok: boolean;
|
|
104
|
+
data?: unknown;
|
|
105
|
+
error?: string;
|
|
106
|
+
/** The @cN label, passed through when commands use label-based IDs */
|
|
107
|
+
label?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── Daemon State ──
|
|
111
|
+
|
|
112
|
+
export interface DaemonInfo {
|
|
113
|
+
pid: number;
|
|
114
|
+
port: number;
|
|
115
|
+
socketPath: string;
|
|
116
|
+
startedAt: number;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface StatusInfo {
|
|
120
|
+
daemonRunning: boolean;
|
|
121
|
+
port: number;
|
|
122
|
+
connectedApps: number;
|
|
123
|
+
componentCount: number;
|
|
124
|
+
profilingActive: boolean;
|
|
125
|
+
uptime: number;
|
|
126
|
+
}
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: {
|
|
5
|
+
cli: 'src/cli.ts',
|
|
6
|
+
daemon: 'src/daemon.ts',
|
|
7
|
+
},
|
|
8
|
+
format: ['esm'],
|
|
9
|
+
target: 'node22',
|
|
10
|
+
platform: 'node',
|
|
11
|
+
splitting: true,
|
|
12
|
+
clean: true,
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
banner: {
|
|
15
|
+
js: '#!/usr/bin/env node',
|
|
16
|
+
},
|
|
17
|
+
});
|