@vapi-ai/web 1.0.197 → 1.0.200
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/dist/vapi.js +13 -13
- package/package.json +1 -1
- package/vapi.ts +10 -11
package/dist/vapi.js
CHANGED
|
@@ -38,12 +38,10 @@ function buildAudioPlayer(track, participantId) {
|
|
|
38
38
|
return player;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
function subscribeToTracks(
|
|
42
|
-
|
|
43
|
-
if (sessionId === "local") {
|
|
41
|
+
function subscribeToTracks(e, call) {
|
|
42
|
+
if (e.participant.local)
|
|
44
43
|
return;
|
|
45
|
-
|
|
46
|
-
call.updateParticipant(sessionId, {
|
|
44
|
+
call.updateParticipant(e.participant.session_id, {
|
|
47
45
|
setSubscribedTracks: {
|
|
48
46
|
audio: true,
|
|
49
47
|
video: false,
|
|
@@ -89,21 +87,23 @@ class Vapi extends events_1.default {
|
|
|
89
87
|
// Don't print to console
|
|
90
88
|
});
|
|
91
89
|
this.call.on("track-started", (e) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
var _b, _c;
|
|
93
|
-
if (!e)
|
|
90
|
+
var _b, _c, _d;
|
|
91
|
+
if (!e || !e.participant)
|
|
92
|
+
return;
|
|
93
|
+
if ((_b = e.participant) === null || _b === void 0 ? void 0 : _b.local)
|
|
94
|
+
return;
|
|
95
|
+
if (e.track.kind !== "audio")
|
|
94
96
|
return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
if (((_b = e === null || e === void 0 ? void 0 : e.participant) === null || _b === void 0 ? void 0 : _b.user_name) !== "Vapi Speaker")
|
|
97
|
+
yield buildAudioPlayer(e.track, e.participant.session_id);
|
|
98
|
+
if (((_c = e === null || e === void 0 ? void 0 : e.participant) === null || _c === void 0 ? void 0 : _c.user_name) !== "Vapi Speaker")
|
|
99
99
|
return;
|
|
100
|
-
(
|
|
100
|
+
(_d = this.call) === null || _d === void 0 ? void 0 : _d.sendAppMessage("playable");
|
|
101
101
|
this.emit("call-start");
|
|
102
102
|
}));
|
|
103
103
|
this.call.on("participant-joined", (e) => {
|
|
104
104
|
if (!e || !this.call)
|
|
105
105
|
return;
|
|
106
|
-
subscribeToTracks(e
|
|
106
|
+
subscribeToTracks(e, this.call);
|
|
107
107
|
});
|
|
108
108
|
yield this.call.join({ url, subscribeToTracksAutomatically: false });
|
|
109
109
|
this.call.startRemoteParticipantsAudioLevelObserver();
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -30,12 +30,10 @@ async function buildAudioPlayer(track: any, participantId: string) {
|
|
|
30
30
|
await startPlayer(player, track);
|
|
31
31
|
return player;
|
|
32
32
|
}
|
|
33
|
-
function subscribeToTracks(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
call.updateParticipant(sessionId, {
|
|
33
|
+
function subscribeToTracks(e: DailyEventObjectParticipant, call: DailyCall) {
|
|
34
|
+
if (e.participant.local) return;
|
|
35
|
+
|
|
36
|
+
call.updateParticipant(e.participant.session_id, {
|
|
39
37
|
setSubscribedTracks: {
|
|
40
38
|
audio: true,
|
|
41
39
|
video: false,
|
|
@@ -89,10 +87,11 @@ export default class Vapi extends EventEmitter {
|
|
|
89
87
|
});
|
|
90
88
|
|
|
91
89
|
this.call.on("track-started", async (e) => {
|
|
92
|
-
if (!e) return;
|
|
93
|
-
if (e.
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
if (!e || !e.participant) return;
|
|
91
|
+
if (e.participant?.local) return;
|
|
92
|
+
if (e.track.kind !== "audio") return;
|
|
93
|
+
|
|
94
|
+
await buildAudioPlayer(e.track, e.participant.session_id);
|
|
96
95
|
|
|
97
96
|
if (e?.participant?.user_name !== "Vapi Speaker") return;
|
|
98
97
|
this.call?.sendAppMessage("playable");
|
|
@@ -101,7 +100,7 @@ export default class Vapi extends EventEmitter {
|
|
|
101
100
|
|
|
102
101
|
this.call.on("participant-joined", (e) => {
|
|
103
102
|
if (!e || !this.call) return;
|
|
104
|
-
subscribeToTracks(e
|
|
103
|
+
subscribeToTracks(e, this.call);
|
|
105
104
|
});
|
|
106
105
|
|
|
107
106
|
await this.call.join({ url, subscribeToTracksAutomatically: false });
|