Skip to content

Commit 219ee1f

Browse files
committed
docs: tighten prose and jsdocs; reorder client-script shapes
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.
1 parent b32a0da commit 219ee1f

8 files changed

Lines changed: 32 additions & 43 deletions

File tree

docs/content/1.guide/17.client-context.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ A failed import retries on the next dock update.
7878

7979
`importFrom` accepts three shapes:
8080

81-
- **An absolute filesystem path** to a built, self-contained ES module — declared on the definition's `dock.clientScript`. The hub install path serves the file's directory under the devframe's mount base (`<base>__page-script/`) and rewrites `importFrom` to that served URL, so a definition names its own client script and mounting by package name works with no host wiring (this is how the [a11y inspector](/plugins/a11y) ships its page script).
8281
- **A URL served by the host framework** — a self-contained ES module; works on every host framework.
8382
- **A bare npm specifier** (`'vite-plugin-vue-tracer/client/vite-devtools'`) — resolved through the host framework.
83+
- **An absolute filesystem path**, declared on the definition's `dock.clientScript`. The hub serves its directory under `<base>__page-script/` and rewrites `importFrom` to that URL, so mounting by package name needs no host wiring.
8484

85-
A definition declares its own by path on `dock: { clientScript: { importFrom } }`. Per-mount, attach a URL via `ctx.install(myDevframe, { dock: { clientScript: { importFrom } } })`; under Vite `/@fs/<absolute path>` serves it, and other host frameworks mount the directory statically.
85+
Per-mount, attach a URL via `ctx.install(myDevframe, { dock: { clientScript: { importFrom } } })`; under Vite `/@fs/<absolute path>` serves it, and other host frameworks mount the directory statically.
8686

8787
### Bare npm specifiers
8888

docs/content/5.plugins/4.a11y.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ The page script and the panel talk over the [in-page channel](/guide/in-page-cha
3131

3232
## In a hub
3333

34-
The definition declares the page script as its dock [client script](/guide/client-context), so mounting by package name works everywhere with no extra wiring:
34+
The definition declares the page script as its dock [client script](/guide/client-context), so mounting by package name just works:
3535

3636
```ts
3737
initHub({ devframes: ['@devframes/plugin-a11y'] })
3838
```
3939

40-
The hub serves the page-script bundle same-origin under the a11y mount base and rewrites the dock's `clientScript` to that URL; a client runtime (`createDevframeClientRuntime()`) then imports it into the host page. Each scan also mirrors into the hub's messages feed — a summary plus one per rule.
40+
The hub serves the bundle same-origin and a client runtime imports it into the host page. Each scan also mirrors into the hub's messages feed — a summary plus one per rule.
4141

42-
A host that mounts the module itself still can — for example, a Vite host serving it via `/@fs/` — by attaching `a11yPageScriptBundlePath` as the dock's `clientScript`:
42+
A host can also mount the module itself — e.g. a Vite host via `/@fs/`:
4343

4444
```ts
4545
import createA11yDevframe, { a11yPageScriptBundlePath } from '@devframes/plugin-a11y'

examples/a11y-messages-playground/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ The window is split in two:
5555
## How it's wired
5656

5757
`src/a11y-messages-playground.ts` is the entire host-framework integration - a ~120-line Vite plugin
58-
that runs `@devframes/hub` in the dev server and mounts the two devframes as docks.
59-
The a11y inspector declares its own page script, so the host passes only the devframes:
58+
that runs `@devframes/hub` in the dev server and mounts the two devframes as docks
59+
(the a11y inspector declares its own page script):
6060

6161
```ts
6262
a11yMessagesPlayground({

examples/hub-next/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Open the printed URL. The dock rail on the left lists every mounted tool with it
2020

2121
Selecting a tool loads its SPA in the stage. The bottom drawer mirrors the hub's **Commands**, **Messages**, and **Terminals** subsystems, plus a button that dispatches a command through `hub:commands:execute`, and a **Transport** section showing which RPC transport the connection runs on (`websocket` or `sse`) with a segmented Auto / WS / SSE toggle - the choice rides a `?transport=` URL param and reconnects the whole client runtime on the pinned transport.
2222

23-
The A11y Inspector shows a live axe-core report of this hub's own page: the devframe declares its own page-script module as the a11y dock's `clientScript`, so the hub serves it same-origin inside the hub namespace and rewrites the entry to that URL with no host wiring; the hub client runtime - `createDevframeClientRuntime()` booted in `app/page.tsx` - imports it into the page, so the docked panel and the page script share the origin and tab their in-page channel handshakes across.
23+
The A11y Inspector shows a live axe-core report of this hub's own page: the devframe declares its own page-script module as the a11y dock's `clientScript`, so the hub serves it same-origin with no host wiring; the hub client runtime - `createDevframeClientRuntime()` booted in `app/page.tsx` - imports it into the page, so the docked panel and the page script share the origin and tab their in-page channel handshakes across.
2424

2525
The **RPC & State Inspector** carries an **Instances** tab that lists every devframe dev server running on your machine. The hub registers itself in the shared registry (`~/.devframe/instances/`) on startup via `registerDevframeInstance()`, so it shows up as "this instance"; start another example (e.g. `pnpm --filter hub-vite dev`, or any `node bin.mjs` CLI example) in a second terminal and it appears there too, each linking to its own SPA.
2626

packages/devframe/src/types/devframe.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,13 @@ export interface DevframeDockDefaults {
264264
/** Id of the dock group this entry collapses under, if any. */
265265
groupId?: string
266266
/**
267-
* A client script the hub imports into the host page for this devframe (its
268-
* **page script**). `importFrom` is an **absolute filesystem path** to a built
269-
* ES module, a **URL** the host serves, or a **bare npm specifier**. An
270-
* absolute path is served by the hub install path (its directory mounted under
271-
* the devframe's mount base, `importFrom` rewritten to the served URL), so a
272-
* definition names its own page script and mounting by package name needs no
273-
* host wiring; URL and bare-specifier values pass through untouched.
267+
* A client script the hub imports into the host page (this devframe's **page
268+
* script**). An absolute-path `importFrom` is served by the hub under the
269+
* mount base and rewritten to that URL, so mounting by package name needs no
270+
* host wiring; a URL or bare specifier passes through untouched.
274271
*/
275272
clientScript?: {
276-
/** What to import: an absolute filesystem path, a served URL, or a bare npm specifier. */
273+
/** An absolute filesystem path, a served URL, or a bare npm specifier. */
277274
importFrom: string
278275
/**
279276
* The name to import the module as.

packages/hub/src/node/install-devframe.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ function nextAvailableDockId(views: DevframeHubContext['docks']['views'], baseId
4040
}
4141

4242
/**
43-
* When a dock's `clientScript.importFrom` names an **absolute filesystem path**
44-
* to a built module, serve its directory under the devframe's mount base
45-
* (`<base>__page-script/`) and rewrite `importFrom` to that served URL. A URL or
46-
* bare specifier (distinguished by not existing on disk) passes through
47-
* untouched, as does an absent client script.
43+
* When a dock's `clientScript.importFrom` is an absolute filesystem path, serve
44+
* its directory under `<base>__page-script/` and rewrite `importFrom` to that
45+
* URL. A URL or bare specifier (not existing on disk) passes through untouched.
4846
*/
4947
async function resolvePageScriptClientScript(
5048
ctx: DevframeHubContext,
@@ -111,9 +109,8 @@ export async function prepareDevframe(
111109
? resolveBasePath(d, 'hosted')
112110
: resolveBasePath({ ...d, id, basePath: undefined }, 'hosted'))
113111

114-
// Definition-level `dock` beneath per-mount `options.dock`. Resolved before
115-
// the SPA mount so an absolute-path page script is served ahead of the SPA
116-
// catch-all.
112+
// Definition `dock` beneath per-mount `options.dock`. Resolved before the SPA
113+
// mount so an absolute-path page script is served ahead of the SPA catch-all.
117114
const dockDefaults = { ...d.dock, ...options.dock }
118115
const clientScript = await resolvePageScriptClientScript(ctx, dockDefaults.clientScript, base)
119116
if (clientScript)
@@ -146,9 +143,8 @@ export async function prepareDevframe(
146143
id,
147144
title: d.name,
148145
icon: d.icon,
149-
// Dock defaults (definition + per-mount, folded into `dockDefaults`) sit
150-
// above the name/icon-derived defaults; `type`/`url` (and `id`) stay locked,
151-
// derived from the definition.
146+
// `dockDefaults` sits above the name/icon defaults; `type`/`url`/`id` stay
147+
// locked, derived from the definition.
152148
...dockDefaults,
153149
type: 'iframe',
154150
url: base,

plugins/a11y/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ page script itself free of any RPC dependency.
5757
devframe deliberately provides no access to the user app's DOM, so the
5858
page script is the author-provided bridge into the user app's page. In a hub, the
5959
page script is the a11y dock's **client script**, and the definition declares it by
60-
path (`dock.clientScript.importFrom = a11yPageScriptBundlePath`): the hub install
61-
path serves the bundle same-origin under the a11y mount base and rewrites the entry
62-
to that URL, so `devframes: ['@devframes/plugin-a11y']` works everywhere with no host
63-
wiring. The hub's client runtime (`createDevframeClientRuntime` from
64-
`@devframes/hub/client`) then imports it into the host page and calls its default
65-
export with the client-script context. A host that prefers to serve the module
66-
itself (e.g. via `/@fs/…` under Vite) can still attach `a11yPageScriptBundlePath` as
67-
a per-mount `clientScript`. Booted that way, the page script also
60+
path, so the hub serves it same-origin and `devframes: ['@devframes/plugin-a11y']`
61+
works with no host wiring. The hub's client runtime (`createDevframeClientRuntime`
62+
from `@devframes/hub/client`) then imports it into the host page and calls its default
63+
export with the client-script context. A host can also serve the module itself (e.g.
64+
via `/@fs/…` under Vite) by attaching `a11yPageScriptBundlePath` as a per-mount
65+
`clientScript`. Booted that way, the page script also
6866
mirrors the active route's scan into the hub's **messages feed** — a summary entry
6967
driven through the loading → idle lifecycle plus one entry per violated rule,
7068
carrying the impact-mapped level, WCAG tags as labels, and the first offending
@@ -121,7 +119,7 @@ pnpm -C plugins/a11y dev # from source: same, at /__devframes_plugin_a11
121119

122120
| Path | Export | Purpose |
123121
|------|--------|---------|
124-
| `src/index.ts` | `.` | `createA11yDevframe()` (also the default export), declaring the page script as its dock's client script by path; `a11yPageScriptBundlePath` — that page-script module, for hosts that serve it themselves |
122+
| `src/index.ts` | `.` | `createA11yDevframe()` (also the default export), declaring the page script as its dock's client script; `a11yPageScriptBundlePath` — that module, for hosts that serve it themselves |
125123
| `src/node/index.ts` | `/node` | `setupA11y(ctx, options?)` — registers the RPC functions with the runtime config |
126124
| `src/cli.ts` | `/cli` | `createA11yCli()` — backs the `devframes_plugin_a11y` bin |
127125
| `src/client/index.ts` | `/client` | `connectA11y()` — typed browser RPC client wrapper |

plugins/a11y/src/index.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ const distDir: RemoteAssets = {
2323
* — the dock **client script** the client runtime imports into the host page to
2424
* scan it (its default export boots the page script; importing it does too).
2525
*
26-
* The definition already declares this path as its dock `clientScript`, so a
27-
* hub serves it same-origin and boots it with no host wiring. Exported for
28-
* hosts that mount the module themselves (e.g. via `/@fs/` under Vite).
29-
* Resolves under `<pkg>/dist/inject/inject.js` from both the source and the
30-
* published entry. Requires the built bundle (`pnpm -C plugins/a11y build`).
26+
* The definition already declares this as its dock `clientScript`, so a hub
27+
* serves it with no host wiring. Exported for hosts that mount the module
28+
* themselves (e.g. via `/@fs/` under Vite). Requires the built bundle
29+
* (`pnpm -C plugins/a11y build`).
3130
*/
3231
export const a11yPageScriptBundlePath: string = fileURLToPath(new URL('../dist/inject/inject.js', import.meta.url))
3332

@@ -91,8 +90,7 @@ export function createA11yDevframe(options: A11yDevframeOptions = {}): DevframeD
9190
description: pkg.description,
9291
icon: options.icon ?? 'ph:person-simple-circle-duotone',
9392
basePath: options.basePath ?? BASE_PATH,
94-
// Declare the page script by path; the hub serves it same-origin and boots
95-
// it with no per-host wiring.
93+
// Declare the page script by path; the hub serves it with no host wiring.
9694
dock: {
9795
category: '~builtin',
9896
clientScript: { importFrom: a11yPageScriptBundlePath },

0 commit comments

Comments
 (0)