import binding = require('../binding'); import type { ParserConfig } from "@swc/types"; import type { ExtractedMessage, ExtractorCtx, ExtractorType } from "@lingui/conf"; import { LinguiMacroOptions } from "./macro-src/map-options"; export type { LinguiMacroOptions }; export type TransformOptions = { /** * The same options as in `jsc.parser` in `.swcrc` * https://swc.rs/docs/configuration/compilation#jscparser * * The syntax (ecmascript/typescript) and jsx support is automatically inferred from the filename, * you don't need to specify it manually */ parser?: ParserConfig; /** * Options for Lingui Macro */ macro?: LinguiMacroOptions; /** * Controls source map generation: * - `true` (default) — source map returned in `result.map` * - `"inline"` — source map appended to code as a base64 data URL, `result.map` is undefined * - `false` — no source map generated, `result.map` is undefined */ sourceMaps?: "inline" | boolean; }; export type TransformResult = { code: string; map?: string; }; /** * Transform source code by applying the Lingui macro transformation. * * This is a minimal SWC + Lingui transformer built as a single native library * for optimal performance. It only transforms Lingui macros and keeps everything * else as-is. * * Parser options are automatically inferred from the filename (.ts, .tsx, .js, .jsx, etc.) * * @param code - The source code to transform * @param filename - The filename (used for parser inference and source maps) * @param options - Optional transform options * @returns Promise resolving to transformed code and source map */ export declare function transform(code: string, filename: string, options?: TransformOptions): Promise; export type ExtractorOptions = { /** * The same options as in `jsc.parser` in `.swcrc` * https://swc.rs/docs/configuration/compilation#jscparser * * The syntax (ecmascript/typescript) and jsx support is automatically inferred from the filename, * you don't need to specify it manually */ parser?: ParserConfig; /** * Options for Lingui Macro * * Except of `descriptorFields` property which is always set to `All` in extraction */ macro?: Omit; }; export declare function extractMessages(sourceCode: string, filename: string, options?: ExtractorOptions): Promise; export declare function extractMessagesFromFiles(filePaths: string[], options?: ExtractorOptions): Promise; /** * Creates pluggable SWC Lingui Extractor implementation. * * Example: * * ```ts * // lingui.config.ts * defineConfig({ * extractors: [createSwcExtractor()], * }) * ``` * * Macro options automatically inherited from the Lingui Config. */ export declare function createSwcExtractor(options?: ExtractorOptions): ExtractorType & { extractFromFiles: (filenames: string[], onMessageExtracted: (msg: ExtractedMessage) => void, ctx: ExtractorCtx) => Promise; };