Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/kit/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ for (const cmd of commands) {
}
```

Subscribe to lifecycle events to react to registrations:
Subscribe to lifecycle events in the Node process to react to registrations:

```ts
ctx.commands.events.on('command:registered', (cmd) => {
ctx.commands.events.on('commands:registered', (cmd) => {
console.log('new command:', cmd.id)
})
ctx.commands.events.on('command:unregistered', (id) => {
ctx.commands.events.on('commands:unregistered', (id) => {
console.log('removed:', id)
})
```
Expand Down
8 changes: 4 additions & 4 deletions docs/kit/dock-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ interface DockEntry {
/** Author-set single line of progress/status, shown inline on the card */
digest?: string
}
/** JsonRenderer handle created by ctx.createJsonRenderer() (for type: 'json-render') */
ui?: JsonRenderer
/** Serializable view reference from ctx.createJsonRenderer() (for type: 'json-render') */
view?: JsonRenderViewRef
}
```

Expand Down Expand Up @@ -425,7 +425,7 @@ The launcher tracks the spawned process for the life of the embed. When that pro

JSON render panels describe a UI as a JSON spec on the server — the client renders it from a built-in component library. This is the shortest path to a DevTools panel: server-side TypeScript only.

Create a renderer handle with `ctx.createJsonRenderer()` and pass it as `ui` when registering a `json-render` dock entry:
Create a renderer handle with `ctx.createJsonRenderer()` and pass its `view` reference when registering a `json-render` dock entry:

```ts
const ui = ctx.createJsonRenderer({
Expand Down Expand Up @@ -457,7 +457,7 @@ ctx.docks.register({
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})
```

Expand Down
8 changes: 4 additions & 4 deletions docs/kit/json-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Vite DevTools provides `ctx.createJsonRenderer()`; the `JsonRenderSpec` / `JsonR

## Getting started

Create a renderer handle with `ctx.createJsonRenderer()` and pass it as `ui` when registering a `json-render` dock entry:
Create a renderer handle with `ctx.createJsonRenderer()` and pass its `view` reference when registering a `json-render` dock entry:

```ts
import type { PluginWithDevTools } from '@vitejs/devtools-kit'
Expand Down Expand Up @@ -49,7 +49,7 @@ export function MyPlugin(): PluginWithDevTools {
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})
},
},
Expand Down Expand Up @@ -109,7 +109,7 @@ ctx.docks.update({
type: 'json-render',
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
ui,
view: ui.view,
badge: hasWarnings ? '!' : undefined,
})
```
Expand Down Expand Up @@ -701,7 +701,7 @@ export function BuildReportPlugin(): PluginWithDevTools {
title: 'Build Report',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})

ctx.rpc.register(defineRpcFunction({
Expand Down
12 changes: 6 additions & 6 deletions docs/kit/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,19 @@ The [A11y Checker example](/kit/examples#a11y-checker) is a plugin that uses mes

## Events

The host emits events for observers of the message stream:
The host emits these events within the Node process:

```ts
ctx.messages.events.on('message:added', (entry) => { /* ... */ })
ctx.messages.events.on('message:updated', (entry) => { /* ... */ })
ctx.messages.events.on('message:removed', (id) => { /* ... */ })
ctx.messages.events.on('message:cleared', () => { /* ... */ })
ctx.messages.events.on('messages:added', (entry) => { /* ... */ })
ctx.messages.events.on('messages:updated', (entry) => { /* ... */ })
ctx.messages.events.on('messages:removed', (id) => { /* ... */ })
ctx.messages.events.on('messages:cleared', () => { /* ... */ })
```

Use the events to bridge messages into external tools — mirror them into a structured log, forward certain categories to your own reporter, etc.:

```ts
ctx.messages.events.on('message:added', (entry) => {
ctx.messages.events.on('messages:added', (entry) => {
if (entry.category === 'a11y')
console.log('a11y finding:', entry.message)
})
Expand Down
10 changes: 5 additions & 5 deletions docs/kit/remote-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ interface RemoteDockOptions {

#### `transport`

- **`'fragment'` (default)** — the descriptor rides as a URL fragment (`#vite-devtools-kit-connection=...`). Fragments stay client-side: they don't reach servers, don't enter access logs, and get stripped from `Referer` on sub-resource requests. The safest place to carry an auth token.
- **`'query'`** — the descriptor rides as a query parameter (`?vite-devtools-kit-connection=...`). Pick this when your SPA router uses the fragment for navigation, or when your hosting platform / CDN rewrites URLs in a way that drops fragments.
- **`'fragment'` (default)** — the descriptor rides as a URL fragment (`#devframe-remote-connection=...`). Fragments stay client-side: they don't reach servers, don't enter access logs, and get stripped from `Referer` on sub-resource requests. The safest place to carry an auth token.
- **`'query'`** — the descriptor rides as a query parameter (`?devframe-remote-connection=...`). Pick this when your SPA router uses the fragment for navigation, or when your hosting platform / CDN rewrites URLs in a way that drops fragments.

> [!WARNING]
> With `'query'` transport, the auth token appears in server access logs and outbound `Referer` headers. Use it only when you control the analytics / log pipeline on the hosted origin.
Expand Down Expand Up @@ -156,8 +156,8 @@ const rpc = await connectRemoteDevTools({
For testing or non-browser environments, pass an explicit URL or raw fragment/query string to `parseRemoteConnection`:

```ts
parseRemoteConnection('https://example.com/p#vite-devtools-kit-connection=...')
parseRemoteConnection('?vite-devtools-kit-connection=...')
parseRemoteConnection('https://example.com/p#devframe-remote-connection=...')
parseRemoteConnection('?devframe-remote-connection=...')
```

## Descriptor shape
Expand All @@ -176,7 +176,7 @@ interface RemoteConnectionInfo {
}
```

It's JSON-encoded and base64url-encoded, then appended to the iframe URL under the parameter name `vite-devtools-kit-connection`.
It's JSON-encoded and base64url-encoded, then appended to the iframe URL under the parameter name `devframe-remote-connection`.

## Trust boundary

Expand Down
2 changes: 1 addition & 1 deletion docs/kit/remote-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ ctx.docks.register({
## How it works

1. Your plugin registers an iframe dock with `remote: true` pointing at this page.
2. The DevTools core allocates a session-only auth token and appends the connection descriptor to the iframe URL: `#vite-devtools-kit-connection=…`
2. The DevTools core allocates a session-only auth token and appends the connection descriptor to the iframe URL: `#devframe-remote-connection=…`
3. When this page loads, [`parseRemoteConnection()`](./remote-client#connect-from-the-hosted-page) reads the descriptor, and [`connectRemoteDevTools()`](./remote-client#connect-from-the-hosted-page) opens a WebSocket back to the local dev server.
4. The live "dock registry" list above subscribes to the `devframe:docks` shared state — it re-renders on every registration change.

Expand Down
4 changes: 2 additions & 2 deletions docs/kit/terminals.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ ctx.terminals.update({

## Events

Subscribe to lifecycle changes (register, update, remove) via the host event emitter:
Subscribe to lifecycle changes (register, update, remove) through the host event emitter in the Node process:

```ts
ctx.terminals.events.on('terminal:session:updated', (session) => {
ctx.terminals.events.on('terminals:session:updated', (session) => {
console.log(session.id, session.status)
})
```
Expand Down
9 changes: 4 additions & 5 deletions packages/core/src/node/json-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export type { JsonRenderView, JsonRenderViewRef }
* The handle returned by `ctx.createJsonRenderer()`. It wraps a devframe
* {@link JsonRenderView} and exposes the kit's method names.
*
* Register a `json-render` dock entry with the handle as `ui`
* (`docks.register({ type: 'json-render', ui, … })`); the client subscribes
* Register a `json-render` dock entry with the handle's `view` reference
* (`docks.register({ type: 'json-render', view: ui.view, … })`); the client subscribes
* through its `stateKey`. Drive the panel by calling `updateSpec` /
* `updateState` on the handle.
*/
Expand Down Expand Up @@ -70,9 +70,8 @@ export function attachJsonRenderer(context: KitNodeContext): void {
const createJsonRenderer: CreateJsonRenderer = (spec, options = {}) => {
const view = createJsonRenderView(context, { id: `kit-${nanoid()}`, spec, ...options })

// Methods are non-enumerable so the handle stays serializable when carried
// on a dock entry's `ui` field — the docks shared-state projection walks
// only enumerable own keys, so the closures never reach the wire.
// Keep methods non-enumerable on the handle. Dock entries carry handle.view,
// the serializable reference that clients use to subscribe to the spec.
const handle = {
_stateKey: view.ref.stateKey,
view: view.ref,
Expand Down
2 changes: 1 addition & 1 deletion skills/vite-devtools-kit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ ctx.docks.register({
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})
```

Expand Down
4 changes: 2 additions & 2 deletions skills/vite-devtools-kit/references/dock-entry-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Server-side JSON specs rendered by the built-in component library. No client cod
```ts
interface JsonRenderEntry extends DockEntryBase {
type: 'json-render'
ui: JsonRenderer // Handle from ctx.createJsonRenderer()
view: JsonRenderViewRef // Reference from ctx.createJsonRenderer().view
}

// Registration
Expand Down Expand Up @@ -265,7 +265,7 @@ ctx.docks.register({
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})
```

Expand Down
6 changes: 3 additions & 3 deletions skills/vite-devtools-kit/references/json-render-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ctx.docks.register({
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})
```

Expand All @@ -70,7 +70,7 @@ ctx.docks.update({
type: 'json-render',
title: 'My Panel',
icon: 'ph:chart-bar-duotone',
ui,
view: ui.view,
badge: hasWarnings ? '!' : undefined,
})
```
Expand Down Expand Up @@ -263,7 +263,7 @@ export function BuildReportPlugin(): PluginWithDevTools {
title: 'Build Report',
icon: 'ph:chart-bar-duotone',
type: 'json-render',
ui,
view: ui.view,
})

ctx.rpc.register(defineRpcFunction({
Expand Down
10 changes: 5 additions & 5 deletions skills/vite-devtools-kit/references/remote-client-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ remote: { transport: 'query', originLock: false }

| Value | Descriptor location | Visibility |
|-------|--------------------|------------|
| `'fragment'` (default) | `#vite-devtools-kit-connection=...` | Not sent to servers, not in access logs, stripped from Referer |
| `'query'` | `?vite-devtools-kit-connection=...` | Appears in server logs and outbound Referer |
| `'fragment'` (default) | `#devframe-remote-connection=...` | Not sent to servers, not in access logs, stripped from Referer |
| `'query'` | `?devframe-remote-connection=...` | Appears in server logs and outbound Referer |

Prefer `'fragment'`. Opt into `'query'` only when:
- Your SPA router uses the fragment for navigation.
Expand Down Expand Up @@ -113,8 +113,8 @@ const rpc = await connectRemoteDevTools({
For tests or non-browser environments, pass an explicit URL or raw fragment/query string to `parseRemoteConnection`:

```ts
parseRemoteConnection('https://example.com/p#vite-devtools-kit-connection=...')
parseRemoteConnection('?vite-devtools-kit-connection=...')
parseRemoteConnection('https://example.com/p#devframe-remote-connection=...')
parseRemoteConnection('?devframe-remote-connection=...')
```

## Descriptor shape
Expand All @@ -131,7 +131,7 @@ interface RemoteConnectionInfo {
}
```

JSON-encoded then base64url-encoded, appended to the iframe URL under the key `vite-devtools-kit-connection`.
JSON-encoded then base64url-encoded, appended to the iframe URL under the key `devframe-remote-connection`.

## Trust model

Expand Down
Loading