/** * Standalone `@token` / `@theme` / `@style` / `@quantize` CSS transform. * * This is the 4-phase CSS walk lifted out of the Vite plugin's `transform` * hook into a pure function over an explicit {@link TransformCssContext}, so * it is testable without the Vite plugin lifecycle: pass a `warn` sink, a * {@link PrimitiveResolutionCache}, the project root + dirs, and you exercise * the whole pipeline directly. * * 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. * * Composition over inheritance: standalone functions over an explicit context * record, no classes. * * @module */ import type { PrimitiveResolutionCache } from './primitive-resolution-cache.js'; import type { BoundaryDefinitionMap } from './boundary-manifest.js'; /** Convention source directory overrides per primitive kind. */ export interface PrimitiveDirs { readonly boundary?: string; readonly token?: string; readonly theme?: string; readonly style?: string; } /** * Explicit context for {@link transformCss}: everything the transform needs * that the Vite plugin lifecycle would otherwise hide in a closure or on * `this`. * * - `warn` — doctor-style warning sink (the Rollup `this.warn` in production). * - `addWatchFile` — optional convention-file watch registrar (the Rollup * `this.addWatchFile`; absent in unit tests / outside watch mode, where * watch registration is a legitimate no-op). * - `cache` — shared resolution caches (read + populated here). * - `projectRoot` / `dirs` — convention-resolution inputs. */ export interface TransformCssContext { warn(message: string): void; addWatchFile?(id: string): void; readonly cache: PrimitiveResolutionCache; readonly projectRoot: string; readonly dirs?: PrimitiveDirs; readonly boundaryDefinitions?: BoundaryDefinitionMap; /** Selector for the auto-emitted viewport `@container` containment (default `:root`). */ readonly quantizeContainer?: string; } /** * Run the 4-phase CSS transform on a single sheet. Returns the rewritten CSS, * or `null` when nothing changed (no `@czap` at-rules, or every block was * left untransformed). Emits doctor-style warnings through `ctx.warn`, and * re-registers resolved convention files through `ctx.addWatchFile`. * * Behaviour is identical to the in-plugin transform it was lifted from: the * deterministic token→theme→style→quantize ordering, the per-kind resolution * caching, the parse-miss / empty-quantize / unresolved-primitive warnings, * and the sheet-level viewport-containment aggregation. */ export declare function transformCss(code: string, id: string, ctx: TransformCssContext): Promise; /** * Find the full span of an at-rule block in CSS source. * Returns the start/end character offsets, or null if not found. * * Works for any at-rule pattern: `@token`, `@theme`, `@style`, * `@quantize`. Searches and brace-counts on a comment- and * string-blanked copy of the source (same offsets, via * {@link blankCssCommentsAndStrings}), so marker text inside comments, * string values (`content: "@token x {"`), or unquoted data URLs never * matches, and braces inside those constructs never skew the depth * count. The returned offsets splice the ORIGINAL source. */ export declare function findAtRuleBlock(css: string, marker: string, name: string): { start: number; end: number; } | null; //# sourceMappingURL=transform-css.d.ts.map