/** * @license * Julian Cataldo * SPDX-License-Identifier: ISC */ import type { ImportAttribute, ImportDeclaration } from '@oxc-project/types'; import type { parseSync } from 'rolldown/utils'; type ParseSync = typeof parseSync; /** Resolve the OXC parser — bundled in Rolldown (Vite 8) or standalone. */ export declare function resolveParser(): Promise; export type ImportAttributeType = 'css' | 'css-lit'; export interface Options { /** Glob patterns for JS/TS files to transform (default: all JS/TS). */ include?: string[]; /** * Glob patterns to exclude from general transformation work. * * Files that contain `with { type: 'css' | 'css-lit' }` imports are still * transformed even if excluded, because bundlers do not handle these import * attributes natively. */ exclude?: string[]; /** * Force every CSS import to produce a specific output, regardless of * the per-import `type` attribute or SSR auto-detection. * * - `'CSSStyleSheet'` — always emit a constructable `CSSStyleSheet` * (even during SSR — make sure a polyfill is available). * - `'CSSResult'` — always emit a Lit `CSSResult` via `unsafeCSS()`. * * When unset (default), the output is determined per-import: * `type: 'css'` → `CSSStyleSheet` on the client, `CSSResult` in SSR; * `type: 'css-lit'` → `CSSResult` everywhere. */ outputMode?: 'CSSStyleSheet' | 'CSSResult'; /** Enable verbose logging. */ log?: boolean; /** **Experimental**. Enable HMR (Hot Module Replacement) for CSS modules. */ hmr?: boolean; } export declare const defaultOptions: Required>; /** * Virtual module prefix for per-CSS-file singletons. * * Full ID format: `virtual:csm/` where `` is a stable * SHA-256 digest of `mode + '\0' + absoluteCssPath`. A registry maps * each hash back to its metadata so the `load` hook can generate the * correct bootstrap code. * * We avoid embedding file-system paths in the virtual ID because * Rolldown (used by Vite 8+) misidentifies path-like virtual IDs as * real files and bypasses the `load` hook for export analysis. */ export declare const VIRTUAL_CSS_PREFIX = "virtual:csm/"; /** Metadata stored per virtual CSS module. */ export interface VirtualCssEntry { cssAbsPath: string; useLit: boolean; } /** Deterministic short hash for a mode + absolute CSS path pair. */ export declare function virtualCssKey(mode: string, cssAbsPath: string): string; export interface CssImportMatch { node: ImportDeclaration; type: ImportAttributeType; } /** * Returns the import-attribute `type` value if the attribute list * contains `type: 'css'` or `type: 'css-lit'`, otherwise `null`. */ export declare function getCssAttributeType(attributes: ImportAttribute[]): ImportAttributeType | null; /** * Scan the top-level body for CSS import declarations that carry a * recognised `with { type: … }` attribute. */ export declare function findCssImports(body: readonly ImportDeclaration[]): CssImportMatch[]; /** * Build the code for a virtual CSS module singleton. * * Every CSS file gets at most two virtual modules (one per mode: `sheet` or * `lit`). All JS files that `import … with { type: 'css' }` from the same * CSS file share the **same** virtual module — and therefore the same * `CSSStyleSheet` or `CSSResult` instance, exactly like a native CSS module * script would behave in the browser. * * @param cssAbsPath Absolute path of the CSS source file. * @param useLit `true` → emit a Lit `CSSResult`; `false` → `CSSStyleSheet`. * @param dev When set, prepend a DSD marker comment and (optionally) * inject an `import.meta.hot.accept` block for graceful HMR. */ export declare function buildVirtualModuleCode(cssAbsPath: string, useLit: boolean, dev?: { cssModuleId: string; injectHmr: boolean; }): string; export declare function standardCssModules(options?: Options): any; export {}; //# sourceMappingURL=index.d.ts.map