roku-debug 0.20.5 → 0.20.7
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/CHANGELOG.md +17 -0
- package/dist/CompileErrorProcessor.d.ts +7 -2
- package/dist/CompileErrorProcessor.js +64 -69
- package/dist/CompileErrorProcessor.js.map +1 -1
- package/dist/DeviceInfo.d.ts +1 -0
- package/dist/adapters/DebugProtocolAdapter.d.ts +64 -17
- package/dist/adapters/DebugProtocolAdapter.js +264 -157
- package/dist/adapters/DebugProtocolAdapter.js.map +1 -1
- package/dist/adapters/TelnetAdapter.d.ts +8 -3
- package/dist/adapters/TelnetAdapter.js +14 -6
- package/dist/adapters/TelnetAdapter.js.map +1 -1
- package/dist/adapters/TelnetRequestPipeline.d.ts +34 -0
- package/dist/adapters/TelnetRequestPipeline.js +35 -22
- package/dist/adapters/TelnetRequestPipeline.js.map +1 -1
- package/dist/debugProtocol/Constants.d.ts +171 -81
- package/dist/debugProtocol/Constants.js +206 -126
- package/dist/debugProtocol/Constants.js.map +1 -1
- package/dist/debugProtocol/DebugProtocolClientReplaySession.d.ts +46 -0
- package/dist/debugProtocol/DebugProtocolClientReplaySession.js +278 -0
- package/dist/debugProtocol/DebugProtocolClientReplaySession.js.map +1 -0
- package/dist/debugProtocol/PluginInterface.d.ts +38 -0
- package/dist/debugProtocol/PluginInterface.js +86 -0
- package/dist/debugProtocol/PluginInterface.js.map +1 -0
- package/dist/debugProtocol/ProtocolUtil.d.ts +56 -0
- package/dist/debugProtocol/ProtocolUtil.js +164 -0
- package/dist/debugProtocol/ProtocolUtil.js.map +1 -0
- package/dist/debugProtocol/client/DebugProtocolClient.d.ts +310 -0
- package/dist/debugProtocol/client/DebugProtocolClient.js +1079 -0
- package/dist/debugProtocol/client/DebugProtocolClient.js.map +1 -0
- package/dist/debugProtocol/client/DebugProtocolClientPlugin.d.ts +44 -0
- package/dist/debugProtocol/client/DebugProtocolClientPlugin.js +3 -0
- package/dist/debugProtocol/client/DebugProtocolClientPlugin.js.map +1 -0
- package/dist/debugProtocol/events/ProtocolEvent.d.ts +66 -0
- package/dist/debugProtocol/events/ProtocolEvent.js +3 -0
- package/dist/debugProtocol/events/ProtocolEvent.js.map +1 -0
- package/dist/debugProtocol/events/requests/AddBreakpointsRequest.d.ts +30 -0
- package/dist/debugProtocol/events/requests/AddBreakpointsRequest.js +63 -0
- package/dist/debugProtocol/events/requests/AddBreakpointsRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.d.ts +48 -0
- package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.js +69 -0
- package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/ContinueRequest.d.ts +20 -0
- package/dist/debugProtocol/events/requests/ContinueRequest.js +40 -0
- package/dist/debugProtocol/events/requests/ContinueRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/ExecuteRequest.d.ts +26 -0
- package/dist/debugProtocol/events/requests/ExecuteRequest.js +49 -0
- package/dist/debugProtocol/events/requests/ExecuteRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/ExitChannelRequest.d.ts +20 -0
- package/dist/debugProtocol/events/requests/ExitChannelRequest.js +40 -0
- package/dist/debugProtocol/events/requests/ExitChannelRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/HandshakeRequest.d.ts +26 -0
- package/dist/debugProtocol/events/requests/HandshakeRequest.js +47 -0
- package/dist/debugProtocol/events/requests/HandshakeRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/ListBreakpointsRequest.d.ts +20 -0
- package/dist/debugProtocol/events/requests/ListBreakpointsRequest.js +40 -0
- package/dist/debugProtocol/events/requests/ListBreakpointsRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.d.ts +29 -0
- package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.js +60 -0
- package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/StackTraceRequest.d.ts +22 -0
- package/dist/debugProtocol/events/requests/StackTraceRequest.js +43 -0
- package/dist/debugProtocol/events/requests/StackTraceRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/StepRequest.d.ts +25 -0
- package/dist/debugProtocol/events/requests/StepRequest.js +46 -0
- package/dist/debugProtocol/events/requests/StepRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/StopRequest.d.ts +20 -0
- package/dist/debugProtocol/events/requests/StopRequest.js +39 -0
- package/dist/debugProtocol/events/requests/StopRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/ThreadsRequest.d.ts +20 -0
- package/dist/debugProtocol/events/requests/ThreadsRequest.js +40 -0
- package/dist/debugProtocol/events/requests/ThreadsRequest.js.map +1 -0
- package/dist/debugProtocol/events/requests/VariablesRequest.d.ts +59 -0
- package/dist/debugProtocol/events/requests/VariablesRequest.js +123 -0
- package/dist/debugProtocol/events/requests/VariablesRequest.js.map +1 -0
- package/dist/debugProtocol/events/responses/AddBreakpointsResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.d.ts +3 -0
- package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.js +9 -0
- package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/ExecuteV3Response.d.ts +42 -0
- package/dist/debugProtocol/events/responses/ExecuteV3Response.js +94 -0
- package/dist/debugProtocol/events/responses/ExecuteV3Response.js.map +1 -0
- package/dist/debugProtocol/events/responses/GenericResponse.d.ts +17 -0
- package/dist/debugProtocol/events/responses/GenericResponse.js +40 -0
- package/dist/debugProtocol/events/responses/GenericResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/GenericV3Response.d.ts +15 -0
- package/dist/debugProtocol/events/responses/GenericV3Response.js +38 -0
- package/dist/debugProtocol/events/responses/GenericV3Response.js.map +1 -0
- package/dist/debugProtocol/events/responses/HandshakeResponse.d.ts +28 -0
- package/dist/debugProtocol/events/responses/HandshakeResponse.js +69 -0
- package/dist/debugProtocol/events/responses/HandshakeResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/HandshakeV3Response.d.ts +42 -0
- package/dist/debugProtocol/events/responses/HandshakeV3Response.js +98 -0
- package/dist/debugProtocol/events/responses/HandshakeV3Response.js.map +1 -0
- package/dist/debugProtocol/events/responses/ListBreakpointsResponse.d.ts +35 -0
- package/dist/debugProtocol/events/responses/ListBreakpointsResponse.js +68 -0
- package/dist/debugProtocol/events/responses/ListBreakpointsResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/RemoveBreakpointsResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/StackTraceResponse.d.ts +24 -0
- package/dist/debugProtocol/events/responses/StackTraceResponse.js +72 -0
- package/dist/debugProtocol/events/responses/StackTraceResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/StackTraceV3Response.d.ts +37 -0
- package/dist/debugProtocol/events/responses/StackTraceV3Response.js +67 -0
- package/dist/debugProtocol/events/responses/StackTraceV3Response.js.map +1 -0
- package/dist/debugProtocol/events/responses/ThreadsResponse.d.ts +54 -0
- package/dist/debugProtocol/events/responses/ThreadsResponse.js +80 -0
- package/dist/debugProtocol/events/responses/ThreadsResponse.js.map +1 -0
- package/dist/debugProtocol/events/responses/VariablesResponse.d.ts +117 -0
- package/dist/debugProtocol/events/responses/VariablesResponse.js +335 -0
- package/dist/debugProtocol/events/responses/VariablesResponse.js.map +1 -0
- package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.d.ts +35 -0
- package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.js +58 -0
- package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.js.map +1 -0
- package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.d.ts +42 -0
- package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.js +97 -0
- package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.js.map +1 -0
- package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.d.ts +41 -0
- package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.js +74 -0
- package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.js.map +1 -0
- package/dist/debugProtocol/events/updates/CompileErrorUpdate.d.ts +60 -0
- package/dist/debugProtocol/events/updates/CompileErrorUpdate.js +89 -0
- package/dist/debugProtocol/events/updates/CompileErrorUpdate.js.map +1 -0
- package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.d.ts +23 -0
- package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.js +49 -0
- package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.js.map +1 -0
- package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.d.ts +26 -0
- package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.js +50 -0
- package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.js.map +1 -0
- package/dist/debugProtocol/server/DebugProtocolServer.d.ts +110 -0
- package/dist/debugProtocol/server/DebugProtocolServer.js +306 -0
- package/dist/debugProtocol/server/DebugProtocolServer.js.map +1 -0
- package/dist/debugProtocol/server/DebugProtocolServerPlugin.d.ts +41 -0
- package/dist/debugProtocol/server/DebugProtocolServerPlugin.js +3 -0
- package/dist/debugProtocol/server/DebugProtocolServerPlugin.js.map +1 -0
- package/dist/debugSession/BrightScriptDebugSession.d.ts +9 -1
- package/dist/debugSession/BrightScriptDebugSession.js +178 -89
- package/dist/debugSession/BrightScriptDebugSession.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +1 -0
- package/dist/logging.js +4 -2
- package/dist/logging.js.map +1 -1
- package/dist/managers/ActionQueue.d.ts +7 -1
- package/dist/managers/ActionQueue.js +27 -5
- package/dist/managers/ActionQueue.js.map +1 -1
- package/dist/managers/BreakpointManager.d.ts +82 -27
- package/dist/managers/BreakpointManager.js +168 -63
- package/dist/managers/BreakpointManager.js.map +1 -1
- package/dist/managers/ProjectManager.d.ts +3 -0
- package/dist/managers/ProjectManager.js +42 -36
- package/dist/managers/ProjectManager.js.map +1 -1
- package/dist/util.d.ts +8 -6
- package/dist/util.js +36 -19
- package/dist/util.js.map +1 -1
- package/package.json +15 -6
- package/roku-debug-0.20.7.tgz +0 -0
- package/dist/debugProtocol/Debugger.d.ts +0 -161
- package/dist/debugProtocol/Debugger.js +0 -635
- package/dist/debugProtocol/Debugger.js.map +0 -1
- package/dist/debugProtocol/responses/AddBreakpointsResponse.js.map +0 -1
- package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.d.ts +0 -32
- package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.js +0 -67
- package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.js.map +0 -1
- package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.d.ts +0 -32
- package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.js +0 -56
- package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.js.map +0 -1
- package/dist/debugProtocol/responses/ConnectIOPortResponse.d.ts +0 -10
- package/dist/debugProtocol/responses/ConnectIOPortResponse.js +0 -39
- package/dist/debugProtocol/responses/ConnectIOPortResponse.js.map +0 -1
- package/dist/debugProtocol/responses/ExecuteResponseV3.d.ts +0 -23
- package/dist/debugProtocol/responses/ExecuteResponseV3.js +0 -54
- package/dist/debugProtocol/responses/ExecuteResponseV3.js.map +0 -1
- package/dist/debugProtocol/responses/HandshakeResponse.d.ts +0 -12
- package/dist/debugProtocol/responses/HandshakeResponse.js +0 -39
- package/dist/debugProtocol/responses/HandshakeResponse.js.map +0 -1
- package/dist/debugProtocol/responses/HandshakeResponseV3.d.ts +0 -14
- package/dist/debugProtocol/responses/HandshakeResponseV3.js +0 -47
- package/dist/debugProtocol/responses/HandshakeResponseV3.js.map +0 -1
- package/dist/debugProtocol/responses/ListBreakpointsResponse.d.ts +0 -25
- package/dist/debugProtocol/responses/ListBreakpointsResponse.js +0 -65
- package/dist/debugProtocol/responses/ListBreakpointsResponse.js.map +0 -1
- package/dist/debugProtocol/responses/ProtocolEvent.d.ts +0 -11
- package/dist/debugProtocol/responses/ProtocolEvent.js +0 -38
- package/dist/debugProtocol/responses/ProtocolEvent.js.map +0 -1
- package/dist/debugProtocol/responses/ProtocolEventV3.d.ts +0 -11
- package/dist/debugProtocol/responses/ProtocolEventV3.js +0 -42
- package/dist/debugProtocol/responses/ProtocolEventV3.js.map +0 -1
- package/dist/debugProtocol/responses/RemoveBreakpointsResponse.js.map +0 -1
- package/dist/debugProtocol/responses/StackTraceResponse.d.ts +0 -18
- package/dist/debugProtocol/responses/StackTraceResponse.js +0 -58
- package/dist/debugProtocol/responses/StackTraceResponse.js.map +0 -1
- package/dist/debugProtocol/responses/StackTraceResponseV3.d.ts +0 -18
- package/dist/debugProtocol/responses/StackTraceResponseV3.js +0 -58
- package/dist/debugProtocol/responses/StackTraceResponseV3.js.map +0 -1
- package/dist/debugProtocol/responses/ThreadsResponse.d.ts +0 -22
- package/dist/debugProtocol/responses/ThreadsResponse.js +0 -63
- package/dist/debugProtocol/responses/ThreadsResponse.js.map +0 -1
- package/dist/debugProtocol/responses/UndefinedResponse.d.ts +0 -10
- package/dist/debugProtocol/responses/UndefinedResponse.js +0 -39
- package/dist/debugProtocol/responses/UndefinedResponse.js.map +0 -1
- package/dist/debugProtocol/responses/UpdateThreadsResponse.d.ts +0 -25
- package/dist/debugProtocol/responses/UpdateThreadsResponse.js +0 -91
- package/dist/debugProtocol/responses/UpdateThreadsResponse.js.map +0 -1
- package/dist/debugProtocol/responses/VariableResponse.d.ts +0 -27
- package/dist/debugProtocol/responses/VariableResponse.js +0 -141
- package/dist/debugProtocol/responses/VariableResponse.js.map +0 -1
- package/dist/debugProtocol/responses/index.d.ts +0 -11
- package/dist/debugProtocol/responses/index.js +0 -24
- package/dist/debugProtocol/responses/index.js.map +0 -1
- package/roku-debug-0.20.5.tgz +0 -0
- /package/dist/debugProtocol/{responses → events/responses}/AddBreakpointsResponse.d.ts +0 -0
- /package/dist/debugProtocol/{responses → events/responses}/AddBreakpointsResponse.js +0 -0
- /package/dist/debugProtocol/{responses → events/responses}/RemoveBreakpointsResponse.d.ts +0 -0
- /package/dist/debugProtocol/{responses → events/responses}/RemoveBreakpointsResponse.js +0 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protocolUtil = exports.ProtocolUtil = void 0;
|
|
4
|
+
const smart_buffer_1 = require("smart-buffer");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
const Constants_1 = require("./Constants");
|
|
7
|
+
class ProtocolUtil {
|
|
8
|
+
/**
|
|
9
|
+
* Load json data onto an event, and mark it as successful
|
|
10
|
+
*/
|
|
11
|
+
loadJson(event, data) {
|
|
12
|
+
event.data = {
|
|
13
|
+
...event.data,
|
|
14
|
+
...(data !== null && data !== void 0 ? data : {})
|
|
15
|
+
};
|
|
16
|
+
event.success = true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Helper function for buffer loading.
|
|
20
|
+
* Handles things like try/catch, setting buffer read offset, etc
|
|
21
|
+
*/
|
|
22
|
+
bufferLoaderHelper(event, buffer, minByteLength, processor) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
// Required size of this processor
|
|
25
|
+
try {
|
|
26
|
+
if (buffer.byteLength >= minByteLength) {
|
|
27
|
+
let smartBuffer = smart_buffer_1.SmartBuffer.fromBuffer(buffer);
|
|
28
|
+
//have the processor consume the requred bytes.
|
|
29
|
+
event.success = ((_a = processor(smartBuffer)) !== null && _a !== void 0 ? _a : true);
|
|
30
|
+
//if the event has a packet length, use THAT as the read offset. Otherwise, set the offset to the end of the read position of the buffer
|
|
31
|
+
if (event.success) {
|
|
32
|
+
if (!event.readOffset) {
|
|
33
|
+
event.readOffset = (_b = event.data.packetLength) !== null && _b !== void 0 ? _b : smartBuffer.readOffset;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Could not parse
|
|
40
|
+
event.readOffset = 0;
|
|
41
|
+
event.success = false;
|
|
42
|
+
}
|
|
43
|
+
return event;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load the common DebuggerRequest fields
|
|
47
|
+
*/
|
|
48
|
+
loadCommonRequestFields(request, smartBuffer) {
|
|
49
|
+
request.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
|
|
50
|
+
request.data.requestId = smartBuffer.readUInt32LE(); // request_id
|
|
51
|
+
request.data.command = Constants_1.CommandCode[smartBuffer.readUInt32LE()]; // command_code
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Load the common DebuggerResponse
|
|
55
|
+
*/
|
|
56
|
+
loadCommonResponseFields(response, smartBuffer) {
|
|
57
|
+
response.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
|
|
58
|
+
response.data.requestId = smartBuffer.readUInt32LE(); // request_id
|
|
59
|
+
response.data.errorCode = smartBuffer.readUInt32LE(); // error_code
|
|
60
|
+
//if the error code is non-zero, and we have more bytes, then there will be additional data about the error
|
|
61
|
+
if (response.data.errorCode !== Constants_1.ErrorCode.OK && response.data.packetLength > smartBuffer.readOffset) {
|
|
62
|
+
response.data.errorData = {};
|
|
63
|
+
const errorFlags = smartBuffer.readUInt32LE(); // error_flags
|
|
64
|
+
// eslint-disable-next-line no-bitwise
|
|
65
|
+
if (errorFlags & Constants_1.ErrorFlags.INVALID_VALUE_IN_PATH) {
|
|
66
|
+
response.data.errorData.invalidPathIndex = smartBuffer.readUInt32LE(); // invalid_path_index
|
|
67
|
+
}
|
|
68
|
+
// eslint-disable-next-line no-bitwise
|
|
69
|
+
if (errorFlags & Constants_1.ErrorFlags.MISSING_KEY_IN_PATH) {
|
|
70
|
+
response.data.errorData.missingKeyIndex = smartBuffer.readUInt32LE(); // missing_key_index
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
loadCommonUpdateFields(update, smartBuffer, updateType) {
|
|
75
|
+
update.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
|
|
76
|
+
update.data.requestId = smartBuffer.readUInt32LE(); // request_id
|
|
77
|
+
update.data.errorCode = smartBuffer.readUInt32LE(); // error_code
|
|
78
|
+
// requestId 0 means this is an update.
|
|
79
|
+
if (update.data.requestId === 0) {
|
|
80
|
+
update.data.updateType = Constants_1.UpdateTypeCode[smartBuffer.readUInt32LE()];
|
|
81
|
+
//if this is not the update type we want, return false
|
|
82
|
+
if (update.data.updateType !== updateType) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
//not an update. We should not proceed any further.
|
|
88
|
+
throw new Error('This is not an update');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Inserts the common command fields to the beginning of the buffer, and computes
|
|
93
|
+
* the correct `packet_length` value.
|
|
94
|
+
*/
|
|
95
|
+
insertCommonRequestFields(request, smartBuffer) {
|
|
96
|
+
smartBuffer.insertUInt32LE(Constants_1.CommandCode[request.data.command], 0); // command_code - An enum representing the debugging command being sent. See the COMMANDS enum
|
|
97
|
+
smartBuffer.insertUInt32LE(request.data.requestId, 0); // request_id - The ID of the debugger request (must be >=1). This ID is included in the debugger response.
|
|
98
|
+
smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length - The size of the packet to be sent.
|
|
99
|
+
request.data.packetLength = smartBuffer.writeOffset;
|
|
100
|
+
return smartBuffer;
|
|
101
|
+
}
|
|
102
|
+
insertCommonResponseFields(response, smartBuffer) {
|
|
103
|
+
var _a, _b, _c, _d, _e;
|
|
104
|
+
//insert error data
|
|
105
|
+
const flags = (
|
|
106
|
+
// eslint-disable-next-line no-bitwise
|
|
107
|
+
0 |
|
|
108
|
+
(util_1.util.isNullish((_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.errorData) === null || _b === void 0 ? void 0 : _b.invalidPathIndex) ? 0 : Constants_1.ErrorFlags.INVALID_VALUE_IN_PATH) |
|
|
109
|
+
(util_1.util.isNullish((_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.errorData) === null || _d === void 0 ? void 0 : _d.missingKeyIndex) ? 0 : Constants_1.ErrorFlags.MISSING_KEY_IN_PATH));
|
|
110
|
+
if (response.data.errorCode !== Constants_1.ErrorCode.OK &&
|
|
111
|
+
//there's some error data
|
|
112
|
+
Object.values((_e = response.data.errorData) !== null && _e !== void 0 ? _e : {}).some(x => !util_1.util.isNullish(x))) {
|
|
113
|
+
//do these in reverse order since we're writing to the start of the buffer
|
|
114
|
+
if (!util_1.util.isNullish(response.data.errorData.missingKeyIndex)) {
|
|
115
|
+
smartBuffer.insertUInt32LE(response.data.errorData.missingKeyIndex, 0);
|
|
116
|
+
}
|
|
117
|
+
//write error data
|
|
118
|
+
if (!util_1.util.isNullish(response.data.errorData.invalidPathIndex)) {
|
|
119
|
+
smartBuffer.insertUInt32LE(response.data.errorData.invalidPathIndex, 0);
|
|
120
|
+
}
|
|
121
|
+
//write flags
|
|
122
|
+
smartBuffer.insertUInt32LE(flags, 0);
|
|
123
|
+
}
|
|
124
|
+
smartBuffer.insertUInt32LE(response.data.errorCode, 0); // error_code
|
|
125
|
+
smartBuffer.insertUInt32LE(response.data.requestId, 0); // request_id
|
|
126
|
+
smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length
|
|
127
|
+
response.data.packetLength = smartBuffer.writeOffset;
|
|
128
|
+
return smartBuffer;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Inserts the common response fields to the beginning of the buffer, and computes
|
|
132
|
+
* the correct `packet_length` value.
|
|
133
|
+
*/
|
|
134
|
+
insertCommonUpdateFields(update, smartBuffer) {
|
|
135
|
+
smartBuffer.insertUInt32LE(Constants_1.UpdateTypeCode[update.data.updateType], 0); // update_type
|
|
136
|
+
smartBuffer.insertUInt32LE(update.data.errorCode, 0); // error_code
|
|
137
|
+
smartBuffer.insertUInt32LE(update.data.requestId, 0); // request_id
|
|
138
|
+
smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length
|
|
139
|
+
update.data.packetLength = smartBuffer.writeOffset;
|
|
140
|
+
return smartBuffer;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Tries to read a string from the buffer and will throw an error if there is no null terminator.
|
|
144
|
+
* @param {SmartBuffer} bufferReader
|
|
145
|
+
*/
|
|
146
|
+
readStringNT(bufferReader) {
|
|
147
|
+
// Find next null character (if one is not found, throw)
|
|
148
|
+
let buffer = bufferReader.toBuffer();
|
|
149
|
+
let foundNullTerminator = false;
|
|
150
|
+
for (let i = bufferReader.readOffset; i < buffer.length; i++) {
|
|
151
|
+
if (buffer[i] === 0x00) {
|
|
152
|
+
foundNullTerminator = true;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (!foundNullTerminator) {
|
|
157
|
+
throw new Error('Could not read buffer string as there is no null terminator.');
|
|
158
|
+
}
|
|
159
|
+
return bufferReader.readStringNT();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.ProtocolUtil = ProtocolUtil;
|
|
163
|
+
exports.protocolUtil = new ProtocolUtil();
|
|
164
|
+
//# sourceMappingURL=ProtocolUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProtocolUtil.js","sourceRoot":"","sources":["../../src/debugProtocol/ProtocolUtil.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAC3C,kCAA+B;AAE/B,2CAAiF;AAGjF,MAAa,YAAY;IAErB;;OAEG;IACI,QAAQ,CAAC,KAAsC,EAAE,IAAS;QAC7D,KAAK,CAAC,IAAI,GAAG;YACT,GAAG,KAAK,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 +1,310 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PROTOCOL_ERROR_CODES, Command } from '../Constants';
|
|
3
|
+
import { ExecuteV3Response } from '../events/responses/ExecuteV3Response';
|
|
4
|
+
import { ListBreakpointsResponse } from '../events/responses/ListBreakpointsResponse';
|
|
5
|
+
import { AddBreakpointsResponse } from '../events/responses/AddBreakpointsResponse';
|
|
6
|
+
import { ThreadsRequest } from '../events/requests/ThreadsRequest';
|
|
7
|
+
import type { ProtocolRequest, ProtocolResponse, ProtocolUpdate } from '../events/ProtocolEvent';
|
|
8
|
+
import { HandshakeResponse } from '../events/responses/HandshakeResponse';
|
|
9
|
+
import { HandshakeV3Response } from '../events/responses/HandshakeV3Response';
|
|
10
|
+
import { GenericV3Response } from '../events/responses/GenericV3Response';
|
|
11
|
+
import { AllThreadsStoppedUpdate } from '../events/updates/AllThreadsStoppedUpdate';
|
|
12
|
+
import { CompileErrorUpdate } from '../events/updates/CompileErrorUpdate';
|
|
13
|
+
import { GenericResponse } from '../events/responses/GenericResponse';
|
|
14
|
+
import type { StackTraceResponse } from '../events/responses/StackTraceResponse';
|
|
15
|
+
import { ThreadsResponse } from '../events/responses/ThreadsResponse';
|
|
16
|
+
import { VariablesResponse } from '../events/responses/VariablesResponse';
|
|
17
|
+
import { ThreadAttachedUpdate } from '../events/updates/ThreadAttachedUpdate';
|
|
18
|
+
import { StackTraceV3Response } from '../events/responses/StackTraceV3Response';
|
|
19
|
+
import type { DebugProtocolClientPlugin } from './DebugProtocolClientPlugin';
|
|
20
|
+
import PluginInterface from '../PluginInterface';
|
|
21
|
+
import type { VerifiedBreakpoint } from '../events/updates/BreakpointVerifiedUpdate';
|
|
22
|
+
export declare class DebugProtocolClient {
|
|
23
|
+
logger: import("@rokucommunity/logger/dist/Logger").Logger;
|
|
24
|
+
supportedVersionRange: string;
|
|
25
|
+
constructor(options?: ConstructorOptions);
|
|
26
|
+
private addCorePlugin;
|
|
27
|
+
static DEBUGGER_MAGIC: string;
|
|
28
|
+
scriptTitle: string;
|
|
29
|
+
isHandshakeComplete: boolean;
|
|
30
|
+
connectedToIoPort: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Debug protocol version 3.0.0 introduced a packet_length to all responses. Prior to that, most responses had no packet length at all.
|
|
33
|
+
* This field indicates whether we should be looking for packet_length or not in the responses we get from the device
|
|
34
|
+
*/
|
|
35
|
+
watchPacketLength: boolean;
|
|
36
|
+
protocolVersion: string;
|
|
37
|
+
primaryThread: number;
|
|
38
|
+
stackFrameIndex: number;
|
|
39
|
+
/**
|
|
40
|
+
* A collection of plugins that can interact with the client at lifecycle points
|
|
41
|
+
*/
|
|
42
|
+
plugins: PluginInterface<DebugProtocolClientPlugin>;
|
|
43
|
+
private emitter;
|
|
44
|
+
/**
|
|
45
|
+
* The primary socket for this session. It's used to communicate with the debugger by sending commands and receives responses or updates
|
|
46
|
+
*/
|
|
47
|
+
private controlSocket;
|
|
48
|
+
/**
|
|
49
|
+
* Promise that is resolved when the control socket is closed
|
|
50
|
+
*/
|
|
51
|
+
private controlSocketClosed;
|
|
52
|
+
/**
|
|
53
|
+
* A socket where the debug server will send stdio
|
|
54
|
+
*/
|
|
55
|
+
private ioSocket;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves when the ioSocket has closed
|
|
58
|
+
*/
|
|
59
|
+
private ioSocketClosed;
|
|
60
|
+
/**
|
|
61
|
+
* The buffer where all unhandled data will be stored until successfully consumed
|
|
62
|
+
*/
|
|
63
|
+
private buffer;
|
|
64
|
+
/**
|
|
65
|
+
* Is the debugger currently stopped at a line of code in the program
|
|
66
|
+
*/
|
|
67
|
+
isStopped: boolean;
|
|
68
|
+
private requestIdSequence;
|
|
69
|
+
private activeRequests;
|
|
70
|
+
private options;
|
|
71
|
+
/**
|
|
72
|
+
* Prior to protocol v3.1.0, the Roku device would regularly set the wrong thread as "active",
|
|
73
|
+
* so this flag lets us know if we should use our better-than-nothing workaround
|
|
74
|
+
*/
|
|
75
|
+
private get enableThreadHoppingWorkaround();
|
|
76
|
+
/**
|
|
77
|
+
* Starting in protocol v3.1.0, component libary breakpoints must be added in the format `lib:/<library_name>/<filepath>`, but prior they didn't require this.
|
|
78
|
+
* So this flag tells us which format to support
|
|
79
|
+
*/
|
|
80
|
+
private get enableComponentLibrarySpecificBreakpoints();
|
|
81
|
+
/**
|
|
82
|
+
* Starting in protocol v3.1.0, breakpoints can support conditional expressions. This flag indicates whether the current sessuion supports that functionality.
|
|
83
|
+
*/
|
|
84
|
+
private get supportsConditionalBreakpoints();
|
|
85
|
+
get supportsBreakpointRegistrationWhileRunning(): boolean;
|
|
86
|
+
get supportsBreakpointVerification(): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Get a promise that resolves after an event occurs exactly once
|
|
89
|
+
*/
|
|
90
|
+
once(eventName: 'app-exit' | 'cannot-continue' | 'close' | 'start'): Promise<void>;
|
|
91
|
+
once(eventName: 'breakpoints-verified'): Promise<BreakpointsVerifiedEvent>;
|
|
92
|
+
once<T = AllThreadsStoppedUpdate | ThreadAttachedUpdate>(eventName: 'runtime-error' | 'suspend'): Promise<T>;
|
|
93
|
+
once(eventName: 'io-output'): Promise<string>;
|
|
94
|
+
once(eventName: 'data'): Promise<Buffer>;
|
|
95
|
+
once(eventName: 'response'): Promise<ProtocolResponse>;
|
|
96
|
+
once(eventName: 'update'): Promise<ProtocolUpdate>;
|
|
97
|
+
once(eventName: 'protocol-version'): Promise<ProtocolVersionDetails>;
|
|
98
|
+
once(eventName: 'handshake-verified'): Promise<HandshakeResponse>;
|
|
99
|
+
on(eventName: 'compile-error', handler: (event: CompileErrorUpdate) => void): any;
|
|
100
|
+
on(eventName: 'app-exit' | 'cannot-continue' | 'close' | 'start', handler: () => void): any;
|
|
101
|
+
on(eventName: 'breakpoints-verified', handler: (event: BreakpointsVerifiedEvent) => void): any;
|
|
102
|
+
on(eventName: 'response', handler: (response: ProtocolResponse) => void): any;
|
|
103
|
+
on(eventName: 'update', handler: (update: ProtocolUpdate) => void): any;
|
|
104
|
+
/**
|
|
105
|
+
* The raw data from the server socket. You probably don't need this...
|
|
106
|
+
*/
|
|
107
|
+
on(eventName: 'data', handler: (data: Buffer) => void): any;
|
|
108
|
+
on<T = AllThreadsStoppedUpdate | ThreadAttachedUpdate>(eventName: 'runtime-error' | 'suspend', handler: (data: T) => void): any;
|
|
109
|
+
on(eventName: 'io-output', handler: (output: string) => void): any;
|
|
110
|
+
on(eventName: 'protocol-version', handler: (data: ProtocolVersionDetails) => void): any;
|
|
111
|
+
on(eventName: 'handshake-verified', handler: (data: HandshakeResponse) => void): any;
|
|
112
|
+
private emit;
|
|
113
|
+
/**
|
|
114
|
+
* A function that can be used to cancel the repeating interval that's running to try and establish a connection to the control socket.
|
|
115
|
+
*/
|
|
116
|
+
private cancelControlConnectInterval;
|
|
117
|
+
/**
|
|
118
|
+
* A collection of sockets created when trying to connect to the debug protocol's control socket. We keep these around for quicker tear-down
|
|
119
|
+
* whenever there is an early-terminated debug session
|
|
120
|
+
*/
|
|
121
|
+
private pendingControlConnectionSockets;
|
|
122
|
+
private establishControlConnection;
|
|
123
|
+
/**
|
|
124
|
+
* A queue for processing the incoming buffer, every transmission at a time
|
|
125
|
+
*/
|
|
126
|
+
private bufferQueue;
|
|
127
|
+
/**
|
|
128
|
+
* Connect to the debug server.
|
|
129
|
+
* @param sendHandshake should the handshake be sent as part of this connect process. If false, `.sendHandshake()` will need to be called before a session can begin
|
|
130
|
+
*/
|
|
131
|
+
connect(sendHandshake?: boolean): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Send the initial handshake request, and wait for the handshake response
|
|
134
|
+
*/
|
|
135
|
+
sendHandshake(): Promise<HandshakeResponse | HandshakeV3Response>;
|
|
136
|
+
private processHandshakeRequest;
|
|
137
|
+
/**
|
|
138
|
+
* Write a specific buffer log entry to the logger, which, when file logging is enabled
|
|
139
|
+
* can be extracted and processed through the DebugProtocolClientReplaySession
|
|
140
|
+
*/
|
|
141
|
+
private writeToBufferLog;
|
|
142
|
+
continue(): Promise<GenericResponse>;
|
|
143
|
+
private processContinueRequest;
|
|
144
|
+
pause(): Promise<GenericResponse>;
|
|
145
|
+
private processStopRequest;
|
|
146
|
+
/**
|
|
147
|
+
* Send the "exit channel" command, which will tell the debug session to immediately quit
|
|
148
|
+
*/
|
|
149
|
+
exitChannel(): Promise<GenericResponse>;
|
|
150
|
+
stepIn(threadIndex?: number): Promise<GenericResponse>;
|
|
151
|
+
stepOver(threadIndex?: number): Promise<GenericResponse>;
|
|
152
|
+
stepOut(threadIndex?: number): Promise<GenericResponse>;
|
|
153
|
+
private step;
|
|
154
|
+
private processStepRequest;
|
|
155
|
+
threads(): Promise<ThreadsResponse>;
|
|
156
|
+
processThreadsRequest(request: ThreadsRequest): Promise<ThreadsResponse>;
|
|
157
|
+
/**
|
|
158
|
+
* Get the stackTrace from the device IF currently stopped
|
|
159
|
+
*/
|
|
160
|
+
getStackTrace(threadIndex?: number): Promise<StackTraceResponse>;
|
|
161
|
+
private processStackTraceRequest;
|
|
162
|
+
/**
|
|
163
|
+
* @param variablePathEntries One or more path entries to the variable to be inspected. E.g., m.top.myObj["someKey"] can be accessed with ["m","top","myobj","\"someKey\""].
|
|
164
|
+
*
|
|
165
|
+
* If no path is specified, the variables accessible from the specified stack frame are returned.
|
|
166
|
+
*
|
|
167
|
+
* Starting in protocol v3.1.0, The keys for indexed gets (i.e. obj["key"]) should be wrapped in quotes so they can be handled in a case-sensitive fashion (if applicable on device).
|
|
168
|
+
* All non-quoted keys (i.e. strings without leading and trailing quotes inside them) will be treated as case-insensitive).
|
|
169
|
+
* @param getChildKeys If set, VARIABLES response include the child keys for container types like lists and associative arrays
|
|
170
|
+
* @param stackFrameIndex 0 = first function called, nframes-1 = last function. This indexing does not match the order of the frames returned from the STACKTRACE command
|
|
171
|
+
* @param threadIndex the index (or perhaps ID?) of the thread to get variables for
|
|
172
|
+
*/
|
|
173
|
+
getVariables(variablePathEntries?: Array<string>, stackFrameIndex?: number, threadIndex?: number): Promise<VariablesResponse>;
|
|
174
|
+
private processVariablesRequest;
|
|
175
|
+
executeCommand(sourceCode: string, stackFrameIndex?: number, threadIndex?: number): Promise<ExecuteV3Response>;
|
|
176
|
+
private processExecuteRequest;
|
|
177
|
+
addBreakpoints(breakpoints: Array<BreakpointSpec & {
|
|
178
|
+
componentLibraryName?: string;
|
|
179
|
+
}>): Promise<AddBreakpointsResponse>;
|
|
180
|
+
listBreakpoints(): Promise<ListBreakpointsResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Remove breakpoints having the specified IDs
|
|
183
|
+
*/
|
|
184
|
+
removeBreakpoints(breakpointIds: number[]): Promise<ListBreakpointsResponse>;
|
|
185
|
+
private processRemoveBreakpointsRequest;
|
|
186
|
+
/**
|
|
187
|
+
* Given a request, process it in the proper fashion. This is mostly used for external mocking/testing of
|
|
188
|
+
* this client, but it should force the client to flow in the same fashion as a live debug session
|
|
189
|
+
*/
|
|
190
|
+
processRequest<TResponse extends ProtocolResponse>(request: ProtocolRequest): Promise<TResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* Send a request to the roku device, and get a promise that resolves once we have received the response
|
|
193
|
+
*/
|
|
194
|
+
private sendRequest;
|
|
195
|
+
/**
|
|
196
|
+
* Sometimes a request arrives that we don't understand. If that's the case, this function can be used
|
|
197
|
+
* to discard that entire response by discarding `packet_length` number of bytes
|
|
198
|
+
*/
|
|
199
|
+
private discardNextResponseOrUpdate;
|
|
200
|
+
/**
|
|
201
|
+
* A counter to help give a unique id to each update (mostly just for logging purposes)
|
|
202
|
+
*/
|
|
203
|
+
private updateSequence;
|
|
204
|
+
private logEvent;
|
|
205
|
+
private process;
|
|
206
|
+
/**
|
|
207
|
+
* Given a buffer, try to parse into a specific ProtocolResponse or ProtocolUpdate
|
|
208
|
+
*/
|
|
209
|
+
getResponseOrUpdate(buffer: Buffer): Promise<ProtocolResponse | ProtocolUpdate>;
|
|
210
|
+
static getResponse(buffer: Buffer, command: Command): ExecuteV3Response | ListBreakpointsResponse | GenericV3Response | StackTraceV3Response | ThreadsResponse | VariablesResponse;
|
|
211
|
+
getUpdate(buffer: Buffer): ProtocolUpdate;
|
|
212
|
+
private handleUpdateQueue;
|
|
213
|
+
/**
|
|
214
|
+
* Handle/process any received updates from the debug protocol
|
|
215
|
+
*/
|
|
216
|
+
private handleUpdate;
|
|
217
|
+
/**
|
|
218
|
+
* Verify all the handshake data
|
|
219
|
+
*/
|
|
220
|
+
private verifyHandshake;
|
|
221
|
+
/**
|
|
222
|
+
* When the debugger emits the IOPortOpenedUpdate, we need to immediately connect to the IO port to start receiving that data
|
|
223
|
+
*/
|
|
224
|
+
private connectToIoPort;
|
|
225
|
+
/**
|
|
226
|
+
* Destroy this instance, shutting down any sockets or other long-running items and cleaning up.
|
|
227
|
+
* @param immediate if true, all sockets are immediately closed and do not gracefully shut down
|
|
228
|
+
*/
|
|
229
|
+
destroy(immediate?: boolean): Promise<void>;
|
|
230
|
+
private shutdown;
|
|
231
|
+
private isDestroyingControlSocket;
|
|
232
|
+
private destroyControlSocket;
|
|
233
|
+
private isDestroyingIOSocket;
|
|
234
|
+
/**
|
|
235
|
+
* @param immediate if true, force close immediately instead of waiting for it to settle
|
|
236
|
+
*/
|
|
237
|
+
private destroyIOSocket;
|
|
238
|
+
}
|
|
239
|
+
export interface ProtocolVersionDetails {
|
|
240
|
+
message: string;
|
|
241
|
+
errorCode: PROTOCOL_ERROR_CODES;
|
|
242
|
+
}
|
|
243
|
+
export interface BreakpointSpec {
|
|
244
|
+
/**
|
|
245
|
+
* The path of the source file where the breakpoint is to be inserted.
|
|
246
|
+
*/
|
|
247
|
+
filePath: string;
|
|
248
|
+
/**
|
|
249
|
+
* The (1-based) line number in the channel application code where the breakpoint is to be executed.
|
|
250
|
+
*/
|
|
251
|
+
lineNumber: number;
|
|
252
|
+
/**
|
|
253
|
+
* The number of times to ignore the breakpoint condition before executing the breakpoint. This number is decremented each time the channel application reaches the breakpoint.
|
|
254
|
+
*/
|
|
255
|
+
hitCount?: number;
|
|
256
|
+
/**
|
|
257
|
+
* BrightScript code that evaluates to a boolean value. The expression is compiled and executed in
|
|
258
|
+
* the context where the breakpoint is located. If specified, the hitCount is only be
|
|
259
|
+
* updated if this evaluates to true.
|
|
260
|
+
* @avaiable since protocol version 3.1.0
|
|
261
|
+
*/
|
|
262
|
+
conditionalExpression?: string;
|
|
263
|
+
}
|
|
264
|
+
export interface ConstructorOptions {
|
|
265
|
+
/**
|
|
266
|
+
* The host/ip address of the Roku
|
|
267
|
+
*/
|
|
268
|
+
host: string;
|
|
269
|
+
/**
|
|
270
|
+
* The port number used to send all debugger commands. This is static/unchanging for Roku devices,
|
|
271
|
+
* but is configurable here to support unit testing or alternate runtimes (i.e. https://www.npmjs.com/package/brs)
|
|
272
|
+
*/
|
|
273
|
+
controlPort?: number;
|
|
274
|
+
/**
|
|
275
|
+
* The interval (in milliseconds) for how frequently the `connect`
|
|
276
|
+
* call should retry connecting to the control port. At the start of a debug session,
|
|
277
|
+
* the protocol debugger will start trying to connect the moment the channel is sideloaded,
|
|
278
|
+
* and keep trying until a successful connection is established or the debug session is terminated
|
|
279
|
+
* @default 250
|
|
280
|
+
*/
|
|
281
|
+
controlConnectInterval?: number;
|
|
282
|
+
/**
|
|
283
|
+
* The maximum time (in milliseconds) the debugger will keep retrying connections.
|
|
284
|
+
* This is here to prevent infinitely pinging the Roku device.
|
|
285
|
+
*/
|
|
286
|
+
controlConnectMaxTime?: number;
|
|
287
|
+
/**
|
|
288
|
+
* The number of milliseconds that the client should wait during a shutdown request before forcefully terminating the sockets
|
|
289
|
+
*/
|
|
290
|
+
shutdownTimeout?: number;
|
|
291
|
+
/**
|
|
292
|
+
* The max time the client will wait for the `exit channel` response before forcefully terminating the sockets
|
|
293
|
+
*/
|
|
294
|
+
exitChannelTimeout?: number;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Is the event a ProtocolRequest
|
|
298
|
+
*/
|
|
299
|
+
export declare function isProtocolRequest(event: ProtocolRequest | ProtocolResponse | ProtocolUpdate): event is ProtocolRequest;
|
|
300
|
+
/**
|
|
301
|
+
* Is the event a ProtocolResponse
|
|
302
|
+
*/
|
|
303
|
+
export declare function isProtocolResponse(event: ProtocolRequest | ProtocolResponse | ProtocolUpdate): event is ProtocolResponse;
|
|
304
|
+
/**
|
|
305
|
+
* Is the event a ProtocolUpdate update
|
|
306
|
+
*/
|
|
307
|
+
export declare function isProtocolUpdate(event: ProtocolRequest | ProtocolResponse | ProtocolUpdate): event is ProtocolUpdate;
|
|
308
|
+
export interface BreakpointsVerifiedEvent {
|
|
309
|
+
breakpoints: VerifiedBreakpoint[];
|
|
310
|
+
}
|