@honeybbq/teamspeak 0.0.1 → 1.0.0-beta.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 (393) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +726 -2
  3. package/dist/client/abort.d.ts +5 -0
  4. package/dist/client/abort.d.ts.map +1 -0
  5. package/dist/client/abort.js +23 -0
  6. package/dist/client/abort.js.map +1 -0
  7. package/dist/client/address.d.ts +17 -0
  8. package/dist/client/address.d.ts.map +1 -0
  9. package/dist/client/address.js +66 -0
  10. package/dist/client/address.js.map +1 -0
  11. package/dist/client/api/voice.d.ts +24 -0
  12. package/dist/client/api/voice.d.ts.map +1 -0
  13. package/dist/client/api/voice.js +33 -0
  14. package/dist/client/api/voice.js.map +1 -0
  15. package/dist/client/capabilities.d.ts +68 -0
  16. package/dist/client/capabilities.d.ts.map +1 -0
  17. package/dist/client/capabilities.js +59 -0
  18. package/dist/client/capabilities.js.map +1 -0
  19. package/dist/client/client.d.ts +196 -0
  20. package/dist/client/client.d.ts.map +1 -0
  21. package/dist/client/client.js +1523 -0
  22. package/dist/client/client.js.map +1 -0
  23. package/dist/client/commands.d.ts +66 -0
  24. package/dist/client/commands.d.ts.map +1 -0
  25. package/dist/client/commands.js +162 -0
  26. package/dist/client/commands.js.map +1 -0
  27. package/dist/client/crypto/crypt-ops.d.ts +7 -0
  28. package/dist/client/crypto/crypt-ops.d.ts.map +1 -0
  29. package/dist/client/crypto/crypt-ops.js +2 -0
  30. package/dist/client/crypto/crypt-ops.js.map +1 -0
  31. package/dist/client/crypto/crypt.d.ts +37 -0
  32. package/dist/client/crypto/crypt.d.ts.map +1 -0
  33. package/dist/client/crypto/crypt.js +203 -0
  34. package/dist/client/crypto/crypt.js.map +1 -0
  35. package/dist/client/crypto/eax.d.ts +12 -0
  36. package/dist/client/crypto/eax.d.ts.map +1 -0
  37. package/dist/client/crypto/eax.js +118 -0
  38. package/dist/client/crypto/eax.js.map +1 -0
  39. package/dist/client/crypto/identity.d.ts +97 -0
  40. package/dist/client/crypto/identity.d.ts.map +1 -0
  41. package/dist/client/crypto/identity.js +412 -0
  42. package/dist/client/crypto/identity.js.map +1 -0
  43. package/dist/client/crypto/index.d.ts +7 -0
  44. package/dist/client/crypto/index.d.ts.map +1 -0
  45. package/dist/client/crypto/index.js +5 -0
  46. package/dist/client/crypto/index.js.map +1 -0
  47. package/dist/client/crypto/primitives.d.ts +43 -0
  48. package/dist/client/crypto/primitives.d.ts.map +1 -0
  49. package/dist/client/crypto/primitives.js +116 -0
  50. package/dist/client/crypto/primitives.js.map +1 -0
  51. package/dist/client/diagnostics.d.ts +45 -0
  52. package/dist/client/diagnostics.d.ts.map +1 -0
  53. package/dist/client/diagnostics.js +30 -0
  54. package/dist/client/diagnostics.js.map +1 -0
  55. package/dist/client/discovery/index.d.ts +2 -0
  56. package/dist/client/discovery/index.d.ts.map +1 -0
  57. package/dist/client/discovery/index.js +2 -0
  58. package/dist/client/discovery/index.js.map +1 -0
  59. package/dist/client/discovery/resolver.d.ts +26 -0
  60. package/dist/client/discovery/resolver.d.ts.map +1 -0
  61. package/dist/client/discovery/resolver.js +275 -0
  62. package/dist/client/discovery/resolver.js.map +1 -0
  63. package/dist/client/errors.d.ts +82 -0
  64. package/dist/client/errors.d.ts.map +1 -0
  65. package/dist/client/errors.js +201 -0
  66. package/dist/client/errors.js.map +1 -0
  67. package/dist/client/events.d.ts +3 -0
  68. package/dist/client/events.d.ts.map +1 -0
  69. package/dist/client/events.js +8 -0
  70. package/dist/client/events.js.map +1 -0
  71. package/dist/client/handshake/crypt-handshake.d.ts +17 -0
  72. package/dist/client/handshake/crypt-handshake.d.ts.map +1 -0
  73. package/dist/client/handshake/crypt-handshake.js +128 -0
  74. package/dist/client/handshake/crypt-handshake.js.map +1 -0
  75. package/dist/client/handshake/crypt-init2.d.ts +7 -0
  76. package/dist/client/handshake/crypt-init2.d.ts.map +1 -0
  77. package/dist/client/handshake/crypt-init2.js +37 -0
  78. package/dist/client/handshake/crypt-init2.js.map +1 -0
  79. package/dist/client/handshake/index.d.ts +4 -0
  80. package/dist/client/handshake/index.d.ts.map +1 -0
  81. package/dist/client/handshake/index.js +4 -0
  82. package/dist/client/handshake/index.js.map +1 -0
  83. package/dist/client/handshake/license.d.ts +35 -0
  84. package/dist/client/handshake/license.d.ts.map +1 -0
  85. package/dist/client/handshake/license.js +169 -0
  86. package/dist/client/handshake/license.js.map +1 -0
  87. package/dist/client/handshake.d.ts +27 -0
  88. package/dist/client/handshake.d.ts.map +1 -0
  89. package/dist/client/handshake.js +126 -0
  90. package/dist/client/handshake.js.map +1 -0
  91. package/dist/client/helpers.d.ts +6 -0
  92. package/dist/client/helpers.d.ts.map +1 -0
  93. package/dist/client/helpers.js +13 -0
  94. package/dist/client/helpers.js.map +1 -0
  95. package/dist/client/hooks.d.ts +7 -0
  96. package/dist/client/hooks.d.ts.map +1 -0
  97. package/dist/client/hooks.js +28 -0
  98. package/dist/client/hooks.js.map +1 -0
  99. package/dist/client/index.d.ts +26 -0
  100. package/dist/client/index.d.ts.map +1 -0
  101. package/dist/client/index.js +28 -0
  102. package/dist/client/index.js.map +1 -0
  103. package/dist/client/reconnect.d.ts +12 -0
  104. package/dist/client/reconnect.d.ts.map +1 -0
  105. package/dist/client/reconnect.js +44 -0
  106. package/dist/client/reconnect.js.map +1 -0
  107. package/dist/client/throttle.d.ts +20 -0
  108. package/dist/client/throttle.d.ts.map +1 -0
  109. package/dist/client/throttle.js +83 -0
  110. package/dist/client/throttle.js.map +1 -0
  111. package/dist/client/trace.d.ts +223 -0
  112. package/dist/client/trace.d.ts.map +1 -0
  113. package/dist/client/trace.js +13 -0
  114. package/dist/client/trace.js.map +1 -0
  115. package/dist/client/transfer.d.ts +111 -0
  116. package/dist/client/transfer.d.ts.map +1 -0
  117. package/dist/client/transfer.js +243 -0
  118. package/dist/client/transfer.js.map +1 -0
  119. package/dist/client/transport/generation-window.d.ts +30 -0
  120. package/dist/client/transport/generation-window.d.ts.map +1 -0
  121. package/dist/client/transport/generation-window.js +97 -0
  122. package/dist/client/transport/generation-window.js.map +1 -0
  123. package/dist/client/transport/handler.d.ts +61 -0
  124. package/dist/client/transport/handler.d.ts.map +1 -0
  125. package/dist/client/transport/handler.js +793 -0
  126. package/dist/client/transport/handler.js.map +1 -0
  127. package/dist/client/transport/index.d.ts +6 -0
  128. package/dist/client/transport/index.d.ts.map +1 -0
  129. package/dist/client/transport/index.js +5 -0
  130. package/dist/client/transport/index.js.map +1 -0
  131. package/dist/client/transport/packet.d.ts +36 -0
  132. package/dist/client/transport/packet.d.ts.map +1 -0
  133. package/dist/client/transport/packet.js +55 -0
  134. package/dist/client/transport/packet.js.map +1 -0
  135. package/dist/client/transport/quicklz.d.ts +24 -0
  136. package/dist/client/transport/quicklz.d.ts.map +1 -0
  137. package/dist/client/transport/quicklz.js +179 -0
  138. package/dist/client/transport/quicklz.js.map +1 -0
  139. package/dist/client/types.d.ts +226 -0
  140. package/dist/client/types.d.ts.map +1 -0
  141. package/dist/client/types.js +39 -0
  142. package/dist/client/types.js.map +1 -0
  143. package/dist/core/api/channels.d.ts +182 -0
  144. package/dist/core/api/channels.d.ts.map +1 -0
  145. package/dist/core/api/channels.js +155 -0
  146. package/dist/core/api/channels.js.map +1 -0
  147. package/dist/core/api/clients.d.ts +304 -0
  148. package/dist/core/api/clients.d.ts.map +1 -0
  149. package/dist/core/api/clients.js +260 -0
  150. package/dist/core/api/clients.js.map +1 -0
  151. package/dist/core/api/command.d.ts +305 -0
  152. package/dist/core/api/command.d.ts.map +1 -0
  153. package/dist/core/api/command.js +363 -0
  154. package/dist/core/api/command.js.map +1 -0
  155. package/dist/core/api/files.d.ts +153 -0
  156. package/dist/core/api/files.d.ts.map +1 -0
  157. package/dist/core/api/files.js +181 -0
  158. package/dist/core/api/files.js.map +1 -0
  159. package/dist/core/api/groups.d.ts +248 -0
  160. package/dist/core/api/groups.d.ts.map +1 -0
  161. package/dist/core/api/groups.js +271 -0
  162. package/dist/core/api/groups.js.map +1 -0
  163. package/dist/core/api/moderation.d.ts +205 -0
  164. package/dist/core/api/moderation.d.ts.map +1 -0
  165. package/dist/core/api/moderation.js +209 -0
  166. package/dist/core/api/moderation.js.map +1 -0
  167. package/dist/core/api/parse.d.ts +16 -0
  168. package/dist/core/api/parse.d.ts.map +1 -0
  169. package/dist/core/api/parse.js +40 -0
  170. package/dist/core/api/parse.js.map +1 -0
  171. package/dist/core/api/server.d.ts +310 -0
  172. package/dist/core/api/server.d.ts.map +1 -0
  173. package/dist/core/api/server.js +290 -0
  174. package/dist/core/api/server.js.map +1 -0
  175. package/dist/core/command/command.d.ts +20 -0
  176. package/dist/core/command/command.d.ts.map +1 -0
  177. package/dist/core/command/command.js +112 -0
  178. package/dist/core/command/command.js.map +1 -0
  179. package/dist/core/command/ids.d.ts +125 -0
  180. package/dist/core/command/ids.d.ts.map +1 -0
  181. package/dist/core/command/ids.js +85 -0
  182. package/dist/core/command/ids.js.map +1 -0
  183. package/dist/core/command/parser.d.ts +17 -0
  184. package/dist/core/command/parser.d.ts.map +1 -0
  185. package/dist/core/command/parser.js +65 -0
  186. package/dist/core/command/parser.js.map +1 -0
  187. package/dist/core/command/request.d.ts +61 -0
  188. package/dist/core/command/request.d.ts.map +1 -0
  189. package/dist/core/command/request.js +64 -0
  190. package/dist/core/command/request.js.map +1 -0
  191. package/dist/core/command/responses.d.ts +59 -0
  192. package/dist/core/command/responses.d.ts.map +1 -0
  193. package/dist/core/command/responses.js +74 -0
  194. package/dist/core/command/responses.js.map +1 -0
  195. package/dist/core/command-name.d.ts +333 -0
  196. package/dist/core/command-name.d.ts.map +1 -0
  197. package/dist/core/command-name.js +331 -0
  198. package/dist/core/command-name.js.map +1 -0
  199. package/dist/core/enums.d.ts +146 -0
  200. package/dist/core/enums.d.ts.map +1 -0
  201. package/dist/core/enums.js +132 -0
  202. package/dist/core/enums.js.map +1 -0
  203. package/dist/core/errorcode.d.ts +413 -0
  204. package/dist/core/errorcode.d.ts.map +1 -0
  205. package/dist/core/errorcode.js +410 -0
  206. package/dist/core/errorcode.js.map +1 -0
  207. package/dist/core/errors.d.ts +111 -0
  208. package/dist/core/errors.d.ts.map +1 -0
  209. package/dist/core/errors.js +233 -0
  210. package/dist/core/errors.js.map +1 -0
  211. package/dist/core/events.d.ts +207 -0
  212. package/dist/core/events.d.ts.map +1 -0
  213. package/dist/core/events.js +6 -0
  214. package/dist/core/events.js.map +1 -0
  215. package/dist/core/helpers.d.ts +42 -0
  216. package/dist/core/helpers.d.ts.map +1 -0
  217. package/dist/core/helpers.js +156 -0
  218. package/dist/core/helpers.js.map +1 -0
  219. package/dist/core/index.d.ts +35 -0
  220. package/dist/core/index.d.ts.map +1 -0
  221. package/dist/core/index.js +34 -0
  222. package/dist/core/index.js.map +1 -0
  223. package/dist/core/internal.d.ts +23 -0
  224. package/dist/core/internal.d.ts.map +1 -0
  225. package/dist/core/internal.js +20 -0
  226. package/dist/core/internal.js.map +1 -0
  227. package/dist/core/middleware.d.ts +14 -0
  228. package/dist/core/middleware.d.ts.map +1 -0
  229. package/dist/core/middleware.js +18 -0
  230. package/dist/core/middleware.js.map +1 -0
  231. package/dist/core/notification-name.d.ts +154 -0
  232. package/dist/core/notification-name.d.ts.map +1 -0
  233. package/dist/core/notification-name.js +152 -0
  234. package/dist/core/notification-name.js.map +1 -0
  235. package/dist/core/notifications.d.ts +43 -0
  236. package/dist/core/notifications.d.ts.map +1 -0
  237. package/dist/core/notifications.js +116 -0
  238. package/dist/core/notifications.js.map +1 -0
  239. package/dist/core/permission-name.d.ts +533 -0
  240. package/dist/core/permission-name.d.ts.map +1 -0
  241. package/dist/core/permission-name.js +531 -0
  242. package/dist/core/permission-name.js.map +1 -0
  243. package/dist/core/permission.d.ts +31 -0
  244. package/dist/core/permission.d.ts.map +1 -0
  245. package/dist/core/permission.js +20 -0
  246. package/dist/core/permission.js.map +1 -0
  247. package/dist/core/property-name.d.ts +403 -0
  248. package/dist/core/property-name.d.ts.map +1 -0
  249. package/dist/core/property-name.js +405 -0
  250. package/dist/core/property-name.js.map +1 -0
  251. package/dist/core/reason.d.ts +39 -0
  252. package/dist/core/reason.d.ts.map +1 -0
  253. package/dist/core/reason.js +36 -0
  254. package/dist/core/reason.js.map +1 -0
  255. package/dist/core/reconnect.d.ts +59 -0
  256. package/dist/core/reconnect.d.ts.map +1 -0
  257. package/dist/core/reconnect.js +55 -0
  258. package/dist/core/reconnect.js.map +1 -0
  259. package/dist/core/types.d.ts +110 -0
  260. package/dist/core/types.d.ts.map +1 -0
  261. package/dist/core/types.js +27 -0
  262. package/dist/core/types.js.map +1 -0
  263. package/dist/query/client.d.ts +194 -0
  264. package/dist/query/client.d.ts.map +1 -0
  265. package/dist/query/client.js +967 -0
  266. package/dist/query/client.js.map +1 -0
  267. package/dist/query/errors.d.ts +61 -0
  268. package/dist/query/errors.d.ts.map +1 -0
  269. package/dist/query/errors.js +100 -0
  270. package/dist/query/errors.js.map +1 -0
  271. package/dist/query/index.d.ts +36 -0
  272. package/dist/query/index.d.ts.map +1 -0
  273. package/dist/query/index.js +34 -0
  274. package/dist/query/index.js.map +1 -0
  275. package/dist/query/knownhosts.d.ts +61 -0
  276. package/dist/query/knownhosts.d.ts.map +1 -0
  277. package/dist/query/knownhosts.js +223 -0
  278. package/dist/query/knownhosts.js.map +1 -0
  279. package/dist/query/lines.d.ts +14 -0
  280. package/dist/query/lines.d.ts.map +1 -0
  281. package/dist/query/lines.js +29 -0
  282. package/dist/query/lines.js.map +1 -0
  283. package/dist/query/options.d.ts +187 -0
  284. package/dist/query/options.d.ts.map +1 -0
  285. package/dist/query/options.js +213 -0
  286. package/dist/query/options.js.map +1 -0
  287. package/dist/query/reconnect.d.ts +29 -0
  288. package/dist/query/reconnect.d.ts.map +1 -0
  289. package/dist/query/reconnect.js +87 -0
  290. package/dist/query/reconnect.js.map +1 -0
  291. package/dist/query/ssh.d.ts +345 -0
  292. package/dist/query/ssh.d.ts.map +1 -0
  293. package/dist/query/ssh.js +241 -0
  294. package/dist/query/ssh.js.map +1 -0
  295. package/dist/query/stream.d.ts +38 -0
  296. package/dist/query/stream.d.ts.map +1 -0
  297. package/dist/query/stream.js +70 -0
  298. package/dist/query/stream.js.map +1 -0
  299. package/dist/query/tcp.d.ts +38 -0
  300. package/dist/query/tcp.d.ts.map +1 -0
  301. package/dist/query/tcp.js +53 -0
  302. package/dist/query/tcp.js.map +1 -0
  303. package/dist/query/transport.d.ts +36 -0
  304. package/dist/query/transport.d.ts.map +1 -0
  305. package/dist/query/transport.js +2 -0
  306. package/dist/query/transport.js.map +1 -0
  307. package/dist/query/web.d.ts +54 -0
  308. package/dist/query/web.d.ts.map +1 -0
  309. package/dist/query/web.js +146 -0
  310. package/dist/query/web.js.map +1 -0
  311. package/dist/versions/index.d.ts +3094 -0
  312. package/dist/versions/index.d.ts.map +1 -0
  313. package/dist/versions/index.js +9237 -0
  314. package/dist/versions/index.js.map +1 -0
  315. package/package.json +118 -4
  316. package/src/client/abort.ts +24 -0
  317. package/src/client/address.ts +74 -0
  318. package/src/client/api/voice.ts +61 -0
  319. package/src/client/capabilities.ts +106 -0
  320. package/src/client/client.ts +1809 -0
  321. package/src/client/commands.ts +193 -0
  322. package/src/client/crypto/crypt-ops.ts +6 -0
  323. package/src/client/crypto/crypt.ts +275 -0
  324. package/src/client/crypto/eax.ts +152 -0
  325. package/src/client/crypto/identity.ts +484 -0
  326. package/src/client/crypto/index.ts +21 -0
  327. package/src/client/crypto/primitives.ts +141 -0
  328. package/src/client/diagnostics.ts +58 -0
  329. package/src/client/discovery/index.ts +1 -0
  330. package/src/client/discovery/resolver.ts +325 -0
  331. package/src/client/errors.ts +217 -0
  332. package/src/client/events.ts +12 -0
  333. package/src/client/handshake/crypt-handshake.ts +157 -0
  334. package/src/client/handshake/crypt-init2.ts +48 -0
  335. package/src/client/handshake/index.ts +3 -0
  336. package/src/client/handshake/license.ts +208 -0
  337. package/src/client/handshake.ts +150 -0
  338. package/src/client/helpers.ts +10 -0
  339. package/src/client/hooks.ts +30 -0
  340. package/src/client/index.ts +93 -0
  341. package/src/client/reconnect.ts +43 -0
  342. package/src/client/throttle.ts +92 -0
  343. package/src/client/trace.ts +237 -0
  344. package/src/client/transfer.ts +436 -0
  345. package/src/client/transport/generation-window.ts +108 -0
  346. package/src/client/transport/handler.ts +926 -0
  347. package/src/client/transport/index.ts +14 -0
  348. package/src/client/transport/packet.ts +69 -0
  349. package/src/client/transport/quicklz.ts +209 -0
  350. package/src/client/types.ts +268 -0
  351. package/src/core/api/channels.ts +396 -0
  352. package/src/core/api/clients.ts +654 -0
  353. package/src/core/api/command.ts +563 -0
  354. package/src/core/api/files.ts +405 -0
  355. package/src/core/api/groups.ts +622 -0
  356. package/src/core/api/moderation.ts +525 -0
  357. package/src/core/api/parse.ts +52 -0
  358. package/src/core/api/server.ts +709 -0
  359. package/src/core/command/command.ts +125 -0
  360. package/src/core/command/ids.ts +149 -0
  361. package/src/core/command/parser.ts +68 -0
  362. package/src/core/command/request.ts +119 -0
  363. package/src/core/command/responses.ts +114 -0
  364. package/src/core/command-name.ts +334 -0
  365. package/src/core/enums.ts +167 -0
  366. package/src/core/errorcode.ts +412 -0
  367. package/src/core/errors.ts +258 -0
  368. package/src/core/events.ts +219 -0
  369. package/src/core/helpers.ts +161 -0
  370. package/src/core/index.ts +126 -0
  371. package/src/core/internal.ts +23 -0
  372. package/src/core/middleware.ts +24 -0
  373. package/src/core/notification-name.ts +155 -0
  374. package/src/core/notifications.ts +157 -0
  375. package/src/core/permission-name.ts +538 -0
  376. package/src/core/permission.ts +34 -0
  377. package/src/core/property-name.ts +411 -0
  378. package/src/core/reason.ts +38 -0
  379. package/src/core/reconnect.ts +98 -0
  380. package/src/core/types.ts +138 -0
  381. package/src/query/client.ts +1132 -0
  382. package/src/query/errors.ts +108 -0
  383. package/src/query/index.ts +65 -0
  384. package/src/query/knownhosts.ts +257 -0
  385. package/src/query/lines.ts +28 -0
  386. package/src/query/options.ts +388 -0
  387. package/src/query/reconnect.ts +84 -0
  388. package/src/query/ssh.ts +614 -0
  389. package/src/query/stream.ts +91 -0
  390. package/src/query/tcp.ts +85 -0
  391. package/src/query/transport.ts +35 -0
  392. package/src/query/web.ts +195 -0
  393. package/src/versions/index.ts +10774 -0
@@ -0,0 +1,219 @@
1
+ /**
2
+ * The events a TeamSpeak client receives from the server. Every kind of client
3
+ * shares these types.
4
+ */
5
+
6
+ import type { ChannelID, ClientID, ServerGroupID, UID } from "./command/ids.js";
7
+ import type { ClientEntry } from "./api/clients.js";
8
+ import type { NotificationName } from "./notification-name.js";
9
+
10
+ /** A text message, sent privately, to a channel, or to the whole server. */
11
+ export interface TextMessageEvent {
12
+ /** The sender's nickname. */
13
+ readonly invokerName: string;
14
+ /** The sender's unique identifier. */
15
+ readonly invokerUID: UID;
16
+ /** The message, unescaped. */
17
+ readonly message: string;
18
+ /**
19
+ * The sender's server groups. A text message does not carry them; they are
20
+ * those of the sender as the client knows it, so they are `undefined` for a
21
+ * sender the client has not seen.
22
+ */
23
+ readonly invokerGroups: readonly ServerGroupID[] | undefined;
24
+ /**
25
+ * Private, channel or server; compare it with `TextMessageTarget`. A plain
26
+ * number, since a server may send a mode that table does not name.
27
+ */
28
+ readonly targetMode: number;
29
+ /**
30
+ * The client a private message was sent to. Channel and server messages
31
+ * carry no target, so it is 0 for them.
32
+ */
33
+ readonly targetID: ClientID;
34
+ /** The sender. */
35
+ readonly invokerID: ClientID;
36
+ }
37
+
38
+ /** A client changing channel, of its own accord or moved by someone. */
39
+ export interface ClientMovedEvent {
40
+ /** Who moved the client; the client itself for a move of its own. */
41
+ readonly invokerName: string;
42
+ /** The mover's unique identifier. */
43
+ readonly invokerUID: UID;
44
+ /** The channel the client is now in. */
45
+ readonly targetChannelID: ChannelID;
46
+ /** Why the client moved; compare it with `Reason`. */
47
+ readonly reason: number;
48
+ /** The message that came with the move, such as a channel kick's reason; "" when none. */
49
+ readonly reasonMessage: string;
50
+ /** The client that moved. */
51
+ readonly clientID: ClientID;
52
+ /** The mover. */
53
+ readonly invokerID: ClientID;
54
+ }
55
+
56
+ /**
57
+ * A client going out of view: leaving the server, kicked or banned from it, or
58
+ * in a channel that stopped being subscribed.
59
+ */
60
+ export interface ClientLeaveEvent {
61
+ /** The reason given for a kick or a ban, or the client's own parting message. */
62
+ readonly reasonMessage: string;
63
+ /** Why the client left; compare it with `Reason`. */
64
+ readonly reason: number;
65
+ /** The client that left. */
66
+ readonly clientID: ClientID;
67
+ /** Who kicked or banned the client; empty otherwise. */
68
+ readonly invokerName: string;
69
+ /** The kicker's unique identifier; empty unless kicked or banned. */
70
+ readonly invokerUID: UID;
71
+ /** The kicker; 0 unless kicked or banned. */
72
+ readonly invokerID: ClientID;
73
+ }
74
+
75
+ /** This client being kicked from its channel or the server. */
76
+ export interface KickedEvent {
77
+ /** The reason the invoker gave. */
78
+ readonly reasonMessage: string;
79
+ /** `Reason.KickChannel`, `Reason.KickServer` or `Reason.KickServerBan`. */
80
+ readonly reason: number;
81
+ /** Who kicked this client. */
82
+ readonly invokerName: string;
83
+ /** The kicker's unique identifier. */
84
+ readonly invokerUID: UID;
85
+ /** The kicker. */
86
+ readonly invokerID: ClientID;
87
+ }
88
+
89
+ /**
90
+ * A client coming into view: the same record `listClients` returns, so one
91
+ * type describes a client however it was learned of; its own id is `id`, as
92
+ * in every record. The fields only `clientlist -times` reports are undefined
93
+ * here.
94
+ */
95
+ export type ClientEnterEvent = ClientEntry;
96
+
97
+ /** This client being poked. */
98
+ export interface PokeEvent {
99
+ /** Who poked. */
100
+ readonly invokerName: string;
101
+ /** The poker's unique identifier. */
102
+ readonly invokerUID: UID;
103
+ /** The poker. */
104
+ readonly invokerID: ClientID;
105
+ /** The poke's message, unescaped. */
106
+ readonly message: string;
107
+ }
108
+
109
+ /** Audio from another client, in the channel or whispered. */
110
+ export interface VoiceDataEvent {
111
+ /** Who is speaking. */
112
+ readonly clientID: ClientID;
113
+ /**
114
+ * How the audio is encoded; compare it with `Codec`. A plain number, since a
115
+ * server may relay a codec that table does not name.
116
+ */
117
+ readonly codec: number;
118
+ /** One encoded frame, copied: it stays valid after the listener returns. */
119
+ readonly data: Uint8Array;
120
+ }
121
+
122
+ /**
123
+ * A notification from the server, as it arrived: the escape hatch for one the
124
+ * SDK does not model, and for the ones it does. Match its `name` against
125
+ * `NotificationName`.
126
+ *
127
+ * This is the catch-all layer: the client delivers every notification as one
128
+ * of these, including the ones that also have a typed event of their own,
129
+ * which it delivers first. So a notification is never taken out of the
130
+ * catch-all by being given a typed event.
131
+ */
132
+ export interface NotificationEvent {
133
+ /** The notification's name, such as `notifyserveredited`; `NotificationName` lists the known ones. */
134
+ readonly name: NotificationName | (string & {});
135
+ /** Its parameters, unescaped. */
136
+ readonly params: Readonly<Record<string, string>>;
137
+ }
138
+
139
+ /** What `connected` delivers. */
140
+ export interface ConnectedEvent {
141
+ /**
142
+ * Whether the reconnect loop made this connection, rather than a call to
143
+ * `connect()`.
144
+ */
145
+ readonly reconnected: boolean;
146
+ }
147
+
148
+ /** What `disconnected` delivers. */
149
+ export interface DisconnectedEvent {
150
+ /**
151
+ * `undefined` after `disconnect()`, and the cause otherwise, such as a failed
152
+ * handshake, the connection timing out, or the client being removed.
153
+ */
154
+ readonly error: Error | undefined;
155
+ /**
156
+ * Whether the reconnect loop will try again, as of this event. False after
157
+ * `disconnect()`, without `reconnect` options, when `shouldRetry` refuses
158
+ * this cause, and once `backoff.maxAttempts` is spent. A `disconnect()` or a
159
+ * manual `connect()` while it waits can still end the loop.
160
+ */
161
+ readonly willReconnect: boolean;
162
+ }
163
+
164
+ /**
165
+ * The events a server sends, by name, that every kind of client delivers.
166
+ *
167
+ * These are the modelled events; `notification` carries every notification
168
+ * besides, after the event it produced. Gaining a key is an additive change,
169
+ * so a minor release may add one; none is ever removed in a minor.
170
+ */
171
+ export interface ServerEventMap {
172
+ /** A text message to this client, its channel or the server. */
173
+ textMessage: TextMessageEvent;
174
+ /** A client coming into view, including every client already there on connecting. */
175
+ clientEnter: ClientEnterEvent;
176
+ /** A client going out of view. */
177
+ clientLeave: ClientLeaveEvent;
178
+ /** A client changing channel. */
179
+ clientMoved: ClientMovedEvent;
180
+ /**
181
+ * Every notification the server sends, modelled or not, after any event it
182
+ * produces. A notification with an event of its own still arrives here: this
183
+ * is the catch-all layer, so the typed event is delivered alongside it, never
184
+ * instead of it.
185
+ */
186
+ notification: NotificationEvent;
187
+ }
188
+
189
+ /**
190
+ * The events about a connection's own life, by name, that every kind of client
191
+ * delivers.
192
+ *
193
+ * `connected` and `disconnected` come from the client's own lifecycle rather
194
+ * than from a notification, so nothing on the catch-all carries them. `kicked`
195
+ * is not of that kind: it is derived from the `notifyclientleftview` or
196
+ * `notifyclientmoved` that reports this client kicked, so that notification
197
+ * reaches the catch-all as well. What the three share is the delivery, not the
198
+ * origin: they go out on the client's own path, which event middleware does
199
+ * not see, because they are about the connection rather than about the
200
+ * server's event stream. `kicked` is the convenience event for the one case it
201
+ * names, this client kicked from the server or from its channel. Gaining a key
202
+ * is additive, and none is removed in a minor release.
203
+ */
204
+ export interface SessionEventMap {
205
+ /** The handshake completing, on `connect()` and on every reconnection. */
206
+ connected: ConnectedEvent;
207
+ /**
208
+ * The connection ending, after `disconnect()`, a drop, or a failed attempt;
209
+ * the event says why and whether the reconnect loop will try again.
210
+ */
211
+ disconnected: DisconnectedEvent;
212
+ /**
213
+ * This client being kicked from its channel or the server: derived from the
214
+ * `notifyclientmoved` or `notifyclientleftview` that reports it, so that
215
+ * notification also arrives on the catch-all. A kick from the server ends
216
+ * the connection as well, which `disconnected` reports.
217
+ */
218
+ kicked: KickedEvent;
219
+ }
@@ -0,0 +1,161 @@
1
+ import { isCommandName } from "./command/parser.js";
2
+
3
+ const MAX_UINT64 = (1n << 64n) - 1n;
4
+ const MAX_UINT64_DIGITS = String(MAX_UINT64).length;
5
+
6
+ /**
7
+ * Read an unsigned 64-bit decimal: digits only, 0 to 2^64-1. Anything else — a
8
+ * sign, a hex or binary prefix, a fraction, a value that does not fit — reads as
9
+ * 0, which names nothing, instead of throwing: the text comes off the network.
10
+ * `BigInt()` alone takes all of those, in any width.
11
+ */
12
+ export function parseUint64(s: string): bigint {
13
+ if (!/^[0-9]+$/.test(s)) return 0n;
14
+ // Leading zeros are dropped first so that no long run of digits reaches BigInt.
15
+ const digits = s.replace(/^0+(?=[0-9])/, "");
16
+ if (digits.length > MAX_UINT64_DIGITS) return 0n;
17
+ const value = BigInt(digits);
18
+ return value > MAX_UINT64 ? 0n : value;
19
+ }
20
+
21
+ export function parseUint16(s: string): number {
22
+ const v = parseInt(s, 10);
23
+ if (isNaN(v) || v < 0 || v > 65535) return 0;
24
+ return v;
25
+ }
26
+
27
+ export function parseInt10(s: string): number {
28
+ const v = parseInt(s, 10);
29
+ return isNaN(v) ? 0 : v;
30
+ }
31
+
32
+ /** The bytes the rows of a line may hold together, see {@link rowLimits}. */
33
+ const MIN_ROW_BUDGET = 64 * 1024;
34
+ const ROW_GROWTH = 4;
35
+ const MAX_ROW_AMPLIFICATION = 64;
36
+
37
+ /**
38
+ * Expand a pipe-separated multi-row TS3 command line into individual rows.
39
+ *
40
+ * A named line (`notifyclientleftview a=1|a=2`) keeps its name on every row; a
41
+ * nameless response (`cldbid=1|cldbid=2`) stays nameless. Whether the first
42
+ * token is a name is decided by the parser's own rule — deciding it here by
43
+ * position is how a nameless batch with no space in it went through unsplit and
44
+ * a one-field-per-row response came back as a single row. Tokens are split on
45
+ * the space and on nothing else, as the parser splits them.
46
+ *
47
+ * TeamSpeak compresses a batch by leaving out of a row the fields whose value
48
+ * is unchanged from the previous row: in a notifycliententerview batch, ctid is
49
+ * often present only on the first row. A row is therefore the fields of the
50
+ * previous row, as that row came out, that it does not name itself, followed by
51
+ * its own. Tokens stay escaped so the command parser can still perform the
52
+ * single unescape pass later.
53
+ *
54
+ * A row that names a field of its own each time makes every row carry all the
55
+ * fields before it, so the rows would grow with the square of the line. The
56
+ * rows of a real server's line are a little larger than their own parts and
57
+ * never come near the limits that stop this: once the rows together would hold
58
+ * more than the larger of four times the line and 64 KiB, the rows after that
59
+ * carry only their own tokens. A name repeated on every row can grow them on its
60
+ * own, so at twice that the rows stop, and the rest of the line is dropped.
61
+ * Neither limit passes 64 times the line. Lengths are counted in characters.
62
+ */
63
+ export function splitCommandRows(line: string): string[] {
64
+ const spaceIdx = line.indexOf(" ");
65
+ const head = spaceIdx < 0 ? line : line.slice(0, spaceIdx);
66
+ const name = isCommandName(head) ? head : "";
67
+ const rest = name === "" ? line : spaceIdx < 0 ? "" : line.slice(spaceIdx + 1);
68
+
69
+ if (!rest.includes("|")) return [line];
70
+
71
+ const prefix = name === "" ? "" : `${name} `;
72
+ const { inherit: inheritLimit, drop: dropLimit } = rowLimits(line.length);
73
+ const rows: string[] = [];
74
+ let used = 0;
75
+ // The fields of the row before, each once, with the token that row gave it;
76
+ // empty once rows stop inheriting.
77
+ let previous: string[] = [];
78
+ let inheriting = true;
79
+
80
+ for (const part of rest.split("|")) {
81
+ if (part === "") continue;
82
+ const tokens = part.split(" ").filter(Boolean);
83
+
84
+ let row = prefix + tokens.join(" ");
85
+ if (inheriting) {
86
+ const resolved = resolveRow(previous, tokens);
87
+ const inherited = prefix + resolved.join(" ");
88
+ if (used + inherited.length <= inheritLimit) {
89
+ row = inherited;
90
+ previous = lastPerField(resolved);
91
+ } else {
92
+ inheriting = false;
93
+ previous = [];
94
+ }
95
+ }
96
+ if (used + row.length > dropLimit) break;
97
+ used += row.length;
98
+ rows.push(row);
99
+ }
100
+ return rows.length === 0 ? [line] : rows;
101
+ }
102
+
103
+ /**
104
+ * The tokens of a row: the fields of the previous row that the row does not
105
+ * name, then the row's own tokens.
106
+ */
107
+ function resolveRow(previous: string[], tokens: string[]): string[] {
108
+ const named = new Set<string>();
109
+ for (const token of tokens) named.add(fieldName(token));
110
+ return [...previous.filter((token) => !named.has(fieldName(token))), ...tokens];
111
+ }
112
+
113
+ /** The last token of each field, in the order the fields first appear. */
114
+ function lastPerField(tokens: string[]): string[] {
115
+ const at = new Map<string, number>();
116
+ const kept: string[] = [];
117
+ for (const token of tokens) {
118
+ const key = fieldName(token);
119
+ const i = at.get(key);
120
+ if (i === undefined) {
121
+ at.set(key, kept.length);
122
+ kept.push(token);
123
+ } else {
124
+ kept[i] = token;
125
+ }
126
+ }
127
+ return kept;
128
+ }
129
+
130
+ /**
131
+ * How many characters the rows of a line of `n` may hold together before they
132
+ * stop inheriting fields, and before they stop.
133
+ */
134
+ function rowLimits(n: number): { inherit: number; drop: number } {
135
+ const inherit = Math.max(ROW_GROWTH * n, MIN_ROW_BUDGET);
136
+ const drop = Math.min(2 * inherit, MAX_ROW_AMPLIFICATION * n);
137
+ return { inherit: Math.min(inherit, drop), drop };
138
+ }
139
+
140
+ function fieldName(token: string): string {
141
+ const equalIndex = token.indexOf("=");
142
+ return equalIndex > 0 ? token.slice(0, equalIndex) : token;
143
+ }
144
+
145
+ /**
146
+ * Sleep, or wake early once `signal` aborts. Resolves either way, never
147
+ * rejects. The timer keeps the process alive while it runs.
148
+ */
149
+ export function sleep(ms: number, signal?: AbortSignal): Promise<void> {
150
+ if (ms <= 0 || signal?.aborted) return Promise.resolve();
151
+
152
+ return new Promise((resolve) => {
153
+ const done = (): void => {
154
+ clearTimeout(timer);
155
+ signal?.removeEventListener("abort", done);
156
+ resolve();
157
+ };
158
+ const timer = setTimeout(done, ms);
159
+ signal?.addEventListener("abort", done, { once: true });
160
+ });
161
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * What every TeamSpeak connection shares: the command language, ids, errors,
3
+ * and the typed commands that run on any connection able to execute a command.
4
+ *
5
+ * The voice client is in `@honeybbq/teamspeak/client`.
6
+ *
7
+ * @module @honeybbq/teamspeak
8
+ */
9
+
10
+ // Escaping, for a raw line sent with a client's `exec`.
11
+ export { escape, unescape } from "./command/command.js";
12
+
13
+ // Requests and the connections that execute them.
14
+ export type {
15
+ CommandExecutor,
16
+ CommandOptions,
17
+ CommandRequest,
18
+ ParamValue,
19
+ } from "./command/request.js";
20
+
21
+ // Branded ids: a ChannelID cannot be passed where a ClientID is meant.
22
+ export {
23
+ asBanID,
24
+ asChannelID,
25
+ asClientFileTransferID,
26
+ asMessageID,
27
+ asServerFileTransferID,
28
+ asServerID,
29
+ asChannelGroupID,
30
+ asClientDBID,
31
+ asClientID,
32
+ asIconID,
33
+ asPermissionID,
34
+ asServerGroupID,
35
+ asUID,
36
+ asChannelUID,
37
+ } from "./command/ids.js";
38
+ export type {
39
+ BanID,
40
+ ClientFileTransferID,
41
+ MessageID,
42
+ ServerFileTransferID,
43
+ ServerID,
44
+ ChannelGroupID,
45
+ ChannelID,
46
+ ClientDBID,
47
+ ClientID,
48
+ IconID,
49
+ PermissionID,
50
+ ServerGroupID,
51
+ UID,
52
+ ChannelUID,
53
+ } from "./command/ids.js";
54
+
55
+ export {
56
+ TeamspeakError,
57
+ ServerError,
58
+ CommandTimeoutError,
59
+ NotConnectedError,
60
+ NoDataError,
61
+ AlreadyConnectedError,
62
+ } from "./errors.js";
63
+ export { ErrorCode } from "./errorcode.js";
64
+ export { Reason } from "./reason.js";
65
+
66
+ // Small-integer enumerations, as named values and types.
67
+ export {
68
+ ClientType,
69
+ Codec,
70
+ GroupNameMode,
71
+ GroupType,
72
+ HostMessageMode,
73
+ LogLevel,
74
+ PermissionTarget,
75
+ TextMessageTarget,
76
+ PrivilegeKeyType,
77
+ } from "./enums.js";
78
+
79
+ // Permissions, by id or by name.
80
+ export { permissionByID, permissionByName } from "./permission.js";
81
+ export { PermissionName } from "./permission-name.js";
82
+ export { CommandName } from "./command-name.js";
83
+ export { NotificationName } from "./notification-name.js";
84
+ export { PropertyName } from "./property-name.js";
85
+ export type { Permission } from "./permission.js";
86
+
87
+ export { noopLogger, consoleLogger, ClientStatus } from "./types.js";
88
+ export type {
89
+ ClientVersion,
90
+ Listener,
91
+ ServerFamily,
92
+ Unsubscribe,
93
+ CommandMiddleware,
94
+ FileDownloadInfo,
95
+ FileUploadInfo,
96
+ Logger,
97
+ } from "./types.js";
98
+
99
+ // The events a server sends, shared by every client.
100
+ export type {
101
+ TextMessageEvent,
102
+ ClientMovedEvent,
103
+ ClientLeaveEvent,
104
+ KickedEvent,
105
+ ClientEnterEvent,
106
+ PokeEvent,
107
+ VoiceDataEvent,
108
+ NotificationEvent,
109
+ ConnectedEvent,
110
+ DisconnectedEvent,
111
+ ServerEventMap,
112
+ SessionEventMap,
113
+ } from "./events.js";
114
+
115
+ // Reconnection policy, whose retry decision each client supplies.
116
+ export { backoffDelay, defaultBackoffPolicy } from "./reconnect.js";
117
+ export type { BackoffPolicy, ReconnectOptions } from "./reconnect.js";
118
+
119
+ // Typed commands, one module per area of the protocol.
120
+ export * from "./api/channels.js";
121
+ export * from "./api/clients.js";
122
+ export * from "./api/server.js";
123
+ export * from "./api/groups.js";
124
+ export * from "./api/moderation.js";
125
+ export * from "./api/files.js";
126
+ export type { Channel, PagingOptions, PermissionEntry } from "./api/command.js";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Protocol plumbing for the modules next to the core, `client` and `query`.
3
+ *
4
+ * Not public API and not exported by the package: they import it by relative
5
+ * path, so it can change in any release.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+
10
+ export { isCommandName, parseCommand } from "./command/parser.js";
11
+ export { encodeRequest } from "./command/request.js";
12
+ export { buildCommandChain } from "./middleware.js";
13
+ export { buildCommand, buildCommandOrdered } from "./command/command.js";
14
+ export type { Command } from "./command/command.js";
15
+ export { parseClient } from "./api/parse.js";
16
+ export { handleNotification } from "./notifications.js";
17
+ export type { NotificationResult } from "./notifications.js";
18
+ export { parseIconID } from "./command/ids.js";
19
+ export { responseSpec } from "./command/responses.js";
20
+ export type { ResponseSpec } from "./command/responses.js";
21
+ export { parseErrorCode, parseServerError } from "./errors.js";
22
+ export { splitCommandRows, parseUint64, parseUint16, parseInt10, sleep } from "./helpers.js";
23
+ export { jitteredDelay, resolveBackoffPolicy } from "./reconnect.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Command middleware, and the chain it makes.
3
+ *
4
+ * Both clients wrap the typed command layer the same way, so the composing
5
+ * lives here; each supplies its own base handler.
6
+ */
7
+
8
+ import type { CommandExecutor } from "./command/request.js";
9
+ import type { CommandMiddleware } from "./types.js";
10
+
11
+ /**
12
+ * Compose a chain of middlewares around a base handler.
13
+ * Rightmost middleware wraps the base first.
14
+ */
15
+ export function buildCommandChain(
16
+ middlewares: readonly CommandMiddleware[],
17
+ base: CommandExecutor["send"],
18
+ ): CommandExecutor["send"] {
19
+ let handler = base;
20
+ for (let i = middlewares.length - 1; i >= 0; i--) {
21
+ handler = middlewares[i]!(handler);
22
+ }
23
+ return handler;
24
+ }