Skip to content

Commit 2fb9bf9

Browse files
antfubotantfu
authored andcommitted
feat(examples): rebrand each hub-*-minimal example to its host framework's color
Each minimal example (Vite, Next.js, Nitro, Rsbuild, Hono) already calls createUi() with no branding, so all five render the identical default sage green dock. Pass branding.primaryColor (and a matching productName) to createUi() in each so the dock visibly reflects the host it's running on - Vite's purple (#646cff), Next.js/Vercel's monochrome black (#000000), Nitro's pink/red (#ff2056), Rsbuild's orange (#ff5e00), and Hono's orange (#e36002). Colors verified against each project's live site (theme-color meta / computed CSS custom properties). hub-vite and hub-next (the two hand-rolled-UI reference hosts) are left on the shared devframe design system, per this repo's parity/one-product design principle for those two. Verified end to end in Chromium (hub-vite-minimal, hub-nitro-minimal) that branding.json is served and --devframe-primary resolves to the configured color inside the dock's shadow root.
1 parent bc4e5bc commit 2fb9bf9

9 files changed

Lines changed: 29 additions & 9 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Open <http://localhost:5179> — the host page carries the floating dock via one
1111

1212
## How it works
1313

14-
- [`src/app.ts`](./src/app.ts) — runtime-agnostic: `initHub({ devframes, ui: createUi() })` plus `app.all('/__devframes/*', c => hub.handler(c.req.raw))`. Everything — frame SPAs, `__connection.json`, `__index.json`, `embedded.js`, `__client-imports.js` — flows through that one route. The instance is memoized on `globalThis` so a dev-time reload reuses the live hub. It configures no WebSocket transport, so each entry below wires the socket its runtime's way; both end up serving `/__devframes/__ws` on the app's own origin, which is what the hub advertises either way.
14+
- [`src/app.ts`](./src/app.ts) — runtime-agnostic: `initHub({ devframes, ui: createUi({ branding }) })` (rebranded to Hono's own orange, `#e36002`) plus `app.all('/__devframes/*', c => hub.handler(c.req.raw))`. Everything — frame SPAs, `__connection.json`, `__index.json`, `embedded.js`, `__client-imports.js` — flows through that one route. The instance is memoized on `globalThis` so a dev-time reload reuses the live hub. It configures no WebSocket transport, so each entry below wires the socket its runtime's way; both end up serving `/__devframes/__ws` on the app's own origin, which is what the hub advertises either way.
1515
- [`src/server.ts`](./src/server.ts) — Node: `@hono/node-server`'s `serve()` returns the `node:http` server, and `hub.attach(server)` routes its upgrade events to the shared RPC socket.
1616
- [`src/bun.ts`](./src/bun.ts) — Bun: upgrades arrive as fetch requests, so this entry binds Bun's own transport to the hub context with `createContextRpcServer` + `attachBunWsTransport` and answers the upgrade route inside `Bun.serve({ fetch, websocket })`.
1717

‎examples/hub-hono-minimal/src/app.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export const hub: HubInstance = globalRef.__hubHonoMinimal ??= initHub({
3838
createOgDevframe(),
3939
createAssetsDevframe({ watch: false }),
4040
],
41-
ui: createUi(),
41+
// Rebrand the reference UI to Hono's own orange — one field, no CSS:
42+
// `createUi`'s `branding` option publishes `branding.json`, which the dock
43+
// fetches at boot and feeds into `--devframe-primary` (see
44+
// `@devframes/hub-ui`'s `primary-ramp.css`).
45+
ui: createUi({ branding: { primaryColor: '#e36002', productName: 'Devframes on Hono' } }),
4246
// Single-user localhost demo: reachable only on loopback, so it opts out
4347
// of the gate for a no-friction dev experience. A hub reachable beyond
4448
// localhost should gate (see docs/guide/security.md).

‎examples/hub-next-minimal/src/client/hub.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ async function loadHub(): Promise<HubInstance> {
7676
base: DEVFRAMES_HUB_BASE,
7777
ws: { sidecar: true },
7878
devframes,
79-
ui: (hubUi.createUi as typeof CreateUi)(),
79+
// Rebrand the reference UI to Next.js/Vercel's monochrome black — one
80+
// field, no CSS: `createUi`'s `branding` option publishes
81+
// `branding.json`, which the dock fetches at boot and feeds into
82+
// `--devframe-primary` (see `@devframes/hub-ui`'s `primary-ramp.css`).
83+
ui: (hubUi.createUi as typeof CreateUi)({ branding: { primaryColor: '#000000', productName: 'Devframes on Next.js' } }),
8084
// Serve the reference json-render frontend as a prebuilt renderer module
8185
// — the one-liner that makes `'json-render'` docks render in the prebuilt
8286
// viewer. Swap it for any community implementation of the same contract.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Open <http://localhost:3000> - the host page carries the floating dock via one s
1010

1111
## How it works
1212

13-
- [`hub.ts`](./hub.ts) - `initHub({ devframes, ui: createUi(), key })`: mounts the Inspect and Messages plugins against one shared hub context, fills the hub's `ui` slot with `@devframes/hub-ui`'s prebuilt viewer + floating-dock bootstrap, and memoizes the instance across Nitro's dev-time module reloads.
13+
- [`hub.ts`](./hub.ts) - `initHub({ devframes, ui: createUi({ branding }) })`: mounts the Inspect and Messages plugins against one shared hub context, fills the hub's `ui` slot with `@devframes/hub-ui`'s prebuilt viewer + floating-dock bootstrap (rebranded to Nitro's own pink/red, `#ff2056`), and memoizes the instance across Nitro's dev-time module reloads.
1414
- [`routes/__devframes/[...path].ts`](./routes/__devframes/%5B...path%5D.ts) (and its `index.ts` sibling for the namespace root) - the delegation: every request under `/__devframes/` becomes `hub.handler(event.req)`, web-standard Request in, Response out. Everything - frame SPAs, `__connection.json`, `__index.json`, `embedded.js`, `__client-imports.js` - flows through it.
1515
- [`nitro.config.ts`](./nitro.config.ts) - keeps the devframe packages external so their prebuilt client assets resolve from the packages themselves rather than Nitro's build output.
1616
- The RPC WebSocket runs on a side-car port - Nitro handlers hand over `Request`s, so `ws: { sidecar: true }` asks for one - advertised through `__connection.json`; the browser client discovers it automatically.

‎examples/hub-nitro-minimal/hub.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ export const hub: HubInstance = globalRef.__hubNitroMinimal ??= initHub({
4141
createOgDevframe(),
4242
createAssetsDevframe({ watch: false }),
4343
],
44-
ui: createUi(),
44+
// Rebrand the reference UI to Nitro's own pink/red — one field, no CSS:
45+
// `createUi`'s `branding` option publishes `branding.json`, which the dock
46+
// fetches at boot and feeds into `--devframe-primary` (see
47+
// `@devframes/hub-ui`'s `primary-ramp.css`).
48+
ui: createUi({ branding: { primaryColor: '#ff2056', productName: 'Devframes on Nitro' } }),
4549
// Single-user localhost demo: reachable only on loopback, so it opts out
4650
// of the gate for a no-friction dev experience. A hub reachable beyond
4751
// localhost should gate (see docs/guide/security.md).

‎examples/hub-rsbuild-minimal/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Open the printed URL - the host page carries the floating dock via one injected
1212

1313
[`rsbuild.config.ts`](./rsbuild.config.ts) is the entire host:
1414

15-
- `initHub({ devframes: [inspect, messages], ui: createUi() })` runs in Rsbuild's Node config process (never bundled into the browser), so `createUi()`'s prebuilt viewer/dock and the plugins' node code work unchanged.
15+
- `initHub({ devframes: [inspect, messages], ui: createUi({ branding }) })` runs in Rsbuild's Node config process (never bundled into the browser), so `createUi()`'s prebuilt viewer/dock and the plugins' node code work unchanged. `branding.primaryColor` is Rsbuild's own orange (`#ff5e00`) — a rebrand reaches every `primary`-based color in the dock, no CSS required.
1616
- `dev.setupMiddlewares` unshifts `hub.nodeMiddleware`, which owns the whole `/__devframes/` namespace and hands everything else back to Rsbuild.
1717
- The RPC WebSocket runs on a side-car port (`ws: { sidecar: true }`, since Rsbuild's middleware stack never hands over upgrades), advertised through `__connection.json`; the browser client discovers it automatically.
1818
- `html.tags` injects `<script type="module" src="/__devframes/embedded.js">`, so the floating dock mounts itself.

‎examples/hub-rsbuild-minimal/rsbuild.config.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ export default defineConfig({
7676
hub ??= initHub({
7777
base,
7878
devframes: builtinDevframes,
79-
ui: createUi(),
79+
// Rebrand the reference UI to Rsbuild's own orange — one field, no
80+
// CSS: `createUi`'s `branding` option publishes `branding.json`,
81+
// which the dock fetches at boot and feeds into `--devframe-primary`
82+
// (see `@devframes/hub-ui`'s `primary-ramp.css`).
83+
ui: createUi({ branding: { primaryColor: '#ff5e00', productName: 'Devframes on Rsbuild' } }),
8084
// Serve the reference json-render frontend as a prebuilt renderer
8185
// module — the one-liner that makes `'json-render'` docks render in
8286
// the prebuilt viewer. Swap it for any community implementation of

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Open the printed URL - the host page carries the floating dock via one injected
1212

1313
[`vite.config.ts`](./vite.config.ts) is the entire host:
1414

15-
- `initHub({ devframes: [inspect, messages], ui: createUi() })` runs in Vite's Node config process (never bundled into the browser), so `createUi()`'s prebuilt viewer/dock and the plugins' node code work unchanged.
15+
- `initHub({ devframes: [inspect, messages], ui: createUi({ branding }) })` runs in Vite's Node config process (never bundled into the browser), so `createUi()`'s prebuilt viewer/dock and the plugins' node code work unchanged. `branding.primaryColor` is Vite's own purple (`#646cff`) — a rebrand reaches every `primary`-based color in the dock, no CSS required.
1616
- `server.middlewares.use(hub.nodeMiddleware)` mounts the whole `/__devframes/` namespace; the middleware self-filters by base and hands everything else back to Vite.
1717
- The RPC WebSocket shares Vite's own dev server at `/__devframes/__ws` - zero extra ports.
1818
- `transformIndexHtml` injects `<script type="module" src="/__devframes/embedded.js">` into the host page, so the floating dock mounts itself.

‎examples/hub-vite-minimal/vite.config.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export default defineConfig({
8181
const hub = initHub({
8282
base,
8383
devframes: builtinDevframes,
84-
ui: createUi(),
84+
// Rebrand the reference UI to Vite's own purple — one field, no CSS:
85+
// `createUi`'s `branding` option publishes `branding.json`, which the
86+
// dock fetches at boot and feeds into `--devframe-primary` (see
87+
// `@devframes/hub-ui`'s `primary-ramp.css`).
88+
ui: createUi({ branding: { primaryColor: '#646cff', productName: 'Devframes on Vite' } }),
8589
// Serve the reference json-render frontend as a prebuilt renderer
8690
// module — the one-liner that makes `'json-render'` docks render in
8791
// the prebuilt viewer. Swap it for any community implementation of

0 commit comments

Comments
 (0)