8000 Merge pull request #72 from andersk/typescript · stacktracejs/stacktrace-gps@a1b044b · GitHub
[go: up one dir, main page]

Skip to content

Commit a1b044b

Browse files
authored
Merge pull request #72 from andersk/typescript
Add TypeScript declarations
2 parents 4ec577e + 9a29bf2 commit a1b044b

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@
5050
"url": "https://github.com/stacktracejs/stacktrace-gps/issues"
5151
},
5252
"main": "./stacktrace-gps.js",
53+
"types": "./stacktrace-gps.d.ts",
5354
"files": [
5455
"LICENSE",
5556
"README.md",
5657
"stacktrace-gps.js",
58+
"stacktrace-gps.d.ts",
5759
"dist/",
5860
"node_modules/source-map/"
5961
],

stacktrace-gps.d.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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

Comments
 (0)
0