Skip to content

Commit 6ca3e6f

Browse files
authored
feat!: reduce devframe + @devframes/hub public API surface for 0.9 (#190)
1 parent ffdb690 commit 6ca3e6f

134 files changed

Lines changed: 790 additions & 400 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

alias.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const alias = {
1818
'devframe/node/auth': r('devframe/src/node/auth/index.ts'),
1919
'devframe/node/hub-internals': r('devframe/src/node/hub-internals/index.ts'),
2020
'devframe/node': r('devframe/src/node/index.ts'),
21+
'devframe/internal': r('devframe/src/internal/index.ts'),
2122
'devframe/constants': r('devframe/src/constants.ts'),
2223
'devframe/utils/agent-tool-name': r('devframe/src/utils/agent-tool-name.ts'),
2324
'devframe/utils/colors': r('devframe/src/utils/colors.ts'),
@@ -27,9 +28,7 @@ export const alias = {
2728
'devframe/utils/launch-editor': r('devframe/src/utils/launch-editor.ts'),
2829
'devframe/utils/nanoid': r('devframe/src/utils/nanoid.ts'),
2930
'devframe/utils/open': r('devframe/src/utils/open.ts'),
30-
'devframe/utils/promise': r('devframe/src/utils/promise.ts'),
3131
'devframe/utils/simple-schema': r('devframe/src/utils/simple-schema.ts'),
32-
'devframe/utils/scope': r('devframe/src/utils/scope.ts'),
3332
'devframe/utils/serve-static': r('devframe/src/utils/serve-static.ts'),
3433
'devframe/utils/shared-state': r('devframe/src/utils/shared-state.ts'),
3534
'devframe/utils/streaming-channel': r('devframe/src/utils/streaming-channel.ts'),

docs/guide/migration-0.9.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ outline: deep
44

55
# Migrating to 0.9
66

7-
0.9 removes the compatibility shims that were deprecated across the 0.7 series. Each removed export has a drop-in replacement that has shipped alongside it since 0.7, so migrating is a matter of updating import paths and a handful of call sites. This page covers the changes between 0.8.x and 0.9.
7+
0.9 removes the compatibility shims that were deprecated across the 0.7 series and trims the public API surface of `devframe` and `@devframes/hub` down to what integrations actually consume. Each change has a drop-in replacement, so migrating is a matter of updating import paths and a handful of call sites. This page covers the changes between 0.8.x and 0.9.
88

99
## `devframe/adapters/cli` is removed
1010

@@ -96,3 +96,69 @@ const view = createJsonRenderView(ctx, {
9696
`createJsonRenderView` returns a view carrying a serializable `ref` (a shared-state key or an inline spec). Project it onto a hub dock with `toJsonRenderDockEntry` from `@devframes/json-render/hub`, which contributes the `'json-render'` dock type to the hub's open dock union. A dock entry now carries that serializable `view` ref rather than a live renderer handle — a client reads `entry.view.stateKey` (or `entry.view.spec`) to render it.
9797

9898
See [JSON-Render](./json-render) for the full integration reference.
99+
100+
## `defineDevframe` moves to the package root
101+
102+
`defineDevframe` — the primary authoring helper — now lives on the `devframe` entry point alongside `defineRpcFunction`. `devframe/types` is now strictly type-only. Import both values and types from `devframe`:
103+
104+
| 0.8.x | 0.9 |
105+
|-------|-----|
106+
| `import { defineDevframe } from 'devframe/types'` | `import { defineDevframe } from 'devframe'` |
107+
| `import type { DevframeNodeContext } from 'devframe/types'` | `import type { DevframeNodeContext } from 'devframe'` |
108+
109+
```ts
110+
import type { DevframeNodeContext } from 'devframe'
111+
// 0.9
112+
import { defineDevframe, defineRpcFunction } from 'devframe'
113+
```
114+
115+
`devframe/types` still resolves as the type-only subpath — useful for `declare module 'devframe/types'` augmentations — but `devframe` is the canonical import for both values and types.
116+
117+
## `devframe/utils/{promise,scope}` are removed
118+
119+
Two utility subpaths with no integration consumers are removed:
120+
121+
| Removed | Replacement |
122+
|---------|-------------|
123+
| `import { promiseWithResolver } from 'devframe/utils/promise'` | `Promise.withResolvers()` (native) |
124+
| `import { isQualifiedName, qualifyName } from 'devframe/utils/scope'` | Inline the check (`name.includes(':')`) |
125+
126+
The other `devframe/utils/*` helpers — `colors`, `open`, `launch-editor`, `hash`, `nanoid`, `crypto-token`, `structured-clone`, `events`, `shared-state`, `streaming-channel`, `when`, `simple-schema`, `serve-static`, `agent-tool-name` — are unchanged.
127+
128+
## `devframe/node` is slimmed to the context surface
129+
130+
`devframe/node` keeps just the context-building API — `createHostContext` (+ `CreateHostContextOptions`), `createStorage` (+ `CreateStorageOptions`), and the `RpcFunctionsHost` type. Serve a devframe through the adapters (`createDevServer`, `createBuild`, `createCac`) or [`devframe/initiate`](../adapters/initiate); build a context to embed one with `createHostContext`.
131+
132+
The internal host implementations and low-level factories are no longer exported at all:
133+
134+
| Removed from `devframe/node` | Notes |
135+
|---|---|
136+
| `DevframeDiagnosticsHost`, `DevframeServicesHostImpl`, `DevframeViewHost` (classes) | Internal host implementations. The same-named **types** remain on `devframe/types`. |
137+
| `createRpcSharedStateServerHost`, `createRpcStreamingServerHost` | Wired internally by `createContextRpcServer`. |
138+
| `createScopedNodeContext`, `createNodeSettings` | Internal to context assembly. |
139+
| `toDialableHost`, `formatHostForUrl`, `isObject` | Internal helpers (`isObject` is removed entirely — inline `typeof x === 'object' && x !== null`). |
140+
141+
## Cross-package internals move to `devframe/internal`
142+
143+
The low-level primitives shared between `devframe` and its first-party integrations (`@devframes/hub`, the inspect plugin, `@vitejs/devtools`, custom hosts) now live at the new `devframe/internal` entry point, which is explicitly **unstable** (it can change in any minor release). They were previously on `devframe/node`:
144+
145+
| Moved | From | To |
146+
|---|---|---|
147+
| `createH3DevframeHost` (+ `CreateH3DevframeHostOptions`) | `devframe/node` | `devframe/internal` |
148+
| `startHttpAndWs` (+ `StartedServer`, `StartHttpAndWsOptions`) | `devframe/node` | `devframe/internal` |
149+
| `createContextRpcServer` (+ `ContextRpcServer`, `CreateContextRpcServerOptions`) | `devframe/node` | `devframe/internal` |
150+
| `DevframeAgentHost` (class) | `devframe/node` | `devframe/internal` |
151+
| `coerceAgentPositionalArgs` (+ `AgentArgsFallback`) | `devframe/node` | `devframe/internal` |
152+
| `registerDevframeInstance` / `listLiveDevframeInstances` (+ `DevframeInstanceRecord`, `DevframeInstanceRegistration`) | `devframe/node` | `devframe/internal` |
153+
| `normalizeHttpServerUrl` | `devframe/node` | `devframe/internal` |
154+
155+
A host that stands up its own server composes from `devframe/internal``createH3DevframeHost` for the node `DevframeHost`, `startHttpAndWs` (or `createContextRpcServer` + `devframe/rpc/server` + `devframe/rpc/transports/*`) to bind a transport — plus `devframe/node`'s `createHostContext` and `devframe/node/hub-internals`. This is the path `@devframes/hub`'s `initHub` takes. A custom host advertises itself with `registerDevframeInstance`, and a devtool enumerates running instances with `listLiveDevframeInstances`. Application code should prefer the adapters and `devframe/initiate`.
156+
157+
## `@devframes/hub` category order lives only on `/constants`
158+
159+
`DEFAULT_CATEGORIES_ORDER` is now exported only from `@devframes/hub/constants` (its documented single source of truth). The redundant re-exports from `@devframes/hub`, `@devframes/hub/node`, and `@devframes/hub/client` are removed:
160+
161+
```ts
162+
// 0.9
163+
import { DEFAULT_CATEGORIES_ORDER } from '@devframes/hub/constants'
164+
```

docs/helpers/utilities.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ randomDigits(6) // '047204' — uniform, leading zeros preserved
9797
timingSafeEqual(input, secret) // constant-time string comparison
9898
```
9999

100-
### `devframe/utils/promise`
101-
102-
Promise constructor with externally-controlled resolution.
103-
104-
```ts
105-
import { promiseWithResolver } from 'devframe/utils/promise'
106-
107-
const { promise, resolve, reject } = promiseWithResolver<number>()
108-
```
109-
110100
### `devframe/utils/events`
111101

112102
Generic typed event emitter — `on(event, cb)` returns an unsubscribe function. Used as the eventing primitive across devframe's hosts.

examples/a11y-messages-playground/src/a11y-messages-playground.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { DevframeHubContext } from '@devframes/hub/node'
22
import type { ClientScriptEntry } from '@devframes/hub/types'
3-
import type { DevframeInstanceRegistration } from 'devframe/node'
4-
import type { DevframeDefinition, DevframeHost } from 'devframe/types'
3+
import type { DevframeDefinition, DevframeHost } from 'devframe'
4+
import type { DevframeInstanceRegistration } from 'devframe/internal'
55
import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite'
66
import { homedir } from 'node:os'
77
import process from 'node:process'
88
import { createHubContext, mountDevframe } from '@devframes/hub/node'
99
import { DEVFRAME_CONNECTION_META_FILENAME } from 'devframe/constants'
10-
import { registerDevframeInstance, startHttpAndWs } from 'devframe/node'
10+
import { registerDevframeInstance, startHttpAndWs } from 'devframe/internal'
1111
import { serveStaticNodeMiddleware } from 'devframe/utils/serve-static'
1212
import { getPort } from 'get-port-please'
1313
import { join } from 'pathe'

examples/files-inspector/src/devframe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fileURLToPath } from 'node:url'
2-
import { defineDevframe } from 'devframe/types'
2+
import { defineDevframe } from 'devframe'
33
import pkg from '../package.json' with { type: 'json' }
44
import { NAMESPACE, serverFunctions } from './rpc/index.ts'
55

examples/files-inspector/tests/_utils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { StartedServer } from 'devframe/node'
1+
import type { StartedServer } from 'devframe/internal'
22
import { existsSync } from 'node:fs'
33
import { mkdtemp, writeFile } from 'node:fs/promises'
44
import os from 'node:os'
@@ -7,11 +7,8 @@ import { fileURLToPath } from 'node:url'
77
import {
88
DEVFRAME_CONNECTION_META_FILENAME,
99
} from 'devframe/constants'
10-
import {
11-
createH3DevframeHost,
12-
createHostContext,
13-
startHttpAndWs,
14-
} from 'devframe/node'
10+
import { createH3DevframeHost, startHttpAndWs } from 'devframe/internal'
11+
import { createHostContext } from 'devframe/node'
1512
import { mountStaticHandler } from 'devframe/utils/serve-static'
1613
import { getPort } from 'get-port-please'
1714
import { H3 } from 'h3'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { createUi as CreateUi } from '@devframes/hub-ui'
22
import type { HubInstance } from '@devframes/hub/initiate'
3-
import type { DevframeDefinition } from 'devframe/types'
3+
import type { DevframeDefinition } from 'devframe'
44
import { DEVFRAMES_HUB_BASE, initHub } from '@devframes/hub/initiate'
55

66
// The plugin packages and `@devframes/hub-ui` resolve their prebuilt `dist`

examples/hub-next/src/client/devframe/demo-devframe-b.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DevframeHubContext } from '@devframes/hub/node'
22
import { fileURLToPath } from 'node:url'
3-
import { defineDevframe } from 'devframe/types'
3+
import { defineDevframe } from 'devframe'
44
import { dirname, resolve } from 'pathe'
55
import pkg from '../../../package.json' with { type: 'json' }
66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DevframeHubContext } from '@devframes/hub/node'
22
import { fileURLToPath } from 'node:url'
3-
import { defineDevframe } from 'devframe/types'
3+
import { defineDevframe } from 'devframe'
44
import { dirname, resolve } from 'pathe'
55
import pkg from '../../../package.json' with { type: 'json' }
66

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { HubDevframeEntry, HubInstance } from '@devframes/hub/initiate'
22
import type { DevframeHubContext } from '@devframes/hub/node'
3-
import type { DevframeInstanceRegistration } from 'devframe/node'
4-
import type { DevframeDefinition } from 'devframe/types'
3+
import type { DevframeDefinition } from 'devframe'
4+
import type { DevframeInstanceRegistration } from 'devframe/internal'
55
import { homedir } from 'node:os'
66
import process from 'node:process'
77
import { fileURLToPath } from 'node:url'
88
import { defineHubRpcFunction } from '@devframes/hub'
99
import { DEVFRAMES_HUB_BASE, initHub } from '@devframes/hub/initiate'
1010
import { toJsonRenderDockEntry } from '@devframes/json-render/hub'
11-
import { registerDevframeInstance } from 'devframe/node'
11+
import { registerDevframeInstance } from 'devframe/internal'
1212
import { createDashboardView } from 'json-render/dashboard'
1313
import { dirname, join } from 'pathe'
1414
import demoDevframe from './demo-devframe'

0 commit comments

Comments
 (0)