@presto1314w/vite-devtools-browser 0.3.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.
- package/README.md +317 -323
- package/dist/browser-session.d.ts +10 -0
- package/dist/browser-session.js +4 -0
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +58 -3
- package/dist/cli.js +68 -58
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -1,325 +1,319 @@
|
|
|
1
|
-
# vite-browser
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
It
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
#
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
vite-browser
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
##
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
vite-browser
|
|
197
|
-
vite-browser
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
vite-browser
|
|
203
|
-
vite-browser
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
vite-browser
|
|
212
|
-
vite-browser
|
|
213
|
-
vite-browser
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
1
|
+
# vite-browser
|
|
2
|
+
|
|
3
|
+
**Explain why your Vite app broke after a hot update.**
|
|
4
|
+
|
|
5
|
+
`vite-browser` is a runtime diagnostics toolchain for Vite apps. It connects current errors to recent HMR activity, traces store and module updates into rerender paths, and returns structured terminal output that both developers and AI agents can reason about directly.
|
|
6
|
+
|
|
7
|
+
No plugin installation. No GUI. Just connect to a running Vite dev server and start querying.
|
|
8
|
+
|
|
9
|
+
**CLI**
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g @presto1314w/vite-devtools-browser
|
|
12
|
+
npx playwright install chromium
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Agent Skill**
|
|
16
|
+
```bash
|
|
17
|
+
npx skills add MapleCity1314/vite-browser
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## The Problem It Solves
|
|
23
|
+
|
|
24
|
+
You save a file. Vite hot-updates. The page breaks.
|
|
25
|
+
|
|
26
|
+
The error overlay tells you *what* broke. It does not tell you *why the update caused it*.
|
|
27
|
+
|
|
28
|
+
You want to know:
|
|
29
|
+
- which module change triggered this error
|
|
30
|
+
- whether a store update propagated into a broken render path
|
|
31
|
+
- what the HMR timeline looked like before the failure
|
|
32
|
+
|
|
33
|
+
`vite-browser` answers these questions from the terminal, without touching your project config.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quickstart
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# terminal A - your app
|
|
41
|
+
cd my-app && npm run dev
|
|
42
|
+
|
|
43
|
+
# terminal B - diagnostics
|
|
44
|
+
vite-browser open http://localhost:5173
|
|
45
|
+
vite-browser vite runtime
|
|
46
|
+
vite-browser errors --mapped --inline-source
|
|
47
|
+
vite-browser correlate errors --mapped --window 5000
|
|
48
|
+
vite-browser close
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Example: Tracing a Broken HMR Update
|
|
54
|
+
|
|
55
|
+
You edit `src/store/cart.ts`. The page breaks with `TypeError: cannot read properties of undefined`.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# 1. check what the error actually is
|
|
59
|
+
$ vite-browser errors --mapped --inline-source
|
|
60
|
+
|
|
61
|
+
TypeError: Cannot read properties of undefined (reading 'items')
|
|
62
|
+
|
|
63
|
+
# Mapped Stack
|
|
64
|
+
- /src/components/CartSummary.tsx:14:12
|
|
65
|
+
14 | total = cart.items.reduce(...)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 2. correlate with recent HMR activity
|
|
70
|
+
$ vite-browser correlate errors --mapped --window 5000
|
|
71
|
+
|
|
72
|
+
# Error Correlation
|
|
73
|
+
Confidence: high
|
|
74
|
+
HMR update observed within 5000ms of the current error
|
|
75
|
+
Matching modules: /src/store/cart.ts
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# 3. trace how the update propagated
|
|
80
|
+
$ vite-browser correlate renders --window 5000
|
|
81
|
+
|
|
82
|
+
# Render Correlation
|
|
83
|
+
Confidence: high
|
|
84
|
+
Recent store update likely propagated through 1 render step(s).
|
|
85
|
+
|
|
86
|
+
## Store Updates
|
|
87
|
+
- cart
|
|
88
|
+
|
|
89
|
+
## Changed Keys
|
|
90
|
+
- items
|
|
91
|
+
|
|
92
|
+
## Render Path
|
|
93
|
+
- AppShell > ShoppingCart > CartSummary
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 4. get a structured diagnosis
|
|
98
|
+
$ vite-browser diagnose propagation --window 5000
|
|
99
|
+
|
|
100
|
+
# Propagation Diagnosis
|
|
101
|
+
Status: fail
|
|
102
|
+
Confidence: high
|
|
103
|
+
A plausible store -> render -> error propagation path was found.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Four commands. You know the store update broke the render path. You know where to fix it.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Built For Agents
|
|
111
|
+
|
|
112
|
+
Models cannot visually inspect a DevTools panel. They work much better when runtime signals are structured commands that can be queried, compared, and chained in a loop.
|
|
113
|
+
|
|
114
|
+
`vite-browser` turns Vite runtime state, HMR activity, module graph changes, framework component trees, mapped errors, and network activity into terminal output an agent can consume directly.
|
|
115
|
+
|
|
116
|
+
Each command is a one-shot request against a long-lived browser daemon - no browser lifecycle management on every step, no GUI dependency, no project config changes required.
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# an agent debugging loop looks like this
|
|
120
|
+
vite-browser vite runtime
|
|
121
|
+
vite-browser errors --mapped --inline-source
|
|
122
|
+
vite-browser correlate errors --mapped --window 5000
|
|
123
|
+
vite-browser correlate renders --window 5000
|
|
124
|
+
vite-browser diagnose propagation --window 5000
|
|
125
|
+
vite-browser diagnose hmr --limit 50
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Agent Skill workflows are also available for scenario-based debugging in coding assistants:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npx skills add MapleCity1314/vite-browser
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Core Capabilities
|
|
137
|
+
|
|
138
|
+
**Framework detection**
|
|
139
|
+
- Vue, React, Svelte best-effort detection with version hinting
|
|
140
|
+
|
|
141
|
+
**Vue runtime**
|
|
142
|
+
- component tree and details
|
|
143
|
+
- Pinia stores, getters, and changed keys
|
|
144
|
+
- Vue Router state
|
|
145
|
+
|
|
146
|
+
**React runtime**
|
|
147
|
+
- component tree with props, state, hooks, context, and source metadata
|
|
148
|
+
|
|
149
|
+
**Svelte runtime**
|
|
150
|
+
- component tree when metadata is available
|
|
151
|
+
|
|
152
|
+
**Vite runtime diagnostics**
|
|
153
|
+
- runtime status and HMR health
|
|
154
|
+
- HMR timeline, summary, and clear
|
|
155
|
+
- module graph snapshot, diff, trace, and clear
|
|
156
|
+
- error / HMR correlation over configurable time windows
|
|
157
|
+
- store and module update / render path correlation
|
|
158
|
+
- propagation diagnosis with store updates, changed keys, and render paths
|
|
159
|
+
- rule-based HMR diagnosis with confidence levels
|
|
160
|
+
- source-mapped errors with optional inline source snippets
|
|
161
|
+
|
|
162
|
+
**Debug utilities**
|
|
163
|
+
- console logs, network tracing, screenshot, page `eval`
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Positioning
|
|
168
|
+
|
|
169
|
+
| Tool | Best for | Gap vs `vite-browser` |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `agent-browser` | general browser automation | no Vite runtime awareness |
|
|
172
|
+
| `next-browser` | Next.js + React debugging | not a Vite runtime tool |
|
|
173
|
+
| `vite-plugin-vue-mcp` | Vue MCP integration | requires plugin install, Vue only |
|
|
174
|
+
| `vite-browser` | Vite runtime diagnostics for agents and developers | browser lifecycle coverage still expanding |
|
|
175
|
+
|
|
176
|
+
`vite-browser` requires no changes to your project. It works against any running Vite dev server across Vue, React, and Svelte.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Recommended Workflows
|
|
181
|
+
|
|
182
|
+
### HMR / runtime triage
|
|
183
|
+
```bash
|
|
184
|
+
vite-browser vite runtime
|
|
185
|
+
vite-browser errors --mapped --inline-source
|
|
186
|
+
vite-browser correlate errors --mapped --window 5000
|
|
187
|
+
vite-browser diagnose hmr --limit 50
|
|
188
|
+
vite-browser vite hmr trace --limit 50
|
|
189
|
+
vite-browser vite module-graph trace --limit 200
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Propagation / rerender triage
|
|
193
|
+
```bash
|
|
194
|
+
vite-browser correlate renders --window 5000
|
|
195
|
+
vite-browser diagnose propagation --window 5000
|
|
196
|
+
vite-browser vue pinia
|
|
197
|
+
vite-browser vue tree
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Data / API triage
|
|
201
|
+
```bash
|
|
202
|
+
vite-browser errors --mapped
|
|
203
|
+
vite-browser logs
|
|
204
|
+
vite-browser network
|
|
205
|
+
vite-browser network <idx>
|
|
206
|
+
vite-browser eval '<state probe>'
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Component / state triage
|
|
210
|
+
```bash
|
|
211
|
+
vite-browser detect
|
|
212
|
+
vite-browser vue tree
|
|
213
|
+
vite-browser vue pinia
|
|
214
|
+
vite-browser vue router
|
|
215
|
+
vite-browser react tree
|
|
216
|
+
vite-browser svelte tree
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## Command Reference
|
|
222
|
+
|
|
223
|
+
### Browser
|
|
224
|
+
```bash
|
|
225
|
+
vite-browser open <url> [--cookies-json <file>]
|
|
226
|
+
vite-browser close
|
|
227
|
+
vite-browser goto <url>
|
|
228
|
+
vite-browser back
|
|
229
|
+
vite-browser reload
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Framework
|
|
233
|
+
```bash
|
|
234
|
+
vite-browser detect
|
|
235
|
+
vite-browser vue tree [id]
|
|
236
|
+
vite-browser vue pinia [store]
|
|
237
|
+
vite-browser vue router
|
|
238
|
+
vite-browser react tree [id]
|
|
239
|
+
vite-browser svelte tree [id]
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Vite Runtime
|
|
243
|
+
```bash
|
|
244
|
+
vite-browser vite restart
|
|
245
|
+
vite-browser vite runtime
|
|
246
|
+
vite-browser vite hmr
|
|
247
|
+
vite-browser vite hmr trace [--limit <n>]
|
|
248
|
+
vite-browser vite hmr clear
|
|
249
|
+
vite-browser vite module-graph [--filter <txt>] [--limit <n>]
|
|
250
|
+
vite-browser vite module-graph trace [--filter <txt>] [--limit <n>]
|
|
251
|
+
vite-browser vite module-graph clear
|
|
252
|
+
vite-browser errors
|
|
253
|
+
vite-browser errors --mapped
|
|
254
|
+
vite-browser errors --mapped --inline-source
|
|
255
|
+
vite-browser correlate errors [--window <ms>]
|
|
256
|
+
vite-browser correlate renders [--window <ms>]
|
|
257
|
+
vite-browser correlate errors --mapped --inline-source
|
|
258
|
+
vite-browser diagnose hmr [--window <ms>] [--limit <n>]
|
|
259
|
+
vite-browser diagnose propagation [--window <ms>]
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Utilities
|
|
263
|
+
```bash
|
|
264
|
+
vite-browser logs
|
|
265
|
+
vite-browser network [idx]
|
|
266
|
+
vite-browser screenshot
|
|
267
|
+
vite-browser eval <script>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Current Boundaries
|
|
273
|
+
|
|
274
|
+
`v0.3.1` is strong at:
|
|
231
275
|
- surfacing runtime state as structured shell output
|
|
232
|
-
- linking current errors to recent HMR
|
|
233
|
-
- detecting
|
|
276
|
+
- linking current errors to recent HMR and module activity
|
|
277
|
+
- detecting common HMR failure patterns with confidence levels
|
|
234
278
|
- narrowing likely store/module -> render paths in Vue-first flows
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
vite-browser
|
|
247
|
-
vite-browser
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
vite-browser correlate renders [--window <ms>]
|
|
277
|
-
vite-browser correlate errors --mapped --inline-source
|
|
278
|
-
vite-browser diagnose hmr [--window <ms>] [--limit <n>]
|
|
279
|
-
vite-browser diagnose propagation [--window <ms>]
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Utilities
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
vite-browser logs
|
|
286
|
-
vite-browser network [idx]
|
|
287
|
-
vite-browser screenshot
|
|
288
|
-
vite-browser eval <script>
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## Skill Packs
|
|
292
|
-
|
|
293
|
-
The entry skill routes to specialized workflows:
|
|
294
|
-
|
|
295
|
-
- `skills/vite-browser-core-debug/SKILL.md`
|
|
296
|
-
- `skills/vite-browser-runtime-diagnostics/SKILL.md`
|
|
297
|
-
- `skills/vite-browser-network-regression/SKILL.md`
|
|
298
|
-
- `skills/vite-browser-release-smoke/SKILL.md`
|
|
299
|
-
|
|
300
|
-
Router definition: [skills/SKILL.md](./skills/SKILL.md)
|
|
301
|
-
|
|
302
|
-
## Local Development
|
|
303
|
-
|
|
304
|
-
```bash
|
|
305
|
-
pnpm install
|
|
306
|
-
pnpm build
|
|
307
|
-
pnpm test
|
|
308
|
-
pnpm test:coverage
|
|
309
|
-
pnpm test:evals
|
|
310
|
-
pnpm test:evals:e2e
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## Discovery
|
|
314
|
-
|
|
315
|
-
If you want to introduce the project to new users, start with the launch kit in [docs/launch-kit.md](./docs/launch-kit.md).
|
|
316
|
-
|
|
317
|
-
## Requirements
|
|
318
|
-
|
|
319
|
-
- Node.js `>=20`
|
|
320
|
-
- Chromium installed via Playwright
|
|
321
|
-
- Running Vite dev server
|
|
322
|
-
|
|
323
|
-
## License
|
|
324
|
-
|
|
325
|
-
MIT
|
|
279
|
+
- capturing browser-side runtime errors even when the Vite overlay is absent
|
|
280
|
+
|
|
281
|
+
`correlate renders` and `diagnose propagation` are **high-confidence propagation clues**, not strict causal proof. They do not reliably trace deep chains like `store -> component A -> component B -> error` across arbitrary graphs, and intentionally fall back to conservative output when evidence is incomplete.
|
|
282
|
+
|
|
283
|
+
React store inspection (Zustand, Redux) and deeper cross-framework propagation tracing are on the roadmap.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Skill Packs
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
skills/vite-browser-core-debug/SKILL.md
|
|
291
|
+
skills/vite-browser-runtime-diagnostics/SKILL.md
|
|
292
|
+
skills/vite-browser-network-regression/SKILL.md
|
|
293
|
+
skills/vite-browser-release-smoke/SKILL.md
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Router: [skills/SKILL.md](./skills/SKILL.md)
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Local Development
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
pnpm install
|
|
304
|
+
pnpm build
|
|
305
|
+
pnpm test
|
|
306
|
+
pnpm test:coverage
|
|
307
|
+
pnpm test:evals
|
|
308
|
+
pnpm test:evals:e2e
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Requirements
|
|
312
|
+
|
|
313
|
+
- Node.js `>=20`
|
|
314
|
+
- Chromium via Playwright
|
|
315
|
+
- Running Vite dev server
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
MIT
|
|
@@ -8,13 +8,23 @@ export type HmrEvent = {
|
|
|
8
8
|
message: string;
|
|
9
9
|
path?: string;
|
|
10
10
|
};
|
|
11
|
+
export type RuntimeError = {
|
|
12
|
+
timestamp: number;
|
|
13
|
+
message: string;
|
|
14
|
+
stack?: string;
|
|
15
|
+
source?: string | null;
|
|
16
|
+
line?: number | null;
|
|
17
|
+
col?: number | null;
|
|
18
|
+
};
|
|
11
19
|
export type BrowserSessionState = {
|
|
12
20
|
context: BrowserContext | null;
|
|
13
21
|
page: Page | null;
|
|
14
22
|
framework: BrowserFramework;
|
|
15
23
|
extensionModeDisabled: boolean;
|
|
24
|
+
collectorInstalled: boolean;
|
|
16
25
|
consoleLogs: string[];
|
|
17
26
|
hmrEvents: HmrEvent[];
|
|
27
|
+
runtimeErrors: RuntimeError[];
|
|
18
28
|
lastReactSnapshot: ReactNode[];
|
|
19
29
|
lastModuleGraphUrls: string[] | null;
|
|
20
30
|
};
|
package/dist/browser-session.js
CHANGED
|
@@ -13,8 +13,10 @@ export function createBrowserSessionState() {
|
|
|
13
13
|
page: null,
|
|
14
14
|
framework: "unknown",
|
|
15
15
|
extensionModeDisabled: false,
|
|
16
|
+
collectorInstalled: false,
|
|
16
17
|
consoleLogs: [],
|
|
17
18
|
hmrEvents: [],
|
|
19
|
+
runtimeErrors: [],
|
|
18
20
|
lastReactSnapshot: [],
|
|
19
21
|
lastModuleGraphUrls: null,
|
|
20
22
|
};
|
|
@@ -30,8 +32,10 @@ export function resetBrowserSessionState(state) {
|
|
|
30
32
|
state.context = null;
|
|
31
33
|
state.page = null;
|
|
32
34
|
state.framework = "unknown";
|
|
35
|
+
state.collectorInstalled = false;
|
|
33
36
|
state.consoleLogs.length = 0;
|
|
34
37
|
state.hmrEvents.length = 0;
|
|
38
|
+
state.runtimeErrors.length = 0;
|
|
35
39
|
state.lastModuleGraphUrls = null;
|
|
36
40
|
state.lastReactSnapshot = [];
|
|
37
41
|
}
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Page } from "playwright";
|
|
2
|
-
import { type HmrEvent } from "./browser-session.js";
|
|
2
|
+
import { type HmrEvent, type RuntimeError } from "./browser-session.js";
|
|
3
3
|
import { resolveViaSourceMap } from "./sourcemap.js";
|
|
4
4
|
import { EventQueue } from "./event-queue.js";
|
|
5
5
|
export { contextUsable, isClosedTargetError, type HmrEvent } from "./browser-session.js";
|
|
@@ -19,6 +19,7 @@ export declare function cookies(cookies: {
|
|
|
19
19
|
}[], domain: string): Promise<number>;
|
|
20
20
|
export declare function close(): Promise<void>;
|
|
21
21
|
export declare function recordConsoleMessage(logs: string[], events: HmrEvent[], type: string, message: string, maxLogs?: number, maxEvents?: number): void;
|
|
22
|
+
export declare function recordRuntimeError(runtimeErrors: RuntimeError[], message: string, stack?: string, source?: string | null, line?: number | null, col?: number | null, logType?: string, maxErrors?: number): void;
|
|
22
23
|
export declare function parseViteLog(message: string): HmrEvent;
|
|
23
24
|
export declare function goto(url: string): Promise<string>;
|
|
24
25
|
export declare function back(): Promise<void>;
|
package/dist/browser.js
CHANGED
|
@@ -12,6 +12,7 @@ const session = createBrowserSessionState();
|
|
|
12
12
|
let eventQueue = null;
|
|
13
13
|
const MAX_LOGS = 200;
|
|
14
14
|
const MAX_HMR_EVENTS = 500;
|
|
15
|
+
const MAX_RUNTIME_ERRORS = 50;
|
|
15
16
|
export function setEventQueue(queue) {
|
|
16
17
|
eventQueue = queue;
|
|
17
18
|
}
|
|
@@ -25,6 +26,10 @@ export function getCurrentPage() {
|
|
|
25
26
|
* Inject browser-side event collector into the page
|
|
26
27
|
*/
|
|
27
28
|
async function injectEventCollector(currentPage) {
|
|
29
|
+
if (session.context && !session.collectorInstalled) {
|
|
30
|
+
await session.context.addInitScript(initBrowserEventCollector);
|
|
31
|
+
session.collectorInstalled = true;
|
|
32
|
+
}
|
|
28
33
|
await currentPage.evaluate(initBrowserEventCollector);
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
@@ -60,7 +65,15 @@ async function ensurePage() {
|
|
|
60
65
|
}
|
|
61
66
|
function attachListeners(currentPage) {
|
|
62
67
|
currentPage.on("console", (msg) => {
|
|
63
|
-
|
|
68
|
+
const type = msg.type();
|
|
69
|
+
const message = msg.text();
|
|
70
|
+
recordConsoleMessage(session.consoleLogs, session.hmrEvents, type, message);
|
|
71
|
+
if (type === "error" || isVueUnhandledWarning(type, message)) {
|
|
72
|
+
recordRuntimeError(session.runtimeErrors, message, undefined, undefined, undefined, undefined);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
currentPage.on("pageerror", (error) => {
|
|
76
|
+
recordRuntimeError(session.runtimeErrors, error.message, error.stack, undefined, undefined, undefined, "pageerror");
|
|
64
77
|
});
|
|
65
78
|
}
|
|
66
79
|
export function recordConsoleMessage(logs, events, type, message, maxLogs = MAX_LOGS, maxEvents = MAX_HMR_EVENTS) {
|
|
@@ -75,6 +88,34 @@ export function recordConsoleMessage(logs, events, type, message, maxLogs = MAX_
|
|
|
75
88
|
if (events.length > maxEvents)
|
|
76
89
|
events.shift();
|
|
77
90
|
}
|
|
91
|
+
export function recordRuntimeError(runtimeErrors, message, stack, source, line, col, logType = "runtime-error", maxErrors = MAX_RUNTIME_ERRORS) {
|
|
92
|
+
const error = {
|
|
93
|
+
timestamp: Date.now(),
|
|
94
|
+
message,
|
|
95
|
+
stack,
|
|
96
|
+
source,
|
|
97
|
+
line,
|
|
98
|
+
col,
|
|
99
|
+
};
|
|
100
|
+
runtimeErrors.push(error);
|
|
101
|
+
if (runtimeErrors.length > maxErrors)
|
|
102
|
+
runtimeErrors.shift();
|
|
103
|
+
eventQueue?.push({
|
|
104
|
+
timestamp: error.timestamp,
|
|
105
|
+
type: "error",
|
|
106
|
+
payload: {
|
|
107
|
+
message,
|
|
108
|
+
stack,
|
|
109
|
+
source,
|
|
110
|
+
line,
|
|
111
|
+
col,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const details = stack ? `${message}\n${stack}` : message;
|
|
115
|
+
session.consoleLogs.push(`[${logType}] ${details}`);
|
|
116
|
+
if (session.consoleLogs.length > MAX_LOGS)
|
|
117
|
+
session.consoleLogs.shift();
|
|
118
|
+
}
|
|
78
119
|
export function parseViteLog(message) {
|
|
79
120
|
const lower = message.toLowerCase();
|
|
80
121
|
const event = {
|
|
@@ -198,15 +239,29 @@ export async function viteModuleGraph(filter, limit = 200, mode = "snapshot") {
|
|
|
198
239
|
export async function errors(mapped = false, inlineSource = false) {
|
|
199
240
|
const currentPage = requireCurrentPage();
|
|
200
241
|
const errorInfo = await readOverlayError(currentPage);
|
|
201
|
-
|
|
242
|
+
const runtimeError = session.runtimeErrors[session.runtimeErrors.length - 1];
|
|
243
|
+
if (!errorInfo && !runtimeError)
|
|
202
244
|
return "no errors";
|
|
203
|
-
const raw =
|
|
245
|
+
const raw = errorInfo
|
|
246
|
+
? `${errorInfo.message ?? "Vite error"}\n\n${errorInfo.stack ?? ""}`.trim()
|
|
247
|
+
: formatRuntimeError(runtimeError);
|
|
204
248
|
if (!mapped)
|
|
205
249
|
return raw;
|
|
206
250
|
const origin = new URL(currentPage.url()).origin;
|
|
207
251
|
const mappedStack = await mapStackTrace(raw, origin, inlineSource);
|
|
208
252
|
return mappedStack;
|
|
209
253
|
}
|
|
254
|
+
function formatRuntimeError(error) {
|
|
255
|
+
const location = error.source && error.line != null && error.col != null
|
|
256
|
+
? `\n\nat ${error.source}:${error.line}:${error.col}`
|
|
257
|
+
: "";
|
|
258
|
+
return `${error.message}${location}${error.stack ? `\n\n${error.stack}` : ""}`.trim();
|
|
259
|
+
}
|
|
260
|
+
function isVueUnhandledWarning(type, message) {
|
|
261
|
+
if (type !== "warning")
|
|
262
|
+
return false;
|
|
263
|
+
return /\[Vue warn\]: Unhandled error during execution/i.test(message);
|
|
264
|
+
}
|
|
210
265
|
export async function logs() {
|
|
211
266
|
if (session.consoleLogs.length === 0)
|
|
212
267
|
return "no logs";
|
package/dist/cli.js
CHANGED
|
@@ -195,66 +195,69 @@ export function exit(io, res, msg) {
|
|
|
195
195
|
io.exit(0);
|
|
196
196
|
}
|
|
197
197
|
export function printUsage() {
|
|
198
|
-
return `
|
|
199
|
-
vite-browser - Programmatic access to Vue/React/Svelte DevTools and Vite dev server
|
|
200
|
-
|
|
201
|
-
USAGE
|
|
202
|
-
vite-browser <command> [options]
|
|
203
|
-
|
|
204
|
-
BROWSER CONTROL
|
|
205
|
-
open <url> [--cookies-json <file>] Launch browser and navigate
|
|
206
|
-
close Close browser and daemon
|
|
207
|
-
goto <url> Full-page navigation
|
|
208
|
-
back Go back in history
|
|
209
|
-
reload Reload current page
|
|
210
|
-
|
|
211
|
-
FRAMEWORK DETECTION
|
|
212
|
-
detect Detect framework (vue/react/svelte)
|
|
213
|
-
|
|
214
|
-
VUE COMMANDS
|
|
215
|
-
vue tree [id] Show Vue component tree or inspect component
|
|
216
|
-
vue pinia [store] Show Pinia stores or inspect specific store
|
|
217
|
-
vue router Show Vue Router information
|
|
218
|
-
|
|
219
|
-
REACT COMMANDS
|
|
220
|
-
react tree [id] Show React component tree or inspect component
|
|
221
|
-
|
|
222
|
-
SVELTE COMMANDS
|
|
223
|
-
svelte tree [id] Show Svelte component tree or inspect component
|
|
224
|
-
|
|
225
|
-
VITE COMMANDS
|
|
226
|
-
vite restart Restart Vite dev server
|
|
227
|
-
vite hmr Show HMR summary
|
|
228
|
-
vite hmr trace [--limit <n>] Show HMR timeline
|
|
229
|
-
vite hmr clear Clear tracked HMR timeline
|
|
230
|
-
vite runtime Show Vite runtime status
|
|
231
|
-
vite module-graph [--filter <txt>] [--limit <n>]
|
|
232
|
-
Show loaded Vite module resources
|
|
233
|
-
vite module-graph trace [--filter <txt>] [--limit <n>]
|
|
234
|
-
Show module additions/removals since baseline
|
|
235
|
-
vite module-graph clear Clear module-graph baseline
|
|
236
|
-
errors Show build/runtime errors
|
|
237
|
-
errors --mapped Show errors with source-map mapping
|
|
238
|
-
errors --mapped --inline-source Include mapped source snippets
|
|
239
|
-
correlate errors [--window <ms>] Correlate current errors with recent HMR events
|
|
240
|
-
correlate renders [--window <ms>] Summarize recent render/update propagation evidence
|
|
241
|
-
correlate errors --mapped Correlate mapped errors with recent HMR events
|
|
242
|
-
diagnose hmr [--window <ms>] Diagnose HMR failures from runtime, errors, and trace data
|
|
243
|
-
diagnose hmr [--limit <n>] Control how many recent HMR trace entries are inspected
|
|
244
|
-
diagnose propagation [--window <ms>]
|
|
245
|
-
Diagnose likely update -> render -> error propagation
|
|
246
|
-
logs Show dev server logs
|
|
247
|
-
|
|
248
|
-
UTILITIES
|
|
249
|
-
screenshot Save screenshot to temp file
|
|
250
|
-
eval <script> Evaluate JavaScript in page context
|
|
251
|
-
network [idx] List network requests or inspect one
|
|
252
|
-
|
|
253
|
-
OPTIONS
|
|
254
|
-
-h, --help Show this help message
|
|
198
|
+
return `
|
|
199
|
+
vite-browser - Programmatic access to Vue/React/Svelte DevTools and Vite dev server
|
|
200
|
+
|
|
201
|
+
USAGE
|
|
202
|
+
vite-browser <command> [options]
|
|
203
|
+
|
|
204
|
+
BROWSER CONTROL
|
|
205
|
+
open <url> [--cookies-json <file>] Launch browser and navigate
|
|
206
|
+
close Close browser and daemon
|
|
207
|
+
goto <url> Full-page navigation
|
|
208
|
+
back Go back in history
|
|
209
|
+
reload Reload current page
|
|
210
|
+
|
|
211
|
+
FRAMEWORK DETECTION
|
|
212
|
+
detect Detect framework (vue/react/svelte)
|
|
213
|
+
|
|
214
|
+
VUE COMMANDS
|
|
215
|
+
vue tree [id] Show Vue component tree or inspect component
|
|
216
|
+
vue pinia [store] Show Pinia stores or inspect specific store
|
|
217
|
+
vue router Show Vue Router information
|
|
218
|
+
|
|
219
|
+
REACT COMMANDS
|
|
220
|
+
react tree [id] Show React component tree or inspect component
|
|
221
|
+
|
|
222
|
+
SVELTE COMMANDS
|
|
223
|
+
svelte tree [id] Show Svelte component tree or inspect component
|
|
224
|
+
|
|
225
|
+
VITE COMMANDS
|
|
226
|
+
vite restart Restart Vite dev server
|
|
227
|
+
vite hmr Show HMR summary
|
|
228
|
+
vite hmr trace [--limit <n>] Show HMR timeline
|
|
229
|
+
vite hmr clear Clear tracked HMR timeline
|
|
230
|
+
vite runtime Show Vite runtime status
|
|
231
|
+
vite module-graph [--filter <txt>] [--limit <n>]
|
|
232
|
+
Show loaded Vite module resources
|
|
233
|
+
vite module-graph trace [--filter <txt>] [--limit <n>]
|
|
234
|
+
Show module additions/removals since baseline
|
|
235
|
+
vite module-graph clear Clear module-graph baseline
|
|
236
|
+
errors Show build/runtime errors
|
|
237
|
+
errors --mapped Show errors with source-map mapping
|
|
238
|
+
errors --mapped --inline-source Include mapped source snippets
|
|
239
|
+
correlate errors [--window <ms>] Correlate current errors with recent HMR events
|
|
240
|
+
correlate renders [--window <ms>] Summarize recent render/update propagation evidence
|
|
241
|
+
correlate errors --mapped Correlate mapped errors with recent HMR events
|
|
242
|
+
diagnose hmr [--window <ms>] Diagnose HMR failures from runtime, errors, and trace data
|
|
243
|
+
diagnose hmr [--limit <n>] Control how many recent HMR trace entries are inspected
|
|
244
|
+
diagnose propagation [--window <ms>]
|
|
245
|
+
Diagnose likely update -> render -> error propagation
|
|
246
|
+
logs Show dev server logs
|
|
247
|
+
|
|
248
|
+
UTILITIES
|
|
249
|
+
screenshot Save screenshot to temp file
|
|
250
|
+
eval <script> Evaluate JavaScript in page context
|
|
251
|
+
network [idx] List network requests or inspect one
|
|
252
|
+
|
|
253
|
+
OPTIONS
|
|
254
|
+
-h, --help Show this help message
|
|
255
255
|
`;
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
function isEntrypoint(argv1) {
|
|
258
|
+
return Boolean(argv1 && import.meta.url.endsWith(argv1.replaceAll("\\", "/")));
|
|
259
|
+
}
|
|
260
|
+
async function main() {
|
|
258
261
|
await runCli(process.argv, {
|
|
259
262
|
send,
|
|
260
263
|
readFile: readFileSync,
|
|
@@ -263,3 +266,10 @@ if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replaceAll("\\",
|
|
|
263
266
|
exit: (code) => process.exit(code),
|
|
264
267
|
});
|
|
265
268
|
}
|
|
269
|
+
if (isEntrypoint(process.argv[1])) {
|
|
270
|
+
void main().catch((error) => {
|
|
271
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
272
|
+
console.error(message);
|
|
273
|
+
process.exit(1);
|
|
274
|
+
});
|
|
275
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@presto1314w/vite-devtools-browser",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Runtime diagnostics CLI for Vite apps with event-stream correlation, HMR diagnosis, framework inspection, and mapped errors",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"vite",
|
|
8
|
-
"devtools",
|
|
9
|
-
"debugging",
|
|
10
|
-
"runtime-diagnostics",
|
|
11
|
-
"hmr",
|
|
12
|
-
"module-graph",
|
|
13
|
-
"sourcemap",
|
|
14
|
-
"vue",
|
|
15
|
-
"react",
|
|
16
|
-
"svelte",
|
|
17
|
-
"cli",
|
|
18
|
-
"ai-agents"
|
|
19
|
-
],
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Runtime diagnostics CLI for Vite apps with event-stream correlation, HMR diagnosis, framework inspection, and mapped errors",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"vite",
|
|
8
|
+
"devtools",
|
|
9
|
+
"debugging",
|
|
10
|
+
"runtime-diagnostics",
|
|
11
|
+
"hmr",
|
|
12
|
+
"module-graph",
|
|
13
|
+
"sourcemap",
|
|
14
|
+
"vue",
|
|
15
|
+
"react",
|
|
16
|
+
"svelte",
|
|
17
|
+
"cli",
|
|
18
|
+
"ai-agents"
|
|
19
|
+
],
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
22
|
"url": "git+https://github.com/MapleCity1314/vite-browser.git"
|