/** * Mounts the Lit devframe ({@link createLitDevframe}) into the Vite DevTools * hub and bridges the page runtime's `import.meta.hot` transport to the * definition's `TimelineSource` port. Everything Vite-specific lives here: * the definition itself must keep running under `createDevServer()` with no * Vite installed. * * Vite DevTools 0.7+ is itself built on devframe, so its plugin context is a * devframe hub context: `ctx.install(definition)` serves the panel SPA from * the definition's `clientAssets`, registers its dock, and exposes its RPC * over the hub's authenticated WebSocket. That is all * `createPluginFromDevframe()` from `@vitejs/devtools-kit` does, so calling * `install` directly keeps DevTools an optional peer we never import at * runtime — the hook below is duck-typed, exactly as the panel's previous * dock registration was. * * @see plans/devframe-foundation.md */ import type { Plugin, ViteDevServer } from 'vite'; import type { DevframeDefinition } from 'devframe'; import type { FeatureSettings } from '../../types/timeline.js'; import type { SourceLocator } from '../source-locator.js'; import { type NodeActionsOptions } from './node-actions.js'; /** * The slice of the Vite DevTools hub context this plugin uses. Structurally a * subset of `ViteDevToolsNodeContext` from `@vitejs/devtools-kit/node`; * declared here so the package never imports that optional peer at runtime. * Install `@vitejs/devtools-kit` as a dev dependency to check it against the * real declarations. */ interface DevToolsHubContext { readonly viteServer?: ViteDevServer; /** Serve a devframe's SPA, register its dock, and run its `setup()`. */ install: (devframe: DevframeDefinition, options?: { base?: string; dock?: Record; }) => Promise; docks?: { activate?: (dockId: string, params?: Record) => void; }; commands?: { register?: (command: Record) => unknown; }; /** * The hub's host runtime. Structurally the slice of devframe's * `DevframeHost` {@link registerInstance} needs; `DevframeHubContext` * extends `DevframeNodeContext`, which carries it. */ host?: { resolveOrigin?: () => string; }; } declare module 'vite' { interface Plugin { /** Vite DevTools plugin hook, contributed by `@vitejs/devtools`. */ devtools?: { capabilities?: { dev?: boolean; build?: boolean; }; setup: (ctx: DevToolsHubContext) => void | Promise; }; } } export interface CreateLitDevframePluginOptions { version: string; /** * Read in `devtools.setup()`; when it returns false the panel is not * mounted. Defaults to always on. */ enabled?: () => boolean; features?: () => FeatureSettings | null; /** See {@link CreateLitDevframeOptions.configuredEditor}. */ configuredEditor?: () => string | undefined; /** Override the built panel SPA directory. Defaults to `dist/client`. */ clientAssets?: string; /** See {@link CreateLitDevframeOptions.sourceLocator}. */ sourceLocator?: () => SourceLocator; /** See {@link NodeActionsOptions.sourceDocs}. */ sourceDocs?: NodeActionsOptions['sourceDocs']; } /** * The Vite plugin that mounts the Lit devframe on the DevTools hub. Without * the hub nothing calls `devtools.setup()`, so the plugin serves the panel * on Vite's own server at {@link STANDALONE_PANEL_BASE} instead. */ export declare function createLitDevframePlugin(options: CreateLitDevframePluginOptions): Plugin; export {}; //# sourceMappingURL=vite.d.ts.map