export interface SourceMapResolution { targetFilePath: string; targetLineNumber: number; targetColumnNumber: number; sourceMapInfo: { success: boolean; sourceMapUsed?: string | undefined; matchedSource?: string | undefined; }; } /** * Resolves TypeScript<->JavaScript coordinates against `*.js.map` files. * * Maintains two caches keyed by file mtime/size: * * 1. `traceMapCache` -- parsed {@link TraceMap} per `.map` file, plus a * `sourcesByBasename` index for O(1) source-name lookups. * 2. `sourceMapListingCache` -- short-TTL directory listings so repeat * breakpoint placements do not rescan the build directory. * * All public methods accept and return DAP/MCP 1-based line / column numbers * and convert to the trace-mapping 0-based column convention internally. * Cache invalidation is automatic: rebuilds are paid only for `.map` files * whose mtime+size actually changed on disk. */ export declare class SourceMapResolver { private readonly traceMapCache; private readonly sourceMapListingCache; private readonly mapsByBasename; private addBasenamesForMap; private removeBasenamesForMap; private getTraceMap; private static readonly SKIP_DIR_NAMES; private collectSourceMapFiles; private findSourceMapsInDirs; private siblingMapCandidates; /** * Heuristic for paths that may have a corresponding source map. * * - Authored TypeScript (`.ts/.tsx/.mts/.cts`) is always considered original * because that is the canonical input shape for this server. * - Plain JavaScript (`.js/.jsx/.mjs/.cjs`) is considered original only when * either (a) the path sits under SOURCE_DIR_MARKER (looks like authored * source kept in `/src/...`) or (b) an adjacent `.map` exists. Both * gates are cheap and prevent every plain-JS breakpoint placement from * kicking off a project-wide source-map discovery scan when the file has * no source map at all (the common case for runtime/node_modules JS). */ private looksLikeOriginalSource; /** * Resolve source map position for TypeScript/JavaScript mapping. * columnNumber is required: resolveGeneratedPosition rejects 0 (1-based check), * so a default of 0 caused every defaulted call to silently fall back to the * original path. Callers must pass a real 1-based column. */ resolveSourceMapPosition(filePath: string, lineNumber: number, columnNumber: number): Promise; /** * Typed internal entry point. Public `resolveGeneratedPosition` wraps this in * an MCP envelope; in-process callers (e.g. {@link resolveSourceMapPosition}) * consume the typed result directly. */ private resolveGeneratedPositionInternal; resolveGeneratedPosition(originalSource: string, originalLine: number, originalColumn: number, sourceMapPaths?: string[], originalSourcePath?: string): Promise<{ content: Array<{ type: string; text: string; }>; }>; resolveOriginalPosition(generatedLine: number, generatedColumn: number, sourceMapPaths?: string[], generatedSourcePath?: string): Promise<{ content: Array<{ type: string; text: string; }>; }>; private collectMapFilesForResolve; private matchSource; /** * Drop the cached directory listing of `.js.map` files. Use after a known * rebuild when waiting up to {@link SOURCE_MAP_LISTING_TTL_MS} for the TTL * to expire is not acceptable -- e.g. an AI agent that just triggered a * build and immediately wants to set a breakpoint on the freshly emitted * file. Passing `roots` clears only matching entries; passing nothing * clears the whole listing cache. The parsed trace-map cache is keyed by * mtime+size and self-invalidates per file, so it stays intact. */ invalidateSourceMapListing(roots?: string[]): void; /** * Drop the parsed {@link TraceMap} cache entry for a single `.map` file, or * the whole cache when no argument is passed. The cache is already keyed by * mtime+size, so callers rarely need this -- it exists for tests and for * recovery from cases where an upstream tool rewrote a map atomically with * the same size+mtime. * * Also keeps the cross-map basename index ({@link mapsByBasename}) in sync * so subsequent resolves do not get pointed at maps that are no longer in * the parsed cache. */ invalidateTraceMap(mapFile?: string): void; private suggestSimilarSources; } //# sourceMappingURL=source-map-resolver.d.ts.map