import { type DesignSystemTheme } from "@agent-native/toolkit/design-system/theme"; import type { Plugin, UserConfig } from "vite"; import { type McpIntegrationsConfigInput } from "../shared/mcp-integration-config.js"; import { type AgentNativeRouteWarmupConfigInput } from "../shared/route-warmup-config.js"; /** * Wraps a single Nitro-provided Vite plugin so that, if it defines a * `hotUpdate` hook, any `environment.hot.send({ type: "full-reload" })` call * made from inside that hook is coalesced with a trailing debounce (leading * edge suppressed) instead of firing immediately for every changed file. * Everything else — module-graph invalidation, non-reload hot messages, the * hook's return value — passes through unchanged and immediate. A burst of * N changes within the debounce window collapses into exactly one * full-reload once things go quiet; a single isolated change still reloads, * just delayed by up to `NITRO_FULL_RELOAD_DEBOUNCE_MS`. * * `hotUpdate` only ever runs on Vite's dev server (never during a build), so * this has no effect outside `vite dev`. */ declare function debounceNitroFullReloadHotUpdate(plugin: Plugin): Plugin; /** * Build the `resolve.dedupe` list dynamically. Reads core's package.json and * collects every peerDependency that the consuming app also declares. This * ensures Vite resolves them from the app root, not from core's own * node_modules — preventing duplicate React context / singleton issues. */ declare function getClientDedupe(cwd: string): string[]; /** * Locate `packages/core/src` if we're inside the framework monorepo. * Shared between `getCoreSourceAliases` (which redirects imports to src/) * and `getDefaultOptimizeDeps` (which must NOT prebundle from dist/ when * the alias is active — otherwise the prebundle is built from a snapshot * of dist/ at startup and never picks up new exports). */ declare function findCorePackageRoot(cwd: string): string | null; /** * Pin react-router imports to the consuming app's install. pnpm keeps a peer * copy under `@agent-native/core/node_modules/react-router`; `resolve.dedupe` * alone can still leave SSR `Meta`/`Links` on a different FrameworkContext * than React Router's dev server router. */ declare function getReactRouterAliases(cwd: string): Array<{ find: RegExp; replacement: string; }>; declare function getDefaultOptimizeDeps(cwd: string): string[]; export interface NitroOptions { /** Nitro deployment preset (e.g. "node", "vercel", "netlify", "cloudflare_pages", "cloudflare_module"). Default: "node" */ preset?: string; /** Source directory for server files. Default: "./server" */ srcDir?: string; /** Routes directory name (relative to srcDir). Default: "routes" */ routesDir?: string; /** Any additional Nitro config overrides */ [key: string]: unknown; } export interface ClientConfigOptions { /** Port for dev server. Default: 8080 */ port?: number; /** Additional hostnames allowed to access the dev server. */ allowedHosts?: NonNullable["allowedHosts"]>; /** Vite log level. Workspace child apps default to "warn" so only the gateway URL is advertised. */ logLevel?: UserConfig["logLevel"]; /** Additional Vite plugins */ plugins?: any[]; /** Static design tokens emitted into the client build. */ designSystemTheme?: DesignSystemTheme; /** Nitro plugin options (preset, srcDir, etc) */ nitro?: NitroOptions; /** Override resolve aliases */ aliases?: Record; /** Override build.outDir. Default: "dist/spa" */ outDir?: string; /** Additional fs.allow paths */ fsAllow?: string[]; /** Additional fs.deny patterns */ fsDeny?: string[]; /** Additional Vite optimizeDeps configuration */ optimizeDeps?: NonNullable; /** Additional Vite define constants. */ define?: UserConfig["define"]; /** * Browser/server compatibility epoch for app changes that cannot safely run * across a cached client and a newer action backend. Bump only for an * incompatible protocol or data-model transition, not for every deploy. */ clientCompatibilityVersion?: string; /** * Framework route warmup behavior mounted by AgentSidebar. * * React Router's native prefetch warms both `.data` and JS, but its `.data` * request uses browser link prefetch. Chrome sends `Sec-Purpose: prefetch` * on those requests, which some production CDNs reject for dynamic `.data` * URLs before our SWR cache headers can help. Agent-Native therefore uses * ordinary fetches for `.data` and `modulepreload` for route JS by default. */ routeWarmup?: AgentNativeRouteWarmupConfigInput; /** * Controls the MCP integrations catalog exposed from the composer + menu. * * - `false` hides the whole MCP integrations entry. * - `{ defaults: false }` hides all bundled provider presets but still * allows custom MCP servers. * - `{ defaults: { include: ["context7"] } }` allows only those preset ids. * - `{ defaults: { exclude: ["stripe"] } }` hides specific preset ids. */ mcpIntegrations?: McpIntegrationsConfigInput; /** * Whether to auto-inject the Tailwind v4 Vite plugin (`@tailwindcss/vite`). * Defaults to true — set to `false` if a template wants to manage Tailwind * itself (e.g. the legacy v3 PostCSS pipeline). */ tailwind?: boolean; /** * Package names to stub in the SSR bundle with an empty proxy object. * * Use this for dependencies that only run in the browser (canvas / diagram * libraries, editors, WebGL) but would otherwise get pulled into the * server bundle via SSR's noExternal policy — pushing the CF Pages * Functions bundle over the 25 MiB limit. * * Only add packages that are provably never called during SSR. If the * server imports one, it will receive a Proxy that throws on any real * use (which is better than bundling a 10 MiB dep the worker never calls). * * @example * ssrStubs: ["mermaid", "@excalidraw/excalidraw"] */ ssrStubs?: string[]; /** * @deprecated Pass `reactRouter()` directly in the `plugins` array instead. * Previously used to auto-load the React Router Vite plugin via require(), * but this fails in ESM contexts. Templates should now do: * ```ts * import { reactRouter } from "@react-router/dev/vite"; * defineConfig({ plugins: [reactRouter()] }) * ``` */ reactRouter?: boolean | Record; } export interface AgentNativeVitePluginOptions extends Omit { /** * Include the legacy React SWC transform for non-React Router SPA apps. * * React Router framework-mode apps should pass `reactRouter()` as a normal * Vite plugin and leave this off. */ legacySpa?: boolean; } export declare function stripMountedDevApiPath(reqUrl: string | undefined, base: string | undefined): string | undefined; export declare function isFrameworkDevPath(reqUrl: string, base: string | undefined): boolean; declare function nitroModuleGraphSignature(environment: unknown): string | null; declare function nitroStartupGate(options?: { now?: () => number; settleMs?: number; timeoutMs?: number; }): Plugin; declare function nitroStartupRecovery(): Plugin; /** * Agent-Native's Vite plugin preset. * * Use this in ordinary Vite configs so `vite.config.ts` keeps Vite's native * `UserConfig` type surface: * * ```ts * import { defineConfig } from "vite"; * import { reactRouter } from "@react-router/dev/vite"; * import { agentNative } from "@agent-native/core/vite"; * * export default defineConfig({ * plugins: [reactRouter(), agentNative({ ssrStubs: ["shiki"] })], * }); * ``` */ export declare function agentNative(options?: AgentNativeVitePluginOptions): Plugin[]; /** * Create the client Vite config with sensible agent-native defaults. * * @deprecated Prefer `defineConfig` from `vite` plus the `agentNative()` plugin * preset. This compatibility wrapper remains for existing templates. */ export declare function defineConfig(options?: ClientConfigOptions): UserConfig; export { getClientDedupe as _getClientDedupe, getDefaultOptimizeDeps as _getDefaultOptimizeDeps, findCorePackageRoot as _findCorePackageRoot, getReactRouterAliases as _getReactRouterAliases, nitroStartupGate as _nitroStartupGate, nitroStartupRecovery as _nitroStartupRecovery, nitroModuleGraphSignature as _nitroModuleGraphSignature, debounceNitroFullReloadHotUpdate as _debounceNitroFullReloadHotUpdate, }; //# sourceMappingURL=client.d.ts.map