Skip to content

feat(hub): serve a definition's absolute-path page script automatically - #312

Merged
antfu merged 3 commits into
mainfrom
fix/a11y-default-client-script
Aug 27, 2026
Merged

feat(hub): serve a definition's absolute-path page script automatically#312
antfu merged 3 commits into
mainfrom
fix/a11y-default-client-script

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

Mounting the a11y inspector by package name (initHub({ devframes: ['@devframes/plugin-a11y'] })) left its panel stuck on "No page connected": nothing booted its page script. The knowledge was split — the plugin knew the page-script file, the host knew the URL space, and every host had to hand-write the same mount + clientScript recipe to join them.

Closes #310.

What

Let a devframe declare its page script by path. DevframeDockDefaults.clientScript now accepts an absolute filesystem path in importFrom; the hub install path (prepareDevframe) serves the file's directory under the devframe's mount base (<base>__page-script/) and rewrites importFrom to that served URL — the same mountStatic the hub already uses for each devframe's SPA dist. A URL or bare-specifier importFrom still passes through untouched, so the change is additive.

The a11y inspector then declares its own page script:

dock: { category: '~builtin', clientScript: { importFrom: a11yPageScriptBundlePath } }

so devframes: ['@devframes/plugin-a11y'] works on every host with no wiring. The three reference hosts (hub-vite, hub-next, a11y-messages-playground) drop their manual mount + clientScript recipes.

Notes

  • An absolute path is distinguished from an already-servable root path (/@fs/…, a mounted bundle) by existence on disk — only a real file is mounted and rewritten.
  • The in-page channel already re-handshakes on either side (re)loading, so panel/page-script boot order needs no host-side sequencing.
  • Docs updated: a11y plugin page, client-context guide, and the three example READMEs; API snapshot and knip.jsonc (hub-next's a11y dep is now referenced only via the runtime import() loop) updated to match.

This PR was created with the help of an agent.

Let a devframe declare its page script on `dock.clientScript.importFrom`
as an absolute filesystem path. The hub install path mounts the file's
directory under the devframe's mount base and rewrites `importFrom` to
the served URL, so mounting the a11y inspector by package name works on
every host with no per-host wiring.

The a11y inspector now declares its own page script, and the reference
hosts (hub-vite, hub-next, a11y-messages-playground) drop their manual
mount + `clientScript` recipes.

Closes #310
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
devframe Ready Ready Preview Aug 27, 2026 4:27pm

Comment thread examples/a11y-messages-playground/README.md Outdated
Comment thread examples/a11y-messages-playground/vite.config.ts Outdated
Use pathe consistently in the install-devframe test so the served-dir
assertion matches the implementation's normalized path on Windows.
Trim the verbose comments/descriptions added across the change per review.
Comment thread docs/content/1.guide/17.client-context.md Outdated
Move the absolute-path shape to the third bullet and drop the a11y
parenthetical (review). Make the page-script docs, jsdocs, and comments
as concise as possible.
@antfu
antfu merged commit ec4aa61 into main Aug 27, 2026
10 of 11 checks passed
@antfu
antfu deleted the fix/a11y-default-client-script branch August 27, 2026 16:27
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.

a11y: mounting by package name leaves the panel on "No page connected"

2 participants