Skip to content

refactor!: replace startHttpAndWs and mountDevframe with initHub/initDevframe and ctx.install - #192

Merged
antfu merged 2 commits into
mainfrom
giant-bats-grow
Aug 12, 2026
Merged

refactor!: replace startHttpAndWs and mountDevframe with initHub/initDevframe and ctx.install#192
antfu merged 2 commits into
mainfrom
giant-bats-grow

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Intent

Shrink the framework's public surface to two assembly factories and one hub-context method:

  • Remove startHttpAndWs in favor of initDevframe / initHub, which now own the HTTP+WS binding internally (inlined into the instance shell). StartedServer stays (it's createDevServer's return); StartHttpAndWsOptions is gone.
  • Instance registry via a flag: both factories gain an opt-in register?: boolean | Partial<DevframeInstanceRecord> that dynamically imports and calls registerDevframeInstance once the origin resolves, tearing it down on close(). createDevServer now delegates to it rather than registering itself.
  • Remove mountDevframe in favor of a ctx.install(devframe, options?) method on the hub context. initHub's devframes list and every host go through it. MountDevframeOptionsInstallDevframeOptions.

Examples

All hub examples now assemble through initHub/initDevframe with minimal code: the two legacy manual hosts (a11y-messages-playground, storybook) and the a11y demo were converted, and hub-vite/hub-next drop their hand-rolled registerDevframeInstance in favor of register.

Notes

  • Internal test harnesses that hand-build a context (custom cwd, hub context, injected fakes, exposed ctx) route through a shared repo-internal helper tests/helpers/serve-test-context.ts so startHttpAndWs is fully gone while their semantics are preserved.
  • BREAKING CHANGE: startHttpAndWs / StartHttpAndWsOptions and mountDevframe / MountDevframeOptions are removed. Use initDevframe / initHub (with register) and ctx.install.

Verification

pnpm lint, pnpm knip, pnpm typecheck, pnpm build, and pnpm test (1077 tests, incl. regenerated tsnapi API snapshots) all pass. The pre-existing hub-hono-minimal typecheck failure (missing @types/bun in the container) is unchanged from main and unrelated.


This PR was created with the help of an agent.

…Devframe and ctx.install

Remove the public `startHttpAndWs` API in favor of `initDevframe`/`initHub`,
which now own the HTTP+WS binding internally (via the instance shell). Add an
opt-in `register` flag to both factories so they publish to the instance
registry via a dynamic import — `createDevServer` delegates to it.

Replace the free `mountDevframe` function with a `ctx.install(devframe)` method
on the hub context; `initHub`'s `devframes` list and every host go through it.

Convert the legacy manual hosts and simplify the hub examples accordingly.

BREAKING CHANGE: `startHttpAndWs` / `StartHttpAndWsOptions` and
`mountDevframe` / `MountDevframeOptions` are removed. Use `initDevframe` /
`initHub` (with `register` for registry publishing) and `ctx.install` instead.
@netlify

netlify Bot commented Aug 12, 2026

Copy link
Copy Markdown

Deploy Preview for devfra failed.

Name Link
🔨 Latest commit 58d7c12
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7c26e21b162000084292b2
…n guide

The `unit-test / lint` CI job runs `pnpm typecheck`; `hub-hono-minimal` had a
latent, cache-masked failure (unresolved `Bun` global in the Bun entry and a
hono `ServerType` vs `node:http` `Server` mismatch). Type the Bun entry's slice
locally instead of pulling `@types/bun`, and narrow the hono server cast.

Revise `docs/guide/migration-0.9.md` end to end so it describes the final 0.9
surface: `startHttpAndWs` and `mountDevframe` are now documented as removed
(in favor of `createDevServer`/`initDevframe`/`initHub` and `ctx.install`), the
new opt-in `register` flag is covered, and the internals-move table reflects
`StartedServer` (not `startHttpAndWs`) relocating to `devframe/internal`.
@antfu
antfu merged commit 5dc9b97 into main Aug 12, 2026
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants