@d-id/client-sdk 1.1.21 → 1.1.22
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as H, a as X, S as Y, d as Z, T as l, C as u, b as p, A as M, e as F, f as k, g as b } from "./index-
|
|
2
|
-
function ee(c, f,
|
|
3
|
-
const m = H(c, `${f}/v2/agents/${
|
|
1
|
+
import { c as H, a as X, S as Y, d as Z, T as l, C as u, b as p, A as M, e as F, f as k, g as b } from "./index-DrtrGN5e.js";
|
|
2
|
+
function ee(c, f, d, i) {
|
|
3
|
+
const m = H(c, `${f}/v2/agents/${d}`, i);
|
|
4
4
|
return {
|
|
5
5
|
async createStream(a) {
|
|
6
6
|
return m.post("/sessions", a);
|
|
@@ -26,13 +26,13 @@ const te = {
|
|
|
26
26
|
kind: "InternalServerError",
|
|
27
27
|
description: "Stream Error"
|
|
28
28
|
});
|
|
29
|
-
function P(c, f,
|
|
29
|
+
function P(c, f, d, i) {
|
|
30
30
|
var m, a;
|
|
31
|
-
throw f("Failed to connect to LiveKit room:", c), i(), (m =
|
|
31
|
+
throw f("Failed to connect to LiveKit room:", c), i(), (m = d.onConnectionStateChange) == null || m.call(d, u.Fail), (a = d.onError) == null || a.call(d, c, { sessionId: "" }), c;
|
|
32
32
|
}
|
|
33
|
-
async function oe(c, f,
|
|
33
|
+
async function oe(c, f, d) {
|
|
34
34
|
var R, D;
|
|
35
|
-
const i = X(
|
|
35
|
+
const i = X(d.debug || !1, "LiveKitStreamingManager"), { Room: m, RoomEvent: a, ConnectionState: v } = await ne(), { callbacks: e, auth: _, baseURL: I, analytics: N } = d;
|
|
36
36
|
let g = null, y = !1;
|
|
37
37
|
const K = Y.Fluent;
|
|
38
38
|
let w = !0, h = null;
|
|
@@ -68,7 +68,7 @@ async function oe(c, f, s) {
|
|
|
68
68
|
"stream-type": K
|
|
69
69
|
});
|
|
70
70
|
function x(n) {
|
|
71
|
-
var t, o, r,
|
|
71
|
+
var t, o, r, s, C;
|
|
72
72
|
switch (i("Connection state changed:", n), n) {
|
|
73
73
|
case v.Connecting:
|
|
74
74
|
(t = e.onConnectionStateChange) == null || t.call(e, u.Connecting);
|
|
@@ -83,7 +83,7 @@ async function oe(c, f, s) {
|
|
|
83
83
|
i("LiveKit room disconnected"), y = !1, (r = e.onConnectionStateChange) == null || r.call(e, u.Disconnected);
|
|
84
84
|
break;
|
|
85
85
|
case v.Reconnecting:
|
|
86
|
-
i("LiveKit room reconnecting..."), (
|
|
86
|
+
i("LiveKit room reconnecting..."), (s = e.onConnectionStateChange) == null || s.call(e, u.Connecting);
|
|
87
87
|
break;
|
|
88
88
|
case v.SignalReconnecting:
|
|
89
89
|
i("LiveKit room signal reconnecting..."), (C = e.onConnectionStateChange) == null || C.call(e, u.Connecting);
|
|
@@ -102,14 +102,14 @@ async function oe(c, f, s) {
|
|
|
102
102
|
i("Participant connected:", n.identity);
|
|
103
103
|
}
|
|
104
104
|
function Q(n, t, o) {
|
|
105
|
-
var
|
|
105
|
+
var s, C;
|
|
106
106
|
i(`Track subscribed: ${n.kind} from ${o.identity}`);
|
|
107
107
|
const r = n.mediaStreamTrack;
|
|
108
108
|
if (!r) {
|
|
109
109
|
i(`No mediaStreamTrack available for ${n.kind}`);
|
|
110
110
|
return;
|
|
111
111
|
}
|
|
112
|
-
h ? (h.addTrack(r), i(`Added ${n.kind} track to shared MediaStream`)) : (h = new MediaStream([r]), i(`Created shared MediaStream with ${n.kind} track`)), n.kind === "video" && ((
|
|
112
|
+
h ? (h.addTrack(r), i(`Added ${n.kind} track to shared MediaStream`)) : (h = new MediaStream([r]), i(`Created shared MediaStream with ${n.kind} track`)), n.kind === "video" && ((s = e.onSrcObjectReady) == null || s.call(e, h), (C = e.onVideoStateChange) == null || C.call(e, F.Start));
|
|
113
113
|
}
|
|
114
114
|
function V(n, t, o) {
|
|
115
115
|
var r;
|
|
@@ -120,16 +120,16 @@ async function oe(c, f, s) {
|
|
|
120
120
|
const o = new TextDecoder().decode(n);
|
|
121
121
|
i("Data received:", o);
|
|
122
122
|
try {
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
123
|
+
const s = JSON.parse(o);
|
|
124
|
+
if (s.subject === k.ChatAnswer) {
|
|
125
125
|
const C = b.Answer;
|
|
126
126
|
(r = e.onMessage) == null || r.call(e, C, {
|
|
127
127
|
event: C,
|
|
128
|
-
...
|
|
128
|
+
...s
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
} catch (
|
|
132
|
-
i("Failed to parse data channel message:",
|
|
131
|
+
} catch (s) {
|
|
132
|
+
i("Failed to parse data channel message:", s);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function z(n) {
|
|
@@ -146,29 +146,28 @@ async function oe(c, f, s) {
|
|
|
146
146
|
function G() {
|
|
147
147
|
h && (h.getTracks().forEach((n) => n.stop()), h = null);
|
|
148
148
|
}
|
|
149
|
-
async function L(n) {
|
|
150
|
-
var
|
|
149
|
+
async function L(n, t = "lk.chat") {
|
|
150
|
+
var o, r;
|
|
151
151
|
if (!y || !g) {
|
|
152
|
-
i("Room is not connected for sending messages"), (
|
|
152
|
+
i("Room is not connected for sending messages"), (o = e.onError) == null || o.call(e, new Error(A), {
|
|
153
153
|
sessionId: S
|
|
154
154
|
});
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
try {
|
|
158
|
-
await g.localParticipant.sendText(n, {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
} catch (r) {
|
|
162
|
-
i("Failed to send message:", r), (o = e.onError) == null || o.call(e, new Error(A), { sessionId: S });
|
|
158
|
+
await g.localParticipant.sendText(n, { topic: t }), i("Message sent successfully:", n);
|
|
159
|
+
} catch (s) {
|
|
160
|
+
i("Failed to send message:", s), (r = e.onError) == null || r.call(e, new Error(A), { sessionId: S });
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
return {
|
|
166
164
|
speak(n) {
|
|
167
|
-
const t = JSON.stringify(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
165
|
+
const t = typeof n == "string" ? n : JSON.stringify(n);
|
|
166
|
+
return L(
|
|
167
|
+
t,
|
|
168
|
+
"did.speak"
|
|
169
|
+
/* Speak */
|
|
170
|
+
);
|
|
172
171
|
},
|
|
173
172
|
async disconnect() {
|
|
174
173
|
var n, t;
|