Skip to content

feat(core): shared-iframe soft navigation (devframe 0.7.11)#464

Merged
antfu merged 2 commits into
mainfrom
feat/shared-iframe-soft-nav
Jul 23, 2026
Merged

feat(core): shared-iframe soft navigation (devframe 0.7.11)#464
antfu merged 2 commits into
mainfrom
feat/shared-iframe-soft-nav

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Description

Implements the Vite DevTools UI contract for devframe's shared-iframe soft-navigation feature — the downstream half of devframes/devframe#128, which shipped the hub side in devframe v0.7.11 and hands the viewer contract to Vite DevTools (§6 / §11 of the design spec).

A multi-tab integration (e.g. a devtool with its own Modules / Timeline / Plugins views inside one SPA) can now surface each internal tab as its own DevTools dock while all of them share one live iframe and switch views by client-side (soft) navigation, with no reload.

What changed

  • Deps: bump the devframe family to ^0.7.11 (hub's strict devframe: "0.7.11" peer moves the whole family in lockstep). Adapt the kit to json-render 0.7.11 dropping upstreamVersion from the view ref (it was vestigial — the client only reads _stateKey).
  • Kit (the Vite skin over hub): re-export the hub frame-nav adapter as attachDevToolsFrameNav plus its protocol types/constants under DevTools* names, and re-export the NavTarget / FrameSubTabsConfig iframe-entry types.
  • Core (the viewer contract):
    • ViewIframe.vue keys iframe panes by frameId ?? id, so an anchor and its members share one kept-alive iframe (§6.1); the unmount is guarded on pane.target so the switch handoff is order-independent.
    • state/context.ts auto-attaches the hub frame-nav adapter for subTabs anchors when their iframe mounts — one adapter per frameId, torn down on removal — replicating hub's maybeAttachFrameNav since core runs its own dock machinery (§6.2 / §7). Client-dock register now materializes its DockEntryState eagerly (the adapter subscribes to entry:activated synchronously right after registering), and dispose clears the selection when the active member vanishes (§7.5).
  • Docs / tests / snapshots: a "Shared-iframe soft navigation" section in docs/kit/dock-system.md, 7 new tests exercising the adapter attach + bidirectional nav loop, and regenerated API export snapshots.

The complementary embedded-app postMessage nav shim (e.g. for Nuxt DevTools) lives in its own repo per the spec.

Gates: pnpm lint && pnpm test && pnpm typecheck && pnpm build all pass (314 tests, +7 new).

Linked Issues

Implements the downstream contract from devframes/devframe#128 (devframe v0.7.11).

Additional context

Reviewers may want to focus on the pane-keying / unmount-race guard in ViewIframe.vue and the eager client-dock state creation in context.ts, which is the seam that lets the hub adapter subscribe to member activation synchronously.

This PR was created with the help of an agent.

Implement the Vite DevTools UI contract for devframe's shared-iframe
soft-nav feature (devframes/devframe#128). An iframe dock flagged
`subTabs` becomes an anchor that owns one live iframe (its `frameId`);
each tab the embedded app reports over the `devframe:frame-nav`
postMessage protocol surfaces as its own client-only member dock that
shares that iframe and switches views without a reload.

- Bump the devframe family to 0.7.11 (hub's strict `devframe` peer moves
  the whole family in lockstep); adapt the kit to json-render dropping
  `upstreamVersion` from the view ref.
- Kit: re-export the hub frame-nav adapter + protocol types under the
  kit's `DevTools*` names, and the `NavTarget` / `FrameSubTabsConfig`
  iframe-entry types.
- Core: key iframe panes by `frameId` so an anchor and its members share
  one kept-alive iframe, guarding the switch handoff on `pane.target`;
  auto-attach the frame-nav adapter for `subTabs` anchors (one per
  `frameId`, torn down on removal). Client-dock registration now
  materializes its DockEntryState eagerly so the adapter can subscribe to
  activation synchronously, and clears the selection when the active
  member is removed.
@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@464

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@464

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@464

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@464

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@464

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@464

commit: 49e0639

Replace the four faked Nuxt group iframes (all pointing at the debug
dashboard) with a single `subTabs` anchor dock backed by a real mock
Nuxt DevTools SPA. The SPA (`mock-nuxt-devtools.vue`) is a self-contained
page with its own internal tab rail that ships the ~40-line
`devframe:frame-nav` postMessage shim: it announces its tab manifest,
answers `navigate`, and reports `navigated` on in-app clicks.

The frame-nav adapter materializes one grouped dock per reported tab
(Overview / Pages / Components / Modules), all sharing one live iframe
and soft-navigating between views with no reload — dogfooding the
shared-iframe soft-navigation feature end to end in the core playground.
@antfu
antfu merged commit 5cb6e65 into main Jul 23, 2026
10 checks passed
@antfu
antfu deleted the feat/shared-iframe-soft-nav branch July 23, 2026 07:59
antfubot added a commit to antfubot/devtools-1 that referenced this pull request Jul 23, 2026
Replace the per-tab `/embed/` iframes (which deep-loaded client routes and
404'd) with the shared-iframe soft-navigation model from devframe#128 /
vitejs/devtools#464. Register a single `subTabs` anchor iframe under the
Nuxt group that loads the client root once; a client-side `devframe:frame-nav`
postMessage shim announces one member dock per tab (from useAllTabs, carrying
its category as an in-group sub-category) and soft-navigates within that one
iframe. No deep-path loads, no Node-side tab list.

Upgrades @vitejs/devtools + @vitejs/devtools-kit to ^0.4.5 and the devframe
family to ^0.7.11.
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