From 2fcf4c1a89acf2118a45f2749dde5184ba9fc44c Mon Sep 17 00:00:00 2001 From: "Anthony Fu (via agent)" Date: Sat, 15 Aug 2026 11:47:23 +0000 Subject: [PATCH 1/3] feat!: remove per-plugin vite wrappers; export hub base constants from @devframes/hub/constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- docs/guide/migration-0.9.md | 31 ++++++++++++++++ docs/plugins/a11y.md | 5 +-- docs/plugins/assets.md | 5 +-- docs/plugins/data-inspector.md | 5 +-- docs/plugins/inspect.md | 5 +-- docs/plugins/og.md | 5 +-- packages/hub-ui/src/client/state/context.ts | 10 +++--- packages/hub-ui/src/client/state/renderers.ts | 31 ---------------- packages/hub/src/constants.ts | 15 ++++++++ packages/hub/src/node/initiate.ts | 14 +++----- packages/next/package.json | 3 +- packages/next/src/hub-client.tsx | 4 +-- packages/next/src/hub.ts | 12 +++---- packages/nuxt/src/hub-client.ts | 4 +-- packages/nuxt/src/hub.ts | 13 ++----- packages/vite/src/hub-client.ts | 4 +-- packages/vite/src/hub.ts | 12 ++----- plugins/a11y/README.md | 1 - plugins/a11y/package.json | 2 -- plugins/a11y/src/vite.ts | 20 ----------- plugins/a11y/tsdown.config.ts | 1 - plugins/assets/README.md | 2 +- plugins/assets/package.json | 3 +- plugins/assets/src/spa/vite.config.ts | 5 +-- plugins/assets/src/vite.ts | 16 --------- plugins/assets/tsdown.config.ts | 1 - plugins/data-inspector/README.md | 4 ++- plugins/data-inspector/package.json | 3 +- plugins/data-inspector/src/spa/vite.config.ts | 13 +++---- plugins/data-inspector/src/vite.ts | 25 ------------- plugins/data-inspector/tsdown.config.ts | 1 - plugins/inspect/README.md | 5 +-- plugins/inspect/package.json | 3 +- plugins/inspect/src/spa/vite.config.ts | 5 +-- plugins/inspect/src/vite.ts | 15 -------- plugins/inspect/tsdown.config.ts | 1 - plugins/messages/package.json | 3 +- plugins/messages/src/vite.ts | 15 -------- plugins/messages/tsdown.config.ts | 1 - plugins/og/README.md | 2 +- plugins/og/package.json | 3 +- plugins/og/src/spa/vite.config.ts | 5 +-- plugins/og/src/vite.ts | 16 --------- plugins/og/tsdown.config.ts | 1 - pnpm-lock.yaml | 36 ++++++++----------- .../@devframes/hub/constants.snapshot.d.ts | 5 +++ .../@devframes/hub/constants.snapshot.js | 5 +++ .../@devframes/hub/initiate.snapshot.d.ts | 4 +-- .../@devframes/hub/initiate.snapshot.js | 4 +-- .../@devframes/plugin-a11y/vite.snapshot.d.ts | 10 ------ .../@devframes/plugin-a11y/vite.snapshot.js | 6 ---- .../plugin-assets/vite.snapshot.d.ts | 14 -------- .../@devframes/plugin-assets/vite.snapshot.js | 6 ---- .../plugin-data-inspector/vite.snapshot.d.ts | 10 ------ .../plugin-data-inspector/vite.snapshot.js | 6 ---- .../plugin-inspect/vite.snapshot.d.ts | 10 ------ .../plugin-inspect/vite.snapshot.js | 6 ---- .../plugin-messages/vite.snapshot.d.ts | 10 ------ .../plugin-messages/vite.snapshot.js | 6 ---- .../@devframes/plugin-og/vite.snapshot.d.ts | 14 -------- .../@devframes/plugin-og/vite.snapshot.js | 6 ---- 61 files changed, 143 insertions(+), 365 deletions(-) delete mode 100644 packages/hub-ui/src/client/state/renderers.ts delete mode 100644 plugins/a11y/src/vite.ts delete mode 100644 plugins/assets/src/vite.ts delete mode 100644 plugins/data-inspector/src/vite.ts delete mode 100644 plugins/inspect/src/vite.ts delete mode 100644 plugins/messages/src/vite.ts delete mode 100644 plugins/og/src/vite.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-a11y/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-a11y/vite.snapshot.js delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-assets/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-assets/vite.snapshot.js delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-data-inspector/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-data-inspector/vite.snapshot.js delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-inspect/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-inspect/vite.snapshot.js delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-messages/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-messages/vite.snapshot.js delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-og/vite.snapshot.d.ts delete mode 100644 tests/__snapshots__/tsnapi/@devframes/plugin-og/vite.snapshot.js diff --git a/docs/guide/migration-0.9.md b/docs/guide/migration-0.9.md index 8de11ec4..0a05e1fa 100644 --- a/docs/guide/migration-0.9.md +++ b/docs/guide/migration-0.9.md @@ -43,6 +43,12 @@ Each splits into two scoped subpaths — `.../dev-spa` (author one devframe's SP | `@devframes/next/client` | `@devframes/next/dev-spa/client` | | mount a hub inside a tool | `@devframes/{vite,nuxt,next}/hub` (+ `/hub/client`) | +**Built-in plugins** + +| Removed / moved | Replacement | +|---|---| +| `@devframes/plugin-{a11y,assets,data-inspector,inspect,messages,og}/vite` | `devframeVite(def, options)` from `@devframes/vite/dev-spa`, against the plugin's default export | + ## `devframe/adapters/cli` is removed 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({ `@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. +## Built-in plugins' `/vite` subpath is removed + +`a11yVitePlugin`, `assetsVitePlugin`, `dataInspectorVitePlugin`, `inspectVitePlugin`, `messagesVitePlugin`, and `ogVitePlugin` — each plugin's `@devframes/plugin-/vite` export — were one-line renames over `devframeVite(def, options)`. Call `devframeVite` directly against the plugin's default export instead: + +```ts +// 0.8.x +import { a11yVitePlugin } from '@devframes/plugin-a11y/vite' + +export default defineConfig({ + plugins: [a11yVitePlugin()], +}) +``` + +```ts +// 0.9 +import a11yDevframe from '@devframes/plugin-a11y' +import { devframeVite } from '@devframes/vite/dev-spa' + +export default defineConfig({ + plugins: [devframeVite(a11yDevframe)], +}) +``` + +`@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. + ## `@devframes/nuxt` and `@devframes/next` split into `/dev-spa` and `/hub` 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. diff --git a/docs/plugins/a11y.md b/docs/plugins/a11y.md index 4b82e26a..f7411e1c 100644 --- a/docs/plugins/a11y.md +++ b/docs/plugins/a11y.md @@ -56,12 +56,13 @@ Runs the panel alone, without a host page to scan — serves at `/__devframes_pl ```ts // vite.config.ts -import { a11yVitePlugin } from '@devframes/plugin-a11y/vite' +import a11yDevframe from '@devframes/plugin-a11y' +import { devframeVite } from '@devframes/vite/dev-spa' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ - a11yVitePlugin(), + devframeVite(a11yDevframe), ], }) ``` diff --git a/docs/plugins/assets.md b/docs/plugins/assets.md index 3cf9d555..11eb71a2 100644 --- a/docs/plugins/assets.md +++ b/docs/plugins/assets.md @@ -30,12 +30,13 @@ pnpx @devframes/plugin-assets --read-only # disable upload / rename / delete / m ```ts // vite.config.ts -import { assetsVitePlugin } from '@devframes/plugin-assets/vite' +import assetsDevframe from '@devframes/plugin-assets' +import { devframeVite } from '@devframes/vite/dev-spa' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ - assetsVitePlugin(), + devframeVite(assetsDevframe), ], }) ``` diff --git a/docs/plugins/data-inspector.md b/docs/plugins/data-inspector.md index ae06d6af..a0463722 100644 --- a/docs/plugins/data-inspector.md +++ b/docs/plugins/data-inspector.md @@ -107,14 +107,15 @@ pnpx @devframes/plugin-data-inspector attach # attach to a process ## Mount into a Vite host ```ts +import dataInspectorDevframe from '@devframes/plugin-data-inspector' import { registerDataSource } from '@devframes/plugin-data-inspector/registry' // vite.config.ts -import { dataInspectorVitePlugin } from '@devframes/plugin-data-inspector/vite' +import { devframeVite } from '@devframes/vite/dev-spa' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ - dataInspectorVitePlugin(), + devframeVite(dataInspectorDevframe), { name: 'my-app:data-sources', configureServer(server) { diff --git a/docs/plugins/inspect.md b/docs/plugins/inspect.md index 767f6e8b..e993d4d6 100644 --- a/docs/plugins/inspect.md +++ b/docs/plugins/inspect.md @@ -44,12 +44,13 @@ Opens the inspector against a fresh standalone devframe connection — handy as ```ts // vite.config.ts -import { inspectVitePlugin } from '@devframes/plugin-inspect/vite' +import inspectDevframe from '@devframes/plugin-inspect' +import { devframeVite } from '@devframes/vite/dev-spa' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ - inspectVitePlugin(), + devframeVite(inspectDevframe), ], }) ``` diff --git a/docs/plugins/og.md b/docs/plugins/og.md index ae8ab651..9de2438b 100644 --- a/docs/plugins/og.md +++ b/docs/plugins/og.md @@ -24,12 +24,13 @@ pnpx @devframes/plugin-og ```ts // vite.config.ts -import { ogVitePlugin } from '@devframes/plugin-og/vite' +import ogDevframe from '@devframes/plugin-og' +import { devframeVite } from '@devframes/vite/dev-spa' import { defineConfig } from 'vite' export default defineConfig({ plugins: [ - ogVitePlugin(), + devframeVite(ogDevframe), ], }) ``` diff --git a/packages/hub-ui/src/client/state/context.ts b/packages/hub-ui/src/client/state/context.ts index 07771410..437180d7 100644 --- a/packages/hub-ui/src/client/state/context.ts +++ b/packages/hub-ui/src/client/state/context.ts @@ -1,10 +1,10 @@ import type { DevframeClientCommand, DevframeDockEntry, DevframeDockUserEntry, DevframeRpcClientFunctions, DevframeViewIframe } from '@devframes/hub' -import type { CommandsContext, DevframeRpcClient, DockClientScriptContext, DockEntryState, DockPanelStorage, DockRegistration, DockRendererManifest, DocksContext } from '@devframes/hub/client' +import type { CommandsContext, DevframeClientContext, DevframeRpcClient, DockClientScriptContext, DockEntryState, DockPanelStorage, DockRegistration, DockRendererManifest, DocksContext } from '@devframes/hub/client' import type { SharedState } from 'devframe/utils/shared-state' import type { WhenContext } from 'devframe/utils/when' import type { Ref } from 'vue' import type { DevframeDocksUserSettings } from './dock-settings' -import { attachFrameNavClient } from '@devframes/hub/client' +import { attachFrameNavClient, createDockRenderersContext } from '@devframes/hub/client' import { DEFAULT_STATE_USER_SETTINGS, DOCK_RENDERERS_STATE_KEY } from '@devframes/hub/constants' import { computed, markRaw, reactive, ref, toRefs, watch, watchEffect } from 'vue' import { BUILTIN_ENTRIES, BUILTIN_ENTRY_SETTINGS, DEFAULT_CATEGORIES_ORDER, HUB_UI_HIDE_EVENT } from '../constants' @@ -14,7 +14,6 @@ import { docksGroupByCategories, getCategoryLabel, getGroupMembers, getGroupMemb import { createDockEntryState, DEFAULT_DOCK_PANEL_STORE, sharedStateToRef, useDocksEntries } from './docks' import { createClientMessagesClient } from './messages-client' import { registerMainFrameDockActionHandler, triggerMainFrameDockAction, useIsDockPopupOpen } from './popup' -import { createDockRenderers } from './renderers' import { executeSetupScript } from './setup-script' const docksContextByRpc = new WeakMap() @@ -538,7 +537,10 @@ export async function createDocksContext( }, events: rpc.events, }, - renderers: markRaw(createDockRenderers(() => docksContext, () => rendererManifest.value)), + renderers: markRaw(createDockRenderersContext({ + context: () => docksContext as DevframeClientContext, + manifest: () => rendererManifest.value, + })), rpc: markRaw(rpc), clientType, }) diff --git a/packages/hub-ui/src/client/state/renderers.ts b/packages/hub-ui/src/client/state/renderers.ts deleted file mode 100644 index 40a195b4..00000000 --- a/packages/hub-ui/src/client/state/renderers.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { - DevframeClientContext, - DockRendererManifest, - DockRenderersContext, - DocksContext, -} from '@devframes/hub/client' -import { createDockRenderersContext } from '@devframes/hub/client' - -/** - * The client-side dock-renderer registry required by the hub's `DocksContext`. - * Delegates to the hub's shared factory, so local-first resolution, lazy - * imports from the hub's renderer manifest (`initHub({ renderers })` → - * the `devframe:dock-renderers` shared-state slot), and the typed mount - * result behave exactly like `createDevframeClientHost`'s registry. - * - * hub-ui renders its native dock types directly in `ViewEntry.vue`; every - * other type routes through this registry via `ViewDockRenderer.vue` — e.g. a - * `'json-render'` dock renders with whatever implementation the host - * composed (`jsonRenderUiRenderer()` from `@devframes/json-render-ui/hub`, - * or any community renderer), and falls back to the missing-renderer view - * when none is present. - */ -export function createDockRenderers( - getContext: () => DocksContext, - manifest: () => DockRendererManifest, -): DockRenderersContext { - return createDockRenderersContext({ - context: () => getContext() as DevframeClientContext, - manifest, - }) -} diff --git a/packages/hub/src/constants.ts b/packages/hub/src/constants.ts index 35179d0b..f169e761 100644 --- a/packages/hub/src/constants.ts +++ b/packages/hub/src/constants.ts @@ -1,7 +1,22 @@ import type { DevframeDocksUserSettings } from './types/settings' +import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash } from 'ufo' export * from 'devframe/constants' +/** Default mount base for a hub instance — one namespace, one catch-all. */ +export const DEVFRAMES_HUB_BASE = '/__devframes/' + +/** + * Normalize a hub mount base to an absolute path with leading and trailing + * slashes (e.g. `devframes` → `/devframes/`), collapsing any doubled + * slashes the input introduced. The one implementation every hub-aware + * host (`@devframes/hub` itself, and the Vite/Nuxt/Next adapters) resolves + * `options.base` through. + */ +export function normalizeHubBase(base: string): string { + return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base))) +} + /** * The default ordering weight for each known dock category — lower sorts * earlier. Downstream viewers (e.g. `@vitejs/devtools-kit`) import this as the diff --git a/packages/hub/src/node/initiate.ts b/packages/hub/src/node/initiate.ts index 94395ebe..9c175d43 100644 --- a/packages/hub/src/node/initiate.ts +++ b/packages/hub/src/node/initiate.ts @@ -16,8 +16,8 @@ import { createH3DevframeHost, createInstanceShell, resolveInstanceRegister } fr import { mountStaticHandler } from 'devframe/utils/serve-static' import { H3 } from 'h3' import { resolve } from 'pathe' -import { cleanDoubleSlashes, joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } from 'ufo' -import { DOCK_RENDERERS_STATE_KEY } from '../constants' +import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo' +import { DEVFRAMES_HUB_BASE, DOCK_RENDERERS_STATE_KEY, normalizeHubBase } from '../constants' import { createHubContext } from './context' import { diagnostics } from './diagnostics' @@ -35,8 +35,8 @@ function normalizeDevframeEntry(entry: DevframeDefinition | HubDevframeEntry): H return 'devframe' in entry ? entry : { devframe: entry } } -/** Default mount base for a hub instance — one namespace, one catch-all. */ -export const DEVFRAMES_HUB_BASE = '/__devframes/' +/** Default mount base for a hub instance — re-exported from `../constants` (the client-safe home) for existing importers of this node entry. */ +export { DEVFRAMES_HUB_BASE } /** Content-type for a UI asset key, inferred from its file extension. */ function assetContentType(key: string): string { @@ -333,10 +333,6 @@ function resolveDevframesInput(input: DevframesInput): Promise arrays.flat()) } -function normalizeBase(base: string): string { - return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base))) -} - /** * Validate the renderer-module registrations fail-fast: route-safe types * (each becomes the `__renderers/.mjs` URL segment), one module @@ -401,7 +397,7 @@ function renderClientImportsModule(ctx: DevframeHubContext): string { * through {@link HubInstance.attach}. */ export function initHub(options: InitHubOptions): HubInstance { - const base = normalizeBase(options.base) + const base = normalizeHubBase(options.base) const baseNoSlash = base.slice(0, -1) const app = new H3() const cwd = options.cwd ?? process.cwd() diff --git a/packages/next/package.json b/packages/next/package.json index 6f5d8e3f..b669b7c5 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -74,8 +74,7 @@ } }, "dependencies": { - "h3": "catalog:deps", - "ufo": "catalog:deps" + "h3": "catalog:deps" }, "devDependencies": { "@devframes/hub": "workspace:*", diff --git a/packages/next/src/hub-client.tsx b/packages/next/src/hub-client.tsx index e33d1dba..980aaae3 100644 --- a/packages/next/src/hub-client.tsx +++ b/packages/next/src/hub-client.tsx @@ -2,13 +2,11 @@ import type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' import { createDevframeClientHost } from '@devframes/hub/client' +import { DEVFRAMES_HUB_BASE } from '@devframes/hub/constants' import { useEffect, useState } from 'react' export type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' -/** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */ -const DEVFRAMES_HUB_BASE = '/__devframes/' - export interface UseDevframeHubClientOptions extends DevframeClientHostOptions { /** * Hub mount base to connect to. Forwarded as `connect.baseURL` when no diff --git a/packages/next/src/hub.ts b/packages/next/src/hub.ts index 18834fc9..ac393672 100644 --- a/packages/next/src/hub.ts +++ b/packages/next/src/hub.ts @@ -1,6 +1,6 @@ import type { DevframeHubUi, HubInstance, InitHubOptions } from '@devframes/hub/initiate' -import { DEVFRAMES_HUB_BASE, initHub } from '@devframes/hub/initiate' -import { cleanDoubleSlashes, withLeadingSlash, withTrailingSlash } from 'ufo' +import { DEVFRAMES_HUB_BASE, normalizeHubBase } from '@devframes/hub/constants' +import { initHub } from '@devframes/hub/initiate' // The "bring your own DevframeHost" seam for `initHub({ context })`. export type { @@ -80,7 +80,7 @@ export interface NextDevframeHubOptions { * instead of leaking a side-car per reload. */ export async function createNextDevframeHub(options: NextDevframeHubOptions = {}): Promise { - const base = normalizeBase(options.base ?? DEVFRAMES_HUB_BASE) + const base = normalizeHubBase(options.base ?? DEVFRAMES_HUB_BASE) const ui = options.ui === false ? undefined @@ -149,7 +149,7 @@ function hubRegistry(): Map> { * ``` */ export function nextDevframeHub(options: NextDevframeHubOptions = {}): NextDevframeHubHandle { - const base = normalizeBase(options.base ?? DEVFRAMES_HUB_BASE) + const base = normalizeHubBase(options.base ?? DEVFRAMES_HUB_BASE) const ready = (): Promise => { const registry = hubRegistry() @@ -188,7 +188,3 @@ async function loadDefaultUi(): Promise { const mod = await import(/* webpackIgnore: true */ /* turbopackIgnore: true */ '@devframes/hub-ui') return (mod.createUi as () => DevframeHubUi)() } - -function normalizeBase(base: string): string { - return cleanDoubleSlashes(withTrailingSlash(withLeadingSlash(base))) -} diff --git a/packages/nuxt/src/hub-client.ts b/packages/nuxt/src/hub-client.ts index 9b836283..4aa43bd0 100644 --- a/packages/nuxt/src/hub-client.ts +++ b/packages/nuxt/src/hub-client.ts @@ -1,13 +1,11 @@ import type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' import type { Ref } from 'vue' import { createDevframeClientHost } from '@devframes/hub/client' +import { DEVFRAMES_HUB_BASE } from '@devframes/hub/constants' import { onScopeDispose, shallowRef } from 'vue' export type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' -/** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */ -const DEVFRAMES_HUB_BASE = '/__devframes/' - export interface UseDevframeHubClientOptions extends DevframeClientHostOptions { /** * Hub mount base to connect to. Forwarded as `connect.baseURL` when no diff --git a/packages/nuxt/src/hub.ts b/packages/nuxt/src/hub.ts index 2a15eed4..67383bac 100644 --- a/packages/nuxt/src/hub.ts +++ b/packages/nuxt/src/hub.ts @@ -1,10 +1,8 @@ import type { ViteDevframeHubOptions } from '@devframes/vite/hub' +import { DEVFRAMES_HUB_BASE, normalizeHubBase } from '@devframes/hub/constants' import { viteDevframeHub } from '@devframes/vite/hub' import { addVitePlugin, createResolver, defineNuxtModule } from '@nuxt/kit' -/** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */ -const DEVFRAMES_HUB_BASE = '/__devframes/' - export interface DevframeNuxtHubOptions extends Omit { /** * Inject `@devframes/hub-ui`'s floating-dock bootstrap (`embedded.js`) @@ -72,7 +70,7 @@ export default defineNuxtModule({ createResolver(import.meta.url) - const base = normalizeBase(options.base ?? DEVFRAMES_HUB_BASE) + const base = normalizeHubBase(options.base ?? DEVFRAMES_HUB_BASE) const { injectEmbedded, quiet: _quiet, ...hubOptions } = options // Wire the hub into Nuxt's own Vite dev server. `quiet: true` suppresses @@ -94,10 +92,3 @@ export default defineNuxtModule({ } }, }) - -function normalizeBase(base: string): string { - let out = base.startsWith('/') ? base : `/${base}` - if (!out.endsWith('/')) - out = `${out}/` - return out -} diff --git a/packages/vite/src/hub-client.ts b/packages/vite/src/hub-client.ts index db54446f..30158458 100644 --- a/packages/vite/src/hub-client.ts +++ b/packages/vite/src/hub-client.ts @@ -1,11 +1,9 @@ import type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' import { createDevframeClientHost } from '@devframes/hub/client' +import { DEVFRAMES_HUB_BASE } from '@devframes/hub/constants' export type { DevframeClientHost, DevframeClientHostOptions } from '@devframes/hub/client' -/** Default hub mount base — mirrors `@devframes/hub`'s `DEVFRAMES_HUB_BASE`. */ -const DEVFRAMES_HUB_BASE = '/__devframes/' - export interface MountDevframeHubClientOptions extends DevframeClientHostOptions { /** * Hub mount base to connect to. Forwarded as `connect.baseURL` when no diff --git a/packages/vite/src/hub.ts b/packages/vite/src/hub.ts index 3ab97a68..6741ed42 100644 --- a/packages/vite/src/hub.ts +++ b/packages/vite/src/hub.ts @@ -5,7 +5,8 @@ import type { DevframeDefinition } from 'devframe' import type { Plugin, ResolvedConfig, ViteDevServer } from 'vite' import { Server as NodeHttpServer } from 'node:http' import process from 'node:process' -import { DEVFRAMES_HUB_BASE, initHub } from '@devframes/hub/initiate' +import { DEVFRAMES_HUB_BASE, normalizeHubBase } from '@devframes/hub/constants' +import { initHub } from '@devframes/hub/initiate' export interface ViteDevframeHubOptions { /** @@ -115,7 +116,7 @@ function recommendViteDevtools(): void { * single devframe's own SPA, reach for `@devframes/vite/dev-spa` instead. */ export function viteDevframeHub(options: ViteDevframeHubOptions = {}): Plugin { - const base = normalizeBase(options.base ?? DEVFRAMES_HUB_BASE) + const base = normalizeHubBase(options.base ?? DEVFRAMES_HUB_BASE) let viteConfig: ResolvedConfig | undefined let instance: HubInstance | undefined // Set once the hub is up if its UI ships an `embedded.js` bootstrap — the @@ -248,10 +249,3 @@ function attachClientScripts( : { devframe: def, dock: { clientScript } } }) } - -function normalizeBase(base: string): string { - let out = base.startsWith('/') ? base : `/${base}` - if (!out.endsWith('/')) - out = `${out}/` - return out -} diff --git a/plugins/a11y/README.md b/plugins/a11y/README.md index a2d0c473..14021c09 100644 --- a/plugins/a11y/README.md +++ b/plugins/a11y/README.md @@ -118,7 +118,6 @@ pnpm -C plugins/a11y dev # from source: same, at /__devframes_plugin_a11 | `src/index.ts` | `.` | `createA11yDevframe()` + the default `DevframeDefinition`; `a11yAgentBundlePath` — the agent module a hub attaches as this dock's client script | | `src/node/index.ts` | `/node` | `setupA11y(ctx, options?)` — registers the RPC functions with the runtime config | | `src/cli.ts` | `/cli` | `createA11yCli()` — backs the `devframes_plugin_a11y` bin | -| `src/vite.ts` | `/vite` | `a11yVitePlugin()` — mounts the panel into a Vite host | | `src/client/index.ts` | `/client` | `connectA11y()` — typed browser RPC client wrapper | | `src/rpc/` | — | `get-config` static RPC + the type-safe client registry | | `src/shared/protocol.ts` | — | the agent ↔ panel `BroadcastChannel` contract | diff --git a/plugins/a11y/package.json b/plugins/a11y/package.json index 4d8697c0..caa26591 100644 --- a/plugins/a11y/package.json +++ b/plugins/a11y/package.json @@ -26,7 +26,6 @@ "./client": "./dist/client/index.mjs", "./cli": "./dist/cli.mjs", "./node": "./dist/node/index.mjs", - "./vite": "./dist/vite.mjs", "./package.json": "./package.json" }, "types": "./dist/index.d.mts", @@ -62,7 +61,6 @@ } }, "dependencies": { - "@devframes/vite": "workspace:*", "cac": "catalog:deps" }, "devDependencies": { diff --git a/plugins/a11y/src/vite.ts b/plugins/a11y/src/vite.ts deleted file mode 100644 index 0d85b270..00000000 --- a/plugins/a11y/src/vite.ts +++ /dev/null @@ -1,20 +0,0 @@ -import type { DevframeViteOptions, DevframeVitePlugin } from '@devframes/vite/dev-spa' -import { devframeVite } from '@devframes/vite/dev-spa' -import a11yDevframe from './index.ts' - -export type { DevframeViteOptions } - -/** - * Mount the a11y inspector panel into an existing Vite dev server. In the - * default static-mount mode it serves the built panel at - * `/__devframes_plugin_a11y/`; pass `{ bridge: true }` for the bridge mode - * where the host owns the SPA and devframe runs a side-car RPC + WS - * server. - * - * The in-page agent that scans the host is loaded separately: a hub loads it - * as this dock's client script (see {@link a11yAgentBundlePath}); a standalone - * host adds `