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
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebugProtocolServer = exports.DEBUGGER_MAGIC = void 0;
|
|
4
|
+
const eventemitter3_1 = require("eventemitter3");
|
|
5
|
+
const Net = require("net");
|
|
6
|
+
const ActionQueue_1 = require("../../managers/ActionQueue");
|
|
7
|
+
const Constants_1 = require("../Constants");
|
|
8
|
+
const AddBreakpointsRequest_1 = require("../events/requests/AddBreakpointsRequest");
|
|
9
|
+
const AddConditionalBreakpointsRequest_1 = require("../events/requests/AddConditionalBreakpointsRequest");
|
|
10
|
+
const ContinueRequest_1 = require("../events/requests/ContinueRequest");
|
|
11
|
+
const ExecuteRequest_1 = require("../events/requests/ExecuteRequest");
|
|
12
|
+
const ExitChannelRequest_1 = require("../events/requests/ExitChannelRequest");
|
|
13
|
+
const HandshakeRequest_1 = require("../events/requests/HandshakeRequest");
|
|
14
|
+
const ListBreakpointsRequest_1 = require("../events/requests/ListBreakpointsRequest");
|
|
15
|
+
const RemoveBreakpointsRequest_1 = require("../events/requests/RemoveBreakpointsRequest");
|
|
16
|
+
const StackTraceRequest_1 = require("../events/requests/StackTraceRequest");
|
|
17
|
+
const StepRequest_1 = require("../events/requests/StepRequest");
|
|
18
|
+
const StopRequest_1 = require("../events/requests/StopRequest");
|
|
19
|
+
const ThreadsRequest_1 = require("../events/requests/ThreadsRequest");
|
|
20
|
+
const VariablesRequest_1 = require("../events/requests/VariablesRequest");
|
|
21
|
+
const HandshakeResponse_1 = require("../events/responses/HandshakeResponse");
|
|
22
|
+
const HandshakeV3Response_1 = require("../events/responses/HandshakeV3Response");
|
|
23
|
+
const PluginInterface_1 = require("../PluginInterface");
|
|
24
|
+
const logging_1 = require("../../logging");
|
|
25
|
+
const util_1 = require("../../util");
|
|
26
|
+
const ProtocolUtil_1 = require("../ProtocolUtil");
|
|
27
|
+
const smart_buffer_1 = require("smart-buffer");
|
|
28
|
+
exports.DEBUGGER_MAGIC = 'bsdebug';
|
|
29
|
+
/**
|
|
30
|
+
* A class that emulates the way a Roku's DebugProtocol debug session/server works. This is mostly useful for unit testing,
|
|
31
|
+
* but might eventually be helpful for an off-device emulator as well
|
|
32
|
+
*/
|
|
33
|
+
class DebugProtocolServer {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.options = options;
|
|
36
|
+
this.logger = logging_1.logger.createLogger(`[${DebugProtocolServer.name}]`);
|
|
37
|
+
/**
|
|
38
|
+
* Indicates whether the client has sent the magic string to kick off the debug session.
|
|
39
|
+
*/
|
|
40
|
+
this.isHandshakeComplete = false;
|
|
41
|
+
this.buffer = Buffer.alloc(0);
|
|
42
|
+
/**
|
|
43
|
+
* A collection of plugins that can interact with the server at lifecycle points
|
|
44
|
+
*/
|
|
45
|
+
this.plugins = new PluginInterface_1.default();
|
|
46
|
+
/**
|
|
47
|
+
* A queue for processing the incoming buffer, every transmission at a time
|
|
48
|
+
*/
|
|
49
|
+
this.bufferQueue = new ActionQueue_1.ActionQueue();
|
|
50
|
+
/**
|
|
51
|
+
* An event emitter used for all of the events this server emitts
|
|
52
|
+
*/
|
|
53
|
+
this.emitter = new eventemitter3_1.EventEmitter();
|
|
54
|
+
}
|
|
55
|
+
get controlPort() {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = this.options.controlPort) !== null && _a !== void 0 ? _a : this._port;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Run the server. This opens a socket and listens for a connection.
|
|
61
|
+
* The promise resolves when the server has started listening. It does NOT wait for a client to connect
|
|
62
|
+
*/
|
|
63
|
+
async start() {
|
|
64
|
+
var _a, _b, _c;
|
|
65
|
+
const deferred = (0, util_1.defer)();
|
|
66
|
+
try {
|
|
67
|
+
this.server = new Net.Server({});
|
|
68
|
+
//Roku only allows 1 connection, so we should too.
|
|
69
|
+
this.server.maxConnections = 1;
|
|
70
|
+
//whenever a client makes a connection
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
72
|
+
this.server.on('connection', async (socket) => {
|
|
73
|
+
const event = await this.plugins.emit('onClientConnected', {
|
|
74
|
+
server: this,
|
|
75
|
+
client: socket
|
|
76
|
+
});
|
|
77
|
+
this.client = event.client;
|
|
78
|
+
//anytime we receive incoming data from the client
|
|
79
|
+
this.client.on('data', (data) => {
|
|
80
|
+
//queue up processing the new data, chunk by chunk
|
|
81
|
+
void this.bufferQueue.run(async () => {
|
|
82
|
+
this.buffer = Buffer.concat([this.buffer, data]);
|
|
83
|
+
while (this.buffer.length > 0 && await this.process()) {
|
|
84
|
+
//the loop condition is the actual work
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//handle connection errors
|
|
90
|
+
this.client.on('error', (e) => {
|
|
91
|
+
this.logger.error(e);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
this._port = (_a = this.controlPort) !== null && _a !== void 0 ? _a : await util_1.util.getPort();
|
|
95
|
+
//handle connection errors
|
|
96
|
+
this.server.on('error', (e) => {
|
|
97
|
+
this.logger.error(e);
|
|
98
|
+
});
|
|
99
|
+
this.server.listen({
|
|
100
|
+
port: (_b = this.options.controlPort) !== null && _b !== void 0 ? _b : 8081,
|
|
101
|
+
hostName: (_c = this.options.host) !== null && _c !== void 0 ? _c : '0.0.0.0'
|
|
102
|
+
}, () => {
|
|
103
|
+
void this.plugins.emit('onServerStart', { server: this });
|
|
104
|
+
deferred.resolve();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
deferred.reject(e);
|
|
109
|
+
}
|
|
110
|
+
return deferred.promise;
|
|
111
|
+
}
|
|
112
|
+
async stop() {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
//close the client socket
|
|
115
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
116
|
+
//now close the server
|
|
117
|
+
try {
|
|
118
|
+
await new Promise((resolve, reject) => {
|
|
119
|
+
this.server.close((err) => {
|
|
120
|
+
if (err) {
|
|
121
|
+
reject(err);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
resolve();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
(_b = this.client) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
|
|
131
|
+
delete this.client;
|
|
132
|
+
(_c = this.server) === null || _c === void 0 ? void 0 : _c.removeAllListeners();
|
|
133
|
+
delete this.server;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async destroy() {
|
|
137
|
+
await this.stop();
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Given a buffer, find the request that matches it
|
|
141
|
+
*/
|
|
142
|
+
static getRequest(buffer, allowHandshake) {
|
|
143
|
+
//when enabled, look at the start of the buffer for the exact DEBUGGER_MAGIC text. This is a boolean because
|
|
144
|
+
//there could be cases where binary data looks similar to this structure, so the caller must opt-in to this logic
|
|
145
|
+
if (allowHandshake && buffer.length >= 8 && ProtocolUtil_1.protocolUtil.readStringNT(smart_buffer_1.SmartBuffer.fromBuffer(buffer)) === exports.DEBUGGER_MAGIC) {
|
|
146
|
+
return HandshakeRequest_1.HandshakeRequest.fromBuffer(buffer);
|
|
147
|
+
}
|
|
148
|
+
// if we don't have enough buffer data, skip this
|
|
149
|
+
if (buffer.length < 12) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
//the client may only send commands to the server, so extract the command type from the known byte position
|
|
153
|
+
const command = Constants_1.CommandCode[buffer.readUInt32LE(8)]; // command_code
|
|
154
|
+
switch (command) {
|
|
155
|
+
case Constants_1.Command.AddBreakpoints:
|
|
156
|
+
return AddBreakpointsRequest_1.AddBreakpointsRequest.fromBuffer(buffer);
|
|
157
|
+
case Constants_1.Command.Stop:
|
|
158
|
+
return StopRequest_1.StopRequest.fromBuffer(buffer);
|
|
159
|
+
case Constants_1.Command.Continue:
|
|
160
|
+
return ContinueRequest_1.ContinueRequest.fromBuffer(buffer);
|
|
161
|
+
case Constants_1.Command.Threads:
|
|
162
|
+
return ThreadsRequest_1.ThreadsRequest.fromBuffer(buffer);
|
|
163
|
+
case Constants_1.Command.StackTrace:
|
|
164
|
+
return StackTraceRequest_1.StackTraceRequest.fromBuffer(buffer);
|
|
165
|
+
case Constants_1.Command.Variables:
|
|
166
|
+
return VariablesRequest_1.VariablesRequest.fromBuffer(buffer);
|
|
167
|
+
case Constants_1.Command.Step:
|
|
168
|
+
return StepRequest_1.StepRequest.fromBuffer(buffer);
|
|
169
|
+
case Constants_1.Command.ListBreakpoints:
|
|
170
|
+
return ListBreakpointsRequest_1.ListBreakpointsRequest.fromBuffer(buffer);
|
|
171
|
+
case Constants_1.Command.RemoveBreakpoints:
|
|
172
|
+
return RemoveBreakpointsRequest_1.RemoveBreakpointsRequest.fromBuffer(buffer);
|
|
173
|
+
case Constants_1.Command.Execute:
|
|
174
|
+
return ExecuteRequest_1.ExecuteRequest.fromBuffer(buffer);
|
|
175
|
+
case Constants_1.Command.AddConditionalBreakpoints:
|
|
176
|
+
return AddConditionalBreakpointsRequest_1.AddConditionalBreakpointsRequest.fromBuffer(buffer);
|
|
177
|
+
case Constants_1.Command.ExitChannel:
|
|
178
|
+
return ExitChannelRequest_1.ExitChannelRequest.fromBuffer(buffer);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
getResponse(request) {
|
|
182
|
+
if (request instanceof HandshakeRequest_1.HandshakeRequest) {
|
|
183
|
+
return HandshakeV3Response_1.HandshakeV3Response.fromJson({
|
|
184
|
+
magic: this.magic,
|
|
185
|
+
protocolVersion: '3.1.0',
|
|
186
|
+
//TODO update this to an actual date from the device
|
|
187
|
+
revisionTimestamp: new Date(2022, 1, 1)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Process a single request.
|
|
193
|
+
* @returns true if successfully processed a request, and false if not
|
|
194
|
+
*/
|
|
195
|
+
async process() {
|
|
196
|
+
try {
|
|
197
|
+
this.logger.log('process() start', { buffer: this.buffer.toJSON() });
|
|
198
|
+
//at this point, there is an active debug session. The plugin must provide us all the real-world data
|
|
199
|
+
let { buffer, request } = await this.plugins.emit('provideRequest', {
|
|
200
|
+
server: this,
|
|
201
|
+
buffer: this.buffer,
|
|
202
|
+
request: undefined
|
|
203
|
+
});
|
|
204
|
+
//we must build the request if the plugin didn't supply one (most plugins won't provide a request...)
|
|
205
|
+
if (!request) {
|
|
206
|
+
//if we haven't seen the handshake yet, look for the handshake first
|
|
207
|
+
if (!this.isHandshakeComplete) {
|
|
208
|
+
request = HandshakeRequest_1.HandshakeRequest.fromBuffer(buffer);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
request = DebugProtocolServer.getRequest(buffer, false);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
//if we couldn't construct a request this request, hard-fail
|
|
215
|
+
if (!request || !request.success) {
|
|
216
|
+
this.logger.error('process() invalid request', { request });
|
|
217
|
+
throw new Error(`Unable to parse request: ${JSON.stringify(this.buffer.toJSON().data)}`);
|
|
218
|
+
}
|
|
219
|
+
this.logger.log('process() constructed request', { request });
|
|
220
|
+
//trim the buffer now that the request has been processed
|
|
221
|
+
this.buffer = buffer.slice(request.readOffset);
|
|
222
|
+
this.logger.log('process() buffer sliced', { buffer: this.buffer.toJSON() });
|
|
223
|
+
//now ask the plugin to provide a response for the given request
|
|
224
|
+
let { response } = await this.plugins.emit('provideResponse', {
|
|
225
|
+
server: this,
|
|
226
|
+
request: request,
|
|
227
|
+
response: undefined
|
|
228
|
+
});
|
|
229
|
+
//if the plugin didn't provide a response, we need to try our best to make one (we only support a few...plugins should provide most of them)
|
|
230
|
+
if (!response) {
|
|
231
|
+
response = this.getResponse(request);
|
|
232
|
+
}
|
|
233
|
+
if (!response) {
|
|
234
|
+
this.logger.error('process() invalid response', { request, response });
|
|
235
|
+
throw new Error(`Server was unable to provide a response for ${JSON.stringify(request.data)}`);
|
|
236
|
+
}
|
|
237
|
+
//if this is part of the handshake flow, the client should have sent a magic string to kick off the debugger. If it matches, set `isHandshakeComplete = true`
|
|
238
|
+
if ((response instanceof HandshakeResponse_1.HandshakeResponse || response instanceof HandshakeV3Response_1.HandshakeV3Response) && response.data.magic === this.magic) {
|
|
239
|
+
this.isHandshakeComplete = true;
|
|
240
|
+
}
|
|
241
|
+
//send the response to the client. (TODO handle when the response is missing)
|
|
242
|
+
await this.sendResponse(response);
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
catch (e) {
|
|
246
|
+
this.logger.error('process() error', e);
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Send a response from the server to the client. This involves writing the response buffer to the client socket
|
|
252
|
+
*/
|
|
253
|
+
async sendResponse(response) {
|
|
254
|
+
const event = await this.plugins.emit('beforeSendResponse', {
|
|
255
|
+
server: this,
|
|
256
|
+
response: response
|
|
257
|
+
});
|
|
258
|
+
this.logger.log('sendResponse()', { response });
|
|
259
|
+
this.client.write(event.response.toBuffer());
|
|
260
|
+
await this.plugins.emit('afterSendResponse', {
|
|
261
|
+
server: this,
|
|
262
|
+
response: event.response
|
|
263
|
+
});
|
|
264
|
+
return event.response;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Send an update from the server to the client. This can be things like ALL_THREADS_STOPPED
|
|
268
|
+
*/
|
|
269
|
+
sendUpdate(update) {
|
|
270
|
+
return this.sendResponse(update);
|
|
271
|
+
}
|
|
272
|
+
on(eventName, callback) {
|
|
273
|
+
this.emitter.on(eventName, callback);
|
|
274
|
+
return () => {
|
|
275
|
+
var _a;
|
|
276
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.removeListener(eventName, callback);
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Subscribe to an event exactly one time. This will fire the very next time an event happens,
|
|
281
|
+
* and then immediately unsubscribe
|
|
282
|
+
*/
|
|
283
|
+
once(eventName) {
|
|
284
|
+
return new Promise((resolve) => {
|
|
285
|
+
const off = this.on(eventName, (event) => {
|
|
286
|
+
off();
|
|
287
|
+
resolve(event);
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
emit(eventName, event) {
|
|
292
|
+
var _a;
|
|
293
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.emit(eventName, event);
|
|
294
|
+
return event;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The magic string used to kick off the debug session.
|
|
298
|
+
* @default "bsdebug"
|
|
299
|
+
*/
|
|
300
|
+
get magic() {
|
|
301
|
+
var _a;
|
|
302
|
+
return (_a = this.options.magic) !== null && _a !== void 0 ? _a : exports.DEBUGGER_MAGIC;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.DebugProtocolServer = DebugProtocolServer;
|
|
306
|
+
//# sourceMappingURL=DebugProtocolServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugProtocolServer.js","sourceRoot":"","sources":["../../../src/debugProtocol/server/DebugProtocolServer.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAC7C,2BAA2B;AAC3B,4DAAyD;AACzD,4CAAoD;AAEpD,oFAAiF;AACjF,0GAAuG;AACvG,wEAAqE;AACrE,sEAAmE;AACnE,8EAA2E;AAC3E,0EAAuE;AACvE,sFAAmF;AACnF,0FAAuF;AACvF,4EAAyE;AACzE,gEAA6D;AAC7D,gEAA6D;AAC7D,sEAAmE;AACnE,0EAAuE;AACvE,6EAA0E;AAC1E,iFAA8E;AAC9E,wDAAiD;AAEjD,2CAAuC;AACvC,qCAAyC;AACzC,kDAA+C;AAC/C,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EAAE,CAAI,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxC,GAAG,EAAE,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAKM,IAAI,CAAI,SAAiB,EAAE,KAAU;;QACxC,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACH,IAAY,KAAK;;QACb,OAAO,MAAA,IAAI,CAAC,OAAO,CAAC,KAAK,mCAAI,sBAAc,CAAC;IAChD,CAAC;CACJ;AA9TD,kDA8TC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { DebugProtocolServer } from './DebugProtocolServer';
|
|
3
|
+
import type { Socket } from 'net';
|
|
4
|
+
import type { ProtocolRequest, ProtocolResponse } from '../events/ProtocolEvent';
|
|
5
|
+
export interface ProtocolServerPlugin {
|
|
6
|
+
onServerStart?: Handler<OnServerStartEvent>;
|
|
7
|
+
onClientConnected?: Handler<OnClientConnectedEvent>;
|
|
8
|
+
provideRequest?: Handler<ProvideRequestEvent>;
|
|
9
|
+
provideResponse?: Handler<ProvideResponseEvent>;
|
|
10
|
+
beforeSendResponse?: Handler<BeforeSendResponseEvent>;
|
|
11
|
+
afterSendResponse?: Handler<AfterSendResponseEvent>;
|
|
12
|
+
}
|
|
13
|
+
export interface OnServerStartEvent {
|
|
14
|
+
server: DebugProtocolServer;
|
|
15
|
+
}
|
|
16
|
+
export interface OnClientConnectedEvent {
|
|
17
|
+
server: DebugProtocolServer;
|
|
18
|
+
client: Socket;
|
|
19
|
+
}
|
|
20
|
+
export interface ProvideRequestEvent {
|
|
21
|
+
server: DebugProtocolServer;
|
|
22
|
+
buffer: Buffer;
|
|
23
|
+
/**
|
|
24
|
+
* The plugin should provide this property
|
|
25
|
+
*/
|
|
26
|
+
request?: ProtocolRequest;
|
|
27
|
+
}
|
|
28
|
+
export interface ProvideResponseEvent {
|
|
29
|
+
server: DebugProtocolServer;
|
|
30
|
+
request: ProtocolRequest;
|
|
31
|
+
/**
|
|
32
|
+
* The plugin should provide this property
|
|
33
|
+
*/
|
|
34
|
+
response?: ProtocolResponse;
|
|
35
|
+
}
|
|
36
|
+
export interface BeforeSendResponseEvent {
|
|
37
|
+
server: DebugProtocolServer;
|
|
38
|
+
response: ProtocolResponse;
|
|
39
|
+
}
|
|
40
|
+
export declare type AfterSendResponseEvent = BeforeSendResponseEvent;
|
|
41
|
+
export declare type Handler<T, R = void> = (event: T) => R;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugProtocolServerPlugin.js","sourceRoot":"","sources":["../../../src/debugProtocol/server/DebugProtocolServerPlugin.ts"],"names":[],"mappings":""}
|
|
@@ -11,7 +11,7 @@ import { FileLoggingManager } from '../logging';
|
|
|
11
11
|
import type { DeviceInfo } from '../DeviceInfo';
|
|
12
12
|
export declare class BrightScriptDebugSession extends BaseDebugSession {
|
|
13
13
|
constructor();
|
|
14
|
-
private
|
|
14
|
+
private onDeviceBreakpointsChanged;
|
|
15
15
|
logger: import("@rokucommunity/logger/dist/Logger").Logger;
|
|
16
16
|
/**
|
|
17
17
|
* A sequence used to help identify log statements for requests
|
|
@@ -37,6 +37,14 @@ export declare class BrightScriptDebugSession extends BaseDebugSession {
|
|
|
37
37
|
private rokuAdapter;
|
|
38
38
|
private rendezvousTracker;
|
|
39
39
|
tempVarPrefix: string;
|
|
40
|
+
/**
|
|
41
|
+
* The first encountered compile error, will be used to send to the client as a runtime error (nicer UI presentation)
|
|
42
|
+
*/
|
|
43
|
+
private compileError;
|
|
44
|
+
/**
|
|
45
|
+
* A magic number to represent a fake thread that will be used for showing compile errors in the UI as if they were runtime crashes
|
|
46
|
+
*/
|
|
47
|
+
private COMPILE_ERROR_THREAD_ID;
|
|
40
48
|
private get enableDebugProtocol();
|
|
41
49
|
private getRokuAdapter;
|
|
42
50
|
private launchConfiguration;
|