roku-debug 0.20.6 → 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 +6 -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/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 +14 -5
- 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.6.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
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KeyType = exports.EventName = exports.DebugProtocolAdapter = void 0;
|
|
4
|
-
const Debugger_1 = require("../debugProtocol/Debugger");
|
|
3
|
+
exports.isDebugProtocolAdapter = exports.KeyType = exports.EventName = exports.DebugProtocolAdapter = void 0;
|
|
5
4
|
const EventEmitter = require("events");
|
|
6
5
|
const net_1 = require("net");
|
|
6
|
+
const brighterscript_1 = require("brighterscript");
|
|
7
7
|
const CompileErrorProcessor_1 = require("../CompileErrorProcessor");
|
|
8
8
|
const ChanperfTracker_1 = require("../ChanperfTracker");
|
|
9
9
|
const Constants_1 = require("../debugProtocol/Constants");
|
|
10
10
|
const util_1 = require("../util");
|
|
11
11
|
const logging_1 = require("../logging");
|
|
12
12
|
const semver = require("semver");
|
|
13
|
-
const
|
|
13
|
+
const DebugProtocolClient_1 = require("../debugProtocol/client/DebugProtocolClient");
|
|
14
|
+
const VariablesResponse_1 = require("../debugProtocol/events/responses/VariablesResponse");
|
|
14
15
|
/**
|
|
15
16
|
* A class that connects to a Roku device over telnet debugger port and provides a standardized way of interacting with it.
|
|
16
17
|
*/
|
|
17
18
|
class DebugProtocolAdapter {
|
|
18
|
-
constructor(options, projectManager, breakpointManager, rendezvousTracker) {
|
|
19
|
+
constructor(options, projectManager, breakpointManager, rendezvousTracker, deviceInfo) {
|
|
19
20
|
this.options = options;
|
|
20
21
|
this.projectManager = projectManager;
|
|
21
22
|
this.breakpointManager = breakpointManager;
|
|
22
23
|
this.rendezvousTracker = rendezvousTracker;
|
|
23
|
-
this.
|
|
24
|
+
this.deviceInfo = deviceInfo;
|
|
25
|
+
this.logger = logging_1.logger.createLogger(`[padapter]`);
|
|
24
26
|
/**
|
|
25
27
|
* Due to casing issues with the variables request on some versions of the debug protocol, we first need to try the request in the supplied case.
|
|
26
28
|
* If that fails we retry in lower case. This flag is used to drive that logic switching
|
|
@@ -39,7 +41,12 @@ class DebugProtocolAdapter {
|
|
|
39
41
|
* which indicates that the app is running on the Roku
|
|
40
42
|
*/
|
|
41
43
|
this.isAppRunning = false;
|
|
42
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Indicates whether this class had `.destroy()` called at least once. Mostly used for checking externally to see if
|
|
46
|
+
* the whole debug session has been terminated or is in a bad state.
|
|
47
|
+
*/
|
|
48
|
+
this.isDestroyed = false;
|
|
49
|
+
this.syncBreakpointsPromise = Promise.resolve();
|
|
43
50
|
util_1.util.normalizeAdapterOptions(this.options);
|
|
44
51
|
this.emitter = new EventEmitter();
|
|
45
52
|
this.chanperfTracker = new ChanperfTracker_1.ChanperfTracker();
|
|
@@ -57,12 +64,20 @@ class DebugProtocolAdapter {
|
|
|
57
64
|
var _a;
|
|
58
65
|
return (_a = this.socketDebugger) === null || _a === void 0 ? void 0 : _a.protocolVersion;
|
|
59
66
|
}
|
|
67
|
+
once(eventName) {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
const disconnect = this.on(eventName, (...args) => {
|
|
70
|
+
disconnect();
|
|
71
|
+
resolve(...args);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
60
75
|
on(eventName, handler) {
|
|
61
|
-
|
|
76
|
+
var _a;
|
|
77
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.on(eventName, handler);
|
|
62
78
|
return () => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
79
|
+
var _a;
|
|
80
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.removeListener(eventName, handler);
|
|
66
81
|
};
|
|
67
82
|
}
|
|
68
83
|
emit(eventName, data) {
|
|
@@ -126,7 +141,7 @@ class DebugProtocolAdapter {
|
|
|
126
141
|
*/
|
|
127
142
|
async connect() {
|
|
128
143
|
let deferred = (0, util_1.defer)();
|
|
129
|
-
this.socketDebugger = new
|
|
144
|
+
this.socketDebugger = new DebugProtocolClient_1.DebugProtocolClient(this.options);
|
|
130
145
|
try {
|
|
131
146
|
// Emit IO from the debugger.
|
|
132
147
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
@@ -176,7 +191,7 @@ class DebugProtocolAdapter {
|
|
|
176
191
|
console.debug('hasRuntimeError!!', data);
|
|
177
192
|
this.emit('runtime-error', {
|
|
178
193
|
message: data.data.stopReasonDetail,
|
|
179
|
-
errorCode:
|
|
194
|
+
errorCode: data.data.stopReason
|
|
180
195
|
});
|
|
181
196
|
});
|
|
182
197
|
this.socketDebugger.on('cannot-continue', () => {
|
|
@@ -185,9 +200,18 @@ class DebugProtocolAdapter {
|
|
|
185
200
|
//handle when the device verifies breakpoints
|
|
186
201
|
this.socketDebugger.on('breakpoints-verified', (event) => {
|
|
187
202
|
var _a;
|
|
203
|
+
let unverifiableDeviceIds = [];
|
|
188
204
|
//mark the breakpoints as verified
|
|
189
205
|
for (let breakpoint of (_a = event === null || event === void 0 ? void 0 : event.breakpoints) !== null && _a !== void 0 ? _a : []) {
|
|
190
|
-
this.breakpointManager.verifyBreakpoint(breakpoint.
|
|
206
|
+
const success = this.breakpointManager.verifyBreakpoint(breakpoint.id, true);
|
|
207
|
+
if (!success) {
|
|
208
|
+
unverifiableDeviceIds.push(breakpoint.id);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//if there were any unsuccessful breakpoint verifications, we need to ask the device to delete those breakpoints as they've gone missing on our side
|
|
212
|
+
if (unverifiableDeviceIds.length > 0) {
|
|
213
|
+
this.logger.warn('Could not find breakpoints to verify. Removing from device:', { deviceBreakpointIds: unverifiableDeviceIds });
|
|
214
|
+
void this.socketDebugger.removeBreakpoints(unverifiableDeviceIds);
|
|
191
215
|
}
|
|
192
216
|
this.emit('breakpoints-verified', event);
|
|
193
217
|
});
|
|
@@ -198,6 +222,17 @@ class DebugProtocolAdapter {
|
|
|
198
222
|
this.compileClient.destroy();
|
|
199
223
|
this.compileClient = undefined;
|
|
200
224
|
}
|
|
225
|
+
this.socketDebugger.on('compile-error', (update) => {
|
|
226
|
+
let diagnostics = [];
|
|
227
|
+
diagnostics.push({
|
|
228
|
+
path: update.data.filePath,
|
|
229
|
+
range: brighterscript_1.util.createRange(update.data.lineNumber - 1, 0, update.data.lineNumber - 1, 999),
|
|
230
|
+
message: update.data.errorMessage,
|
|
231
|
+
severity: brighterscript_1.DiagnosticSeverity.Error,
|
|
232
|
+
code: undefined
|
|
233
|
+
});
|
|
234
|
+
this.emit('diagnostics', diagnostics);
|
|
235
|
+
});
|
|
201
236
|
this.logger.log(`Connected to device`, { host: this.options.host, connected: this.connected });
|
|
202
237
|
this.emit('connected', this.connected);
|
|
203
238
|
//the adapter is connected and running smoothly. resolve the promise
|
|
@@ -214,8 +249,18 @@ class DebugProtocolAdapter {
|
|
|
214
249
|
this.emit('app-exit');
|
|
215
250
|
}, 200);
|
|
216
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Determines if the current version of the debug protocol supports emitting compile error updates.
|
|
254
|
+
*/
|
|
255
|
+
get supportsCompileErrorReporting() {
|
|
256
|
+
return semver.satisfies(this.deviceInfo['brightscript-debugger-version'], '>=3.1.0');
|
|
257
|
+
}
|
|
217
258
|
async watchCompileOutput() {
|
|
218
259
|
let deferred = (0, util_1.defer)();
|
|
260
|
+
//If the debugProtocol supports compile error updates, don't scrape telnet logs for compile errors
|
|
261
|
+
if (this.supportsCompileErrorReporting) {
|
|
262
|
+
return deferred.resolve();
|
|
263
|
+
}
|
|
219
264
|
try {
|
|
220
265
|
this.compileClient = new net_1.Socket();
|
|
221
266
|
this.compileErrorProcessor.on('diagnostics', (errors) => {
|
|
@@ -228,7 +273,7 @@ class DebugProtocolAdapter {
|
|
|
228
273
|
});
|
|
229
274
|
this.logger.info('Connecting via telnet to gather compile info', { host: this.options.host, port: this.options.brightScriptConsolePort });
|
|
230
275
|
this.compileClient.connect(this.options.brightScriptConsolePort, this.options.host, () => {
|
|
231
|
-
this.logger.log(`
|
|
276
|
+
this.logger.log(`CONNECTED via telnet to gather compile info`, { host: this.options.host, port: this.options.brightScriptConsolePort });
|
|
232
277
|
});
|
|
233
278
|
this.logger.debug('Waiting for the compile client to settle');
|
|
234
279
|
await this.settle(this.compileClient, 'data');
|
|
@@ -305,7 +350,7 @@ class DebugProtocolAdapter {
|
|
|
305
350
|
* @returns the output of the command (if possible)
|
|
306
351
|
*/
|
|
307
352
|
async evaluate(command, frameId = this.socketDebugger.primaryThread) {
|
|
308
|
-
var _a, _b, _c;
|
|
353
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
309
354
|
if (this.supportsExecuteCommand) {
|
|
310
355
|
if (!this.isAtDebuggerPrompt) {
|
|
311
356
|
throw new Error('Cannot run evaluate: debugger is not paused');
|
|
@@ -317,15 +362,20 @@ class DebugProtocolAdapter {
|
|
|
317
362
|
this.logger.log('evaluate ', { command, frameId });
|
|
318
363
|
const response = await this.socketDebugger.executeCommand(command, stackFrame.frameIndex, stackFrame.threadIndex);
|
|
319
364
|
this.logger.info('evaluate response', { command, response });
|
|
320
|
-
if (response.executeSuccess) {
|
|
365
|
+
if (response.data.executeSuccess) {
|
|
321
366
|
return {
|
|
322
367
|
message: undefined,
|
|
323
368
|
type: 'message'
|
|
324
369
|
};
|
|
325
370
|
}
|
|
326
371
|
else {
|
|
372
|
+
const messages = [
|
|
373
|
+
...(_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.compileErrors) !== null && _b !== void 0 ? _b : [],
|
|
374
|
+
...(_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.runtimeErrors) !== null && _d !== void 0 ? _d : [],
|
|
375
|
+
...(_f = (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.otherErrors) !== null && _f !== void 0 ? _f : []
|
|
376
|
+
];
|
|
327
377
|
return {
|
|
328
|
-
message: (
|
|
378
|
+
message: (_g = messages[0]) !== null && _g !== void 0 ? _g : 'Unknown error executing command',
|
|
329
379
|
type: 'error'
|
|
330
380
|
};
|
|
331
381
|
}
|
|
@@ -337,24 +387,24 @@ class DebugProtocolAdapter {
|
|
|
337
387
|
};
|
|
338
388
|
}
|
|
339
389
|
}
|
|
340
|
-
async getStackTrace(
|
|
390
|
+
async getStackTrace(threadIndex = this.socketDebugger.primaryThread) {
|
|
341
391
|
if (!this.isAtDebuggerPrompt) {
|
|
342
392
|
throw new Error('Cannot get stack trace: debugger is not paused');
|
|
343
393
|
}
|
|
344
|
-
return this.resolve(`stack trace for thread ${
|
|
345
|
-
var _a, _b;
|
|
346
|
-
var
|
|
347
|
-
let thread = await this.getThreadByThreadId(
|
|
394
|
+
return this.resolve(`stack trace for thread ${threadIndex}`, async () => {
|
|
395
|
+
var _a, _b, _c, _d, _e;
|
|
396
|
+
var _f, _g;
|
|
397
|
+
let thread = await this.getThreadByThreadId(threadIndex);
|
|
348
398
|
let frames = [];
|
|
349
|
-
let stackTraceData = await this.socketDebugger.
|
|
350
|
-
for (let i = 0; i < stackTraceData.
|
|
351
|
-
let frameData = stackTraceData.entries[i];
|
|
399
|
+
let stackTraceData = await this.socketDebugger.getStackTrace(threadIndex);
|
|
400
|
+
for (let i = 0; (_c = i < ((_b = (_a = stackTraceData === null || stackTraceData === void 0 ? void 0 : stackTraceData.data) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.length)) !== null && _c !== void 0 ? _c : 0; i++) {
|
|
401
|
+
let frameData = stackTraceData.data.entries[i];
|
|
352
402
|
let stackFrame = {
|
|
353
403
|
frameId: this.nextFrameId++,
|
|
354
404
|
// frame index is the reverse of the returned order.
|
|
355
|
-
frameIndex: stackTraceData.
|
|
356
|
-
threadIndex:
|
|
357
|
-
filePath: frameData.
|
|
405
|
+
frameIndex: stackTraceData.data.entries.length - i - 1,
|
|
406
|
+
threadIndex: threadIndex,
|
|
407
|
+
filePath: frameData.filePath,
|
|
358
408
|
lineNumber: frameData.lineNumber,
|
|
359
409
|
// eslint-disable-next-line no-nested-ternary
|
|
360
410
|
functionIdentifier: this.cleanUpFunctionName(i === 0 ? (frameData.functionName) ? frameData.functionName : thread.functionName : frameData.functionName)
|
|
@@ -364,8 +414,8 @@ class DebugProtocolAdapter {
|
|
|
364
414
|
}
|
|
365
415
|
//if the first frame is missing any data, suppliment with thread information
|
|
366
416
|
if (frames[0]) {
|
|
367
|
-
(
|
|
368
|
-
(
|
|
417
|
+
(_d = (_f = frames[0]).filePath) !== null && _d !== void 0 ? _d : (_f.filePath = thread.filePath);
|
|
418
|
+
(_e = (_g = frames[0]).lineNumber) !== null && _e !== void 0 ? _e : (_g.lineNumber = thread.lineNumber);
|
|
369
419
|
}
|
|
370
420
|
return frames;
|
|
371
421
|
});
|
|
@@ -377,11 +427,12 @@ class DebugProtocolAdapter {
|
|
|
377
427
|
return functionName.substring(functionName.lastIndexOf('@') + 1);
|
|
378
428
|
}
|
|
379
429
|
/**
|
|
380
|
-
*
|
|
381
|
-
* @param expression
|
|
430
|
+
* Get info about the specified variable.
|
|
431
|
+
* @param expression the expression for the specified variable (i.e. `m`, `someVar.value`, `arr[1][2].three`). If empty string/undefined is specified, all local variables are retrieved instead
|
|
382
432
|
*/
|
|
383
|
-
async
|
|
384
|
-
const
|
|
433
|
+
async getVariablesResponse(expression, frameId) {
|
|
434
|
+
const isScopesRequest = expression === '';
|
|
435
|
+
const logger = this.logger.createLogger('[getVariable]');
|
|
385
436
|
logger.info('begin', { expression });
|
|
386
437
|
if (!this.isAtDebuggerPrompt) {
|
|
387
438
|
throw new Error('Cannot resolve variable: debugger is not paused');
|
|
@@ -390,89 +441,122 @@ class DebugProtocolAdapter {
|
|
|
390
441
|
if (!frame) {
|
|
391
442
|
throw new Error('Cannot request variable without a corresponding frame');
|
|
392
443
|
}
|
|
393
|
-
logger.
|
|
444
|
+
logger.info(`Expression:`, JSON.stringify(expression));
|
|
394
445
|
let variablePath = expression === '' ? [] : util_1.util.getVariablePath(expression);
|
|
395
446
|
// Temporary workaround related to casing issues over the protocol
|
|
396
447
|
if (this.enableVariablesLowerCaseRetry && (variablePath === null || variablePath === void 0 ? void 0 : variablePath.length) > 0) {
|
|
397
448
|
variablePath[0] = variablePath[0].toLowerCase();
|
|
398
449
|
}
|
|
399
|
-
let response = await this.socketDebugger.getVariables(variablePath,
|
|
400
|
-
if (this.enableVariablesLowerCaseRetry && response.errorCode !== Constants_1.
|
|
450
|
+
let response = await this.socketDebugger.getVariables(variablePath, frame.frameIndex, frame.threadIndex);
|
|
451
|
+
if (this.enableVariablesLowerCaseRetry && response.data.errorCode !== Constants_1.ErrorCode.OK) {
|
|
401
452
|
// Temporary workaround related to casing issues over the protocol
|
|
402
453
|
logger.log(`Retrying expression as lower case:`, expression);
|
|
403
454
|
variablePath = expression === '' ? [] : util_1.util.getVariablePath(expression === null || expression === void 0 ? void 0 : expression.toLowerCase());
|
|
404
|
-
response = await this.socketDebugger.getVariables(variablePath,
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
455
|
+
response = await this.socketDebugger.getVariables(variablePath, frame.frameIndex, frame.threadIndex);
|
|
456
|
+
}
|
|
457
|
+
return response;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Get the variable for the specified expression.
|
|
461
|
+
*/
|
|
462
|
+
async getVariable(expression, frameId) {
|
|
463
|
+
var _a;
|
|
464
|
+
const response = await this.getVariablesResponse(expression, frameId);
|
|
465
|
+
if (Array.isArray((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.variables)) {
|
|
466
|
+
const container = this.createEvaluateContainer(response.data.variables[0],
|
|
467
|
+
//the name of the top container is the expression itself
|
|
468
|
+
expression,
|
|
469
|
+
//this is the top-level container, so there are no parent keys to this entry
|
|
470
|
+
undefined);
|
|
471
|
+
return container;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get the list of local variables
|
|
476
|
+
*/
|
|
477
|
+
async getLocalVariables(frameId) {
|
|
478
|
+
var _a, _b;
|
|
479
|
+
const response = await this.getVariablesResponse('', frameId);
|
|
480
|
+
if (((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.errorCode) === Constants_1.ErrorCode.OK && Array.isArray((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.variables)) {
|
|
481
|
+
//create a top-level container to hold all the local vars
|
|
482
|
+
const container = this.createEvaluateContainer(
|
|
483
|
+
//dummy data
|
|
484
|
+
{
|
|
485
|
+
isConst: false,
|
|
486
|
+
isContainer: true,
|
|
487
|
+
keyType: VariablesResponse_1.VariableType.String,
|
|
488
|
+
refCount: undefined,
|
|
489
|
+
type: VariablesResponse_1.VariableType.AssociativeArray,
|
|
490
|
+
value: undefined,
|
|
491
|
+
children: response.data.variables
|
|
492
|
+
},
|
|
493
|
+
//no name, this is a dummy container
|
|
494
|
+
undefined,
|
|
495
|
+
//there's no parent path
|
|
496
|
+
undefined);
|
|
497
|
+
return container;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Create an EvaluateContainer for the given variable. If the variable has children, those are created and attached as well
|
|
502
|
+
* @param variable a Variable object from the debug protocol debugger
|
|
503
|
+
* @param name the name of this variable. For example, `alpha.beta.charlie`, this value would be `charlie`. For local vars, this is the root variable name (i.e. `alpha`)
|
|
504
|
+
* @param parentEvaluateName the string used to derive the parent, _excluding_ this variable's name (i.e. `alpha.beta` or `alpha[0]`)
|
|
505
|
+
*/
|
|
506
|
+
createEvaluateContainer(variable, name, parentEvaluateName) {
|
|
507
|
+
var _a, _b, _c;
|
|
508
|
+
let value;
|
|
509
|
+
let variableType = variable.type;
|
|
510
|
+
if (variable.value === null) {
|
|
511
|
+
value = 'roInvalid';
|
|
512
|
+
}
|
|
513
|
+
else if (variableType === 'String') {
|
|
514
|
+
value = `\"${variable.value}\"`;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
value = variable.value;
|
|
518
|
+
}
|
|
519
|
+
if (variableType === VariablesResponse_1.VariableType.SubtypedObject) {
|
|
520
|
+
//subtyped objects can only have string values
|
|
521
|
+
let parts = variable.value.split('; ');
|
|
522
|
+
variableType = `${parts[0]} (${parts[1]})`;
|
|
523
|
+
}
|
|
524
|
+
else if (variableType === VariablesResponse_1.VariableType.AssociativeArray) {
|
|
525
|
+
variableType = VariablesResponse_1.VariableType.AssociativeArray;
|
|
526
|
+
}
|
|
527
|
+
//build full evaluate name for this var. (i.e. `alpha["beta"]` + ["charlie"]` === `alpha["beta"]["charlie"]`)
|
|
528
|
+
let evaluateName;
|
|
529
|
+
if (!(parentEvaluateName === null || parentEvaluateName === void 0 ? void 0 : parentEvaluateName.trim())) {
|
|
530
|
+
evaluateName = name;
|
|
531
|
+
}
|
|
532
|
+
else if (typeof name === 'string') {
|
|
533
|
+
evaluateName = `${parentEvaluateName}["${name}"]`;
|
|
534
|
+
}
|
|
535
|
+
else if (typeof name === 'number') {
|
|
536
|
+
evaluateName = `${parentEvaluateName}[${name}]`;
|
|
537
|
+
}
|
|
538
|
+
let container = {
|
|
539
|
+
name: name !== null && name !== void 0 ? name : '',
|
|
540
|
+
evaluateName: evaluateName !== null && evaluateName !== void 0 ? evaluateName : '',
|
|
541
|
+
type: variableType !== null && variableType !== void 0 ? variableType : '',
|
|
542
|
+
value: value !== null && value !== void 0 ? value : null,
|
|
543
|
+
highLevelType: undefined,
|
|
544
|
+
//non object/array variables don't have a key type
|
|
545
|
+
keyType: variable.keyType,
|
|
546
|
+
elementCount: (_c = (_a = variable.childCount) !== null && _a !== void 0 ? _a : (_b = variable.children) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : undefined,
|
|
547
|
+
//non object/array variables still need to have an empty `children` array to help upstream logic. The `keyType` being null is how we know it doesn't actually have children
|
|
548
|
+
children: []
|
|
549
|
+
};
|
|
550
|
+
//recursively generate children containers
|
|
551
|
+
if ([KeyType.integer, KeyType.string].includes(container.keyType) && Array.isArray(variable.children)) {
|
|
552
|
+
container.children = [];
|
|
553
|
+
for (let i = 0; i < variable.children.length; i++) {
|
|
554
|
+
const childVariable = variable.children[i];
|
|
555
|
+
const childContainer = this.createEvaluateContainer(childVariable, container.keyType === KeyType.integer ? i.toString() : childVariable.name, container.evaluateName);
|
|
556
|
+
container.children.push(childContainer);
|
|
472
557
|
}
|
|
473
|
-
mainContainer.children = children;
|
|
474
|
-
return mainContainer;
|
|
475
558
|
}
|
|
559
|
+
return container;
|
|
476
560
|
}
|
|
477
561
|
/**
|
|
478
562
|
* Cache items by a unique key
|
|
@@ -495,18 +579,19 @@ class DebugProtocolAdapter {
|
|
|
495
579
|
throw new Error('Cannot get threads: debugger is not paused');
|
|
496
580
|
}
|
|
497
581
|
return this.resolve('threads', async () => {
|
|
582
|
+
var _a, _b, _c;
|
|
498
583
|
let threads = [];
|
|
499
|
-
let
|
|
500
|
-
for (let i = 0; i <
|
|
501
|
-
let threadInfo =
|
|
584
|
+
let threadsResponse = await this.socketDebugger.threads();
|
|
585
|
+
for (let i = 0; (_c = i < ((_b = (_a = threadsResponse.data) === null || _a === void 0 ? void 0 : _a.threads) === null || _b === void 0 ? void 0 : _b.length)) !== null && _c !== void 0 ? _c : 0; i++) {
|
|
586
|
+
let threadInfo = threadsResponse.data.threads[i];
|
|
502
587
|
let thread = {
|
|
503
588
|
// NOTE: On THREAD_ATTACHED events the threads request is marking the wrong thread as primary.
|
|
504
589
|
// NOTE: Rely on the thead index from the threads update event.
|
|
505
590
|
isSelected: this.socketDebugger.primaryThread === i,
|
|
506
591
|
// isSelected: threadInfo.isPrimary,
|
|
507
|
-
filePath: threadInfo.
|
|
592
|
+
filePath: threadInfo.filePath,
|
|
508
593
|
functionName: threadInfo.functionName,
|
|
509
|
-
lineNumber: threadInfo.lineNumber
|
|
594
|
+
lineNumber: threadInfo.lineNumber,
|
|
510
595
|
lineContents: threadInfo.codeSnippet,
|
|
511
596
|
threadId: i
|
|
512
597
|
};
|
|
@@ -528,21 +613,26 @@ class DebugProtocolAdapter {
|
|
|
528
613
|
}
|
|
529
614
|
}
|
|
530
615
|
removeAllListeners() {
|
|
531
|
-
|
|
532
|
-
|
|
616
|
+
if (this.emitter) {
|
|
617
|
+
this.emitter.removeAllListeners();
|
|
618
|
+
}
|
|
533
619
|
}
|
|
534
620
|
/**
|
|
535
621
|
* Disconnect from the telnet session and unset all objects
|
|
536
622
|
*/
|
|
537
623
|
async destroy() {
|
|
624
|
+
this.isDestroyed = true;
|
|
625
|
+
// destroy the debug client if it's defined
|
|
538
626
|
if (this.socketDebugger) {
|
|
539
|
-
|
|
540
|
-
|
|
627
|
+
try {
|
|
628
|
+
await this.socketDebugger.destroy();
|
|
629
|
+
}
|
|
630
|
+
catch (e) {
|
|
631
|
+
this.logger.error(e);
|
|
632
|
+
}
|
|
541
633
|
}
|
|
542
634
|
this.cache = undefined;
|
|
543
|
-
|
|
544
|
-
this.emitter.removeAllListeners();
|
|
545
|
-
}
|
|
635
|
+
this.removeAllListeners();
|
|
546
636
|
this.emitter = undefined;
|
|
547
637
|
}
|
|
548
638
|
/**
|
|
@@ -566,20 +656,34 @@ class DebugProtocolAdapter {
|
|
|
566
656
|
this.chanperfTracker.clearHistory();
|
|
567
657
|
}
|
|
568
658
|
async syncBreakpoints() {
|
|
659
|
+
this.logger.log('syncBreakpoints()');
|
|
660
|
+
//wait for the previous sync to finish
|
|
661
|
+
this.syncBreakpointsPromise = this.syncBreakpointsPromise
|
|
662
|
+
//ignore any errors
|
|
663
|
+
.catch(() => { })
|
|
664
|
+
//run the next sync
|
|
665
|
+
.then(() => this._syncBreakpoints());
|
|
666
|
+
//return the new promise, which will resolve once our latest `syncBreakpoints()` call is finished
|
|
667
|
+
return this.syncBreakpointsPromise;
|
|
668
|
+
}
|
|
669
|
+
async _syncBreakpoints() {
|
|
670
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
569
671
|
//we can't send breakpoints unless we're stopped (or in a protocol version that supports sending them while running).
|
|
570
672
|
//So...if we're not stopped, quit now. (we'll get called again when the stop event happens)
|
|
571
|
-
if (!this.socketDebugger.supportsBreakpointRegistrationWhileRunning && !this.isAtDebuggerPrompt) {
|
|
673
|
+
if (!((_a = this.socketDebugger) === null || _a === void 0 ? void 0 : _a.supportsBreakpointRegistrationWhileRunning) && !this.isAtDebuggerPrompt) {
|
|
572
674
|
return;
|
|
573
675
|
}
|
|
574
676
|
//compute breakpoint changes since last sync
|
|
575
677
|
const diff = await this.breakpointManager.getDiff(this.projectManager.getAllProjects());
|
|
576
|
-
|
|
678
|
+
this.logger.log('Syncing breakpoints', diff);
|
|
679
|
+
// REMOVE breakpoints (delete these breakpoints from the device)
|
|
577
680
|
if (diff.removed.length > 0) {
|
|
578
|
-
await this.
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
681
|
+
const response = await this.socketDebugger.removeBreakpoints(
|
|
682
|
+
//TODO handle retrying to remove breakpoints that don't have deviceIds yet but might get one in the future
|
|
683
|
+
diff.removed.map(x => x.deviceId).filter(x => typeof x === 'number'));
|
|
684
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.errorCode) === Constants_1.ErrorCode.NOT_STOPPED) {
|
|
685
|
+
this.breakpointManager.failedDeletions.push(...diff.removed);
|
|
686
|
+
}
|
|
583
687
|
}
|
|
584
688
|
if (diff.added.length > 0) {
|
|
585
689
|
const breakpointsToSendToDevice = diff.added.map(breakpoint => {
|
|
@@ -589,45 +693,44 @@ class DebugProtocolAdapter {
|
|
|
589
693
|
lineNumber: breakpoint.line,
|
|
590
694
|
hitCount: !isNaN(hitCount) ? hitCount : undefined,
|
|
591
695
|
conditionalExpression: breakpoint.condition,
|
|
592
|
-
|
|
696
|
+
srcHash: breakpoint.srcHash,
|
|
697
|
+
destHash: breakpoint.destHash,
|
|
593
698
|
componentLibraryName: breakpoint.componentLibraryName
|
|
594
699
|
};
|
|
595
700
|
});
|
|
596
|
-
//
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
for (const breakpoint of breakpointsToSendToDevice) {
|
|
604
|
-
if ((_a = breakpoint === null || breakpoint === void 0 ? void 0 : breakpoint.conditionalExpression) === null || _a === void 0 ? void 0 : _a.trim()) {
|
|
605
|
-
conditionalBreakpoints.push(breakpoint);
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
standardBreakpoints.push(breakpoint);
|
|
609
|
-
}
|
|
701
|
+
//split the list into conditional and non-conditional breakpoints.
|
|
702
|
+
//(TODO we can eliminate this splitting logic once the conditional breakpoints "continue" bug in protocol is fixed)
|
|
703
|
+
const standardBreakpoints = [];
|
|
704
|
+
const conditionalBreakpoints = [];
|
|
705
|
+
for (const breakpoint of breakpointsToSendToDevice) {
|
|
706
|
+
if ((_c = breakpoint === null || breakpoint === void 0 ? void 0 : breakpoint.conditionalExpression) === null || _c === void 0 ? void 0 : _c.trim()) {
|
|
707
|
+
conditionalBreakpoints.push(breakpoint);
|
|
610
708
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
709
|
+
else {
|
|
710
|
+
standardBreakpoints.push(breakpoint);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
for (const breakpoints of [standardBreakpoints, conditionalBreakpoints]) {
|
|
714
|
+
const response = await this.socketDebugger.addBreakpoints(breakpoints);
|
|
715
|
+
//if the response was successful, and we have the correct number of breakpoints in the response
|
|
716
|
+
if (response.data.errorCode === Constants_1.ErrorCode.OK && ((_e = (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.breakpoints) === null || _e === void 0 ? void 0 : _e.length) === breakpoints.length) {
|
|
717
|
+
for (let i = 0; (_h = i < ((_g = (_f = response === null || response === void 0 ? void 0 : response.data) === null || _f === void 0 ? void 0 : _f.breakpoints) === null || _g === void 0 ? void 0 : _g.length)) !== null && _h !== void 0 ? _h : 0; i++) {
|
|
718
|
+
const deviceBreakpoint = response.data.breakpoints[i];
|
|
719
|
+
if (typeof (deviceBreakpoint === null || deviceBreakpoint === void 0 ? void 0 : deviceBreakpoint.id) === 'number') {
|
|
618
720
|
//sync this breakpoint's deviceId with the roku-assigned breakpoint ID
|
|
619
|
-
this.breakpointManager.setBreakpointDeviceId(breakpoints[i].
|
|
721
|
+
this.breakpointManager.setBreakpointDeviceId(breakpoints[i].srcHash, breakpoints[i].destHash, deviceBreakpoint.id);
|
|
722
|
+
}
|
|
723
|
+
//this breakpoint had an issue. remove it from the client
|
|
724
|
+
if (deviceBreakpoint.errorCode !== Constants_1.ErrorCode.OK) {
|
|
725
|
+
this.breakpointManager.deleteBreakpoint(breakpoints[i].srcHash);
|
|
620
726
|
}
|
|
621
|
-
//return true to mark this action as complete
|
|
622
|
-
success && (success = true);
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
|
-
//this action is not yet complete. it should be retried
|
|
626
|
-
success && (success = false);
|
|
627
727
|
}
|
|
728
|
+
//the entire response was bad. delete these breakpoints from the client
|
|
628
729
|
}
|
|
629
|
-
|
|
630
|
-
|
|
730
|
+
else {
|
|
731
|
+
this.breakpointManager.deleteBreakpoints(breakpoints.map(x => x.srcHash));
|
|
732
|
+
}
|
|
733
|
+
}
|
|
631
734
|
}
|
|
632
735
|
}
|
|
633
736
|
}
|
|
@@ -642,4 +745,8 @@ var KeyType;
|
|
|
642
745
|
KeyType["integer"] = "Integer";
|
|
643
746
|
KeyType["legacy"] = "Legacy";
|
|
644
747
|
})(KeyType = exports.KeyType || (exports.KeyType = {}));
|
|
748
|
+
function isDebugProtocolAdapter(adapter) {
|
|
749
|
+
return (adapter === null || adapter === void 0 ? void 0 : adapter.constructor.name) === DebugProtocolAdapter.name;
|
|
750
|
+
}
|
|
751
|
+
exports.isDebugProtocolAdapter = isDebugProtocolAdapter;
|
|
645
752
|
//# sourceMappingURL=DebugProtocolAdapter.js.map
|