forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapFrames.js
More file actions
52 lines (44 loc) · 1.14 KB
/
mapFrames.js
File metadata and controls
52 lines (44 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// @flow
import { getFrames } from "../../selectors";
import type { Frame } from "../../types";
import type { ThunkArgs } from "../types";
function updateFrameLocation(frame: Frame, sourceMaps: any) {
return sourceMaps.getOriginalLocation(frame.location).then(loc => ({
...frame,
location: loc,
generatedLocation: frame.generatedLocation || frame.location
}));
}
function updateFrameLocations(
frames: Frame[],
sourceMaps: any
): Promise<Frame[]> {
if (!frames || frames.length == 0) {
return Promise.resolve(frames);
}
return Promise.all(
frames.map(frame => updateFrameLocation(frame, sourceMaps))
);
}
/**
* Map call stack frame locations to original locations.
* e.g.
* 1. When the debuggee pauses
* 2. When a source is pretty printed
*
* @memberof actions/pause
* @static
*/
export function mapFrames() {
return async function({ dispatch, getState, sourceMaps }: ThunkArgs) {
const frames = getFrames(getState());
if (!frames) {
return;
}
const mappedFrames = await updateFrameLocations(frames, sourceMaps);
dispatch({
type: "MAP_FRAMES",
frames: mappedFrames
});
};
}