Skip to content

Commit 493307b

Browse files
committed
refactor(examples)!: rename hub examples to the hub-* prefix and add the hub-*-minimal family
The two reference hosts become hub-vite and hub-next; the middleware demos become hub-nitro-minimal and hub-hono-minimal, joined by new hub-vite-minimal, hub-next-minimal, and hub-rsbuild-minimal — each a single initHub({ ui: createUi() }) handler mounted on its framework (the whole minimal integration is the config/route file). The Nitro one now uses a catch-all server route (+ index route) per @atinux's review; the Rsbuild one lazy-inits the hub inside server.setup so importing the config is side-effect free. Also: .gitignore now covers .next/.nitro/.output so knip (which respects gitignore) doesn't scan Next/Nitro build output; playwright/vitest/turbo/ knip/verify-typecheck-coverage/scripts/AGENTS/docs and the sidebar are repointed at the new names, and docs gain a page per minimal example. BREAKING CHANGE: example package names changed (vite-devframe-hub -> hub-vite, next-devframe-hub -> hub-next, nitro/hono-devframe-hub -> hub-nitro-minimal/hub-hono-minimal).
1 parent d54199c commit 493307b

120 files changed

Lines changed: 1154 additions & 302 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*.tsbuildinfo
88
coverage
99
dist
10+
.next
11+
.nitro
12+
.output
1013
lib-cov
1114
logs
1215
node_modules

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
**`devframe`** is the framework-neutral container for one devtool integration, portable across viewers. Build a single tool (its RPC, its SPA, its diagnostics, its CLI/build/spa/embedded outputs) without caring how it'll be displayed. A devframe app runs standalone (CLI, static deploy, embedded SPA) just as well as it mounts inside a hub.
66

7-
**`@devframes/hub`** is the framework-neutral hub layer that sits on top of devframe and provides the multi-integration orchestration (docks, terminals, messages, commands). It does not ship UI — implementers (e.g. `@vitejs/devtools-kit`) provide their own UI on top of the hub's RPC + shared-state protocol. It does ship a **headless client runtime** (`createDevframeClientHost()` from `@devframes/hub/client`): booted in the host page, it assembles the shared `DevframeClientContext` (panel, docks, commands, when) and imports each dock entry's client script (`action` / `custom-render` / iframe `clientScript`) into that page — how a plugin like the a11y inspector runs code inside the page being inspected. See `examples/vite-devframe-hub/` for a working ~120-line Vite host demonstrating the protocol end to end.
7+
**`@devframes/hub`** is the framework-neutral hub layer that sits on top of devframe and provides the multi-integration orchestration (docks, terminals, messages, commands). It does not ship UI — implementers (e.g. `@vitejs/devtools-kit`) provide their own UI on top of the hub's RPC + shared-state protocol. It does ship a **headless client runtime** (`createDevframeClientHost()` from `@devframes/hub/client`): booted in the host page, it assembles the shared `DevframeClientContext` (panel, docks, commands, when) and imports each dock entry's client script (`action` / `custom-render` / iframe `clientScript`) into that page — how a plugin like the a11y inspector runs code inside the page being inspected. See `examples/hub-vite/` for a working ~120-line Vite host demonstrating the protocol end to end.
88

99
## Stack & Structure
1010

@@ -70,7 +70,7 @@ These reinforce devframe's positioning as "the container for one devtool integra
7070

7171
### Hub example parity
7272

73-
`examples/vite-devframe-hub/` (Vite plugin + vanilla client) and `examples/next-devframe-hub/` (Next.js App Router + React client) are the two reference hosts, and they stay at **feature parity**. They mount the same set of plugins and demo devframes, expose the same dock rail / iframe stage / subsystem drawer, and speak the same hub protocol — the only differences should be the host framework's own plumbing (how static assets are mounted, how the side-car server starts, how the client is rendered).
73+
`examples/hub-vite/` (Vite plugin + vanilla client) and `examples/hub-next/` (Next.js App Router + React client) are the two reference hosts, and they stay at **feature parity**. They mount the same set of plugins and demo devframes, expose the same dock rail / iframe stage / subsystem drawer, and speak the same hub protocol — the only differences should be the host framework's own plumbing (how static assets are mounted, how the side-car server starts, how the client is rendered).
7474

7575
Any change to one lands in the other in the same PR: adding a dock, wiring a new hub subsystem, changing the drawer layout, adopting a new client-runtime API. Their READMEs mirror each other too. If a capability genuinely can't exist on one host, say so explicitly in both READMEs rather than letting the examples silently drift.
7676

‎docs/.vitepress/config.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,13 @@ function examplesItems(prefix: string) {
8686
{ text: 'json-render', link: `${prefix}/examples/json-render` },
8787
{ text: 'streaming-chat', link: `${prefix}/examples/streaming-chat` },
8888
{ text: 'next-runtime-snapshot', link: `${prefix}/examples/next-runtime-snapshot` },
89-
{ text: 'vite-devframe-hub', link: `${prefix}/examples/vite-devframe-hub` },
90-
{ text: 'next-devframe-hub', link: `${prefix}/examples/next-devframe-hub` },
89+
{ text: 'hub-vite', link: `${prefix}/examples/hub-vite` },
90+
{ text: 'hub-next', link: `${prefix}/examples/hub-next` },
91+
{ text: 'hub-vite-minimal', link: `${prefix}/examples/hub-vite-minimal` },
92+
{ text: 'hub-next-minimal', link: `${prefix}/examples/hub-next-minimal` },
93+
{ text: 'hub-nitro-minimal', link: `${prefix}/examples/hub-nitro-minimal` },
94+
{ text: 'hub-hono-minimal', link: `${prefix}/examples/hub-hono-minimal` },
95+
{ text: 'hub-rsbuild-minimal', link: `${prefix}/examples/hub-rsbuild-minimal` },
9196
] satisfies DefaultTheme.NavItemWithLink[]
9297
}
9398

‎docs/errors/DF8004.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ outline: deep
1818
import { initHub } from '@devframes/hub/initiate'
1919

2020
initHub({
21+
base: '/__devframes/',
2122
devframes: [defineDevframe({ id: 'devframes:plugin:my-tool', /* … */ })], // ✗ throws DF8004
2223
})
2324

‎docs/examples/hub-hono-minimal.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-hono-minimal
6+
7+
The minimal [Hono](https://hono.dev) host for [`@devframes/hub`](/guide/hub): one `initHub()` call behind a catch-all route, running on **Node and Bun** from the same app file, the UI supplied by `@devframes/hub-ui`.
8+
9+
Package: `hub-hono-minimal` · framework: **Hono**
10+
11+
## What it shows
12+
13+
- `initHub({ base, devframes: [inspect, messages], ui: createUi() })` in `src/app.ts` plus `app.all(\`${hub.base}*\`, c => hub.handler(c.req.raw, c.env))`.
14+
- On Node (`@hono/node-server`), the RPC WebSocket runs on an eager side-car port.
15+
- On Bun (`Bun.serve({ fetch, websocket: hub.websocket })`), WebSocket upgrades complete through `hub.handler(request, server)` on the app's own origin — no side-car. The repo's `scripts/smoke-bun.ts` exercises this path end to end.
16+
17+
## Run it
18+
19+
```sh
20+
pnpm install
21+
pnpm --filter hub-hono-minimal dev # Node
22+
pnpm --filter hub-hono-minimal dev:bun # Bun
23+
```
24+
25+
## Source
26+
27+
[`examples/hub-hono-minimal`](https://github.com/devframes/devframe/tree/main/examples/hub-hono-minimal)

‎docs/examples/hub-next-minimal.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-next-minimal
6+
7+
The minimal [Next.js](https://nextjs.org) host for [`@devframes/hub`](/guide/hub): one `initHub()` call on an App Router catch-all route, the UI supplied by `@devframes/hub-ui`.
8+
9+
Package: `hub-next-minimal` · framework: **React (Next.js)**
10+
11+
## What it shows
12+
13+
- `initHub({ base, devframes: [inspect, messages], ui: createUi() })` behind one route (`app/%5F_devframes/[[...path]]/route.ts`) delegating to `hub.handler(request)`.
14+
- The plugins and `@devframes/hub-ui` load via a bundler-ignored dynamic `import()`, so Next resolves their published `dist` at runtime (their `import.meta.url` asset lookups don't survive static bundling).
15+
- Next route handlers can't accept WebSocket upgrades, so the instance runs its eager side-car WS server, advertised through `<base>__connection.json`.
16+
17+
## Run it
18+
19+
```sh
20+
pnpm install
21+
pnpm --filter hub-next-minimal dev
22+
```
23+
24+
Open the printed URL for the host page with the floating dock, or `/__devframes/` for the standalone viewer.
25+
26+
## Source
27+
28+
[`examples/hub-next-minimal`](https://github.com/devframes/devframe/tree/main/examples/hub-next-minimal)

‎docs/examples/hub-next.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-next
6+
7+
The same hub protocol as the [Vite host](./hub-vite), hosted from a **Next.js** App Router app with a hand-built React viewer — proof that the hub is host-runtime-agnostic.
8+
9+
Package: `hub-next` · framework: **React (Next.js)**
10+
11+
## What it proves
12+
13+
- `initHub({ base, devframes, configure })` boots the whole hub from one call; a single App Router catch-all route (`app/%5F_devframes/[[...path]]/route.ts`) delegates to `hub.handler(request)`.
14+
- Next route handlers can't accept WebSocket upgrades, so the instance starts its eager side-car WS server, advertised through `<base>__connection.json`.
15+
- The [JSON-render](/guide/json-render) hub integration with **registry replacement**: the React client renders the server-authored view with a small in-example React registry (rather than the Vue `@devframes/json-render-ui`) — the path a non-Vue host uses.
16+
- [Client-only docks](/guide/client-context#client-only-docks) the page registers itself with `context.docks.register()`.
17+
18+
For the minimal counterpart — the hub UI supplied by `@devframes/hub-ui` instead of a hand-built viewer — see [hub-next-minimal](./hub-next-minimal).
19+
20+
## Run it
21+
22+
```sh
23+
pnpm install
24+
pnpm --filter hub-next dev
25+
```
26+
27+
Open the printed URL to see the docks, commands, messages, and terminals the hub exposes.
28+
29+
## Source
30+
31+
[`examples/hub-next`](https://github.com/devframes/devframe/tree/main/examples/hub-next)

‎docs/examples/hub-nitro-minimal.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-nitro-minimal
6+
7+
The minimal [Nitro](https://nitro.build) host for [`@devframes/hub`](/guide/hub): one `initHub()` call behind a catch-all route, the UI supplied by `@devframes/hub-ui`.
8+
9+
Package: `hub-nitro-minimal` · framework: **Nitro**
10+
11+
## What it shows
12+
13+
- `initHub({ base, devframes: [inspect, messages], ui: createUi() })` in `hub.ts`, delegated to by a catch-all route (`routes/__devframes/[...path].ts`, plus its `index.ts` sibling for the namespace root) via `hub.handler(event.req)`.
14+
- `nitro.config.ts` keeps the devframe packages external so their prebuilt client assets resolve from the packages themselves rather than Nitro's build output.
15+
- The RPC WebSocket runs on an eager side-car port, advertised through `<base>__connection.json`.
16+
17+
## Run it
18+
19+
```sh
20+
pnpm install
21+
pnpm --filter hub-nitro-minimal dev
22+
```
23+
24+
Open the printed URL for the host page with the floating dock, or `/__devframes/` for the standalone viewer.
25+
26+
## Source
27+
28+
[`examples/hub-nitro-minimal`](https://github.com/devframes/devframe/tree/main/examples/hub-nitro-minimal)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-rsbuild-minimal
6+
7+
The minimal [Rsbuild](https://rsbuild.dev) host for [`@devframes/hub`](/guide/hub): one `initHub()` call mounted into the dev server's middleware stack, the UI supplied by `@devframes/hub-ui`.
8+
9+
Package: `hub-rsbuild-minimal` · framework: **Rsbuild**
10+
11+
## What it shows
12+
13+
- `initHub({ base, devframes: [inspect, messages], ui: createUi() })` created inside `server.setup` in `rsbuild.config.ts` — lazily, so importing the config never spawns the hub's side-car.
14+
- `server.setup` registers `hub.nodeMiddleware`, which owns the `/__devframes/` namespace and hands everything else back to Rsbuild.
15+
- The RPC WebSocket runs on an eager side-car port, advertised through `<base>__connection.json`; `html.tags` injects the `${hub.base}embedded.js` bootstrap.
16+
17+
## Run it
18+
19+
```sh
20+
pnpm install
21+
pnpm --filter hub-rsbuild-minimal dev
22+
```
23+
24+
Open the printed URL for the host page with the floating dock, or `/__devframes/` for the standalone viewer.
25+
26+
## Source
27+
28+
[`examples/hub-rsbuild-minimal`](https://github.com/devframes/devframe/tree/main/examples/hub-rsbuild-minimal)

‎docs/examples/hub-vite-minimal.md‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
outline: deep
3+
---
4+
5+
# hub-vite-minimal
6+
7+
The minimal [Vite](https://vite.dev) host for [`@devframes/hub`](/guide/hub): one `initHub()` call mounted as dev middleware, the UI supplied by `@devframes/hub-ui`. No hand-built viewer — the whole integration is the config file.
8+
9+
Package: `hub-vite-minimal` · framework: **Vite**
10+
11+
## What it shows
12+
13+
- `initHub({ base, devframes: [inspect, messages], ui: createUi() })` in `vite.config.ts` — runs in Vite's Node config process, never bundled into the browser.
14+
- `server.middlewares.use(hub.nodeMiddleware)` mounts the whole `/__devframes/` namespace; the WebSocket upgrade shares Vite's own server at `<base>__ws`.
15+
- `transformIndexHtml` injects `<script type="module" src="${hub.base}embedded.js">`, so the floating dock mounts itself on the host page.
16+
17+
## Run it
18+
19+
```sh
20+
pnpm install
21+
pnpm --filter hub-vite-minimal dev
22+
```
23+
24+
Open the printed URL for the host page with the floating dock, or `/__devframes/` for the standalone viewer.
25+
26+
## Source
27+
28+
[`examples/hub-vite-minimal`](https://github.com/devframes/devframe/tree/main/examples/hub-vite-minimal)

0 commit comments

Comments
 (0)