@d-id/client-sdk 1.1.22-staging.102 → 1.1.22-staging.103

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,9 +1,9 @@
1
- import { c as l, a as k, S as b, d as ee, T as ne, C as u, b as w, A as _, e as N, f as $, g as te } from "./index-DRoGHx1v.js";
2
- function oe(c, v, s, o) {
3
- const f = l(c, `${v}/v2/agents/${s}`, o);
1
+ import { c as l, a as k, S as b, d as ee, T as ne, C as u, b as w, A as _, e as N, f as $, g as te } from "./index-Cx4MD7mS.js";
2
+ function oe(c, y, s, o) {
3
+ const v = l(c, `${y}/v2/agents/${s}`, o);
4
4
  return {
5
5
  async createStream(a) {
6
- return f.post("/sessions", a);
6
+ return v.post("/sessions", a);
7
7
  }
8
8
  };
9
9
  }
@@ -26,17 +26,17 @@ const re = {
26
26
  kind: "InternalServerError",
27
27
  description: "Stream Error"
28
28
  });
29
- function U(c, v, s, o) {
30
- var f, a;
31
- throw v("Failed to connect to LiveKit room:", c), o(), (f = s.onConnectionStateChange) == null || f.call(s, u.Fail), (a = s.onError) == null || a.call(s, c, { sessionId: "" }), c;
29
+ function U(c, y, s, o) {
30
+ var v, a;
31
+ throw y("Failed to connect to LiveKit room:", c), o(), (v = s.onConnectionStateChange) == null || v.call(s, u.Fail), (a = s.onError) == null || a.call(s, c, { sessionId: "" }), c;
32
32
  }
33
- async function se(c, v, s) {
33
+ async function se(c, y, s) {
34
34
  var P, I;
35
- const o = k(s.debug || !1, "LiveKitStreamingManager"), { Room: f, RoomEvent: a, ConnectionState: y } = await ie(), { callbacks: e, auth: j, baseURL: x, analytics: V } = s;
35
+ const o = k(s.debug || !1, "LiveKitStreamingManager"), { Room: v, RoomEvent: a, ConnectionState: p } = await ie(), { callbacks: e, auth: j, baseURL: x, analytics: V } = s;
36
36
  let g = null, E = !1;
37
37
  const F = b.Fluent;
38
- let T = !0, m = null;
39
- g = new f({
38
+ let T = !0, f = null;
39
+ g = new v({
40
40
  adaptiveStream: !1,
41
41
  // Must be false to use mediaStreamTrack directly
42
42
  dynacast: !0
@@ -46,7 +46,7 @@ async function se(c, v, s) {
46
46
  try {
47
47
  const n = await O.createStream({
48
48
  transport_provider: ne.Livekit,
49
- chat_persist: v.chat_persist ?? !0
49
+ chat_persist: y.chat_persist ?? !0
50
50
  }), { id: t, session_token: i, session_url: r } = n;
51
51
  (P = e.onStreamCreated) == null || P.call(e, { session_id: t, stream_id: t, agent_id: c }), S = t, A = i, M = r, await g.prepareConnection(M, A);
52
52
  } catch (n) {
@@ -70,22 +70,22 @@ async function se(c, v, s) {
70
70
  function J(n) {
71
71
  var t, i, r, d, C;
72
72
  switch (o("Connection state changed:", n), n) {
73
- case y.Connecting:
73
+ case p.Connecting:
74
74
  (t = e.onConnectionStateChange) == null || t.call(e, u.Connecting);
75
75
  break;
76
- case y.Connected:
76
+ case p.Connected:
77
77
  o("LiveKit room connected successfully"), E = !0, T ? queueMicrotask(() => {
78
- var p;
79
- (p = e.onConnectionStateChange) == null || p.call(e, u.Connected);
78
+ var m;
79
+ (m = e.onConnectionStateChange) == null || m.call(e, u.Connected);
80
80
  }) : (i = e.onConnectionStateChange) == null || i.call(e, u.Connected);
81
81
  break;
82
- case y.Disconnected:
82
+ case p.Disconnected:
83
83
  o("LiveKit room disconnected"), E = !1, (r = e.onConnectionStateChange) == null || r.call(e, u.Disconnected);
84
84
  break;
85
- case y.Reconnecting:
85
+ case p.Reconnecting:
86
86
  o("LiveKit room reconnecting..."), (d = e.onConnectionStateChange) == null || d.call(e, u.Connecting);
87
87
  break;
88
- case y.SignalReconnecting:
88
+ case p.SignalReconnecting:
89
89
  o("LiveKit room signal reconnecting..."), (C = e.onConnectionStateChange) == null || C.call(e, u.Connecting);
90
90
  break;
91
91
  }
@@ -102,34 +102,34 @@ async function se(c, v, s) {
102
102
  o("Participant connected:", n.identity);
103
103
  }
104
104
  function W(n, t, i) {
105
- var d, C;
105
+ var d, C, m;
106
106
  o(`Track subscribed: ${n.kind} from ${i.identity}`);
107
107
  const r = n.mediaStreamTrack;
108
108
  if (!r) {
109
109
  o(`No mediaStreamTrack available for ${n.kind}`);
110
110
  return;
111
111
  }
112
- m ? (m.addTrack(r), o(`Added ${n.kind} track to shared MediaStream`)) : (m = new MediaStream([r]), o(`Created shared MediaStream with ${n.kind} track`)), n.kind === "video" && ((d = e.onSrcObjectReady) == null || d.call(e, m), (C = e.onVideoStateChange) == null || C.call(e, N.Start));
112
+ f ? (f.addTrack(r), o(`Added ${n.kind} track to shared MediaStream`)) : (f = new MediaStream([r]), o(`Created shared MediaStream with ${n.kind} track`)), n.kind === "video" && ((d = e.onStreamReady) == null || d.call(e), (C = e.onSrcObjectReady) == null || C.call(e, f), (m = e.onVideoStateChange) == null || m.call(e, N.Start));
113
113
  }
114
114
  function B(n, t, i) {
115
115
  var r;
116
116
  o(`Track unsubscribed: ${n.kind} from ${i.identity}`), n.kind === "video" && ((r = e.onVideoStateChange) == null || r.call(e, N.Stop));
117
117
  }
118
118
  function G(n, t, i, r) {
119
- var C, p;
119
+ var C, m;
120
120
  const d = new TextDecoder().decode(n);
121
121
  o("Data received:", d);
122
122
  try {
123
- const h = JSON.parse(d), R = r || h.subject;
124
- if (R === $.ChatAnswer) {
123
+ const h = JSON.parse(d), D = r || h.subject;
124
+ if (D === $.ChatAnswer) {
125
125
  const L = te.Answer;
126
126
  (C = e.onMessage) == null || C.call(e, L, {
127
127
  event: L,
128
128
  ...h
129
129
  });
130
- } else if ([$.StreamVideoCreated, $.StreamVideoDone].includes(R)) {
130
+ } else if ([$.StreamVideoCreated, $.StreamVideoDone].includes(D)) {
131
131
  const L = (h == null ? void 0 : h.role) || (t == null ? void 0 : t.identity) || "datachannel";
132
- (p = e.onMessage) == null || p.call(e, R, {
132
+ (m = e.onMessage) == null || m.call(e, D, {
133
133
  [L]: h
134
134
  });
135
135
  }
@@ -149,9 +149,9 @@ async function se(c, v, s) {
149
149
  o("Track subscription failed:", { trackSid: n, participant: t, reason: i });
150
150
  }
151
151
  function Z() {
152
- m && (m.getTracks().forEach((n) => n.stop()), m = null);
152
+ f && (f.getTracks().forEach((n) => n.stop()), f = null);
153
153
  }
154
- async function D(n, t = "lk.chat") {
154
+ async function R(n, t = "lk.chat") {
155
155
  var i, r;
156
156
  if (!E || !g) {
157
157
  o("Room is not connected for sending messages"), (i = e.onError) == null || i.call(e, new Error(K), {
@@ -168,7 +168,7 @@ async function se(c, v, s) {
168
168
  return {
169
169
  speak(n) {
170
170
  const t = typeof n == "string" ? n : JSON.stringify(n);
171
- return D(
171
+ return R(
172
172
  t,
173
173
  "did.speak"
174
174
  /* Speak */
@@ -178,8 +178,8 @@ async function se(c, v, s) {
178
178
  var n, t;
179
179
  g && (await g.disconnect(), g = null), Z(), E = !1, (n = e.onConnectionStateChange) == null || n.call(e, u.Completed), (t = e.onAgentActivityStateChange) == null || t.call(e, _.Idle);
180
180
  },
181
- sendDataChannelMessage: D,
182
- sendTextMessage: D,
181
+ sendDataChannelMessage: R,
182
+ sendTextMessage: R,
183
183
  sessionId: S,
184
184
  streamId: S,
185
185
  streamType: F,
@@ -8,3 +8,8 @@ export declare const interruptTimestampTracker: {
8
8
  update: () => number;
9
9
  get: (delta?: boolean) => number;
10
10
  };
11
+ export declare const streamReadyTimestampTracker: {
12
+ reset: () => number;
13
+ update: () => number;
14
+ get: (delta?: boolean) => number;
15
+ };
@@ -60,6 +60,7 @@ export interface ManagerCallbacks {
60
60
  session_id: string;
61
61
  agent_id: string;
62
62
  }) => void;
63
+ onStreamReady?: () => void;
63
64
  }
64
65
  export type ManagerCallbackKeys = keyof ManagerCallbacks;
65
66
  export interface StreamEndUserData {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d-id/client-sdk",
3
3
  "private": false,
4
- "version": "1.1.22-staging.102",
4
+ "version": "1.1.22-staging.103",
5
5
  "type": "module",
6
6
  "description": "d-id client sdk",
7
7
  "repository": {