vite-plugin-react-server
Version:
Vite plugin for React Server Components (RSC)
24 lines • 1.18 kB
TypeScript
import type { RegExpOpt } from "../types.js";
/**
* Unified pattern matcher that consolidates pattern resolution logic
* used across resolveDirectiveMatcher and resolvePatternWithValues.
*
* This helper reduces code duplication and provides consistent pattern matching
* behavior across the codebase.
*/
export interface PatternMatcherOptions {
/** Values for string interpolation */
values?: Record<string, string>;
/** Whether to handle deserialized RegExp objects */
handleDeserialized?: boolean;
/** Default fallback function when no pattern matches */
fallback?: (input: string, moduleId?: string) => boolean;
/** Whether to throw error on invalid patterns (vs using fallback) */
throwOnInvalid?: boolean;
}
/**
* Creates a pattern matcher function from various pattern types.
* Consolidates logic from resolveDirectiveMatcher and resolvePatternWithValues.
*/
export declare function createPatternMatcher(pattern?: RegExpOpt, defaultPattern?: RegExpOpt | ((input: string, moduleId?: string) => boolean), options?: PatternMatcherOptions): (input: string, moduleId?: string) => boolean;
//# sourceMappingURL=createPatternMatcher.d.ts.map