/** * StyleX integration for Nifra's Bun and Vite pipelines. * * The StyleX compiler stays an optional peer owned by the StyleX project. This module owns only the * Nifra boundary: transform route/component modules in both pipelines, emit client CSS through the * existing virtual stylesheet seam, and run the same transform without CSS for SSR. */ import type { BunPlugin } from "bun"; /** StyleX's module resolution option, kept structural so the compiler remains an optional peer. */ export interface StylexModuleResolution { readonly type: "commonJS" | "haste"; readonly rootDir: string; } /** Structural slice of `@babel/core` used by the adapter. */ export interface StylexBabelCompiler { transformAsync(source: string, options: Readonly>): Promise; } /** Structural slice of the StyleX Babel plugin used by the adapter. */ export interface StylexCompiler { withOptions(options: Readonly>): unknown; processStylexRules(rules: readonly unknown[], options: Readonly>): string; } /** Optional peer injection and compiler configuration shared by Bun and Vite adapters. */ export interface StylexPluginOptions { /** Inject `@babel/core` in tests or advanced integrations. Defaults to the optional peer. */ readonly babel?: StylexBabelCompiler; /** Inject `@stylexjs/babel-plugin` in tests or advanced integrations. */ readonly compiler?: StylexCompiler; /** Inject Babel syntax plugins. Defaults to the three official syntax peers. */ readonly syntaxPlugins?: { readonly flow: unknown; readonly jsx: unknown; readonly typescript: unknown; }; /** StyleX import sources to transform. Defaults to `stylex` and `@stylexjs/stylex`. */ readonly importSources?: readonly string[]; /** StyleX development transform mode. Defaults to Nifra's dev-server signal. */ readonly dev?: boolean; /** StyleX CSS layer output. Defaults to `true` for deterministic precedence. */ readonly useCSSLayers?: boolean; /** StyleX's module resolution policy. */ readonly unstable_moduleResolution?: StylexModuleResolution; /** Extra Babel plugins and presets merged before the StyleX plugin. */ readonly babelConfig?: { readonly plugins?: readonly unknown[]; readonly presets?: readonly unknown[]; }; } interface StylexBabelResult { readonly code?: unknown; readonly metadata?: unknown; } /** Build a Bun plugin that transforms StyleX and emits CSS for the browser or class maps for SSR. */ export declare function stylexBunPlugin(generate: "dom" | "ssr", options?: StylexPluginOptions): BunPlugin; /** Structural Vite plugin return type. Vite remains an optional peer of `@nifrajs/web`. */ export interface StylexVitePlugin { readonly name: string; transform(source: string, id: string): Promise<{ readonly code: string; readonly map?: null; } | undefined>; resolveId(id: string): string | undefined; load(id: string): string | undefined; } /** Build a Vite plugin that maps each transformed StyleX module to a virtual CSS asset. */ export declare function stylexVitePlugin(generate: "dom" | "ssr", options?: StylexPluginOptions): StylexVitePlugin; /** Convenience alias for apps that configure only a browser Vite build. */ export declare const stylexVite: (options?: StylexPluginOptions) => StylexVitePlugin; export {}; //# sourceMappingURL=stylex.d.ts.map