Skip to content

Commit d28900a

Browse files
committed
feat!: remove per-plugin vite wrappers; export hub base constants from @devframes/hub/constants
Deletes three drift-prone hand-copy clusters: - plugins/{a11y,assets,data-inspector,inspect,messages,og}/src/vite.ts — each an 8-25 line rename over devframeVite(def, options) from @devframes/vite/dev-spa, and the sole reason those plugins depended on @devframes/vite. Consumers now call devframeVite() directly against the plugin's default export; @devframes/vite moves to devDependencies where it's still needed for the plugin's own SPA dev config. plugin-code-server's codeServerVite and plugin-terminals's terminalsVite are unaffected — they compose a bridge + static plugin and build their devframe from options, which is real behaviour beyond delegation, not a mirror. - DEVFRAMES_HUB_BASE hand-copied across packages/{vite,nuxt,next}'s hub-client wrappers (each commented "mirrors @devframes/hub's"). Now defined once in the client-safe packages/hub/src/constants.ts and imported everywhere; packages/hub/src/node/initiate.ts re-exports it for existing importers of that entry. - normalizeBase reimplemented ×4 with two different mechanisms (ufo vs hand-rolled). One canonical normalizeHubBase (ufo-based, hub already depends on ufo) now lives next to the constant and is used by @devframes/hub itself and all three framework adapters. Also deletes packages/hub-ui/src/client/state/renderers.ts, a 30-line shim that only delegated to createDockRenderersContext; its one call site now calls that directly. Breaking: the six plugins' /vite export subpath is gone. Migration documented in docs/guide/migration-0.9.md. Created with the help of an agent.
1 parent 97cbe1d commit d28900a

61 files changed

Lines changed: 143 additions & 365 deletions

Some content is hidden

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

‎docs/guide/migration-0.9.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ Each splits into two scoped subpaths — `.../dev-spa` (author one devframe's SP
4343
| `@devframes/next/client` | `@devframes/next/dev-spa/client` |
4444
| mount a hub inside a tool | `@devframes/{vite,nuxt,next}/hub` (+ `/hub/client`) |
4545

46+
**Built-in plugins**
47+
48+
| Removed / moved | Replacement |
49+
|---|---|
50+
| `@devframes/plugin-{a11y,assets,data-inspector,inspect,messages,og}/vite` | `devframeVite(def, options)` from `@devframes/vite/dev-spa`, against the plugin's default export |
51+
4652
## `devframe/adapters/cli` is removed
4753

4854
The CLI adapter was renamed to `cac` in 0.7. The `devframe/adapters/cli` entry - `createCli`, `CreateCliOptions`, and `CliHandle` - is now gone. Import from `devframe/adapters/cac` instead:
@@ -281,6 +287,31 @@ export default defineConfig({
281287

282288
`@devframes/vite` (and `@devframes/nuxt` / `@devframes/next`) take `@devframes/hub` and `@devframes/hub-ui` as **optional** peers — only the `/hub` scope needs them. Install `vite` as a peer as before. See [`@devframes/vite`](/frameworks/vite) for the full reference.
283289

290+
## Built-in plugins' `/vite` subpath is removed
291+
292+
`a11yVitePlugin`, `assetsVitePlugin`, `dataInspectorVitePlugin`, `inspectVitePlugin`, `messagesVitePlugin`, and `ogVitePlugin` — each plugin's `@devframes/plugin-<name>/vite` export — were one-line renames over `devframeVite(def, options)`. Call `devframeVite` directly against the plugin's default export instead:
293+
294+
```ts
295+
// 0.8.x
296+
import { a11yVitePlugin } from '@devframes/plugin-a11y/vite'
297+
298+
export default defineConfig({
299+
plugins: [a11yVitePlugin()],
300+
})
301+
```
302+
303+
```ts
304+
// 0.9
305+
import a11yDevframe from '@devframes/plugin-a11y'
306+
import { devframeVite } from '@devframes/vite/dev-spa'
307+
308+
export default defineConfig({
309+
plugins: [devframeVite(a11yDevframe)],
310+
})
311+
```
312+
313+
`@devframes/plugin-code-server`'s `codeServerVite` and `@devframes/plugin-terminals`'s `terminalsVite` are unaffected — they mount a bridge and a static plugin together (and build their devframe from the passed options), not a plain `devframeVite` delegation.
314+
284315
## `@devframes/nuxt` and `@devframes/next` split into `/dev-spa` and `/hub`
285316

286317
Both packages now serve their single-devframe surface from a `.../dev-spa` subpath, and the bare package root throws with a pointer to the two scopes.

‎docs/plugins/a11y.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ Runs the panel alone, without a host page to scan — serves at `/__devframes_pl
5656

5757
```ts
5858
// vite.config.ts
59-
import { a11yVitePlugin } from '@devframes/plugin-a11y/vite'
59+
import a11yDevframe from '@devframes/plugin-a11y'
60+
import { devframeVite } from '@devframes/vite/dev-spa'
6061
import { defineConfig } from 'vite'
6162

6263
export default defineConfig({
6364
plugins: [
64-
a11yVitePlugin(),
65+
devframeVite(a11yDevframe),
6566
],
6667
})
6768
```

‎docs/plugins/assets.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ pnpx @devframes/plugin-assets --read-only # disable upload / rename / delete / m
3030

3131
```ts
3232
// vite.config.ts
33-
import { assetsVitePlugin } from '@devframes/plugin-assets/vite'
33+
import assetsDevframe from '@devframes/plugin-assets'
34+
import { devframeVite } from '@devframes/vite/dev-spa'
3435
import { defineConfig } from 'vite'
3536

3637
export default defineConfig({
3738
plugins: [
38-
assetsVitePlugin(),
39+
devframeVite(assetsDevframe),
3940
],
4041
})
4142
```

‎docs/plugins/data-inspector.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ pnpx @devframes/plugin-data-inspector attach # attach to a process
107107
## Mount into a Vite host
108108

109109
```ts
110+
import dataInspectorDevframe from '@devframes/plugin-data-inspector'
110111
import { registerDataSource } from '@devframes/plugin-data-inspector/registry'
111112
// vite.config.ts
112-
import { dataInspectorVitePlugin } from '@devframes/plugin-data-inspector/vite'
113+
import { devframeVite } from '@devframes/vite/dev-spa'
113114
import { defineConfig } from 'vite'
114115

115116
export default defineConfig({
116117
plugins: [
117-
dataInspectorVitePlugin(),
118+
devframeVite(dataInspectorDevframe),
118119
{
119120
name: 'my-app:data-sources',
120121
configureServer(server) {

‎docs/plugins/inspect.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ Opens the inspector against a fresh standalone devframe connection — handy as
4444

4545
```ts
4646
// vite.config.ts
47-
import { inspectVitePlugin } from '@devframes/plugin-inspect/vite'
47+
import inspectDevframe from '@devframes/plugin-inspect'
48+
import { devframeVite } from '@devframes/vite/dev-spa'
4849
import { defineConfig } from 'vite'
4950

5051
export default defineConfig({
5152
plugins: [
52-
inspectVitePlugin(),
53+
devframeVite(inspectDevframe),
5354
],
5455
})
5556
```

‎docs/plugins/og.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ pnpx @devframes/plugin-og
2424

2525
```ts
2626
// vite.config.ts
27-
import { ogVitePlugin } from '@devframes/plugin-og/vite'
27+
import ogDevframe from '@devframes/plugin-og'
28+
import { devframeVite } from '@devframes/vite/dev-spa'
2829
import { defineConfig } from 'vite'
2930

3031
export default defineConfig({
3132
plugins: [
32-
ogVitePlugin(),
33+
devframeVite(ogDevframe),
3334
],
3435
})
3536
```

‎packages/hub-ui/src/client/state/context.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { DevframeClientCommand, DevframeDockEntry, DevframeDockUserEntry, DevframeRpcClientFunctions, DevframeViewIframe } from '@devframes/hub'
2-
import type { CommandsContext, DevframeRpcClient, DockClientScriptContext, DockEntryState, DockPanelStorage, DockRegistration, DockRendererManifest, DocksContext } from '@devframes/hub/client'
2+
import type { CommandsContext, DevframeClientContext, DevframeRpcClient, DockClientScriptContext, DockEntryState, DockPanelStorage, DockRegistration, DockRendererManifest, DocksContext } from '@devframes/hub/client'
33
import type { SharedState } from 'devframe/utils/shared-state'
44
import type { WhenContext } from 'devframe/utils/when'
55
import type { Ref } from 'vue'
66
import type { DevframeDocksUserSettings } from './dock-settings'
7-
import { attachFrameNavClient } from '@devframes/hub/client'
7+
import { attachFrameNavClient, createDockRenderersContext } from '@devframes/hub/client'
88
import { DEFAULT_STATE_USER_SETTINGS, DOCK_RENDERERS_STATE_KEY } from '@devframes/hub/constants'
99
import { computed, markRaw, reactive, ref, toRefs, watch, watchEffect } from 'vue'
1010
import { BUILTIN_ENTRIES, BUILTIN_ENTRY_SETTINGS, DEFAULT_CATEGORIES_ORDER, HUB_UI_HIDE_EVENT } from '../constants'
@@ -14,7 +14,6 @@ import { docksGroupByCategories, getCategoryLabel, getGroupMembers, getGroupMemb
1414
import { createDockEntryState, DEFAULT_DOCK_PANEL_STORE, sharedStateToRef, useDocksEntries } from './docks'
1515
import { createClientMessagesClient } from './messages-client'
1616
import { registerMainFrameDockActionHandler, triggerMainFrameDockAction, useIsDockPopupOpen } from './popup'
17-
import { createDockRenderers } from './renderers'
1817
import { executeSetupScript } from './setup-script'
1918

2019
const docksContextByRpc = new WeakMap<DevframeRpcClient, DocksContext>()
@@ -538,7 +537,10 @@ export async function createDocksContext(
538537
},
539538
events: rpc.events,
540539
},
541-
renderers: markRaw(createDockRenderers(() => docksContext, () => rendererManifest.value)),
540+
renderers: markRaw(createDockRenderersContext({
541+
context: () => docksContext as DevframeClientContext,
542+
manifest: () => rendererManifest.value,
543+
})),
542544
rpc: markRaw(rpc),
543545
clientType,
544546
})

‎packages/hub-ui/src/client/state/renderers.ts‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎packages/hub/src/constants.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
import type { DevframeDocksUserSettings } from './types/settings'
2+
import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash } from 'ufo'
23

34
export * from 'devframe/constants'
45

6+
/** Default mount base for a hub instance — one namespace, one catch-all. */
7+
export const DEVFRAMES_HUB_BASE = '/__devframes/'
8+
9+
/**
10+
* Normalize a hub mount base to an absolute path with leading and trailing
11+
* slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled
12+
* slashes the input introduced. The one implementation every hub-aware
13+
* host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves
14+
* `options.base` through.
15+
*/
16+
export function normalizeHubBase(base: string): string {
17+
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)))
18+
}
19+
520
/**
621
* The default ordering weight for each known dock category — lower sorts
722
* earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the

‎packages/hub/src/node/initiate.ts‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import { createH3DevframeHost, createInstanceShell, resolveInstanceRegister } fr
1616
import { mountStaticHandler } from 'devframe/utils/serve-static'
1717
import { H3 } from 'h3'
1818
import { resolve } from 'pathe'
19-
import { cleanDoubleSlashes, joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } from 'ufo'
20-
import { DOCK_RENDERERS_STATE_KEY } from '../constants'
19+
import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo'
20+
import { DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, normalizeHubBase } from '../constants'
2121
import { createHubContext } from './context'
2222
import { diagnostics } from './diagnostics'
2323

@@ -35,8 +35,8 @@ function normalizeDevframeEntry(entry: DevframeDefinition | HubDevframeEntry): H
3535
return 'devframe' in entry ? entry : { devframe: entry }
3636
}
3737

38-
/** Default mount base for a hub instance — one namespace, one catch-all. */
39-
export const DEVFRAMES_HUB_BASE = '/__devframes/'
38+
/** Default mount base for a hub instance — re-exported from `../constants` (the client-safe home) for existing importers of this node entry. */
39+
export { DEVFRAMES_HUB_BASE }
4040

4141
/** Content-type for a UI asset key, inferred from its file extension. */
4242
function assetContentType(key: string): string {
@@ -333,10 +333,6 @@ function resolveDevframesInput(input: DevframesInput): Promise<HubDevframeEntry[
333333
.then(arrays => arrays.flat())
334334
}
335335

336-
function normalizeBase(base: string): string {
337-
return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base)))
338-
}
339-
340336
/**
341337
* Validate the renderer-module registrations fail-fast: route-safe types
342338
* (each becomes the `<base>__renderers/<type>.mjs` URL segment), one module
@@ -401,7 +397,7 @@ function renderClientImportsModule(ctx: DevframeHubContext): string {
401397
* through {@link HubInstance.attach}.
402398
*/
403399
export function initHub(options: InitHubOptions): HubInstance {
404-
const base = normalizeBase(options.base)
400+
const base = normalizeHubBase(options.base)
405401
const baseNoSlash = base.slice(0, -1)
406402
const app = new H3()
407403
const cwd = options.cwd ?? process.cwd()

0 commit comments

Comments
 (0)