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
Copy file name to clipboardExpand all lines: docs/guide/client-context.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ Boot the host once per page: a second boot replaces the published context and lo
50
50
|----------|-------------|
51
51
|`rpc`| The [RPC client](./client) — call server functions, register client-side functions, access shared state. |
52
52
|`clientType`|`'embedded'` (runtime inside your app) or `'standalone'` (independent hub page). |
53
-
|`docks`| Dock entries and selection — `entries`, `selected`, `groupedEntries`, `switchEntry()`, `toggleEntry()`, `getStateById()`. |
53
+
|`docks`| Dock entries and selection — `entries`, `selected`, `groupedEntries`, `switchEntry()`, `toggleEntry()`, `getStateById()`, plus `register()` / `update()` for [client-only docks](#client-only-docks). |
54
54
|`panel`| Dock panel state: position, size, drag/resize flags. |
55
55
|`commands`| The command palette: `register()`, `execute()`, `getKeybindings()`. |
56
56
|`renderers`| Dock-renderer registry — `register()`, `get()`, `has()`, `mount(entry, container)`. Routes a dock `type` to a host-registered renderer (e.g. [JSON-Render](./json-render)); the hub ships none. |
@@ -71,6 +71,25 @@ if (ctx) {
71
71
}
72
72
```
73
73
74
+
### Client-only docks
75
+
76
+
The [node hub context](./hub) registers docks that flow into the `devframe:docks` shared state and reach every connected viewer. A client host can also register a dock that lives only in this page, for a view a host page synthesizes itself:
77
+
78
+
```ts
79
+
const handle =ctx.docks.register({
80
+
id: 'my-local-view',
81
+
title: 'Local',
82
+
icon: 'ph:cube-duotone',
83
+
type: 'custom-render',
84
+
renderer: { importFrom: '/my-view.mjs' },
85
+
})
86
+
87
+
handle.update({ badge: '3' }) // patch it in place (the id is immutable)
88
+
handle.dispose() // remove it
89
+
```
90
+
91
+
Client-only docks merge into the same `docks.entries` list, group, select, and load their client scripts exactly like server docks — they just never sync to the hub or other viewers. A client dock sharing an id with a server dock overrides it locally. `ctx.docks.update(entry)` replaces a previously registered client dock wholesale. Registering an id that a client dock already owns throws unless you pass `register(entry, true)`.
92
+
74
93
## Dock client scripts
75
94
76
95
A dock entry declares its client script as a `ClientScriptEntry` — `{ importFrom, importName? }`, where `importName` defaults to `'default'`. The field depends on the entry kind:
0 commit comments