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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/debugProtocol/Constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,2EAAc,CAAA;IACd,yEAAa,CAAA;IACb,iFAAiB,CAAA;AACrB,CAAC,EAJW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAI/B;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/debugProtocol/Constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC5B,2EAAc,CAAA;IACd,yEAAa,CAAA;IACb,iFAAiB,CAAA;AACrB,CAAC,EAJW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAI/B;AAED;;GAEG;AACH,IAAY,OA8DX;AA9DD,WAAY,OAAO;IACf;;;;OAIG;IACH,wBAAa,CAAA;IACb;;OAEG;IACH,gCAAqB,CAAA;IACrB;;OAEG;IACH,8BAAmB,CAAA;IACnB;;OAEG;IACH,oCAAyB,CAAA;IACzB;;OAEG;IACH,kCAAuB,CAAA;IACvB;;;OAGG;IACH,wBAAa,CAAA;IACb;;;;OAIG;IACH,4CAAiC,CAAA;IACjC;;;;OAIG;IACH,8CAAmC,CAAA;IACnC;;;;OAIG;IACH,kDAAuC,CAAA;IACvC;;;;OAIG;IACH,8BAAmB,CAAA;IACnB;;;;OAIG;IACH,kEAAuD,CAAA;IACvD;;OAEG;IACH,sCAA2B,CAAA;AAC/B,CAAC,EA9DW,OAAO,GAAP,eAAO,KA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/B;;OAEG;IACH,6BAAe,CAAA;IACf;;OAEG;IACH,2CAA6B,CAAA;AACjC,CAAC,EAzBW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAyBrB;AACD;;GAEG;AACH,IAAY,cAOX;AAPD,WAAY,cAAc;IACtB,6DAAa,CAAA;IACb,+DAAc,CAAA;IACd,+DAAc,CAAA;IACd,qEAAiB,CAAA;IACjB,qDAAS,CAAA;IACT,mEAAgB,CAAA;AACpB,CAAC,EAPW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAOzB;AAED;;GAEG;AACH,IAAY,UAqCX;AArCD,WAAY,UAAU;IAClB,qCAAuB,CAAA;IACvB;;OAEG;IACH,2CAA6B,CAAA;IAC7B;;;;OAIG;IACH,qDAAuC,CAAA;IACvC;;;;;;;;OAQG;IACH,+CAAiC,CAAA;IACjC;;;OAGG;IACH,iDAAmC,CAAA;IACnC;;;OAGG;IACH,2CAA6B,CAAA;IAC7B;;;OAGG;IACH,uDAAyC,CAAA;AAC7C,CAAC,EArCW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAqCrB;AACD;;GAEG;AACH,IAAY,cAYX;AAZD,WAAY,cAAc;IACtB,6DAAa,CAAA;IACb,mEAAgB,CAAA;IAChB,6EAAqB,CAAA;IACrB,uEAAkB,CAAA;IAClB,yEAAmB,CAAA;IACnB,mEAAgB,CAAA;IAChB,MAAM;IACN,4CAA4C;IAC5C,yBAAyB;IACzB,MAAM;IACN,+EAAsB,CAAA;AAC1B,CAAC,EAZW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAYzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ProtocolRequest, ProtocolResponse, ProtocolUpdate } from './events/ProtocolEvent';
|
|
3
|
+
export declare class DebugProtocolClientReplaySession {
|
|
4
|
+
constructor(options: {
|
|
5
|
+
bufferLog: string;
|
|
6
|
+
});
|
|
7
|
+
private disposables;
|
|
8
|
+
/**
|
|
9
|
+
* A dumb tcp server that will simply spit back the server buffer data when needed
|
|
10
|
+
*/
|
|
11
|
+
private server;
|
|
12
|
+
private ioSocket;
|
|
13
|
+
private client;
|
|
14
|
+
private entryIndex;
|
|
15
|
+
private entries;
|
|
16
|
+
private peekEntry;
|
|
17
|
+
private advanceEntry;
|
|
18
|
+
private flushIO;
|
|
19
|
+
private parseBufferLog;
|
|
20
|
+
result: Array<ProtocolRequest | ProtocolResponse | ProtocolUpdate>;
|
|
21
|
+
private finished;
|
|
22
|
+
private controlPort;
|
|
23
|
+
private ioPort;
|
|
24
|
+
run(): Promise<void>;
|
|
25
|
+
private createClient;
|
|
26
|
+
private openIOPort;
|
|
27
|
+
private clientSync;
|
|
28
|
+
private clientActionQueue;
|
|
29
|
+
private clientProcess;
|
|
30
|
+
private finalizeIfDone;
|
|
31
|
+
private createServer;
|
|
32
|
+
private serverActionQueue;
|
|
33
|
+
private serverSync;
|
|
34
|
+
private serverProcessIdx;
|
|
35
|
+
private serverProcess;
|
|
36
|
+
/**
|
|
37
|
+
* Sleep for the amount of time between the two specified entries
|
|
38
|
+
*/
|
|
39
|
+
private sleepForEntryGap;
|
|
40
|
+
destroy(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface BufferLogEntry {
|
|
43
|
+
type: 'client-to-server' | 'server-to-client' | 'io';
|
|
44
|
+
timestamp: Date;
|
|
45
|
+
buffer: Buffer;
|
|
46
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebugProtocolClientReplaySession = void 0;
|
|
4
|
+
const DebugProtocolClient_1 = require("./client/DebugProtocolClient");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
const DebugProtocolServer_1 = require("./server/DebugProtocolServer");
|
|
7
|
+
const Net = require("net");
|
|
8
|
+
const ActionQueue_1 = require("../managers/ActionQueue");
|
|
9
|
+
const IOPortOpenedUpdate_1 = require("./events/updates/IOPortOpenedUpdate");
|
|
10
|
+
class DebugProtocolClientReplaySession {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.disposables = Array();
|
|
13
|
+
this.entryIndex = 0;
|
|
14
|
+
this.result = [];
|
|
15
|
+
this.finished = (0, util_1.defer)();
|
|
16
|
+
this.clientSync = new BufferSync();
|
|
17
|
+
this.clientActionQueue = new ActionQueue_1.ActionQueue();
|
|
18
|
+
this.serverActionQueue = new ActionQueue_1.ActionQueue();
|
|
19
|
+
this.serverSync = new BufferSync();
|
|
20
|
+
this.serverProcessIdx = 0;
|
|
21
|
+
this.parseBufferLog(options === null || options === void 0 ? void 0 : options.bufferLog);
|
|
22
|
+
}
|
|
23
|
+
peekEntry() {
|
|
24
|
+
this.flushIO();
|
|
25
|
+
return this.entries[this.entryIndex];
|
|
26
|
+
}
|
|
27
|
+
advanceEntry() {
|
|
28
|
+
this.flushIO();
|
|
29
|
+
return this.entries[this.entryIndex++];
|
|
30
|
+
}
|
|
31
|
+
flushIO() {
|
|
32
|
+
var _a;
|
|
33
|
+
while (((_a = this.entries[this.entryIndex]) === null || _a === void 0 ? void 0 : _a.type) === 'io') {
|
|
34
|
+
const entry = this.entries[this.entryIndex++];
|
|
35
|
+
this.ioSocket.write(entry.buffer);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
parseBufferLog(bufferLog) {
|
|
39
|
+
this.entries = bufferLog
|
|
40
|
+
.split(/\r?\n/g)
|
|
41
|
+
//only keep lines that include the `[[bufferLog]]` magic text
|
|
42
|
+
.filter(x => x.includes('[[bufferLog]]'))
|
|
43
|
+
//remove leading text, leaving only the raw bufferLog entry
|
|
44
|
+
.map(x => x.replace(/.*?\[\[bufferLog\]\]:/, '').trim())
|
|
45
|
+
.filter(x => !!x)
|
|
46
|
+
.map(line => {
|
|
47
|
+
const entry = JSON.parse(line);
|
|
48
|
+
entry.timestamp = new Date(entry.timestamp);
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
50
|
+
entry.buffer = Buffer.from(entry.buffer);
|
|
51
|
+
return entry;
|
|
52
|
+
});
|
|
53
|
+
return this.entries;
|
|
54
|
+
}
|
|
55
|
+
async run() {
|
|
56
|
+
this.controlPort = await util_1.util.getPort();
|
|
57
|
+
this.ioPort = await util_1.util.getPort();
|
|
58
|
+
await this.createServer(this.controlPort);
|
|
59
|
+
this.createClient(this.controlPort);
|
|
60
|
+
//connect, but don't send the handshake. That'll be send through our first server-to-client entry (hopefully)
|
|
61
|
+
await this.client.connect(false);
|
|
62
|
+
void this.clientProcess();
|
|
63
|
+
await this.finished.promise;
|
|
64
|
+
}
|
|
65
|
+
createClient(controlPort) {
|
|
66
|
+
this.client = new DebugProtocolClient_1.DebugProtocolClient({
|
|
67
|
+
controlPort: controlPort,
|
|
68
|
+
host: 'localhost'
|
|
69
|
+
});
|
|
70
|
+
//store the responses in the result
|
|
71
|
+
this.client.on('response', (response) => {
|
|
72
|
+
this.result.push(response);
|
|
73
|
+
void this.clientProcess();
|
|
74
|
+
});
|
|
75
|
+
this.client.on('update', (update) => {
|
|
76
|
+
this.result.push(update);
|
|
77
|
+
void this.clientProcess();
|
|
78
|
+
});
|
|
79
|
+
this.client.on('io-output', (data) => {
|
|
80
|
+
console.log(data);
|
|
81
|
+
void this.clientProcess();
|
|
82
|
+
});
|
|
83
|
+
//anytime the client receives buffer data, we should try and process it
|
|
84
|
+
this.client.on('data', (data) => {
|
|
85
|
+
this.clientSync.pushActual(data);
|
|
86
|
+
void this.clientProcess();
|
|
87
|
+
});
|
|
88
|
+
this.client.plugins.add({
|
|
89
|
+
beforeHandleUpdate: async (event) => {
|
|
90
|
+
if ((0, IOPortOpenedUpdate_1.isIOPortOpenedUpdate)(event.update)) {
|
|
91
|
+
//spin up an IO port before finishing this update
|
|
92
|
+
await this.openIOPort();
|
|
93
|
+
const update = IOPortOpenedUpdate_1.IOPortOpenedUpdate.fromJson(event.update.data);
|
|
94
|
+
update.data.port = this.ioPort;
|
|
95
|
+
//if we get an IO update, change the port and host to the local stuff (for testing purposes)
|
|
96
|
+
event.update = update;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
//stuff to run when the session is disposed
|
|
101
|
+
this.disposables.push(() => {
|
|
102
|
+
return this.client.destroy();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
openIOPort() {
|
|
106
|
+
console.log(`Spinning up mock IO socket on port ${this.ioPort}`);
|
|
107
|
+
return new Promise((resolve) => {
|
|
108
|
+
const server = new Net.Server({});
|
|
109
|
+
//whenever a client makes a connection
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
111
|
+
server.on('connection', (client) => {
|
|
112
|
+
this.ioSocket = client;
|
|
113
|
+
//anytime we receive incoming data from the client
|
|
114
|
+
client.on('data', (data) => {
|
|
115
|
+
//TODO send IO data
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
server.listen({
|
|
119
|
+
port: this.ioPort,
|
|
120
|
+
hostName: 'localhost'
|
|
121
|
+
}, () => {
|
|
122
|
+
resolve();
|
|
123
|
+
});
|
|
124
|
+
//stuff to run when the session is disposed
|
|
125
|
+
this.disposables.push(() => {
|
|
126
|
+
server.close();
|
|
127
|
+
});
|
|
128
|
+
this.disposables.push(() => {
|
|
129
|
+
var _a;
|
|
130
|
+
(_a = this.ioSocket) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async clientProcess() {
|
|
135
|
+
await this.clientActionQueue.run(async () => {
|
|
136
|
+
var _a;
|
|
137
|
+
//build a single buffer of client data
|
|
138
|
+
while (((_a = this.peekEntry()) === null || _a === void 0 ? void 0 : _a.type) === 'client-to-server') {
|
|
139
|
+
//make sure it's been enough time since the last entry
|
|
140
|
+
await this.sleepForEntryGap();
|
|
141
|
+
const entry = this.advanceEntry();
|
|
142
|
+
const request = DebugProtocolServer_1.DebugProtocolServer.getRequest(entry.buffer, true);
|
|
143
|
+
//store this client data for our mock server to recognize and track
|
|
144
|
+
this.serverSync.pushExpected(request.toBuffer());
|
|
145
|
+
//store the request in the result
|
|
146
|
+
this.result.push(request);
|
|
147
|
+
//send the request
|
|
148
|
+
void this.client.processRequest(request);
|
|
149
|
+
}
|
|
150
|
+
this.finalizeIfDone();
|
|
151
|
+
return true;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
finalizeIfDone() {
|
|
155
|
+
if (this.clientSync.areInSync && this.serverSync.areInSync && this.entryIndex >= this.entries.length) {
|
|
156
|
+
this.finished.resolve();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
createServer(controlPort) {
|
|
160
|
+
return new Promise((resolve) => {
|
|
161
|
+
const server = new Net.Server({});
|
|
162
|
+
//Roku only allows 1 connection, so we should too.
|
|
163
|
+
server.maxConnections = 1;
|
|
164
|
+
//whenever a client makes a connection
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
166
|
+
server.on('connection', (client) => {
|
|
167
|
+
this.server = client;
|
|
168
|
+
//anytime we receive incoming data from the client
|
|
169
|
+
client.on('data', (data) => {
|
|
170
|
+
console.log('server got:', JSON.stringify(data.toJSON().data));
|
|
171
|
+
void this.serverProcess(data);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
server.listen({
|
|
175
|
+
port: controlPort,
|
|
176
|
+
hostName: 'localhost'
|
|
177
|
+
}, () => {
|
|
178
|
+
resolve();
|
|
179
|
+
});
|
|
180
|
+
//stuff to run when the session is disposed
|
|
181
|
+
this.disposables.push(() => {
|
|
182
|
+
server.close();
|
|
183
|
+
});
|
|
184
|
+
this.disposables.push(() => {
|
|
185
|
+
var _a;
|
|
186
|
+
(_a = this.client) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async serverProcess(data) {
|
|
191
|
+
let serverProcesIdx = this.serverProcessIdx++;
|
|
192
|
+
await this.serverActionQueue.run(async () => {
|
|
193
|
+
var _a;
|
|
194
|
+
try {
|
|
195
|
+
console.log(serverProcesIdx);
|
|
196
|
+
this.serverSync.pushActual(data);
|
|
197
|
+
if (this.serverSync.areInSync) {
|
|
198
|
+
this.serverSync.clear();
|
|
199
|
+
//send all the server messages, each delayed slightly to simulate the chunked buffer flushing that roku causes
|
|
200
|
+
while (((_a = this.peekEntry()) === null || _a === void 0 ? void 0 : _a.type) === 'server-to-client') {
|
|
201
|
+
//make sure enough time has passed since the last entry
|
|
202
|
+
await this.sleepForEntryGap();
|
|
203
|
+
const entry = this.advanceEntry();
|
|
204
|
+
this.server.write(entry.buffer);
|
|
205
|
+
this.clientSync.pushExpected(entry.buffer);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
this.finalizeIfDone();
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
console.error('serverProcess failed to handle buffer', e);
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Sleep for the amount of time between the two specified entries
|
|
218
|
+
*/
|
|
219
|
+
async sleepForEntryGap() {
|
|
220
|
+
const currentEntry = this.entries[this.entryIndex];
|
|
221
|
+
const previousEntry = this.entries[this.entryIndex - 1];
|
|
222
|
+
let gap = 0;
|
|
223
|
+
if (currentEntry && previousEntry) {
|
|
224
|
+
gap = currentEntry.timestamp.getTime() - (previousEntry === null || previousEntry === void 0 ? void 0 : previousEntry.timestamp.getTime());
|
|
225
|
+
//if the gap is negative, then the time has already passed. Just timeout at zero
|
|
226
|
+
gap = gap > 0 ? gap : 0;
|
|
227
|
+
}
|
|
228
|
+
//longer delays make the test run slower, but don't really make the test any more accurate,
|
|
229
|
+
//so cap the delay at 100ms
|
|
230
|
+
if (gap > 100) {
|
|
231
|
+
gap = 100;
|
|
232
|
+
}
|
|
233
|
+
await util_1.util.sleep(gap);
|
|
234
|
+
}
|
|
235
|
+
async destroy() {
|
|
236
|
+
for (const dispose of this.disposables) {
|
|
237
|
+
try {
|
|
238
|
+
await Promise.resolve(dispose());
|
|
239
|
+
}
|
|
240
|
+
catch (_a) { }
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.DebugProtocolClientReplaySession = DebugProtocolClientReplaySession;
|
|
245
|
+
class BufferSync {
|
|
246
|
+
constructor() {
|
|
247
|
+
this.expected = Buffer.alloc(0);
|
|
248
|
+
this.actual = Buffer.alloc(0);
|
|
249
|
+
}
|
|
250
|
+
pushExpected(buffer) {
|
|
251
|
+
this.expected = Buffer.concat([this.expected, buffer]);
|
|
252
|
+
}
|
|
253
|
+
pushActual(buffer) {
|
|
254
|
+
this.actual = Buffer.concat([this.actual, buffer]);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Are the two buffers in sync?
|
|
258
|
+
*/
|
|
259
|
+
get areInSync() {
|
|
260
|
+
return JSON.stringify(this.expected) === JSON.stringify(this.actual);
|
|
261
|
+
}
|
|
262
|
+
clear() {
|
|
263
|
+
this.expected = Buffer.alloc(0);
|
|
264
|
+
this.actual = Buffer.alloc(0);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function bufferStartsWith(subject, search) {
|
|
268
|
+
const subjectData = subject.toJSON().data;
|
|
269
|
+
const searchData = search.toJSON().data;
|
|
270
|
+
for (let i = 0; i < searchData.length; i++) {
|
|
271
|
+
if (subjectData[i] !== searchData[i]) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
//if we made it to the end of the search, then the subject fully starts with search
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=DebugProtocolClientReplaySession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DebugProtocolClientReplaySession.js","sourceRoot":"","sources":["../../src/debugProtocol/DebugProtocolClientReplaySession.ts"],"names":[],"mappings":";;;AAAA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U,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE;YAClC,OAAO,KAAK,CAAC;SAChB;KACJ;IACD,mFAAmF;IACnF,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
|
|
2
|
+
export default class PluginInterface<TPlugin> {
|
|
3
|
+
constructor(plugins?: TPlugin[]);
|
|
4
|
+
private plugins;
|
|
5
|
+
/**
|
|
6
|
+
* Call `event` on plugins
|
|
7
|
+
*/
|
|
8
|
+
emit<K extends keyof TPlugin & string>(eventName: K, event: Arguments<TPlugin[K]>[0]): Promise<Arguments<TPlugin[K]>[0]>;
|
|
9
|
+
/**
|
|
10
|
+
* Add a plugin to the end of the list of plugins
|
|
11
|
+
* @param plugin the plugin
|
|
12
|
+
* @param priority the priority for the plugin. Lower number means higher priority. (ex: 1 executes before 5)
|
|
13
|
+
*/
|
|
14
|
+
add<T extends TPlugin = TPlugin>(plugin: T, priority?: number): T;
|
|
15
|
+
/**
|
|
16
|
+
* Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event.
|
|
17
|
+
* Once the event fires for the first time, the plugin is unregistered.
|
|
18
|
+
* @param eventName the name of the event to subscribe to
|
|
19
|
+
* @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5)
|
|
20
|
+
*/
|
|
21
|
+
once<TEventType>(eventName: keyof TPlugin, priority?: number): Promise<TEventType>;
|
|
22
|
+
/**
|
|
23
|
+
* Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event.
|
|
24
|
+
* Once the event fires for the first time and the matcher evaluates to true, the plugin is unregistered.
|
|
25
|
+
* @param eventName the name of the event to subscribe to
|
|
26
|
+
* @param matcher a function to call that, when true, will deregister this hander and return the event
|
|
27
|
+
* @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5)
|
|
28
|
+
*/
|
|
29
|
+
onceIf<TEventType>(eventName: keyof TPlugin, matcher: (TEventType: any) => boolean, priority?: number): Promise<TEventType>;
|
|
30
|
+
/**
|
|
31
|
+
* Remove the specified plugin
|
|
32
|
+
*/
|
|
33
|
+
remove<T extends TPlugin = TPlugin>(plugin: T): void;
|
|
34
|
+
/**
|
|
35
|
+
* Remove all plugins
|
|
36
|
+
*/
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class PluginInterface {
|
|
4
|
+
constructor(plugins = []) {
|
|
5
|
+
this.plugins = [];
|
|
6
|
+
for (const plugin of plugins !== null && plugins !== void 0 ? plugins : []) {
|
|
7
|
+
this.add(plugin);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Call `event` on plugins
|
|
12
|
+
*/
|
|
13
|
+
async emit(eventName, event) {
|
|
14
|
+
for (let { plugin } of this.plugins) {
|
|
15
|
+
if (plugin[eventName]) {
|
|
16
|
+
await Promise.resolve(plugin[eventName](event));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return event;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add a plugin to the end of the list of plugins
|
|
23
|
+
* @param plugin the plugin
|
|
24
|
+
* @param priority the priority for the plugin. Lower number means higher priority. (ex: 1 executes before 5)
|
|
25
|
+
*/
|
|
26
|
+
add(plugin, priority = 1) {
|
|
27
|
+
const container = {
|
|
28
|
+
plugin: plugin,
|
|
29
|
+
priority: priority
|
|
30
|
+
};
|
|
31
|
+
this.plugins.push(container);
|
|
32
|
+
//sort the plugins by priority
|
|
33
|
+
this.plugins.sort((a, b) => {
|
|
34
|
+
return a.priority - b.priority;
|
|
35
|
+
});
|
|
36
|
+
return plugin;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event.
|
|
40
|
+
* Once the event fires for the first time, the plugin is unregistered.
|
|
41
|
+
* @param eventName the name of the event to subscribe to
|
|
42
|
+
* @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5)
|
|
43
|
+
*/
|
|
44
|
+
once(eventName, priority = 1) {
|
|
45
|
+
return this.onceIf(eventName, () => true, priority);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adds a temporary plugin with a single event hook, and resolve a promise with the event from the next occurance of that event.
|
|
49
|
+
* Once the event fires for the first time and the matcher evaluates to true, the plugin is unregistered.
|
|
50
|
+
* @param eventName the name of the event to subscribe to
|
|
51
|
+
* @param matcher a function to call that, when true, will deregister this hander and return the event
|
|
52
|
+
* @param priority the priority for this event. Lower number means higher priority. (ex: 1 executes before 5)
|
|
53
|
+
*/
|
|
54
|
+
onceIf(eventName, matcher, priority = 1) {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
const tempPlugin = {};
|
|
57
|
+
tempPlugin[eventName] = (event) => {
|
|
58
|
+
if (matcher(event)) {
|
|
59
|
+
//remove the temp plugin
|
|
60
|
+
this.remove(tempPlugin);
|
|
61
|
+
//resolve the promise with this event
|
|
62
|
+
resolve(event);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
this.add(tempPlugin, priority);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove the specified plugin
|
|
70
|
+
*/
|
|
71
|
+
remove(plugin) {
|
|
72
|
+
for (let i = this.plugins.length - 1; i >= 0; i--) {
|
|
73
|
+
if (this.plugins[i].plugin === plugin) {
|
|
74
|
+
this.plugins.splice(i, 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Remove all plugins
|
|
80
|
+
*/
|
|
81
|
+
clear() {
|
|
82
|
+
this.plugins = [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.default = PluginInterface;
|
|
86
|
+
//# sourceMappingURL=PluginInterface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginInterface.js","sourceRoot":"","sources":["../../src/debugProtocol/PluginInterface.ts"],"names":[],"mappings":";;AAKA,MAAqB,eAAe;IAChC,YACI,UAAU,EAAe;QAOrB,YAAO,GAAoC,EAAE,CAAC;QALlD,KAAK,MAAM,MAAM,IAAI,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SACpB;IACL,CAAC;IAID;;OAEG;IACI,KAAK,CAAC,IAAI,CAAmC,SAAY,EAAE,KAA+B;QAC7F,KAAK,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE;YACjC,IAAK,MAAc,CAAC,SAAS,CAAC,EAAE;gBAC5B,MAAM,OAAO,CAAC,OAAO,CAAE,MAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;aAC5D;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,GAAG,CAA8B,MAAS,EAAE,QAAQ,GAAG,CAAC;QAC3D,MAAM,SAAS,GAAG;YACd,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,QAAQ;SACrB,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE7B,8BAA8B;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACvB,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QACnC,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
|
2
|
+
import { SmartBuffer } from 'smart-buffer';
|
|
3
|
+
import type { UpdateType } from './Constants';
|
|
4
|
+
import type { ProtocolRequest, ProtocolResponse, ProtocolUpdate } from './events/ProtocolEvent';
|
|
5
|
+
export declare class ProtocolUtil {
|
|
6
|
+
/**
|
|
7
|
+
* Load json data onto an event, and mark it as successful
|
|
8
|
+
*/
|
|
9
|
+
loadJson(event: {
|
|
10
|
+
data: any;
|
|
11
|
+
success: boolean;
|
|
12
|
+
}, data: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Helper function for buffer loading.
|
|
15
|
+
* Handles things like try/catch, setting buffer read offset, etc
|
|
16
|
+
*/
|
|
17
|
+
bufferLoaderHelper(event: {
|
|
18
|
+
success: boolean;
|
|
19
|
+
readOffset: number;
|
|
20
|
+
data?: {
|
|
21
|
+
packetLength?: number;
|
|
22
|
+
};
|
|
23
|
+
}, buffer: Buffer, minByteLength: number, processor: (buffer: SmartBuffer) => boolean | void): {
|
|
24
|
+
success: boolean;
|
|
25
|
+
readOffset: number;
|
|
26
|
+
data?: {
|
|
27
|
+
packetLength?: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Load the common DebuggerRequest fields
|
|
32
|
+
*/
|
|
33
|
+
loadCommonRequestFields(request: ProtocolRequest, smartBuffer: SmartBuffer): void;
|
|
34
|
+
/**
|
|
35
|
+
* Load the common DebuggerResponse
|
|
36
|
+
*/
|
|
37
|
+
loadCommonResponseFields(response: ProtocolResponse, smartBuffer: SmartBuffer): void;
|
|
38
|
+
loadCommonUpdateFields(update: ProtocolUpdate, smartBuffer: SmartBuffer, updateType: UpdateType): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Inserts the common command fields to the beginning of the buffer, and computes
|
|
41
|
+
* the correct `packet_length` value.
|
|
42
|
+
*/
|
|
43
|
+
insertCommonRequestFields(request: ProtocolRequest, smartBuffer: SmartBuffer): SmartBuffer;
|
|
44
|
+
insertCommonResponseFields(response: ProtocolResponse, smartBuffer: SmartBuffer): SmartBuffer;
|
|
45
|
+
/**
|
|
46
|
+
* Inserts the common response fields to the beginning of the buffer, and computes
|
|
47
|
+
* the correct `packet_length` value.
|
|
48
|
+
*/
|
|
49
|
+
insertCommonUpdateFields(update: ProtocolUpdate, smartBuffer: SmartBuffer): SmartBuffer;
|
|
50
|
+
/**
|
|
51
|
+
* Tries to read a string from the buffer and will throw an error if there is no null terminator.
|
|
52
|
+
* @param {SmartBuffer} bufferReader
|
|
53
|
+
*/
|
|
54
|
+
readStringNT(bufferReader: SmartBuffer): string;
|
|
55
|
+
}
|
|
56
|
+
export declare const protocolUtil: ProtocolUtil;
|