Skip to content

Commit 16dd84a

Browse files
committed
refactor(hub): tighten public surface
Address downstream feedback from @vitejs/devtools-kit: - Drop the Vite-specific `~viteplus` category from the hub's framework-neutral surface; widen `DevframeDockEntryCategory` to `(string & {})` so kits register their own categories ad-hoc. - Rename `DevframeDockHost` → `DevframeDocksHost` and `DevframeTerminalHost` → `DevframeTerminalsHost` so host class names match their `ctx.docks` / `ctx.terminals` property names. - Rename `HubNodeContext` → `DevframeHubContext` to follow the `Devframe*` prefix pattern the rest of the codebase uses. - Rename hub's `defineRpcFunction` → `defineHubRpcFunction` so the hub-context-typed factory can't be confused with devframe's or a kit's identically-named export.
1 parent 4d2054d commit 16dd84a

31 files changed

Lines changed: 113 additions & 106 deletions

‎docs/errors/DF8100.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ outline: deep
1919

2020
## Source
2121

22-
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDockHost.register()` throws when `views.has(view.id) && !force`.
22+
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDocksHost.register()` throws when `views.has(view.id) && !force`.

‎docs/errors/DF8101.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ The `update` handle returned by `ctx.docks.register(view)` received a patch whos
1919

2020
## Source
2121

22-
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDockHost.register()` returns an `update` callable that throws this when the patch carries a different `id`.
22+
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDocksHost.register()` returns an `update` callable that throws this when the patch carries a different `id`.

‎docs/errors/DF8102.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ outline: deep
1919

2020
## Source
2121

22-
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDockHost.update()` throws when `views.has(view.id) === false`.
22+
- [`packages/hub/src/node/host-docks.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-docks.ts) — `DevframeDocksHost.update()` throws when `views.has(view.id) === false`.

‎docs/errors/DF8200.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ outline: deep
1919

2020
## Source
2121

22-
- [`packages/hub/src/node/host-terminals.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-terminals.ts) — `DevframeTerminalHost.register()` and `startChildProcess()` throw when the id is already taken.
22+
- [`packages/hub/src/node/host-terminals.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-terminals.ts) — `DevframeTerminalsHost.register()` and `startChildProcess()` throw when the id is already taken.

‎docs/errors/DF8201.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ outline: deep
1919

2020
## Source
2121

22-
- [`packages/hub/src/node/host-terminals.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-terminals.ts) — `DevframeTerminalHost.update()` throws when `sessions.has(patch.id) === false`.
22+
- [`packages/hub/src/node/host-terminals.ts`](https://github.com/devframes/devframe/blob/main/packages/hub/src/node/host-terminals.ts) — `DevframeTerminalsHost.update()` throws when `sessions.has(patch.id) === false`.

‎docs/guide/hub.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ outline: deep
1111
1212
## What the hub adds
1313

14-
A hub-aware node context (`HubNodeContext`) extends `DevframeNodeContext` with four subsystems:
14+
A hub-aware node context (`DevframeHubContext`) extends `DevframeNodeContext` with four subsystems:
1515

1616
| Subsystem | Surface | Purpose |
1717
|---|---|---|

‎examples/minimal-next-devframe-hub/src/client/devframe/demo-devframe.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { HubNodeContext } from '@devframes/hub/node'
1+
import type { DevframeHubContext } from '@devframes/hub/node'
22
import { defineDevframe } from 'devframe/types'
33

44
export default defineDevframe({
@@ -7,7 +7,7 @@ export default defineDevframe({
77
icon: 'ph:rocket-duotone',
88
basePath: '/__next-demo-tool/',
99
async setup(rawCtx) {
10-
const ctx = rawCtx as unknown as HubNodeContext
10+
const ctx = rawCtx as unknown as DevframeHubContext
1111

1212
ctx.commands.register({
1313
id: 'next-demo-tool:say-hello',

‎examples/minimal-next-devframe-hub/src/client/devframe/minimal-next-devframe-hub.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { HubNodeContext } from '@devframes/hub/node'
1+
import type { DevframeHubContext } from '@devframes/hub/node'
22
import type { StartedServer } from 'devframe/node'
33
import type { ConnectionMeta, DevframeDefinition, DevframeHost } from 'devframe/types'
44
import { homedir } from 'node:os'
55
import process from 'node:process'
6-
import { defineRpcFunction } from '@devframes/hub'
6+
import { defineHubRpcFunction } from '@devframes/hub'
77
import { createHubContext, mountDevframe } from '@devframes/hub/node'
88
import { startHttpAndWs } from 'devframe/node'
99
import { getPort } from 'get-port-please'
@@ -22,26 +22,26 @@ export interface MinimalNextDevframeHubOptions {
2222
}
2323

2424
export interface StartedMinimalNextDevframeHub extends StartedServer {
25-
context: HubNodeContext
25+
context: DevframeHubContext
2626
connectionMeta: ConnectionMeta & { backend: 'websocket', websocket: number }
2727
}
2828

29-
const minimalNextHubMessagesList = defineRpcFunction({
29+
const minimalNextHubMessagesList = defineHubRpcFunction({
3030
name: 'minimal-next-devframe-hub:messages:list',
3131
type: 'static',
3232
jsonSerializable: true,
33-
setup: (ctx: HubNodeContext) => ({
33+
setup: (ctx: DevframeHubContext) => ({
3434
async handler() {
3535
return Array.from(ctx.messages.entries.values())
3636
},
3737
}),
3838
})
3939

40-
const minimalNextHubTerminalsList = defineRpcFunction({
40+
const minimalNextHubTerminalsList = defineHubRpcFunction({
4141
name: 'minimal-next-devframe-hub:terminals:list',
4242
type: 'static',
4343
jsonSerializable: true,
44-
setup: (ctx: HubNodeContext) => ({
44+
setup: (ctx: DevframeHubContext) => ({
4545
async handler() {
4646
return Array.from(ctx.terminals.sessions.values()).map(s => ({
4747
id: s.id,

‎examples/minimal-vite-devframe-hub/src/devframe.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { HubNodeContext } from '@devframes/hub/node'
1+
import type { DevframeHubContext } from '@devframes/hub/node'
22
import { defineDevframe } from 'devframe/types'
33

44
/**
@@ -16,7 +16,7 @@ export default defineDevframe({
1616
icon: 'ph:rocket-duotone',
1717
basePath: '/__demo-tool/',
1818
async setup(rawCtx) {
19-
const ctx = rawCtx as unknown as HubNodeContext
19+
const ctx = rawCtx as unknown as DevframeHubContext
2020

2121
ctx.commands.register({
2222
id: 'demo-tool:say-hello',

‎examples/minimal-vite-devframe-hub/src/minimal-vite-devframe-hub.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type { HubNodeContext } from '@devframes/hub/node'
1+
import type { DevframeHubContext } from '@devframes/hub/node'
22
import type { DevframeDefinition, DevframeHost } from 'devframe/types'
33
import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
44
import { homedir } from 'node:os'
5-
import { defineRpcFunction } from '@devframes/hub'
5+
import { defineHubRpcFunction } from '@devframes/hub'
66
import { createHubContext, mountDevframe } from '@devframes/hub/node'
77
import { DEVFRAME_CONNECTION_META_FILENAME } from 'devframe/constants'
88
import { startHttpAndWs } from 'devframe/node'
@@ -20,22 +20,22 @@ export interface MinimalViteDevframeHubOptions {
2020

2121
// Minimal hub-local RPCs — used by the UI for read-side data. A more
2222
// ambitious hub host might hoist these into `@devframes/hub` itself.
23-
const minimalViteHubMessagesList = defineRpcFunction({
23+
const minimalViteHubMessagesList = defineHubRpcFunction({
2424
name: 'minimal-vite-devframe-hub:messages:list',
2525
type: 'static',
2626
jsonSerializable: true,
27-
setup: (ctx: HubNodeContext) => ({
27+
setup: (ctx: DevframeHubContext) => ({
2828
async handler() {
2929
return Array.from(ctx.messages.entries.values())
3030
},
3131
}),
3232
})
3333

34-
const minimalViteHubTerminalsList = defineRpcFunction({
34+
const minimalViteHubTerminalsList = defineHubRpcFunction({
3535
name: 'minimal-vite-devframe-hub:terminals:list',
3636
type: 'static',
3737
jsonSerializable: true,
38-
setup: (ctx: HubNodeContext) => ({
38+
setup: (ctx: DevframeHubContext) => ({
3939
async handler() {
4040
return Array.from(ctx.terminals.sessions.values()).map(s => ({
4141
id: s.id,

0 commit comments

Comments
 (0)