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.
Files changed (211) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/CompileErrorProcessor.d.ts +7 -2
  3. package/dist/CompileErrorProcessor.js +64 -69
  4. package/dist/CompileErrorProcessor.js.map +1 -1
  5. package/dist/DeviceInfo.d.ts +1 -0
  6. package/dist/adapters/DebugProtocolAdapter.d.ts +64 -17
  7. package/dist/adapters/DebugProtocolAdapter.js +264 -157
  8. package/dist/adapters/DebugProtocolAdapter.js.map +1 -1
  9. package/dist/adapters/TelnetAdapter.d.ts +8 -3
  10. package/dist/adapters/TelnetAdapter.js +14 -6
  11. package/dist/adapters/TelnetAdapter.js.map +1 -1
  12. package/dist/debugProtocol/Constants.d.ts +171 -81
  13. package/dist/debugProtocol/Constants.js +206 -126
  14. package/dist/debugProtocol/Constants.js.map +1 -1
  15. package/dist/debugProtocol/DebugProtocolClientReplaySession.d.ts +46 -0
  16. package/dist/debugProtocol/DebugProtocolClientReplaySession.js +278 -0
  17. package/dist/debugProtocol/DebugProtocolClientReplaySession.js.map +1 -0
  18. package/dist/debugProtocol/PluginInterface.d.ts +38 -0
  19. package/dist/debugProtocol/PluginInterface.js +86 -0
  20. package/dist/debugProtocol/PluginInterface.js.map +1 -0
  21. package/dist/debugProtocol/ProtocolUtil.d.ts +56 -0
  22. package/dist/debugProtocol/ProtocolUtil.js +164 -0
  23. package/dist/debugProtocol/ProtocolUtil.js.map +1 -0
  24. package/dist/debugProtocol/client/DebugProtocolClient.d.ts +310 -0
  25. package/dist/debugProtocol/client/DebugProtocolClient.js +1079 -0
  26. package/dist/debugProtocol/client/DebugProtocolClient.js.map +1 -0
  27. package/dist/debugProtocol/client/DebugProtocolClientPlugin.d.ts +44 -0
  28. package/dist/debugProtocol/client/DebugProtocolClientPlugin.js +3 -0
  29. package/dist/debugProtocol/client/DebugProtocolClientPlugin.js.map +1 -0
  30. package/dist/debugProtocol/events/ProtocolEvent.d.ts +66 -0
  31. package/dist/debugProtocol/events/ProtocolEvent.js +3 -0
  32. package/dist/debugProtocol/events/ProtocolEvent.js.map +1 -0
  33. package/dist/debugProtocol/events/requests/AddBreakpointsRequest.d.ts +30 -0
  34. package/dist/debugProtocol/events/requests/AddBreakpointsRequest.js +63 -0
  35. package/dist/debugProtocol/events/requests/AddBreakpointsRequest.js.map +1 -0
  36. package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.d.ts +48 -0
  37. package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.js +69 -0
  38. package/dist/debugProtocol/events/requests/AddConditionalBreakpointsRequest.js.map +1 -0
  39. package/dist/debugProtocol/events/requests/ContinueRequest.d.ts +20 -0
  40. package/dist/debugProtocol/events/requests/ContinueRequest.js +40 -0
  41. package/dist/debugProtocol/events/requests/ContinueRequest.js.map +1 -0
  42. package/dist/debugProtocol/events/requests/ExecuteRequest.d.ts +26 -0
  43. package/dist/debugProtocol/events/requests/ExecuteRequest.js +49 -0
  44. package/dist/debugProtocol/events/requests/ExecuteRequest.js.map +1 -0
  45. package/dist/debugProtocol/events/requests/ExitChannelRequest.d.ts +20 -0
  46. package/dist/debugProtocol/events/requests/ExitChannelRequest.js +40 -0
  47. package/dist/debugProtocol/events/requests/ExitChannelRequest.js.map +1 -0
  48. package/dist/debugProtocol/events/requests/HandshakeRequest.d.ts +26 -0
  49. package/dist/debugProtocol/events/requests/HandshakeRequest.js +47 -0
  50. package/dist/debugProtocol/events/requests/HandshakeRequest.js.map +1 -0
  51. package/dist/debugProtocol/events/requests/ListBreakpointsRequest.d.ts +20 -0
  52. package/dist/debugProtocol/events/requests/ListBreakpointsRequest.js +40 -0
  53. package/dist/debugProtocol/events/requests/ListBreakpointsRequest.js.map +1 -0
  54. package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.d.ts +29 -0
  55. package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.js +60 -0
  56. package/dist/debugProtocol/events/requests/RemoveBreakpointsRequest.js.map +1 -0
  57. package/dist/debugProtocol/events/requests/StackTraceRequest.d.ts +22 -0
  58. package/dist/debugProtocol/events/requests/StackTraceRequest.js +43 -0
  59. package/dist/debugProtocol/events/requests/StackTraceRequest.js.map +1 -0
  60. package/dist/debugProtocol/events/requests/StepRequest.d.ts +25 -0
  61. package/dist/debugProtocol/events/requests/StepRequest.js +46 -0
  62. package/dist/debugProtocol/events/requests/StepRequest.js.map +1 -0
  63. package/dist/debugProtocol/events/requests/StopRequest.d.ts +20 -0
  64. package/dist/debugProtocol/events/requests/StopRequest.js +39 -0
  65. package/dist/debugProtocol/events/requests/StopRequest.js.map +1 -0
  66. package/dist/debugProtocol/events/requests/ThreadsRequest.d.ts +20 -0
  67. package/dist/debugProtocol/events/requests/ThreadsRequest.js +40 -0
  68. package/dist/debugProtocol/events/requests/ThreadsRequest.js.map +1 -0
  69. package/dist/debugProtocol/events/requests/VariablesRequest.d.ts +59 -0
  70. package/dist/debugProtocol/events/requests/VariablesRequest.js +123 -0
  71. package/dist/debugProtocol/events/requests/VariablesRequest.js.map +1 -0
  72. package/dist/debugProtocol/events/responses/AddBreakpointsResponse.js.map +1 -0
  73. package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.d.ts +3 -0
  74. package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.js +9 -0
  75. package/dist/debugProtocol/events/responses/AddConditionalBreakpointsResponse.js.map +1 -0
  76. package/dist/debugProtocol/events/responses/ExecuteV3Response.d.ts +42 -0
  77. package/dist/debugProtocol/events/responses/ExecuteV3Response.js +94 -0
  78. package/dist/debugProtocol/events/responses/ExecuteV3Response.js.map +1 -0
  79. package/dist/debugProtocol/events/responses/GenericResponse.d.ts +17 -0
  80. package/dist/debugProtocol/events/responses/GenericResponse.js +40 -0
  81. package/dist/debugProtocol/events/responses/GenericResponse.js.map +1 -0
  82. package/dist/debugProtocol/events/responses/GenericV3Response.d.ts +15 -0
  83. package/dist/debugProtocol/events/responses/GenericV3Response.js +38 -0
  84. package/dist/debugProtocol/events/responses/GenericV3Response.js.map +1 -0
  85. package/dist/debugProtocol/events/responses/HandshakeResponse.d.ts +28 -0
  86. package/dist/debugProtocol/events/responses/HandshakeResponse.js +69 -0
  87. package/dist/debugProtocol/events/responses/HandshakeResponse.js.map +1 -0
  88. package/dist/debugProtocol/events/responses/HandshakeV3Response.d.ts +42 -0
  89. package/dist/debugProtocol/events/responses/HandshakeV3Response.js +98 -0
  90. package/dist/debugProtocol/events/responses/HandshakeV3Response.js.map +1 -0
  91. package/dist/debugProtocol/events/responses/ListBreakpointsResponse.d.ts +35 -0
  92. package/dist/debugProtocol/events/responses/ListBreakpointsResponse.js +68 -0
  93. package/dist/debugProtocol/events/responses/ListBreakpointsResponse.js.map +1 -0
  94. package/dist/debugProtocol/events/responses/RemoveBreakpointsResponse.js.map +1 -0
  95. package/dist/debugProtocol/events/responses/StackTraceResponse.d.ts +24 -0
  96. package/dist/debugProtocol/events/responses/StackTraceResponse.js +72 -0
  97. package/dist/debugProtocol/events/responses/StackTraceResponse.js.map +1 -0
  98. package/dist/debugProtocol/events/responses/StackTraceV3Response.d.ts +37 -0
  99. package/dist/debugProtocol/events/responses/StackTraceV3Response.js +67 -0
  100. package/dist/debugProtocol/events/responses/StackTraceV3Response.js.map +1 -0
  101. package/dist/debugProtocol/events/responses/ThreadsResponse.d.ts +54 -0
  102. package/dist/debugProtocol/events/responses/ThreadsResponse.js +80 -0
  103. package/dist/debugProtocol/events/responses/ThreadsResponse.js.map +1 -0
  104. package/dist/debugProtocol/events/responses/VariablesResponse.d.ts +117 -0
  105. package/dist/debugProtocol/events/responses/VariablesResponse.js +335 -0
  106. package/dist/debugProtocol/events/responses/VariablesResponse.js.map +1 -0
  107. package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.d.ts +35 -0
  108. package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.js +58 -0
  109. package/dist/debugProtocol/events/updates/AllThreadsStoppedUpdate.js.map +1 -0
  110. package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.d.ts +42 -0
  111. package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.js +97 -0
  112. package/dist/debugProtocol/events/updates/BreakpointErrorUpdate.js.map +1 -0
  113. package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.d.ts +41 -0
  114. package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.js +74 -0
  115. package/dist/debugProtocol/events/updates/BreakpointVerifiedUpdate.js.map +1 -0
  116. package/dist/debugProtocol/events/updates/CompileErrorUpdate.d.ts +60 -0
  117. package/dist/debugProtocol/events/updates/CompileErrorUpdate.js +89 -0
  118. package/dist/debugProtocol/events/updates/CompileErrorUpdate.js.map +1 -0
  119. package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.d.ts +23 -0
  120. package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.js +49 -0
  121. package/dist/debugProtocol/events/updates/IOPortOpenedUpdate.js.map +1 -0
  122. package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.d.ts +26 -0
  123. package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.js +50 -0
  124. package/dist/debugProtocol/events/updates/ThreadAttachedUpdate.js.map +1 -0
  125. package/dist/debugProtocol/server/DebugProtocolServer.d.ts +110 -0
  126. package/dist/debugProtocol/server/DebugProtocolServer.js +306 -0
  127. package/dist/debugProtocol/server/DebugProtocolServer.js.map +1 -0
  128. package/dist/debugProtocol/server/DebugProtocolServerPlugin.d.ts +41 -0
  129. package/dist/debugProtocol/server/DebugProtocolServerPlugin.js +3 -0
  130. package/dist/debugProtocol/server/DebugProtocolServerPlugin.js.map +1 -0
  131. package/dist/debugSession/BrightScriptDebugSession.d.ts +9 -1
  132. package/dist/debugSession/BrightScriptDebugSession.js +178 -89
  133. package/dist/debugSession/BrightScriptDebugSession.js.map +1 -1
  134. package/dist/index.d.ts +2 -3
  135. package/dist/index.js +2 -3
  136. package/dist/index.js.map +1 -1
  137. package/dist/logging.d.ts +1 -0
  138. package/dist/logging.js +4 -2
  139. package/dist/logging.js.map +1 -1
  140. package/dist/managers/ActionQueue.d.ts +7 -1
  141. package/dist/managers/ActionQueue.js +27 -5
  142. package/dist/managers/ActionQueue.js.map +1 -1
  143. package/dist/managers/BreakpointManager.d.ts +82 -27
  144. package/dist/managers/BreakpointManager.js +168 -63
  145. package/dist/managers/BreakpointManager.js.map +1 -1
  146. package/dist/managers/ProjectManager.d.ts +3 -0
  147. package/dist/managers/ProjectManager.js +42 -36
  148. package/dist/managers/ProjectManager.js.map +1 -1
  149. package/dist/util.d.ts +8 -6
  150. package/dist/util.js +36 -19
  151. package/dist/util.js.map +1 -1
  152. package/package.json +14 -5
  153. package/roku-debug-0.20.7.tgz +0 -0
  154. package/dist/debugProtocol/Debugger.d.ts +0 -161
  155. package/dist/debugProtocol/Debugger.js +0 -635
  156. package/dist/debugProtocol/Debugger.js.map +0 -1
  157. package/dist/debugProtocol/responses/AddBreakpointsResponse.js.map +0 -1
  158. package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.d.ts +0 -32
  159. package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.js +0 -67
  160. package/dist/debugProtocol/responses/BreakpointErrorUpdateResponse.js.map +0 -1
  161. package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.d.ts +0 -32
  162. package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.js +0 -56
  163. package/dist/debugProtocol/responses/BreakpointVerifiedUpdateResponse.js.map +0 -1
  164. package/dist/debugProtocol/responses/ConnectIOPortResponse.d.ts +0 -10
  165. package/dist/debugProtocol/responses/ConnectIOPortResponse.js +0 -39
  166. package/dist/debugProtocol/responses/ConnectIOPortResponse.js.map +0 -1
  167. package/dist/debugProtocol/responses/ExecuteResponseV3.d.ts +0 -23
  168. package/dist/debugProtocol/responses/ExecuteResponseV3.js +0 -54
  169. package/dist/debugProtocol/responses/ExecuteResponseV3.js.map +0 -1
  170. package/dist/debugProtocol/responses/HandshakeResponse.d.ts +0 -12
  171. package/dist/debugProtocol/responses/HandshakeResponse.js +0 -39
  172. package/dist/debugProtocol/responses/HandshakeResponse.js.map +0 -1
  173. package/dist/debugProtocol/responses/HandshakeResponseV3.d.ts +0 -14
  174. package/dist/debugProtocol/responses/HandshakeResponseV3.js +0 -47
  175. package/dist/debugProtocol/responses/HandshakeResponseV3.js.map +0 -1
  176. package/dist/debugProtocol/responses/ListBreakpointsResponse.d.ts +0 -25
  177. package/dist/debugProtocol/responses/ListBreakpointsResponse.js +0 -65
  178. package/dist/debugProtocol/responses/ListBreakpointsResponse.js.map +0 -1
  179. package/dist/debugProtocol/responses/ProtocolEvent.d.ts +0 -11
  180. package/dist/debugProtocol/responses/ProtocolEvent.js +0 -38
  181. package/dist/debugProtocol/responses/ProtocolEvent.js.map +0 -1
  182. package/dist/debugProtocol/responses/ProtocolEventV3.d.ts +0 -11
  183. package/dist/debugProtocol/responses/ProtocolEventV3.js +0 -42
  184. package/dist/debugProtocol/responses/ProtocolEventV3.js.map +0 -1
  185. package/dist/debugProtocol/responses/RemoveBreakpointsResponse.js.map +0 -1
  186. package/dist/debugProtocol/responses/StackTraceResponse.d.ts +0 -18
  187. package/dist/debugProtocol/responses/StackTraceResponse.js +0 -58
  188. package/dist/debugProtocol/responses/StackTraceResponse.js.map +0 -1
  189. package/dist/debugProtocol/responses/StackTraceResponseV3.d.ts +0 -18
  190. package/dist/debugProtocol/responses/StackTraceResponseV3.js +0 -58
  191. package/dist/debugProtocol/responses/StackTraceResponseV3.js.map +0 -1
  192. package/dist/debugProtocol/responses/ThreadsResponse.d.ts +0 -22
  193. package/dist/debugProtocol/responses/ThreadsResponse.js +0 -63
  194. package/dist/debugProtocol/responses/ThreadsResponse.js.map +0 -1
  195. package/dist/debugProtocol/responses/UndefinedResponse.d.ts +0 -10
  196. package/dist/debugProtocol/responses/UndefinedResponse.js +0 -39
  197. package/dist/debugProtocol/responses/UndefinedResponse.js.map +0 -1
  198. package/dist/debugProtocol/responses/UpdateThreadsResponse.d.ts +0 -25
  199. package/dist/debugProtocol/responses/UpdateThreadsResponse.js +0 -91
  200. package/dist/debugProtocol/responses/UpdateThreadsResponse.js.map +0 -1
  201. package/dist/debugProtocol/responses/VariableResponse.d.ts +0 -27
  202. package/dist/debugProtocol/responses/VariableResponse.js +0 -141
  203. package/dist/debugProtocol/responses/VariableResponse.js.map +0 -1
  204. package/dist/debugProtocol/responses/index.d.ts +0 -11
  205. package/dist/debugProtocol/responses/index.js +0 -24
  206. package/dist/debugProtocol/responses/index.js.map +0 -1
  207. package/roku-debug-0.20.6.tgz +0 -0
  208. /package/dist/debugProtocol/{responses → events/responses}/AddBreakpointsResponse.d.ts +0 -0
  209. /package/dist/debugProtocol/{responses → events/responses}/AddBreakpointsResponse.js +0 -0
  210. /package/dist/debugProtocol/{responses → events/responses}/RemoveBreakpointsResponse.d.ts +0 -0
  211. /package/dist/debugProtocol/{responses → events/responses}/RemoveBreakpointsResponse.js +0 -0
@@ -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,sEAAmE;AACnE,kCAAsC;AAEtC,sEAAmE;AACnE,2BAA2B;AAC3B,yDAAsD;AACtD,4EAA+F;AAE/F,MAAa,gCAAgC;IACzC,YAAY,OAEX;QAIO,gBAAW,GAAG,KAAK,EAAc,CAAC;QAWlC,eAAU,GAAG,CAAC,CAAC;QAqChB,WAAM,GAA+D,EAAE,CAAC;QACvE,aAAQ,GAAG,IAAA,YAAK,GAAE,CAAC;QAiGnB,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAE9B,sBAAiB,GAAG,IAAI,yBAAW,EAAE,CAAC;QAkEtC,sBAAiB,GAAG,IAAI,yBAAW,EAAE,CAAC;QAEtC,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAC9B,qBAAgB,GAAG,CAAC,CAAC;QA5NzB,IAAI,CAAC,cAAc,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;IAgBO,SAAS;QACb,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;IACO,YAAY;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3C,CAAC;IAEO,OAAO;;QACX,OAAO,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,0CAAE,IAAI,MAAK,IAAI,EAAE;YACjD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YAC9C,IAA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AAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;CACJ;AAED,SAAS,gBAAgB,CAAC,OAAe,EAAE,MAAc;IACrD,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC;IAC1C,MAAM,UAAU,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,M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ACI,MAAM,CAA8B,MAAS;QAChD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE;gBACnC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aAC7B;SACJ;IACL,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AA5FD,kCA4FC"}
@@ -0,0 +1,56 @@
1
+ /// <reference types="node" />
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;
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.protocolUtil = exports.ProtocolUtil = void 0;
4
+ const smart_buffer_1 = require("smart-buffer");
5
+ const util_1 = require("../util");
6
+ const Constants_1 = require("./Constants");
7
+ class ProtocolUtil {
8
+ /**
9
+ * Load json data onto an event, and mark it as successful
10
+ */
11
+ loadJson(event, data) {
12
+ event.data = {
13
+ ...event.data,
14
+ ...(data !== null && data !== void 0 ? data : {})
15
+ };
16
+ event.success = true;
17
+ }
18
+ /**
19
+ * Helper function for buffer loading.
20
+ * Handles things like try/catch, setting buffer read offset, etc
21
+ */
22
+ bufferLoaderHelper(event, buffer, minByteLength, processor) {
23
+ var _a, _b;
24
+ // Required size of this processor
25
+ try {
26
+ if (buffer.byteLength >= minByteLength) {
27
+ let smartBuffer = smart_buffer_1.SmartBuffer.fromBuffer(buffer);
28
+ //have the processor consume the requred bytes.
29
+ event.success = ((_a = processor(smartBuffer)) !== null && _a !== void 0 ? _a : true);
30
+ //if the event has a packet length, use THAT as the read offset. Otherwise, set the offset to the end of the read position of the buffer
31
+ if (event.success) {
32
+ if (!event.readOffset) {
33
+ event.readOffset = (_b = event.data.packetLength) !== null && _b !== void 0 ? _b : smartBuffer.readOffset;
34
+ }
35
+ }
36
+ }
37
+ }
38
+ catch (error) {
39
+ // Could not parse
40
+ event.readOffset = 0;
41
+ event.success = false;
42
+ }
43
+ return event;
44
+ }
45
+ /**
46
+ * Load the common DebuggerRequest fields
47
+ */
48
+ loadCommonRequestFields(request, smartBuffer) {
49
+ request.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
50
+ request.data.requestId = smartBuffer.readUInt32LE(); // request_id
51
+ request.data.command = Constants_1.CommandCode[smartBuffer.readUInt32LE()]; // command_code
52
+ }
53
+ /**
54
+ * Load the common DebuggerResponse
55
+ */
56
+ loadCommonResponseFields(response, smartBuffer) {
57
+ response.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
58
+ response.data.requestId = smartBuffer.readUInt32LE(); // request_id
59
+ response.data.errorCode = smartBuffer.readUInt32LE(); // error_code
60
+ //if the error code is non-zero, and we have more bytes, then there will be additional data about the error
61
+ if (response.data.errorCode !== Constants_1.ErrorCode.OK && response.data.packetLength > smartBuffer.readOffset) {
62
+ response.data.errorData = {};
63
+ const errorFlags = smartBuffer.readUInt32LE(); // error_flags
64
+ // eslint-disable-next-line no-bitwise
65
+ if (errorFlags & Constants_1.ErrorFlags.INVALID_VALUE_IN_PATH) {
66
+ response.data.errorData.invalidPathIndex = smartBuffer.readUInt32LE(); // invalid_path_index
67
+ }
68
+ // eslint-disable-next-line no-bitwise
69
+ if (errorFlags & Constants_1.ErrorFlags.MISSING_KEY_IN_PATH) {
70
+ response.data.errorData.missingKeyIndex = smartBuffer.readUInt32LE(); // missing_key_index
71
+ }
72
+ }
73
+ }
74
+ loadCommonUpdateFields(update, smartBuffer, updateType) {
75
+ update.data.packetLength = smartBuffer.readUInt32LE(); // packet_length
76
+ update.data.requestId = smartBuffer.readUInt32LE(); // request_id
77
+ update.data.errorCode = smartBuffer.readUInt32LE(); // error_code
78
+ // requestId 0 means this is an update.
79
+ if (update.data.requestId === 0) {
80
+ update.data.updateType = Constants_1.UpdateTypeCode[smartBuffer.readUInt32LE()];
81
+ //if this is not the update type we want, return false
82
+ if (update.data.updateType !== updateType) {
83
+ return false;
84
+ }
85
+ }
86
+ else {
87
+ //not an update. We should not proceed any further.
88
+ throw new Error('This is not an update');
89
+ }
90
+ }
91
+ /**
92
+ * Inserts the common command fields to the beginning of the buffer, and computes
93
+ * the correct `packet_length` value.
94
+ */
95
+ insertCommonRequestFields(request, smartBuffer) {
96
+ smartBuffer.insertUInt32LE(Constants_1.CommandCode[request.data.command], 0); // command_code - An enum representing the debugging command being sent. See the COMMANDS enum
97
+ smartBuffer.insertUInt32LE(request.data.requestId, 0); // request_id - The ID of the debugger request (must be >=1). This ID is included in the debugger response.
98
+ smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length - The size of the packet to be sent.
99
+ request.data.packetLength = smartBuffer.writeOffset;
100
+ return smartBuffer;
101
+ }
102
+ insertCommonResponseFields(response, smartBuffer) {
103
+ var _a, _b, _c, _d, _e;
104
+ //insert error data
105
+ const flags = (
106
+ // eslint-disable-next-line no-bitwise
107
+ 0 |
108
+ (util_1.util.isNullish((_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.errorData) === null || _b === void 0 ? void 0 : _b.invalidPathIndex) ? 0 : Constants_1.ErrorFlags.INVALID_VALUE_IN_PATH) |
109
+ (util_1.util.isNullish((_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.errorData) === null || _d === void 0 ? void 0 : _d.missingKeyIndex) ? 0 : Constants_1.ErrorFlags.MISSING_KEY_IN_PATH));
110
+ if (response.data.errorCode !== Constants_1.ErrorCode.OK &&
111
+ //there's some error data
112
+ Object.values((_e = response.data.errorData) !== null && _e !== void 0 ? _e : {}).some(x => !util_1.util.isNullish(x))) {
113
+ //do these in reverse order since we're writing to the start of the buffer
114
+ if (!util_1.util.isNullish(response.data.errorData.missingKeyIndex)) {
115
+ smartBuffer.insertUInt32LE(response.data.errorData.missingKeyIndex, 0);
116
+ }
117
+ //write error data
118
+ if (!util_1.util.isNullish(response.data.errorData.invalidPathIndex)) {
119
+ smartBuffer.insertUInt32LE(response.data.errorData.invalidPathIndex, 0);
120
+ }
121
+ //write flags
122
+ smartBuffer.insertUInt32LE(flags, 0);
123
+ }
124
+ smartBuffer.insertUInt32LE(response.data.errorCode, 0); // error_code
125
+ smartBuffer.insertUInt32LE(response.data.requestId, 0); // request_id
126
+ smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length
127
+ response.data.packetLength = smartBuffer.writeOffset;
128
+ return smartBuffer;
129
+ }
130
+ /**
131
+ * Inserts the common response fields to the beginning of the buffer, and computes
132
+ * the correct `packet_length` value.
133
+ */
134
+ insertCommonUpdateFields(update, smartBuffer) {
135
+ smartBuffer.insertUInt32LE(Constants_1.UpdateTypeCode[update.data.updateType], 0); // update_type
136
+ smartBuffer.insertUInt32LE(update.data.errorCode, 0); // error_code
137
+ smartBuffer.insertUInt32LE(update.data.requestId, 0); // request_id
138
+ smartBuffer.insertUInt32LE(smartBuffer.writeOffset + 4, 0); // packet_length
139
+ update.data.packetLength = smartBuffer.writeOffset;
140
+ return smartBuffer;
141
+ }
142
+ /**
143
+ * Tries to read a string from the buffer and will throw an error if there is no null terminator.
144
+ * @param {SmartBuffer} bufferReader
145
+ */
146
+ readStringNT(bufferReader) {
147
+ // Find next null character (if one is not found, throw)
148
+ let buffer = bufferReader.toBuffer();
149
+ let foundNullTerminator = false;
150
+ for (let i = bufferReader.readOffset; i < buffer.length; i++) {
151
+ if (buffer[i] === 0x00) {
152
+ foundNullTerminator = true;
153
+ break;
154
+ }
155
+ }
156
+ if (!foundNullTerminator) {
157
+ throw new Error('Could not read buffer string as there is no null terminator.');
158
+ }
159
+ return bufferReader.readStringNT();
160
+ }
161
+ }
162
+ exports.ProtocolUtil = ProtocolUtil;
163
+ exports.protocolUtil = new ProtocolUtil();
164
+ //# sourceMappingURL=ProtocolUtil.js.map
@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