@burdenoff/fe-libs 2026.1014.3 → 2026.1014.4
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/shared/assistant/avatar/live/avatarSessionClient.d.ts +25 -7
- package/dist/shared/assistant/avatar/live/avatarSessionClient.js +122 -61
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +7 -2
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +11 -6
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +201 -192
- package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +1 -1
- package/dist/shared/assistant/avatar/useAvatarCopy.js +1 -0
- package/dist/shared/assistant/i18nManifest.d.ts +1 -0
- package/dist/shared/assistant/i18nManifest.js +1 -0
- package/dist/shared-assistant.js +7 -7
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AvatarNotReadyError as e, LiveKitAvatarTransport as t } from "./avatarTransport.js";
|
|
2
2
|
import { createAvatarTransportPort as n } from "./avatarTransportPort.js";
|
|
3
3
|
import { createAvatarReplyOutputs as r } from "./avatarReplyOutputs.js";
|
|
4
|
-
import { AvatarApiError as i,
|
|
4
|
+
import { AvatarApiError as i, avatarAvailabilityRefusal as a, avatarRefusalFor as o } from "./avatarSessionClient.js";
|
|
5
5
|
//#region src/shared/assistant/avatar/live/liveAvatarController.ts
|
|
6
|
-
var
|
|
6
|
+
var s = 12e4, c = 1e4, l = 8e3, u = 5e3, d = 2e4, f = {
|
|
7
7
|
voiceLive: !1,
|
|
8
8
|
offered: !1,
|
|
9
9
|
phase: "off",
|
|
@@ -15,8 +15,13 @@ var o = 12e4, s = 1e4, c = 8e3, l = 5e3, u = 2e4, d = {
|
|
|
15
15
|
audioBlocked: !1,
|
|
16
16
|
videoReady: !1
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function p(e) {
|
|
19
19
|
switch (e) {
|
|
20
|
+
case "permission_revoked": return {
|
|
21
|
+
problem: "unavailable",
|
|
22
|
+
notice: null,
|
|
23
|
+
hide: !0
|
|
24
|
+
};
|
|
20
25
|
case "start_superseded": return {
|
|
21
26
|
problem: "already-running",
|
|
22
27
|
notice: null
|
|
@@ -46,69 +51,72 @@ function f(e) {
|
|
|
46
51
|
};
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
var m = new Set(["playback-blocked", "needs-hosted-voice"]), h = {
|
|
55
|
+
problem: "unavailable",
|
|
56
|
+
hide: !0
|
|
57
|
+
};
|
|
58
|
+
function g(s) {
|
|
59
|
+
let { scheduler: c, preferences: l } = s, d = s.idleMs ?? 12e4, g = s.endBeforeDeadlineMs ?? 1e4, _ = s.connectTimeoutMs ?? 2e4, v = s.requestTimeoutMs ?? 8e3, y = f, b = /* @__PURE__ */ new Set(), x = !1, S = null, C = 0, w = !1, T = !1, E = 0, D = null, O = null, k = null, A = 0, j = !1, M = null, N = null, P = !1;
|
|
60
|
+
function F(e) {
|
|
53
61
|
try {
|
|
54
|
-
|
|
62
|
+
s.onLog?.(e);
|
|
55
63
|
} catch {}
|
|
56
64
|
}
|
|
57
|
-
function
|
|
58
|
-
return e && !
|
|
65
|
+
function I(e) {
|
|
66
|
+
return e && !x && s.browserSupported();
|
|
59
67
|
}
|
|
60
|
-
function
|
|
68
|
+
function L(e) {
|
|
61
69
|
let t = {
|
|
62
|
-
...
|
|
70
|
+
...y,
|
|
63
71
|
...e
|
|
64
|
-
}, n =
|
|
72
|
+
}, n = I(t.voiceLive), r = {
|
|
65
73
|
...t,
|
|
66
74
|
offered: n
|
|
67
75
|
};
|
|
68
|
-
if (!Object.keys(r).every((e) => r[e] ===
|
|
69
|
-
|
|
70
|
-
for (let e of [...
|
|
76
|
+
if (!Object.keys(r).every((e) => r[e] === y[e])) {
|
|
77
|
+
y = r;
|
|
78
|
+
for (let e of [...b]) try {
|
|
71
79
|
e();
|
|
72
80
|
} catch {}
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
83
|
+
function R() {
|
|
84
|
+
l.getState().avatarEnabled !== w && l.setAvatarEnabled(w);
|
|
77
85
|
}
|
|
78
|
-
let
|
|
86
|
+
let z = {
|
|
79
87
|
positionSec: null,
|
|
80
88
|
synthetic: !0,
|
|
81
89
|
rpc: "none"
|
|
82
|
-
},
|
|
90
|
+
}, B = r({
|
|
83
91
|
port: {
|
|
84
|
-
isActive: () =>
|
|
85
|
-
isAudioBlocked: () =>
|
|
86
|
-
connectionId: () =>
|
|
87
|
-
isMeterHealthy: () =>
|
|
88
|
-
isMeterAudible: () =>
|
|
89
|
-
openSegment: () =>
|
|
90
|
-
clearBuffer: (e) =>
|
|
91
|
-
setOutputMuted: (e) =>
|
|
92
|
-
subscribe: (e) =>
|
|
92
|
+
isActive: () => O !== null && O.port.isActive(),
|
|
93
|
+
isAudioBlocked: () => O?.port.isAudioBlocked() ?? !1,
|
|
94
|
+
connectionId: () => O?.port.connectionId() ?? 0,
|
|
95
|
+
isMeterHealthy: () => O?.port.isMeterHealthy() ?? !1,
|
|
96
|
+
isMeterAudible: () => O?.port.isMeterAudible() ?? !1,
|
|
97
|
+
openSegment: () => O ? O.port.openSegment() : Promise.reject(new e("connection")),
|
|
98
|
+
clearBuffer: (e) => O ? O.port.clearBuffer(e) : Promise.resolve(z),
|
|
99
|
+
setOutputMuted: (e) => O?.port.setOutputMuted(e),
|
|
100
|
+
subscribe: (e) => O ? O.port.subscribe(e) : () => void 0
|
|
93
101
|
},
|
|
94
|
-
scheduler:
|
|
95
|
-
decode:
|
|
96
|
-
...
|
|
97
|
-
...
|
|
98
|
-
...
|
|
102
|
+
scheduler: c,
|
|
103
|
+
decode: s.decode,
|
|
104
|
+
...s.trackerConfig ? { trackerConfig: s.trackerConfig } : {},
|
|
105
|
+
...s.maxDrainMs === void 0 ? {} : { maxDrainMs: s.maxDrainMs },
|
|
106
|
+
...s.stallMs === void 0 ? {} : { stallMs: s.stallMs },
|
|
99
107
|
onNotice: (e) => {
|
|
100
|
-
switch (
|
|
108
|
+
switch (F({
|
|
101
109
|
event: "notice",
|
|
102
110
|
notice: e
|
|
103
111
|
}), e.kind) {
|
|
104
112
|
case "interrupted":
|
|
105
|
-
|
|
113
|
+
L({ notice: "interrupted" });
|
|
106
114
|
return;
|
|
107
115
|
case "voice-fallback":
|
|
108
|
-
|
|
116
|
+
w && L({ notice: "voice-only" });
|
|
109
117
|
return;
|
|
110
118
|
case "audio-blocked":
|
|
111
|
-
|
|
119
|
+
L({
|
|
112
120
|
audioBlocked: !0,
|
|
113
121
|
problem: "playback-blocked"
|
|
114
122
|
});
|
|
@@ -118,28 +126,28 @@ function m(o) {
|
|
|
118
126
|
},
|
|
119
127
|
onActivity: (e) => {
|
|
120
128
|
if (e) {
|
|
121
|
-
|
|
129
|
+
M?.(), M = null;
|
|
122
130
|
return;
|
|
123
131
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
132
|
+
if (T) {
|
|
133
|
+
W("user", { notice: "time-limit" });
|
|
126
134
|
return;
|
|
127
135
|
}
|
|
128
|
-
|
|
136
|
+
V();
|
|
129
137
|
}
|
|
130
138
|
});
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
139
|
+
function V() {
|
|
140
|
+
M?.(), M = null, y.phase === "ready" && (M = c.setTimeout(() => {
|
|
141
|
+
M = null, y.phase === "ready" && !B.isBusy() && W("idle", {});
|
|
142
|
+
}, d));
|
|
135
143
|
}
|
|
136
|
-
function
|
|
137
|
-
|
|
144
|
+
function H() {
|
|
145
|
+
M?.(), M = null, N?.(), N = null;
|
|
138
146
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
let e =
|
|
142
|
-
if (
|
|
147
|
+
function U() {
|
|
148
|
+
B.leave();
|
|
149
|
+
let e = O;
|
|
150
|
+
if (O = null, e !== null) {
|
|
143
151
|
if (e.unsubscribe?.(), e.meter !== null) {
|
|
144
152
|
if (e.meterAudible) {
|
|
145
153
|
e.meterAudible = !1;
|
|
@@ -147,193 +155,194 @@ function m(o) {
|
|
|
147
155
|
}
|
|
148
156
|
e.meter.stop();
|
|
149
157
|
}
|
|
150
|
-
e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null &&
|
|
158
|
+
e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && s.releaseAudioElement(e.audioElement);
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
let n =
|
|
156
|
-
|
|
161
|
+
function W(e, t) {
|
|
162
|
+
E += 1, w = !1, T = !1, U(), H();
|
|
163
|
+
let n = D;
|
|
164
|
+
D = null, R(), n !== null && (F({
|
|
157
165
|
event: "session-ended",
|
|
158
166
|
reason: e
|
|
159
|
-
}),
|
|
167
|
+
}), s.client()?.end(n, {
|
|
160
168
|
reason: e,
|
|
161
169
|
keepalive: t.keepalive === !0
|
|
162
|
-
}).catch(() => void 0)),
|
|
170
|
+
}).catch(() => void 0)), L({
|
|
163
171
|
phase: "off",
|
|
164
172
|
audioBlocked: !1,
|
|
165
173
|
videoReady: !1,
|
|
166
|
-
...t.problem === void 0 ?
|
|
174
|
+
...t.problem === void 0 ? y.problem !== null && m.has(y.problem) ? { problem: null } : {} : { problem: t.problem },
|
|
167
175
|
...t.notice === void 0 ? {} : { notice: t.notice }
|
|
168
176
|
});
|
|
169
177
|
}
|
|
170
|
-
function
|
|
171
|
-
let t =
|
|
172
|
-
t.hide && (
|
|
178
|
+
function G(e) {
|
|
179
|
+
let t = o(e);
|
|
180
|
+
return t.hide && (x = !0), e instanceof i && F({
|
|
173
181
|
event: "refused",
|
|
174
182
|
status: e.status,
|
|
175
183
|
code: e.code
|
|
176
|
-
}),
|
|
184
|
+
}), w = !1, R(), L({
|
|
177
185
|
phase: "off",
|
|
178
186
|
problem: t.problem
|
|
179
|
-
});
|
|
187
|
+
}), t;
|
|
180
188
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
189
|
+
function K(e = h) {
|
|
190
|
+
e.hide && (x = !0), w = !1, R(), L({
|
|
183
191
|
phase: "off",
|
|
184
|
-
problem:
|
|
192
|
+
problem: e.problem,
|
|
185
193
|
avatars: []
|
|
186
194
|
});
|
|
187
195
|
}
|
|
188
|
-
function
|
|
196
|
+
function q(e) {
|
|
189
197
|
switch (e.type) {
|
|
190
198
|
case "audioPlayback":
|
|
191
|
-
e.canPlay ?
|
|
199
|
+
e.canPlay ? y.problem === "playback-blocked" ? L({
|
|
192
200
|
audioBlocked: !1,
|
|
193
201
|
problem: null
|
|
194
|
-
}) :
|
|
202
|
+
}) : L({ audioBlocked: !1 }) : L({
|
|
195
203
|
audioBlocked: !0,
|
|
196
204
|
problem: "playback-blocked"
|
|
197
205
|
});
|
|
198
206
|
return;
|
|
199
207
|
case "avatarLeft":
|
|
200
208
|
case "disconnected":
|
|
201
|
-
|
|
209
|
+
J();
|
|
202
210
|
return;
|
|
203
211
|
default: return;
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
|
-
async function
|
|
207
|
-
let e =
|
|
208
|
-
if (e === null ||
|
|
209
|
-
let t =
|
|
210
|
-
|
|
214
|
+
async function J() {
|
|
215
|
+
let e = D;
|
|
216
|
+
if (e === null || y.phase === "ending" || y.phase === "off") return;
|
|
217
|
+
let t = E;
|
|
218
|
+
L({ phase: "ending" });
|
|
211
219
|
let n = null, r = !1;
|
|
212
220
|
try {
|
|
213
|
-
let t =
|
|
221
|
+
let t = s.client(), i = t === null ? void 0 : await X((n) => t.status(e, n));
|
|
214
222
|
n = i?.endedReason ?? null, r = i !== void 0 && [
|
|
215
223
|
"ended",
|
|
216
224
|
"failed",
|
|
217
225
|
"canceled"
|
|
218
226
|
].includes(i.state);
|
|
219
227
|
} catch {}
|
|
220
|
-
if (
|
|
221
|
-
let i =
|
|
222
|
-
r && (
|
|
228
|
+
if (E !== t) return;
|
|
229
|
+
let i = p(n);
|
|
230
|
+
i.hide && (x = !0), r && (D = null, F({
|
|
223
231
|
event: "session-ended",
|
|
224
232
|
reason: "server"
|
|
225
|
-
})),
|
|
233
|
+
})), W("client_error", i);
|
|
226
234
|
}
|
|
227
|
-
async function
|
|
228
|
-
let i =
|
|
235
|
+
async function Y(e, r) {
|
|
236
|
+
let i = s.client();
|
|
229
237
|
if (i === null) {
|
|
230
|
-
|
|
238
|
+
K();
|
|
231
239
|
return;
|
|
232
240
|
}
|
|
233
|
-
let a = ++
|
|
234
|
-
|
|
241
|
+
let a = ++E;
|
|
242
|
+
L({
|
|
235
243
|
phase: "starting",
|
|
236
244
|
problem: null,
|
|
237
245
|
notice: null
|
|
238
246
|
});
|
|
239
|
-
let
|
|
247
|
+
let o;
|
|
240
248
|
try {
|
|
241
|
-
|
|
249
|
+
o = await s.openRoom();
|
|
242
250
|
} catch {
|
|
243
|
-
|
|
251
|
+
E === a && K();
|
|
244
252
|
return;
|
|
245
253
|
}
|
|
246
|
-
let
|
|
247
|
-
|
|
254
|
+
let l = () => {
|
|
255
|
+
o.disconnect().catch(() => void 0);
|
|
248
256
|
};
|
|
249
|
-
if (
|
|
250
|
-
|
|
257
|
+
if (E !== a) {
|
|
258
|
+
l();
|
|
251
259
|
return;
|
|
252
260
|
}
|
|
253
|
-
let d =
|
|
261
|
+
let d = c.now(), f;
|
|
254
262
|
try {
|
|
255
263
|
f = await i.create({
|
|
256
264
|
avatarId: e,
|
|
257
265
|
consentVersion: r,
|
|
258
|
-
idempotencyKey:
|
|
266
|
+
idempotencyKey: s.newIdempotencyKey()
|
|
259
267
|
});
|
|
260
268
|
} catch (e) {
|
|
261
|
-
|
|
269
|
+
if (l(), E !== a) return;
|
|
270
|
+
G(e).showDisclosure && (S = null, $.requestOn());
|
|
262
271
|
return;
|
|
263
272
|
}
|
|
264
|
-
if (
|
|
265
|
-
|
|
273
|
+
if (E !== a) {
|
|
274
|
+
l(), i.end(f.sessionId, { reason: j ? "voice_end" : "user" }).catch(() => void 0);
|
|
266
275
|
return;
|
|
267
276
|
}
|
|
268
|
-
|
|
277
|
+
D = f.sessionId, L({ phase: "connecting" });
|
|
269
278
|
let p = new t({
|
|
270
|
-
room:
|
|
279
|
+
room: o,
|
|
271
280
|
avatarIdentity: f.avatarIdentity,
|
|
272
|
-
scheduler:
|
|
273
|
-
...
|
|
274
|
-
}),
|
|
281
|
+
scheduler: c,
|
|
282
|
+
...s.readinessProbe === void 0 ? {} : { readinessProbe: s.readinessProbe }
|
|
283
|
+
}), m = /* @__PURE__ */ new Set(), h = {
|
|
275
284
|
session: f,
|
|
276
285
|
transport: p,
|
|
277
|
-
audioElement:
|
|
286
|
+
audioElement: s.createAudioElement(),
|
|
278
287
|
meter: null,
|
|
279
288
|
meterAudible: !1,
|
|
280
|
-
meterListeners:
|
|
289
|
+
meterListeners: m,
|
|
281
290
|
videoTrack: null,
|
|
282
291
|
unsubscribe: null,
|
|
283
292
|
port: n({
|
|
284
293
|
transport: p,
|
|
285
|
-
isEnabled: () =>
|
|
286
|
-
subscribeMeter: (e) => (
|
|
287
|
-
|
|
294
|
+
isEnabled: () => w && !T,
|
|
295
|
+
subscribeMeter: (e) => (m.add(e), () => {
|
|
296
|
+
m.delete(e);
|
|
288
297
|
}),
|
|
289
|
-
isMeterHealthy: () =>
|
|
298
|
+
isMeterHealthy: () => h.meter?.isRunning() ?? !1
|
|
290
299
|
})
|
|
291
300
|
};
|
|
292
|
-
|
|
301
|
+
O = h, h.unsubscribe = p.subscribe(q);
|
|
293
302
|
try {
|
|
294
|
-
await
|
|
303
|
+
await Z(p.connect({
|
|
295
304
|
url: f.livekitUrl,
|
|
296
305
|
token: f.participantToken,
|
|
297
|
-
audioElement:
|
|
306
|
+
audioElement: h.audioElement,
|
|
298
307
|
onAvatarAudio: (e) => {
|
|
299
|
-
if (!(e.mediaStreamTrack === null ||
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
for (let t of [...
|
|
308
|
+
if (!(e.mediaStreamTrack === null || h.meter !== null)) try {
|
|
309
|
+
h.meter = s.startMeter(e.mediaStreamTrack, (e) => {
|
|
310
|
+
h.meterAudible = e;
|
|
311
|
+
for (let t of [...m]) t(e);
|
|
303
312
|
});
|
|
304
313
|
} catch {
|
|
305
|
-
|
|
314
|
+
h.meter = null;
|
|
306
315
|
}
|
|
307
316
|
},
|
|
308
317
|
onAvatarVideo: (e) => {
|
|
309
|
-
|
|
318
|
+
h.videoTrack = e, k !== null && e.attach(k), O === h && L({ videoReady: !0 });
|
|
310
319
|
}
|
|
311
|
-
}),
|
|
320
|
+
}), _);
|
|
312
321
|
} catch (e) {
|
|
313
|
-
if (
|
|
314
|
-
|
|
322
|
+
if (E !== a) return;
|
|
323
|
+
F({
|
|
315
324
|
event: "connect-failed",
|
|
316
325
|
error: e instanceof Error ? e.name : "error"
|
|
317
|
-
}),
|
|
326
|
+
}), W("client_error", { problem: "connection" });
|
|
318
327
|
return;
|
|
319
328
|
}
|
|
320
|
-
if (
|
|
321
|
-
|
|
329
|
+
if (E !== a || O !== h) return;
|
|
330
|
+
L({
|
|
322
331
|
phase: "ready",
|
|
323
332
|
audioBlocked: p.audioBlocked,
|
|
324
333
|
...p.audioBlocked ? { problem: "playback-blocked" } : {}
|
|
325
|
-
}),
|
|
326
|
-
let v =
|
|
327
|
-
|
|
328
|
-
|
|
334
|
+
}), V();
|
|
335
|
+
let v = C > 0 ? d + C - u - c.now() : f.endsAt - s.now(), y = Math.max(0, v - g);
|
|
336
|
+
N = c.setTimeout(() => {
|
|
337
|
+
N = null, E === a && (T = !0, B.isBusy() || W("user", { notice: "time-limit" }));
|
|
329
338
|
}, y);
|
|
330
339
|
}
|
|
331
|
-
function
|
|
340
|
+
function X(t) {
|
|
332
341
|
let n = new AbortController();
|
|
333
342
|
return new Promise((r, i) => {
|
|
334
|
-
let a =
|
|
343
|
+
let a = c.setTimeout(() => {
|
|
335
344
|
n.abort(), i(new e("connection"));
|
|
336
|
-
},
|
|
345
|
+
}, v);
|
|
337
346
|
t(n.signal).then((e) => {
|
|
338
347
|
a(), r(e);
|
|
339
348
|
}, (e) => {
|
|
@@ -341,9 +350,9 @@ function m(o) {
|
|
|
341
350
|
});
|
|
342
351
|
});
|
|
343
352
|
}
|
|
344
|
-
function
|
|
353
|
+
function Z(t, n) {
|
|
345
354
|
return new Promise((r, i) => {
|
|
346
|
-
let a =
|
|
355
|
+
let a = c.setTimeout(() => i(new e("connection")), n);
|
|
347
356
|
t.then((e) => {
|
|
348
357
|
a(), r(e);
|
|
349
358
|
}, (e) => {
|
|
@@ -351,138 +360,138 @@ function m(o) {
|
|
|
351
360
|
});
|
|
352
361
|
});
|
|
353
362
|
}
|
|
354
|
-
let
|
|
355
|
-
|
|
356
|
-
let e =
|
|
357
|
-
if (e !==
|
|
363
|
+
let Q = [];
|
|
364
|
+
Q.push(l.subscribe(() => {
|
|
365
|
+
let e = l.getState().avatarEnabled;
|
|
366
|
+
if (e !== w) {
|
|
358
367
|
if (e) {
|
|
359
|
-
|
|
368
|
+
l.setAvatarEnabled(!1);
|
|
360
369
|
return;
|
|
361
370
|
}
|
|
362
|
-
|
|
371
|
+
y.phase !== "off" && y.phase !== "checking" && y.phase !== "choosing" ? W(j ? "voice_end" : "user", {}) : w = !1;
|
|
363
372
|
}
|
|
364
|
-
})),
|
|
365
|
-
if (
|
|
366
|
-
|
|
373
|
+
})), s.subscribeWorkspaceChange && Q.push(s.subscribeWorkspaceChange(() => {
|
|
374
|
+
if (x = !1, y.phase === "off") {
|
|
375
|
+
L({
|
|
367
376
|
problem: null,
|
|
368
377
|
avatars: [],
|
|
369
378
|
consentVersion: null
|
|
370
379
|
});
|
|
371
380
|
return;
|
|
372
381
|
}
|
|
373
|
-
|
|
382
|
+
W("workspace_switch", { problem: null }), L({
|
|
374
383
|
avatars: [],
|
|
375
384
|
consentVersion: null
|
|
376
385
|
});
|
|
377
|
-
})),
|
|
378
|
-
(
|
|
386
|
+
})), s.subscribePageHide && Q.push(s.subscribePageHide(() => {
|
|
387
|
+
(D !== null || y.phase !== "off") && W("page_hide", { keepalive: !0 });
|
|
379
388
|
}));
|
|
380
|
-
let
|
|
389
|
+
let $ = {
|
|
381
390
|
subscribe(e) {
|
|
382
|
-
return
|
|
383
|
-
|
|
391
|
+
return b.add(e), () => {
|
|
392
|
+
b.delete(e);
|
|
384
393
|
};
|
|
385
394
|
},
|
|
386
|
-
getSnapshot: () =>
|
|
395
|
+
getSnapshot: () => y,
|
|
387
396
|
setVoiceLive(e) {
|
|
388
|
-
if (
|
|
389
|
-
|
|
397
|
+
if (j = !e, e) {
|
|
398
|
+
L({
|
|
390
399
|
voiceLive: !0,
|
|
391
|
-
problem:
|
|
400
|
+
problem: x ? y.problem : null,
|
|
392
401
|
notice: null
|
|
393
402
|
});
|
|
394
403
|
return;
|
|
395
404
|
}
|
|
396
|
-
(
|
|
405
|
+
(D !== null || y.phase !== "off") && (y.phase === "checking" || y.phase === "choosing" ? (E += 1, L({ phase: "off" })) : W("voice_end", {})), L({
|
|
397
406
|
voiceLive: !1,
|
|
398
407
|
notice: null
|
|
399
408
|
});
|
|
400
409
|
},
|
|
401
410
|
requestOn() {
|
|
402
|
-
if (
|
|
403
|
-
let e =
|
|
411
|
+
if (P || !y.offered || y.phase !== "off") return;
|
|
412
|
+
let e = s.client();
|
|
404
413
|
if (e === null) {
|
|
405
|
-
|
|
414
|
+
K();
|
|
406
415
|
return;
|
|
407
416
|
}
|
|
408
|
-
let t = ++
|
|
409
|
-
|
|
417
|
+
let t = ++E;
|
|
418
|
+
L({
|
|
410
419
|
phase: "checking",
|
|
411
420
|
problem: null,
|
|
412
421
|
notice: null
|
|
413
|
-
}),
|
|
414
|
-
if (
|
|
422
|
+
}), X((t) => e.availability(t)).then((e) => {
|
|
423
|
+
if (E !== t) return;
|
|
415
424
|
if (!e.available) {
|
|
416
|
-
|
|
425
|
+
K(a(e.reason));
|
|
417
426
|
return;
|
|
418
427
|
}
|
|
419
|
-
|
|
420
|
-
let n =
|
|
421
|
-
|
|
428
|
+
C = e.maxSessionSeconds * 1e3;
|
|
429
|
+
let n = l.getState().avatarId, r = n !== null && e.avatars.includes(n) ? n : e.avatars[0] ?? null;
|
|
430
|
+
L({
|
|
422
431
|
phase: "choosing",
|
|
423
432
|
avatars: e.avatars,
|
|
424
433
|
selectedAvatarId: r,
|
|
425
434
|
consentVersion: e.consentVersion
|
|
426
|
-
}),
|
|
435
|
+
}), S === e.consentVersion && e.avatars.length === 1 && $.confirm();
|
|
427
436
|
}, (e) => {
|
|
428
|
-
|
|
437
|
+
E === t && G(e);
|
|
429
438
|
});
|
|
430
439
|
},
|
|
431
440
|
confirm() {
|
|
432
|
-
if (
|
|
433
|
-
let e =
|
|
434
|
-
e === null || t === null || (
|
|
441
|
+
if (y.phase !== "choosing" || !y.voiceLive) return;
|
|
442
|
+
let e = y.selectedAvatarId, t = y.consentVersion;
|
|
443
|
+
e === null || t === null || (S = t, l.setAvatarId(e), w = !0, R(), Y(e, t));
|
|
435
444
|
},
|
|
436
445
|
cancelChoice() {
|
|
437
|
-
|
|
446
|
+
y.phase === "choosing" && (E += 1, L({ phase: "off" }));
|
|
438
447
|
},
|
|
439
448
|
selectAvatar(e) {
|
|
440
|
-
|
|
449
|
+
y.avatars.includes(e) && L({ selectedAvatarId: e });
|
|
441
450
|
},
|
|
442
451
|
switchOff() {
|
|
443
|
-
if (
|
|
444
|
-
|
|
452
|
+
if (y.phase === "checking" || y.phase === "choosing") {
|
|
453
|
+
E += 1, L({ phase: "off" });
|
|
445
454
|
return;
|
|
446
455
|
}
|
|
447
|
-
if (
|
|
448
|
-
|
|
456
|
+
if (y.phase === "off" && !w) {
|
|
457
|
+
R();
|
|
449
458
|
return;
|
|
450
459
|
}
|
|
451
|
-
|
|
460
|
+
W(j ? "voice_end" : "user", {});
|
|
452
461
|
},
|
|
453
462
|
resumeAudio() {
|
|
454
|
-
let e =
|
|
463
|
+
let e = O;
|
|
455
464
|
e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0));
|
|
456
465
|
},
|
|
457
466
|
setStageMounted(e) {
|
|
458
|
-
|
|
467
|
+
A = Math.max(0, A + (e ? 1 : -1));
|
|
459
468
|
},
|
|
460
469
|
attachVideo(e) {
|
|
461
|
-
let t =
|
|
470
|
+
let t = O?.videoTrack ?? null;
|
|
462
471
|
if (e === null) {
|
|
463
|
-
|
|
472
|
+
k !== null && t?.detach(), k = null;
|
|
464
473
|
return;
|
|
465
474
|
}
|
|
466
|
-
|
|
475
|
+
k = e, t?.attach(e);
|
|
467
476
|
},
|
|
468
477
|
route(e, t) {
|
|
469
|
-
if (
|
|
478
|
+
if (y.phase !== "ready" || T || !w || A === 0 || O === null || O.port.isAudioBlocked() || e.fallback === !1) return "speakers";
|
|
470
479
|
let n = e.voice;
|
|
471
|
-
return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (
|
|
480
|
+
return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (F({
|
|
472
481
|
event: "notice",
|
|
473
482
|
notice: { kind: "needs-hosted-voice" }
|
|
474
|
-
}),
|
|
483
|
+
}), L({ problem: "needs-hosted-voice" }), "speakers") : (y.problem === "needs-hosted-voice" && L({ problem: null }), "avatar");
|
|
475
484
|
},
|
|
476
|
-
createOutput: () =>
|
|
485
|
+
createOutput: () => B.createOutput(),
|
|
477
486
|
dispose() {
|
|
478
|
-
if (!
|
|
479
|
-
|
|
480
|
-
for (let e of
|
|
481
|
-
|
|
487
|
+
if (!P) {
|
|
488
|
+
P = !0, (D !== null || y.phase !== "off") && W("user", {});
|
|
489
|
+
for (let e of Q.splice(0)) e();
|
|
490
|
+
b.clear();
|
|
482
491
|
}
|
|
483
492
|
}
|
|
484
493
|
};
|
|
485
|
-
return
|
|
494
|
+
return $;
|
|
486
495
|
}
|
|
487
496
|
//#endregion
|
|
488
|
-
export {
|
|
497
|
+
export { d as LIVE_AVATAR_CONNECT_TIMEOUT_MS, c as LIVE_AVATAR_END_BEFORE_DEADLINE_MS, s as LIVE_AVATAR_IDLE_MS, l as LIVE_AVATAR_REQUEST_TIMEOUT_MS, g as createLiveAvatarController };
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* word for word by `avatarConsentCopy.test.ts`.
|
|
18
18
|
*/
|
|
19
19
|
/** What the person can be told went wrong; the adapter maps server codes onto these. */
|
|
20
|
-
export type AvatarProblem = 'unavailable' | 'not-ready' | 'already-running' | 'capacity' | 'rate-limited' | 'paused' | 'provider' | 'connection' | 'needs-hosted-voice' | 'unsupported-browser' | 'playback-blocked';
|
|
20
|
+
export type AvatarProblem = 'unavailable' | 'not-ready' | 'already-running' | 'capacity' | 'rate-limited' | 'paused' | 'start-timeout' | 'provider' | 'connection' | 'needs-hosted-voice' | 'unsupported-browser' | 'playback-blocked';
|
|
21
21
|
export interface AvatarCopy {
|
|
22
22
|
toggle: string;
|
|
23
23
|
toggleHint: string;
|