/
types.js
131 lines (115 loc) 路 2.95 KB
/
types.js
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
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @oncall react_native
*/
'use strict';
// Page information received from the device. New page is created for
// each new instance of VM and can appear when user reloads React Native
// application.
export type Page = {
id: string,
title: string,
vm: string,
app: string,
...
};
// Chrome Debugger Protocol message/event passed between device and debugger.
export type WrappedEvent = {
event: 'wrappedEvent',
payload: {
pageId: string,
wrappedEvent: string,
...
},
...
};
// Request sent from Inspector Proxy to Device when new debugger is connected
// to particular page.
export type ConnectRequest = {
event: 'connect',
payload: {pageId: string, ...},
...
};
// Request sent from Inspector Proxy to Device to notify that debugger is
// disconnected.
export type DisconnectRequest = {
event: 'disconnect',
payload: {pageId: string, ...},
...
};
// Request sent from Inspector Proxy to Device to get a list of pages.
export type GetPagesRequest = {event: 'getPages', ...};
// Response to GetPagesRequest containing a list of page infos.
export type GetPagesResponse = {
event: 'getPages',
payload: Array<Page>,
...
};
// Union type for all possible messages sent from device to Inspector Proxy.
export type MessageFromDevice =
| GetPagesResponse
| WrappedEvent
| DisconnectRequest;
// Union type for all possible messages sent from Inspector Proxy to device.
export type MessageToDevice =
| GetPagesRequest
| WrappedEvent
| ConnectRequest
| DisconnectRequest;
// Page description object that is sent in response to /json HTTP request from debugger.
export type PageDescription = {
id: string,
description: string,
title: string,
faviconUrl: string,
devtoolsFrontendUrl: string,
type: string,
webSocketDebuggerUrl: string,
...
};
export type JsonPagesListResponse = Array<PageDescription>;
// Response to /json/version HTTP request from the debugger specifying browser type and
// Chrome protocol version.
export type JsonVersionResponse = {
Browser: string,
'Protocol-Version': string,
...
};
/**
* Types were exported from https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol.d.ts
*/
export type SetBreakpointByUrlRequest = {
id: number,
method: 'Debugger.setBreakpointByUrl',
params: {
lineNumber: number,
url?: string,
urlRegex?: string,
scriptHash?: string,
columnNumber?: number,
condition?: string,
},
};
export type GetScriptSourceRequest = {
id: number,
method: 'Debugger.getScriptSource',
params: {
scriptId: string,
},
};
export type GetScriptSourceResponse = {
scriptSource: string,
/**
* Wasm bytecode.
*/
bytecode?: string,
};
export type DebuggerRequest =
| SetBreakpointByUrlRequest
| GetScriptSourceRequest;