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
docs(examples): make the client-only json-render dock interactive
Turns the inline client-authored view into a small interactive playground:
`$bindState` text/switch inputs write into the view's own state, `$state`
reads mirror them live, and Add / Clear buttons drive the built-in
`pushState` / `setState` actions to mutate a notes list that re-renders — all
client-side, with no server and no shared state. Applied to both the Vite
(Vue) and Next (React) hub shells.
- The built-in `hub:commands:execute` RPC dispatches any registered server command, regardless of how the host was constructed.
17
17
- The browser-side `connectDevframe({ baseURL: '/__hub/' })` discovers the WS endpoint via the Next route handler at `/__hub/__connection.json`, which starts the singleton host on demand.
18
18
- The [JSON-render](/guide/json-render) hub integration with **registry replacement**: the host authors a view and projects it onto a `json-render` dock, and the React client renders it with a small in-example React registry (rather than the Vue `@devframes/json-render-ui`) — the path a non-Vue host uses.
19
-
-[Client-only docks](/guide/client-context#client-only-docks) the page registers itself with `context.docks.register()`: an iframe dock rendered from a Blob URL, and a `json-render` dock whose spec is authored in the browser and carried inline in the dock entry (`view: { spec }`) — rendered by the same React registry as the server-authored view, with no shared state, yet never syncing to the hub or other viewers.
19
+
-[Client-only docks](/guide/client-context#client-only-docks) the page registers itself with `context.docks.register()`: an iframe dock rendered from a Blob URL, and an interactive `json-render` dock whose spec is authored in the browser and carried inline in the dock entry (`view: { spec }`) — its inputs, toggles, and `pushState`/`setState` buttons drive the view's own state (no shared state, nothing synced to the hub), rendered by the same React registry as the server-authored view.
- The built-in `hub:commands:execute` RPC dispatches any registered server command, regardless of how the host was constructed.
17
17
- The browser-side `connectDevframe({ baseURL: '/__hub/' })` discovers the WS endpoint via the kit's `__connection.json` middleware.
18
18
- The opt-in [JSON-render](/guide/json-render) hub integration end to end: the host authors a view on its hub context and projects it onto a `json-render` dock, and the client host renders it via `@devframes/json-render-ui` (registered through `createDevframeClientHost({ renderers })`).
19
-
-[Client-only docks](/guide/client-context#client-only-docks) the page registers itself with `context.docks.register()`: an iframe dock rendered from a Blob URL, and a `json-render` dock whose spec is authored in the browser and carried inline in the dock entry (`view: { spec }`) — rendered by the same renderer as the server-authored view, with no shared state, yet never syncing to the hub or other viewers.
19
+
-[Client-only docks](/guide/client-context#client-only-docks) the page registers itself with `context.docks.register()`: an iframe dock rendered from a Blob URL, and an interactive `json-render` dock whose spec is authored in the browser and carried inline in the dock entry (`view: { spec }`) — its inputs, toggles, and `pushState`/`setState` buttons drive the view's own state (no shared state, nothing synced to the hub), rendered by the same renderer as the server-authored view.
Copy file name to clipboardExpand all lines: docs/guide/client-context.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,15 +96,15 @@ A client-only dock can render a [JSON-render](./json-render) view the page autho
96
96
const spec = { /* a DevframeJsonRenderSpec built in the browser */ }
97
97
98
98
ctx.docks.register({
99
-
id: 'client-metrics',
100
-
title: 'Client Metrics',
101
-
icon: 'ph:gauge-duotone',
99
+
id: 'client-playground',
100
+
title: 'Client Playground',
101
+
icon: 'ph:sliders-horizontal-duotone',
102
102
type: 'json-render',
103
103
view: { spec },
104
104
})
105
105
```
106
106
107
-
The `view` field accepts either `{ spec }` (rendered inline, static) or `{ stateKey }` (subscribed to a live shared state, the shape `createJsonRenderView` produces server-side).
107
+
The `view` field accepts either `{ spec }` (the spec rendered inline) or `{ stateKey }` (subscribed to a live shared state, the shape `createJsonRenderView` produces server-side). An inline view still runs its own state: `{ $bindState }` inputs and `{ $state }` reads work against the spec's `state`, and the built-in `setState` / `pushState` / `removeState` actions mutate it — so a client-authored view is interactive with no server and no shared state. What `{ spec }` lacks versus `{ stateKey }` is a server-driven update stream.
about: {type: 'Card',props: {title: 'About this dock'},children: ['aboutText']},
75
-
aboutText: {
76
-
type: 'Text',
77
-
props: {
78
-
text: 'This json-render view was authored in the browser and seeded into a client-local shared state — it never reaches the hub server or other viewers, yet renders through the same dock renderer as a server-authored view.',
79
-
variant: 'body',
80
-
color: 'muted',
81
-
},
77
+
78
+
// ── Two-way binding: type a name, see it echoed live; toggle a switch ──
about: {type: 'Card',props: {title: 'About this dock'},children: ['aboutText']},
99
-
aboutText: {
100
-
type: 'Text',
101
-
props: {
102
-
text: 'This json-render view was authored in the browser and seeded into a client-local shared state — it never reaches the hub server or other viewers, yet renders through the same dock renderer as a server-authored view.',
103
-
variant: 'body',
104
-
color: 'muted',
105
-
},
101
+
102
+
// ── Two-way binding: type a name, see it echoed live; toggle a switch ──
0 commit comments