@vapi-ai/web 1.0.221 → 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 -2
- package/package.json +1 -1
- package/vapi.ts +9 -2
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,7 +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");
|
|
100
|
-
this.
|
|
107
|
+
this.cleanup();
|
|
101
108
|
});
|
|
102
109
|
this.call.on("participant-left", (e) => {
|
|
103
110
|
if (!e)
|
|
@@ -144,7 +151,7 @@ class Vapi extends VapiEventEmitter {
|
|
|
144
151
|
catch (e) {
|
|
145
152
|
console.error(e);
|
|
146
153
|
this.emit("error", e);
|
|
147
|
-
this.
|
|
154
|
+
this.cleanup();
|
|
148
155
|
return null;
|
|
149
156
|
}
|
|
150
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,7 +132,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
125
132
|
|
|
126
133
|
this.call.on("left-meeting", () => {
|
|
127
134
|
this.emit("call-end");
|
|
128
|
-
this.
|
|
135
|
+
this.cleanup();
|
|
129
136
|
});
|
|
130
137
|
|
|
131
138
|
this.call.on("participant-left", (e) => {
|
|
@@ -176,7 +183,7 @@ export default class Vapi extends VapiEventEmitter {
|
|
|
176
183
|
} catch (e) {
|
|
177
184
|
console.error(e);
|
|
178
185
|
this.emit("error", e);
|
|
179
|
-
this.
|
|
186
|
+
this.cleanup();
|
|
180
187
|
return null;
|
|
181
188
|
}
|
|
182
189
|
}
|