@depup/react-native__dev-middleware 0.84.1-depup.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/changes.json +38 -0
- package/dist/createDevMiddleware.d.ts +62 -0
- package/dist/createDevMiddleware.js +140 -0
- package/dist/createDevMiddleware.js.flow +72 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +26 -0
- package/dist/index.js.flow +24 -0
- package/dist/inspector-proxy/CdpDebugLogging.d.ts +20 -0
- package/dist/inspector-proxy/CdpDebugLogging.js +117 -0
- package/dist/inspector-proxy/CdpDebugLogging.js.flow +20 -0
- package/dist/inspector-proxy/CustomMessageHandler.d.ts +48 -0
- package/dist/inspector-proxy/CustomMessageHandler.js +1 -0
- package/dist/inspector-proxy/CustomMessageHandler.js.flow +54 -0
- package/dist/inspector-proxy/Device.d.ts +62 -0
- package/dist/inspector-proxy/Device.js +810 -0
- package/dist/inspector-proxy/Device.js.flow +70 -0
- package/dist/inspector-proxy/DeviceEventReporter.d.ts +54 -0
- package/dist/inspector-proxy/DeviceEventReporter.js +194 -0
- package/dist/inspector-proxy/DeviceEventReporter.js.flow +62 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.d.ts +31 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.js +50 -0
- package/dist/inspector-proxy/EventLoopPerfTracker.js.flow +34 -0
- package/dist/inspector-proxy/InspectorProxy.d.ts +53 -0
- package/dist/inspector-proxy/InspectorProxy.js +477 -0
- package/dist/inspector-proxy/InspectorProxy.js.flow +62 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.d.ts +24 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.js +64 -0
- package/dist/inspector-proxy/InspectorProxyHeartbeat.js.flow +25 -0
- package/dist/inspector-proxy/cdp-types/messages.d.ts +41 -0
- package/dist/inspector-proxy/cdp-types/messages.js +1 -0
- package/dist/inspector-proxy/cdp-types/messages.js.flow +54 -0
- package/dist/inspector-proxy/cdp-types/protocol.d.ts +106 -0
- package/dist/inspector-proxy/cdp-types/protocol.js +1 -0
- package/dist/inspector-proxy/cdp-types/protocol.js.flow +124 -0
- package/dist/inspector-proxy/types.d.ts +115 -0
- package/dist/inspector-proxy/types.js +1 -0
- package/dist/inspector-proxy/types.js.flow +152 -0
- package/dist/middleware/openDebuggerMiddleware.d.ts +36 -0
- package/dist/middleware/openDebuggerMiddleware.js +216 -0
- package/dist/middleware/openDebuggerMiddleware.js.flow +36 -0
- package/dist/types/BrowserLauncher.d.ts +62 -0
- package/dist/types/BrowserLauncher.js +1 -0
- package/dist/types/BrowserLauncher.js.flow +66 -0
- package/dist/types/EventReporter.d.ts +124 -0
- package/dist/types/EventReporter.js +1 -0
- package/dist/types/EventReporter.js.flow +151 -0
- package/dist/types/Experiments.d.ts +30 -0
- package/dist/types/Experiments.js +1 -0
- package/dist/types/Experiments.js.flow +34 -0
- package/dist/types/Logger.d.ts +15 -0
- package/dist/types/Logger.js +1 -0
- package/dist/types/Logger.js.flow +16 -0
- package/dist/utils/DefaultBrowserLauncher.d.ts +30 -0
- package/dist/utils/DefaultBrowserLauncher.js +57 -0
- package/dist/utils/DefaultBrowserLauncher.js.flow +29 -0
- package/dist/utils/getBaseUrlFromRequest.d.ts +14 -0
- package/dist/utils/getBaseUrlFromRequest.js +19 -0
- package/dist/utils/getBaseUrlFromRequest.js.flow +17 -0
- package/dist/utils/getDevToolsFrontendUrl.d.ts +29 -0
- package/dist/utils/getDevToolsFrontendUrl.js +58 -0
- package/dist/utils/getDevToolsFrontendUrl.js.flow +29 -0
- package/package.json +97 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { JSONSerializable } from "../types";
|
|
12
|
+
import type { Commands, Events } from "./protocol";
|
|
13
|
+
|
|
14
|
+
// Note: A CDP event is a JSON-RPC notification with no `id` member.
|
|
15
|
+
export type CDPEvent<TEvent: $Keys<Events> = "unknown"> = {
|
|
16
|
+
method: TEvent,
|
|
17
|
+
params: Events[TEvent],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type CDPRequest<TCommand: $Keys<Commands> = "unknown"> = {
|
|
21
|
+
method: TCommand,
|
|
22
|
+
params: Commands[TCommand]["paramsType"],
|
|
23
|
+
id: number,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type CDPResponse<TCommand: $Keys<Commands> = "unknown"> =
|
|
27
|
+
| {
|
|
28
|
+
result: Commands[TCommand]["resultType"],
|
|
29
|
+
id: number,
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
error: CDPRequestError,
|
|
33
|
+
id: number,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type CDPRequestError = {
|
|
37
|
+
code: number,
|
|
38
|
+
message: string,
|
|
39
|
+
data?: JSONSerializable,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type CDPClientMessage =
|
|
43
|
+
| CDPRequest<"Debugger.getScriptSource">
|
|
44
|
+
| CDPRequest<"Debugger.scriptParsed">
|
|
45
|
+
| CDPRequest<"Debugger.setBreakpointByUrl">
|
|
46
|
+
| CDPRequest<"Network.loadNetworkResource">
|
|
47
|
+
| CDPRequest<>;
|
|
48
|
+
|
|
49
|
+
export type CDPServerMessage =
|
|
50
|
+
| CDPEvent<"Debugger.scriptParsed">
|
|
51
|
+
| CDPEvent<"Runtime.consoleAPICalled">
|
|
52
|
+
| CDPEvent<>
|
|
53
|
+
| CDPResponse<"Debugger.getScriptSource">
|
|
54
|
+
| CDPResponse<>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { JSONSerializable } from "../types";
|
|
12
|
+
type integer = number;
|
|
13
|
+
export interface Debugger {
|
|
14
|
+
GetScriptSourceParams: {
|
|
15
|
+
/**
|
|
16
|
+
* Id of the script to get source for.
|
|
17
|
+
*/
|
|
18
|
+
scriptId: string;
|
|
19
|
+
};
|
|
20
|
+
GetScriptSourceResult: {
|
|
21
|
+
/**
|
|
22
|
+
* Script source (empty in case of Wasm bytecode).
|
|
23
|
+
*/
|
|
24
|
+
scriptSource: string;
|
|
25
|
+
/**
|
|
26
|
+
* Wasm bytecode. (Encoded as a base64 string when passed over JSON)
|
|
27
|
+
*/
|
|
28
|
+
bytecode?: string;
|
|
29
|
+
};
|
|
30
|
+
SetBreakpointByUrlParams: {
|
|
31
|
+
/**
|
|
32
|
+
* Line number to set breakpoint at.
|
|
33
|
+
*/
|
|
34
|
+
lineNumber: integer;
|
|
35
|
+
/**
|
|
36
|
+
* URL of the resources to set breakpoint on.
|
|
37
|
+
*/
|
|
38
|
+
url?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Regex pattern for the URLs of the resources to set breakpoints on. Either `url` or
|
|
41
|
+
* `urlRegex` must be specified.
|
|
42
|
+
*/
|
|
43
|
+
urlRegex?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Script hash of the resources to set breakpoint on.
|
|
46
|
+
*/
|
|
47
|
+
scriptHash?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Offset in the line to set breakpoint at.
|
|
50
|
+
*/
|
|
51
|
+
columnNumber?: integer;
|
|
52
|
+
/**
|
|
53
|
+
* Expression to use as a breakpoint condition. When specified, debugger will only stop on the
|
|
54
|
+
* breakpoint if this expression evaluates to true.
|
|
55
|
+
*/
|
|
56
|
+
condition?: string;
|
|
57
|
+
};
|
|
58
|
+
ScriptParsedEvent: {
|
|
59
|
+
/**
|
|
60
|
+
* Identifier of the script parsed.
|
|
61
|
+
*/
|
|
62
|
+
scriptId: string;
|
|
63
|
+
/**
|
|
64
|
+
* URL or name of the script parsed (if any).
|
|
65
|
+
*/
|
|
66
|
+
url: string;
|
|
67
|
+
/**
|
|
68
|
+
* URL of source map associated with script (if any).
|
|
69
|
+
*/
|
|
70
|
+
sourceMapURL: string;
|
|
71
|
+
};
|
|
72
|
+
ConsoleAPICalled: {
|
|
73
|
+
args: Array<{ type: string; value: string }>;
|
|
74
|
+
executionContextId: number;
|
|
75
|
+
stackTrace: {
|
|
76
|
+
timestamp: number;
|
|
77
|
+
type: string;
|
|
78
|
+
callFrames: Array<{
|
|
79
|
+
columnNumber: number;
|
|
80
|
+
lineNumber: number;
|
|
81
|
+
functionName: string;
|
|
82
|
+
scriptId: string;
|
|
83
|
+
url: string;
|
|
84
|
+
}>;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export type Events = {
|
|
89
|
+
"Debugger.scriptParsed": Debugger["ScriptParsedEvent"];
|
|
90
|
+
"Runtime.consoleAPICalled": Debugger["ConsoleAPICalled"];
|
|
91
|
+
[method: string]: JSONSerializable;
|
|
92
|
+
};
|
|
93
|
+
export type Commands = {
|
|
94
|
+
"Debugger.getScriptSource": {
|
|
95
|
+
paramsType: Debugger["GetScriptSourceParams"];
|
|
96
|
+
resultType: Debugger["GetScriptSourceResult"];
|
|
97
|
+
};
|
|
98
|
+
"Debugger.setBreakpointByUrl": {
|
|
99
|
+
paramsType: Debugger["SetBreakpointByUrlParams"];
|
|
100
|
+
resultType: void;
|
|
101
|
+
};
|
|
102
|
+
[method: string]: {
|
|
103
|
+
paramsType: JSONSerializable;
|
|
104
|
+
resultType: JSONSerializable;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Adapted from https://github.com/ChromeDevTools/devtools-protocol/blob/master/types/protocol.d.ts
|
|
12
|
+
|
|
13
|
+
import type { JSONSerializable } from "../types";
|
|
14
|
+
|
|
15
|
+
type integer = number;
|
|
16
|
+
|
|
17
|
+
export interface Debugger {
|
|
18
|
+
GetScriptSourceParams: {
|
|
19
|
+
/**
|
|
20
|
+
* Id of the script to get source for.
|
|
21
|
+
*/
|
|
22
|
+
scriptId: string,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
GetScriptSourceResult: {
|
|
26
|
+
/**
|
|
27
|
+
* Script source (empty in case of Wasm bytecode).
|
|
28
|
+
*/
|
|
29
|
+
scriptSource: string,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Wasm bytecode. (Encoded as a base64 string when passed over JSON)
|
|
33
|
+
*/
|
|
34
|
+
bytecode?: string,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
SetBreakpointByUrlParams: {
|
|
38
|
+
/**
|
|
39
|
+
* Line number to set breakpoint at.
|
|
40
|
+
*/
|
|
41
|
+
lineNumber: integer,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* URL of the resources to set breakpoint on.
|
|
45
|
+
*/
|
|
46
|
+
url?: string,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Regex pattern for the URLs of the resources to set breakpoints on. Either `url` or
|
|
50
|
+
* `urlRegex` must be specified.
|
|
51
|
+
*/
|
|
52
|
+
urlRegex?: string,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Script hash of the resources to set breakpoint on.
|
|
56
|
+
*/
|
|
57
|
+
scriptHash?: string,
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Offset in the line to set breakpoint at.
|
|
61
|
+
*/
|
|
62
|
+
columnNumber?: integer,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Expression to use as a breakpoint condition. When specified, debugger will only stop on the
|
|
66
|
+
* breakpoint if this expression evaluates to true.
|
|
67
|
+
*/
|
|
68
|
+
condition?: string,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
ScriptParsedEvent: {
|
|
72
|
+
/**
|
|
73
|
+
* Identifier of the script parsed.
|
|
74
|
+
*/
|
|
75
|
+
scriptId: string,
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* URL or name of the script parsed (if any).
|
|
79
|
+
*/
|
|
80
|
+
url: string,
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* URL of source map associated with script (if any).
|
|
84
|
+
*/
|
|
85
|
+
sourceMapURL: string,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
ConsoleAPICalled: {
|
|
89
|
+
args: Array<{ type: string, value: string }>,
|
|
90
|
+
executionContextId: number,
|
|
91
|
+
stackTrace: {
|
|
92
|
+
timestamp: number,
|
|
93
|
+
type: string,
|
|
94
|
+
callFrames: Array<{
|
|
95
|
+
columnNumber: number,
|
|
96
|
+
lineNumber: number,
|
|
97
|
+
functionName: string,
|
|
98
|
+
scriptId: string,
|
|
99
|
+
url: string,
|
|
100
|
+
}>,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export type Events = {
|
|
106
|
+
"Debugger.scriptParsed": Debugger["ScriptParsedEvent"],
|
|
107
|
+
"Runtime.consoleAPICalled": Debugger["ConsoleAPICalled"],
|
|
108
|
+
[method: string]: JSONSerializable,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export type Commands = {
|
|
112
|
+
"Debugger.getScriptSource": {
|
|
113
|
+
paramsType: Debugger["GetScriptSourceParams"],
|
|
114
|
+
resultType: Debugger["GetScriptSourceResult"],
|
|
115
|
+
},
|
|
116
|
+
"Debugger.setBreakpointByUrl": {
|
|
117
|
+
paramsType: Debugger["SetBreakpointByUrlParams"],
|
|
118
|
+
resultType: void,
|
|
119
|
+
},
|
|
120
|
+
[method: string]: {
|
|
121
|
+
paramsType: JSONSerializable,
|
|
122
|
+
resultType: JSONSerializable,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A capability flag disables a specific feature/hack in the InspectorProxy
|
|
13
|
+
* layer by indicating that the target supports one or more modern CDP features.
|
|
14
|
+
*/
|
|
15
|
+
export type TargetCapabilityFlags = Readonly<{
|
|
16
|
+
/**
|
|
17
|
+
* The target supports a stable page representation across reloads.
|
|
18
|
+
*
|
|
19
|
+
* In the proxy, this disables legacy page reload emulation and the
|
|
20
|
+
* additional 'React Native Experimental' target in `/json/list`.
|
|
21
|
+
*
|
|
22
|
+
* In the launch flow, this allows targets to be matched directly by
|
|
23
|
+
* `logicalDeviceId`.
|
|
24
|
+
*/
|
|
25
|
+
nativePageReloads?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The target supports fetching source code and source maps.
|
|
28
|
+
*
|
|
29
|
+
* In the proxy, this disables source fetching emulation and host rewrites.
|
|
30
|
+
*/
|
|
31
|
+
nativeSourceCodeFetching?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The target supports the modern `rn_fusebox.html` entry point.
|
|
34
|
+
*
|
|
35
|
+
* In the launch flow, this controls the Chrome DevTools entrypoint that is used.
|
|
36
|
+
*/
|
|
37
|
+
prefersFuseboxFrontend?: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
export type PageFromDevice = Readonly<{
|
|
40
|
+
id: string;
|
|
41
|
+
title: string;
|
|
42
|
+
/** Sent from modern targets only */
|
|
43
|
+
description?: string;
|
|
44
|
+
/** @deprecated This is sent from legacy targets only */
|
|
45
|
+
vm?: string;
|
|
46
|
+
app: string;
|
|
47
|
+
capabilities?: TargetCapabilityFlags;
|
|
48
|
+
}>;
|
|
49
|
+
export type Page = Readonly<
|
|
50
|
+
Omit<
|
|
51
|
+
PageFromDevice,
|
|
52
|
+
keyof { capabilities: NonNullable<PageFromDevice["capabilities"]> }
|
|
53
|
+
> & { capabilities: NonNullable<PageFromDevice["capabilities"]> }
|
|
54
|
+
>;
|
|
55
|
+
export type WrappedEvent = Readonly<{
|
|
56
|
+
event: "wrappedEvent";
|
|
57
|
+
payload: Readonly<{ pageId: string; wrappedEvent: string }>;
|
|
58
|
+
}>;
|
|
59
|
+
export type ConnectRequest = Readonly<{
|
|
60
|
+
event: "connect";
|
|
61
|
+
payload: Readonly<{ pageId: string }>;
|
|
62
|
+
}>;
|
|
63
|
+
export type DisconnectRequest = Readonly<{
|
|
64
|
+
event: "disconnect";
|
|
65
|
+
payload: Readonly<{ pageId: string }>;
|
|
66
|
+
}>;
|
|
67
|
+
export type GetPagesRequest = { event: "getPages" };
|
|
68
|
+
export type GetPagesResponse = {
|
|
69
|
+
event: "getPages";
|
|
70
|
+
payload: ReadonlyArray<PageFromDevice>;
|
|
71
|
+
};
|
|
72
|
+
export type MessageFromDevice =
|
|
73
|
+
| GetPagesResponse
|
|
74
|
+
| WrappedEvent
|
|
75
|
+
| DisconnectRequest;
|
|
76
|
+
export type MessageToDevice =
|
|
77
|
+
| GetPagesRequest
|
|
78
|
+
| WrappedEvent
|
|
79
|
+
| ConnectRequest
|
|
80
|
+
| DisconnectRequest;
|
|
81
|
+
export type PageDescription = Readonly<{
|
|
82
|
+
id: string;
|
|
83
|
+
title: string;
|
|
84
|
+
appId: string;
|
|
85
|
+
description: string;
|
|
86
|
+
type: string;
|
|
87
|
+
devtoolsFrontendUrl: string;
|
|
88
|
+
webSocketDebuggerUrl: string;
|
|
89
|
+
/** @deprecated Prefer `title` */
|
|
90
|
+
deviceName: string;
|
|
91
|
+
/** @deprecated This is sent from legacy targets only */
|
|
92
|
+
vm?: string;
|
|
93
|
+
reactNative: Readonly<{
|
|
94
|
+
logicalDeviceId: string;
|
|
95
|
+
capabilities: Page["capabilities"];
|
|
96
|
+
}>;
|
|
97
|
+
}>;
|
|
98
|
+
export type JsonPagesListResponse = Array<PageDescription>;
|
|
99
|
+
export type JsonVersionResponse = Readonly<{
|
|
100
|
+
Browser: string;
|
|
101
|
+
"Protocol-Version": string;
|
|
102
|
+
}>;
|
|
103
|
+
export type JSONSerializable =
|
|
104
|
+
| boolean
|
|
105
|
+
| number
|
|
106
|
+
| string
|
|
107
|
+
| null
|
|
108
|
+
| ReadonlyArray<JSONSerializable>
|
|
109
|
+
| { readonly [$$Key$$: string]: JSONSerializable };
|
|
110
|
+
export type DeepReadOnly<T> =
|
|
111
|
+
T extends ReadonlyArray<infer V>
|
|
112
|
+
? ReadonlyArray<DeepReadOnly<V>>
|
|
113
|
+
: T extends {}
|
|
114
|
+
? { readonly [K in keyof T]: DeepReadOnly<T[K]> }
|
|
115
|
+
: T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @flow strict-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A capability flag disables a specific feature/hack in the InspectorProxy
|
|
13
|
+
* layer by indicating that the target supports one or more modern CDP features.
|
|
14
|
+
*/
|
|
15
|
+
export type TargetCapabilityFlags = $ReadOnly<{
|
|
16
|
+
/**
|
|
17
|
+
* The target supports a stable page representation across reloads.
|
|
18
|
+
*
|
|
19
|
+
* In the proxy, this disables legacy page reload emulation and the
|
|
20
|
+
* additional 'React Native Experimental' target in `/json/list`.
|
|
21
|
+
*
|
|
22
|
+
* In the launch flow, this allows targets to be matched directly by
|
|
23
|
+
* `logicalDeviceId`.
|
|
24
|
+
*/
|
|
25
|
+
nativePageReloads?: boolean,
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The target supports fetching source code and source maps.
|
|
29
|
+
*
|
|
30
|
+
* In the proxy, this disables source fetching emulation and host rewrites.
|
|
31
|
+
*/
|
|
32
|
+
nativeSourceCodeFetching?: boolean,
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The target supports the modern `rn_fusebox.html` entry point.
|
|
36
|
+
*
|
|
37
|
+
* In the launch flow, this controls the Chrome DevTools entrypoint that is used.
|
|
38
|
+
*/
|
|
39
|
+
prefersFuseboxFrontend?: boolean,
|
|
40
|
+
}>;
|
|
41
|
+
|
|
42
|
+
// Page information received from the device. New page is created for
|
|
43
|
+
// each new instance of VM and can appear when user reloads React Native
|
|
44
|
+
// application.
|
|
45
|
+
|
|
46
|
+
export type PageFromDevice = $ReadOnly<{
|
|
47
|
+
id: string,
|
|
48
|
+
title: string,
|
|
49
|
+
/** Sent from modern targets only */
|
|
50
|
+
description?: string,
|
|
51
|
+
/** @deprecated This is sent from legacy targets only */
|
|
52
|
+
vm?: string,
|
|
53
|
+
app: string,
|
|
54
|
+
capabilities?: TargetCapabilityFlags,
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
export type Page = $ReadOnly<{
|
|
58
|
+
...PageFromDevice,
|
|
59
|
+
capabilities: NonNullable<PageFromDevice["capabilities"]>,
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
// Chrome Debugger Protocol message/event passed between device and debugger.
|
|
63
|
+
export type WrappedEvent = $ReadOnly<{
|
|
64
|
+
event: "wrappedEvent",
|
|
65
|
+
payload: $ReadOnly<{
|
|
66
|
+
pageId: string,
|
|
67
|
+
wrappedEvent: string,
|
|
68
|
+
}>,
|
|
69
|
+
}>;
|
|
70
|
+
|
|
71
|
+
// Request sent from Inspector Proxy to Device when new debugger is connected
|
|
72
|
+
// to particular page.
|
|
73
|
+
export type ConnectRequest = $ReadOnly<{
|
|
74
|
+
event: "connect",
|
|
75
|
+
payload: $ReadOnly<{ pageId: string }>,
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
// Request sent from Inspector Proxy to Device to notify that debugger is
|
|
79
|
+
// disconnected.
|
|
80
|
+
export type DisconnectRequest = $ReadOnly<{
|
|
81
|
+
event: "disconnect",
|
|
82
|
+
payload: $ReadOnly<{ pageId: string }>,
|
|
83
|
+
}>;
|
|
84
|
+
|
|
85
|
+
// Request sent from Inspector Proxy to Device to get a list of pages.
|
|
86
|
+
export type GetPagesRequest = { event: "getPages" };
|
|
87
|
+
|
|
88
|
+
// Response to GetPagesRequest containing a list of page infos.
|
|
89
|
+
export type GetPagesResponse = {
|
|
90
|
+
event: "getPages",
|
|
91
|
+
payload: $ReadOnlyArray<PageFromDevice>,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Union type for all possible messages sent from device to Inspector Proxy.
|
|
95
|
+
export type MessageFromDevice =
|
|
96
|
+
| GetPagesResponse
|
|
97
|
+
| WrappedEvent
|
|
98
|
+
| DisconnectRequest;
|
|
99
|
+
|
|
100
|
+
// Union type for all possible messages sent from Inspector Proxy to device.
|
|
101
|
+
export type MessageToDevice =
|
|
102
|
+
| GetPagesRequest
|
|
103
|
+
| WrappedEvent
|
|
104
|
+
| ConnectRequest
|
|
105
|
+
| DisconnectRequest;
|
|
106
|
+
|
|
107
|
+
// Page description object that is sent in response to /json HTTP request from debugger.
|
|
108
|
+
export type PageDescription = $ReadOnly<{
|
|
109
|
+
id: string,
|
|
110
|
+
title: string,
|
|
111
|
+
appId: string,
|
|
112
|
+
description: string,
|
|
113
|
+
type: string,
|
|
114
|
+
devtoolsFrontendUrl: string,
|
|
115
|
+
webSocketDebuggerUrl: string,
|
|
116
|
+
|
|
117
|
+
// React Native specific fields
|
|
118
|
+
/** @deprecated Prefer `title` */
|
|
119
|
+
deviceName: string,
|
|
120
|
+
/** @deprecated This is sent from legacy targets only */
|
|
121
|
+
vm?: string,
|
|
122
|
+
|
|
123
|
+
// React Native specific metadata
|
|
124
|
+
reactNative: $ReadOnly<{
|
|
125
|
+
logicalDeviceId: string,
|
|
126
|
+
capabilities: Page["capabilities"],
|
|
127
|
+
}>,
|
|
128
|
+
}>;
|
|
129
|
+
|
|
130
|
+
export type JsonPagesListResponse = Array<PageDescription>;
|
|
131
|
+
|
|
132
|
+
// Response to /json/version HTTP request from the debugger specifying browser type and
|
|
133
|
+
// Chrome protocol version.
|
|
134
|
+
export type JsonVersionResponse = $ReadOnly<{
|
|
135
|
+
Browser: string,
|
|
136
|
+
"Protocol-Version": string,
|
|
137
|
+
}>;
|
|
138
|
+
|
|
139
|
+
export type JSONSerializable =
|
|
140
|
+
| boolean
|
|
141
|
+
| number
|
|
142
|
+
| string
|
|
143
|
+
| null
|
|
144
|
+
| $ReadOnlyArray<JSONSerializable>
|
|
145
|
+
| { +[string]: JSONSerializable };
|
|
146
|
+
|
|
147
|
+
export type DeepReadOnly<T> =
|
|
148
|
+
T extends $ReadOnlyArray<infer V>
|
|
149
|
+
? $ReadOnlyArray<DeepReadOnly<V>>
|
|
150
|
+
: T extends { ... }
|
|
151
|
+
? { +[K in keyof T]: DeepReadOnly<T[K]> }
|
|
152
|
+
: T;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { InspectorProxyQueries } from "../inspector-proxy/InspectorProxy";
|
|
12
|
+
import type { BrowserLauncher } from "../types/BrowserLauncher";
|
|
13
|
+
import type { EventReporter } from "../types/EventReporter";
|
|
14
|
+
import type { Experiments } from "../types/Experiments";
|
|
15
|
+
import type { Logger } from "../types/Logger";
|
|
16
|
+
import type { NextHandleFunction } from "connect";
|
|
17
|
+
type Options = Readonly<{
|
|
18
|
+
serverBaseUrl: string;
|
|
19
|
+
logger?: Logger;
|
|
20
|
+
browserLauncher: BrowserLauncher;
|
|
21
|
+
eventReporter?: EventReporter;
|
|
22
|
+
experiments: Experiments;
|
|
23
|
+
inspectorProxy: InspectorProxyQueries;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Open the debugger frontend for a given CDP target.
|
|
27
|
+
*
|
|
28
|
+
* Currently supports React Native DevTools (rn_fusebox.html) and legacy Hermes
|
|
29
|
+
* (rn_inspector.html) targets.
|
|
30
|
+
*
|
|
31
|
+
* @see https://chromedevtools.github.io/devtools-protocol/
|
|
32
|
+
*/
|
|
33
|
+
declare function openDebuggerMiddleware(
|
|
34
|
+
$$PARAM_0$$: Options,
|
|
35
|
+
): NextHandleFunction;
|
|
36
|
+
export default openDebuggerMiddleware;
|