react-devbelt 0.3.0 → 0.4.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/README.md +41 -257
- package/dist/{chunk-QT3YSHQA.js → chunk-6TOYYHSR.js} +2 -2
- package/dist/chunk-6TOYYHSR.js.map +1 -0
- package/dist/{chunk-C7RMX5PF.js → chunk-C6GPW32O.js} +2 -2
- package/dist/chunk-C6GPW32O.js.map +1 -0
- package/dist/{chunk-6PAFI4BJ.js → chunk-EYWS436C.js} +5 -5
- package/dist/chunk-EYWS436C.js.map +1 -0
- package/dist/{chunk-QRXHNBFY.js → chunk-M4KSKILI.js} +2 -2
- package/dist/chunk-M4KSKILI.js.map +1 -0
- package/dist/{chunk-GB5T3MS2.js → chunk-SYBN2CEO.js} +159 -28
- package/dist/chunk-SYBN2CEO.js.map +1 -0
- package/dist/{context-D2euxPc4.d.ts → context-BLsQOE6l.d.ts} +1 -1
- package/dist/core.js +5 -4
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/install.js +5 -5
- package/dist/install.js.map +1 -1
- package/dist/plugins.js +4 -4
- package/dist/{toolbar-entry-QHIQKNOO.js → toolbar-entry-XIKTJ2OG.js} +24 -24
- package/dist/toolbar-entry-XIKTJ2OG.js.map +1 -0
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +2 -2
- package/package.json +6 -2
- package/dist/chunk-6PAFI4BJ.js.map +0 -1
- package/dist/chunk-C7RMX5PF.js.map +0 -1
- package/dist/chunk-GB5T3MS2.js.map +0 -1
- package/dist/chunk-QRXHNBFY.js.map +0 -1
- package/dist/chunk-QT3YSHQA.js.map +0 -1
- package/dist/toolbar-entry-QHIQKNOO.js.map +0 -1
- /package/dist/{plugin-C8VytW9X.d.ts → index-C8VytW9X.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -15,310 +15,94 @@
|
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
It floats over your app
|
|
18
|
+
It floats over your app, inside a shadow root with its own stylesheet, so your CSS stays untouched. Dev-only: production builds contain none of it.
|
|
19
19
|
|
|
20
|
-
>
|
|
21
|
-
|
|
22
|
-
## ✨ What you get
|
|
23
|
-
|
|
24
|
-
- 🌐 **Network**: every `fetch` and XHR, with bodies, a waterfall, cURL / fetch export and replay
|
|
25
|
-
- 🐛 **Console**: `console.error`, `console.warn`, uncaught errors and unhandled rejections, with stacks
|
|
26
|
-
- 📱 **Viewport**: frame the page as a phone, iPad, laptop or custom size (keys `1`–`6`)
|
|
27
|
-
- 🎯 **Grab**: point at an element (key `G`), copy it with its component stack and source location
|
|
28
|
-
- 🤖 **Debug bundle**: page, viewport, errors and failed requests in one paste for your AI assistant
|
|
29
|
-
- 🗄️ **Storage** *(opt-in)*: view, edit and clear localStorage, sessionStorage and readable cookies. Secret-looking values are Redacted
|
|
30
|
-
- 📐 **Breakpoint** *(opt-in)*: current breakpoint and width, plus an outline-everything toggle
|
|
31
|
-
- 📸 **Capture** *(opt-in)*: screenshots and screen recording
|
|
32
|
-
- ⚡ **TanStack Query** *(opt-in, separate package)*: queries and mutations, with refetch, invalidate and reset
|
|
33
|
-
- 🧠 **Agent tools**: everything above is readable by a browser agent through WebMCP and `window.devbelt`
|
|
34
|
-
- 🔌 **Plugins**: add your own. The built-ins are plugins too
|
|
20
|
+
<div align="center">
|
|
35
21
|
|
|
36
|
-
|
|
22
|
+
<img src="https://raw.githubusercontent.com/ArtifactyNight/react-devbelt/main/docs/images/network.png" alt="The Belt over a page, with the Network window open showing requests and a waterfall" width="900">
|
|
37
23
|
|
|
38
|
-
|
|
24
|
+
</div>
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
<table>
|
|
27
|
+
<tr>
|
|
28
|
+
<td width="50%"><img src="https://raw.githubusercontent.com/ArtifactyNight/react-devbelt/main/docs/images/console.png" alt="The Console window listing an error and a warning"></td>
|
|
29
|
+
<td width="50%"><img src="https://raw.githubusercontent.com/ArtifactyNight/react-devbelt/main/docs/images/viewport.png" alt="The page framed as a phone with the Viewport size buttons in the Belt"></td>
|
|
30
|
+
</tr>
|
|
31
|
+
</table>
|
|
41
32
|
|
|
42
|
-
From your project's folder:
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
npx react-devbelt init
|
|
46
|
-
```
|
|
34
|
+
> ⚠️ `0.x`. The plugin API (`apiVersion: 1`) is the part most likely to change before 1.0.
|
|
47
35
|
|
|
48
|
-
|
|
36
|
+
## ✨ What you get
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
- 🌐 **Network**: every `fetch` and XHR, with bodies, a waterfall, cURL export and replay
|
|
39
|
+
- 🐛 **Console**: errors, warnings and unhandled rejections, with stacks
|
|
40
|
+
- 📱 **Viewport**: frame the page as a phone, iPad or laptop (keys `1`–`6`)
|
|
41
|
+
- 🎯 **Grab**: point at an element (key `G`) and copy it with its component stack and source location
|
|
42
|
+
- 🤖 **Debug bundle** and **Agent tools**: page state in one paste for your AI assistant, and readable by browser agents through WebMCP and `window.devbelt`
|
|
43
|
+
- 🧩 **Opt-in**: Storage, Breakpoint, Capture, and [TanStack Query](https://github.com/ArtifactyNight/react-devbelt/blob/main/packages/devbelt-plugin-tanstack-query). Plugins are open, so you can add your own
|
|
56
44
|
|
|
57
|
-
|
|
45
|
+
## 🚀 Install
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
Needs React 19+.
|
|
60
48
|
|
|
61
49
|
```bash
|
|
62
|
-
npx react-devbelt
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
It moves `react-devbelt`, and `devbelt-plugin-tanstack-query` if you use it, to the latest version with your package manager, keeping each in its section of `package.json`. It shows what will change, links the changelog when a release may break (any minor bump while on `0.x`), and asks first. `-y` and `--cwd` work here too.
|
|
66
|
-
|
|
67
|
-
### 🤖 Agent installation
|
|
68
|
-
|
|
69
|
-
Paste this into Claude Code, Cursor, Codex or any coding agent, from your project's folder. It sets up the default toolbar and leaves the rest alone.
|
|
70
|
-
|
|
71
|
-
```text
|
|
72
|
-
Install react-devbelt, a dev-only toolbar, in this project. Docs: https://github.com/ArtifactyNight/react-devbelt#readme
|
|
73
|
-
|
|
74
|
-
1. Read package.json. react-devbelt needs React 19 or newer. If this project uses an older React, stop and tell me; do not upgrade it.
|
|
75
|
-
2. Add `react-devbelt` as a dev dependency with the package manager this repo already uses (check the lockfile).
|
|
76
|
-
3. Set it up for the framework:
|
|
77
|
-
- Next.js 16.3 or newer: in next.config.ts, wrap the exported config with `withDevBelt` from "react-devbelt/next". In the root layout (app/layout.tsx or src/app/layout.tsx), render `<DevBelt />` from "react-devbelt" once, inside <body> after {children}.
|
|
78
|
-
- Next.js 15 or older: skip withDevBelt. Add `import "react-devbelt/install";` to instrumentation-client.ts (Next 15.3+; create it at the project root, or in src/ if the project uses src/) or to the top of a client entry. Render <DevBelt /> in the root layout as above.
|
|
79
|
-
- Vite, Create React App or any other React app: make `import "react-devbelt/install";` the first import of the entry file (for example src/main.tsx), and render <DevBelt /> next to <App />.
|
|
80
|
-
4. Look for other dev tools this toolbar can replace: @tanstack/react-query-devtools, react-grab, react-scan, eruda, vconsole, a React Query or Redux devtools panel, or similar. List what you find with the file where each is mounted, then ask me whether to remove each one or keep it. Do not remove anything until I answer. If I say remove, delete the import, the mounted component and the dependency.
|
|
81
|
-
5. Keep every other setting and file as it is. Do not wrap <DevBelt /> in an environment check: it renders nothing on the server and in production builds by itself.
|
|
82
|
-
6. Run the type check, start the dev server, and open the app. Confirm the toolbar shows at the bottom of the page. Then tell me which files you changed. Do not commit.
|
|
50
|
+
npx react-devbelt init
|
|
83
51
|
```
|
|
84
52
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
### 🔧 Manual installation
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
npm install -D react-devbelt
|
|
91
|
-
```
|
|
53
|
+
It detects Next.js, Vite or Create React App, installs the package, wires up the toolbar, and shows every file it will touch before asking. `npx react-devbelt upgrade` updates it later.
|
|
92
54
|
|
|
93
|
-
|
|
55
|
+
Prefer a coding agent or manual setup? See the [guide](https://github.com/ArtifactyNight/react-devbelt/blob/main/docs/guide.md#-install).
|
|
94
56
|
|
|
95
|
-
|
|
57
|
+
### ▲ Next.js (16.3+)
|
|
96
58
|
|
|
97
59
|
```ts
|
|
98
|
-
// next.config.ts
|
|
60
|
+
// next.config.ts
|
|
99
61
|
import { withDevBelt } from "react-devbelt/next";
|
|
100
|
-
export default withDevBelt({
|
|
101
|
-
/* your config */
|
|
102
|
-
});
|
|
62
|
+
export default withDevBelt({ /* your config */ });
|
|
103
63
|
```
|
|
104
64
|
|
|
105
65
|
```tsx
|
|
106
|
-
// app/layout.tsx
|
|
66
|
+
// app/layout.tsx, inside <body> after {children}
|
|
107
67
|
import { DevBelt } from "react-devbelt";
|
|
108
|
-
|
|
109
|
-
export default function RootLayout({
|
|
110
|
-
children,
|
|
111
|
-
}: {
|
|
112
|
-
children: React.ReactNode;
|
|
113
|
-
}) {
|
|
114
|
-
return (
|
|
115
|
-
<html lang="en">
|
|
116
|
-
<body>
|
|
117
|
-
{children}
|
|
118
|
-
<DevBelt />
|
|
119
|
-
</body>
|
|
120
|
-
</html>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
68
|
+
<DevBelt />
|
|
123
69
|
```
|
|
124
70
|
|
|
125
|
-
On Next 15 or earlier, skip `withDevBelt` and add `import "react-devbelt/install";` to `instrumentation-client.ts
|
|
71
|
+
On Next 15 or earlier, skip `withDevBelt` and add `import "react-devbelt/install";` to `instrumentation-client.ts`.
|
|
126
72
|
|
|
127
|
-
|
|
73
|
+
### ⚛️ Vite, CRA and other React apps
|
|
128
74
|
|
|
129
75
|
```tsx
|
|
130
76
|
// src/main.tsx
|
|
131
77
|
import "react-devbelt/install"; // first, so early requests and errors are caught
|
|
132
|
-
import { createRoot } from "react-dom/client";
|
|
133
78
|
import { DevBelt } from "react-devbelt";
|
|
134
79
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<App />
|
|
138
|
-
<DevBelt />
|
|
139
|
-
</>,
|
|
140
|
-
);
|
|
80
|
+
// render next to your app:
|
|
81
|
+
<DevBelt />
|
|
141
82
|
```
|
|
142
83
|
|
|
143
|
-
`<DevBelt />` renders nothing on the server and in production.
|
|
84
|
+
`<DevBelt />` renders nothing on the server and in production. A production bundle drops its code entirely.
|
|
144
85
|
|
|
145
86
|
## 🎛️ Choosing and configuring plugins
|
|
146
87
|
|
|
147
|
-
You get Viewport, Grab, Network, Console, Display and Copy debug bundle by default.
|
|
148
|
-
|
|
149
|
-
```tsx
|
|
150
|
-
// devbelt.tsx
|
|
151
|
-
"use client";
|
|
152
|
-
import { DevBelt, installDevBelt } from "react-devbelt";
|
|
153
|
-
import {
|
|
154
|
-
network,
|
|
155
|
-
consolePlugin,
|
|
156
|
-
viewport,
|
|
157
|
-
grab,
|
|
158
|
-
bundle,
|
|
159
|
-
display,
|
|
160
|
-
} from "react-devbelt/plugins";
|
|
161
|
-
|
|
162
|
-
export const plugins =
|
|
163
|
-
process.env.NODE_ENV === "production"
|
|
164
|
-
? []
|
|
165
|
-
: [
|
|
166
|
-
viewport(),
|
|
167
|
-
grab(),
|
|
168
|
-
network({
|
|
169
|
-
// header values are masked in the log; say what a replay should send
|
|
170
|
-
replayHeaders: (name) =>
|
|
171
|
-
name.toLowerCase() === "authorization"
|
|
172
|
-
? `Bearer ${getToken()}`
|
|
173
|
-
: null,
|
|
174
|
-
}),
|
|
175
|
-
consolePlugin(),
|
|
176
|
-
bundle(),
|
|
177
|
-
display({
|
|
178
|
-
darkClass: "dark",
|
|
179
|
-
locale: { cookie: "locale", options: ["en", "th"] },
|
|
180
|
-
}),
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
installDevBelt(plugins); // optional: start capturing before the app renders
|
|
184
|
-
|
|
185
|
-
export const Toolbar = () => <DevBelt plugins={plugins} />;
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
Create the array once at module level, not inside a component. With your own list, do not also `import "react-devbelt/install"`; whichever runs first decides each plugin's options.
|
|
189
|
-
|
|
190
|
-
### 💡 Toolbar tips
|
|
191
|
-
|
|
192
|
-
- Right-click (or long-press) a pinned tool for its own options (the same section as in More tools) and **Unpin from toolbar**.
|
|
193
|
-
- `Ctrl`/`⌘` + `.` collapses the toolbar to its chip (and brings back a hidden one). `Ctrl`/`⌘` + `/` hides everything, windows included, until you press it again. Both work with focus in a text field or in the framed page, and both are in More tools. Hiding is not saved: a reload shows the toolbar again.
|
|
194
|
-
- Text that changes while you watch it, such as the request count, the breakpoint readout and the "Copied" confirmations, morphs between values with [Torph](https://torph.lochie.me).
|
|
195
|
-
|
|
196
|
-
### 🧩 Opt-in plugins
|
|
197
|
-
|
|
198
|
-
Not in `defaultPlugins()`. Add them by name: `[...defaultPlugins(), storage(), breakpoint(), capture()]`.
|
|
199
|
-
|
|
200
|
-
| Plugin | From | What it does |
|
|
201
|
-
| --- | --- | --- |
|
|
202
|
-
| 📐 `breakpoint()` | `react-devbelt/plugins` | Current breakpoint and width, outline-all-elements toggle |
|
|
203
|
-
| 🗄️ `storage()` | `react-devbelt/plugins` | localStorage, sessionStorage and cookies, with Redaction |
|
|
204
|
-
| 📸 `capture()` | `react-devbelt/plugins` | Screenshot (page, region or full page; copied or saved as PNG) and screen recording (saved as a video) |
|
|
205
|
-
| ⚡ `tanstackQuery(client)` | `devbelt-plugin-tanstack-query` | TanStack Query v5 queries and mutations |
|
|
206
|
-
|
|
207
|
-
Each has its own section below, except TanStack Query: see [its package](https://github.com/ArtifactyNight/react-devbelt/blob/main/packages/devbelt-plugin-tanstack-query).
|
|
208
|
-
|
|
209
|
-
### ⚙️ Built-in plugin options
|
|
210
|
-
|
|
211
|
-
| Plugin | Option | Meaning |
|
|
212
|
-
| -------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
213
|
-
| `network()` | `redactHeaders` | Header names to mask. Default: `authorization`, `proxy-authorization`, `cookie`, `set-cookie`, `x-api-key` |
|
|
214
|
-
| | `replayHeaders(name, maskedValue)` | What a replayed request sends for a header. Return `null` to leave it out (the default for redacted headers) |
|
|
215
|
-
| | `fetch` | Also record `fetch`. Default `true` |
|
|
216
|
-
| `storage()` (opt-in) | `stores` | Which stores the Window, Agent tools and Debug bundle include. Any of `localStorage`, `sessionStorage`, `cookies`. Default: all three |
|
|
217
|
-
| | `redact` | Keys whose values are Redacted. Default `/token\|secret\|password\|auth\|session\|jwt\|key/i` |
|
|
218
|
-
| | `includeValuesInBundle` | Put values in the Debug bundle too (Redacted ones stay hidden). Default `false`: key names and sizes only |
|
|
219
|
-
| `display()` | `darkClass` | Class toggled on `<html>` for dark mode. Default `"dark"`; `false` hides the switch |
|
|
220
|
-
| | `locale` | `{ cookie, options, default? }` adds a language switch that sets a cookie and reloads |
|
|
221
|
-
| `breakpoint()` | `breakpoints` | Name to minimum width (px number or `"48rem"`/`"768px"`). Default: Tailwind v4's `sm 40rem`, `md 48rem`, `lg 64rem`, `xl 80rem`, `2xl 96rem` |
|
|
222
|
-
| | `base` | Name of the range below the smallest breakpoint. Default `"base"` |
|
|
223
|
-
| | `outline` | Start with the outline on. Default `false`. A saved choice wins after the first toggle |
|
|
224
|
-
|
|
225
|
-
### 📐 Breakpoint indicator (opt-in)
|
|
226
|
-
|
|
227
|
-
Shows the current breakpoint and width (e.g. `md · 812px`) next to an outline toggle, live as you resize. With a Frame up, it reports the Frame's real width, custom sizes included. Not the window, not the scaled-down on-screen size. Unpin the Plugin and the readout, toggle and outline all stop. The Debug bundle gets a `Breakpoint` line. Below your smallest breakpoint it shows `base`, or the name you pass as `base`.
|
|
228
|
-
|
|
229
|
-
```tsx
|
|
230
|
-
import { breakpoint } from "react-devbelt/plugins";
|
|
231
|
-
|
|
232
|
-
breakpoint(); // Tailwind v4 breakpoints
|
|
233
|
-
breakpoint({ breakpoints: { tablet: "48rem", desktop: 1200 }, base: "xs", outline: true });
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### 📸 Screenshot and recording (opt-in)
|
|
237
|
-
|
|
238
|
-
`capture()` adds a camera, a region picker and a record button.
|
|
239
|
-
|
|
240
|
-
- **Camera**: copies a PNG of the page, toolbar left out (the Frame's page while one is up).
|
|
241
|
-
- **Crop**: drag over the page to copy just that region. `Esc` cancels. Over a Frame, the part outside it is left out.
|
|
242
|
-
- **More tools**: save a screenshot, or a full-page one.
|
|
243
|
-
- **Record**: uses the browser's own screen sharing. It asks what to share and shows its own indicator. Stopping saves a `.webm` (`.mp4` where that's all the browser can record). Hidden where screen capture isn't available.
|
|
244
|
-
|
|
245
|
-
Screenshots are rendered from the DOM with [modern-screenshot](https://github.com/qq15725/modern-screenshot), loaded on first use. No permission prompt. Cross-origin images without CORS headers come out blank.
|
|
246
|
-
|
|
247
|
-
While recording, the toolbar, its windows and popovers (and the size HUD) are hidden so they stay out of the video, then return when you stop. Turn that off with `capture({ hideWhileRecording: false })`, or per person in More tools ("Hide toolbar while recording", saved, wins over the option). To stop with the toolbar hidden, use the browser's own "Stop sharing" bar, or bring the toolbar back with `Ctrl`/`⌘` + `.`.
|
|
248
|
-
|
|
249
|
-
Paste a copied screenshot straight into an AI chat.
|
|
88
|
+
You get Viewport, Grab, Network, Console, Display and Copy debug bundle by default. Add the opt-in ones by name:
|
|
250
89
|
|
|
251
90
|
```tsx
|
|
252
|
-
import {
|
|
253
|
-
|
|
254
|
-
capture(); // screenshots at the screen's pixel ratio
|
|
255
|
-
capture({ scale: 1 }); // smaller files
|
|
256
|
-
capture({ hideWhileRecording: false }); // keep the toolbar in the video
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### 🗄️ Storage (opt-in)
|
|
260
|
-
|
|
261
|
-
Add it by name: `[...defaultPlugins(), storage()]`.
|
|
262
|
-
|
|
263
|
-
Its Window has a tab per enabled store (localStorage, sessionStorage and readable cookies by default; pass `stores` to drop one), a filter, and a detail area. Open an entry to see its value in the JSON view, shortened until you expand it. You can add, edit and delete entries, or clear the active store. Redacted values stay hidden until revealed, and can be replaced or deleted without being shown. `devbelt:*` keys are never touched.
|
|
264
|
-
|
|
265
|
-
- **Write Agent tools** (`devbelt_set_storage_item`, `devbelt_delete_storage_item`, `devbelt_clear_storage`) are off until you set `agent: { write: true }` on the plugin.
|
|
266
|
-
- **HttpOnly cookies** can't be seen, and it says so.
|
|
267
|
-
- **Redaction**: values whose key matches `redact` show only name and length, in the Window, in `devbelt_get_storage` and in the Debug bundle.
|
|
268
|
-
- **Debug bundle**: key names and sizes. Values only with `includeValuesInBundle`, and Redacted ones never.
|
|
269
|
-
|
|
270
|
-
## 🧱 `<DevBelt>` props
|
|
271
|
-
|
|
272
|
-
| Prop | Default | |
|
|
273
|
-
| ----------- | ---------- | --------------------------------------------------------------------------- |
|
|
274
|
-
| `plugins` | built-ins | The tools to show |
|
|
275
|
-
| `isolation` | `"shadow"` | `"none"` renders in a plain div; import `react-devbelt/styles.css` yourself |
|
|
276
|
-
| `panelMode` | `"window"` | How tools open: `"window"` is a floating window; `"popover"` is a panel on the tool's toolbar item, one at a time. People switch it in More tools, and that choice is remembered |
|
|
277
|
-
| `aiTools` | Cursor, Claude Code, Codex | The AI tools offered by "Open debug bundle in" and Grab's "After grabbing" in More tools. See [AI tools](#-ai-tools) |
|
|
278
|
-
| `enabled` | `true` | Switch the toolbar off in development without removing it |
|
|
279
|
-
|
|
280
|
-
## 🤝 AI tools
|
|
281
|
-
|
|
282
|
-
**Open debug bundle in** (More tools) and **After grabbing** (a saved choice that also opens what Grab copied) hand a prompt to an AI coding tool on the same machine, through its deep link. The prompt is filled in, not sent. You read it, then press Enter.
|
|
283
|
-
|
|
284
|
-
| Tool | Link | Notes |
|
|
285
|
-
| --- | --- | --- |
|
|
286
|
-
| Cursor | `cursor://anysphere.cursor-deeplink/prompt?text=…` | Opens in the focused Cursor window |
|
|
287
|
-
| Claude Code | `claude-cli://open?q=…` | Works once Claude Code has run an interactive session on the machine, which registers the link handler |
|
|
288
|
-
| Codex | `codex://new?prompt=…` | The Codex app |
|
|
91
|
+
import { DevBelt } from "react-devbelt";
|
|
92
|
+
import { defaultPlugins, storage, breakpoint, capture } from "react-devbelt/plugins";
|
|
289
93
|
|
|
290
|
-
|
|
94
|
+
const plugins = [...defaultPlugins(), storage(), breakpoint(), capture()]; // build once, at module level
|
|
291
95
|
|
|
292
|
-
|
|
293
|
-
import { defaultAiTools } from "react-devbelt/core";
|
|
294
|
-
|
|
295
|
-
const aiTools = [
|
|
296
|
-
...defaultAiTools,
|
|
297
|
-
{
|
|
298
|
-
id: "my-editor",
|
|
299
|
-
label: "My editor",
|
|
300
|
-
link: (prompt: string) => `my-editor://chat?prompt=${encodeURIComponent(prompt)}`,
|
|
301
|
-
maxPrompt: 4000, // optional, default 5000
|
|
302
|
-
},
|
|
303
|
-
];
|
|
304
|
-
|
|
305
|
-
<DevBelt aiTools={aiTools} />;
|
|
96
|
+
<DevBelt plugins={plugins} />;
|
|
306
97
|
```
|
|
307
98
|
|
|
308
|
-
|
|
99
|
+
Options for each plugin, `<DevBelt>` props and AI tools are in the [guide](https://github.com/ArtifactyNight/react-devbelt/blob/main/docs/guide.md). To write your own, see [docs/plugins.md](https://github.com/ArtifactyNight/react-devbelt/blob/main/docs/plugins.md).
|
|
309
100
|
|
|
310
101
|
## 🔒 Security
|
|
311
102
|
|
|
312
|
-
The toolbar reads request and response **bodies** and console output. Header credentials are masked
|
|
313
|
-
|
|
314
|
-
- 🚫 Built for development. Production builds drop it. Don't expose it on shared or demo environments.
|
|
315
|
-
- 👀 Tools offered to browser agents are read-only, apart from changing the viewport. Everything they return is marked as untrusted content.
|
|
316
|
-
- ✍️ Tools that change state (editing storage, refetching or invalidating queries) don't exist until you set `agent: { write: true }` on that Plugin.
|
|
317
|
-
- 🙈 Values whose key looks secret (`token`, `password`, `auth`, `session`, `jwt`, `key`, and so on) are Redacted in the Toolbar, in Agent tools and in the Debug bundle.
|
|
318
|
-
|
|
319
|
-
## 🛠️ Writing a plugin
|
|
103
|
+
The toolbar reads request and response **bodies** and console output. Header credentials are masked; bodies are not. Don't expose it on shared or demo environments.
|
|
320
104
|
|
|
321
|
-
|
|
105
|
+
Agent tools are read-only unless you set `agent: { write: true }` on a plugin. Values whose key looks secret (`token`, `password`, `auth`, `jwt`, `key`…) are redacted everywhere.
|
|
322
106
|
|
|
323
107
|
## License
|
|
324
108
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/ui/context.ts
|
|
3
|
+
// src/ui/toolbar/context.ts
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
5
|
var ToolbarContext = createContext(null);
|
|
6
6
|
function useToolbar() {
|
|
@@ -15,4 +15,4 @@ export {
|
|
|
15
15
|
ToolbarContext,
|
|
16
16
|
useToolbar
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-6TOYYHSR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/toolbar/context.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\nimport type { ToolbarApi } from \"../../plugin-api\";\n\nexport const ToolbarContext = createContext<ToolbarApi | null>(null);\n\n/** The toolbar's API, from inside any plugin component. */\nexport function useToolbar(): ToolbarApi {\n const api = useContext(ToolbarContext);\n if (!api) {\n throw new Error(\"devbelt: useToolbar() must be used inside <DevBelt>.\");\n }\n return api;\n}\n"],"mappings":";;;AAEA,SAAS,eAAe,kBAAkB;AAInC,IAAM,iBAAiB,cAAiC,IAAI;AAG5D,SAAS,aAAyB;AACvC,QAAM,MAAM,WAAW,cAAc;AACrC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,sDAAsD;AAAA,EACxE;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
// src/install-plugins.ts
|
|
3
|
+
// src/runtime/install-plugins.ts
|
|
4
4
|
var KEY = "__devbeltInstalled";
|
|
5
5
|
function registry() {
|
|
6
6
|
const host = window;
|
|
@@ -54,4 +54,4 @@ function installPlugins(plugins) {
|
|
|
54
54
|
export {
|
|
55
55
|
installPlugins
|
|
56
56
|
};
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-C6GPW32O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runtime/install-plugins.ts"],"sourcesContent":["import type { DevBeltPlugin } from \"../plugin-api\";\n\ntype Installed = { cleanup: () => void; refs: number };\n\nconst KEY = \"__devbeltInstalled\";\n\nfunction registry(): Map<string, Installed> {\n const host = window as unknown as Record<string, Map<string, Installed>>;\n return (host[KEY] ??= new Map());\n}\n\n/**\n * Runs each plugin's `install` once per frame, however many times this is\n * called (a strict-mode remount, `installDevBelt` plus `<DevBelt />`).\n * The returned function lets go of this caller's hold; a plugin is cleaned up\n * when nobody holds it.\n */\nexport function installPlugins(plugins: readonly DevBeltPlugin[]): () => void {\n if (typeof window === \"undefined\") return () => {};\n const ids = new Set<string>();\n for (const { id } of plugins) {\n if (ids.has(id)) {\n throw new Error(\n `devbelt: two plugins share the id \"${id}\". Plugin ids must be unique.`,\n );\n }\n ids.add(id);\n }\n const installed = registry();\n const held: string[] = [];\n\n for (const plugin of plugins) {\n const existing = installed.get(plugin.id);\n if (existing) {\n existing.refs++;\n } else {\n let cleanup: () => void = () => {};\n try {\n cleanup = plugin.install?.() ?? (() => {});\n } catch (error) {\n // one broken plugin must not take the others down\n console.warn(`devbelt: plugin \"${plugin.id}\" failed to install`, error);\n }\n installed.set(plugin.id, { cleanup, refs: 1 });\n }\n held.push(plugin.id);\n }\n\n let released = false;\n return () => {\n if (released) return;\n released = true;\n for (const id of held) {\n const entry = installed.get(id);\n if (entry && --entry.refs <= 0) {\n entry.cleanup();\n installed.delete(id);\n }\n }\n };\n}\n"],"mappings":";;;AAIA,IAAM,MAAM;AAEZ,SAAS,WAAmC;AAC1C,QAAM,OAAO;AACb,SAAQ,KAAK,GAAG,MAAM,oBAAI,IAAI;AAChC;AAQO,SAAS,eAAe,SAA+C;AAC5E,MAAI,OAAO,WAAW,YAAa,QAAO,MAAM;AAAA,EAAC;AACjD,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,EAAE,GAAG,KAAK,SAAS;AAC5B,QAAI,IAAI,IAAI,EAAE,GAAG;AACf,YAAM,IAAI;AAAA,QACR,sCAAsC,EAAE;AAAA,MAC1C;AAAA,IACF;AACA,QAAI,IAAI,EAAE;AAAA,EACZ;AACA,QAAM,YAAY,SAAS;AAC3B,QAAM,OAAiB,CAAC;AAExB,aAAW,UAAU,SAAS;AAC5B,UAAM,WAAW,UAAU,IAAI,OAAO,EAAE;AACxC,QAAI,UAAU;AACZ,eAAS;AAAA,IACX,OAAO;AACL,UAAI,UAAsB,MAAM;AAAA,MAAC;AACjC,UAAI;AACF,kBAAU,OAAO,UAAU,MAAM,MAAM;AAAA,QAAC;AAAA,MAC1C,SAAS,OAAO;AAEd,gBAAQ,KAAK,oBAAoB,OAAO,EAAE,uBAAuB,KAAK;AAAA,MACxE;AACA,gBAAU,IAAI,OAAO,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;AAAA,IAC/C;AACA,SAAK,KAAK,OAAO,EAAE;AAAA,EACrB;AAEA,MAAI,WAAW;AACf,SAAO,MAAM;AACX,QAAI,SAAU;AACd,eAAW;AACX,eAAW,MAAM,MAAM;AACrB,YAAM,QAAQ,UAAU,IAAI,EAAE;AAC9B,UAAI,SAAS,EAAE,MAAM,QAAQ,GAAG;AAC9B,cAAM,QAAQ;AACd,kBAAU,OAAO,EAAE;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
ToolbarContext
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6TOYYHSR.js";
|
|
5
5
|
import {
|
|
6
6
|
announce
|
|
7
7
|
} from "./chunk-3SXZJ6OP.js";
|
|
@@ -10404,7 +10404,7 @@ function ShortcutPart({
|
|
|
10404
10404
|
);
|
|
10405
10405
|
}
|
|
10406
10406
|
|
|
10407
|
-
// src/ui/styles.ts
|
|
10407
|
+
// src/ui/primitives/styles.ts
|
|
10408
10408
|
var toolbarItemClass = "relative z-10 inline-flex h-8 items-center after:absolute after:inset-x-0 after:-inset-y-1 gap-1.5 rounded-full px-2.5 text-xs font-medium text-fg transition-colors duration-75 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-focus [&_svg]:text-fg-icon [&_svg]:transition-colors [&_svg]:duration-75 data-pressed:[&_svg]:text-fg";
|
|
10409
10409
|
var tooltipClass = "m-0 flex items-center gap-2 rounded-md border border-line bg-surface-raised px-2 py-1 text-xs text-fg shadow-lg";
|
|
10410
10410
|
var kbdClass = "inline-flex h-4 min-w-4 items-center justify-center rounded border border-line-control px-1 font-sans text-[10px] leading-none text-fg";
|
|
@@ -10412,7 +10412,7 @@ var textButtonClass = "inline-flex min-h-6 items-center rounded-md px-1.5 hover:
|
|
|
10412
10412
|
var iconButtonClass = "inline-flex size-7 items-center justify-center rounded-md text-fg-icon hover:bg-hover hover:text-fg focus-visible:outline-2 focus-visible:outline-focus";
|
|
10413
10413
|
var chipClass = "inline-flex h-6 items-center gap-1 rounded-full border border-line-strong px-2.5 text-[11px] font-medium text-fg hover:bg-hover focus-visible:outline-2 focus-visible:outline-focus data-pressed:border-line-inverse data-pressed:bg-inverse data-pressed:text-fg-inverse";
|
|
10414
10414
|
|
|
10415
|
-
// src/ui/morph-text.tsx
|
|
10415
|
+
// src/ui/primitives/morph-text.tsx
|
|
10416
10416
|
import { useContext as useContext4, useEffect as useEffect2 } from "react";
|
|
10417
10417
|
import { TextMorph } from "torph/react";
|
|
10418
10418
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
@@ -14421,7 +14421,7 @@ var TabsTabIcon = parts8.TabIcon;
|
|
|
14421
14421
|
var TabsIndicator = parts8.Indicator;
|
|
14422
14422
|
var TabsPanel = parts8.Panel;
|
|
14423
14423
|
|
|
14424
|
-
// src/ui/json-code.tsx
|
|
14424
|
+
// src/ui/primitives/json-code.tsx
|
|
14425
14425
|
import { useMemo as useMemo2 } from "react";
|
|
14426
14426
|
import hljs from "highlight.js/lib/core";
|
|
14427
14427
|
import json from "highlight.js/lib/languages/json";
|
|
@@ -14612,4 +14612,4 @@ export {
|
|
|
14612
14612
|
TabsPanel,
|
|
14613
14613
|
JsonCode
|
|
14614
14614
|
};
|
|
14615
|
-
//# sourceMappingURL=chunk-
|
|
14615
|
+
//# sourceMappingURL=chunk-EYWS436C.js.map
|