import { Plugin } from 'vite'; import { SolutionFinder } from '@visulima/error/solution'; export type { Solution, SolutionFinder } from '@visulima/error/solution'; import { Properties } from 'csstype'; /** * Framework hint used to route framework-aware solutions. When omitted, the plugin * auto-detects the framework from the configured Vite plugins. */ type Framework = "preact" | "react" | "solid" | "svelte" | "vue"; /** * Balloon position options */ type BalloonPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right"; /** * Custom style options for the balloon trigger * Can be either a CSS string or a CSS.Properties object */ type BalloonStyle = string | Properties; /** * Balloon configuration options */ interface BalloonConfig { readonly enabled?: boolean; readonly icon?: string; readonly position?: BalloonPosition; readonly style?: BalloonStyle; } /** * Overlay configuration options */ interface OverlayConfig { readonly balloon?: BalloonConfig; /** * Custom CSS to inject into the overlay for styling customization. * This CSS will be injected into the shadow DOM and can be used to override * the default styles of the overlay and button elements. * Can be either a CSS string or a CSS.Properties object. */ readonly customCSS?: string | Properties; } /** * Options accepted by the `@visulima/vite-overlay` plugin. */ interface VisulimaViteOverlayOptions { /** * Whether client runtime errors are forwarded to (and displayed in) the overlay. * @default true */ readonly forwardConsole?: boolean; /** * Console method names to forward from the client (e.g. `["error", "warn"]`). * @default ["error"] */ readonly forwardedConsoleMethods?: string[]; /** * Explicitly set the framework used for framework-aware hints. When omitted, the plugin * auto-detects React / Vue / Svelte / Preact / Solid from the configured Vite plugins. */ readonly framework?: Framework; /** * Capture process-wide `unhandledRejection` events and render them in the overlay. * Set to `false` to leave Node's default crash semantics untouched (useful when other * tooling in the dev process produces unrelated rejections). * @default true */ readonly interceptUnhandledRejection?: boolean; /** * @deprecated Use {@link VisulimaViteOverlayOptions.forwardConsole} instead. */ readonly logClientRuntimeError?: boolean; /** * Overlay UI configuration (balloon button, custom CSS). */ readonly overlay?: OverlayConfig; /** * Custom Preact plugin name to match during auto-detection. */ readonly preactPluginName?: string; /** * Custom React plugin name to match during auto-detection. */ readonly reactPluginName?: string; /** * @deprecated Misspelling of {@link VisulimaViteOverlayOptions.showBalloonButton}. Kept for * backward compatibility; prefer `showBalloonButton` or `overlay.balloon.enabled`. */ readonly showBallonButton?: boolean; /** * Whether to show the balloon button. * @default true */ readonly showBalloonButton?: boolean; /** * Custom Solid plugin name to match during auto-detection. */ readonly solidPluginName?: string; /** * Custom solution finders to run before the built-in finders. */ readonly solutionFinders?: SolutionFinder[]; /** * Custom Svelte plugin name to match during auto-detection. */ readonly sveltePluginName?: string; /** * Custom Vue plugin name to match during auto-detection. */ readonly vuePluginName?: string; } /** * Creates a solution finder specifically designed for Vite-related errors. * Provides intelligent suggestions for common Vite import resolution and configuration issues. * @param rootPath The root path of the project * @returns A solution finder object for Vite-specific error handling */ declare const createViteSolutionFinder: (rootPath: string) => SolutionFinder; /** * Main Vite plugin for error overlay functionality. * Intercepts runtime errors and displays them in a user-friendly overlay. * @param options Plugin configuration options * @param options.forwardConsole Whether to log client runtime errors (optional) * @param options.forwardedConsoleMethods Array of console method names to forward (optional) * @param [options.logClientRuntimeError] [deprecated] Use forwardConsole instead * @param options.reactPluginName Custom React plugin name (optional) * @param options.solutionFinders Custom solution finders (optional) * @param options.vuePluginName Custom Vue plugin name (optional) * @param options.sveltePluginName Custom Svelte plugin name (optional) * @param options.preactPluginName Custom Preact plugin name (optional) * @param options.solidPluginName Custom Solid plugin name (optional) * @param options.framework Explicit framework override; skips auto-detection (optional) * @param options.interceptUnhandledRejection Capture process-wide unhandled rejections (optional, default true) * @param options.showBalloonButton Whether to show the balloon button (optional) * @param options.showBallonButton [deprecated] Misspelling of showBalloonButton * @param options.overlay Overlay configuration (optional) * @returns The Vite plugin configuration */ declare const errorOverlayPlugin: (options?: VisulimaViteOverlayOptions) => Plugin; export { type BalloonConfig, type BalloonPosition, type BalloonStyle, type Framework, type OverlayConfig, type VisulimaViteOverlayOptions, createViteSolutionFinder, errorOverlayPlugin as default };