@stoatx/voice-browser 0.0.0-stage → 1.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stoatx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # @stoatx/voice-browser
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/@stoatx/voice-browser.svg?style=flat-square)](https://www.npmjs.com/package/@stoatx/voice-browser)
4
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Strict-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
5
+
6
+ Voice for [`@stoatx/client`](https://www.npmjs.com/package/@stoatx/client) in browsers: join voice channels with the user's microphone and hear everyone else.
7
+
8
+ ```bash
9
+ npm install @stoatx/voice-browser
10
+ ```
11
+
12
+ ```ts
13
+ import { VoiceManager } from "@stoatx/voice-browser";
14
+
15
+ const voice = new VoiceManager(client);
16
+ const connection = await voice.join(channel);
17
+
18
+ // From a click handler: asks for microphone permission the first time.
19
+ await connection.setMicrophoneEnabled(true);
20
+ ```
21
+
22
+ For Node.js, use [`@stoatx/voice-node`](https://www.npmjs.com/package/@stoatx/voice-node). Guides and API reference: **[Stoatx Documentation](https://stoatx-ts.github.io/stoatx/)**.
23
+
24
+ ## License
25
+
26
+ MIT © [Stoatx / Stoatx Team]
package/dist/index.cjs ADDED
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ VoiceConnection: () => VoiceConnection,
24
+ VoiceManager: () => VoiceManager
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/VoiceManager.ts
29
+ var import_voice2 = require("@stoatx/voice");
30
+
31
+ // src/VoiceConnection.ts
32
+ var import_livekit_client = require("livekit-client");
33
+ var import_voice = require("@stoatx/voice");
34
+ var VoiceConnection = class extends import_voice.BaseVoiceConnection {
35
+ room;
36
+ audioContainer;
37
+ audioElements = /* @__PURE__ */ new Set();
38
+ _deafened = false;
39
+ /**
40
+ * @param channelId The voice channel's ID.
41
+ * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.
42
+ * @param options Where to put the audio elements.
43
+ */
44
+ constructor(channelId, serverId, options = {}) {
45
+ super(channelId, serverId);
46
+ this.audioContainer = options.audioContainer;
47
+ this.room = new import_livekit_client.Room();
48
+ this.room.on(import_livekit_client.RoomEvent.TrackSubscribed, (track) => this.attach(track)).on(import_livekit_client.RoomEvent.TrackUnsubscribed, (track) => this.detach(track)).on(
49
+ import_livekit_client.RoomEvent.ActiveSpeakersChanged,
50
+ (speakers) => this.emit(
51
+ "activeSpeakersChange",
52
+ speakers.map((speaker) => speaker.identity)
53
+ )
54
+ ).on(import_livekit_client.RoomEvent.ParticipantConnected, (participant) => this.emit("participantJoin", participant.identity)).on(import_livekit_client.RoomEvent.ParticipantDisconnected, (participant) => this.emit("participantLeave", participant.identity)).on(import_livekit_client.RoomEvent.AudioPlaybackStatusChanged, () => this.emit("audioPlaybackChange", this.room.canPlaybackAudio)).on(import_livekit_client.RoomEvent.Disconnected, () => {
55
+ this._status = "disconnected";
56
+ this.removeAudioElements();
57
+ this.emitBase("disconnect");
58
+ });
59
+ }
60
+ /** The user IDs of everyone else in the call. */
61
+ get participantIds() {
62
+ return [...this.room.remoteParticipants.values()].map((participant) => participant.identity);
63
+ }
64
+ /** Whether the user's microphone is being sent to the call. */
65
+ get microphoneEnabled() {
66
+ return this.room.localParticipant.isMicrophoneEnabled;
67
+ }
68
+ /** Whether other people's audio is muted locally. */
69
+ get deafened() {
70
+ return this._deafened;
71
+ }
72
+ /**
73
+ * Whether the browser lets the call's audio play. Browsers block audio until the user interacts
74
+ * with the page; if this is `false`, call {@link startAudio} from a click or key press.
75
+ */
76
+ get canPlayAudio() {
77
+ return this.room.canPlaybackAudio;
78
+ }
79
+ /** @internal */
80
+ async connect(url, token) {
81
+ await this.room.connect(url, token);
82
+ this._status = "ready";
83
+ this.emitBase("ready");
84
+ }
85
+ /**
86
+ * Turns the microphone on or off. Turning it on the first time asks the user for permission.
87
+ * @param enabled Whether to send the microphone.
88
+ * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.
89
+ * Defaults to the browser's default microphone.
90
+ * @throws If the user denies microphone access.
91
+ * @example
92
+ * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);
93
+ */
94
+ async setMicrophoneEnabled(enabled, deviceId) {
95
+ await this.room.localParticipant.setMicrophoneEnabled(enabled, deviceId === void 0 ? void 0 : { deviceId });
96
+ }
97
+ /**
98
+ * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to
99
+ * fully deafen, like the official client does.
100
+ * @param deafened Whether to mute other people.
101
+ */
102
+ setDeafened(deafened) {
103
+ this._deafened = deafened;
104
+ for (const element of this.audioElements) element.muted = deafened;
105
+ }
106
+ /**
107
+ * Starts the call's audio after the browser blocked it. Must be called from a user interaction,
108
+ * like a click handler.
109
+ */
110
+ async startAudio() {
111
+ await this.room.startAudio();
112
+ }
113
+ /**
114
+ * Keeps the microphone and deafen state after the server moves the user to another call.
115
+ * @param previous The connection being replaced.
116
+ * @internal
117
+ */
118
+ async _takeOver(previous) {
119
+ this.setDeafened(previous.deafened);
120
+ if (previous.microphoneEnabled) await this.setMicrophoneEnabled(true);
121
+ }
122
+ /** Leaves the call, turns the microphone off and removes the audio elements. */
123
+ async disconnect() {
124
+ this._status = "disconnecting";
125
+ this.removeAudioElements();
126
+ await this.room.disconnect();
127
+ }
128
+ attach(track) {
129
+ if (track.kind !== import_livekit_client.Track.Kind.Audio) return;
130
+ const element = track.attach();
131
+ element.muted = this._deafened;
132
+ (this.audioContainer ?? document.body).appendChild(element);
133
+ this.audioElements.add(element);
134
+ }
135
+ detach(track) {
136
+ for (const element of track.detach()) {
137
+ element.remove();
138
+ this.audioElements.delete(element);
139
+ }
140
+ }
141
+ removeAudioElements() {
142
+ for (const element of this.audioElements) element.remove();
143
+ this.audioElements.clear();
144
+ }
145
+ };
146
+
147
+ // src/VoiceManager.ts
148
+ var VoiceManager = class extends import_voice2.BaseVoiceManager {
149
+ /**
150
+ * @param client The client to join calls with.
151
+ * @param options Applied to every connection, e.g. where to put the audio elements.
152
+ */
153
+ constructor(client, options = {}) {
154
+ super(client, (channelId, serverId) => new VoiceConnection(channelId, serverId, options));
155
+ }
156
+ };
157
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/VoiceManager.ts","../src/VoiceConnection.ts"],"sourcesContent":["export { VoiceManager } from \"./VoiceManager\";\nexport { VoiceConnection } from \"./VoiceConnection\";\nexport type { BrowserVoiceConnectionEvents, BrowserVoiceOptions } from \"./VoiceConnection\";\nexport type {\n VoiceChannelResolvable,\n VoiceConnectionEvents,\n VoiceConnectionStatus,\n VoiceJoinOptions,\n VoiceNode,\n} from \"@stoatx/voice\";\n","import type { Client } from \"@stoatx/client\";\nimport { BaseVoiceManager } from \"@stoatx/voice\";\nimport { VoiceConnection, type BrowserVoiceOptions } from \"./VoiceConnection\";\n\n/**\n * Joins voice calls in the browser, with the user's microphone and speakers.\n *\n * @example\n * import { VoiceManager } from \"@stoatx/voice-browser\";\n *\n * const voice = new VoiceManager(client);\n * const connection = await voice.join(channel);\n *\n * // From the mute button's click handler: asks for microphone permission the first time.\n * await connection.setMicrophoneEnabled(true);\n */\nexport class VoiceManager extends BaseVoiceManager<VoiceConnection> {\n /**\n * @param client The client to join calls with.\n * @param options Applied to every connection, e.g. where to put the audio elements.\n */\n constructor(client: Client, options: BrowserVoiceOptions = {}) {\n super(client, (channelId, serverId) => new VoiceConnection(channelId, serverId, options));\n }\n}\n","/// <reference lib=\"dom\" />\nimport { Room, RoomEvent, Track, type RemoteTrack } from \"livekit-client\";\nimport { BaseVoiceConnection, type VoiceConnectionEvents } from \"@stoatx/voice\";\n\n/** Events a browser voice connection emits. */\nexport interface BrowserVoiceConnectionEvents extends VoiceConnectionEvents {\n /**\n * The people currently speaking changed. Includes the logged-in user while they talk.\n * Each ID is the participant's LiveKit identity, which is their Stoat user ID.\n */\n activeSpeakersChange: [userIds: string[]];\n /** Someone joined the call. */\n participantJoin: [userId: string];\n /** Someone left the call. */\n participantLeave: [userId: string];\n /**\n * Whether the browser lets the call's audio play changed. When it's `false`, call\n * {@link VoiceConnection.startAudio} from a click or key press.\n */\n audioPlaybackChange: [canPlay: boolean];\n}\n\n/** Options for a browser voice connection. */\nexport interface BrowserVoiceOptions {\n /**\n * Where to put the `<audio>` elements that play other people's voices.\n * Defaults to `document.body`. The elements have no controls, so they're invisible.\n */\n audioContainer?: HTMLElement;\n}\n\n/**\n * A connection to a voice channel's call in the browser. Sends the user's microphone and plays\n * everyone else. Get one from `VoiceManager.join()`.\n *\n * The microphone starts off, so joining never triggers a permission prompt by itself:\n * call {@link setMicrophoneEnabled} when the user unmutes.\n */\nexport class VoiceConnection extends BaseVoiceConnection<BrowserVoiceConnectionEvents> {\n private readonly room: Room;\n private readonly audioContainer: HTMLElement | undefined;\n private readonly audioElements = new Set<HTMLMediaElement>();\n private _deafened = false;\n\n /**\n * @param channelId The voice channel's ID.\n * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.\n * @param options Where to put the audio elements.\n */\n constructor(channelId: string, serverId: string | null, options: BrowserVoiceOptions = {}) {\n super(channelId, serverId);\n this.audioContainer = options.audioContainer;\n this.room = new Room();\n\n this.room\n .on(RoomEvent.TrackSubscribed, (track) => this.attach(track))\n .on(RoomEvent.TrackUnsubscribed, (track) => this.detach(track))\n .on(RoomEvent.ActiveSpeakersChanged, (speakers) =>\n this.emit(\n \"activeSpeakersChange\",\n speakers.map((speaker) => speaker.identity),\n ),\n )\n .on(RoomEvent.ParticipantConnected, (participant) => this.emit(\"participantJoin\", participant.identity))\n .on(RoomEvent.ParticipantDisconnected, (participant) => this.emit(\"participantLeave\", participant.identity))\n .on(RoomEvent.AudioPlaybackStatusChanged, () => this.emit(\"audioPlaybackChange\", this.room.canPlaybackAudio))\n .on(RoomEvent.Disconnected, () => {\n this._status = \"disconnected\";\n this.removeAudioElements();\n this.emitBase(\"disconnect\");\n });\n }\n\n /** The user IDs of everyone else in the call. */\n public get participantIds(): string[] {\n return [...this.room.remoteParticipants.values()].map((participant) => participant.identity);\n }\n\n /** Whether the user's microphone is being sent to the call. */\n public get microphoneEnabled(): boolean {\n return this.room.localParticipant.isMicrophoneEnabled;\n }\n\n /** Whether other people's audio is muted locally. */\n public get deafened(): boolean {\n return this._deafened;\n }\n\n /**\n * Whether the browser lets the call's audio play. Browsers block audio until the user interacts\n * with the page; if this is `false`, call {@link startAudio} from a click or key press.\n */\n public get canPlayAudio(): boolean {\n return this.room.canPlaybackAudio;\n }\n\n /** @internal */\n public async connect(url: string, token: string): Promise<void> {\n await this.room.connect(url, token);\n this._status = \"ready\";\n this.emitBase(\"ready\");\n }\n\n /**\n * Turns the microphone on or off. Turning it on the first time asks the user for permission.\n * @param enabled Whether to send the microphone.\n * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.\n * Defaults to the browser's default microphone.\n * @throws If the user denies microphone access.\n * @example\n * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);\n */\n public async setMicrophoneEnabled(enabled: boolean, deviceId?: string): Promise<void> {\n await this.room.localParticipant.setMicrophoneEnabled(enabled, deviceId === undefined ? undefined : { deviceId });\n }\n\n /**\n * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to\n * fully deafen, like the official client does.\n * @param deafened Whether to mute other people.\n */\n public setDeafened(deafened: boolean): void {\n this._deafened = deafened;\n for (const element of this.audioElements) element.muted = deafened;\n }\n\n /**\n * Starts the call's audio after the browser blocked it. Must be called from a user interaction,\n * like a click handler.\n */\n public async startAudio(): Promise<void> {\n await this.room.startAudio();\n }\n\n /**\n * Keeps the microphone and deafen state after the server moves the user to another call.\n * @param previous The connection being replaced.\n * @internal\n */\n public override async _takeOver(previous: VoiceConnection): Promise<void> {\n this.setDeafened(previous.deafened);\n if (previous.microphoneEnabled) await this.setMicrophoneEnabled(true);\n }\n\n /** Leaves the call, turns the microphone off and removes the audio elements. */\n public async disconnect(): Promise<void> {\n this._status = \"disconnecting\";\n this.removeAudioElements();\n await this.room.disconnect();\n }\n\n private attach(track: RemoteTrack): void {\n if (track.kind !== Track.Kind.Audio) return;\n const element = track.attach();\n element.muted = this._deafened;\n (this.audioContainer ?? document.body).appendChild(element);\n this.audioElements.add(element);\n }\n\n private detach(track: RemoteTrack): void {\n for (const element of track.detach()) {\n element.remove();\n this.audioElements.delete(element);\n }\n }\n\n private removeAudioElements(): void {\n for (const element of this.audioElements) element.remove();\n this.audioElements.clear();\n }\n}\n"],"mappings":"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","names":["import_voice"]}
@@ -0,0 +1,115 @@
1
+ import { Client } from '@stoatx/client';
2
+ import { VoiceConnectionEvents, BaseVoiceConnection, BaseVoiceManager } from '@stoatx/voice';
3
+ export { VoiceChannelResolvable, VoiceConnectionEvents, VoiceConnectionStatus, VoiceJoinOptions, VoiceNode } from '@stoatx/voice';
4
+
5
+ /** Events a browser voice connection emits. */
6
+ interface BrowserVoiceConnectionEvents extends VoiceConnectionEvents {
7
+ /**
8
+ * The people currently speaking changed. Includes the logged-in user while they talk.
9
+ * Each ID is the participant's LiveKit identity, which is their Stoat user ID.
10
+ */
11
+ activeSpeakersChange: [userIds: string[]];
12
+ /** Someone joined the call. */
13
+ participantJoin: [userId: string];
14
+ /** Someone left the call. */
15
+ participantLeave: [userId: string];
16
+ /**
17
+ * Whether the browser lets the call's audio play changed. When it's `false`, call
18
+ * {@link VoiceConnection.startAudio} from a click or key press.
19
+ */
20
+ audioPlaybackChange: [canPlay: boolean];
21
+ }
22
+ /** Options for a browser voice connection. */
23
+ interface BrowserVoiceOptions {
24
+ /**
25
+ * Where to put the `<audio>` elements that play other people's voices.
26
+ * Defaults to `document.body`. The elements have no controls, so they're invisible.
27
+ */
28
+ audioContainer?: HTMLElement;
29
+ }
30
+ /**
31
+ * A connection to a voice channel's call in the browser. Sends the user's microphone and plays
32
+ * everyone else. Get one from `VoiceManager.join()`.
33
+ *
34
+ * The microphone starts off, so joining never triggers a permission prompt by itself:
35
+ * call {@link setMicrophoneEnabled} when the user unmutes.
36
+ */
37
+ declare class VoiceConnection extends BaseVoiceConnection<BrowserVoiceConnectionEvents> {
38
+ private readonly room;
39
+ private readonly audioContainer;
40
+ private readonly audioElements;
41
+ private _deafened;
42
+ /**
43
+ * @param channelId The voice channel's ID.
44
+ * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.
45
+ * @param options Where to put the audio elements.
46
+ */
47
+ constructor(channelId: string, serverId: string | null, options?: BrowserVoiceOptions);
48
+ /** The user IDs of everyone else in the call. */
49
+ get participantIds(): string[];
50
+ /** Whether the user's microphone is being sent to the call. */
51
+ get microphoneEnabled(): boolean;
52
+ /** Whether other people's audio is muted locally. */
53
+ get deafened(): boolean;
54
+ /**
55
+ * Whether the browser lets the call's audio play. Browsers block audio until the user interacts
56
+ * with the page; if this is `false`, call {@link startAudio} from a click or key press.
57
+ */
58
+ get canPlayAudio(): boolean;
59
+ /** @internal */
60
+ connect(url: string, token: string): Promise<void>;
61
+ /**
62
+ * Turns the microphone on or off. Turning it on the first time asks the user for permission.
63
+ * @param enabled Whether to send the microphone.
64
+ * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.
65
+ * Defaults to the browser's default microphone.
66
+ * @throws If the user denies microphone access.
67
+ * @example
68
+ * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);
69
+ */
70
+ setMicrophoneEnabled(enabled: boolean, deviceId?: string): Promise<void>;
71
+ /**
72
+ * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to
73
+ * fully deafen, like the official client does.
74
+ * @param deafened Whether to mute other people.
75
+ */
76
+ setDeafened(deafened: boolean): void;
77
+ /**
78
+ * Starts the call's audio after the browser blocked it. Must be called from a user interaction,
79
+ * like a click handler.
80
+ */
81
+ startAudio(): Promise<void>;
82
+ /**
83
+ * Keeps the microphone and deafen state after the server moves the user to another call.
84
+ * @param previous The connection being replaced.
85
+ * @internal
86
+ */
87
+ _takeOver(previous: VoiceConnection): Promise<void>;
88
+ /** Leaves the call, turns the microphone off and removes the audio elements. */
89
+ disconnect(): Promise<void>;
90
+ private attach;
91
+ private detach;
92
+ private removeAudioElements;
93
+ }
94
+
95
+ /**
96
+ * Joins voice calls in the browser, with the user's microphone and speakers.
97
+ *
98
+ * @example
99
+ * import { VoiceManager } from "@stoatx/voice-browser";
100
+ *
101
+ * const voice = new VoiceManager(client);
102
+ * const connection = await voice.join(channel);
103
+ *
104
+ * // From the mute button's click handler: asks for microphone permission the first time.
105
+ * await connection.setMicrophoneEnabled(true);
106
+ */
107
+ declare class VoiceManager extends BaseVoiceManager<VoiceConnection> {
108
+ /**
109
+ * @param client The client to join calls with.
110
+ * @param options Applied to every connection, e.g. where to put the audio elements.
111
+ */
112
+ constructor(client: Client, options?: BrowserVoiceOptions);
113
+ }
114
+
115
+ export { type BrowserVoiceConnectionEvents, type BrowserVoiceOptions, VoiceConnection, VoiceManager };
@@ -0,0 +1,115 @@
1
+ import { Client } from '@stoatx/client';
2
+ import { VoiceConnectionEvents, BaseVoiceConnection, BaseVoiceManager } from '@stoatx/voice';
3
+ export { VoiceChannelResolvable, VoiceConnectionEvents, VoiceConnectionStatus, VoiceJoinOptions, VoiceNode } from '@stoatx/voice';
4
+
5
+ /** Events a browser voice connection emits. */
6
+ interface BrowserVoiceConnectionEvents extends VoiceConnectionEvents {
7
+ /**
8
+ * The people currently speaking changed. Includes the logged-in user while they talk.
9
+ * Each ID is the participant's LiveKit identity, which is their Stoat user ID.
10
+ */
11
+ activeSpeakersChange: [userIds: string[]];
12
+ /** Someone joined the call. */
13
+ participantJoin: [userId: string];
14
+ /** Someone left the call. */
15
+ participantLeave: [userId: string];
16
+ /**
17
+ * Whether the browser lets the call's audio play changed. When it's `false`, call
18
+ * {@link VoiceConnection.startAudio} from a click or key press.
19
+ */
20
+ audioPlaybackChange: [canPlay: boolean];
21
+ }
22
+ /** Options for a browser voice connection. */
23
+ interface BrowserVoiceOptions {
24
+ /**
25
+ * Where to put the `<audio>` elements that play other people's voices.
26
+ * Defaults to `document.body`. The elements have no controls, so they're invisible.
27
+ */
28
+ audioContainer?: HTMLElement;
29
+ }
30
+ /**
31
+ * A connection to a voice channel's call in the browser. Sends the user's microphone and plays
32
+ * everyone else. Get one from `VoiceManager.join()`.
33
+ *
34
+ * The microphone starts off, so joining never triggers a permission prompt by itself:
35
+ * call {@link setMicrophoneEnabled} when the user unmutes.
36
+ */
37
+ declare class VoiceConnection extends BaseVoiceConnection<BrowserVoiceConnectionEvents> {
38
+ private readonly room;
39
+ private readonly audioContainer;
40
+ private readonly audioElements;
41
+ private _deafened;
42
+ /**
43
+ * @param channelId The voice channel's ID.
44
+ * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.
45
+ * @param options Where to put the audio elements.
46
+ */
47
+ constructor(channelId: string, serverId: string | null, options?: BrowserVoiceOptions);
48
+ /** The user IDs of everyone else in the call. */
49
+ get participantIds(): string[];
50
+ /** Whether the user's microphone is being sent to the call. */
51
+ get microphoneEnabled(): boolean;
52
+ /** Whether other people's audio is muted locally. */
53
+ get deafened(): boolean;
54
+ /**
55
+ * Whether the browser lets the call's audio play. Browsers block audio until the user interacts
56
+ * with the page; if this is `false`, call {@link startAudio} from a click or key press.
57
+ */
58
+ get canPlayAudio(): boolean;
59
+ /** @internal */
60
+ connect(url: string, token: string): Promise<void>;
61
+ /**
62
+ * Turns the microphone on or off. Turning it on the first time asks the user for permission.
63
+ * @param enabled Whether to send the microphone.
64
+ * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.
65
+ * Defaults to the browser's default microphone.
66
+ * @throws If the user denies microphone access.
67
+ * @example
68
+ * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);
69
+ */
70
+ setMicrophoneEnabled(enabled: boolean, deviceId?: string): Promise<void>;
71
+ /**
72
+ * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to
73
+ * fully deafen, like the official client does.
74
+ * @param deafened Whether to mute other people.
75
+ */
76
+ setDeafened(deafened: boolean): void;
77
+ /**
78
+ * Starts the call's audio after the browser blocked it. Must be called from a user interaction,
79
+ * like a click handler.
80
+ */
81
+ startAudio(): Promise<void>;
82
+ /**
83
+ * Keeps the microphone and deafen state after the server moves the user to another call.
84
+ * @param previous The connection being replaced.
85
+ * @internal
86
+ */
87
+ _takeOver(previous: VoiceConnection): Promise<void>;
88
+ /** Leaves the call, turns the microphone off and removes the audio elements. */
89
+ disconnect(): Promise<void>;
90
+ private attach;
91
+ private detach;
92
+ private removeAudioElements;
93
+ }
94
+
95
+ /**
96
+ * Joins voice calls in the browser, with the user's microphone and speakers.
97
+ *
98
+ * @example
99
+ * import { VoiceManager } from "@stoatx/voice-browser";
100
+ *
101
+ * const voice = new VoiceManager(client);
102
+ * const connection = await voice.join(channel);
103
+ *
104
+ * // From the mute button's click handler: asks for microphone permission the first time.
105
+ * await connection.setMicrophoneEnabled(true);
106
+ */
107
+ declare class VoiceManager extends BaseVoiceManager<VoiceConnection> {
108
+ /**
109
+ * @param client The client to join calls with.
110
+ * @param options Applied to every connection, e.g. where to put the audio elements.
111
+ */
112
+ constructor(client: Client, options?: BrowserVoiceOptions);
113
+ }
114
+
115
+ export { type BrowserVoiceConnectionEvents, type BrowserVoiceOptions, VoiceConnection, VoiceManager };
package/dist/index.js ADDED
@@ -0,0 +1,134 @@
1
+ // src/VoiceManager.ts
2
+ import { BaseVoiceManager } from "@stoatx/voice";
3
+
4
+ // src/VoiceConnection.ts
5
+ import { Room, RoomEvent, Track } from "livekit-client";
6
+ import { BaseVoiceConnection } from "@stoatx/voice";
7
+ var VoiceConnection = class extends BaseVoiceConnection {
8
+ room;
9
+ audioContainer;
10
+ audioElements = /* @__PURE__ */ new Set();
11
+ _deafened = false;
12
+ /**
13
+ * @param channelId The voice channel's ID.
14
+ * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.
15
+ * @param options Where to put the audio elements.
16
+ */
17
+ constructor(channelId, serverId, options = {}) {
18
+ super(channelId, serverId);
19
+ this.audioContainer = options.audioContainer;
20
+ this.room = new Room();
21
+ this.room.on(RoomEvent.TrackSubscribed, (track) => this.attach(track)).on(RoomEvent.TrackUnsubscribed, (track) => this.detach(track)).on(
22
+ RoomEvent.ActiveSpeakersChanged,
23
+ (speakers) => this.emit(
24
+ "activeSpeakersChange",
25
+ speakers.map((speaker) => speaker.identity)
26
+ )
27
+ ).on(RoomEvent.ParticipantConnected, (participant) => this.emit("participantJoin", participant.identity)).on(RoomEvent.ParticipantDisconnected, (participant) => this.emit("participantLeave", participant.identity)).on(RoomEvent.AudioPlaybackStatusChanged, () => this.emit("audioPlaybackChange", this.room.canPlaybackAudio)).on(RoomEvent.Disconnected, () => {
28
+ this._status = "disconnected";
29
+ this.removeAudioElements();
30
+ this.emitBase("disconnect");
31
+ });
32
+ }
33
+ /** The user IDs of everyone else in the call. */
34
+ get participantIds() {
35
+ return [...this.room.remoteParticipants.values()].map((participant) => participant.identity);
36
+ }
37
+ /** Whether the user's microphone is being sent to the call. */
38
+ get microphoneEnabled() {
39
+ return this.room.localParticipant.isMicrophoneEnabled;
40
+ }
41
+ /** Whether other people's audio is muted locally. */
42
+ get deafened() {
43
+ return this._deafened;
44
+ }
45
+ /**
46
+ * Whether the browser lets the call's audio play. Browsers block audio until the user interacts
47
+ * with the page; if this is `false`, call {@link startAudio} from a click or key press.
48
+ */
49
+ get canPlayAudio() {
50
+ return this.room.canPlaybackAudio;
51
+ }
52
+ /** @internal */
53
+ async connect(url, token) {
54
+ await this.room.connect(url, token);
55
+ this._status = "ready";
56
+ this.emitBase("ready");
57
+ }
58
+ /**
59
+ * Turns the microphone on or off. Turning it on the first time asks the user for permission.
60
+ * @param enabled Whether to send the microphone.
61
+ * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.
62
+ * Defaults to the browser's default microphone.
63
+ * @throws If the user denies microphone access.
64
+ * @example
65
+ * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);
66
+ */
67
+ async setMicrophoneEnabled(enabled, deviceId) {
68
+ await this.room.localParticipant.setMicrophoneEnabled(enabled, deviceId === void 0 ? void 0 : { deviceId });
69
+ }
70
+ /**
71
+ * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to
72
+ * fully deafen, like the official client does.
73
+ * @param deafened Whether to mute other people.
74
+ */
75
+ setDeafened(deafened) {
76
+ this._deafened = deafened;
77
+ for (const element of this.audioElements) element.muted = deafened;
78
+ }
79
+ /**
80
+ * Starts the call's audio after the browser blocked it. Must be called from a user interaction,
81
+ * like a click handler.
82
+ */
83
+ async startAudio() {
84
+ await this.room.startAudio();
85
+ }
86
+ /**
87
+ * Keeps the microphone and deafen state after the server moves the user to another call.
88
+ * @param previous The connection being replaced.
89
+ * @internal
90
+ */
91
+ async _takeOver(previous) {
92
+ this.setDeafened(previous.deafened);
93
+ if (previous.microphoneEnabled) await this.setMicrophoneEnabled(true);
94
+ }
95
+ /** Leaves the call, turns the microphone off and removes the audio elements. */
96
+ async disconnect() {
97
+ this._status = "disconnecting";
98
+ this.removeAudioElements();
99
+ await this.room.disconnect();
100
+ }
101
+ attach(track) {
102
+ if (track.kind !== Track.Kind.Audio) return;
103
+ const element = track.attach();
104
+ element.muted = this._deafened;
105
+ (this.audioContainer ?? document.body).appendChild(element);
106
+ this.audioElements.add(element);
107
+ }
108
+ detach(track) {
109
+ for (const element of track.detach()) {
110
+ element.remove();
111
+ this.audioElements.delete(element);
112
+ }
113
+ }
114
+ removeAudioElements() {
115
+ for (const element of this.audioElements) element.remove();
116
+ this.audioElements.clear();
117
+ }
118
+ };
119
+
120
+ // src/VoiceManager.ts
121
+ var VoiceManager = class extends BaseVoiceManager {
122
+ /**
123
+ * @param client The client to join calls with.
124
+ * @param options Applied to every connection, e.g. where to put the audio elements.
125
+ */
126
+ constructor(client, options = {}) {
127
+ super(client, (channelId, serverId) => new VoiceConnection(channelId, serverId, options));
128
+ }
129
+ };
130
+ export {
131
+ VoiceConnection,
132
+ VoiceManager
133
+ };
134
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/VoiceManager.ts","../src/VoiceConnection.ts"],"sourcesContent":["import type { Client } from \"@stoatx/client\";\nimport { BaseVoiceManager } from \"@stoatx/voice\";\nimport { VoiceConnection, type BrowserVoiceOptions } from \"./VoiceConnection\";\n\n/**\n * Joins voice calls in the browser, with the user's microphone and speakers.\n *\n * @example\n * import { VoiceManager } from \"@stoatx/voice-browser\";\n *\n * const voice = new VoiceManager(client);\n * const connection = await voice.join(channel);\n *\n * // From the mute button's click handler: asks for microphone permission the first time.\n * await connection.setMicrophoneEnabled(true);\n */\nexport class VoiceManager extends BaseVoiceManager<VoiceConnection> {\n /**\n * @param client The client to join calls with.\n * @param options Applied to every connection, e.g. where to put the audio elements.\n */\n constructor(client: Client, options: BrowserVoiceOptions = {}) {\n super(client, (channelId, serverId) => new VoiceConnection(channelId, serverId, options));\n }\n}\n","/// <reference lib=\"dom\" />\nimport { Room, RoomEvent, Track, type RemoteTrack } from \"livekit-client\";\nimport { BaseVoiceConnection, type VoiceConnectionEvents } from \"@stoatx/voice\";\n\n/** Events a browser voice connection emits. */\nexport interface BrowserVoiceConnectionEvents extends VoiceConnectionEvents {\n /**\n * The people currently speaking changed. Includes the logged-in user while they talk.\n * Each ID is the participant's LiveKit identity, which is their Stoat user ID.\n */\n activeSpeakersChange: [userIds: string[]];\n /** Someone joined the call. */\n participantJoin: [userId: string];\n /** Someone left the call. */\n participantLeave: [userId: string];\n /**\n * Whether the browser lets the call's audio play changed. When it's `false`, call\n * {@link VoiceConnection.startAudio} from a click or key press.\n */\n audioPlaybackChange: [canPlay: boolean];\n}\n\n/** Options for a browser voice connection. */\nexport interface BrowserVoiceOptions {\n /**\n * Where to put the `<audio>` elements that play other people's voices.\n * Defaults to `document.body`. The elements have no controls, so they're invisible.\n */\n audioContainer?: HTMLElement;\n}\n\n/**\n * A connection to a voice channel's call in the browser. Sends the user's microphone and plays\n * everyone else. Get one from `VoiceManager.join()`.\n *\n * The microphone starts off, so joining never triggers a permission prompt by itself:\n * call {@link setMicrophoneEnabled} when the user unmutes.\n */\nexport class VoiceConnection extends BaseVoiceConnection<BrowserVoiceConnectionEvents> {\n private readonly room: Room;\n private readonly audioContainer: HTMLElement | undefined;\n private readonly audioElements = new Set<HTMLMediaElement>();\n private _deafened = false;\n\n /**\n * @param channelId The voice channel's ID.\n * @param serverId The ID of the server the channel is in, or `null` for DMs and groups.\n * @param options Where to put the audio elements.\n */\n constructor(channelId: string, serverId: string | null, options: BrowserVoiceOptions = {}) {\n super(channelId, serverId);\n this.audioContainer = options.audioContainer;\n this.room = new Room();\n\n this.room\n .on(RoomEvent.TrackSubscribed, (track) => this.attach(track))\n .on(RoomEvent.TrackUnsubscribed, (track) => this.detach(track))\n .on(RoomEvent.ActiveSpeakersChanged, (speakers) =>\n this.emit(\n \"activeSpeakersChange\",\n speakers.map((speaker) => speaker.identity),\n ),\n )\n .on(RoomEvent.ParticipantConnected, (participant) => this.emit(\"participantJoin\", participant.identity))\n .on(RoomEvent.ParticipantDisconnected, (participant) => this.emit(\"participantLeave\", participant.identity))\n .on(RoomEvent.AudioPlaybackStatusChanged, () => this.emit(\"audioPlaybackChange\", this.room.canPlaybackAudio))\n .on(RoomEvent.Disconnected, () => {\n this._status = \"disconnected\";\n this.removeAudioElements();\n this.emitBase(\"disconnect\");\n });\n }\n\n /** The user IDs of everyone else in the call. */\n public get participantIds(): string[] {\n return [...this.room.remoteParticipants.values()].map((participant) => participant.identity);\n }\n\n /** Whether the user's microphone is being sent to the call. */\n public get microphoneEnabled(): boolean {\n return this.room.localParticipant.isMicrophoneEnabled;\n }\n\n /** Whether other people's audio is muted locally. */\n public get deafened(): boolean {\n return this._deafened;\n }\n\n /**\n * Whether the browser lets the call's audio play. Browsers block audio until the user interacts\n * with the page; if this is `false`, call {@link startAudio} from a click or key press.\n */\n public get canPlayAudio(): boolean {\n return this.room.canPlaybackAudio;\n }\n\n /** @internal */\n public async connect(url: string, token: string): Promise<void> {\n await this.room.connect(url, token);\n this._status = \"ready\";\n this.emitBase(\"ready\");\n }\n\n /**\n * Turns the microphone on or off. Turning it on the first time asks the user for permission.\n * @param enabled Whether to send the microphone.\n * @param deviceId The microphone to use, from `navigator.mediaDevices.enumerateDevices()`.\n * Defaults to the browser's default microphone.\n * @throws If the user denies microphone access.\n * @example\n * muteButton.onclick = () => connection.setMicrophoneEnabled(!connection.microphoneEnabled);\n */\n public async setMicrophoneEnabled(enabled: boolean, deviceId?: string): Promise<void> {\n await this.room.localParticipant.setMicrophoneEnabled(enabled, deviceId === undefined ? undefined : { deviceId });\n }\n\n /**\n * Mutes or unmutes everyone else locally. The microphone isn't affected; turn it off too to\n * fully deafen, like the official client does.\n * @param deafened Whether to mute other people.\n */\n public setDeafened(deafened: boolean): void {\n this._deafened = deafened;\n for (const element of this.audioElements) element.muted = deafened;\n }\n\n /**\n * Starts the call's audio after the browser blocked it. Must be called from a user interaction,\n * like a click handler.\n */\n public async startAudio(): Promise<void> {\n await this.room.startAudio();\n }\n\n /**\n * Keeps the microphone and deafen state after the server moves the user to another call.\n * @param previous The connection being replaced.\n * @internal\n */\n public override async _takeOver(previous: VoiceConnection): Promise<void> {\n this.setDeafened(previous.deafened);\n if (previous.microphoneEnabled) await this.setMicrophoneEnabled(true);\n }\n\n /** Leaves the call, turns the microphone off and removes the audio elements. */\n public async disconnect(): Promise<void> {\n this._status = \"disconnecting\";\n this.removeAudioElements();\n await this.room.disconnect();\n }\n\n private attach(track: RemoteTrack): void {\n if (track.kind !== Track.Kind.Audio) return;\n const element = track.attach();\n element.muted = this._deafened;\n (this.audioContainer ?? document.body).appendChild(element);\n this.audioElements.add(element);\n }\n\n private detach(track: RemoteTrack): void {\n for (const element of track.detach()) {\n element.remove();\n this.audioElements.delete(element);\n }\n }\n\n private removeAudioElements(): void {\n for (const element of this.audioElements) element.remove();\n this.audioElements.clear();\n }\n}\n"],"mappings":"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","names":[]}
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@stoatx/voice-browser",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "Voice for @stoatx/client in browsers: join voice channels with the microphone and hear others.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/stoatx-ts/stoatx.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/stoatx-ts/stoatx/issues"
12
+ },
13
+ "homepage": "https://github.com/stoatx-ts/stoatx#readme",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "license": "MIT",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "dependencies": {
32
+ "livekit-client": "^2.23.0",
33
+ "@stoatx/voice": "1.0.1"
34
+ },
35
+ "peerDependencies": {
36
+ "@stoatx/client": "^1.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@stoatx/client": "1.0.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup",
43
+ "dev": "tsup --watch",
44
+ "lint": "eslint src/**/*.ts"
45
+ }
6
46
  }