feat(examples,docs): migrate reference hubs to initHub; Nitro & Hono examples, Bun smoke, framework guides - #172
Open
antfubot wants to merge 4 commits into
Open
feat(examples,docs): migrate reference hubs to initHub; Nitro & Hono examples, Bun smoke, framework guides#172antfubot wants to merge 4 commits into
antfubot wants to merge 4 commits into
Conversation
atinux
reviewed
Aug 6, 2026
Comment on lines
+41
to
+51
| ```ts [Nitro] | ||
| // middleware/devtools.ts | ||
| import { defineHandler } from 'h3' | ||
| import { devtools } from '../devtools' | ||
|
|
||
| export default defineHandler((event) => { | ||
| const { pathname } = new URL(event.req.url) | ||
| if (pathname === '/__my-tool' || pathname.startsWith('/__my-tool/')) | ||
| return devtools.handler(event.req) | ||
| }) | ||
| ``` |
There was a problem hiding this comment.
Another solution is to create a server route, see: https://content.comark.dev/integrations/nitro#mount-the-handler
Suggested change
| ```ts [Nitro] | |
| // middleware/devtools.ts | |
| import { defineHandler } from 'h3' | |
| import { devtools } from '../devtools' | |
| export default defineHandler((event) => { | |
| const { pathname } = new URL(event.req.url) | |
| if (pathname === '/__my-tool' || pathname.startsWith('/__my-tool/')) | |
| return devtools.handler(event.req) | |
| }) | |
| ``` | |
| ```ts [Nitro] | |
| // routes/__my-tool/[...path].ts | |
| import { defineHandler } from 'nitro' | |
| import { devtools } from '../../devtools' | |
| export default defineHandler((event) => devtools.handler(event.req)) |
(not tested)
… & Hono examples, Bun smoke, framework guides Both reference hosts now assemble through one initHub() call while keeping their hand-built viewer UIs as protocol demos: the Vite example shares Vite's own http server for the WS upgrade at /__devframes/__ws (zero extra ports) and the Next example collapses its encoded catch-all routes into a single app/%5F_devframes/[[...path]]/route.ts delegating to hub.handler. New minimal examples prove the middleware story end to end: - examples/nitro-devframe-hub — Nitro v3, one catch-all route (+ an index route for the namespace root), devframe packages kept external so import.meta.url asset resolution survives bundling - examples/hono-devframe-hub — one runtime-agnostic app file served by @hono/node-server on Node and Bun.serve on Bun (fetch-upgrade tier); scripts/smoke-bun.ts exercises fetch + WS RPC + embedded.js on Bun initHub grows what the migrations needed: devframes entries with dock overrides, rpcDeclarations passthrough, a route-safe id guard (DF8004), a bind-retry for the auto side-car, and a buffered embedded.js body that survives dev-worker proxies. Docs: adapters/initiate (mount snippets for Vite/Nitro/Hono/Next/Nuxt/ SvelteKit, WS binding precedence, auth posture) and guide/hub-initiate (the namespace, the ui slot, single hub Auth, singular-vs-hub table).
antfubot
force-pushed
the
feat/handler-examples-docs
branch
from
August 6, 2026 10:39
f60ca01 to
90930f8
Compare
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…inline the module
Vite's lib build recognizes the literal `new URL('...', import.meta.url)`
asset pattern and was inlining the embedded/standalone entry's own source
as a `data:video/mp2t` URL — so at runtime the dock resolved its hub base
from that data URL instead of the served script URL, and connection-meta
discovery failed. Assigning import.meta.url to a variable first sidesteps
the pattern matcher; the base stays the real runtime URL.
Both initDevframe and initHub now take a required `base` option (the mount path is explicit at the call site — pass DEVFRAMES_HUB_BASE for the hub's conventional /__devframes/) and echo the normalized value back as `instance.base`, so route guards and middleware reference it instead of repeating the magic string. BREAKING CHANGE: `base` is no longer optional on initDevframe/initHub.
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Top of the
/__devframes/standard-middleware stack. Seeplans/devframes-standard-middleware.md.Intent
Prove the middleware story across frameworks and make the mount ergonomics explicit.
initDevframe/initHub:baseis required and exposedBoth factories now take a required
base(the mount path is explicit at the call site — passDEVFRAMES_HUB_BASEfor the hub's/__devframes/) and echo the normalized value back asinstance.base, so route guards and middleware reference it instead of repeating the magic string. Breaking:baseis no longer optional.Examples: renamed + a minimal family
hub-vite,hub-next.initHub({ ui: createUi() })handler mounted on the framework, the whole integration in the config/route file:hub-vite-minimal,hub-next-minimal,hub-nitro-minimal,hub-hono-minimal,hub-rsbuild-minimal.server.setupso importing the config is side-effect free.vite-devframe-hub→hub-vite, etc.).Fixes found by dogfooding
hub-ui: Vite's lib build was inlining the embedded/standalone entry's own source as adata:video/mp2tURL (thenew URL('...', import.meta.url)asset pattern), so the dock resolved its base from a data URL and connection discovery failed. Readingimport.meta.urlthrough a variable sidesteps it..gitignorenow covers.next/.nitro/.outputso knip (which respects gitignore) doesn't scan framework build output.Verified
All five minimal examples boot and serve
/,/__devframes/,__connection.json,__index.json,embedded.js, and a frame SPA (200s);bun scripts/smoke-bun.tsexercises the Bun fetch-upgrade tier end to end. Full gauntlet green: build, typecheck (incl.verify-typecheck-coverage), 1084 tests, lint, knip.Created with the help of an agent.