import { EnvVariable, ParsedEnvFile } from '../types/index.js'; /** * Environment File Parser * * Parses .env files into structured format, handling all edge cases: * - Comments (# and //) * - Empty lines * - Quoted values (single and double quotes) * - Multi-line values * - Inline comments * - Escape sequences */ export declare class EnvFileParser { /** * Parse .env file into map of variables * * @param filePath - Path to .env file * @returns Map of key to EnvVariable */ parse(filePath: string): Map; /** * Parse .env file, keeping the trivia that follows the last variable * * @param filePath - Path to .env file */ parseFile(filePath: string): ParsedEnvFile; /** * Parse .env content. * * Preserves each variable's exact original text and the comment/blank lines * above it, so a file can be rewritten without disturbing anything the caller * did not explicitly change. * * @param content - Raw .env file content */ parseContent(content: string): ParsedEnvFile; /** * Convert variable map back to .env format * * A variable that still carries its original text is re-emitted verbatim, so * rewriting a file never reformats — or corrupts — entries the caller did not * touch. Only added or modified variables are serialised from their fields. * * @param vars - Map of key to EnvVariable * @param trailingTrivia - Comment/blank lines to append after the last variable * @returns Formatted .env file content */ stringify(vars: Map, trailingTrivia?: string[]): string; /** * Render a variable as a `KEY=value` line * * @param variable - Variable to render */ private serialize; /** * Parse a single line (or multiline buffer) into EnvVariable * * @param line - Line to parse * @param lineNumber - Line number in file * @param knownKey - Optional key if already parsed (for multiline) * @returns EnvVariable or null if invalid */ private parseLine; /** * Parse value part of KEY=VALUE * * @param valuePart - String after the = sign * @returns Parsed value information */ private parseValue; /** * Unescape value based on quote type * * @param value - Escaped value * @param quoteType - Type of quotes used * @returns Unescaped value */ private unescapeValue; /** * Re-encode a value for writing inside quotes * * Inverse of unescapeValue. Without this, a decoded backslash or newline * would be written raw and break the file on the next read. * * @param value - Decoded value * @param quoteType - Type of quotes being used */ private escapeValue; /** * Find index of inline comment (# or //) * * Both markers require preceding whitespace (or the start of the value), so * that `sk_live_51H8x#special` and `http://example.com` stay intact. * * @param line - Line to search * @returns Index of comment start, or -1 if none */ private findInlineComment; /** * Extract inline comment from string * * @param str - String potentially containing comment * @returns Comment or undefined */ private extractInlineComment; /** * Check if line is a comment * * @param line - Line to check * @returns True if comment line */ private isComment; /** * Check if line starts a multiline value * * @param line - Line to check * @returns Key if multiline starts, null otherwise */ private startsMultiline; /** * Check if multiline value is complete * * @param buffer - Accumulated multiline buffer * @returns True if complete */ private isMultilineComplete; /** * Validate environment variable key * * @param key - Key to validate * @returns True if valid */ private isValidKey; } //# sourceMappingURL=EnvFileParser.d.ts.map