Samuel Shuert | 274a4d6 | 2023-12-01 15:04:55 -0500 | [diff] [blame^] | 1 | // Type definitions for source-map-support 0.5 |
| 2 | // Project: https://github.com/evanw/node-source-map-support |
| 3 | // Definitions by: Bart van der Schoor <https://github.com/Bartvds> |
| 4 | // Jason Cheatham <https://github.com/jason0x43> |
| 5 | // Alcedo Nathaniel De Guzman Jr <https://github.com/natealcedo> |
| 6 | // Griffin Yourick <https://github.com/tough-griff> |
| 7 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
| 8 | |
| 9 | export interface RawSourceMap { |
| 10 | version: 3; |
| 11 | sources: string[]; |
| 12 | names: string[]; |
| 13 | sourceRoot?: string; |
| 14 | sourcesContent?: string[]; |
| 15 | mappings: string; |
| 16 | file: string; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Output of retrieveSourceMap(). |
| 21 | * From source-map-support: |
| 22 | * The map field may be either a string or the parsed JSON object (i.e., |
| 23 | * it must be a valid argument to the SourceMapConsumer constructor). |
| 24 | */ |
| 25 | export interface UrlAndMap { |
| 26 | url: string; |
| 27 | map: string | RawSourceMap; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Options to install(). |
| 32 | */ |
| 33 | export interface Options { |
| 34 | handleUncaughtExceptions?: boolean | undefined; |
| 35 | hookRequire?: boolean | undefined; |
| 36 | emptyCacheBetweenOperations?: boolean | undefined; |
| 37 | environment?: 'auto' | 'browser' | 'node' | undefined; |
| 38 | overrideRetrieveFile?: boolean | undefined; |
| 39 | overrideRetrieveSourceMap?: boolean | undefined; |
| 40 | retrieveFile?(path: string): string; |
| 41 | retrieveSourceMap?(source: string): UrlAndMap | null; |
| 42 | /** |
| 43 | * Set false to disable redirection of require / import `source-map-support` to `@cspotcode/source-map-support` |
| 44 | */ |
| 45 | redirectConflictingLibrary?: boolean; |
| 46 | /** |
| 47 | * Callback will be called every time we redirect due to `redirectConflictingLibrary` |
| 48 | * This allows consumers to log helpful warnings if they choose. |
| 49 | * @param parent NodeJS.Module which made the require() or require.resolve() call |
| 50 | * @param options options object internally passed to node's `_resolveFilename` hook |
| 51 | */ |
| 52 | onConflictingLibraryRedirect?: (request: string, parent: any, isMain: boolean, options: any, redirectedRequest: string) => void; |
| 53 | } |
| 54 | |
| 55 | export interface Position { |
| 56 | source: string; |
| 57 | line: number; |
| 58 | column: number; |
| 59 | } |
| 60 | |
| 61 | export function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */; |
| 62 | export function getErrorSource(error: Error): string | null; |
| 63 | export function mapSourcePosition(position: Position): Position; |
| 64 | export function retrieveSourceMap(source: string): UrlAndMap | null; |
| 65 | export function resetRetrieveHandlers(): void; |
| 66 | |
| 67 | /** |
| 68 | * Install SourceMap support. |
| 69 | * @param options Can be used to e.g. disable uncaughtException handler. |
| 70 | */ |
| 71 | export function install(options?: Options): void; |
| 72 | |
| 73 | /** |
| 74 | * Uninstall SourceMap support. |
| 75 | */ |
| 76 | export function uninstall(): void; |