source-map-resolver.d.ts•2.28 kB
import { Page } from 'playwright';
import { SourceMapConsumer } from 'source-map';
/**
* Represents a location in the original source code
*/
export interface SourceLocation {
file: string;
line: number;
column: number;
name?: string;
content?: string;
}
/**
* Resolves minified JavaScript locations back to original source files
* using source maps.
*/
export declare class SourceMapResolver {
private sourceMapCache;
private page;
private initialized;
private sourceMapUrls;
constructor(cacheSize?: number);
/**
* Initialize the resolver with a Playwright page.
* Sets up request interception to discover and fetch source maps.
*/
initialize(page: Page): Promise<void>;
/**
* Resolve a location in minified code to its original source location.
*
* @param url - The URL of the minified JavaScript file
* @param line - Line number in the minified file (1-indexed)
* @param column - Column number in the minified file (0-indexed)
* @returns Original source location or null if mapping fails
*/
resolveLocation(url: string, line: number, column: number): Promise<SourceLocation | null>;
/**
* Get source map from cache or load it
*/
private getOrLoadSourceMap;
/**
* Fetch a source map from a URL
*/
private fetchSourceMap;
/**
* Resolve a source map URL relative to the JavaScript file URL
*/
private resolveSourceMapUrl;
/**
* Extract source code context around a specific line
*/
private extractSourceContext;
/**
* Clear all cached source maps
*/
clearCache(): void;
/**
* Get source file content from any loaded source map
* Searches through all cached source maps to find the file
*/
getSourceContent(filePath: string): string | null;
/**
* Get all source files from loaded source maps
*/
getAllSourceFiles(): string[];
/**
* Get source map consumer for a specific URL
* Used for advanced source map operations
*/
getSourceMapConsumer(url: string): Promise<SourceMapConsumer | null>;
/**
* Cleanup resources
*/
destroy(): Promise<void>;
}
//# sourceMappingURL=source-map-resolver.d.ts.map