|
| 1 | +import { SourceMapConsumer } from "source-map"; |
| 2 | +import StackFrame = require("stackframe"); |
| 3 | + |
| 4 | +declare namespace StackTraceGPS { |
| 5 | + /** |
| 6 | + * Options for the StackTraceGPS constructor |
| 7 | + */ |
| 8 | + interface Options { |
| 9 | + /** Pre-populate source cache to avoid network requests */ |
| 10 | + sourceCache?: { [url: string]: string | Promise<string> }; |
| 11 | + |
| 12 | + /** Pre-populate SourceMapConsumer cache to avoid network requests */ |
| 13 | + sourceMapConsumerCache?: { [sourceMappingUrl: string]: SourceMapConsumer }; |
| 14 | + |
| 15 | + /** True to prevent network requests (best effort without sources or source maps) */ |
| 16 | + offline?: boolean; |
| 17 | + |
| 18 | + /** Function to be used for making X-Domain requests */ |
| 19 | + ajax?(url: string): Promise<string>; |
| 20 | + |
| 21 | + /** Function to convert base64-encoded strings to their original representation */ |
| 22 | + atob?(base64: string): string; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +declare class StackTraceGPS { |
| 27 | + /** |
| 28 | + * @param opts - StackTraceGPS.Options object |
| 29 | + */ |
| 30 | + constructor(opts?: StackTraceGPS.Options); |
| 31 | + |
| 32 | + /** |
| 33 | + * Given a StackFrame, enhance function name and use source maps for |
| 34 | + * a better StackFrame. |
| 35 | + * |
| 36 | + * @param stackframe - StackFrame object |
| 37 | + * @returns Promise that resolves with with source-mapped StackFrame |
| 38 | + */ |
| 39 | + pinpoint(stackframe: StackFrame): Promise<StackFrame>; |
| 40 | + |
| 41 | + /** |
| 42 | + * Given a StackFrame, guess function name from location |
| 43 | + * information. |
| 44 | + * |
| 45 | + * @param stackframe - StackFrame object |
| 46 | + * @returns Promise that resolves with enhanced StackFrame |
| 47 | + */ |
| 48 | + findFunctionName(stackframe: StackFrame): Promise<StackFrame>; |
| 49 | + |
| 50 | + /** |
| 51 | + * Given a StackFrame, seek source-mapped location and return new |
| 52 | + * enhanced StackFrame. |
| 53 | + * |
| 54 | + * @param stackframe - StackFrame object |
| 55 | + * @returns Promise that resolves with enhanced StackFrame |
| 56 | + */ |
| 57 | + getMappedLocation(stackframe: StackFrame): Promise<StackFrame>; |
| 58 | +} |
| 59 | + |
| 60 | +export = StackTraceGPS; |
| 61 | + |
| 62 | +export as namespace StackTraceGPS; // global for non-module UMD users |
0 commit comments