@vapi-ai/web 1.0.194 → 1.0.199

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 (3) hide show
  1. package/dist/vapi.js +15 -11
  2. package/package.json +1 -1
  3. package/vapi.ts +14 -12
package/dist/vapi.js CHANGED
@@ -38,6 +38,18 @@ function buildAudioPlayer(track, participantId) {
38
38
  return player;
39
39
  });
40
40
  }
41
+ function subscribeToTracks(e, call) {
42
+ console.log(e);
43
+ if (e.participant.user_id === "local") {
44
+ return;
45
+ }
46
+ call.updateParticipant(e.participant.session_id, {
47
+ setSubscribedTracks: {
48
+ audio: true,
49
+ video: false,
50
+ },
51
+ });
52
+ }
41
53
  class Vapi extends events_1.default {
42
54
  constructor(apiToken, apiBaseUrl) {
43
55
  super();
@@ -78,8 +90,6 @@ class Vapi extends events_1.default {
78
90
  });
79
91
  this.call.on("track-started", (e) => __awaiter(this, void 0, void 0, function* () {
80
92
  var _b, _c;
81
- console.log("TRACK");
82
- console.log(e);
83
93
  if (!e)
84
94
  return;
85
95
  if (e.track.kind === "audio" && e.participant) {
@@ -91,15 +101,9 @@ class Vapi extends events_1.default {
91
101
  this.emit("call-start");
92
102
  }));
93
103
  this.call.on("participant-joined", (e) => {
94
- var _a, _b;
95
- console.log("JOINED");
96
- console.log(e);
97
- (_a = this.call) === null || _a === void 0 ? void 0 : _a.updateParticipant((_b = e === null || e === void 0 ? void 0 : e.participant.session_id) !== null && _b !== void 0 ? _b : "", {
98
- setSubscribedTracks: {
99
- audio: true,
100
- video: false,
101
- },
102
- });
104
+ if (!e || !this.call)
105
+ return;
106
+ subscribeToTracks(e, this.call);
103
107
  });
104
108
  yield this.call.join({ url, subscribeToTracksAutomatically: false });
105
109
  this.call.startRemoteParticipantsAudioLevelObserver();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vapi-ai/web",
3
- "version": "1.0.194",
3
+ "version": "1.0.199",
4
4
  "description": "",
5
5
  "main": "dist/vapi.js",
6
6
  "types": "dist/vapi.d.ts",
package/vapi.ts CHANGED
@@ -30,6 +30,18 @@ async function buildAudioPlayer(track: any, participantId: string) {
30
30
  await startPlayer(player, track);
31
31
  return player;
32
32
  }
33
+ function subscribeToTracks(e: DailyEventObjectParticipant, call: DailyCall) {
34
+ console.log(e);
35
+ if (e.participant.user_id === "local") {
36
+ return;
37
+ }
38
+ call.updateParticipant(e.participant.session_id, {
39
+ setSubscribedTracks: {
40
+ audio: true,
41
+ video: false,
42
+ },
43
+ });
44
+ }
33
45
 
34
46
  export default class Vapi extends EventEmitter {
35
47
  private started: boolean = false;
@@ -77,9 +89,6 @@ export default class Vapi extends EventEmitter {
77
89
  });
78
90
 
79
91
  this.call.on("track-started", async (e) => {
80
- console.log("TRACK");
81
- console.log(e);
82
-
83
92
  if (!e) return;
84
93
  if (e.track.kind === "audio" && e.participant) {
85
94
  await buildAudioPlayer(e.track, e.participant.session_id);
@@ -91,15 +100,8 @@ export default class Vapi extends EventEmitter {
91
100
  });
92
101
 
93
102
  this.call.on("participant-joined", (e) => {
94
- console.log("JOINED");
95
- console.log(e);
96
-
97
- this.call?.updateParticipant(e?.participant.session_id ?? "", {
98
- setSubscribedTracks: {
99
- audio: true,
100
- video: false,
101
- },
102
- });
103
+ if (!e || !this.call) return;
104
+ subscribeToTracks(e, this.call);
103
105
  });
104
106
 
105
107
  await this.call.join({ url, subscribeToTracksAutomatically: false });