react-devbelt 0.0.0-stage โ 0.2.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/LICENSE +21 -0
- package/NOTICE +16 -0
- package/README.md +324 -2
- package/dist/announce-6XECDMRI.js +12 -0
- package/dist/announce-6XECDMRI.js.map +1 -0
- package/dist/chunk-3SXZJ6OP.js +65 -0
- package/dist/chunk-3SXZJ6OP.js.map +1 -0
- package/dist/chunk-63DO3YVL.js +330 -0
- package/dist/chunk-63DO3YVL.js.map +1 -0
- package/dist/chunk-6PAFI4BJ.js +14615 -0
- package/dist/chunk-6PAFI4BJ.js.map +1 -0
- package/dist/chunk-7JLNVGRQ.js +164 -0
- package/dist/chunk-7JLNVGRQ.js.map +1 -0
- package/dist/chunk-C7RMX5PF.js +57 -0
- package/dist/chunk-C7RMX5PF.js.map +1 -0
- package/dist/chunk-GB5T3MS2.js +8030 -0
- package/dist/chunk-GB5T3MS2.js.map +1 -0
- package/dist/chunk-GNJF3UHO.js +1030 -0
- package/dist/chunk-GNJF3UHO.js.map +1 -0
- package/dist/chunk-PRTINXUT.js +105 -0
- package/dist/chunk-PRTINXUT.js.map +1 -0
- package/dist/chunk-QRXHNBFY.js +22 -0
- package/dist/chunk-QRXHNBFY.js.map +1 -0
- package/dist/chunk-QT3YSHQA.js +18 -0
- package/dist/chunk-QT3YSHQA.js.map +1 -0
- package/dist/cli.js +2174 -0
- package/dist/context-D2euxPc4.d.ts +6 -0
- package/dist/core.d.ts +266 -0
- package/dist/core.js +1070 -0
- package/dist/core.js.map +1 -0
- package/dist/findable-rows-UQBKFZ45.js +356 -0
- package/dist/findable-rows-UQBKFZ45.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.js +21 -0
- package/dist/install.js.map +1 -0
- package/dist/next.d.ts +18 -0
- package/dist/next.js +13 -0
- package/dist/next.js.map +1 -0
- package/dist/plugin-C8VytW9X.d.ts +162 -0
- package/dist/plugins.d.ts +118 -0
- package/dist/plugins.js +36 -0
- package/dist/plugins.js.map +1 -0
- package/dist/sheet-presentation-S6GGOKMB.js +2667 -0
- package/dist/sheet-presentation-S6GGOKMB.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/toolbar-entry-QHIQKNOO.js +1687 -0
- package/dist/toolbar-entry-QHIQKNOO.js.map +1 -0
- package/dist/ui.d.ts +37 -0
- package/dist/ui.js +126 -0
- package/dist/ui.js.map +1 -0
- package/licenses/motion-MIT.txt +21 -0
- package/licenses/ui-sdk-APACHE-2.0.txt +202 -0
- package/package.json +120 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 react-devbelt contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
devbelt
|
|
2
|
+
Copyright (c) 2026 react-devbelt contributors. MIT License (see LICENSE).
|
|
3
|
+
|
|
4
|
+
This package bundles third-party software in its distributed files:
|
|
5
|
+
|
|
6
|
+
ui-sdk (@ui-sdk/core, @ui-sdk/react) - Apache License 2.0
|
|
7
|
+
https://github.com/vercel-labs/ui
|
|
8
|
+
The full license text is in licenses/ui-sdk-APACHE-2.0.txt.
|
|
9
|
+
|
|
10
|
+
motion (framer-motion) - MIT License
|
|
11
|
+
https://motion.dev
|
|
12
|
+
The full license text is in licenses/motion-MIT.txt.
|
|
13
|
+
|
|
14
|
+
It also depends on, without bundling them:
|
|
15
|
+
|
|
16
|
+
react-grab (MIT), highlight.js (BSD-3-Clause), lucide-react (ISC)
|
package/README.md
CHANGED
|
@@ -1,3 +1,325 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# ๐งฐ react-devbelt
|
|
4
|
+
|
|
5
|
+
**A dev toolbar for React and Next.js. Network, console, viewport, grab. One belt.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/react-devbelt)
|
|
8
|
+
[](https://www.npmjs.com/package/react-devbelt)
|
|
9
|
+
[](https://react.dev)
|
|
10
|
+
[](https://nextjs.org)
|
|
11
|
+
[](https://www.typescriptlang.org)
|
|
12
|
+
[](#-security)
|
|
13
|
+
[](#license)
|
|
14
|
+
[](#)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
It floats over your app. It lives in a **shadow root** with its own stylesheet: no Tailwind needed, your CSS untouched. Dev-only: production builds contain none of it.
|
|
19
|
+
|
|
20
|
+
> โ ๏ธ `0.x`. The plugin API (`apiVersion: 1`) is the part most likely to change before 1.0.
|
|
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
|
|
35
|
+
|
|
36
|
+
## ๐ฆ Install
|
|
37
|
+
|
|
38
|
+
Needs React 19+. Built on [ui-sdk](https://ui-sdk.dev) and bundles it. Nothing else to install.
|
|
39
|
+
|
|
40
|
+
### ๐ Get started (npx)
|
|
41
|
+
|
|
42
|
+
From your project's folder:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx react-devbelt init
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
It reads your project (Next.js App or Pages Router, Vite, Create React App), installs `react-devbelt` with the package manager your lockfile uses, and wires up the toolbar. It asks which opt-in tools to add (Storage, Breakpoint, Capture); pick any and it writes a `devbelt.tsx` that holds the plugin list. It shows every file it will touch and asks first. Anything it can't edit safely, it tells you to do by hand.
|
|
49
|
+
|
|
50
|
+
| Flag | What it does |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `-y`, `--yes` | Skip the questions and accept the plan |
|
|
53
|
+
| `--plugins storage,capture` | Choose opt-in tools without the picker (`none` for no extras) |
|
|
54
|
+
| `--skip-install` | Only edit files, don't install the package |
|
|
55
|
+
| `--cwd <dir>` | Run in another folder |
|
|
56
|
+
|
|
57
|
+
Running it again is safe: it only changes what isn't set up yet.
|
|
58
|
+
|
|
59
|
+
To update later:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npx react-devbelt upgrade
|
|
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.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Want the opt-in tools (`storage()`, `breakpoint()`, `capture()`) later? Ask the agent to follow [Choosing and configuring plugins](#-choosing-and-configuring-plugins).
|
|
86
|
+
|
|
87
|
+
### ๐ง Manual installation
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npm install -D react-devbelt
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then set it up for your framework in the Next.js or React sections below. To pick tools or tune them, see [Choosing and configuring plugins](#-choosing-and-configuring-plugins).
|
|
94
|
+
|
|
95
|
+
## โฒ Next.js (16.3+)
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
// next.config.ts: captures requests and errors before hydration
|
|
99
|
+
import { withDevBelt } from "react-devbelt/next";
|
|
100
|
+
export default withDevBelt({
|
|
101
|
+
/* your config */
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// app/layout.tsx
|
|
107
|
+
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
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
On Next 15 or earlier, skip `withDevBelt` and add `import "react-devbelt/install";` to `instrumentation-client.ts` (Next 15.3+) or the top of a client entry.
|
|
126
|
+
|
|
127
|
+
## โ๏ธ React (Vite, CRA, anything)
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
// src/main.tsx
|
|
131
|
+
import "react-devbelt/install"; // first, so early requests and errors are caught
|
|
132
|
+
import { createRoot } from "react-dom/client";
|
|
133
|
+
import { DevBelt } from "react-devbelt";
|
|
134
|
+
|
|
135
|
+
createRoot(document.getElementById("root")!).render(
|
|
136
|
+
<>
|
|
137
|
+
<App />
|
|
138
|
+
<DevBelt />
|
|
139
|
+
</>,
|
|
140
|
+
);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`<DevBelt />` renders nothing on the server and in production. Its code sits behind a build-time `process.env.NODE_ENV` check, so a production bundle drops it entirely (verified against `next build`).
|
|
144
|
+
|
|
145
|
+
## ๐๏ธ Choosing and configuring plugins
|
|
146
|
+
|
|
147
|
+
You get Viewport, Grab, Network, Console, Display and Copy debug bundle by default. To tune them or add your own, make a **client module** that builds the list once:
|
|
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.
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { capture } from "react-devbelt/plugins";
|
|
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 |
|
|
289
|
+
|
|
290
|
+
A prompt over 5,000 characters doesn't fit in a link. It's copied instead, the tool is opened empty where it has such a link (Claude Code), and the toolbar says "Copied ยท paste into โฆ". Add your own tool, or drop one, with the `aiTools` prop. Create the array once, at module level:
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
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} />;
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
A plugin can use the same list: `openInAiTool(tool, text)` from `react-devbelt/core`, with the tools from `useToolbar().aiTools`.
|
|
309
|
+
|
|
310
|
+
## ๐ Security
|
|
311
|
+
|
|
312
|
+
The toolbar reads request and response **bodies** and console output. Header credentials are masked. Bodies are not.
|
|
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
|
|
320
|
+
|
|
321
|
+
See [docs/plugins.md](https://github.com/ArtifactyNight/react-devbelt/blob/main/docs/plugins.md).
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT. Bundles ui-sdk (Apache-2.0); see `NOTICE`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// ../../node_modules/.pnpm/@ui-sdk+core@0.1.0-beta.5/node_modules/@ui-sdk/core/dist/foundation/platform/announce.js
|
|
4
|
+
var regions = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
var announcer;
|
|
6
|
+
var pending = {};
|
|
7
|
+
function setAnnouncer(announce2) {
|
|
8
|
+
announcer = announce2;
|
|
9
|
+
}
|
|
10
|
+
function regionIn(doc, priority) {
|
|
11
|
+
let found = regions.get(doc);
|
|
12
|
+
if (!found) {
|
|
13
|
+
regions.set(doc, found = {});
|
|
14
|
+
}
|
|
15
|
+
const existing = found[priority];
|
|
16
|
+
if (existing?.isConnected) {
|
|
17
|
+
return existing;
|
|
18
|
+
}
|
|
19
|
+
const region = doc.createElement("div");
|
|
20
|
+
region.setAttribute("role", priority === "assertive" ? "alert" : "status");
|
|
21
|
+
region.setAttribute("aria-live", priority);
|
|
22
|
+
region.setAttribute("aria-atomic", "true");
|
|
23
|
+
region.setAttribute(
|
|
24
|
+
"data-ui-sdk-announcer",
|
|
25
|
+
priority === "assertive" ? "assertive" : ""
|
|
26
|
+
);
|
|
27
|
+
region.style.cssText = "position:fixed;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap";
|
|
28
|
+
doc.body.append(region);
|
|
29
|
+
found[priority] = region;
|
|
30
|
+
return region;
|
|
31
|
+
}
|
|
32
|
+
function prepareAnnouncements(doc) {
|
|
33
|
+
if (announcer || !doc.body) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
regionIn(doc, "polite");
|
|
37
|
+
regionIn(doc, "assertive");
|
|
38
|
+
}
|
|
39
|
+
function announce(text, {
|
|
40
|
+
priority = "polite",
|
|
41
|
+
doc = typeof document === "undefined" ? void 0 : document
|
|
42
|
+
} = {}) {
|
|
43
|
+
if (!text) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (announcer) {
|
|
47
|
+
return announcer(text, priority);
|
|
48
|
+
}
|
|
49
|
+
if (!doc?.body) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const region = regionIn(doc, priority);
|
|
53
|
+
region.textContent = "";
|
|
54
|
+
clearTimeout(pending[priority]);
|
|
55
|
+
pending[priority] = setTimeout(() => {
|
|
56
|
+
region.textContent = text;
|
|
57
|
+
}, 100);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
setAnnouncer,
|
|
62
|
+
prepareAnnouncements,
|
|
63
|
+
announce
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=chunk-3SXZJ6OP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@ui-sdk+core@0.1.0-beta.5/node_modules/@ui-sdk/core/dist/foundation/platform/announce.js"],"sourcesContent":["// src/foundation/platform/announce.ts\nvar regions = /* @__PURE__ */ new WeakMap();\nvar announcer;\nvar pending = {};\nfunction setAnnouncer(announce2) {\n announcer = announce2;\n}\nfunction regionIn(doc, priority) {\n let found = regions.get(doc);\n if (!found) {\n regions.set(doc, found = {});\n }\n const existing = found[priority];\n if (existing?.isConnected) {\n return existing;\n }\n const region = doc.createElement(\"div\");\n region.setAttribute(\"role\", priority === \"assertive\" ? \"alert\" : \"status\");\n region.setAttribute(\"aria-live\", priority);\n region.setAttribute(\"aria-atomic\", \"true\");\n region.setAttribute(\n \"data-ui-sdk-announcer\",\n priority === \"assertive\" ? \"assertive\" : \"\"\n );\n region.style.cssText = \"position:fixed;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap\";\n doc.body.append(region);\n found[priority] = region;\n return region;\n}\nfunction prepareAnnouncements(doc) {\n if (announcer || !doc.body) {\n return;\n }\n regionIn(doc, \"polite\");\n regionIn(doc, \"assertive\");\n}\nfunction announce(text, {\n priority = \"polite\",\n doc = typeof document === \"undefined\" ? void 0 : document\n} = {}) {\n if (!text) {\n return;\n }\n if (announcer) {\n return announcer(text, priority);\n }\n if (!doc?.body) {\n return;\n }\n const region = regionIn(doc, priority);\n region.textContent = \"\";\n clearTimeout(pending[priority]);\n pending[priority] = setTimeout(() => {\n region.textContent = text;\n }, 100);\n}\nexport {\n announce,\n prepareAnnouncements,\n setAnnouncer\n};\n"],"mappings":";;;AACA,IAAI,UAA0B,oBAAI,QAAQ;AAC1C,IAAI;AACJ,IAAI,UAAU,CAAC;AACf,SAAS,aAAa,WAAW;AAC/B,cAAY;AACd;AACA,SAAS,SAAS,KAAK,UAAU;AAC/B,MAAI,QAAQ,QAAQ,IAAI,GAAG;AAC3B,MAAI,CAAC,OAAO;AACV,YAAQ,IAAI,KAAK,QAAQ,CAAC,CAAC;AAAA,EAC7B;AACA,QAAM,WAAW,MAAM,QAAQ;AAC/B,MAAI,UAAU,aAAa;AACzB,WAAO;AAAA,EACT;AACA,QAAM,SAAS,IAAI,cAAc,KAAK;AACtC,SAAO,aAAa,QAAQ,aAAa,cAAc,UAAU,QAAQ;AACzE,SAAO,aAAa,aAAa,QAAQ;AACzC,SAAO,aAAa,eAAe,MAAM;AACzC,SAAO;AAAA,IACL;AAAA,IACA,aAAa,cAAc,cAAc;AAAA,EAC3C;AACA,SAAO,MAAM,UAAU;AACvB,MAAI,KAAK,OAAO,MAAM;AACtB,QAAM,QAAQ,IAAI;AAClB,SAAO;AACT;AACA,SAAS,qBAAqB,KAAK;AACjC,MAAI,aAAa,CAAC,IAAI,MAAM;AAC1B;AAAA,EACF;AACA,WAAS,KAAK,QAAQ;AACtB,WAAS,KAAK,WAAW;AAC3B;AACA,SAAS,SAAS,MAAM;AAAA,EACtB,WAAW;AAAA,EACX,MAAM,OAAO,aAAa,cAAc,SAAS;AACnD,IAAI,CAAC,GAAG;AACN,MAAI,CAAC,MAAM;AACT;AAAA,EACF;AACA,MAAI,WAAW;AACb,WAAO,UAAU,MAAM,QAAQ;AAAA,EACjC;AACA,MAAI,CAAC,KAAK,MAAM;AACd;AAAA,EACF;AACA,QAAM,SAAS,SAAS,KAAK,QAAQ;AACrC,SAAO,cAAc;AACrB,eAAa,QAAQ,QAAQ,CAAC;AAC9B,UAAQ,QAAQ,IAAI,WAAW,MAAM;AACnC,WAAO,cAAc;AAAA,EACvB,GAAG,GAAG;AACR;","names":[]}
|