/** * Main Vite 8 plugin for czap -- processes `@token`, `@theme`, * `@style`, and `@quantize` CSS blocks, handles HMR, serves virtual * modules, and configures build environments. * * Transform pipeline order: tokens -- themes -- styles -- quantize. * This ordering ensures themes / styles can reference token custom * properties that were already compiled earlier in the pipeline. * * The factory is thin: it builds the explicit per-instance state — a * {@link PrimitiveResolutionCache} (the resolution + watch caches) and a * {@link WasmState} (the compute-binary state machine) — then wires the * standalone hook logic over it. The 4-phase CSS walk lives in * {@link transformCss} (testable without the Vite lifecycle), and the WASM * transitions live in `wasm-state.ts`; no hook communicates through hidden * closure `let`s. * * @module */ import type { Plugin } from 'vite'; /** * Configuration options for the {@link plugin} factory. Every field * is optional; omitted values use convention-based defaults. */ export interface PluginConfig { /** Override source directories for each primitive kind. */ readonly dirs?: Partial>; /** Toggle surgical HMR emission (default `true`). */ readonly hmr?: boolean; /** * `@quantize` viewport-containment options. * * `container` is the selector the auto-emitted viewport `@container` * containment is declared on — `:root` by default. Set it to a named * selector (e.g. `'.czap-vp'`) when `:root` can't be a container in your * layout (size containment removes `:root` from its parent's size calc, * which a fixed/absolute viewport-locked wrapper conflicts with); you then * own sizing that element to the viewport. Applies to both the CSS * transform and the emitted boundary assets. */ readonly quantize?: { readonly container?: string; }; /** Named Vite environments to configure (browser / server / shader). Defaults to browser when omitted. */ readonly environments?: readonly ('browser' | 'server' | 'shader')[]; /** * Emit each deduplicated boundary CSS output as an immutable build asset and * add `assetUrls` to `virtual:czap/boundaries`. Default `false`: manifests * still carry compiled strings only. */ readonly emitBoundaryAssets?: boolean; /** * WASM runtime configuration. Omitted (the default) **auto-detects**: the * deterministic 3-step search in {@link resolveWASM} runs, and the compute * binary is wired up automatically when one is found (no flag needed). Pass * `false` (or `{ enabled: false }`) to force it off, `true` (or * `{ enabled: true }`) to require it (warn if no binary resolves), or * `{ path }` to point at a specific binary. */ readonly wasm?: boolean | { readonly enabled?: boolean; readonly path?: string; }; } /** * Create the czap Vite plugin. * * Transforms CSS files containing `@token`, `@theme`, `@style`, and * `@quantize` blocks into native CSS custom properties, * `html[data-theme]` selectors, scoped `@layer` / `@scope` rules, and * `@container` queries respectively. Uses convention-based definition * resolution and provides HMR support for surgical CSS and shader * uniform updates. * * @example * ```ts * // vite.config.ts * import { czap } from '@czap/vite'; * const config = { plugins: [czap()] }; * ``` */ export declare function plugin(config?: PluginConfig): Plugin; //# sourceMappingURL=plugin.d.ts.map