forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.js
More file actions
83 lines (71 loc) · 2.1 KB
/
create.js
File metadata and controls
83 lines (71 loc) · 2.1 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
// This module converts Firefox specific types to the generic types
import type { Frame, ThreadId, GeneratedSourceData } from "../../types";
import type {
PausedPacket,
FramesResponse,
FramePacket,
SourcePayload,
ThreadClient
} from "./types";
import { clientCommands } from "./commands";
export function prepareSourcePayload(
client: ThreadClient,
source: SourcePayload
): GeneratedSourceData {
// We populate the set of sources as soon as we hear about them. Note that
// this means that we have seen an actor, but it might still be in the
// debounced queue for creation, so the Redux store itself might not have
// a source actor with this ID yet.
clientCommands.registerSourceActor(source.actor, makeSourceId(source));
return { thread: client.actor, source };
}
export function createFrame(thread: ThreadId, frame: FramePacket): ?Frame {
if (!frame) {
return null;
}
const location = {
sourceId: clientCommands.getSourceForActor(frame.where.actor),
line: frame.where.line,
column: frame.where.column
};
return {
id: frame.actor,
thread,
displayName: frame.displayName,
location,
generatedLocation: location,
this: frame.this,
source: null,
scope: frame.environment
};
}
export function makeSourceId(source: SourcePayload) {
return source.url ? `sourceURL-${source.url}` : `source-${source.actor}`;
}
export function createPause(
thread: string,
packet: PausedPacket,
response: FramesResponse
): any {
// NOTE: useful when the debugger is already paused
const frame = packet.frame || response.frames[0];
return {
...packet,
thread,
frame: createFrame(thread, frame),
frames: response.frames.map(createFrame.bind(null, thread))
};
}
export function createWorker(actor: string, url: string) {
return {
actor,
url,
// Ci.nsIWorkerDebugger.TYPE_DEDICATED
type: 0,
name: ""
};
}