@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.
- package/LICENSE +21 -0
- package/README.md +726 -2
- package/dist/client/abort.d.ts +5 -0
- package/dist/client/abort.d.ts.map +1 -0
- package/dist/client/abort.js +23 -0
- package/dist/client/abort.js.map +1 -0
- package/dist/client/address.d.ts +17 -0
- package/dist/client/address.d.ts.map +1 -0
- package/dist/client/address.js +66 -0
- package/dist/client/address.js.map +1 -0
- package/dist/client/api/voice.d.ts +24 -0
- package/dist/client/api/voice.d.ts.map +1 -0
- package/dist/client/api/voice.js +33 -0
- package/dist/client/api/voice.js.map +1 -0
- package/dist/client/capabilities.d.ts +68 -0
- package/dist/client/capabilities.d.ts.map +1 -0
- package/dist/client/capabilities.js +59 -0
- package/dist/client/capabilities.js.map +1 -0
- package/dist/client/client.d.ts +196 -0
- package/dist/client/client.d.ts.map +1 -0
- package/dist/client/client.js +1523 -0
- package/dist/client/client.js.map +1 -0
- package/dist/client/commands.d.ts +66 -0
- package/dist/client/commands.d.ts.map +1 -0
- package/dist/client/commands.js +162 -0
- package/dist/client/commands.js.map +1 -0
- package/dist/client/crypto/crypt-ops.d.ts +7 -0
- package/dist/client/crypto/crypt-ops.d.ts.map +1 -0
- package/dist/client/crypto/crypt-ops.js +2 -0
- package/dist/client/crypto/crypt-ops.js.map +1 -0
- package/dist/client/crypto/crypt.d.ts +37 -0
- package/dist/client/crypto/crypt.d.ts.map +1 -0
- package/dist/client/crypto/crypt.js +203 -0
- package/dist/client/crypto/crypt.js.map +1 -0
- package/dist/client/crypto/eax.d.ts +12 -0
- package/dist/client/crypto/eax.d.ts.map +1 -0
- package/dist/client/crypto/eax.js +118 -0
- package/dist/client/crypto/eax.js.map +1 -0
- package/dist/client/crypto/identity.d.ts +97 -0
- package/dist/client/crypto/identity.d.ts.map +1 -0
- package/dist/client/crypto/identity.js +412 -0
- package/dist/client/crypto/identity.js.map +1 -0
- package/dist/client/crypto/index.d.ts +7 -0
- package/dist/client/crypto/index.d.ts.map +1 -0
- package/dist/client/crypto/index.js +5 -0
- package/dist/client/crypto/index.js.map +1 -0
- package/dist/client/crypto/primitives.d.ts +43 -0
- package/dist/client/crypto/primitives.d.ts.map +1 -0
- package/dist/client/crypto/primitives.js +116 -0
- package/dist/client/crypto/primitives.js.map +1 -0
- package/dist/client/diagnostics.d.ts +45 -0
- package/dist/client/diagnostics.d.ts.map +1 -0
- package/dist/client/diagnostics.js +30 -0
- package/dist/client/diagnostics.js.map +1 -0
- package/dist/client/discovery/index.d.ts +2 -0
- package/dist/client/discovery/index.d.ts.map +1 -0
- package/dist/client/discovery/index.js +2 -0
- package/dist/client/discovery/index.js.map +1 -0
- package/dist/client/discovery/resolver.d.ts +26 -0
- package/dist/client/discovery/resolver.d.ts.map +1 -0
- package/dist/client/discovery/resolver.js +275 -0
- package/dist/client/discovery/resolver.js.map +1 -0
- package/dist/client/errors.d.ts +82 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +201 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/events.d.ts +3 -0
- package/dist/client/events.d.ts.map +1 -0
- package/dist/client/events.js +8 -0
- package/dist/client/events.js.map +1 -0
- package/dist/client/handshake/crypt-handshake.d.ts +17 -0
- package/dist/client/handshake/crypt-handshake.d.ts.map +1 -0
- package/dist/client/handshake/crypt-handshake.js +128 -0
- package/dist/client/handshake/crypt-handshake.js.map +1 -0
- package/dist/client/handshake/crypt-init2.d.ts +7 -0
- package/dist/client/handshake/crypt-init2.d.ts.map +1 -0
- package/dist/client/handshake/crypt-init2.js +37 -0
- package/dist/client/handshake/crypt-init2.js.map +1 -0
- package/dist/client/handshake/index.d.ts +4 -0
- package/dist/client/handshake/index.d.ts.map +1 -0
- package/dist/client/handshake/index.js +4 -0
- package/dist/client/handshake/index.js.map +1 -0
- package/dist/client/handshake/license.d.ts +35 -0
- package/dist/client/handshake/license.d.ts.map +1 -0
- package/dist/client/handshake/license.js +169 -0
- package/dist/client/handshake/license.js.map +1 -0
- package/dist/client/handshake.d.ts +27 -0
- package/dist/client/handshake.d.ts.map +1 -0
- package/dist/client/handshake.js +126 -0
- package/dist/client/handshake.js.map +1 -0
- package/dist/client/helpers.d.ts +6 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +13 -0
- package/dist/client/helpers.js.map +1 -0
- package/dist/client/hooks.d.ts +7 -0
- package/dist/client/hooks.d.ts.map +1 -0
- package/dist/client/hooks.js +28 -0
- package/dist/client/hooks.js.map +1 -0
- package/dist/client/index.d.ts +26 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +28 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/reconnect.d.ts +12 -0
- package/dist/client/reconnect.d.ts.map +1 -0
- package/dist/client/reconnect.js +44 -0
- package/dist/client/reconnect.js.map +1 -0
- package/dist/client/throttle.d.ts +20 -0
- package/dist/client/throttle.d.ts.map +1 -0
- package/dist/client/throttle.js +83 -0
- package/dist/client/throttle.js.map +1 -0
- package/dist/client/trace.d.ts +223 -0
- package/dist/client/trace.d.ts.map +1 -0
- package/dist/client/trace.js +13 -0
- package/dist/client/trace.js.map +1 -0
- package/dist/client/transfer.d.ts +111 -0
- package/dist/client/transfer.d.ts.map +1 -0
- package/dist/client/transfer.js +243 -0
- package/dist/client/transfer.js.map +1 -0
- package/dist/client/transport/generation-window.d.ts +30 -0
- package/dist/client/transport/generation-window.d.ts.map +1 -0
- package/dist/client/transport/generation-window.js +97 -0
- package/dist/client/transport/generation-window.js.map +1 -0
- package/dist/client/transport/handler.d.ts +61 -0
- package/dist/client/transport/handler.d.ts.map +1 -0
- package/dist/client/transport/handler.js +793 -0
- package/dist/client/transport/handler.js.map +1 -0
- package/dist/client/transport/index.d.ts +6 -0
- package/dist/client/transport/index.d.ts.map +1 -0
- package/dist/client/transport/index.js +5 -0
- package/dist/client/transport/index.js.map +1 -0
- package/dist/client/transport/packet.d.ts +36 -0
- package/dist/client/transport/packet.d.ts.map +1 -0
- package/dist/client/transport/packet.js +55 -0
- package/dist/client/transport/packet.js.map +1 -0
- package/dist/client/transport/quicklz.d.ts +24 -0
- package/dist/client/transport/quicklz.d.ts.map +1 -0
- package/dist/client/transport/quicklz.js +179 -0
- package/dist/client/transport/quicklz.js.map +1 -0
- package/dist/client/types.d.ts +226 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +39 -0
- package/dist/client/types.js.map +1 -0
- package/dist/core/api/channels.d.ts +182 -0
- package/dist/core/api/channels.d.ts.map +1 -0
- package/dist/core/api/channels.js +155 -0
- package/dist/core/api/channels.js.map +1 -0
- package/dist/core/api/clients.d.ts +304 -0
- package/dist/core/api/clients.d.ts.map +1 -0
- package/dist/core/api/clients.js +260 -0
- package/dist/core/api/clients.js.map +1 -0
- package/dist/core/api/command.d.ts +305 -0
- package/dist/core/api/command.d.ts.map +1 -0
- package/dist/core/api/command.js +363 -0
- package/dist/core/api/command.js.map +1 -0
- package/dist/core/api/files.d.ts +153 -0
- package/dist/core/api/files.d.ts.map +1 -0
- package/dist/core/api/files.js +181 -0
- package/dist/core/api/files.js.map +1 -0
- package/dist/core/api/groups.d.ts +248 -0
- package/dist/core/api/groups.d.ts.map +1 -0
- package/dist/core/api/groups.js +271 -0
- package/dist/core/api/groups.js.map +1 -0
- package/dist/core/api/moderation.d.ts +205 -0
- package/dist/core/api/moderation.d.ts.map +1 -0
- package/dist/core/api/moderation.js +209 -0
- package/dist/core/api/moderation.js.map +1 -0
- package/dist/core/api/parse.d.ts +16 -0
- package/dist/core/api/parse.d.ts.map +1 -0
- package/dist/core/api/parse.js +40 -0
- package/dist/core/api/parse.js.map +1 -0
- package/dist/core/api/server.d.ts +310 -0
- package/dist/core/api/server.d.ts.map +1 -0
- package/dist/core/api/server.js +290 -0
- package/dist/core/api/server.js.map +1 -0
- package/dist/core/command/command.d.ts +20 -0
- package/dist/core/command/command.d.ts.map +1 -0
- package/dist/core/command/command.js +112 -0
- package/dist/core/command/command.js.map +1 -0
- package/dist/core/command/ids.d.ts +125 -0
- package/dist/core/command/ids.d.ts.map +1 -0
- package/dist/core/command/ids.js +85 -0
- package/dist/core/command/ids.js.map +1 -0
- package/dist/core/command/parser.d.ts +17 -0
- package/dist/core/command/parser.d.ts.map +1 -0
- package/dist/core/command/parser.js +65 -0
- package/dist/core/command/parser.js.map +1 -0
- package/dist/core/command/request.d.ts +61 -0
- package/dist/core/command/request.d.ts.map +1 -0
- package/dist/core/command/request.js +64 -0
- package/dist/core/command/request.js.map +1 -0
- package/dist/core/command/responses.d.ts +59 -0
- package/dist/core/command/responses.d.ts.map +1 -0
- package/dist/core/command/responses.js +74 -0
- package/dist/core/command/responses.js.map +1 -0
- package/dist/core/command-name.d.ts +333 -0
- package/dist/core/command-name.d.ts.map +1 -0
- package/dist/core/command-name.js +331 -0
- package/dist/core/command-name.js.map +1 -0
- package/dist/core/enums.d.ts +146 -0
- package/dist/core/enums.d.ts.map +1 -0
- package/dist/core/enums.js +132 -0
- package/dist/core/enums.js.map +1 -0
- package/dist/core/errorcode.d.ts +413 -0
- package/dist/core/errorcode.d.ts.map +1 -0
- package/dist/core/errorcode.js +410 -0
- package/dist/core/errorcode.js.map +1 -0
- package/dist/core/errors.d.ts +111 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +233 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events.d.ts +207 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +6 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/helpers.d.ts +42 -0
- package/dist/core/helpers.d.ts.map +1 -0
- package/dist/core/helpers.js +156 -0
- package/dist/core/helpers.js.map +1 -0
- package/dist/core/index.d.ts +35 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +23 -0
- package/dist/core/internal.d.ts.map +1 -0
- package/dist/core/internal.js +20 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/middleware.d.ts +14 -0
- package/dist/core/middleware.d.ts.map +1 -0
- package/dist/core/middleware.js +18 -0
- package/dist/core/middleware.js.map +1 -0
- package/dist/core/notification-name.d.ts +154 -0
- package/dist/core/notification-name.d.ts.map +1 -0
- package/dist/core/notification-name.js +152 -0
- package/dist/core/notification-name.js.map +1 -0
- package/dist/core/notifications.d.ts +43 -0
- package/dist/core/notifications.d.ts.map +1 -0
- package/dist/core/notifications.js +116 -0
- package/dist/core/notifications.js.map +1 -0
- package/dist/core/permission-name.d.ts +533 -0
- package/dist/core/permission-name.d.ts.map +1 -0
- package/dist/core/permission-name.js +531 -0
- package/dist/core/permission-name.js.map +1 -0
- package/dist/core/permission.d.ts +31 -0
- package/dist/core/permission.d.ts.map +1 -0
- package/dist/core/permission.js +20 -0
- package/dist/core/permission.js.map +1 -0
- package/dist/core/property-name.d.ts +403 -0
- package/dist/core/property-name.d.ts.map +1 -0
- package/dist/core/property-name.js +405 -0
- package/dist/core/property-name.js.map +1 -0
- package/dist/core/reason.d.ts +39 -0
- package/dist/core/reason.d.ts.map +1 -0
- package/dist/core/reason.js +36 -0
- package/dist/core/reason.js.map +1 -0
- package/dist/core/reconnect.d.ts +59 -0
- package/dist/core/reconnect.d.ts.map +1 -0
- package/dist/core/reconnect.js +55 -0
- package/dist/core/reconnect.js.map +1 -0
- package/dist/core/types.d.ts +110 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +27 -0
- package/dist/core/types.js.map +1 -0
- package/dist/query/client.d.ts +194 -0
- package/dist/query/client.d.ts.map +1 -0
- package/dist/query/client.js +967 -0
- package/dist/query/client.js.map +1 -0
- package/dist/query/errors.d.ts +61 -0
- package/dist/query/errors.d.ts.map +1 -0
- package/dist/query/errors.js +100 -0
- package/dist/query/errors.js.map +1 -0
- package/dist/query/index.d.ts +36 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +34 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/knownhosts.d.ts +61 -0
- package/dist/query/knownhosts.d.ts.map +1 -0
- package/dist/query/knownhosts.js +223 -0
- package/dist/query/knownhosts.js.map +1 -0
- package/dist/query/lines.d.ts +14 -0
- package/dist/query/lines.d.ts.map +1 -0
- package/dist/query/lines.js +29 -0
- package/dist/query/lines.js.map +1 -0
- package/dist/query/options.d.ts +187 -0
- package/dist/query/options.d.ts.map +1 -0
- package/dist/query/options.js +213 -0
- package/dist/query/options.js.map +1 -0
- package/dist/query/reconnect.d.ts +29 -0
- package/dist/query/reconnect.d.ts.map +1 -0
- package/dist/query/reconnect.js +87 -0
- package/dist/query/reconnect.js.map +1 -0
- package/dist/query/ssh.d.ts +345 -0
- package/dist/query/ssh.d.ts.map +1 -0
- package/dist/query/ssh.js +241 -0
- package/dist/query/ssh.js.map +1 -0
- package/dist/query/stream.d.ts +38 -0
- package/dist/query/stream.d.ts.map +1 -0
- package/dist/query/stream.js +70 -0
- package/dist/query/stream.js.map +1 -0
- package/dist/query/tcp.d.ts +38 -0
- package/dist/query/tcp.d.ts.map +1 -0
- package/dist/query/tcp.js +53 -0
- package/dist/query/tcp.js.map +1 -0
- package/dist/query/transport.d.ts +36 -0
- package/dist/query/transport.d.ts.map +1 -0
- package/dist/query/transport.js +2 -0
- package/dist/query/transport.js.map +1 -0
- package/dist/query/web.d.ts +54 -0
- package/dist/query/web.d.ts.map +1 -0
- package/dist/query/web.js +146 -0
- package/dist/query/web.js.map +1 -0
- package/dist/versions/index.d.ts +3094 -0
- package/dist/versions/index.d.ts.map +1 -0
- package/dist/versions/index.js +9237 -0
- package/dist/versions/index.js.map +1 -0
- package/package.json +118 -4
- package/src/client/abort.ts +24 -0
- package/src/client/address.ts +74 -0
- package/src/client/api/voice.ts +61 -0
- package/src/client/capabilities.ts +106 -0
- package/src/client/client.ts +1809 -0
- package/src/client/commands.ts +193 -0
- package/src/client/crypto/crypt-ops.ts +6 -0
- package/src/client/crypto/crypt.ts +275 -0
- package/src/client/crypto/eax.ts +152 -0
- package/src/client/crypto/identity.ts +484 -0
- package/src/client/crypto/index.ts +21 -0
- package/src/client/crypto/primitives.ts +141 -0
- package/src/client/diagnostics.ts +58 -0
- package/src/client/discovery/index.ts +1 -0
- package/src/client/discovery/resolver.ts +325 -0
- package/src/client/errors.ts +217 -0
- package/src/client/events.ts +12 -0
- package/src/client/handshake/crypt-handshake.ts +157 -0
- package/src/client/handshake/crypt-init2.ts +48 -0
- package/src/client/handshake/index.ts +3 -0
- package/src/client/handshake/license.ts +208 -0
- package/src/client/handshake.ts +150 -0
- package/src/client/helpers.ts +10 -0
- package/src/client/hooks.ts +30 -0
- package/src/client/index.ts +93 -0
- package/src/client/reconnect.ts +43 -0
- package/src/client/throttle.ts +92 -0
- package/src/client/trace.ts +237 -0
- package/src/client/transfer.ts +436 -0
- package/src/client/transport/generation-window.ts +108 -0
- package/src/client/transport/handler.ts +926 -0
- package/src/client/transport/index.ts +14 -0
- package/src/client/transport/packet.ts +69 -0
- package/src/client/transport/quicklz.ts +209 -0
- package/src/client/types.ts +268 -0
- package/src/core/api/channels.ts +396 -0
- package/src/core/api/clients.ts +654 -0
- package/src/core/api/command.ts +563 -0
- package/src/core/api/files.ts +405 -0
- package/src/core/api/groups.ts +622 -0
- package/src/core/api/moderation.ts +525 -0
- package/src/core/api/parse.ts +52 -0
- package/src/core/api/server.ts +709 -0
- package/src/core/command/command.ts +125 -0
- package/src/core/command/ids.ts +149 -0
- package/src/core/command/parser.ts +68 -0
- package/src/core/command/request.ts +119 -0
- package/src/core/command/responses.ts +114 -0
- package/src/core/command-name.ts +334 -0
- package/src/core/enums.ts +167 -0
- package/src/core/errorcode.ts +412 -0
- package/src/core/errors.ts +258 -0
- package/src/core/events.ts +219 -0
- package/src/core/helpers.ts +161 -0
- package/src/core/index.ts +126 -0
- package/src/core/internal.ts +23 -0
- package/src/core/middleware.ts +24 -0
- package/src/core/notification-name.ts +155 -0
- package/src/core/notifications.ts +157 -0
- package/src/core/permission-name.ts +538 -0
- package/src/core/permission.ts +34 -0
- package/src/core/property-name.ts +411 -0
- package/src/core/reason.ts +38 -0
- package/src/core/reconnect.ts +98 -0
- package/src/core/types.ts +138 -0
- package/src/query/client.ts +1132 -0
- package/src/query/errors.ts +108 -0
- package/src/query/index.ts +65 -0
- package/src/query/knownhosts.ts +257 -0
- package/src/query/lines.ts +28 -0
- package/src/query/options.ts +388 -0
- package/src/query/reconnect.ts +84 -0
- package/src/query/ssh.ts +614 -0
- package/src/query/stream.ts +91 -0
- package/src/query/tcp.ts +85 -0
- package/src/query/transport.ts +35 -0
- package/src/query/web.ts +195 -0
- package/src/versions/index.ts +10774 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconnection policy.
|
|
3
|
+
*
|
|
4
|
+
* A dropped connection is normal on a UDP voice session, so a bot that cannot
|
|
5
|
+
* recover is not usable unattended. Reconnecting is opt-in rather than
|
|
6
|
+
* automatic: a silent reconnect makes a dropped session look like a healthy
|
|
7
|
+
* one, and a caller that wanted to know about the drop never finds out.
|
|
8
|
+
*
|
|
9
|
+
* Backoff is not a nicety here. TeamSpeak bans an IP that opens several
|
|
10
|
+
* connections in quick succession — measured at roughly three, after which the
|
|
11
|
+
* server answers `error id=3329` and refuses everything. A reconnect loop
|
|
12
|
+
* without a delay therefore bans itself, and the ban outlasts the outage it was
|
|
13
|
+
* recovering from.
|
|
14
|
+
*/
|
|
15
|
+
/** One second, doubling, capped at a minute, with 20% jitter, never giving up. */
|
|
16
|
+
export const defaultBackoffPolicy = Object.freeze({
|
|
17
|
+
initialDelayMs: 1_000,
|
|
18
|
+
maxDelayMs: 60_000,
|
|
19
|
+
factor: 2,
|
|
20
|
+
jitter: 0.2,
|
|
21
|
+
maxAttempts: 0,
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Compute the delay before an attempt.
|
|
25
|
+
*
|
|
26
|
+
* `attempt` is 1-based: the delay before the first retry is `initialDelayMs`,
|
|
27
|
+
* give or take the jitter, and the delay never grows past `maxDelayMs`.
|
|
28
|
+
*/
|
|
29
|
+
export function backoffDelay(policy, attempt) {
|
|
30
|
+
return jitteredDelay(policy, attempt, Math.random);
|
|
31
|
+
}
|
|
32
|
+
/** @internal The delay, with `random` supplying the jitter. */
|
|
33
|
+
export function jitteredDelay(policy, attempt, random) {
|
|
34
|
+
const exponent = Math.max(0, attempt - 1);
|
|
35
|
+
const raw = policy.initialDelayMs * policy.factor ** exponent;
|
|
36
|
+
const capped = Math.min(raw, policy.maxDelayMs);
|
|
37
|
+
if (policy.jitter <= 0)
|
|
38
|
+
return Math.round(capped);
|
|
39
|
+
// Full jitter would ignore the computed delay; this keeps the trend while
|
|
40
|
+
// spreading peers, so a whole fleet does not retry on the same millisecond.
|
|
41
|
+
// Kept under the ceiling, which a caller reasonably reads as a promise.
|
|
42
|
+
const spread = capped * Math.min(policy.jitter, 1);
|
|
43
|
+
const delay = capped + (random() * 2 - 1) * spread;
|
|
44
|
+
return Math.round(Math.max(0, Math.min(delay, policy.maxDelayMs)));
|
|
45
|
+
}
|
|
46
|
+
export function resolveBackoffPolicy(options) {
|
|
47
|
+
const policy = { ...defaultBackoffPolicy };
|
|
48
|
+
// An explicit undefined keeps the default, as an unset field does.
|
|
49
|
+
for (const [key, value] of Object.entries(options.backoff ?? {})) {
|
|
50
|
+
if (value !== undefined)
|
|
51
|
+
policy[key] = value;
|
|
52
|
+
}
|
|
53
|
+
return policy;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=reconnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconnect.js","sourceRoot":"","sources":["../../src/core/reconnect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAqBH,kFAAkF;AAClF,MAAM,CAAC,MAAM,oBAAoB,GAA4B,MAAM,CAAC,MAAM,CAAC;IACzE,cAAc,EAAE,KAAK;IACrB,UAAU,EAAE,M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MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;QACjE,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/C,CAAC;IACD,OAAO,MAAkC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ClientFileTransferID, ServerFileTransferID } from "./command/ids.js";
|
|
2
|
+
import type { CommandExecutor } from "./command/request.js";
|
|
3
|
+
/**
|
|
4
|
+
* A client build a server accepts: the platform and version string a client
|
|
5
|
+
* sends in `clientinit`, and the signature TeamSpeak made over them.
|
|
6
|
+
*
|
|
7
|
+
* The signature is Ed25519 over the ASCII bytes of `platform` followed by
|
|
8
|
+
* `version`, base64 encoded. It cannot be made, only reused, so the values
|
|
9
|
+
* that work are the ones in `@honeybbq/teamspeak/versions`. The server checks
|
|
10
|
+
* the signature and refuses a build below its configured minimum.
|
|
11
|
+
*/
|
|
12
|
+
export interface ClientVersion {
|
|
13
|
+
/** The `client_platform` sent, such as `"Windows"`, `"Linux"` or `"Android"`. */
|
|
14
|
+
readonly platform: string;
|
|
15
|
+
/** The `client_version` sent, with its build, such as `"3.6.2 [Build: 1695203293]"`. */
|
|
16
|
+
readonly version: string;
|
|
17
|
+
/** Base64 of the 64-byte signature over `platform + version`. */
|
|
18
|
+
readonly sign: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Wraps the typed command layer, outermost first: it sees each request — the
|
|
22
|
+
* command's name and its parameters, passwords still in plain text — with its
|
|
23
|
+
* options, and returns the rows that answer it, or throws. So it can observe,
|
|
24
|
+
* time, retry, or answer a command itself without sending it.
|
|
25
|
+
*
|
|
26
|
+
* It wraps `send` rather than the interface — its type names that one method,
|
|
27
|
+
* `CommandExecutor["send"]` — so `send` is the whole seam between a client
|
|
28
|
+
* and a middleware.
|
|
29
|
+
*
|
|
30
|
+
* Only the typed commands, which reach the client through `send`, pass
|
|
31
|
+
* through it. Raw lines sent with `exec` or `execNoWait` and the client's own
|
|
32
|
+
* handshake-time commands do not. A request's parameters can hold passwords
|
|
33
|
+
* and privilege keys, so a middleware must not log them whole.
|
|
34
|
+
*/
|
|
35
|
+
export type CommandMiddleware = (next: CommandExecutor["send"]) => CommandExecutor["send"];
|
|
36
|
+
/**
|
|
37
|
+
* Where the SDK logs. `console` is one; so is a pino or winston logger. The
|
|
38
|
+
* first argument is the message, the rest structured details.
|
|
39
|
+
*/
|
|
40
|
+
export interface Logger {
|
|
41
|
+
/** Detail for debugging the protocol; never the content of a command. */
|
|
42
|
+
debug(msg: string, ...args: unknown[]): void;
|
|
43
|
+
/** Connection lifecycle: connecting, connected, reconnecting. */
|
|
44
|
+
info(msg: string, ...args: unknown[]): void;
|
|
45
|
+
/** Something went wrong and was recovered from, or will be retried. */
|
|
46
|
+
warn(msg: string, ...args: unknown[]): void;
|
|
47
|
+
/** Something went wrong that the SDK could not report as an error to a caller. */
|
|
48
|
+
error(msg: string, ...args: unknown[]): void;
|
|
49
|
+
}
|
|
50
|
+
/** A no-op logger that discards all messages. */
|
|
51
|
+
export declare const noopLogger: Logger;
|
|
52
|
+
/** A console-backed logger. */
|
|
53
|
+
export declare const consoleLogger: Logger;
|
|
54
|
+
/** A negotiated upload, as `initFileUpload` returns it: what to dial and send. */
|
|
55
|
+
export interface FileUploadInfo {
|
|
56
|
+
/** The key that identifies the transfer on the file transfer connection. */
|
|
57
|
+
readonly fileTransferKey: string;
|
|
58
|
+
/** Where to resume from, in bytes; 0 for a fresh upload. */
|
|
59
|
+
readonly seekPosition: bigint;
|
|
60
|
+
/** The client's id for the transfer. */
|
|
61
|
+
readonly clientFileTransferID: ClientFileTransferID;
|
|
62
|
+
/** The server's id for the transfer. */
|
|
63
|
+
readonly serverFileTransferID: ServerFileTransferID;
|
|
64
|
+
/** The file transfer port to dial. */
|
|
65
|
+
readonly port: number;
|
|
66
|
+
}
|
|
67
|
+
/** A negotiated download, as `initFileDownload` returns it: what to dial and receive. */
|
|
68
|
+
export interface FileDownloadInfo {
|
|
69
|
+
/** The key that identifies the transfer on the file transfer connection. */
|
|
70
|
+
readonly fileTransferKey: string;
|
|
71
|
+
/** How many bytes the server will send. */
|
|
72
|
+
readonly size: bigint;
|
|
73
|
+
/** The client's id for the transfer. */
|
|
74
|
+
readonly clientFileTransferID: ClientFileTransferID;
|
|
75
|
+
/** The server's id for the transfer. */
|
|
76
|
+
readonly serverFileTransferID: ServerFileTransferID;
|
|
77
|
+
/** The file transfer port to dial. */
|
|
78
|
+
readonly port: number;
|
|
79
|
+
}
|
|
80
|
+
/** Removes a listener; calling it again does nothing. Also a `Disposable`, for `using`. */
|
|
81
|
+
export type Unsubscribe = (() => void) & Disposable;
|
|
82
|
+
/**
|
|
83
|
+
* A listener for the event `K` of the event map `M`: it takes the event's
|
|
84
|
+
* payload, or nothing for an event whose payload is `void`.
|
|
85
|
+
*/
|
|
86
|
+
export type Listener<M, K extends keyof M> = M[K] extends void ? () => void : (payload: M[K]) => void;
|
|
87
|
+
/** The values of the table below, before freezing. */
|
|
88
|
+
declare const clientStatusValues: {
|
|
89
|
+
/** Not connected: before `connect()`, after `disconnect()`, or after a drop. */
|
|
90
|
+
readonly Disconnected: "disconnected";
|
|
91
|
+
/** Connecting: `connect()` is waiting for the handshake. */
|
|
92
|
+
readonly Connecting: "connecting";
|
|
93
|
+
/** Connected: the handshake completed and commands can be sent. */
|
|
94
|
+
readonly Connected: "connected";
|
|
95
|
+
};
|
|
96
|
+
/** Where a client is in its connection's life. */
|
|
97
|
+
export declare const ClientStatus: typeof clientStatusValues;
|
|
98
|
+
/**
|
|
99
|
+
* One of {@link ClientStatus}. May gain members in a minor release: a
|
|
100
|
+
* `switch` over it needs a default case.
|
|
101
|
+
*/
|
|
102
|
+
export type ClientStatus = (typeof ClientStatus)[keyof typeof ClientStatus];
|
|
103
|
+
/**
|
|
104
|
+
* The server generation a version string belongs to. May gain members in a
|
|
105
|
+
* minor release, as server generations appear: a `switch` over it needs a
|
|
106
|
+
* default case.
|
|
107
|
+
*/
|
|
108
|
+
export type ServerFamily = "ts3" | "ts6" | "unknown";
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAI5D;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAID;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,eAAe,CAAC,MAAM,CAAC,CAAC;AAI3F;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,yEAAyE;IACzE,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC7C,iEAAiE;IACjE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,uEAAuE;IACvE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,kFAAkF;IAClF,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,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D,UAAU,EAAE,YAAY;IACxB,mEAAmE;aACnE,SAAS,EAAE,WAAW;CACd,CAAC;AACX,kDAAkD;AAClD,eAAO,MAAM,YAAY,EAAE,OAAO,kBACiB,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A no-op logger that discards all messages. */
|
|
2
|
+
export const noopLogger = Object.freeze({
|
|
3
|
+
debug() { },
|
|
4
|
+
info() { },
|
|
5
|
+
warn() { },
|
|
6
|
+
error() { },
|
|
7
|
+
});
|
|
8
|
+
/** A console-backed logger. */
|
|
9
|
+
export const consoleLogger = Object.freeze({
|
|
10
|
+
debug: console.debug.bind(console),
|
|
11
|
+
info: console.info.bind(console),
|
|
12
|
+
warn: console.warn.bind(console),
|
|
13
|
+
error: console.error.bind(console),
|
|
14
|
+
});
|
|
15
|
+
/** The values of the table below, before freezing. */
|
|
16
|
+
const clientStatusValues = {
|
|
17
|
+
/** Not connected: before `connect()`, after `disconnect()`, or after a drop. */
|
|
18
|
+
Disconnected: "disconnected",
|
|
19
|
+
/** Connecting: `connect()` is waiting for the handshake. */
|
|
20
|
+
Connecting: "connecting",
|
|
21
|
+
/** Connected: the handshake completed and commands can be sent. */
|
|
22
|
+
Connected: "connected",
|
|
23
|
+
};
|
|
24
|
+
/** Where a client is in its connection's life. */
|
|
25
|
+
export const ClientStatus =
|
|
26
|
+
/* @__PURE__ */ Object.freeze(clientStatusValues);
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AA2DA,iDAAiD;AACjD,MAAM,CAAC,MAAM,UAAU,GAAW,MAAM,CAAC,MAAM,CAAC;IAC9C,KAAK,KAAI,CAAC;IACV,IAAI,KAAI,CAAC;IACT,IAAI,KAAI,CAAC;IACT,KAAK,KAAI,CAAC;CACX,CAAC,CAAC;AAEH,+BAA+B;AAC/B,MAAM,CAAC,MAAM,aAAa,GAAW,MAAM,CAAC,MAAM,CAAC;IACjD,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;IAClC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;CACnC,CAAC,CAAC;AAyCH,sDAAsD;AACtD,MAAM,kBAAkB,GAAG;IACzB,gFAAgF;IAChF,YAAY,EAAE,cAAc;IAC5B,4DAA4D;IAC5D,UAAU,EAAE,YAAY;IACxB,mEAAmE;IACnE,SAAS,EAAE,WAAW;CACd,CAAC;AACX,kDAAkD;AAClD,MAAM,CAAC,MAAM,YAAY;AACvB,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ClientStatus, type CommandExecutor, type CommandOptions, type CommandRequest, type Listener, type ServerEventMap, type ServerFamily, type ServerID, type SessionEventMap, type Unsubscribe } from "@honeybbq/teamspeak";
|
|
2
|
+
import type { QueryTransport } from "./transport.js";
|
|
3
|
+
import { type QueryClientOptions, type QueryEventCategory } from "./options.js";
|
|
4
|
+
export type { QueryClientOptions, QueryEventsOption, QueryEventCategory, QueryTransportOptions, } from "./options.js";
|
|
5
|
+
/**
|
|
6
|
+
* The events `QueryClient.on()` takes, and what each delivers.
|
|
7
|
+
*
|
|
8
|
+
* The server's own events are the core's, unchanged: ServerQuery and the voice
|
|
9
|
+
* protocol carry the same notifications with the same fields, so a listener
|
|
10
|
+
* written for one client reads the other. `connected` and `disconnected` come
|
|
11
|
+
* from this client's own lifecycle.
|
|
12
|
+
*
|
|
13
|
+
* A notification reaches this client on two layers at once, as it does the
|
|
14
|
+
* voice client: the typed event for it, if it has one, and then `notification`,
|
|
15
|
+
* which carries every notification with its wire name and unescaped parameters.
|
|
16
|
+
* So a typed event added here is additive — the notification it names stays on
|
|
17
|
+
* the catch-all — and none of these keys is removed in a minor release.
|
|
18
|
+
*
|
|
19
|
+
* @experimental Part of the `@honeybbq/teamspeak/query` entry, which may
|
|
20
|
+
* change in a minor release.
|
|
21
|
+
*/
|
|
22
|
+
export interface QueryEventMap extends ServerEventMap, SessionEventMap {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A ServerQuery client: runs the typed commands from `@honeybbq/teamspeak` over
|
|
26
|
+
* one of the three ServerQuery transports, and delivers the notifications the
|
|
27
|
+
* server sends as the core's typed events.
|
|
28
|
+
*
|
|
29
|
+
* ServerQuery answers one command at a time, in order: data lines, then an
|
|
30
|
+
* `error` line that ends the answer. So commands are queued and sent one after
|
|
31
|
+
* another, which also keeps the server's flood protection from seeing a burst.
|
|
32
|
+
* Notifications (`notify…`) can arrive at any point and are not part of an
|
|
33
|
+
* answer.
|
|
34
|
+
*
|
|
35
|
+
* The transport is given as a {@link QueryClientOptions.transport} description
|
|
36
|
+
* rather than an open connection, so the client can build it again when it
|
|
37
|
+
* reconnects.
|
|
38
|
+
*
|
|
39
|
+
* @experimental New in 1.x and may change in a minor release: the options, the
|
|
40
|
+
* transport union and the event map are all still settling.
|
|
41
|
+
*/
|
|
42
|
+
export declare class QueryClient implements CommandExecutor, AsyncDisposable {
|
|
43
|
+
#private;
|
|
44
|
+
constructor(options: QueryClientOptions);
|
|
45
|
+
/** Where the client is in its connection's life. */
|
|
46
|
+
get status(): ClientStatus;
|
|
47
|
+
/**
|
|
48
|
+
* Which server generation the server is, read from its `version` answer.
|
|
49
|
+
* `"unknown"` before connecting.
|
|
50
|
+
*
|
|
51
|
+
* @experimental Part of the entry, which may change in a minor release.
|
|
52
|
+
*/
|
|
53
|
+
get serverFamily(): ServerFamily;
|
|
54
|
+
/** The `version` string the server answered with; "" before connecting. */
|
|
55
|
+
get serverVersion(): string;
|
|
56
|
+
/**
|
|
57
|
+
* The transport carrying this connection, or `undefined` when there is none.
|
|
58
|
+
*
|
|
59
|
+
* Read-only, and the transport is the interface the client itself talks
|
|
60
|
+
* over — counts of what went out and came in, and which connection it is,
|
|
61
|
+
* can be read from it for metrics. The socket underneath is not exposed:
|
|
62
|
+
* a caller that needs it supplies the seam instead (the `connect` option of
|
|
63
|
+
* a `tcp` transport, or `connection` of an `ssh` one), where it is theirs to
|
|
64
|
+
* keep.
|
|
65
|
+
*
|
|
66
|
+
* @experimental Part of the entry, which may change in a minor release.
|
|
67
|
+
*/
|
|
68
|
+
get transport(): QueryTransport | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* The notification categories this connection registered for: what `events`
|
|
71
|
+
* asked for, and empty when the transport delivers no notifications or the
|
|
72
|
+
* client is not connected.
|
|
73
|
+
*/
|
|
74
|
+
get eventCategories(): readonly QueryEventCategory[];
|
|
75
|
+
/**
|
|
76
|
+
* Connect and set the session up: open the transport, then `login` (raw TCP
|
|
77
|
+
* only), `use`, `version`, the notification registrations, and one client
|
|
78
|
+
* list.
|
|
79
|
+
*
|
|
80
|
+
* The `login` and `server` options are applied here rather than left to the
|
|
81
|
+
* caller so that a reconnection is the same session as the first connection
|
|
82
|
+
* was.
|
|
83
|
+
*
|
|
84
|
+
* A failure rejects with its cause and leaves the client disconnected; the
|
|
85
|
+
* transport it opened is closed. `signal` bounds only the connecting: once
|
|
86
|
+
* this resolves, the connection lasts until `disconnect()` or a drop.
|
|
87
|
+
* `connect()` does not retry itself; the `reconnect` option retries a
|
|
88
|
+
* connection that dropped after it was established.
|
|
89
|
+
*
|
|
90
|
+
* `connected` is delivered before this resolves, so a listener added after
|
|
91
|
+
* `await client.connect()` has missed it — add the listeners first.
|
|
92
|
+
*/
|
|
93
|
+
connect(options?: {
|
|
94
|
+
readonly signal?: AbortSignal | undefined;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Leave the server and close the connection.
|
|
98
|
+
*
|
|
99
|
+
* A `connect()` still in flight fails with a NotConnectedError, and so do
|
|
100
|
+
* the commands still waiting for an answer. Resolves once `disconnected` has
|
|
101
|
+
* been delivered, so a listener added after `await client.disconnect()` does
|
|
102
|
+
* not hear it. Does nothing on a client that is not connected; called again
|
|
103
|
+
* while an earlier call is still running, it waits for that one. An explicit
|
|
104
|
+
* `disconnect()` never reconnects.
|
|
105
|
+
*/
|
|
106
|
+
disconnect(): Promise<void>;
|
|
107
|
+
/** `await using client = …` disconnects when the scope ends. */
|
|
108
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Send a typed command. Passwords go as they are: ServerQuery takes the
|
|
111
|
+
* password itself and hashes it server-side, where the voice protocol wants
|
|
112
|
+
* the hash.
|
|
113
|
+
*/
|
|
114
|
+
send(request: CommandRequest, options?: CommandOptions): Promise<Array<Record<string, string>>>;
|
|
115
|
+
/** Send a raw command line and return the rows that answer it. */
|
|
116
|
+
exec(line: string, options?: CommandOptions): Promise<Array<Record<string, string>>>;
|
|
117
|
+
/**
|
|
118
|
+
* Log in with a query account. Over WebQuery the api key does this, and the
|
|
119
|
+
* server refuses the command; over SSH the session is logged in already.
|
|
120
|
+
*
|
|
121
|
+
* Public because a caller driving the client by hand needs it: `connect()`
|
|
122
|
+
* runs it from the `login` option, and this is the same `login` command.
|
|
123
|
+
*/
|
|
124
|
+
login(name: string, password: string, options?: CommandOptions): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Select the virtual server the following commands address, by id or by
|
|
127
|
+
* voice port. `nickname` names the query client on it.
|
|
128
|
+
*
|
|
129
|
+
* Public for the same reason as {@link QueryClient.login}: `connect()` runs
|
|
130
|
+
* it from the `server` option, and this is the same `use` command. Over
|
|
131
|
+
* WebQuery the transport answers it, by addressing that server from then on.
|
|
132
|
+
*/
|
|
133
|
+
use(server: {
|
|
134
|
+
readonly id: ServerID | number;
|
|
135
|
+
} | {
|
|
136
|
+
readonly port: number;
|
|
137
|
+
}, options?: CommandOptions & {
|
|
138
|
+
readonly nickname?: string | undefined;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Ask the server for the notifications of one category: `server`, `channel`
|
|
142
|
+
* (for one channel, or `0` for all), `textserver`, `textchannel`,
|
|
143
|
+
* `textprivate`, and on TeamSpeak 6 `bans`.
|
|
144
|
+
*
|
|
145
|
+
* Public for the same reason as {@link QueryClient.login}: `connect()` runs
|
|
146
|
+
* it once per configured category. With the WebQuery transport there is
|
|
147
|
+
* nothing to register for and the server refuses it, so the client never
|
|
148
|
+
* calls it there, and neither should a caller.
|
|
149
|
+
*/
|
|
150
|
+
registerNotifications(event: QueryEventCategory, channelID?: bigint | number, options?: CommandOptions): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Listen for an event. Returns a function that removes the listener, which is
|
|
153
|
+
* also a `Disposable` (`using stop = client.on(...)`).
|
|
154
|
+
*
|
|
155
|
+
* ```ts
|
|
156
|
+
* client.on("textMessage", (message) => console.log(message.message));
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* A listener that throws does not stop the others: the rest of the event's
|
|
160
|
+
* listeners, and the events after it, are still delivered, and the exception
|
|
161
|
+
* is rethrown on its own, from a microtask, so it surfaces as an
|
|
162
|
+
* `uncaughtException` just as an EventEmitter listener's would.
|
|
163
|
+
*
|
|
164
|
+
* With the WebQuery transport no server event can ever arrive, so this throws
|
|
165
|
+
* a `TypeError` for one rather than accepting a listener that would never
|
|
166
|
+
* run. `connected` and `disconnected` are still accepted: they come from the
|
|
167
|
+
* client, not the server.
|
|
168
|
+
*/
|
|
169
|
+
on<K extends keyof QueryEventMap>(event: K, listener: Listener<QueryEventMap, K>): Unsubscribe;
|
|
170
|
+
/** Listen for the next occurrence of an event only. */
|
|
171
|
+
once<K extends keyof QueryEventMap>(event: K, listener: Listener<QueryEventMap, K>): Unsubscribe;
|
|
172
|
+
/**
|
|
173
|
+
* An event as an async iterator, for `for await`:
|
|
174
|
+
*
|
|
175
|
+
* ```ts
|
|
176
|
+
* for await (const message of client.events("textMessage")) { … }
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* Events that arrive while the loop body runs are buffered, so none is
|
|
180
|
+
* missed. The buffer is unbounded: an iterator that is not consumed as fast
|
|
181
|
+
* as events arrive holds every one of them, so stop iterating (or abort
|
|
182
|
+
* `signal`) when you stop reading.
|
|
183
|
+
*
|
|
184
|
+
* Iteration ends when the loop exits early (`break`, `return`, a throw), and
|
|
185
|
+
* — for every event but `disconnected` — when the client disconnects. When
|
|
186
|
+
* `signal` aborts, listening stops at once, whatever is buffered is
|
|
187
|
+
* discarded, and the pending and every later `next()` reject with the
|
|
188
|
+
* signal's reason.
|
|
189
|
+
*/
|
|
190
|
+
events<K extends keyof QueryEventMap>(event: K, options?: {
|
|
191
|
+
readonly signal?: AbortSignal | undefined;
|
|
192
|
+
}): AsyncIterableIterator<QueryEventMap[K]>;
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/query/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAUZ,KAAK,eAAe,EAEpB,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,QAAQ,EAGb,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,k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