@honeybbq/teamspeak 1.0.0-beta.13 → 1.0.0-beta.15

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 (152) hide show
  1. package/README.md +321 -6
  2. package/dist/client/api/files.d.ts +89 -0
  3. package/dist/client/api/files.d.ts.map +1 -0
  4. package/dist/client/api/files.js +125 -0
  5. package/dist/client/api/files.js.map +1 -0
  6. package/dist/client/client.d.ts +2 -2
  7. package/dist/client/client.d.ts.map +1 -1
  8. package/dist/client/client.js.map +1 -1
  9. package/dist/client/commands.d.ts.map +1 -1
  10. package/dist/client/commands.js +5 -1
  11. package/dist/client/commands.js.map +1 -1
  12. package/dist/client/index.d.ts +2 -1
  13. package/dist/client/index.d.ts.map +1 -1
  14. package/dist/client/index.js +2 -1
  15. package/dist/client/index.js.map +1 -1
  16. package/dist/client/transport/generation-window.d.ts +6 -0
  17. package/dist/client/transport/generation-window.d.ts.map +1 -1
  18. package/dist/client/transport/generation-window.js +11 -0
  19. package/dist/client/transport/generation-window.js.map +1 -1
  20. package/dist/client/transport/handler.d.ts.map +1 -1
  21. package/dist/client/transport/handler.js +31 -1
  22. package/dist/client/transport/handler.js.map +1 -1
  23. package/dist/core/api/channels.d.ts +63 -8
  24. package/dist/core/api/channels.d.ts.map +1 -1
  25. package/dist/core/api/channels.js +74 -8
  26. package/dist/core/api/channels.js.map +1 -1
  27. package/dist/core/api/clients.d.ts +87 -1
  28. package/dist/core/api/clients.d.ts.map +1 -1
  29. package/dist/core/api/clients.js +95 -1
  30. package/dist/core/api/clients.js.map +1 -1
  31. package/dist/core/api/command.d.ts +51 -8
  32. package/dist/core/api/command.d.ts.map +1 -1
  33. package/dist/core/api/command.js +37 -8
  34. package/dist/core/api/command.js.map +1 -1
  35. package/dist/core/api/credentials.d.ts +3 -2
  36. package/dist/core/api/credentials.d.ts.map +1 -1
  37. package/dist/core/api/credentials.js +3 -2
  38. package/dist/core/api/credentials.js.map +1 -1
  39. package/dist/core/api/files.d.ts +47 -2
  40. package/dist/core/api/files.d.ts.map +1 -1
  41. package/dist/core/api/files.js +54 -2
  42. package/dist/core/api/files.js.map +1 -1
  43. package/dist/core/api/groups.d.ts +49 -11
  44. package/dist/core/api/groups.d.ts.map +1 -1
  45. package/dist/core/api/groups.js +53 -11
  46. package/dist/core/api/groups.js.map +1 -1
  47. package/dist/core/api/moderation.d.ts +36 -2
  48. package/dist/core/api/moderation.d.ts.map +1 -1
  49. package/dist/core/api/moderation.js +36 -3
  50. package/dist/core/api/moderation.js.map +1 -1
  51. package/dist/core/api/server.d.ts +112 -7
  52. package/dist/core/api/server.d.ts.map +1 -1
  53. package/dist/core/api/server.js +123 -7
  54. package/dist/core/api/server.js.map +1 -1
  55. package/dist/core/command/responses.d.ts +8 -3
  56. package/dist/core/command/responses.d.ts.map +1 -1
  57. package/dist/core/command/responses.js +11 -3
  58. package/dist/core/command/responses.js.map +1 -1
  59. package/dist/core/command-name.d.ts +12 -0
  60. package/dist/core/command-name.d.ts.map +1 -1
  61. package/dist/core/command-name.js +12 -0
  62. package/dist/core/command-name.js.map +1 -1
  63. package/dist/core/errorcode.d.ts +8 -0
  64. package/dist/core/errorcode.d.ts.map +1 -1
  65. package/dist/core/errorcode.js +8 -0
  66. package/dist/core/errorcode.js.map +1 -1
  67. package/dist/core/errors.d.ts +7 -6
  68. package/dist/core/errors.d.ts.map +1 -1
  69. package/dist/core/errors.js +7 -6
  70. package/dist/core/errors.js.map +1 -1
  71. package/dist/core/index.d.ts +1 -1
  72. package/dist/core/index.d.ts.map +1 -1
  73. package/dist/core/index.js.map +1 -1
  74. package/dist/core/notification-name.d.ts +16 -0
  75. package/dist/core/notification-name.d.ts.map +1 -1
  76. package/dist/core/notification-name.js +16 -0
  77. package/dist/core/notification-name.js.map +1 -1
  78. package/dist/query/client.d.ts.map +1 -1
  79. package/dist/query/client.js +85 -11
  80. package/dist/query/client.js.map +1 -1
  81. package/dist/query/late-rows.d.ts +33 -0
  82. package/dist/query/late-rows.d.ts.map +1 -0
  83. package/dist/query/late-rows.js +51 -0
  84. package/dist/query/late-rows.js.map +1 -0
  85. package/dist/stream/emitter.d.ts +18 -0
  86. package/dist/stream/emitter.d.ts.map +1 -0
  87. package/dist/stream/emitter.js +66 -0
  88. package/dist/stream/emitter.js.map +1 -0
  89. package/dist/stream/errors.d.ts +73 -0
  90. package/dist/stream/errors.d.ts.map +1 -0
  91. package/dist/stream/errors.js +128 -0
  92. package/dist/stream/errors.js.map +1 -0
  93. package/dist/stream/index.d.ts +27 -0
  94. package/dist/stream/index.d.ts.map +1 -0
  95. package/dist/stream/index.js +26 -0
  96. package/dist/stream/index.js.map +1 -0
  97. package/dist/stream/peer.d.ts +43 -0
  98. package/dist/stream/peer.d.ts.map +1 -0
  99. package/dist/stream/peer.js +100 -0
  100. package/dist/stream/peer.js.map +1 -0
  101. package/dist/stream/published.d.ts +54 -0
  102. package/dist/stream/published.d.ts.map +1 -0
  103. package/dist/stream/published.js +205 -0
  104. package/dist/stream/published.js.map +1 -0
  105. package/dist/stream/streams.d.ts +92 -0
  106. package/dist/stream/streams.d.ts.map +1 -0
  107. package/dist/stream/streams.js +671 -0
  108. package/dist/stream/streams.js.map +1 -0
  109. package/dist/stream/types.d.ts +428 -0
  110. package/dist/stream/types.d.ts.map +1 -0
  111. package/dist/stream/types.js +2 -0
  112. package/dist/stream/types.js.map +1 -0
  113. package/dist/stream/wait.d.ts +14 -0
  114. package/dist/stream/wait.d.ts.map +1 -0
  115. package/dist/stream/wait.js +46 -0
  116. package/dist/stream/wait.js.map +1 -0
  117. package/dist/stream/wire.d.ts +91 -0
  118. package/dist/stream/wire.d.ts.map +1 -0
  119. package/dist/stream/wire.js +248 -0
  120. package/dist/stream/wire.js.map +1 -0
  121. package/package.json +13 -6
  122. package/src/client/api/files.ts +249 -0
  123. package/src/client/client.ts +2 -2
  124. package/src/client/commands.ts +4 -1
  125. package/src/client/index.ts +2 -1
  126. package/src/client/transport/generation-window.ts +11 -0
  127. package/src/client/transport/handler.ts +28 -2
  128. package/src/core/api/channels.ts +132 -8
  129. package/src/core/api/clients.ts +167 -1
  130. package/src/core/api/command.ts +85 -8
  131. package/src/core/api/credentials.ts +3 -2
  132. package/src/core/api/files.ts +80 -2
  133. package/src/core/api/groups.ts +85 -11
  134. package/src/core/api/moderation.ts +52 -3
  135. package/src/core/api/server.ts +212 -7
  136. package/src/core/command/responses.ts +14 -3
  137. package/src/core/command-name.ts +12 -0
  138. package/src/core/errorcode.ts +8 -0
  139. package/src/core/errors.ts +7 -6
  140. package/src/core/index.ts +8 -1
  141. package/src/core/notification-name.ts +16 -0
  142. package/src/query/client.ts +91 -10
  143. package/src/query/late-rows.ts +66 -0
  144. package/src/stream/emitter.ts +73 -0
  145. package/src/stream/errors.ts +146 -0
  146. package/src/stream/index.ts +58 -0
  147. package/src/stream/peer.ts +141 -0
  148. package/src/stream/published.ts +254 -0
  149. package/src/stream/streams.ts +765 -0
  150. package/src/stream/types.ts +475 -0
  151. package/src/stream/wait.ts +62 -0
  152. package/src/stream/wire.ts +319 -0
@@ -0,0 +1,128 @@
1
+ import { TeamspeakError } from "@honeybbq/teamspeak";
2
+ /**
3
+ * The connected server does not do streams: only TeamSpeak 6 does. A
4
+ * TeamSpeak 3 server answers none of the stream commands, not even with an
5
+ * error, so `publish` and `watch` refuse before sending rather than wait out
6
+ * a timeout.
7
+ *
8
+ * @beta
9
+ */
10
+ export class StreamsUnsupportedError extends TeamspeakError {
11
+ /** {@inheritDoc @honeybbq/teamspeak!TeamspeakError.kind} */
12
+ static kind = "StreamsUnsupportedError";
13
+ static {
14
+ // On the prototype, not the instance, as built-in errors do: an own `name`
15
+ // would be enumerable and show up in JSON.stringify and object spread.
16
+ Object.defineProperty(this.prototype, "name", {
17
+ value: "StreamsUnsupportedError",
18
+ writable: true,
19
+ configurable: true,
20
+ enumerable: false,
21
+ });
22
+ }
23
+ /** The server generation the client found: never `"ts6"`. */
24
+ family;
25
+ /** The `virtualserver_version` the server sent; empty before the client has connected. */
26
+ version;
27
+ constructor(family, version) {
28
+ super(`streams need a TeamSpeak 6 server; this is ${family === "unknown" ? "an unknown server" : family}${version === "" ? "" : ` (${version})`}`);
29
+ this.family = family;
30
+ this.version = version;
31
+ }
32
+ }
33
+ /**
34
+ * The stream's owner refused a request to watch it. `watch` rejects with it.
35
+ *
36
+ * The server remembers no decision, so a client can ask again, and every ask
37
+ * is relayed to the publisher. A publisher that means to refuse for good can
38
+ * set `rememberDenied`, or leave the request unanswered.
39
+ *
40
+ * @beta
41
+ */
42
+ export class StreamJoinDeniedError extends TeamspeakError {
43
+ /** {@inheritDoc @honeybbq/teamspeak!TeamspeakError.kind} */
44
+ static kind = "StreamJoinDeniedError";
45
+ static {
46
+ // On the prototype, not the instance, as built-in errors do: an own `name`
47
+ // would be enumerable and show up in JSON.stringify and object spread.
48
+ Object.defineProperty(this.prototype, "name", {
49
+ value: "StreamJoinDeniedError",
50
+ writable: true,
51
+ configurable: true,
52
+ enumerable: false,
53
+ });
54
+ }
55
+ /** The stream that was asked for. */
56
+ streamId;
57
+ /** The message the owner gave with the refusal; empty for none. */
58
+ serverMessage;
59
+ constructor(streamId, message) {
60
+ super(`the stream's owner denied the request to watch it${message === "" ? "" : `: ${message}`}`);
61
+ this.streamId = streamId;
62
+ this.serverMessage = message;
63
+ }
64
+ }
65
+ /**
66
+ * A stream command is too long for the server to take. It drops a command
67
+ * line of about 9.2 KB, escaped, without an answer, so the call fails before
68
+ * sending instead of timing out; `MAX_COMMAND_LINE_BYTES` has the exact
69
+ * figure. An SDP offer of a few kilobytes is far under it.
70
+ *
71
+ * @beta
72
+ */
73
+ export class StreamPayloadTooLargeError extends TeamspeakError {
74
+ /** {@inheritDoc @honeybbq/teamspeak!TeamspeakError.kind} */
75
+ static kind = "StreamPayloadTooLargeError";
76
+ static {
77
+ // On the prototype, not the instance, as built-in errors do: an own `name`
78
+ // would be enumerable and show up in JSON.stringify and object spread.
79
+ Object.defineProperty(this.prototype, "name", {
80
+ value: "StreamPayloadTooLargeError",
81
+ writable: true,
82
+ configurable: true,
83
+ enumerable: false,
84
+ });
85
+ }
86
+ /** The command that would have been sent. */
87
+ command;
88
+ /** The size of its line on the wire, escaped, in bytes. */
89
+ size;
90
+ /** The largest line this SDK sends. */
91
+ limit;
92
+ constructor(command, size, limit) {
93
+ super(`${command} is ${size} bytes escaped; the server takes at most ${limit}`);
94
+ this.command = command;
95
+ this.size = size;
96
+ this.limit = limit;
97
+ }
98
+ }
99
+ /**
100
+ * The stream is gone: it ended, or its id is not one this client knows or the
101
+ * server does (error 5635). `watch` rejects with it for an id it has not heard
102
+ * of, and when the stream ends before its owner answers; a signalling call
103
+ * does when the stream ended under it. The server's
104
+ * own refusal, when there was one, is the `cause`.
105
+ *
106
+ * @beta
107
+ */
108
+ export class StreamEndedError extends TeamspeakError {
109
+ /** {@inheritDoc @honeybbq/teamspeak!TeamspeakError.kind} */
110
+ static kind = "StreamEndedError";
111
+ static {
112
+ // On the prototype, not the instance, as built-in errors do: an own `name`
113
+ // would be enumerable and show up in JSON.stringify and object spread.
114
+ Object.defineProperty(this.prototype, "name", {
115
+ value: "StreamEndedError",
116
+ writable: true,
117
+ configurable: true,
118
+ enumerable: false,
119
+ });
120
+ }
121
+ /** The stream that ended. */
122
+ streamId;
123
+ constructor(streamId, options) {
124
+ super(`stream ${streamId} has ended, or is not known`, options);
125
+ this.streamId = streamId;
126
+ }
127
+ }
128
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/stream/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD,4DAA4D;IAC5D,MAAM,CAAmB,IAAI,GAAW,yBAAyB,CAAC;IAClE;QACE,2EAA2E;QAC3E,uEAAuE;QACvE,MAAM,CAAC,cAAc,CAAC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,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * TeamSpeak 6 streams, the screen share: finding the streams of the clients in
3
+ * view, publishing one, and watching one.
4
+ *
5
+ * TeamSpeak does not document the protocol, and it has been measured against
6
+ * TeamSpeak 6 6.0.0-beta13.1 and not yet against the native client, so
7
+ * everything here is `@beta` and may change in a minor release.
8
+ *
9
+ * Only the signalling is in this package. The video itself travels over WebRTC
10
+ * between the publisher and each viewer, which the application brings: SDP and
11
+ * ICE candidates are strings here, handed to and taken from any WebRTC stack.
12
+ * There is no WebRTC dependency.
13
+ *
14
+ * ```ts
15
+ * import { Streams } from "@honeybbq/teamspeak/stream";
16
+ *
17
+ * const streams = new Streams(client);
18
+ * const view = await streams.watch(streamId);
19
+ * ```
20
+ *
21
+ * @module @honeybbq/teamspeak/stream
22
+ * @beta
23
+ */
24
+ export { Streams } from "./streams.js";
25
+ export { StreamEndedError, StreamJoinDeniedError, StreamPayloadTooLargeError, StreamsUnsupportedError, } from "./errors.js";
26
+ export type { IceCandidate, JoinRequest, JoinRequestState, Peer, PeerClosed, PeerCloseCause, PeerEvents, PublishedStream, PublishedStreamEvents, PublishOptions, RawSignal, StreamAccessibility, StreamEnded, StreamEndCause, StreamInfo, StreamsClient, StreamsEventMap, StreamsOptions, StreamSource, StreamStoppedEvent, StreamView, StreamViewerEvent, ViewerIdentity, ViewerPeer, WatchOptions, } from "./types.js";
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stream/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * TeamSpeak 6 streams, the screen share: finding the streams of the clients in
3
+ * view, publishing one, and watching one.
4
+ *
5
+ * TeamSpeak does not document the protocol, and it has been measured against
6
+ * TeamSpeak 6 6.0.0-beta13.1 and not yet against the native client, so
7
+ * everything here is `@beta` and may change in a minor release.
8
+ *
9
+ * Only the signalling is in this package. The video itself travels over WebRTC
10
+ * between the publisher and each viewer, which the application brings: SDP and
11
+ * ICE candidates are strings here, handed to and taken from any WebRTC stack.
12
+ * There is no WebRTC dependency.
13
+ *
14
+ * ```ts
15
+ * import { Streams } from "@honeybbq/teamspeak/stream";
16
+ *
17
+ * const streams = new Streams(client);
18
+ * const view = await streams.watch(streamId);
19
+ * ```
20
+ *
21
+ * @module @honeybbq/teamspeak/stream
22
+ * @beta
23
+ */
24
+ export { Streams } from "./streams.js";
25
+ export { StreamEndedError, StreamJoinDeniedError, StreamPayloadTooLargeError, StreamsUnsupportedError, } from "./errors.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stream/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { ClientID, Unsubscribe } from "@honeybbq/teamspeak";
2
+ import type { IceCandidate, Peer, PeerClosed, PeerEvents, StreamView, ViewerPeer } from "./types.js";
3
+ /** What a peer needs of the `Streams` that made it. */
4
+ export interface PeerLink {
5
+ /** Send a signalling JSON to the other end. */
6
+ sendJson(json: string): Promise<void>;
7
+ /** Tell the server this end is leaving; absent where there is nothing to tell. */
8
+ leave?(): Promise<void>;
9
+ /** The peer closed, whoever closed it. */
10
+ closed(peer: PeerImpl): void;
11
+ /** Something happened that nobody awaits, such as an event dropped for want of a listener. */
12
+ report(error: Error): void;
13
+ }
14
+ /** One end of a stream's signalling with one other client. */
15
+ export declare class PeerImpl implements Peer {
16
+ #private;
17
+ readonly streamId: string;
18
+ readonly clientId: ClientID;
19
+ constructor(streamId: string, clientId: ClientID, link: PeerLink);
20
+ get closed(): boolean;
21
+ on<K extends keyof PeerEvents>(event: K, listener: (payload: PeerEvents[K]) => void): Unsubscribe;
22
+ sendCandidate(candidate: IceCandidate): Promise<void>;
23
+ sendSignal(cmd: string, args: unknown): Promise<void>;
24
+ close(): Promise<void>;
25
+ /** Send a message of the subclasses'. */
26
+ protected send(json: string): Promise<void>;
27
+ /** A signalling JSON from the other end. */
28
+ deliver(json: string): void;
29
+ /** Close without telling the server, once. */
30
+ end(closed: PeerClosed): void;
31
+ }
32
+ /** The publisher's end for one accepted viewer. */
33
+ export declare class ViewerPeerImpl extends PeerImpl implements ViewerPeer {
34
+ sendOffer(sdp: string): Promise<void>;
35
+ }
36
+ /** The viewer's end of a stream it was let into. */
37
+ export declare class StreamViewImpl extends PeerImpl implements StreamView {
38
+ readonly offer: string;
39
+ constructor(streamId: string, streamer: ClientID, offer: string, link: PeerLink);
40
+ answer(sdp: string): Promise<void>;
41
+ leave(): Promise<void>;
42
+ }
43
+ //# sourceMappingURL=peer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../src/stream/peer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,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1C;IAOD,4CAA4C;IAC5C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAiB1B;IAED,8CAA8C;IAC9C,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAK5B;CACF;AAED,mDAAmD;AACnD,qBAAa,cAAe,SAAQ,QAAS,YAAW,UAAU;IAChE,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpC;CACF;AAED,oDAAoD;AACpD,qBAAa,cAAe,SAAQ,QAAS,YAAW,UAAU;IAChE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAG9E;IAED,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjC;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;CACF"}
@@ -0,0 +1,100 @@
1
+ import { TeamspeakError } from "@honeybbq/teamspeak";
2
+ import { Emitter, MAX_KEPT } from "./emitter.js";
3
+ import { answerJson, candidateJson, encodeSignal, offerJson, parseSignal } from "./wire.js";
4
+ /** One end of a stream's signalling with one other client. */
5
+ export class PeerImpl {
6
+ streamId;
7
+ clientId;
8
+ #link;
9
+ #closed = false;
10
+ #emitter;
11
+ constructor(streamId, clientId, link) {
12
+ this.streamId = streamId;
13
+ this.clientId = clientId;
14
+ this.#link = link;
15
+ let reported = false;
16
+ this.#emitter = new Emitter(["offer", "answer", "candidate", "signal", "closed"], (event) => {
17
+ // Once for the peer, not for every message past the bound.
18
+ if (reported)
19
+ return;
20
+ reported = true;
21
+ link.report(new TeamspeakError(`stream ${streamId}: dropping the oldest ${event} from client ${clientId}: ${MAX_KEPT} are waiting for a listener`));
22
+ });
23
+ }
24
+ get closed() {
25
+ return this.#closed;
26
+ }
27
+ on(event, listener) {
28
+ return this.#emitter.on(event, listener);
29
+ }
30
+ sendCandidate(candidate) {
31
+ return this.#send(() => candidateJson(candidate));
32
+ }
33
+ sendSignal(cmd, args) {
34
+ return this.#send(() => encodeSignal(cmd, args));
35
+ }
36
+ async close() {
37
+ if (this.#closed)
38
+ return;
39
+ this.end({ cause: "closed" });
40
+ await this.#link.leave?.();
41
+ }
42
+ /** Send a message of the subclasses'. */
43
+ send(json) {
44
+ return this.#send(() => json);
45
+ }
46
+ async #send(json) {
47
+ if (this.#closed)
48
+ throw new TeamspeakError("the peer is closed");
49
+ await this.#link.sendJson(json());
50
+ }
51
+ /** A signalling JSON from the other end. */
52
+ deliver(json) {
53
+ if (this.#closed)
54
+ return;
55
+ const signal = parseSignal(json);
56
+ switch (signal.kind) {
57
+ case "offer":
58
+ this.#emitter.emit("offer", signal.sdp);
59
+ break;
60
+ case "answer":
61
+ this.#emitter.emit("answer", signal.sdp);
62
+ break;
63
+ case "candidate":
64
+ this.#emitter.emit("candidate", signal.candidate);
65
+ break;
66
+ case "raw":
67
+ this.#emitter.emit("signal", signal.signal);
68
+ break;
69
+ }
70
+ }
71
+ /** Close without telling the server, once. */
72
+ end(closed) {
73
+ if (this.#closed)
74
+ return;
75
+ this.#closed = true;
76
+ this.#link.closed(this);
77
+ this.#emitter.emit("closed", closed);
78
+ }
79
+ }
80
+ /** The publisher's end for one accepted viewer. */
81
+ export class ViewerPeerImpl extends PeerImpl {
82
+ sendOffer(sdp) {
83
+ return this.send(offerJson(sdp));
84
+ }
85
+ }
86
+ /** The viewer's end of a stream it was let into. */
87
+ export class StreamViewImpl extends PeerImpl {
88
+ offer;
89
+ constructor(streamId, streamer, offer, link) {
90
+ super(streamId, streamer, link);
91
+ this.offer = offer;
92
+ }
93
+ answer(sdp) {
94
+ return this.send(answerJson(sdp));
95
+ }
96
+ leave() {
97
+ return this.close();
98
+ }
99
+ }
100
+ //# sourceMappingURL=peer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"peer.js","sourceRoot":"","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C,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;gBAClD,MAAM;YACR,KAAK,KAAK;gBACR,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC5C,MAAM;QACV,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,GAAG,CAAC,MAAkB;QACpB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;CACF;AAED,mDAAmD;AACnD,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,SAAS,CAAC,GAAW;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AAED,oDAAoD;AACpD,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACjC,KAAK,CAAS;IAEvB,YAAY,QAAgB,EAAE,QAAkB,EAAE,KAAa,EAAE,IAAc;QAC7E,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,54 @@
1
+ import type { ClientID, CommandRequest, Unsubscribe } from "@honeybbq/teamspeak";
2
+ import { ViewerPeerImpl } from "./peer.js";
3
+ import type { PublishedStream, PublishedStreamEvents, StreamEnded, StreamInfo, ViewerIdentity, ViewerPeer } from "./types.js";
4
+ /** What a published stream needs of the `Streams` that made it. */
5
+ export interface PublishHost {
6
+ /**
7
+ * The viewer's identity: from the clients in view when it is one, else asked
8
+ * of the server; as far as that goes.
9
+ */
10
+ identity(clientId: ClientID): ViewerIdentity | Promise<ViewerIdentity>;
11
+ /** Report a failure nobody awaits. */
12
+ report(error: Error): void;
13
+ /** Whether a viewer was denied and is to be left unanswered. */
14
+ isDenied(identity: ViewerIdentity): boolean;
15
+ /** Note that a viewer was denied. */
16
+ remember(identity: ViewerIdentity): void;
17
+ /** Send a stream command; a stream the server does not know is a StreamEndedError. */
18
+ send(request: CommandRequest, streamId: string): Promise<void>;
19
+ /** Send `stopstream` for a stream of this client's; a stream already gone is not an error. */
20
+ stop(streamId: string, reason: number): Promise<void>;
21
+ /** What is known of the stream now. */
22
+ info(streamId: string): StreamInfo | undefined;
23
+ /** End the stream here and say so, for `stop()`. */
24
+ stopped(streamId: string, reason: number): void;
25
+ }
26
+ /** A stream this client publishes. */
27
+ export declare class PublishedImpl implements PublishedStream {
28
+ #private;
29
+ readonly id: string;
30
+ readonly host: PublishHost;
31
+ constructor(info: StreamInfo, host: PublishHost);
32
+ get info(): StreamInfo;
33
+ get ended(): boolean;
34
+ on<K extends keyof PublishedStreamEvents>(event: K, listener: (payload: PublishedStreamEvents[K]) => void): Unsubscribe;
35
+ viewers(): readonly ViewerPeer[];
36
+ stop(reason?: number): Promise<void>;
37
+ /** The peer for a viewer this stream let in. */
38
+ openViewer(clientId: ClientID): ViewerPeerImpl;
39
+ /** A viewer asked to watch. */
40
+ request(clientId: ClientID, message: string): void;
41
+ /** The client left view: a request of its that nobody answered is forgotten, as the clid may be reused. */
42
+ dropPending(clientId: ClientID): void;
43
+ /** A viewer is gone, by saying so or by disconnecting. */
44
+ viewerGone(clientId: ClientID): void;
45
+ /**
46
+ * A signalling JSON from a viewer; false when this stream has no such
47
+ * viewer. A viewer whose peer is over is answered true and ignored: the
48
+ * server cannot remove a viewer, so it may keep sending.
49
+ */
50
+ signal(clientId: ClientID, json: string): boolean;
51
+ /** The stream is over: close everything that hangs on it, once. */
52
+ finish(ended: StreamEnded): void;
53
+ }
54
+ //# sourceMappingURL=published.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"published.d.ts","sourceRoot":"","sources":["../../src/stream/published.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEjF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAGV,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACvE,sCAAsC;IACtC,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,sFAAsF;IACtF,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,8FAA8F;IAC9F,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,uCAAuC;IACvC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAC/C,oDAAoD;IACpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACjD;AAqED,sCAAsC;AACtC,qBAAa,aAAc,YAAW,eAAe;;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAc3B,YAAY,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAc9C;IAED,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,EAAE,CAAC,CAAC,SAAS,MAAM,qBAAqB,EACtC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,IAAI,GACpD,WAAW,CAEb;IAED,OAAO,IAAI,SAAS,UAAU,EAAE,CAE/B;IAEK,IAAI,CAAC,MAAM,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAOpC;IAED,gDAAgD;IAChD,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAiB7C;IAED,+BAA+B;IAC/B,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAwBjD;IAED,2GAA2G;IAC3G,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAIpC;IAED,0DAA0D;IAC1D,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAGnC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKhD;IAED,mEAAmE;IACnE,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAW/B;CACF"}
@@ -0,0 +1,205 @@
1
+ import { TeamspeakError } from "@honeybbq/teamspeak";
2
+ import { Emitter, MAX_KEPT } from "./emitter.js";
3
+ import { ViewerPeerImpl } from "./peer.js";
4
+ import { assertFits, respondRequest, signalRequest } from "./wire.js";
5
+ class JoinRequestImpl {
6
+ streamId;
7
+ viewer;
8
+ message;
9
+ #state = "pending";
10
+ #stream;
11
+ constructor(stream, viewer, message) {
12
+ this.#stream = stream;
13
+ this.streamId = stream.id;
14
+ this.viewer = viewer;
15
+ this.message = message;
16
+ }
17
+ get state() {
18
+ return this.#state;
19
+ }
20
+ /** The request will not be answered: the viewer withdrew it, or the stream ended. */
21
+ close(state) {
22
+ if (this.#state === "pending")
23
+ this.#state = state;
24
+ }
25
+ #assertPending() {
26
+ if (this.#state !== "pending") {
27
+ throw new TeamspeakError(`the request cannot be answered: it is ${this.#state}`);
28
+ }
29
+ }
30
+ async accept(offer, message = "") {
31
+ if (typeof offer !== "string" || offer === "") {
32
+ throw new RangeError("the offer must be a non-empty SDP string");
33
+ }
34
+ this.#assertPending();
35
+ const request = respondRequest(this.streamId, this.viewer.clientId, message, offer, true);
36
+ // Before the request is used up: a too long offer may be shortened and tried again.
37
+ assertFits(request);
38
+ this.#state = "accepted";
39
+ // Made before the offer goes out: the viewer answers, and the publisher's
40
+ // side starts sending candidates, as soon as it has the offer, and what
41
+ // arrives before this returns waits in the peer for its first listener.
42
+ const peer = this.#stream.openViewer(this.viewer.clientId);
43
+ try {
44
+ await this.#stream.host.send(request, this.streamId);
45
+ }
46
+ catch (error) {
47
+ this.#state = "failed";
48
+ peer.end({ cause: "closed" });
49
+ throw error;
50
+ }
51
+ return peer;
52
+ }
53
+ async deny(reason = "") {
54
+ this.#assertPending();
55
+ const request = respondRequest(this.streamId, this.viewer.clientId, reason, "", false);
56
+ assertFits(request);
57
+ this.#state = "denied";
58
+ try {
59
+ await this.#stream.host.send(request, this.streamId);
60
+ }
61
+ catch (error) {
62
+ this.#state = "failed";
63
+ throw error;
64
+ }
65
+ this.#stream.host.remember(this.viewer);
66
+ }
67
+ }
68
+ /** A stream this client publishes. */
69
+ export class PublishedImpl {
70
+ id;
71
+ host;
72
+ #initial;
73
+ #ended = false;
74
+ #emitter;
75
+ #peers = new Map();
76
+ #pending = new Map();
77
+ /** Viewers asked about, until the answer comes back, so that a repeat is no new request. */
78
+ #resolving = new Set();
79
+ /** Requests are announced in the order they came, whatever the lookups take. */
80
+ #announcing = Promise.resolve();
81
+ #lookups = 0;
82
+ /** Viewers whose peer is over: what they still send is not worth a report. */
83
+ #closedViewers = new Set();
84
+ constructor(info, host) {
85
+ this.id = info.id;
86
+ this.host = host;
87
+ this.#initial = info;
88
+ let reported = false;
89
+ this.#emitter = new Emitter(["request", "ended"], (event) => {
90
+ if (reported)
91
+ return;
92
+ reported = true;
93
+ host.report(new TeamspeakError(`stream ${info.id}: dropping the oldest ${event}: ${MAX_KEPT} are waiting for a listener`));
94
+ });
95
+ }
96
+ get info() {
97
+ return this.host.info(this.id) ?? this.#initial;
98
+ }
99
+ get ended() {
100
+ return this.#ended;
101
+ }
102
+ on(event, listener) {
103
+ return this.#emitter.on(event, listener);
104
+ }
105
+ viewers() {
106
+ return [...this.#peers.values()];
107
+ }
108
+ async stop(reason = 0) {
109
+ if (!Number.isSafeInteger(reason) || reason < 0 || reason > 0xffff_ffff) {
110
+ throw new RangeError("the stop reason must be an integer from 0 to 4294967295");
111
+ }
112
+ if (this.#ended)
113
+ return;
114
+ await this.host.stop(this.id, reason);
115
+ this.host.stopped(this.id, reason);
116
+ }
117
+ /** The peer for a viewer this stream let in. */
118
+ openViewer(clientId) {
119
+ const peer = new ViewerPeerImpl(this.id, clientId, {
120
+ sendJson: (json) => this.host.send(signalRequest(this.id, clientId, json), this.id),
121
+ closed: (closing) => {
122
+ if (this.#peers.get(clientId) !== closing)
123
+ return;
124
+ this.#peers.delete(clientId);
125
+ this.#closedViewers.add(clientId);
126
+ // Bounded: the oldest is forgotten first, and a forgotten one is merely reported again.
127
+ if (this.#closedViewers.size > 1024) {
128
+ this.#closedViewers.delete(this.#closedViewers.values().next().value);
129
+ }
130
+ },
131
+ report: (error) => this.host.report(error),
132
+ });
133
+ this.#closedViewers.delete(clientId);
134
+ this.#peers.set(clientId, peer);
135
+ return peer;
136
+ }
137
+ /** A viewer asked to watch. */
138
+ request(clientId, message) {
139
+ // Asking again while pending, being looked up or let in is no new request.
140
+ if (this.#ended || this.#peers.has(clientId) || this.#resolving.has(clientId))
141
+ return;
142
+ if (this.#pending.get(clientId)?.state === "pending")
143
+ return;
144
+ this.#resolving.add(clientId);
145
+ const identity = this.host.identity(clientId);
146
+ const announce = (viewer) => {
147
+ // Withdrawn, or the stream over, while the lookup was out.
148
+ if (!this.#resolving.delete(clientId) || this.#ended)
149
+ return;
150
+ if (this.host.isDenied(viewer))
151
+ return;
152
+ const request = new JoinRequestImpl(this, viewer, message);
153
+ this.#pending.set(clientId, request);
154
+ this.#emitter.emit("request", request);
155
+ };
156
+ // Nothing to wait for, and nothing ahead of it to wait for: at once.
157
+ if (!(identity instanceof Promise) && this.#lookups === 0) {
158
+ announce(identity);
159
+ return;
160
+ }
161
+ this.#lookups++;
162
+ this.#announcing = this.#announcing
163
+ .then(() => identity)
164
+ .then(announce)
165
+ .finally(() => this.#lookups--);
166
+ }
167
+ /** The client left view: a request of its that nobody answered is forgotten, as the clid may be reused. */
168
+ dropPending(clientId) {
169
+ this.#resolving.delete(clientId);
170
+ this.#pending.get(clientId)?.close("withdrawn");
171
+ this.#pending.delete(clientId);
172
+ }
173
+ /** A viewer is gone, by saying so or by disconnecting. */
174
+ viewerGone(clientId) {
175
+ this.dropPending(clientId);
176
+ this.#peers.get(clientId)?.end({ cause: "left" });
177
+ }
178
+ /**
179
+ * A signalling JSON from a viewer; false when this stream has no such
180
+ * viewer. A viewer whose peer is over is answered true and ignored: the
181
+ * server cannot remove a viewer, so it may keep sending.
182
+ */
183
+ signal(clientId, json) {
184
+ const peer = this.#peers.get(clientId);
185
+ if (peer === undefined)
186
+ return this.#closedViewers.has(clientId);
187
+ peer.deliver(json);
188
+ return true;
189
+ }
190
+ /** The stream is over: close everything that hangs on it, once. */
191
+ finish(ended) {
192
+ if (this.#ended)
193
+ return;
194
+ this.#ended = true;
195
+ for (const request of this.#pending.values())
196
+ request.close("ended");
197
+ this.#pending.clear();
198
+ const cause = ended.cause === "disconnected" || ended.cause === "disposed" ? ended.cause : "stopped";
199
+ for (const peer of this.#peers.values()) {
200
+ peer.end({ cause, ...(cause === "stopped" ? { reason: ended.reason } : {}) });
201
+ }
202
+ this.#emitter.emit("ended", ended);
203
+ }
204
+ }
205
+ //# sourceMappingURL=published.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"published.js","sourceRoot":"","sources":["../../src/stream/published.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAY3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAyBtE,MAAM,eAAe;IACV,QAAQ,CAAS;IACjB,MAAM,CAAiB;IACvB,OAAO,CAAS;IACzB,MAAM,GAAqB,SAAS,CAAC;IAC5B,OAAO,CAAgB;IAEhC,YAAY,MAAqB,EAAE,MAAsB,EAAE,OAAe;QACxE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,qFAAqF;IACrF,KAAK,CAAC,KAA4B;QAChC,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACrD,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,cAAc,CAAC,yCAAyC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACnF,CAAC;IACH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