import { ZodCompilerPluginOptions } from "./unplugin/types.js"; //#region src/swc.d.ts /** * Minimal @swc/core option shape. zod-compiler keeps @swc/core optional so * non-SWC users do not install a native dependency just by using the package. * `inputSourceMap` matches @swc/core: a JSON string or a boolean — swc does * not accept map objects. */ interface SwcOptions { filename?: string | undefined; inputSourceMap?: boolean | string | undefined; sourceMaps?: boolean | "inline" | undefined; [key: string]: unknown; } interface SwcOutput { code: string; map?: string | undefined; [key: string]: unknown; } interface SwcCoreLike { transform(code: string, options?: SwcOptions): Promise; } /** * Plugin options that make sense for a transformer host. `apply` is Vite * lifecycle and `cache` is the bundler disk cache — the bridge keeps no * persistent cache, so hosts that need one must key transform results on * content themselves. `include`/`exclude` are honored: files they reject * pass through to SWC without the zod-compiler step. * * No `parallel` either: this is a per-file transformer, so whatever drives it * decides how many files run at once. A pool owned by a single `transform()` * call would compete with that instead of adding to it. */ type ZodCompilerSwcOptions = Omit & { /** * SWC is a transformer, not a bundler plugin host, so inline is the safe * default. Lean mode may emit virtual runtime imports that SWC cannot resolve * unless another tool handles them after SWC. */ codegenMode?: "inline" | "lean" | undefined; }; interface SwcBridgeDefaults { /** Options passed through to @swc/core.transform. */ swc?: SwcOptions | undefined; /** zod-compiler options. Defaults match the build plugins except codegenMode is "inline". */ zodCompiler?: ZodCompilerSwcOptions | undefined; } interface SwcBridgeTransformOptions extends SwcBridgeDefaults { /** Absolute or project-relative filename for schema discovery and SWC config resolution. */ filename: string; } interface SwcBridge { transform(code: string, options: SwcBridgeTransformOptions): Promise; transformFile(filename: string, options?: SwcBridgeDefaults): Promise; } declare function transform(code: string, options: SwcBridgeTransformOptions): Promise; declare function transformFile(filename: string, options?: SwcBridgeDefaults): Promise; declare function createSwcCompiler(defaults?: SwcBridgeDefaults): SwcBridge; /** * Test seam for the SWC bridge. It is exported because it is also useful for * custom hosts that already own a @swc/core-compatible transform function. */ declare function transformWithSwc(swc: SwcCoreLike, code: string, options: SwcBridgeTransformOptions): Promise; declare function zodCompiler(defaults?: SwcBridgeDefaults): SwcBridge; //#endregion export { SwcBridge, SwcBridgeDefaults, SwcBridgeTransformOptions, SwcCoreLike, SwcOptions, SwcOutput, ZodCompilerSwcOptions, createSwcCompiler, zodCompiler as default, transform, transformFile, transformWithSwc }; //# sourceMappingURL=swc.d.ts.map