@@ -18,11 +18,13 @@ A DevTools plugin extends a Vite plugin with a `devtools.setup(ctx)` hook. The c
1818
1919| Property | Purpose |
2020| ----------| ---------|
21- | ` ctx.docks ` | Register dock entries (iframe, action, custom-render, launcher) |
21+ | ` ctx.docks ` | Register dock entries (iframe, action, custom-render, launcher, json-render ) |
2222| ` ctx.views ` | Host static files for UI |
2323| ` ctx.rpc ` | Register RPC functions, broadcast to clients |
2424| ` ctx.rpc.sharedState ` | Synchronized server-client state |
2525| ` ctx.logs ` | Emit structured log entries and toast notifications |
26+ | ` ctx.terminals ` | Spawn and manage child processes with streaming terminal output |
27+ | ` ctx.createJsonRenderer ` | Create server-side JSON render specs for zero-client-code UIs |
2628| ` ctx.viteConfig ` | Resolved Vite configuration |
2729| ` ctx.viteServer ` | Dev server instance (dev mode only) |
2830| ` ctx.mode ` | ` 'dev' ` or ` 'build' ` |
@@ -122,6 +124,7 @@ export default function myAnalyzer(): Plugin {
122124| Type | Use Case |
123125| ------| ----------|
124126| ` iframe ` | Full UI panels, dashboards (most common) |
127+ | ` json-render ` | Server-side JSON specs — zero client code needed |
125128| ` action ` | Buttons that trigger client-side scripts (inspectors, toggles) |
126129| ` custom-render ` | Direct DOM access in panel (framework mounting) |
127130| ` launcher ` | Actionable setup cards for initialization tasks |
@@ -168,6 +171,44 @@ ctx.docks.register({
168171})
169172```
170173
174+ ### JSON Render Entry
175+
176+ Build UIs entirely from server-side TypeScript — no client code needed:
177+
178+ ``` ts
179+ const ui = ctx .createJsonRenderer ({
180+ root: ' root' ,
181+ elements: {
182+ root: {
183+ type: ' Stack' ,
184+ props: { direction: ' vertical' , gap: 12 },
185+ children: [' heading' , ' info' ],
186+ },
187+ heading: {
188+ type: ' Text' ,
189+ props: { content: ' Hello from JSON!' , variant: ' heading' },
190+ },
191+ info: {
192+ type: ' KeyValueTable' ,
193+ props: {
194+ entries: [
195+ { key: ' Version' , value: ' 1.0.0' },
196+ { key: ' Status' , value: ' Running' },
197+ ],
198+ },
199+ },
200+ },
201+ })
202+
203+ ctx .docks .register ({
204+ id: ' my-panel' ,
205+ title: ' My Panel' ,
206+ icon: ' ph:chart-bar-duotone' ,
207+ type: ' json-render' ,
208+ ui ,
209+ })
210+ ```
211+
171212### Launcher Entry
172213
173214``` ts
@@ -188,6 +229,31 @@ const entry = ctx.docks.register({
188229})
189230```
190231
232+ ## Terminals & Subprocesses
233+
234+ Spawn and manage child processes with streaming terminal output:
235+
236+ ``` ts
237+ const session = await ctx .terminals .startChildProcess (
238+ {
239+ command: ' vite' ,
240+ args: [' build' , ' --watch' ],
241+ cwd: process .cwd (),
242+ },
243+ {
244+ id: ' my-plugin:build-watcher' ,
245+ title: ' Build Watcher' ,
246+ icon: ' ph:terminal-duotone' ,
247+ },
248+ )
249+
250+ // Lifecycle controls
251+ await session .terminate ()
252+ await session .restart ()
253+ ```
254+
255+ A common pattern is combining with launcher docks — see [ Terminals Patterns] ( ./references/terminals-patterns.md ) .
256+
191257## Logs & Notifications
192258
193259Plugins can emit structured log entries from both server and client contexts. Logs appear in the built-in ** Logs** panel and can optionally show as toast notifications.
@@ -426,11 +492,14 @@ Real-world example plugins in the repo — reference their code structure and pa
426492
427493- ** A11y Checker** ([ ` examples/plugin-a11y-checker ` ] ( https://github.com/vitejs/devtools/tree/main/examples/plugin-a11y-checker ) ) — Action dock entry, client-side axe-core audits, logs with severity levels and element positions, log handle updates
428494- ** File Explorer** ([ ` examples/plugin-file-explorer ` ] ( https://github.com/vitejs/devtools/tree/main/examples/plugin-file-explorer ) ) — Iframe dock entry, RPC functions (static/query/action), hosted UI panel, RPC dump for static builds, backend mode detection
495+ - ** Git UI** ([ ` examples/plugin-git-ui ` ] ( https://github.com/vitejs/devtools/tree/main/examples/plugin-git-ui ) ) — JSON render dock entry, server-side JSON specs, ` $bindState ` two-way binding, ` $state ` in action params, dynamic badge updates
429496
430497## Further Reading
431498
432499- [ RPC Patterns] ( ./references/rpc-patterns.md ) - Advanced RPC patterns and type utilities
433500- [ Dock Entry Types] ( ./references/dock-entry-types.md ) - Detailed dock configuration options
434501- [ Shared State Patterns] ( ./references/shared-state-patterns.md ) - Framework integration examples
435502- [ Project Structure] ( ./references/project-structure.md ) - Recommended file organization
503+ - [ JSON Render Patterns] ( ./references/json-render-patterns.md ) - Server-side JSON specs, components, state binding
504+ - [ Terminals Patterns] ( ./references/terminals-patterns.md ) - Child processes, custom streams, session lifecycle
436505- [ Logs Patterns] ( ./references/logs-patterns.md ) - Log entries, toast notifications, and handle patterns
0 commit comments