/**
 * Shared code transformation utilities.
 * Extracted from next-dev-server.ts and vite-dev-server.ts to avoid duplication
 * and enable AST-based replacements.
 */
/**
 * Interface for file system operations needed by CSS module transforms.
 */
export interface CssModuleContext {
    readFile: (path: string) => string;
    exists: (path: string) => boolean;
}
/**
 * Resolve a relative path from a directory.
 * Pure function — no dependencies.
 */
export declare function resolveRelativePath(dir: string, relativePath: string): string;
/**
 * Resolve a CSS module path relative to the current file context.
 */
export declare function resolveCssModulePath(cssPath: string, currentFile: string | undefined, ctx: CssModuleContext): string | null;
/**
 * Generate replacement code for a CSS Module import.
 * Parses the CSS file, extracts class names, generates scoped names,
 * and injects the scoped CSS via a style tag.
 */
export declare function generateCssModuleReplacement(varName: string, cssPath: string, currentFile: string | undefined, ctx: CssModuleContext): string;
/**
 * Strip CSS imports from code (they are loaded via <link> tags instead).
 * CSS Module imports (*.module.css) are converted to inline objects with class name mappings.
 * Regular CSS imports are stripped entirely.
 */
export declare function stripCssImports(code: string, currentFile: string | undefined, ctx: CssModuleContext): string;
/**
 * Redirect bare npm package imports to esm.sh CDN.
 * Uses acorn AST to precisely target import/export source strings,
 * avoiding false matches inside comments or string literals.
 * Falls back to regex if acorn fails.
 *
 * @param additionalLocalPackages - Extra packages to skip (not redirected to CDN).
 *   Used by frameworks that add their own import map entries (e.g., Convex demo).
 * @param dependencies - Dependency versions from package.json (e.g., {"ai": "^4.0.0"}).
 *   Used to include major version in esm.sh URLs for correct subpath resolution.
 * @param installedPackages - Packages installed in VFS node_modules. These are
 *   served from /_npm/ instead of esm.sh, giving us full control over resolution.
 * @param npmUrlPrefix - Prefix for /_npm/ URLs (e.g., '/__virtual__/3000') so
 *   requests keep their runtime-instance context instead of relying on the
 *   service worker's Referer-based port recovery.
 */
export declare function redirectNpmImports(code: string, additionalLocalPackages?: string[], dependencies?: Record<string, string>, esmShDeps?: string, installedPackages?: Set<string>, npmUrlPrefix?: string): string;
/**
 * ESM to CJS transform using acorn AST parsing.
 * Used in non-browser (test) environments where esbuild is unavailable.
 * Falls back to regex if acorn fails to parse.
 */
export declare function transformEsmToCjsSimple(code: string): string;
/**
 * Add React Refresh registration to transformed code.
 * This enables true HMR (state-preserving) for React components.
 * Shared between NextDevServer and ViteDevServer.
 */
export declare function addReactRefresh(code: string, filename: string): string;
//# sourceMappingURL=code-transforms.d.ts.map