@vapi-ai/web 1.0.220 → 1.0.222
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.d.ts +1 -0
- package/dist/vapi.js +9 -1
- package/package.json +1 -1
- package/vapi.ts +9 -1
package/dist/vapi.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
22
22
|
private call;
|
|
23
23
|
private speakingTimeout;
|
|
24
24
|
constructor(apiToken: string, apiBaseUrl?: string);
|
|
25
|
+
private cleanup;
|
|
25
26
|
start(assistant: CreateAssistantDTO | string): Promise<Call | null>;
|
|
26
27
|
private handleRemoteParticipantsAudioLevel;
|
|
27
28
|
stop(): void;
|
package/dist/vapi.js
CHANGED
|
@@ -78,6 +78,13 @@ class Vapi extends VapiEventEmitter {
|
|
|
78
78
|
client_1.client.baseUrl = apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : "https://api.vapi.ai";
|
|
79
79
|
client_1.client.setSecurityData(apiToken);
|
|
80
80
|
}
|
|
81
|
+
cleanup() {
|
|
82
|
+
var _a;
|
|
83
|
+
this.started = false;
|
|
84
|
+
(_a = this.call) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
85
|
+
this.call = null;
|
|
86
|
+
this.speakingTimeout = null;
|
|
87
|
+
}
|
|
81
88
|
start(assistant) {
|
|
82
89
|
var _a;
|
|
83
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -97,6 +104,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
97
104
|
(_a = this.call.iframe()) === null || _a === void 0 ? void 0 : _a.style.setProperty("display", "none");
|
|
98
105
|
this.call.on("left-meeting", () => {
|
|
99
106
|
this.emit("call-end");
|
|
107
|
+
this.cleanup();
|
|
100
108
|
});
|
|
101
109
|
this.call.on("participant-left", (e) => {
|
|
102
110
|
if (!e)
|
|
@@ -143,7 +151,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
143
151
|
catch (e) {
|
|
144
152
|
console.error(e);
|
|
145
153
|
this.emit("error", e);
|
|
146
|
-
this.
|
|
154
|
+
this.cleanup();
|
|
147
155
|
return null;
|
|
148
156
|
}
|
|
149
157
|
});
|
package/package.json
CHANGED
package/vapi.ts
CHANGED
|
@@ -102,6 +102,13 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
102
102
|
client.setSecurityData(apiToken);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
private cleanup() {
|
|
106
|
+
this.started = false;
|
|
107
|
+
this.call?.destroy();
|
|
108
|
+
this.call = null;
|
|
109
|
+
this.speakingTimeout = null;
|
|
110
|
+
}
|
|
111
|
+
|
|
105
112
|
async start(assistant: CreateAssistantDTO | string): Promise<Call | null> {
|
|
106
113
|
if (this.started) {
|
|
107
114
|
return null;
|
|
@@ -125,6 +132,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
125
132
|
|
|
126
133
|
this.call.on("left-meeting", () => {
|
|
127
134
|
this.emit("call-end");
|
|
135
|
+
this.cleanup();
|
|
128
136
|
});
|
|
129
137
|
|
|
130
138
|
this.call.on("participant-left", (e) => {
|
|
@@ -175,7 +183,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
175
183
|
} catch (e) {
|
|
176
184
|
console.error(e);
|
|
177
185
|
this.emit("error", e);
|
|
178
|
-
this.
|
|
186
|
+
this.cleanup();
|
|
179
187
|
return null;
|
|
180
188
|
}
|
|
181
189
|
}
|