import { Plugin } from "vite"; //#region src/css/compile.d.ts interface StyleCompileResult { code: string; css: string; mapping: Record; stats: { folded: number; precompiled: number; }; /** Literal declarations, including inactive variants, for canonical asset output. */ rules: StyleDeclaration[]; } interface StyleDeclaration { property: string; value: string | null; pseudo: string; condition: string; } interface StyleDirectoryResult { outputDir: string; files: number; stats: StyleCompileResult["stats"]; elapsedMs: number; written: number; } //#endregion //#region src/css/vite-compile.d.ts interface LunaCssBuildContext { inputDir: string; outputDir: string; command: "serve" | "build"; signal: AbortSignal; result: StyleDirectoryResult; } interface LunaCssCompileOptions { /** A complete MoonBit module/workspace, relative to Vite root. */ input: string; /** Compiler-owned directory outside input, relative to Vite root. */ outputDir: string; cssPackage?: string; /** Delay after the latest filesystem event. Defaults to 30ms. */ debounceMs?: number; /** * Default: moon build --target js, with --release for vite build. * Override to integrate a server/client build pipeline. Honor signal on shutdown. * Set false only if another integration compiles the generated MoonBit sources. */ build?: false | ((context: LunaCssBuildContext) => void | Promise); } /** Static CSS preprocessing + MoonBit compilation, shared by Vite dev and build. */ export declare function lunaCssCompile(options: LunaCssCompileOptions): Plugin; //#endregion //#region src/vite-plugin.d.ts export type OutputMode = "inline" | "external" | "auto"; export interface LunaCssPluginOptions { /** * Source directories to extract CSS from * @default ["src"] */ src?: string | string[]; /** * Output mode: "inline" embeds in HTML, "external" creates .css file, "auto" chooses by size * @default "auto" */ mode?: OutputMode; /** * Size threshold in bytes for "auto" mode * @default 4096 */ threshold?: number; /** * CSS filename for external mode (without hash, Vite will add hash in build) * @default "luna.css" */ cssFileName?: string; /** * Enable verbose logging * @default false */ verbose?: boolean; /** * Enable CSS splitting by directory * When enabled, generates per-directory CSS chunks + shared CSS * @default false */ split?: boolean; /** * Minimum usage count for a declaration to be considered "shared" * Only used when split is enabled * @default 3 */ sharedThreshold?: number; /** * Include runtime CSS fallback in dev mode * Generates CSS dynamically for missing rules with console warnings * The runtime uses import.meta.env.DEV for tree-shaking in production * @default true in dev, false in build */ devRuntime?: boolean; /** * Inject dev runtime script into HTML automatically * When false, users must manually import "virtual:luna-css-runtime" * @default true */ injectRuntime?: boolean; /** * Experimental features */ experimental?: { /** * Enable CSS co-occurrence optimization * Merges frequently co-occurring classes into single combined classes * @default false */ optimize?: boolean; /** * Minimum frequency for a pattern to be merged * @default 2 */ optimizeMinFrequency?: number; /** * Maximum pattern size to consider for merging * @default 5 */ optimizeMaxPatternSize?: number; }; } /** * Luna CSS Vite Plugin * * @example * ```ts * // vite.config.ts * import { lunaCss } from "@luna_ui/luna/vite-plugin"; * * export default defineConfig({ * plugins: [ * lunaCss({ * src: ["src/examples/todomvc"], * mode: "auto", * threshold: 4096, * }), * ], * }); * ``` * * @example * ```ts * // main.ts - Import virtual CSS like Tailwind * import "virtual:luna.css"; * ``` * * @example * ```ts * // Split mode with per-directory chunks * lunaCss({ * src: ["src"], * split: true, * sharedThreshold: 3, * }) * * // In your entry: * import "virtual:luna.css"; // All CSS * // Or for fine-grained control: * import "virtual:luna-shared.css"; // Shared CSS only * import "virtual:luna-chunk/todomvc.css"; // Per-directory chunk * ``` */ export declare function lunaCss(options?: LunaCssPluginOptions): Plugin; //#endregion export { type LunaCssBuildContext, type LunaCssCompileOptions, lunaCss as default };