Skip to content

refactor(adapters): rebuild createDevServer, viteDevBridge, and @devframes/next on initDevframe - #168

Merged
antfu merged 1 commit into
mainfrom
feat/handler-adapters
Aug 6, 2026
Merged

refactor(adapters): rebuild createDevServer, viteDevBridge, and @devframes/next on initDevframe#168
antfu merged 1 commit into
mainfrom
feat/handler-adapters

Conversation

@antfubot

@antfubot antfubot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Layer 2 of the /__devframes/ standard-middleware stack (on #167). See plans/devframes-standard-middleware.md.

Intent

One wiring underneath every serving path: createDevServer (CLI), viteDevBridge (Vite), and @devframes/next all become thin assemblies over the devframe/initiate instance, so the handler core gets the battle-testing of every adapter and no server surface is assembled twice.

  • createDevServer = initDevframe + a node listener. Listen-first so the shared WS tier reports the real bound port (port: 0 works); DF0052 listen-rejection preserved; instance registry, --open, onReady, and the StartedServer contract (ws, rpcGroup, connectionMeta) unchanged.
  • viteDevBridge bridge mode mounts instance.nodeMiddleware on Vite's connect stack and shares Vite's own http server for the WS upgrade at <base>__ws — zero extra ports, proxy/HTTPS friendly. A pinned devMiddleware.port keeps the explicit side-car. MCP moves onto the Vite origin at <base>__mcp.
  • @devframes/next reduces to memoization + defaults sugar over the instance (key-memoized against dev-reload leaks; MCP served same-origin through the catch-all route).
  • initDevframe grows the host-integration options the adapters need: app, distDir: false, origin getter, getStorageDir, destroyUnmatchedUpgrades, onPeerConnect/onPeerDisconnect passthrough.

Breaking changes

viteDevBridge and @devframes/next now advertise same-origin relative endpoints — websocket: { path: '__ws' } on the host origin (or { port, path: '__ws' } for a pinned side-car) and mcp: { path: '__mcp' } — instead of side-car-port absolute paths. The devframe client already resolves both forms.

Stack

  1. feat!: add devframe/initiate — initDevframe framework-agnostic middleware #167 feat/handler-core
  2. feat/handler-adapters (this PR)
  3. feat/hub-handler — headless @devframes/hub/initiate (initHub) with the ui slot
  4. feat/hub-ui — @devframes/hub-ui webcomponents port + createUi()
  5. feat/handler-examples-docs — examples + framework guides + Bun smoke test

Created with the help of an agent.

…frames/next on initDevframe

One wiring underneath every serving path: the adapters become thin
assemblies over the devframe/initiate instance.

- createDevServer = initDevframe + a node listener (listen-first so the
  shared WS tier reports the real port; DF0052 rejection preserved;
  registry/openBrowser/onReady unchanged; ws/rpcGroup/connectionMeta
  surfaced from the instance transport)
- viteDevBridge bridge mode = instance.nodeMiddleware on Vite's stack;
  the WS upgrade now shares Vite's own http server at <base>__ws (zero
  extra ports; pinned devMiddleware.port keeps the explicit side-car)
  and MCP moves onto the Vite origin at <base>__mcp
- @devframes/next reduces to memoization + defaults sugar (key-memoized
  instance; MCP same-origin through the catch-all route)
- initDevframe grows the host-integration options the adapters need:
  app, distDir: false, origin getter, getStorageDir,
  destroyUnmatchedUpgrades, onPeerConnect/onPeerDisconnect passthrough
- resolveDevServerPort / resolveMcpConnectionMeta move to adapters/_shared
  (re-exported from adapters/dev unchanged)

BREAKING CHANGE: viteDevBridge and @devframes/next advertise same-origin
relative endpoints now — websocket { path: '__ws' } on the host origin
(or { port, path: '__ws' } for a pinned side-car) and mcp
{ path: '__mcp' } — instead of side-car-port absolute paths.
@antfu
antfu force-pushed the feat/handler-adapters branch from c7d6b22 to 9c7fa82 Compare August 6, 2026 05:46
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 9c7fa82
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a741fa5a4ee6400083170f4
😎 Deploy Preview https://deploy-preview-168--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit b51603a into main Aug 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants