@yume-chan/adb 0.0.10 → 0.0.11

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 (318) hide show
  1. package/CHANGELOG.json +26 -0
  2. package/CHANGELOG.md +15 -1
  3. package/LICENSE +1 -1
  4. package/README.md +56 -43
  5. package/esm/adb.d.ts +48 -0
  6. package/esm/adb.d.ts.map +1 -0
  7. package/esm/adb.js +141 -146
  8. package/esm/adb.js.map +1 -1
  9. package/{dts → esm}/auth.d.ts +8 -8
  10. package/esm/auth.d.ts.map +1 -0
  11. package/esm/auth.js +68 -108
  12. package/esm/auth.js.map +1 -1
  13. package/esm/backend.d.ts +9 -0
  14. package/esm/backend.d.ts.map +1 -0
  15. package/{dts → esm}/commands/base.d.ts +1 -1
  16. package/esm/commands/base.d.ts.map +1 -0
  17. package/esm/commands/base.js +1 -0
  18. package/esm/commands/base.js.map +1 -1
  19. package/{dts → esm}/commands/framebuffer.d.ts +3 -3
  20. package/esm/commands/framebuffer.d.ts.map +1 -0
  21. package/esm/commands/framebuffer.js +15 -18
  22. package/esm/commands/framebuffer.js.map +1 -1
  23. package/esm/commands/index.d.ts +9 -0
  24. package/esm/commands/index.d.ts.map +1 -0
  25. package/esm/commands/index.js +8 -8
  26. package/esm/commands/index.js.map +1 -1
  27. package/esm/commands/install.d.ts +4 -0
  28. package/esm/commands/install.d.ts.map +1 -0
  29. package/esm/commands/install.js +21 -13
  30. package/esm/commands/install.js.map +1 -1
  31. package/esm/commands/power.d.ts +23 -0
  32. package/esm/commands/power.d.ts.map +1 -0
  33. package/esm/commands/power.js +45 -0
  34. package/esm/commands/power.js.map +1 -0
  35. package/{dts → esm}/commands/reverse.d.ts +3 -3
  36. package/esm/commands/reverse.d.ts.map +1 -0
  37. package/esm/commands/reverse.js +49 -60
  38. package/esm/commands/reverse.js.map +1 -1
  39. package/esm/commands/subprocess/index.d.ts +57 -0
  40. package/esm/commands/subprocess/index.d.ts.map +1 -0
  41. package/esm/commands/subprocess/index.js +83 -0
  42. package/esm/commands/subprocess/index.js.map +1 -0
  43. package/esm/commands/subprocess/legacy.d.ts +28 -0
  44. package/esm/commands/subprocess/legacy.d.ts.map +1 -0
  45. package/esm/commands/subprocess/legacy.js +44 -0
  46. package/esm/commands/subprocess/legacy.js.map +1 -0
  47. package/esm/commands/subprocess/protocol.d.ts +38 -0
  48. package/esm/commands/subprocess/protocol.d.ts.map +1 -0
  49. package/esm/commands/subprocess/protocol.js +155 -0
  50. package/esm/commands/subprocess/protocol.js.map +1 -0
  51. package/esm/commands/subprocess/types.d.ts +47 -0
  52. package/esm/commands/subprocess/types.d.ts.map +1 -0
  53. package/esm/commands/{shell → subprocess}/types.js +0 -0
  54. package/esm/commands/{shell → subprocess}/types.js.map +1 -1
  55. package/{dts/commands/shell → esm/commands/subprocess}/utils.d.ts +0 -0
  56. package/esm/commands/subprocess/utils.d.ts.map +1 -0
  57. package/esm/commands/{shell → subprocess}/utils.js +0 -0
  58. package/esm/commands/subprocess/utils.js.map +1 -0
  59. package/esm/commands/sync/index.d.ts +8 -0
  60. package/esm/commands/sync/index.d.ts.map +1 -0
  61. package/esm/commands/sync/index.js +7 -7
  62. package/esm/commands/sync/index.js.map +1 -1
  63. package/{dts → esm}/commands/sync/list.d.ts +4 -4
  64. package/esm/commands/sync/list.d.ts.map +1 -0
  65. package/esm/commands/sync/list.js +16 -19
  66. package/esm/commands/sync/list.js.map +1 -1
  67. package/esm/commands/sync/pull.d.ts +11 -0
  68. package/esm/commands/sync/pull.d.ts.map +1 -0
  69. package/esm/commands/sync/pull.js +17 -11
  70. package/esm/commands/sync/pull.js.map +1 -1
  71. package/esm/commands/sync/push.d.ts +8 -0
  72. package/esm/commands/sync/push.d.ts.map +1 -0
  73. package/esm/commands/sync/push.js +19 -37
  74. package/esm/commands/sync/push.js.map +1 -1
  75. package/{dts → esm}/commands/sync/request.d.ts +3 -3
  76. package/esm/commands/sync/request.d.ts.map +1 -0
  77. package/esm/commands/sync/request.js +24 -27
  78. package/esm/commands/sync/request.js.map +1 -1
  79. package/{dts → esm}/commands/sync/response.d.ts +2 -2
  80. package/esm/commands/sync/response.d.ts.map +1 -0
  81. package/esm/commands/sync/response.js +16 -20
  82. package/esm/commands/sync/response.js.map +1 -1
  83. package/{dts → esm}/commands/sync/stat.d.ts +4 -4
  84. package/esm/commands/sync/stat.d.ts.map +1 -0
  85. package/esm/commands/sync/stat.js +22 -27
  86. package/esm/commands/sync/stat.js.map +1 -1
  87. package/esm/commands/sync/sync.d.ts +83 -0
  88. package/esm/commands/sync/sync.d.ts.map +1 -0
  89. package/esm/commands/sync/sync.js +92 -89
  90. package/esm/commands/sync/sync.js.map +1 -1
  91. package/{dts → esm}/commands/tcpip.d.ts +1 -1
  92. package/{dts → esm}/commands/tcpip.d.ts.map +1 -1
  93. package/esm/commands/tcpip.js +14 -19
  94. package/esm/commands/tcpip.js.map +1 -1
  95. package/{dts → esm}/crypto.d.ts +7 -7
  96. package/esm/crypto.d.ts.map +1 -0
  97. package/esm/crypto.js +26 -29
  98. package/esm/crypto.js.map +1 -1
  99. package/{dts → esm}/features.d.ts +0 -0
  100. package/{dts → esm}/features.d.ts.map +0 -0
  101. package/esm/features.js +1 -1
  102. package/esm/features.js.map +1 -1
  103. package/esm/index.d.ts +11 -0
  104. package/esm/index.d.ts.map +1 -0
  105. package/esm/index.js +10 -10
  106. package/esm/index.js.map +1 -1
  107. package/esm/packet.d.ts +28 -0
  108. package/esm/packet.d.ts.map +1 -0
  109. package/esm/packet.js +26 -51
  110. package/esm/packet.js.map +1 -1
  111. package/esm/socket/controller.d.ts +37 -0
  112. package/esm/socket/controller.d.ts.map +1 -0
  113. package/esm/socket/controller.js +52 -66
  114. package/esm/socket/controller.js.map +1 -1
  115. package/{dts → esm}/socket/dispatcher.d.ts +10 -23
  116. package/esm/socket/dispatcher.d.ts.map +1 -0
  117. package/esm/socket/dispatcher.js +148 -164
  118. package/esm/socket/dispatcher.js.map +1 -1
  119. package/esm/socket/index.d.ts +3 -0
  120. package/esm/socket/index.d.ts.map +1 -0
  121. package/esm/socket/index.js +2 -6
  122. package/esm/socket/index.js.map +1 -1
  123. package/esm/socket/socket.d.ts +34 -0
  124. package/esm/socket/socket.d.ts.map +1 -0
  125. package/esm/socket/socket.js +69 -14
  126. package/esm/socket/socket.js.map +1 -1
  127. package/esm/stream/buffered.d.ts +35 -0
  128. package/esm/stream/buffered.d.ts.map +1 -0
  129. package/esm/stream/buffered.js +123 -0
  130. package/esm/stream/buffered.js.map +1 -0
  131. package/esm/stream/detect.bak.d.ts +240 -0
  132. package/esm/stream/detect.bak.d.ts.map +1 -0
  133. package/esm/stream/detect.bak.js +60 -0
  134. package/esm/stream/detect.bak.js.map +1 -0
  135. package/esm/stream/detect.d.ts +18 -0
  136. package/esm/stream/detect.d.ts.map +1 -0
  137. package/esm/stream/detect.js +6 -0
  138. package/esm/stream/detect.js.map +1 -0
  139. package/esm/stream/detect.native.d.ts +240 -0
  140. package/esm/stream/detect.native.d.ts.map +1 -0
  141. package/esm/stream/detect.native.js +60 -0
  142. package/esm/stream/detect.native.js.map +1 -0
  143. package/esm/stream/detect.polyfill.d.ts +18 -0
  144. package/esm/stream/detect.polyfill.d.ts.map +1 -0
  145. package/esm/stream/detect.polyfill.js +6 -0
  146. package/esm/stream/detect.polyfill.js.map +1 -0
  147. package/esm/stream/index.d.ts +4 -0
  148. package/esm/stream/index.d.ts.map +1 -0
  149. package/esm/stream/index.js +3 -2
  150. package/esm/stream/index.js.map +1 -1
  151. package/esm/stream/transform.d.ts +98 -0
  152. package/esm/stream/transform.d.ts.map +1 -0
  153. package/esm/stream/transform.js +352 -0
  154. package/esm/stream/transform.js.map +1 -0
  155. package/{dts → esm}/utils/auto-reset-event.d.ts +1 -1
  156. package/esm/utils/auto-reset-event.d.ts.map +1 -0
  157. package/esm/utils/auto-reset-event.js +2 -1
  158. package/esm/utils/auto-reset-event.js.map +1 -1
  159. package/esm/utils/base64.d.ts +5 -0
  160. package/esm/utils/base64.d.ts.map +1 -0
  161. package/esm/utils/base64.js +116 -80
  162. package/esm/utils/base64.js.map +1 -1
  163. package/esm/utils/encoding.d.ts +3 -0
  164. package/{dts → esm}/utils/encoding.d.ts.map +1 -1
  165. package/esm/utils/encoding.js +1 -1
  166. package/esm/utils/encoding.js.map +1 -1
  167. package/esm/utils/index.d.ts +4 -0
  168. package/esm/utils/index.d.ts.map +1 -0
  169. package/esm/utils/index.js +3 -5
  170. package/esm/utils/index.js.map +1 -1
  171. package/package.json +50 -44
  172. package/src/adb.ts +147 -143
  173. package/src/auth.ts +23 -19
  174. package/src/backend.ts +3 -12
  175. package/src/commands/base.ts +1 -1
  176. package/src/commands/framebuffer.ts +4 -4
  177. package/src/commands/index.ts +8 -8
  178. package/src/commands/install.ts +26 -15
  179. package/src/commands/power.ts +54 -0
  180. package/src/commands/reverse.ts +10 -8
  181. package/src/commands/subprocess/index.ts +124 -0
  182. package/src/commands/subprocess/legacy.ts +58 -0
  183. package/src/commands/subprocess/protocol.ts +185 -0
  184. package/src/commands/subprocess/types.ts +55 -0
  185. package/src/commands/{shell → subprocess}/utils.ts +0 -0
  186. package/src/commands/sync/index.ts +7 -7
  187. package/src/commands/sync/list.ts +7 -6
  188. package/src/commands/sync/pull.ts +27 -18
  189. package/src/commands/sync/push.ts +25 -30
  190. package/src/commands/sync/request.ts +7 -7
  191. package/src/commands/sync/response.ts +4 -4
  192. package/src/commands/sync/stat.ts +8 -6
  193. package/src/commands/sync/sync.ts +64 -32
  194. package/src/commands/tcpip.ts +3 -3
  195. package/src/crypto.ts +38 -43
  196. package/src/index.ts +11 -10
  197. package/src/packet.ts +37 -52
  198. package/src/socket/dispatcher.ts +90 -103
  199. package/src/socket/index.ts +2 -6
  200. package/src/socket/socket.ts +117 -16
  201. package/src/stream/buffered.ts +147 -0
  202. package/src/stream/detect.native.ts +362 -0
  203. package/src/stream/detect.polyfill.ts +25 -0
  204. package/src/stream/detect.ts +25 -0
  205. package/src/stream/index.ts +3 -2
  206. package/src/stream/transform.ts +427 -0
  207. package/src/utils/auto-reset-event.ts +1 -1
  208. package/src/utils/base64.ts +161 -129
  209. package/src/utils/encoding.ts +3 -3
  210. package/src/utils/index.ts +3 -5
  211. package/tsconfig.build.json +3 -0
  212. package/tsconfig.build.tsbuildinfo +1 -0
  213. package/tsconfig.test.json +10 -0
  214. package/dts/adb.d.ts +0 -46
  215. package/dts/adb.d.ts.map +0 -1
  216. package/dts/auth.d.ts.map +0 -1
  217. package/dts/backend.d.ts +0 -13
  218. package/dts/backend.d.ts.map +0 -1
  219. package/dts/commands/base.d.ts.map +0 -1
  220. package/dts/commands/demo-mode.d.ts +0 -41
  221. package/dts/commands/demo-mode.d.ts.map +0 -1
  222. package/dts/commands/framebuffer.d.ts.map +0 -1
  223. package/dts/commands/index.d.ts +0 -9
  224. package/dts/commands/index.d.ts.map +0 -1
  225. package/dts/commands/install.d.ts +0 -3
  226. package/dts/commands/install.d.ts.map +0 -1
  227. package/dts/commands/reverse.d.ts.map +0 -1
  228. package/dts/commands/shell/index.d.ts +0 -46
  229. package/dts/commands/shell/index.d.ts.map +0 -1
  230. package/dts/commands/shell/legacy.d.ts +0 -38
  231. package/dts/commands/shell/legacy.d.ts.map +0 -1
  232. package/dts/commands/shell/protocol.d.ts +0 -45
  233. package/dts/commands/shell/protocol.d.ts.map +0 -1
  234. package/dts/commands/shell/types.d.ts +0 -47
  235. package/dts/commands/shell/types.d.ts.map +0 -1
  236. package/dts/commands/shell/utils.d.ts.map +0 -1
  237. package/dts/commands/sync/index.d.ts +0 -8
  238. package/dts/commands/sync/index.d.ts.map +0 -1
  239. package/dts/commands/sync/list.d.ts.map +0 -1
  240. package/dts/commands/sync/pull.d.ts +0 -11
  241. package/dts/commands/sync/pull.d.ts.map +0 -1
  242. package/dts/commands/sync/push.d.ts +0 -8
  243. package/dts/commands/sync/push.d.ts.map +0 -1
  244. package/dts/commands/sync/request.d.ts.map +0 -1
  245. package/dts/commands/sync/response.d.ts.map +0 -1
  246. package/dts/commands/sync/stat.d.ts.map +0 -1
  247. package/dts/commands/sync/sync.d.ts +0 -68
  248. package/dts/commands/sync/sync.d.ts.map +0 -1
  249. package/dts/crypto.d.ts.map +0 -1
  250. package/dts/index.d.ts +0 -11
  251. package/dts/index.d.ts.map +0 -1
  252. package/dts/packet.d.ts +0 -27
  253. package/dts/packet.d.ts.map +0 -1
  254. package/dts/socket/close-event-emitter.d.ts +0 -8
  255. package/dts/socket/close-event-emitter.d.ts.map +0 -1
  256. package/dts/socket/controller.d.ts +0 -43
  257. package/dts/socket/controller.d.ts.map +0 -1
  258. package/dts/socket/data-event-emitter.d.ts +0 -10
  259. package/dts/socket/data-event-emitter.d.ts.map +0 -1
  260. package/dts/socket/dispatcher.d.ts.map +0 -1
  261. package/dts/socket/index.d.ts +0 -7
  262. package/dts/socket/index.d.ts.map +0 -1
  263. package/dts/socket/logger.d.ts +0 -9
  264. package/dts/socket/logger.d.ts.map +0 -1
  265. package/dts/socket/socket.d.ts +0 -22
  266. package/dts/socket/socket.d.ts.map +0 -1
  267. package/dts/stream/buffered-stream.d.ts +0 -28
  268. package/dts/stream/buffered-stream.d.ts.map +0 -1
  269. package/dts/stream/index.d.ts +0 -3
  270. package/dts/stream/index.d.ts.map +0 -1
  271. package/dts/stream/stream.d.ts +0 -15
  272. package/dts/stream/stream.d.ts.map +0 -1
  273. package/dts/utils/auto-reset-event.d.ts.map +0 -1
  274. package/dts/utils/base64.d.ts +0 -7
  275. package/dts/utils/base64.d.ts.map +0 -1
  276. package/dts/utils/chunk.d.ts +0 -3
  277. package/dts/utils/chunk.d.ts.map +0 -1
  278. package/dts/utils/encoding.d.ts +0 -3
  279. package/dts/utils/event-queue.d.ts +0 -35
  280. package/dts/utils/event-queue.d.ts.map +0 -1
  281. package/dts/utils/index.d.ts +0 -6
  282. package/dts/utils/index.d.ts.map +0 -1
  283. package/esm/commands/demo-mode.js +0 -170
  284. package/esm/commands/demo-mode.js.map +0 -1
  285. package/esm/commands/shell/index.js +0 -62
  286. package/esm/commands/shell/index.js.map +0 -1
  287. package/esm/commands/shell/legacy.js +0 -49
  288. package/esm/commands/shell/legacy.js.map +0 -1
  289. package/esm/commands/shell/protocol.js +0 -106
  290. package/esm/commands/shell/protocol.js.map +0 -1
  291. package/esm/commands/shell/utils.js.map +0 -1
  292. package/esm/socket/close-event-emitter.js +0 -28
  293. package/esm/socket/close-event-emitter.js.map +0 -1
  294. package/esm/socket/data-event-emitter.js +0 -25
  295. package/esm/socket/data-event-emitter.js.map +0 -1
  296. package/esm/socket/logger.js +0 -2
  297. package/esm/socket/logger.js.map +0 -1
  298. package/esm/stream/buffered-stream.js +0 -67
  299. package/esm/stream/buffered-stream.js.map +0 -1
  300. package/esm/stream/stream.js +0 -41
  301. package/esm/stream/stream.js.map +0 -1
  302. package/esm/utils/chunk.js +0 -70
  303. package/esm/utils/chunk.js.map +0 -1
  304. package/esm/utils/event-queue.js +0 -104
  305. package/esm/utils/event-queue.js.map +0 -1
  306. package/src/commands/demo-mode.ts +0 -160
  307. package/src/commands/shell/index.ts +0 -87
  308. package/src/commands/shell/legacy.ts +0 -59
  309. package/src/commands/shell/protocol.ts +0 -121
  310. package/src/commands/shell/types.ts +0 -55
  311. package/src/socket/close-event-emitter.ts +0 -28
  312. package/src/socket/controller.ts +0 -105
  313. package/src/socket/data-event-emitter.ts +0 -27
  314. package/src/socket/logger.ts +0 -12
  315. package/src/stream/buffered-stream.ts +0 -92
  316. package/src/stream/stream.ts +0 -50
  317. package/src/utils/chunk.ts +0 -70
  318. package/src/utils/event-queue.ts +0 -145
@@ -5,7 +5,6 @@ const paddingChar = '='.charCodeAt(0);
5
5
  function addRange(start, end) {
6
6
  const charCodeStart = start.charCodeAt(0);
7
7
  const charCodeEnd = end.charCodeAt(0);
8
- const length = charCodeEnd - charCodeStart + 1;
9
8
  for (let charCode = charCodeStart; charCode <= charCodeEnd; charCode += 1) {
10
9
  charToIndex[String.fromCharCode(charCode)] = indexToChar.length;
11
10
  indexToChar.push(charCode);
@@ -21,84 +20,122 @@ export function calculateBase64EncodedLength(inputLength) {
21
20
  const paddingLength = remainder !== 0 ? 3 - remainder : 0;
22
21
  return [(inputLength + paddingLength) / 3 * 4, paddingLength];
23
22
  }
24
- export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
25
- var _a;
26
- if (input instanceof ArrayBuffer) {
27
- input = new Uint8Array(input);
28
- }
29
- // Because `Uint8Array` is type compatible with `ArrayBuffer`,
30
- // TypeScript doesn't correctly narrow `input` to `Uint8Array` when assigning.
31
- // Manually eliminate `ArrayBuffer` from `input` with a type guard.
32
- if (input instanceof ArrayBuffer) {
33
- return input;
34
- }
35
- let inputOffset;
36
- let inputLength;
37
- let output;
38
- let outputOffset;
39
- let outputArgumentIndex;
40
- if (typeof arg1 === 'number') {
41
- // overload 1, 3, 4
42
- inputOffset = arg1;
43
- if (typeof arg2 === 'number') {
44
- // overload 1, 4
45
- inputLength = arg2;
46
- outputArgumentIndex = 3;
47
- }
48
- else {
49
- // overload 3
50
- inputLength = input.byteLength - inputOffset;
51
- outputArgumentIndex = 2;
52
- }
23
+ export function encodeBase64(input, output) {
24
+ const [outputLength, paddingLength] = calculateBase64EncodedLength(input.length);
25
+ if (!output) {
26
+ output = new Uint8Array(outputLength);
27
+ encodeForward(input, output, paddingLength);
28
+ return output;
53
29
  }
54
30
  else {
55
- // overload 2
56
- inputOffset = 0;
57
- inputLength = input.byteLength;
58
- outputArgumentIndex = 1;
59
- }
60
- const [outputLength, paddingLength] = calculateBase64EncodedLength(inputLength);
61
- let maybeOutput = arguments[outputArgumentIndex];
62
- let outputType;
63
- if (maybeOutput) {
64
- outputOffset = (_a = arguments[outputArgumentIndex + 1]) !== null && _a !== void 0 ? _a : 0;
65
- if (maybeOutput.byteLength - outputOffset < outputLength) {
31
+ if (output.length < outputLength) {
66
32
  throw new Error('output buffer is too small');
67
33
  }
68
- if (maybeOutput instanceof ArrayBuffer) {
69
- output = new Uint8Array(maybeOutput);
34
+ output = output.subarray(0, outputLength);
35
+ // When input and output are on same ArrayBuffer,
36
+ // we check if it's possible to encode in-place.
37
+ if (input.buffer !== output.buffer) {
38
+ encodeForward(input, output, paddingLength);
39
+ }
40
+ else if (output.byteOffset + output.length - (paddingLength + 1) <= input.byteOffset + input.length) {
41
+ // Output ends before input ends
42
+ // So output won't catch up with input.
43
+ // Depends on padding length,
44
+ // it's possible to write 1-3 bytes after input ends.
45
+ // spell: disable-next-line
46
+ // | aaaaaabb | | | |
47
+ // | aaaaaa | bb0000 | = | = |
48
+ //
49
+ // spell: disable-next-line
50
+ // | aaaaaabb | bbbbcccc | | |
51
+ // | aaaaaa | bbbbbb | cccc00 | = |
52
+ //
53
+ // spell: disable-next-line
54
+ // | aaaaaabb | bbbbcccc | ccdddddd | |
55
+ // | aaaaaa | bbbbbb | cccccc | dddddd |
56
+ // Must encode forwards.
57
+ encodeForward(input, output, paddingLength);
58
+ }
59
+ else if (output.byteOffset >= input.byteOffset - 1) {
60
+ // Output starts after input starts
61
+ // So in backwards, output can't catch up with input.
62
+ // Because first 3 bytes becomes 4 bytes,
63
+ // it's possible to write 1 byte before input starts.
64
+ // spell: disable-next-line
65
+ // | | aaaaaabb | bbbbcccc | ccdddddd |
66
+ // | aaaaaa | bbbbbb | cccccc | dddddd |
67
+ // Must encode backwards.
68
+ encodeBackward(input, output, paddingLength);
70
69
  }
71
70
  else {
72
- output = maybeOutput;
71
+ // Input is in the middle of output,
72
+ // not possible to read neither first or last three bytes,
73
+ throw new Error('input and output cannot overlap');
73
74
  }
74
- outputType = 'number';
75
+ return outputLength;
75
76
  }
76
- else {
77
- const buffer = new ArrayBuffer(outputLength);
78
- output = new Uint8Array(buffer);
79
- outputOffset = 0;
80
- outputType = 'ArrayBuffer';
77
+ }
78
+ function encodeForward(input, output, paddingLength) {
79
+ let inputIndex = 0;
80
+ let outputIndex = 0;
81
+ while (inputIndex < input.length - 2) {
82
+ /* cspell: disable-next-line */
83
+ // aaaaaabb
84
+ const x = input[inputIndex];
85
+ inputIndex += 1;
86
+ /* cspell: disable-next-line */
87
+ // bbbbcccc
88
+ const y = input[inputIndex];
89
+ inputIndex += 1;
90
+ /* cspell: disable-next-line */
91
+ // ccdddddd
92
+ const z = input[inputIndex];
93
+ inputIndex += 1;
94
+ output[outputIndex] = indexToChar[x >> 2];
95
+ outputIndex += 1;
96
+ output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
97
+ outputIndex += 1;
98
+ output[outputIndex] = indexToChar[((y & 0b1111) << 2) | (z >> 6)];
99
+ outputIndex += 1;
100
+ output[outputIndex] = indexToChar[z & 0b111111];
101
+ outputIndex += 1;
81
102
  }
82
- // Because `Uint8Array` is type compatible with `ArrayBuffer`,
83
- // TypeScript doesn't correctly narrow `output` to `Uint8Array` when assigning.
84
- // Manually eliminate `ArrayBuffer` from `output` with a type guard.
85
- if (output instanceof ArrayBuffer) {
86
- return output;
103
+ if (paddingLength === 2) {
104
+ /* cspell: disable-next-line */
105
+ // aaaaaabb
106
+ const x = input[inputIndex];
107
+ inputIndex += 1;
108
+ output[outputIndex] = indexToChar[x >> 2];
109
+ outputIndex += 1;
110
+ output[outputIndex] = indexToChar[((x & 0b11) << 4)];
111
+ outputIndex += 1;
112
+ output[outputIndex] = paddingChar;
113
+ outputIndex += 1;
114
+ output[outputIndex] = paddingChar;
87
115
  }
88
- if (input.buffer === output.buffer) {
89
- const bufferInputStart = input.byteOffset + inputOffset;
90
- const bufferOutputStart = output.byteOffset + outputOffset;
91
- if (bufferOutputStart < bufferInputStart - 1) {
92
- const bufferOutputEnd = bufferOutputStart + outputLength;
93
- if (bufferOutputEnd >= bufferInputStart) {
94
- throw new Error('input and output buffer can not be overlapping');
95
- }
96
- }
116
+ else if (paddingLength === 1) {
117
+ /* cspell: disable-next-line */
118
+ // aaaaaabb
119
+ const x = input[inputIndex];
120
+ inputIndex += 1;
121
+ /* cspell: disable-next-line */
122
+ // bbbbcccc
123
+ const y = input[inputIndex];
124
+ inputIndex += 1;
125
+ output[outputIndex] = indexToChar[x >> 2];
126
+ outputIndex += 1;
127
+ output[outputIndex] = indexToChar[((x & 0b11) << 4) | (y >> 4)];
128
+ outputIndex += 1;
129
+ output[outputIndex] = indexToChar[((y & 0b1111) << 2)];
130
+ outputIndex += 1;
131
+ output[outputIndex] = paddingChar;
97
132
  }
98
- // Run backward to do in-place overwrite
99
- let inputIndex = inputOffset + inputLength - 1;
100
- let outputIndex = outputOffset + outputLength - 1;
133
+ }
134
+ function encodeBackward(input, output, paddingLength) {
135
+ let inputIndex = input.length - 1;
136
+ let outputIndex = output.length - 1;
101
137
  if (paddingLength === 2) {
138
+ /* cspell: disable-next-line */
102
139
  // aaaaaabb
103
140
  const x = input[inputIndex];
104
141
  inputIndex -= 1;
@@ -112,9 +149,11 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
112
149
  outputIndex -= 1;
113
150
  }
114
151
  else if (paddingLength === 1) {
152
+ /* cspell: disable-next-line */
115
153
  // bbbbcccc
116
154
  const y = input[inputIndex];
117
155
  inputIndex -= 1;
156
+ /* cspell: disable-next-line */
118
157
  // aaaaaabb
119
158
  const x = input[inputIndex];
120
159
  inputIndex -= 1;
@@ -127,13 +166,16 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
127
166
  output[outputIndex] = indexToChar[x >> 2];
128
167
  outputIndex -= 1;
129
168
  }
130
- while (inputIndex >= inputOffset) {
169
+ while (inputIndex >= 0) {
170
+ /* cspell: disable-next-line */
131
171
  // ccdddddd
132
172
  const z = input[inputIndex];
133
173
  inputIndex -= 1;
174
+ /* cspell: disable-next-line */
134
175
  // bbbbcccc
135
176
  const y = input[inputIndex];
136
177
  inputIndex -= 1;
178
+ /* cspell: disable-next-line */
137
179
  // aaaaaabb
138
180
  const x = input[inputIndex];
139
181
  inputIndex -= 1;
@@ -146,12 +188,6 @@ export function encodeBase64(input, arg1, arg2, _arg3, _arg4) {
146
188
  output[outputIndex] = indexToChar[x >> 2];
147
189
  outputIndex -= 1;
148
190
  }
149
- if (outputType === 'ArrayBuffer') {
150
- return output.buffer;
151
- }
152
- else {
153
- return outputLength;
154
- }
155
191
  }
156
192
  export function decodeBase64(input) {
157
193
  let padding;
@@ -176,9 +212,9 @@ export function decodeBase64(input) {
176
212
  sIndex += 1;
177
213
  const d = charToIndex[input[sIndex]];
178
214
  sIndex += 1;
179
- result[dIndex] = (a << 2) | ((b & 48) >> 4);
215
+ result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
180
216
  dIndex += 1;
181
- result[dIndex] = ((b & 0b1111) << 4) | ((c & 60) >> 2);
217
+ result[dIndex] = ((b & 0b1111) << 4) | ((c & 0b11_1100) >> 2);
182
218
  dIndex += 1;
183
219
  result[dIndex] = ((c & 0b11) << 6) | d;
184
220
  dIndex += 1;
@@ -189,16 +225,16 @@ export function decodeBase64(input) {
189
225
  const b = charToIndex[input[sIndex]];
190
226
  sIndex += 1;
191
227
  const c = charToIndex[input[sIndex]];
192
- result[dIndex] = (a << 2) | ((b & 48) >> 4);
228
+ result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
193
229
  dIndex += 1;
194
- result[dIndex] = ((b & 0b1111) << 4) | ((c & 60) >> 2);
230
+ result[dIndex] = ((b & 0b1111) << 4) | ((c & 0b11_1100) >> 2);
195
231
  }
196
232
  else if (padding === 2) {
197
233
  const a = charToIndex[input[sIndex]];
198
234
  sIndex += 1;
199
235
  const b = charToIndex[input[sIndex]];
200
- result[dIndex] = (a << 2) | ((b & 48) >> 4);
236
+ result[dIndex] = (a << 2) | ((b & 0b11_0000) >> 4);
201
237
  }
202
- return result.buffer;
238
+ return result;
203
239
  }
204
240
  //# sourceMappingURL=base64.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/utils/base64.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,MAAM,WAAW,GAA2B,EAAE,CAAC;AAC/C,MAAM,WAAW,GAAa,EAAE,CAAC;AACjC,MAAM,WAAW,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IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function encodeUtf8(input: string): Uint8Array;
2
+ export declare function decodeUtf8(buffer: ArrayBufferView | ArrayBuffer): string;
3
+ //# sourceMappingURL=encoding.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAErD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAEtD"}
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AAMA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,GAAG,MAAM,CAExE"}
@@ -3,7 +3,7 @@ const Utf8Encoder = new TextEncoder();
3
3
  // @ts-expect-error @types/node missing `TextDecoder`
4
4
  const Utf8Decoder = new TextDecoder();
5
5
  export function encodeUtf8(input) {
6
- return Utf8Encoder.encode(input).buffer;
6
+ return Utf8Encoder.encode(input);
7
7
  }
8
8
  export function decodeUtf8(buffer) {
9
9
  return Utf8Decoder.decode(buffer);
@@ -1 +1 @@
1
- {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AACA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAmB;IAC1C,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
1
+ {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../src/utils/encoding.ts"],"names":[],"mappings":"AACA,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,qDAAqD;AACrD,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AAEtC,MAAM,UAAU,UAAU,CAAC,KAAa;IACpC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAqC;IAC5D,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './auto-reset-event.js';
2
+ export * from './base64.js';
3
+ export * from './encoding.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
@@ -1,6 +1,4 @@
1
- export * from './auto-reset-event';
2
- export * from './base64';
3
- export * from './chunk';
4
- export * from './encoding';
5
- export * from './event-queue';
1
+ export * from './auto-reset-event.js';
2
+ export * from './base64.js';
3
+ export * from './encoding.js';
6
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,44 +1,50 @@
1
- {
2
- "name": "@yume-chan/adb",
3
- "version": "0.0.10",
4
- "description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
5
- "keywords": [
6
- "adb",
7
- "android-phone"
8
- ],
9
- "license": "MIT",
10
- "author": {
11
- "name": "Simon Chan",
12
- "email": "cnsimonchan@live.com",
13
- "url": "https://chensi.moe/blog"
14
- },
15
- "homepage": "https://github.com/yume-chan/ya-webadb/tree/master/libraries/adb#readme",
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/yume-chan/ya-webadb.git",
19
- "directory": "libraries/adb"
20
- },
21
- "bugs": {
22
- "url": "https://github.com/yume-chan/ya-webadb/issues"
23
- },
24
- "type": "module",
25
- "module": "esm/index.js",
26
- "types": "dts/index.d.ts",
27
- "scripts": {
28
- "build": "build-ts-package",
29
- "build:watch": "build-ts-package --incremental",
30
- "test": "jest --coverage",
31
- "prepublishOnly": "npm run build"
32
- },
33
- "dependencies": {
34
- "@yume-chan/async": "^2.1.4",
35
- "@yume-chan/event": "^0.0.10",
36
- "@yume-chan/struct": "^0.0.10",
37
- "tslib": "^2.3.1"
38
- },
39
- "devDependencies": {
40
- "jest": "^26.6.3",
41
- "typescript": "^4.5.4",
42
- "@yume-chan/ts-package-builder": "^1.0.0"
43
- }
44
- }
1
+ {
2
+ "name": "@yume-chan/adb",
3
+ "version": "0.0.11",
4
+ "description": "TypeScript implementation of Android Debug Bridge (ADB) protocol.",
5
+ "keywords": [
6
+ "adb",
7
+ "android-phone"
8
+ ],
9
+ "license": "MIT",
10
+ "author": {
11
+ "name": "Simon Chan",
12
+ "email": "cnsimonchan@live.com",
13
+ "url": "https://chensi.moe/blog"
14
+ },
15
+ "homepage": "https://github.com/yume-chan/ya-webadb/tree/master/libraries/adb#readme",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/yume-chan/ya-webadb.git",
19
+ "directory": "libraries/adb"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/yume-chan/ya-webadb/issues"
23
+ },
24
+ "type": "module",
25
+ "main": "esm/index.js",
26
+ "types": "esm/index.d.ts",
27
+ "dependencies": {
28
+ "@yume-chan/async": "^2.1.4",
29
+ "@yume-chan/dataview-bigint-polyfill": "0.0.10",
30
+ "@yume-chan/event": "^0.0.10",
31
+ "@yume-chan/struct": "^0.0.10",
32
+ "tslib": "^2.3.1",
33
+ "web-streams-polyfill": "^3.2.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^17.0.17",
37
+ "@types/jest": "^27.4.1",
38
+ "@yume-chan/ts-package-builder": "^1.0.0",
39
+ "cross-env": "^7.0.3",
40
+ "jest": "^27.5.1",
41
+ "ts-jest": "^27.1.3",
42
+ "typescript": "next"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -b tsconfig.build.json",
46
+ "build:watch": "tsc -b tsconfig.build.json",
47
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
48
+ },
49
+ "readme": "# @yume-chan/adb\r\n\r\nTypeScript implementation of Android Debug Bridge (ADB) protocol.\r\n\r\n**WARNING:** The public API is UNSTABLE. If you have any questions, please open an issue.\r\n\r\n- [Compatibility](#compatibility)\r\n - [Basic usage](#basic-usage)\r\n - [Use without bundlers](#use-without-bundlers)\r\n- [Connection](#connection)\r\n - [Backend](#backend)\r\n - [`connect`](#connect)\r\n- [Authentication](#authentication)\r\n - [AdbCredentialStore](#adbcredentialstore)\r\n - [`generateKey`](#generatekey)\r\n - [`iterateKeys`](#iteratekeys)\r\n - [Implementations](#implementations)\r\n - [AdbAuthenticator](#adbauthenticator)\r\n - [`authenticate`](#authenticate)\r\n- [Stream multiplex](#stream-multiplex)\r\n - [Backend](#backend-1)\r\n- [Commands](#commands)\r\n - [childProcess](#childprocess)\r\n - [usb](#usb)\r\n - [tcpip](#tcpip)\r\n - [sync](#sync)\r\n - [LIST](#list)\r\n - [LIS2](#lis2)\r\n - [STAT](#stat)\r\n - [LST2](#lst2)\r\n - [STA2](#sta2)\r\n - [RECV](#recv)\r\n - [RCV2](#rcv2)\r\n - [SEND](#send)\r\n - [SND2](#snd2)\r\n- [Useful links](#useful-links)\r\n\r\n## Compatibility\r\n\r\nHere is a list of features, their used APIs, and their compatibilities. If an optional feature is not actually used, its requirements can be ignored.\r\n\r\nSome features can be polyfilled to support older runtimes, but this library doesn't ship with any polyfills.\r\n\r\nEach backend may have different requirements.\r\n\r\n### Basic usage\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| ------------------------------- | ------ | ---- | ------- | ----------------- | ------ | ------------------- |\r\n| `@yume-chan/struct`<sup>1</sup> | 67 | 79 | 68 | No | 14 | 8.3<sup>2</sup>, 11 |\r\n| [Streams][MDN_Streams] | 67 | 79 | No | No | 14.1 | 16.5 |\r\n| *Overall* | 67 | 79 | No | No | 14.1 | 16.5 |\r\n\r\n<sup>1</sup> `uint64` and `string` used.\r\n\r\n<sup>2</sup> `TextEncoder` and `TextDecoder` are only available in `util` module. Need to be assigned to `globalThis`.\r\n\r\n### Use without bundlers\r\n\r\n| | Chrome | Edge | Firefox | Internet Explorer | Safari | Node.js |\r\n| --------------- | ------ | ---- | ------- | ----------------- | ------ | ------- |\r\n| Top-level await | 89 | 89 | 89 | No | 15 | 14.8 |\r\n\r\n[MDN_Streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API\r\n\r\n## Connection\r\n\r\nThis library doesn't tie to a specific transportation method.\r\n\r\nInstead, a `Backend` is responsible for transferring data in its own way (USB, WebSocket, TCP, etc).\r\n\r\n### Backend\r\n\r\n#### `connect`\r\n\r\n```ts\r\nconnect(): ValueOrPromise<ReadableWritablePair<AdbPacketCore, AdbPacketInit>>\r\n```\r\n\r\nConnect to a device and create a pair of `AdbPacket` streams.\r\n\r\nThe backend is responsible for serializing and deserializing the packets, because it's extreme slow for WebUSB backend (`@yume-chan/adb-backend-webusb`) to read packets with unknown size.\r\n\r\n## Authentication\r\n\r\nFor how does ADB authentication work, see https://chensi.moe/blog/2020/09/30/webadb-part2-connection/#auth.\r\n\r\nIn this library, authentication comes in two parts:\r\n\r\n#### AdbCredentialStore\r\n\r\nAn interface to generate, store and iterate ADB private keys on each runtime. (Because Node.js and Browsers have different APIs to do this)\r\n\r\n##### `generateKey`\r\n\r\n```ts\r\ngenerateKey(): ValueOrPromise<Uint8Array>\r\n```\r\n\r\nGenerate and store a RSA private key with modulus length `2048` and public exponent `65537`.\r\n\r\nThe returned `Uint8Array` is the private key in PKCS #8 format.\r\n\r\n##### `iterateKeys`\r\n\r\n```ts\r\niterateKeys(): Iterator<ArrayBuffer> | AsyncIterator<ArrayBuffer>\r\n```\r\n\r\nSynchronously or asynchronously iterate through all stored RSA private keys.\r\n\r\nEach call to `iterateKeys` must return a different iterator that iterate through all stored keys.\r\n\r\n##### Implementations\r\n\r\nThe `@yume-chan/adb-credential-web` package contains a `AdbWebCredentialStore` implementation using Web Crypto API for generating keys and Web Storage API for storing keys.\r\n\r\n#### AdbAuthenticator\r\n\r\nAn `AdbAuthenticator` generates `AUTH` responses for each `AUTH` request from server.\r\n\r\nThis package contains `AdbSignatureAuthenticator` and `AdbPublicKeyAuthenticator`, the two basic modes.\r\n\r\n#### `authenticate`\r\n\r\n```ts\r\nstatic async authenticate(\r\n connection: ReadableWritablePair<AdbPacketCore, AdbPacketCore>,\r\n credentialStore: AdbCredentialStore,\r\n authenticators = AdbDefaultAuthenticators,\r\n): Promise<Adb>\r\n```\r\n\r\nCall this method to authenticate the connection and create an `Adb` instance.\r\n\r\nIt's possible to call `authenticate` multiple times on a single connection, every time the device receives a `CNXN` packet, it resets its internal state, and starts a new authentication process.\r\n\r\n## Stream multiplex\r\n\r\nADB commands are all based on streams. Multiple streams can send and receive at the same time in one connection.\r\n\r\n1. Client sends an `OPEN` packet to create a stream.\r\n2. Server responds with `OKAY` or `FAIL`.\r\n3. Client and server read/write on the stream.\r\n4. Client/server sends a `CLSE` to close the stream.\r\n\r\nThe `Backend` is responsible for reading and writing data from underlying source.\r\n\r\n### Backend\r\n\r\n## Commands\r\n\r\n### childProcess\r\n\r\nSpawns child process on server. ADB has two shell modes:\r\n\r\n| | Legacy mode | Shell Protocol |\r\n| --------------------------- | --------------------------- | ---------------------------- |\r\n| Feature flag | - | `shell_v2` |\r\n| Implementation | `AdbNoneSubprocessProtocol` | `AdbShellSubprocessProtocol` |\r\n| Splitting stdout and stderr | No | Yes |\r\n| Returning exit code | No | Yes |\r\n| Resizing window | No | Yes |\r\n\r\nThe `Adb#childProcess#shell` and `Adb#childProcess#spawn` methods accepts a list of implementations, and will use the first supported one.\r\n\r\nFor simple command invocation, usually the `AdbNoneSubprocessProtocol` is enough.\r\n\r\n### usb\r\n\r\nDisable ADB over WiFi.\r\n\r\n### tcpip\r\n\r\nEnable ADB over WiFi.\r\n\r\n### sync\r\n\r\nClient and server will communicate with another protocol on the opened stream.\r\n\r\n#### LIST\r\n\r\nRequest server to list the content of a folder.\r\n\r\n#### LIS2\r\n\r\nVersion 2 of the LIST command, contains more information.\r\n\r\nSupported on devices with `ls_v2` feature.\r\n\r\n#### STAT\r\n\r\nRequest server to return the information of a file.\r\n\r\nIf path is a symbolic link, the returned information is about the link itself.\r\n\r\nSo it's actually the [`lstat`](https://linux.die.net/man/2/lstat) system call.\r\n\r\n#### LST2\r\n\r\nVersion 2 of the STAT command, contains more information.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### STA2\r\n\r\nBasically identical to LST2, but if path is a symbolic link, the information is about the file it refers to.\r\n\r\nSupported on devices with `stat_v2` feature.\r\n\r\n#### RECV\r\n\r\nRequest server to send the content of a file.\r\n\r\n#### RCV2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the RECV command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n#### SEND\r\n\r\n*(Not Implemented)*\r\n\r\nSend a file onto server's file system.\r\n\r\n#### SND2\r\n\r\n*(Not Implemented)*\r\n\r\nVersion 2 of the SEND command.\r\n\r\nSupported on devices with `sendrecv_v2` feature.\r\n\r\n## Useful links\r\n\r\n* [ADB protocol overview](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/OVERVIEW.TXT)\r\n* [ADB commands](https://android.googlesource.com/platform/packages/modules/adb/+/2fd69306184634c6d90db3ed3be5349e71dcc471/SERVICES.TXT#145)\r\n"
50
+ }