You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** URL to load in the iframe (for type: 'iframe') */
76
77
url?:string
77
78
/** Action configuration (for type: 'action') */
@@ -86,6 +87,10 @@ interface DockEntry {
86
87
buttonStart?:string
87
88
buttonLoading?:string
88
89
}
90
+
/** Inline JSON spec (for type: 'json-render') */
91
+
spec?:JsonRenderSpec
92
+
/** Shared state key holding the JSON spec (for type: 'json-render') */
93
+
sharedStateKey?:string
89
94
}
90
95
```
91
96
@@ -296,6 +301,163 @@ ctx.docks.register({
296
301
> [!NOTE]
297
302
> Built-in logs panel (`~logs`) is currently reserved and hidden while log UI is under development.
298
303
304
+
## JSON Render Panels
305
+
306
+
JSON render panels let you describe your UI as a JSON spec on the server side. The DevTools client renders it with built-in components powered by [json-render](https://github.com/vercel-labs/json-render). **No client code needed.**
307
+
308
+
This is the simplest way to add a DevTools panel — you only write server-side TypeScript.
This example shows how to build a fully interactive DevTools panel using `@vitejs/devtools-kit`'s **json-render** dock type — with zero client-side code.
4
+
5
+
It registers a `json-render` dock that displays the current git state: branch, staged/unstaged files, recent commits, and a commit form.
6
+
7
+
## How It Works
8
+
9
+
The entire UI is described as a JSON spec on the server side. The DevTools client renders it using built-in components powered by [@json-render/vue](https://github.com/vercel-labs/json-render).
10
+
11
+
1. Node plugin (`src/node/plugin.ts`)
12
+
- collects git state by running `git` commands (`git branch`, `git log`, `git status`)
13
+
- builds a `JsonRenderSpec` describing the UI layout (Stack, Card, DataTable, TextInput, Button, etc.)
14
+
- stores the spec in a shared state key and registers a `json-render` dock entry
15
+
- registers two RPC functions:
16
+
-`git-ui:refresh` — re-reads git state and updates the spec
17
+
-`git-ui:commit` — runs `git commit -m "..."` with the message from the text input
18
+
19
+
2. Client rendering (automatic)
20
+
-`ViewJsonRender.vue` subscribes to the shared state key
21
+
- renders the spec using the built-in devtools component registry
22
+
- bridges button clicks → RPC calls via the json-render action system
23
+
- text input uses `$bindState` for two-way binding; the commit action reads the message via `$state`
24
+
25
+
**Key point**: there is no client-side code in this plugin. No Vue components, no Nuxt app, no iframe. The plugin only writes TypeScript on the server side.
26
+
27
+
## Run The Example
28
+
29
+
From the `examples/plugin-git-ui` directory (`cd examples/plugin-git-ui`):
30
+
31
+
```bash
32
+
pnpm play:dev
33
+
```
34
+
35
+
Then open the app URL, open Vite DevTools, and click the **Git** dock entry.
<p>Open Vite DevTools and click the <strong>Git</strong> dock entry to see the Git UI panel.</p>
5
+
<p style="opacity: 0.6; font-size: 14px;">
6
+
The panel shows your current branch, staged/unstaged files, recent commits, and lets you create commits — all rendered from a JSON spec with zero client-side code.
0 commit comments