/** * @fileoverview Minimatch class - core pattern matching implementation * * This is the heart of minimatch-fast. The Minimatch class provides 100% API * compatibility with minimatch's Minimatch class while using picomatch * internally for faster and more secure pattern matching. * * Key features: * - Pattern compilation and caching for efficient repeated matching * - Full support for glob patterns: *, **, ?, [], {}, extglob * - Brace expansion using the 'braces' package * - Negation patterns with ! * - Comment patterns with # * - Cross-platform path handling (Windows and POSIX) * * Architecture: * 1. Constructor receives pattern and options * 2. Pattern is parsed and expanded (braces) * 3. Picomatch matchers are created for each expanded pattern * 4. match() method tests paths against all matchers * * Compatibility layer: * Some edge cases require special handling to match minimatch's exact behavior: * - Dotfiles (. and ..) are never matched by wildcards * - Negated character classes [^...] don't match dotfiles * - Backslash escapes in character classes ([\b] = literal 'b') * * @author 686f6c61 * @see https://github.com/686f6c61/minimatch-fast * @license MIT */ import type { MinimatchOptions, MMRegExp, ParseReturn, ParseReturnFiltered, Platform } from './types.js'; /** * Default maximum pattern length to prevent ReDoS attacks */ export declare const DEFAULT_MAX_PATTERN_LENGTH = 65536; /** * Minimatch class for glob pattern matching */ export declare class Minimatch { /** Original pattern passed to constructor */ pattern: string; /** Options used for matching */ options: MinimatchOptions; /** 2D array of parsed pattern parts after brace expansion (computed lazily on first access) */ private _set; /** * 2D array of parsed pattern parts after brace expansion. * Computed lazily: building it requires one regex per pattern part, which * matching itself does not need (matchers are compiled separately). */ get set(): ParseReturnFiltered[][]; /** Whether the pattern is negated (starts with !) */ negate: boolean; /** Whether the pattern is a comment (starts with #) */ comment: boolean; /** Whether the pattern is empty */ empty: boolean; /** Whether to preserve multiple consecutive slashes */ preserveMultipleSlashes: boolean; /** Whether to do partial matching */ partial: boolean; /** Result of brace expansion on the pattern */ globSet: string[]; /** Brace-expanded patterns split into path portions */ globParts: string[][]; /** Whether to perform case-insensitive matching */ nocase: boolean; /** Whether running on Windows */ isWindows: boolean; /** Target platform */ platform: Platform; /** Windows-specific magic root handling */ windowsNoMagicRoot: boolean; /** Compiled regular expression (lazily computed) */ regexp: false | null | MMRegExp; /** Whether backslash is treated as path separator */ windowsPathsNoEscape: boolean; /** Whether negation is disabled */ nonegate: boolean; private _picoOpts; private _matchers; private _debugFn; private _debugOn; private _hasNegatedCharClassCached; private _requiresTrailingSlashCached; private _canCrossSlashes; /** * Create a new Minimatch instance * * @param pattern - The glob pattern to match against * @param options - Matching options */ constructor(pattern: string, options?: MinimatchOptions); /** * Enable debug output */ private debug; /** * Check if the pattern contains glob magic characters */ hasMagic(): boolean; /** * Build the pattern matching set */ private make; /** * Parse negation from the pattern */ private parseNegate; /** * Perform brace expansion on the pattern */ braceExpand(): string[]; /** * Split a path by slashes */ slashSplit(p: string): string[]; /** * Preprocess glob parts (optimization, normalization) */ private preprocess; /** * Parse a single pattern part into a regex or string * * Literal parts (no glob magic) are returned as plain strings, matching * minimatch's behavior. This makes hasMagic() work correctly and avoids * regex compilation for literal segments. With nocase, literals are * compiled to regexes so that matching stays case-insensitive (this also * matches minimatch, where hasMagic() returns true for nocase patterns). */ private parse; /** * Run all compiled matchers against a string, returning true on first hit. * Uses a plain loop instead of .some() to avoid a closure allocation * per call - this is the hottest path in the library. */ private _matchAny; /** * Test if a path matches the pattern * * @param path - The path to test * @param partial - Whether to do partial matching * @returns true if the path matches */ match(path: string, partial?: boolean): boolean; /** * Pre-process pattern for minimatch compatibility * Handles edge cases where picomatch behaves differently */ private preprocessPattern; /** * Create a regular expression from the pattern * * @returns RegExp or false if pattern is invalid */ makeRe(): false | MMRegExp; /** * Match a file array against a pattern array * This is for internal use and advanced matching scenarios * * @param file - Array of path segments * @param pattern - Array of pattern parts * @param partial - Whether to do partial matching * @returns true if file matches pattern */ matchOne(file: string[], pattern: ParseReturn[], partial?: boolean): boolean; /** * Create a new Minimatch class with default options * * @param def - Default options to apply * @returns New Minimatch class with defaults */ static defaults(def: MinimatchOptions): typeof Minimatch; } //# sourceMappingURL=minimatch-class.d.ts.map