feat!: add devframe/initiate — initDevframe framework-agnostic middleware - #167
Merged
Conversation
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…er hooks createContextRpcServer owns everything about serving RPC that is independent of how peers connect (auth wiring, session resolver, auto-trust shim); createWsRpcPeerHooks shapes the per-peer lifecycle for any crossws adapter. startHttpAndWs behavior is unchanged — it now composes the two, so other transports (fetch-upgrade runtimes) can reuse the same wiring.
… middleware createHandler(def) serves a devframe's whole surface — SPA, __connection.json discovery, WebSocket RPC, auth gate (on by default), and the optional MCP route — through one fetch handler mountable on any framework's catch-all route, plus a connect-style nodeMiddleware and Bun fetch-upgrade websocket hooks. WebSocket binding resolves by precedence: ws.port (explicit side-car) > server (shared upgrade at <base>__ws) > ws.url alone (no local transport; external server owns it) > Bun fetch-upgrade > eager auto side-car. ws.url always overrides the advertised endpoint (the tunnel pattern: bind locally, advertise the relay). A key option memoizes the handler on globalThis so HMR module re-evaluation can't leak side-cars (DF0053 on option changes; DF0054 for connectionMeta before ready). BREAKING CHANGE: the WS route unifies on `__ws` (was `__devframe_ws`) across every adapter, and the unused DEVFRAME_MOUNT_PATH / DEVFRAME_DIRNAME constants are removed.
antfubot
force-pushed
the
feat/handler-core
branch
from
August 6, 2026 01:46
236ae62 to
1b8b4e4
Compare
…ing a DevframeInstance The factory is named for the instance it initiates (define → init pairing with defineDevframe), reached from the devframe/initiate subpath, and the web-standard request handler is a property — initDevframe(def).handler — matching the content.handler mounting model, so future capabilities extend the instance object instead of overloading a handler-named factory. - subpath: devframe/handler → devframe/initiate (src/adapters/initiate.ts) - createHandler → initDevframe; CreateHandlerOptions → InitDevframeOptions - DevframeHandler → DevframeInstance; fetch → handler - diagnostics/docs updated (DF0053/DF0054 wording)
antfubot
force-pushed
the
feat/handler-core
branch
from
August 6, 2026 01:56
1b8b4e4 to
4231c95
Compare
This was referenced Aug 6, 2026
refactor(adapters): rebuild createDevServer, viteDevBridge, and @devframes/next on initDevframe
#168
Merged
antfu
approved these changes
Aug 6, 2026
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.
Bottom of a 5-PR stack implementing the
/__devframes/standard-middleware plan (plans/devframes-standard-middleware.md, committed here).Intent
Let any framework that can mount a catch-all route host a devframe:
initDevframe(def)fromdevframe/initiatereturns a liveDevframeInstancewhose.handler— a web-standard(request) => Promise<Response>— serves the SPA,__connection.jsondiscovery, WebSocket RPC, the auth gate (on by default), and the optional MCP route. The instance also exposes a connect-stylenodeMiddleware, Bun fetch-upgradewebsockethooks,ready,context,connectionMeta(), andclose()— mirroring thecontent.handlermounting model (factory named for the instance, capabilities reached off it).ws.port(explicit side-car) >server(shared upgrade at<base>__ws) >ws.urlalone (no local transport) > Bun fetch-upgrade > eager auto side-car;ws.urlalways overrides the advertised endpoint (tunnel pattern).__connection.jsonreflects the active combination.keyoption memoizes the instance onglobalThisso dev-time module re-evaluation (Next/Nitro/SvelteKit HMR) can't leak side-car servers (DF0053on option changes;DF0054forconnectionMeta()before ready).createContextRpcServer+ reusablecreateWsRpcPeerHooksextracted fromstartHttpAndWs(no behavior change; carries the newonPeerDisconnecthook) so Node and Bun transports share one wiring.Breaking changes
__ws(was__devframe_ws) across every adapter — matches upstream Vite DevTools'/__devtools/__ws.DEVFRAME_MOUNT_PATH,DEVFRAME_MOUNT_PATH_NO_TRAILING_SLASH,DEVFRAME_DIRNAME.Stack
Created with the help of an agent.