react-devbelt 0.0.0-stage โ†’ 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +16 -0
  3. package/README.md +292 -2
  4. package/dist/announce-6XECDMRI.js +12 -0
  5. package/dist/announce-6XECDMRI.js.map +1 -0
  6. package/dist/chunk-3SXZJ6OP.js +65 -0
  7. package/dist/chunk-3SXZJ6OP.js.map +1 -0
  8. package/dist/chunk-63DO3YVL.js +330 -0
  9. package/dist/chunk-63DO3YVL.js.map +1 -0
  10. package/dist/chunk-6PAFI4BJ.js +14615 -0
  11. package/dist/chunk-6PAFI4BJ.js.map +1 -0
  12. package/dist/chunk-7JLNVGRQ.js +164 -0
  13. package/dist/chunk-7JLNVGRQ.js.map +1 -0
  14. package/dist/chunk-C7RMX5PF.js +57 -0
  15. package/dist/chunk-C7RMX5PF.js.map +1 -0
  16. package/dist/chunk-GNJF3UHO.js +1030 -0
  17. package/dist/chunk-GNJF3UHO.js.map +1 -0
  18. package/dist/chunk-PRTINXUT.js +105 -0
  19. package/dist/chunk-PRTINXUT.js.map +1 -0
  20. package/dist/chunk-QRXHNBFY.js +22 -0
  21. package/dist/chunk-QRXHNBFY.js.map +1 -0
  22. package/dist/chunk-QT3YSHQA.js +18 -0
  23. package/dist/chunk-QT3YSHQA.js.map +1 -0
  24. package/dist/chunk-UBSHMGMV.js +8016 -0
  25. package/dist/chunk-UBSHMGMV.js.map +1 -0
  26. package/dist/context-D2euxPc4.d.ts +6 -0
  27. package/dist/core.d.ts +266 -0
  28. package/dist/core.js +1070 -0
  29. package/dist/core.js.map +1 -0
  30. package/dist/findable-rows-UQBKFZ45.js +356 -0
  31. package/dist/findable-rows-UQBKFZ45.js.map +1 -0
  32. package/dist/index.d.ts +57 -0
  33. package/dist/index.js +47 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/install.d.ts +2 -0
  36. package/dist/install.js +21 -0
  37. package/dist/install.js.map +1 -0
  38. package/dist/next.d.ts +18 -0
  39. package/dist/next.js +13 -0
  40. package/dist/next.js.map +1 -0
  41. package/dist/plugin-C8VytW9X.d.ts +162 -0
  42. package/dist/plugins.d.ts +118 -0
  43. package/dist/plugins.js +36 -0
  44. package/dist/plugins.js.map +1 -0
  45. package/dist/sheet-presentation-S6GGOKMB.js +2667 -0
  46. package/dist/sheet-presentation-S6GGOKMB.js.map +1 -0
  47. package/dist/styles.css +2 -0
  48. package/dist/toolbar-entry-XIOWCGBL.js +1685 -0
  49. package/dist/toolbar-entry-XIOWCGBL.js.map +1 -0
  50. package/dist/ui.d.ts +37 -0
  51. package/dist/ui.js +126 -0
  52. package/dist/ui.js.map +1 -0
  53. package/licenses/motion-MIT.txt +21 -0
  54. package/licenses/ui-sdk-APACHE-2.0.txt +202 -0
  55. package/package.json +115 -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,293 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # ๐Ÿงฐ react-devbelt
4
+
5
+ **A dev toolbar for React and Next.js. Network, console, viewport, grab. One belt.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/react-devbelt?style=flat-square&logo=npm&color=cb3837)](https://www.npmjs.com/package/react-devbelt)
8
+ [![downloads](https://img.shields.io/npm/dm/react-devbelt?style=flat-square&color=blue)](https://www.npmjs.com/package/react-devbelt)
9
+ [![React](https://img.shields.io/badge/React-19+-61dafb?style=flat-square&logo=react&logoColor=white)](https://react.dev)
10
+ [![Next.js](https://img.shields.io/badge/Next.js-ready-000000?style=flat-square&logo=nextdotjs&logoColor=white)](https://nextjs.org)
11
+ [![TypeScript](https://img.shields.io/badge/TypeScript-typed-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
12
+ [![dev only](https://img.shields.io/badge/production-0%20bytes-brightgreen?style=flat-square)](#-security)
13
+ [![license](https://img.shields.io/badge/license-MIT-lightgrey?style=flat-square)](#license)
14
+ [![status](https://img.shields.io/badge/status-0.x-orange?style=flat-square)](#)
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
+ ```bash
39
+ npm install -D react-devbelt
40
+ ```
41
+
42
+ Needs React 19+. Built on [ui-sdk](https://ui-sdk.dev) and bundles it. Nothing else to install.
43
+
44
+ ### ๐Ÿค– Let an agent do it
45
+
46
+ 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.
47
+
48
+ ```text
49
+ Install react-devbelt, a dev-only toolbar, in this project. Docs: https://github.com/ArtifactyNight/react-devbelt#readme
50
+
51
+ 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.
52
+ 2. Add `react-devbelt` as a dev dependency with the package manager this repo already uses (check the lockfile).
53
+ 3. Set it up for the framework:
54
+ - 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}.
55
+ - 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.
56
+ - 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 />.
57
+ 4. 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.
58
+ 5. 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.
59
+ ```
60
+
61
+ Want the opt-in tools (`storage()`, `breakpoint()`, `capture()`) later? Ask the agent to follow [Choosing and configuring plugins](#-choosing-and-configuring-plugins).
62
+
63
+ ## โ–ฒ Next.js (16.3+)
64
+
65
+ ```ts
66
+ // next.config.ts: captures requests and errors before hydration
67
+ import { withDevBelt } from "react-devbelt/next";
68
+ export default withDevBelt({
69
+ /* your config */
70
+ });
71
+ ```
72
+
73
+ ```tsx
74
+ // app/layout.tsx
75
+ import { DevBelt } from "react-devbelt";
76
+
77
+ export default function RootLayout({
78
+ children,
79
+ }: {
80
+ children: React.ReactNode;
81
+ }) {
82
+ return (
83
+ <html lang="en">
84
+ <body>
85
+ {children}
86
+ <DevBelt />
87
+ </body>
88
+ </html>
89
+ );
90
+ }
91
+ ```
92
+
93
+ 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.
94
+
95
+ ## โš›๏ธ React (Vite, CRA, anything)
96
+
97
+ ```tsx
98
+ // src/main.tsx
99
+ import "react-devbelt/install"; // first, so early requests and errors are caught
100
+ import { createRoot } from "react-dom/client";
101
+ import { DevBelt } from "react-devbelt";
102
+
103
+ createRoot(document.getElementById("root")!).render(
104
+ <>
105
+ <App />
106
+ <DevBelt />
107
+ </>,
108
+ );
109
+ ```
110
+
111
+ `<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`).
112
+
113
+ ## ๐ŸŽ›๏ธ Choosing and configuring plugins
114
+
115
+ 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:
116
+
117
+ ```tsx
118
+ // devbelt.tsx
119
+ "use client";
120
+ import { DevBelt, installDevBelt } from "react-devbelt";
121
+ import {
122
+ network,
123
+ consolePlugin,
124
+ viewport,
125
+ grab,
126
+ bundle,
127
+ display,
128
+ } from "react-devbelt/plugins";
129
+
130
+ export const plugins =
131
+ process.env.NODE_ENV === "production"
132
+ ? []
133
+ : [
134
+ viewport(),
135
+ grab(),
136
+ network({
137
+ // header values are masked in the log; say what a replay should send
138
+ replayHeaders: (name) =>
139
+ name.toLowerCase() === "authorization"
140
+ ? `Bearer ${getToken()}`
141
+ : null,
142
+ }),
143
+ consolePlugin(),
144
+ bundle(),
145
+ display({
146
+ darkClass: "dark",
147
+ locale: { cookie: "locale", options: ["en", "th"] },
148
+ }),
149
+ ];
150
+
151
+ installDevBelt(plugins); // optional: start capturing before the app renders
152
+
153
+ export const Toolbar = () => <DevBelt plugins={plugins} />;
154
+ ```
155
+
156
+ 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.
157
+
158
+ ### ๐Ÿ’ก Toolbar tips
159
+
160
+ - Right-click (or long-press) a pinned tool for its own options (the same section as in More tools) and **Unpin from toolbar**.
161
+ - `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.
162
+ - 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).
163
+
164
+ ### ๐Ÿงฉ Opt-in plugins
165
+
166
+ Not in `defaultPlugins()`. Add them by name: `[...defaultPlugins(), storage(), breakpoint(), capture()]`.
167
+
168
+ | Plugin | From | What it does |
169
+ | --- | --- | --- |
170
+ | ๐Ÿ“ `breakpoint()` | `react-devbelt/plugins` | Current breakpoint and width, outline-all-elements toggle |
171
+ | ๐Ÿ—„๏ธ `storage()` | `react-devbelt/plugins` | localStorage, sessionStorage and cookies, with Redaction |
172
+ | ๐Ÿ“ธ `capture()` | `react-devbelt/plugins` | Screenshot (page, region or full page; copied or saved as PNG) and screen recording (saved as a video) |
173
+ | โšก `tanstackQuery(client)` | `devbelt-plugin-tanstack-query` | TanStack Query v5 queries and mutations |
174
+
175
+ 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).
176
+
177
+ ### โš™๏ธ Built-in plugin options
178
+
179
+ | Plugin | Option | Meaning |
180
+ | -------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
181
+ | `network()` | `redactHeaders` | Header names to mask. Default: `authorization`, `proxy-authorization`, `cookie`, `set-cookie`, `x-api-key` |
182
+ | | `replayHeaders(name, maskedValue)` | What a replayed request sends for a header. Return `null` to leave it out (the default for redacted headers) |
183
+ | | `fetch` | Also record `fetch`. Default `true` |
184
+ | `storage()` (opt-in) | `stores` | Which stores the Window, Agent tools and Debug bundle include. Any of `localStorage`, `sessionStorage`, `cookies`. Default: all three |
185
+ | | `redact` | Keys whose values are Redacted. Default `/token\|secret\|password\|auth\|session\|jwt\|key/i` |
186
+ | | `includeValuesInBundle` | Put values in the Debug bundle too (Redacted ones stay hidden). Default `false`: key names and sizes only |
187
+ | `display()` | `darkClass` | Class toggled on `<html>` for dark mode. Default `"dark"`; `false` hides the switch |
188
+ | | `locale` | `{ cookie, options, default? }` adds a language switch that sets a cookie and reloads |
189
+ | `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` |
190
+ | | `base` | Name of the range below the smallest breakpoint. Default `"base"` |
191
+ | | `outline` | Start with the outline on. Default `false`. A saved choice wins after the first toggle |
192
+
193
+ ### ๐Ÿ“ Breakpoint indicator (opt-in)
194
+
195
+ 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`.
196
+
197
+ ```tsx
198
+ import { breakpoint } from "react-devbelt/plugins";
199
+
200
+ breakpoint(); // Tailwind v4 breakpoints
201
+ breakpoint({ breakpoints: { tablet: "48rem", desktop: 1200 }, base: "xs", outline: true });
202
+ ```
203
+
204
+ ### ๐Ÿ“ธ Screenshot and recording (opt-in)
205
+
206
+ `capture()` adds a camera, a region picker and a record button.
207
+
208
+ - **Camera**: copies a PNG of the page, toolbar left out (the Frame's page while one is up).
209
+ - **Crop**: drag over the page to copy just that region. `Esc` cancels. Over a Frame, the part outside it is left out.
210
+ - **More tools**: save a screenshot, or a full-page one.
211
+ - **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.
212
+
213
+ 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.
214
+
215
+ 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`/`โŒ˜` + `.`.
216
+
217
+ Paste a copied screenshot straight into an AI chat.
218
+
219
+ ```tsx
220
+ import { capture } from "react-devbelt/plugins";
221
+
222
+ capture(); // screenshots at the screen's pixel ratio
223
+ capture({ scale: 1 }); // smaller files
224
+ capture({ hideWhileRecording: false }); // keep the toolbar in the video
225
+ ```
226
+
227
+ ### ๐Ÿ—„๏ธ Storage (opt-in)
228
+
229
+ Add it by name: `[...defaultPlugins(), storage()]`.
230
+
231
+ 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.
232
+
233
+ - **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.
234
+ - **HttpOnly cookies** can't be seen, and it says so.
235
+ - **Redaction**: values whose key matches `redact` show only name and length, in the Window, in `devbelt_get_storage` and in the Debug bundle.
236
+ - **Debug bundle**: key names and sizes. Values only with `includeValuesInBundle`, and Redacted ones never.
237
+
238
+ ## ๐Ÿงฑ `<DevBelt>` props
239
+
240
+ | Prop | Default | |
241
+ | ----------- | ---------- | --------------------------------------------------------------------------- |
242
+ | `plugins` | built-ins | The tools to show |
243
+ | `isolation` | `"shadow"` | `"none"` renders in a plain div; import `react-devbelt/styles.css` yourself |
244
+ | `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 |
245
+ | `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) |
246
+ | `enabled` | `true` | Switch the toolbar off in development without removing it |
247
+
248
+ ## ๐Ÿค AI tools
249
+
250
+ **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.
251
+
252
+ | Tool | Link | Notes |
253
+ | --- | --- | --- |
254
+ | Cursor | `cursor://anysphere.cursor-deeplink/prompt?text=โ€ฆ` | Opens in the focused Cursor window |
255
+ | Claude Code | `claude-cli://open?q=โ€ฆ` | Works once Claude Code has run an interactive session on the machine, which registers the link handler |
256
+ | Codex | `codex://new?prompt=โ€ฆ` | The Codex app |
257
+
258
+ 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:
259
+
260
+ ```tsx
261
+ import { defaultAiTools } from "react-devbelt/core";
262
+
263
+ const aiTools = [
264
+ ...defaultAiTools,
265
+ {
266
+ id: "my-editor",
267
+ label: "My editor",
268
+ link: (prompt: string) => `my-editor://chat?prompt=${encodeURIComponent(prompt)}`,
269
+ maxPrompt: 4000, // optional, default 5000
270
+ },
271
+ ];
272
+
273
+ <DevBelt aiTools={aiTools} />;
274
+ ```
275
+
276
+ A plugin can use the same list: `openInAiTool(tool, text)` from `react-devbelt/core`, with the tools from `useToolbar().aiTools`.
277
+
278
+ ## ๐Ÿ”’ Security
279
+
280
+ The toolbar reads request and response **bodies** and console output. Header credentials are masked. Bodies are not.
281
+
282
+ - ๐Ÿšซ Built for development. Production builds drop it. Don't expose it on shared or demo environments.
283
+ - ๐Ÿ‘€ Tools offered to browser agents are read-only, apart from changing the viewport. Everything they return is marked as untrusted content.
284
+ - โœ๏ธ Tools that change state (editing storage, refetching or invalidating queries) don't exist until you set `agent: { write: true }` on that Plugin.
285
+ - ๐Ÿ™ˆ 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.
286
+
287
+ ## ๐Ÿ› ๏ธ Writing a plugin
288
+
289
+ See [docs/plugins.md](https://github.com/ArtifactyNight/react-devbelt/blob/main/docs/plugins.md).
290
+
291
+ ## License
292
+
293
+ MIT. Bundles ui-sdk (Apache-2.0); see `NOTICE`.
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import {
3
+ announce,
4
+ prepareAnnouncements,
5
+ setAnnouncer
6
+ } from "./chunk-3SXZJ6OP.js";
7
+ export {
8
+ announce,
9
+ prepareAnnouncements,
10
+ setAnnouncer
11
+ };
12
+ //# sourceMappingURL=announce-6XECDMRI.js.map
@@ -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":[]}