forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.js
More file actions
384 lines (360 loc) · 9.58 KB
/
types.js
File metadata and controls
384 lines (360 loc) · 9.58 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/* 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
/**
* These are Firefox specific types that allow us to type check
* the packet information exchanged using the Firefox Remote Debug Protocol
* https://wiki.mozilla.org/Remote_Debugging_Protocol
*/
import type {
BreakpointLocation,
BreakpointOptions,
FrameId,
ActorId,
Script,
Pause,
PendingLocation,
Frame,
SourceId,
QueuedSourceData,
Worker,
Range
} from "../../types";
type URL = string;
/**
* The protocol is carried by a reliable, bi-directional byte stream; data sent
* in both directions consists of JSON objects, called packets. A packet is a
* top-level JSON object, not contained inside any other value.
*
* Every packet sent to the client has the form:
* `{ "to":actor, "type":type, ... }`
*
* where actor is the name of the actor to whom the packet is directed and type
* is a string specifying what sort of packet it is. Additional properties may
* be present, depending on type.
*
* Every packet sent from the server has the form:
* `{ "from":actor, ... }`
*
* where actor is the name of the actor that sent it. The packet may have
* additional properties, depending on the situation.
*
* If a packet is directed to an actor that no longer exists, the server
* sends a packet to the client of the following form:
* `{ "from":actor, "error":"noSuchActor" }`
*
* where actor is the name of the non-existent actor. (It is strange to receive
* messages from actors that do not exist, but the client evidently believes
* that actor exists, and this reply allows the client to pair up the error
* report with the source of the problem.)
*
* Clients should silently ignore packet properties they do not recognize. We
* expect that, as the protocol evolves, we will specify new properties that
* can appear in existing packets, and experimental implementations will do
* the same.
*
* @see https://wiki.mozilla.org/Remote_Debugging_Protocol#Packets
* @memberof firefox/packets
* @static
*/
/**
* Frame Packet
* @memberof firefox/packets
* @static
*/
export type FramePacket = {
actor: ActorId,
arguments: any[],
displayName: string,
environment: any,
this: any,
depth?: number,
oldest?: boolean,
type: "pause" | "call",
where: {| actor: string, line: number, column: number |}
};
/**
* Firefox Source File payload
* introductionType can be a "scriptElement"
* @memberof firefox/payloads
* @static
*/
export type SourcePayload = {
actor: ActorId,
url: URL | null,
isBlackBoxed: boolean,
sourceMapURL: URL | null,
introductionUrl: URL | null,
introductionType: string | null
};
/**
* Source Packet sent when there is a "new source" event
* coming from the debug server
* @memberof firefox/packets
* @static
*/
export type SourcePacket = {
from: ActorId,
source: SourcePayload,
type: string
};
/**
* Sources Packet from calling threadClient.getSources();
* @memberof firefox/packets
* @static
*/
export type SourcesPacket = {
from: ActorId,
sources: SourcePayload[]
};
/**
* Pause Packet sent when the server is in a "paused" state
*
* @memberof firefox
* @static
*/
export type PausedPacket = {
actor: ActorId,
from: ActorId,
type: string,
frame: FramePacket,
why: {
actors: ActorId[],
type: string,
onNext?: Function
}
};
export type ResumedPacket = {
from: ActorId,
type: string
};
/**
* Response from the `getFrames` function call
* @memberof firefox
* @static
*/
export type FramesResponse = {
frames: FramePacket[],
from: ActorId
};
export type TabPayload = {
actor: ActorId,
animationsActor: ActorId,
consoleActor: ActorId,
cssPropertiesActor: ActorId,
directorManagerActor: ActorId,
emulationActor: ActorId,
eventLoopLagActor: ActorId,
framerateActor: ActorId,
inspectorActor: ActorId,
memoryActor: ActorId,
monitorActor: ActorId,
outerWindowID: number,
performanceActor: ActorId,
performanceEntriesActor: ActorId,
profilerActor: ActorId,
promisesActor: ActorId,
reflowActor: ActorId,
storageActor: ActorId,
styleEditorActor: ActorId,
styleSheetsActor: ActorId,
timelineActor: ActorId,
title: string,
url: URL,
webExtensionInspectedWindowActor: ActorId
};
/**
* Actions
* @memberof firefox
* @static
*/
export type Actions = {
paused: Pause => void,
resumed: ResumedPacket => void,
newQueuedSources: (QueuedSourceData[]) => void,
fetchEventListeners: () => void,
updateWorkers: () => void
};
/**
* Tab Target gives access to the browser tabs
* @memberof firefox
* @static
*/
export type TabTarget = {
on: (string, Function) => void,
emit: (string, any) => void,
activeConsole: {
evaluateJS: (
script: Script,
func: Function,
params?: { frameActor: ?FrameId }
) => void,
evaluateJSAsync: (
script: Script,
func: Function,
params?: { frameActor: ?FrameId }
) => Promise<{ result: Grip | null }>,
autocomplete: (
input: string,
cursor: number,
func: Function,
frameId: ?string
) => void,
emit: (string, any) => void
},
form: { consoleActor: any },
root: any,
navigateTo: ({ url: string }) => Promise<*>,
listWorkers: () => Promise<*>,
reload: () => Promise<*>,
destroy: () => void,
isBrowsingContext: boolean,
isContentProcess: boolean,
traits: Object
};
/**
* Clients for accessing the Firefox debug server and browser
* @memberof firefox/clients
* @static
*/
/**
* DebuggerClient
* @memberof firefox
* @static
*/
export type DebuggerClient = {
_activeRequests: {
get: any => any,
delete: any => void
},
mainRoot: {
traits: any,
getFront: string => Promise<*>
},
connect: () => Promise<*>,
request: (packet: Object) => Promise<*>,
attachConsole: (actor: String, listeners: Array<*>) => Promise<*>,
createObjectClient: (grip: Grip) => {},
release: (actor: String) => {}
};
export type TabClient = {
listWorkers: () => Promise<*>,
addListener: (string, Function) => void,
on: (string, Function) => void
};
/**
* A grip is a JSON value that refers to a specific JavaScript value in the
* debuggee. Grips appear anywhere an arbitrary value from the debuggee needs
* to be conveyed to the client: stack frames, object property lists, lexical
* environments, paused packets, and so on.
*
* For mutable values like objects and arrays, grips do not merely convey the
* value's current state to the client. They also act as references to the
* original value, by including an actor to which the client can send messages
* to modify the value in the debuggee.
*
* @see https://wiki.mozilla.org/Remote_Debugging_Protocol#Grips
* @memberof firefox
* @static
*/
export type Grip = {
actor: string,
class: string,
displayClass: string,
displayName?: string,
parameterNames?: string[],
userDisplayName?: string,
name: string,
extensible: boolean,
location: {
url: string,
line: number,
column: number
},
frozen: boolean,
ownPropertyLength: number,
preview: Object,
sealed: boolean,
optimizedOut: boolean,
type: string
};
export type FunctionGrip = {|
class: "Function",
name: string,
parameterNames: string[],
displayName: string,
userDisplayName: string,
url: string,
line: number,
column: number
|};
/**
* SourceClient
* @memberof firefox
* @static
*/
export type SourceClient = {
source: () => { source: any, contentType?: string },
_activeThread: ThreadClient,
actor: string,
getBreakpointPositionsCompressed: (range: ?Range) => Promise<any>,
prettyPrint: number => Promise<*>,
disablePrettyPrint: () => Promise<*>,
blackBox: (range?: Range) => Promise<*>,
unblackBox: (range?: Range) => Promise<*>,
getBreakableLines: () => Promise<number[]>
};
/**
* ObjectClient
* @memberof firefox
* @static
*/
export type ObjectClient = {
getPrototypeAndProperties: () => any
};
/**
* ThreadClient
* @memberof firefox
* @static
*/
export type ThreadClient = {
resume: Function => Promise<*>,
stepIn: Function => Promise<*>,
stepOver: Function => Promise<*>,
stepOut: Function => Promise<*>,
rewind: Function => Promise<*>,
reverseStepOver: Function => Promise<*>,
breakOnNext: () => Promise<*>,
// FIXME: unclear if SourceId or ActorId here
source: ({ actor: SourceId }) => SourceClient,
pauseGrip: (Grip | Function) => ObjectClient,
pauseOnExceptions: (boolean, boolean) => Promise<*>,
setBreakpoint: (BreakpointLocation, BreakpointOptions) => Promise<*>,
removeBreakpoint: PendingLocation => Promise<*>,
setXHRBreakpoint: (path: string, method: string) => Promise<boolean>,
removeXHRBreakpoint: (path: string, method: string) => Promise<boolean>,
interrupt: () => Promise<*>,
eventListeners: () => Promise<*>,
getFrames: (number, number) => FramesResponse,
getEnvironment: (frame: Frame) => Promise<*>,
addListener: (string, Function) => void,
getSources: () => Promise<SourcesPacket>,
reconfigure: ({ observeAsmJS: boolean }) => Promise<*>,
getLastPausePacket: () => ?PausedPacket,
_parent: TabClient,
actor: ActorId,
request: (payload: Object) => Promise<*>,
url: string,
setEventListenerBreakpoints: (string[]) => void,
skipBreakpoints: boolean => Promise<{| skip: boolean |}>
};
export type Panel = {|
emit: (eventName: string) => void,
openLink: (url: string) => void,
openWorkerToolbox: (worker: Worker) => void,
openElementInInspector: (grip: Object) => void,
openConsoleAndEvaluate: (input: string) => void,
highlightDomElement: (grip: Object) => void,
unHighlightDomElement: (grip: Object) => void
|};