@burdenoff/fe-libs 2026.1024.4 → 2026.1026.1
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/LiveAvatarStage.js +2 -3
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +2 -3
- package/dist/shared/assistant/avatar/live/avatarPorts.d.ts +9 -0
- package/dist/shared/assistant/avatar/live/avatarTransport.d.ts +25 -3
- package/dist/shared/assistant/avatar/live/avatarTransport.js +29 -2
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +22 -4
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +113 -81
- package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +15 -1
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +204 -186
- package/dist/shared/assistant/avatar/live/liveKitAvatarRoom.js +6 -1
- package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +1 -1
- package/dist/shared-assistant.js +2 -2
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ var c = 12e4, l = 1e4, u = 8e3, ee = 5e3, d = 2e4, f = 15e3, te = 2, ne = 5, p =
|
|
|
20
20
|
notice: null,
|
|
21
21
|
audioBlocked: !1,
|
|
22
22
|
videoReady: !1,
|
|
23
|
+
videoBlocked: !1,
|
|
23
24
|
minutes: null,
|
|
24
25
|
minutesReason: null,
|
|
25
26
|
sessionMinutes: null,
|
|
@@ -79,8 +80,8 @@ function h(c) {
|
|
|
79
80
|
let { scheduler: l, preferences: u } = c, d = c.idleMs ?? 12e4, te = c.endBeforeDeadlineMs ?? 1e4, ne = c.connectTimeoutMs ?? 2e4, m = c.requestTimeoutMs ?? 8e3, h = {
|
|
80
81
|
...re,
|
|
81
82
|
tabOffered: c.browserSupported()
|
|
82
|
-
}, g = /* @__PURE__ */ new Set(), _ = !1, le = null, ue = 0,
|
|
83
|
-
function
|
|
83
|
+
}, g = /* @__PURE__ */ new Set(), _ = !1, v = null, le = null, ue = 0, y = !1, b = !1, x = 0, S = null, C = null, w = [], de = 0, fe = !1, pe = "user", T = !1, E = !1, D = null, O = null, k = null, A = null, j = !1, me = 0, M = 0, N = null, P = !1, F = !1, I = null, L = null, R = 0, z = 0, he = !1, B = 0, V = null, H = !1;
|
|
84
|
+
function U(e) {
|
|
84
85
|
try {
|
|
85
86
|
c.onLog?.(e);
|
|
86
87
|
} catch {}
|
|
@@ -91,10 +92,10 @@ function h(c) {
|
|
|
91
92
|
function _e(e, t) {
|
|
92
93
|
return (e || t) && ge();
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function W() {
|
|
95
96
|
return h.retryAt !== null && c.now() < h.retryAt;
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
+
function G(e) {
|
|
98
99
|
let t = {
|
|
99
100
|
...h,
|
|
100
101
|
...e
|
|
@@ -104,36 +105,36 @@ function h(c) {
|
|
|
104
105
|
...t,
|
|
105
106
|
offered: _e(t.voiceLive, t.tabOpen),
|
|
106
107
|
tabOffered: ge(),
|
|
107
|
-
heldByVoice:
|
|
108
|
+
heldByVoice: E && t.voiceLive
|
|
108
109
|
};
|
|
109
110
|
if (!Object.keys(n).every((e) => n[e] === h[e])) {
|
|
110
|
-
n.retryAt !== h.retryAt && (
|
|
111
|
+
n.retryAt !== h.retryAt && (A?.(), A = null), h = n;
|
|
111
112
|
for (let e of [...g]) try {
|
|
112
113
|
e();
|
|
113
114
|
} catch {}
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
function ve() {
|
|
117
|
-
return fe && !
|
|
118
|
+
return fe && !T ? "voice_end" : "user";
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
u.getState().avatarEnabled !==
|
|
120
|
+
function K() {
|
|
121
|
+
u.getState().avatarEnabled !== y && u.setAvatarEnabled(y);
|
|
121
122
|
}
|
|
122
123
|
let ye = {
|
|
123
124
|
positionSec: null,
|
|
124
125
|
synthetic: !0,
|
|
125
126
|
rpc: "none"
|
|
126
|
-
},
|
|
127
|
+
}, q = r({
|
|
127
128
|
port: {
|
|
128
|
-
isActive: () =>
|
|
129
|
-
isAudioBlocked: () =>
|
|
130
|
-
connectionId: () =>
|
|
131
|
-
isMeterHealthy: () =>
|
|
132
|
-
isMeterAudible: () =>
|
|
133
|
-
openSegment: () =>
|
|
134
|
-
clearBuffer: (e) =>
|
|
135
|
-
setOutputMuted: (e) =>
|
|
136
|
-
subscribe: (e) =>
|
|
129
|
+
isActive: () => C !== null && C.port.isActive(),
|
|
130
|
+
isAudioBlocked: () => C?.port.isAudioBlocked() ?? !1,
|
|
131
|
+
connectionId: () => C?.port.connectionId() ?? 0,
|
|
132
|
+
isMeterHealthy: () => C?.port.isMeterHealthy() ?? !1,
|
|
133
|
+
isMeterAudible: () => C?.port.isMeterAudible() ?? !1,
|
|
134
|
+
openSegment: () => C ? C.port.openSegment() : Promise.reject(new e("connection")),
|
|
135
|
+
clearBuffer: (e) => C ? C.port.clearBuffer(e) : Promise.resolve(ye),
|
|
136
|
+
setOutputMuted: (e) => C?.port.setOutputMuted(e),
|
|
137
|
+
subscribe: (e) => C ? C.port.subscribe(e) : () => void 0
|
|
137
138
|
},
|
|
138
139
|
scheduler: l,
|
|
139
140
|
decode: c.decode,
|
|
@@ -141,18 +142,18 @@ function h(c) {
|
|
|
141
142
|
...c.maxDrainMs === void 0 ? {} : { maxDrainMs: c.maxDrainMs },
|
|
142
143
|
...c.stallMs === void 0 ? {} : { stallMs: c.stallMs },
|
|
143
144
|
onNotice: (e) => {
|
|
144
|
-
switch (
|
|
145
|
+
switch (U({
|
|
145
146
|
event: "notice",
|
|
146
147
|
notice: e
|
|
147
148
|
}), e.kind) {
|
|
148
149
|
case "interrupted":
|
|
149
|
-
|
|
150
|
+
G({ notice: "interrupted" });
|
|
150
151
|
return;
|
|
151
152
|
case "voice-fallback":
|
|
152
|
-
|
|
153
|
+
y && G({ notice: "voice-only" });
|
|
153
154
|
return;
|
|
154
155
|
case "audio-blocked":
|
|
155
|
-
|
|
156
|
+
G({
|
|
156
157
|
audioBlocked: !0,
|
|
157
158
|
problem: "playback-blocked"
|
|
158
159
|
});
|
|
@@ -162,11 +163,11 @@ function h(c) {
|
|
|
162
163
|
},
|
|
163
164
|
onActivity: (e) => {
|
|
164
165
|
if (e) {
|
|
165
|
-
|
|
166
|
+
O?.(), O = null;
|
|
166
167
|
return;
|
|
167
168
|
}
|
|
168
|
-
if (
|
|
169
|
-
|
|
169
|
+
if (b) {
|
|
170
|
+
J("user", { notice: be() });
|
|
170
171
|
return;
|
|
171
172
|
}
|
|
172
173
|
xe();
|
|
@@ -176,17 +177,17 @@ function h(c) {
|
|
|
176
177
|
return he ? "minutes-ended" : "time-limit";
|
|
177
178
|
}
|
|
178
179
|
function xe() {
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
O?.(), O = null, h.phase === "ready" && (O = l.setTimeout(() => {
|
|
181
|
+
O = null, h.phase === "ready" && !q.isBusy() && J("idle", {});
|
|
181
182
|
}, d));
|
|
182
183
|
}
|
|
183
184
|
function Se() {
|
|
184
|
-
|
|
185
|
+
O?.(), O = null, k?.(), k = null;
|
|
185
186
|
}
|
|
186
187
|
function Ce() {
|
|
187
|
-
|
|
188
|
-
let e =
|
|
189
|
-
if (
|
|
188
|
+
q.leave();
|
|
189
|
+
let e = C;
|
|
190
|
+
if (C = null, e !== null) {
|
|
190
191
|
if (e.unsubscribe?.(), e.meter !== null) {
|
|
191
192
|
if (e.meterAudible) {
|
|
192
193
|
e.meterAudible = !1;
|
|
@@ -197,11 +198,11 @@ function h(c) {
|
|
|
197
198
|
e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && c.releaseAudioElement(e.audioElement);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
|
|
202
|
-
let n =
|
|
203
|
-
if (
|
|
204
|
-
|
|
201
|
+
function J(e, t) {
|
|
202
|
+
x += 1, pe = e, y = !1, b = !1, E = !1, D = null, he = !1, Ce(), Se();
|
|
203
|
+
let n = S;
|
|
204
|
+
if (S = null, K(), n !== null) {
|
|
205
|
+
U({
|
|
205
206
|
event: "session-ended",
|
|
206
207
|
reason: e
|
|
207
208
|
});
|
|
@@ -211,11 +212,12 @@ function h(c) {
|
|
|
211
212
|
keepalive: t.keepalive === !0
|
|
212
213
|
}).then(i, i);
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
+
Be(), G({
|
|
215
216
|
phase: "off",
|
|
216
217
|
closing: !1,
|
|
217
218
|
audioBlocked: !1,
|
|
218
219
|
videoReady: !1,
|
|
220
|
+
videoBlocked: !1,
|
|
219
221
|
sessionMinutes: null,
|
|
220
222
|
sessionEndsAt: null,
|
|
221
223
|
...t.problem === void 0 ? h.problem !== null && ae.has(h.problem) ? { problem: null } : {} : { problem: t.problem },
|
|
@@ -224,34 +226,34 @@ function h(c) {
|
|
|
224
226
|
}
|
|
225
227
|
function we(e) {
|
|
226
228
|
let t = s(e);
|
|
227
|
-
t.hide && (_ = !0), e instanceof i &&
|
|
229
|
+
t.hide && (_ = !0), e instanceof i && U({
|
|
228
230
|
event: "refused",
|
|
229
231
|
status: e.status,
|
|
230
232
|
code: e.code
|
|
231
|
-
}),
|
|
233
|
+
}), y = !1, E = !1, D = null, K();
|
|
232
234
|
let n = t.retryAfterSeconds !== void 0 && t.retryAfterSeconds > 0 ? t.retryAfterSeconds * 1e3 : 0, r = n > 0 ? c.now() + n : null;
|
|
233
|
-
return
|
|
235
|
+
return G({
|
|
234
236
|
phase: "off",
|
|
235
237
|
problem: t.problem,
|
|
236
238
|
retryAt: r,
|
|
237
239
|
budgetScope: t.scope ?? null,
|
|
238
240
|
minutesReason: t.minutesReason ?? null
|
|
239
|
-
}), r !== null && h.retryAt === r && (
|
|
240
|
-
|
|
241
|
-
}, n)), t.problem !== null && se.has(t.problem) &&
|
|
241
|
+
}), r !== null && h.retryAt === r && (A = l.setTimeout(() => {
|
|
242
|
+
A = null, Te(r);
|
|
243
|
+
}, n)), t.problem !== null && se.has(t.problem) && Z(!0), t;
|
|
242
244
|
}
|
|
243
245
|
function Te(e) {
|
|
244
|
-
h.retryAt === e &&
|
|
246
|
+
h.retryAt === e && G({
|
|
245
247
|
problem: null,
|
|
246
248
|
retryAt: null
|
|
247
249
|
});
|
|
248
250
|
}
|
|
249
251
|
function Ee() {
|
|
250
252
|
let e = h.retryAt;
|
|
251
|
-
|
|
253
|
+
j || e === null || W() || Te(e);
|
|
252
254
|
}
|
|
253
|
-
function
|
|
254
|
-
e.hide && (_ = !0),
|
|
255
|
+
function Y(e = oe) {
|
|
256
|
+
e.hide && (_ = !0), y = !1, E = !1, D = null, K(), Pe(), G({
|
|
255
257
|
phase: "off",
|
|
256
258
|
problem: e.problem,
|
|
257
259
|
retryAt: null,
|
|
@@ -261,7 +263,7 @@ function h(c) {
|
|
|
261
263
|
});
|
|
262
264
|
}
|
|
263
265
|
function De(e) {
|
|
264
|
-
|
|
266
|
+
D = null, G({
|
|
265
267
|
phase: "off",
|
|
266
268
|
problem: e.problem,
|
|
267
269
|
retryAt: null,
|
|
@@ -269,10 +271,10 @@ function h(c) {
|
|
|
269
271
|
});
|
|
270
272
|
}
|
|
271
273
|
function Oe() {
|
|
272
|
-
return
|
|
274
|
+
return N = l.now(), me += 1, me;
|
|
273
275
|
}
|
|
274
276
|
function ke(e) {
|
|
275
|
-
return e <=
|
|
277
|
+
return e <= M ? !1 : (M = e, !0);
|
|
276
278
|
}
|
|
277
279
|
function Ae(e, t) {
|
|
278
280
|
return ke(e) ? { minutes: t } : {};
|
|
@@ -292,24 +294,24 @@ function h(c) {
|
|
|
292
294
|
return c.isPageVisible?.() ?? !0;
|
|
293
295
|
}
|
|
294
296
|
function Ne() {
|
|
295
|
-
|
|
297
|
+
I?.(), I = null, L = null;
|
|
296
298
|
}
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
+
function X() {
|
|
300
|
+
B += 1, V?.(), V = null, h.purchase !== "idle" && G({ purchase: "idle" });
|
|
299
301
|
}
|
|
300
302
|
function Pe() {
|
|
301
|
-
|
|
303
|
+
M = me, F = !1, R = 0, Ne(), X();
|
|
302
304
|
}
|
|
303
305
|
function Fe() {
|
|
304
|
-
return !
|
|
306
|
+
return !j && h.minutes !== null && h.offered && (h.phase === "off" || h.phase === "choosing");
|
|
305
307
|
}
|
|
306
|
-
function
|
|
307
|
-
if (e && (
|
|
308
|
-
if (
|
|
309
|
-
|
|
308
|
+
function Z(e) {
|
|
309
|
+
if (e && (R = 0), !Fe() || !Me()) return;
|
|
310
|
+
if (P) {
|
|
311
|
+
F = !0;
|
|
310
312
|
return;
|
|
311
313
|
}
|
|
312
|
-
let t = l.now(), n = Math.max(
|
|
314
|
+
let t = l.now(), n = Math.max(N === null ? t : N + f, z);
|
|
313
315
|
if (t < n) {
|
|
314
316
|
Ie(n);
|
|
315
317
|
return;
|
|
@@ -318,78 +320,91 @@ function h(c) {
|
|
|
318
320
|
r !== null && Re(r);
|
|
319
321
|
}
|
|
320
322
|
function Ie(e) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
I !== null && L !== null && L <= e || (Ne(), L = e, I = l.setTimeout(() => {
|
|
324
|
+
I = null, L = null, Z(!1);
|
|
323
325
|
}, e - l.now()));
|
|
324
326
|
}
|
|
325
327
|
function Le(e) {
|
|
326
|
-
return !(e instanceof i) || e.status !== 429 ? !1 : (
|
|
328
|
+
return !(e instanceof i) || e.status !== 429 ? !1 : (z = Math.max(z, l.now() + Math.max(0, e.retryAfterSeconds ?? 0) * 1e3), !0);
|
|
327
329
|
}
|
|
328
330
|
function Re(e) {
|
|
329
331
|
let t = Oe();
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
P = !0, Ge((t) => e.availability(t)).then((e) => {
|
|
333
|
+
j || (R = 0, G(je(t, e.available ? e.minutes ?? null : null)));
|
|
332
334
|
}, (e) => {
|
|
333
|
-
|
|
335
|
+
j || Le(e) && t > M && R < 2 && (R += 1, F = !0);
|
|
334
336
|
}).finally(() => {
|
|
335
|
-
|
|
337
|
+
P = !1, F && (F = !1, Z(!1));
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
340
|
function ze(e) {
|
|
339
|
-
e === "workspace_switch" || e === "page_hide" ||
|
|
341
|
+
e === "workspace_switch" || e === "page_hide" || Z(!0);
|
|
342
|
+
}
|
|
343
|
+
function Be() {
|
|
344
|
+
let e = v;
|
|
345
|
+
v = null, e?.();
|
|
346
|
+
}
|
|
347
|
+
function Ve() {
|
|
348
|
+
v !== null || !c.subscribeUserGesture || (v = c.subscribeUserGesture(() => {
|
|
349
|
+
let e = C;
|
|
350
|
+
e === null || !h.videoBlocked || e.transport.resumeVideo().catch(() => void 0);
|
|
351
|
+
}));
|
|
340
352
|
}
|
|
341
|
-
function
|
|
353
|
+
function He(e) {
|
|
342
354
|
switch (e.type) {
|
|
343
355
|
case "audioPlayback":
|
|
344
|
-
e.canPlay ? h.problem === "playback-blocked" ?
|
|
356
|
+
e.canPlay ? h.problem === "playback-blocked" ? G({
|
|
345
357
|
audioBlocked: !1,
|
|
346
358
|
problem: null
|
|
347
|
-
}) :
|
|
359
|
+
}) : G({ audioBlocked: !1 }) : G({
|
|
348
360
|
audioBlocked: !0,
|
|
349
361
|
problem: "playback-blocked"
|
|
350
362
|
});
|
|
351
363
|
return;
|
|
364
|
+
case "videoPlayback":
|
|
365
|
+
G({ videoBlocked: !e.canPlay }), e.canPlay ? Be() : Ve();
|
|
366
|
+
return;
|
|
352
367
|
case "avatarLeft":
|
|
353
368
|
case "disconnected":
|
|
354
|
-
|
|
369
|
+
Ue();
|
|
355
370
|
return;
|
|
356
371
|
default: return;
|
|
357
372
|
}
|
|
358
373
|
}
|
|
359
|
-
async function
|
|
360
|
-
let e =
|
|
374
|
+
async function Ue() {
|
|
375
|
+
let e = S;
|
|
361
376
|
if (e === null || h.phase === "ending" || h.phase === "off") return;
|
|
362
|
-
let t =
|
|
363
|
-
|
|
377
|
+
let t = x;
|
|
378
|
+
G({ phase: "ending" });
|
|
364
379
|
let n = null, r = !1;
|
|
365
380
|
try {
|
|
366
|
-
let t = c.client(), i = t === null ? void 0 : await
|
|
381
|
+
let t = c.client(), i = t === null ? void 0 : await Ge((n) => t.status(e, n));
|
|
367
382
|
n = i?.endedReason ?? null, r = i !== void 0 && [
|
|
368
383
|
"ended",
|
|
369
384
|
"failed",
|
|
370
385
|
"canceled"
|
|
371
386
|
].includes(i.state);
|
|
372
387
|
} catch {}
|
|
373
|
-
if (
|
|
388
|
+
if (x !== t) return;
|
|
374
389
|
let i = ie(n);
|
|
375
|
-
i.hide && (_ = !0), r && (
|
|
390
|
+
i.hide && (_ = !0), r && (S = null, U({
|
|
376
391
|
event: "session-ended",
|
|
377
392
|
reason: "server"
|
|
378
393
|
}));
|
|
379
394
|
let a = i.notice === "time-limit" ? be() : i.notice;
|
|
380
|
-
|
|
395
|
+
J("client_error", {
|
|
381
396
|
problem: i.problem,
|
|
382
397
|
notice: a
|
|
383
398
|
}), r && ze("client_error");
|
|
384
399
|
}
|
|
385
|
-
async function
|
|
400
|
+
async function We(e, r) {
|
|
386
401
|
let i = c.client();
|
|
387
402
|
if (i === null) {
|
|
388
|
-
|
|
403
|
+
Y();
|
|
389
404
|
return;
|
|
390
405
|
}
|
|
391
|
-
let a = ++
|
|
392
|
-
|
|
406
|
+
let a = ++x;
|
|
407
|
+
G({
|
|
393
408
|
phase: "starting",
|
|
394
409
|
problem: null,
|
|
395
410
|
notice: null
|
|
@@ -398,13 +413,13 @@ function h(c) {
|
|
|
398
413
|
try {
|
|
399
414
|
o = await c.openRoom();
|
|
400
415
|
} catch {
|
|
401
|
-
|
|
416
|
+
x === a && Y();
|
|
402
417
|
return;
|
|
403
418
|
}
|
|
404
419
|
let s = () => {
|
|
405
420
|
o.disconnect().catch(() => void 0);
|
|
406
421
|
};
|
|
407
|
-
if (
|
|
422
|
+
if (x !== a) {
|
|
408
423
|
s();
|
|
409
424
|
return;
|
|
410
425
|
}
|
|
@@ -416,15 +431,15 @@ function h(c) {
|
|
|
416
431
|
idempotencyKey: c.newIdempotencyKey()
|
|
417
432
|
});
|
|
418
433
|
} catch (e) {
|
|
419
|
-
if (s(),
|
|
434
|
+
if (s(), x !== a) return;
|
|
420
435
|
we(e).showDisclosure && (le = null, $.requestOn({ start: !1 }));
|
|
421
436
|
return;
|
|
422
437
|
}
|
|
423
|
-
if (
|
|
438
|
+
if (x !== a) {
|
|
424
439
|
s(), i.end(d.sessionId, { reason: pe === "voice_end" ? "voice_end" : "user" }).catch(() => void 0);
|
|
425
440
|
return;
|
|
426
441
|
}
|
|
427
|
-
|
|
442
|
+
S = d.sessionId, G({ phase: "connecting" });
|
|
428
443
|
let f = new t({
|
|
429
444
|
room: o,
|
|
430
445
|
avatarIdentity: d.avatarIdentity,
|
|
@@ -441,16 +456,16 @@ function h(c) {
|
|
|
441
456
|
unsubscribe: null,
|
|
442
457
|
port: n({
|
|
443
458
|
transport: f,
|
|
444
|
-
isEnabled: () =>
|
|
459
|
+
isEnabled: () => y && !b,
|
|
445
460
|
subscribeMeter: (e) => (p.add(e), () => {
|
|
446
461
|
p.delete(e);
|
|
447
462
|
}),
|
|
448
463
|
isMeterHealthy: () => m.meter?.isRunning() ?? !1
|
|
449
464
|
})
|
|
450
465
|
};
|
|
451
|
-
|
|
466
|
+
C = m, m.unsubscribe = f.subscribe(He);
|
|
452
467
|
try {
|
|
453
|
-
await
|
|
468
|
+
await Ke(f.connect({
|
|
454
469
|
url: d.livekitUrl,
|
|
455
470
|
token: d.participantToken,
|
|
456
471
|
audioElement: m.audioElement,
|
|
@@ -466,33 +481,34 @@ function h(c) {
|
|
|
466
481
|
},
|
|
467
482
|
onAvatarVideo: (e) => {
|
|
468
483
|
m.videoTrack = e;
|
|
469
|
-
let t =
|
|
470
|
-
t !== null && e.attach(t),
|
|
484
|
+
let t = qe();
|
|
485
|
+
t !== null && e.attach(t), C === m && G({ videoReady: !0 });
|
|
471
486
|
}
|
|
472
487
|
}), ne);
|
|
473
488
|
} catch (e) {
|
|
474
|
-
if (
|
|
475
|
-
|
|
489
|
+
if (x !== a) return;
|
|
490
|
+
U({
|
|
476
491
|
event: "connect-failed",
|
|
477
492
|
error: e instanceof Error ? e.name : "error"
|
|
478
|
-
}),
|
|
493
|
+
}), J("client_error", { problem: "connection" });
|
|
479
494
|
return;
|
|
480
495
|
}
|
|
481
|
-
if (
|
|
496
|
+
if (x !== a || C !== m) return;
|
|
482
497
|
let re = d.maxSessionSeconds === void 0 ? ue : d.maxSessionSeconds * 1e3, ie = re > 0 ? u + re - ee - l.now() : d.endsAt - c.now();
|
|
483
|
-
he = d.minutes?.limitedByBalance === !0,
|
|
498
|
+
he = d.minutes?.limitedByBalance === !0, G({
|
|
484
499
|
phase: "ready",
|
|
485
500
|
audioBlocked: f.audioBlocked,
|
|
501
|
+
videoBlocked: f.videoBlocked,
|
|
486
502
|
...f.audioBlocked ? { problem: "playback-blocked" } : {},
|
|
487
503
|
sessionMinutes: d.minutes ?? null,
|
|
488
504
|
sessionEndsAt: d.maxSessionSeconds === void 0 ? null : c.now() + ie
|
|
489
505
|
}), xe();
|
|
490
506
|
let ae = Math.max(0, ie - te);
|
|
491
|
-
|
|
492
|
-
|
|
507
|
+
k = l.setTimeout(() => {
|
|
508
|
+
k = null, x === a && (b = !0, G({ closing: !0 }), q.isBusy() || J("user", { notice: be() }));
|
|
493
509
|
}, ae);
|
|
494
510
|
}
|
|
495
|
-
function
|
|
511
|
+
function Ge(t) {
|
|
496
512
|
let n = new AbortController();
|
|
497
513
|
return new Promise((r, i) => {
|
|
498
514
|
let a = l.setTimeout(() => {
|
|
@@ -505,7 +521,7 @@ function h(c) {
|
|
|
505
521
|
});
|
|
506
522
|
});
|
|
507
523
|
}
|
|
508
|
-
function
|
|
524
|
+
function Ke(t, n) {
|
|
509
525
|
return new Promise((r, i) => {
|
|
510
526
|
let a = l.setTimeout(() => i(new e("connection")), n);
|
|
511
527
|
t.then((e) => {
|
|
@@ -515,50 +531,52 @@ function h(c) {
|
|
|
515
531
|
});
|
|
516
532
|
});
|
|
517
533
|
}
|
|
518
|
-
function
|
|
519
|
-
return
|
|
534
|
+
function qe() {
|
|
535
|
+
return w[w.length - 1] ?? null;
|
|
520
536
|
}
|
|
521
|
-
function
|
|
522
|
-
let t =
|
|
537
|
+
function Je(e) {
|
|
538
|
+
let t = w.indexOf(e);
|
|
523
539
|
if (t === -1) return;
|
|
524
|
-
let n = t ===
|
|
525
|
-
|
|
526
|
-
let r =
|
|
540
|
+
let n = t === w.length - 1;
|
|
541
|
+
w.splice(t, 1);
|
|
542
|
+
let r = C?.videoTrack ?? null;
|
|
527
543
|
if (!n || r === null) return;
|
|
528
544
|
r.detach();
|
|
529
|
-
let i =
|
|
545
|
+
let i = qe();
|
|
530
546
|
i !== null && r.attach(i);
|
|
531
547
|
}
|
|
532
548
|
let Q = [];
|
|
533
549
|
Q.push(u.subscribe(() => {
|
|
534
550
|
let e = u.getState().avatarEnabled;
|
|
535
|
-
if (e !==
|
|
551
|
+
if (e !== y) {
|
|
536
552
|
if (e) {
|
|
537
553
|
u.setAvatarEnabled(!1);
|
|
538
554
|
return;
|
|
539
555
|
}
|
|
540
|
-
h.phase !== "off" && h.phase !== "checking" && h.phase !== "choosing" ?
|
|
556
|
+
h.phase !== "off" && h.phase !== "checking" && h.phase !== "choosing" ? J(ve(), {}) : y = !1;
|
|
541
557
|
}
|
|
542
558
|
})), c.subscribeWorkspaceChange && Q.push(c.subscribeWorkspaceChange(() => {
|
|
543
|
-
if (_ = !1, Pe(), h.phase === "off" ?
|
|
559
|
+
if (_ = !1, Pe(), h.phase === "off" ? G({
|
|
544
560
|
problem: null,
|
|
545
561
|
avatars: [],
|
|
546
562
|
consentVersion: null,
|
|
547
563
|
minutes: null
|
|
548
|
-
}) : (
|
|
564
|
+
}) : (J("workspace_switch", { problem: null }), G({
|
|
549
565
|
avatars: [],
|
|
550
566
|
consentVersion: null,
|
|
551
567
|
minutes: null
|
|
552
|
-
})),
|
|
553
|
-
let e =
|
|
568
|
+
})), T) {
|
|
569
|
+
let e = x;
|
|
554
570
|
l.setTimeout(() => {
|
|
555
|
-
|
|
571
|
+
T && x === e && $.requestOn({ start: !1 });
|
|
556
572
|
}, 0);
|
|
557
573
|
}
|
|
558
574
|
})), c.subscribePageHide && Q.push(c.subscribePageHide(() => {
|
|
559
|
-
(
|
|
575
|
+
(S !== null || h.phase !== "off") && J("page_hide", { keepalive: !0 });
|
|
576
|
+
})), c.subscribePageHidden && Q.push(c.subscribePageHidden(() => {
|
|
577
|
+
c.endOnHide?.() === !0 && (S !== null || h.phase !== "off") && J("page_hide", { keepalive: !0 });
|
|
560
578
|
})), c.subscribePageVisible && Q.push(c.subscribePageVisible(() => {
|
|
561
|
-
|
|
579
|
+
P || Z(!0);
|
|
562
580
|
})), c.subscribePageShow && Q.push(c.subscribePageShow(Ee));
|
|
563
581
|
let $ = {
|
|
564
582
|
subscribe(e) {
|
|
@@ -569,46 +587,46 @@ function h(c) {
|
|
|
569
587
|
getSnapshot: () => h,
|
|
570
588
|
setVoiceLive(e) {
|
|
571
589
|
if (fe = !e, e) {
|
|
572
|
-
|
|
590
|
+
G({
|
|
573
591
|
voiceLive: !0,
|
|
574
|
-
problem: _ ||
|
|
592
|
+
problem: _ || T && W() ? h.problem : null,
|
|
575
593
|
notice: null
|
|
576
594
|
});
|
|
577
595
|
return;
|
|
578
596
|
}
|
|
579
|
-
if (
|
|
580
|
-
|
|
597
|
+
if (E = !1, T) {
|
|
598
|
+
G({ voiceLive: !1 });
|
|
581
599
|
return;
|
|
582
600
|
}
|
|
583
|
-
(
|
|
601
|
+
(S !== null || h.phase !== "off") && (h.phase === "checking" || h.phase === "choosing" ? (x += 1, G({ phase: "off" })) : J("voice_end", {})), G({
|
|
584
602
|
voiceLive: !1,
|
|
585
603
|
notice: null
|
|
586
604
|
});
|
|
587
605
|
},
|
|
588
606
|
requestOn(e = {}) {
|
|
589
|
-
if (
|
|
607
|
+
if (j || !h.offered || h.phase !== "off") return;
|
|
590
608
|
let t = e.start === void 0 ? "auto" : e.start ? "start" : "choose";
|
|
591
|
-
if (t === "start" &&
|
|
609
|
+
if (t === "start" && W()) return;
|
|
592
610
|
let n = e.avatarId ?? h.selectedAvatarId, r = h.consentVersion, i = c.client();
|
|
593
611
|
if (i === null) {
|
|
594
|
-
|
|
612
|
+
Y();
|
|
595
613
|
return;
|
|
596
614
|
}
|
|
597
|
-
t === "start" && (
|
|
598
|
-
let o = ++
|
|
599
|
-
|
|
615
|
+
t === "start" && (D = l.now());
|
|
616
|
+
let o = ++x, s = Oe();
|
|
617
|
+
F = !1, Ne(), G({
|
|
600
618
|
phase: "checking",
|
|
601
|
-
problem:
|
|
619
|
+
problem: W() ? h.problem : null,
|
|
602
620
|
notice: null
|
|
603
|
-
}),
|
|
604
|
-
if (
|
|
621
|
+
}), Ge((e) => i.availability(e)).then((e) => {
|
|
622
|
+
if (x !== o) return;
|
|
605
623
|
if (!e.available) {
|
|
606
|
-
|
|
624
|
+
Y(a(e.reason));
|
|
607
625
|
return;
|
|
608
626
|
}
|
|
609
627
|
ue = e.maxSessionSeconds * 1e3;
|
|
610
628
|
let i = t === "start" && n !== null && e.avatars.includes(n), c = u.getState().avatarId, l = i ? n : c !== null && e.avatars.includes(c) ? c : e.avatars[0] ?? null;
|
|
611
|
-
switch (
|
|
629
|
+
switch (G({
|
|
612
630
|
phase: "choosing",
|
|
613
631
|
avatars: e.avatars,
|
|
614
632
|
selectedAvatarId: l,
|
|
@@ -619,132 +637,132 @@ function h(c) {
|
|
|
619
637
|
le === e.consentVersion && e.avatars.length === 1 && $.confirm();
|
|
620
638
|
return;
|
|
621
639
|
case "start":
|
|
622
|
-
i && r === e.consentVersion ? $.confirm() :
|
|
640
|
+
i && r === e.consentVersion ? $.confirm() : D = null;
|
|
623
641
|
return;
|
|
624
642
|
case "choose": return;
|
|
625
643
|
}
|
|
626
644
|
}, (e) => {
|
|
627
|
-
Le(e),
|
|
645
|
+
Le(e), x === o && we(e);
|
|
628
646
|
});
|
|
629
647
|
},
|
|
630
648
|
confirm() {
|
|
631
|
-
if (h.phase !== "choosing" || !(h.voiceLive ||
|
|
649
|
+
if (h.phase !== "choosing" || !(h.voiceLive || T) || W()) return;
|
|
632
650
|
let e = o(h.minutes);
|
|
633
651
|
if (e !== null) {
|
|
634
652
|
De(e);
|
|
635
653
|
return;
|
|
636
654
|
}
|
|
637
655
|
let t = h.selectedAvatarId, n = h.consentVersion;
|
|
638
|
-
t === null || n === null || (le = n, u.setAvatarId(t),
|
|
656
|
+
t === null || n === null || (le = n, u.setAvatarId(t), y = !0, E = !T, T && (D ??= l.now()), K(), We(t, n));
|
|
639
657
|
},
|
|
640
658
|
recheckRetry: Ee,
|
|
641
659
|
cancelChoice() {
|
|
642
|
-
h.phase === "choosing" && (
|
|
660
|
+
h.phase === "choosing" && (x += 1, D = null, G({ phase: "off" }));
|
|
643
661
|
},
|
|
644
662
|
refreshMinutes() {
|
|
645
|
-
|
|
663
|
+
Z(!0);
|
|
646
664
|
},
|
|
647
665
|
checkMinutesPurchase() {
|
|
648
|
-
if (
|
|
666
|
+
if (j || h.minutes === null) return;
|
|
649
667
|
let e = c.client();
|
|
650
668
|
if (e === null) return;
|
|
651
|
-
|
|
652
|
-
let t =
|
|
653
|
-
|
|
669
|
+
X();
|
|
670
|
+
let t = B, n = l.now(), r = N === null ? n : Math.max(n, N + p), i = h.minutes.balance?.availableMinutes ?? 0, a = 0;
|
|
671
|
+
G({ purchase: "checking" });
|
|
654
672
|
let o = () => {
|
|
655
|
-
if (
|
|
673
|
+
if (V = null, t !== B) return;
|
|
656
674
|
a += 1;
|
|
657
675
|
let n = a >= 5;
|
|
658
676
|
if (h.phase !== "off" && h.phase !== "choosing" && h.phase !== "checking") {
|
|
659
|
-
|
|
677
|
+
X();
|
|
660
678
|
return;
|
|
661
679
|
}
|
|
662
|
-
if (n || (
|
|
663
|
-
n &&
|
|
680
|
+
if (n || (V = l.setTimeout(o, r + a * p - l.now())), !Me() || h.phase === "checking" || P || H || l.now() < z) {
|
|
681
|
+
n && X();
|
|
664
682
|
return;
|
|
665
683
|
}
|
|
666
|
-
|
|
684
|
+
H = !0;
|
|
667
685
|
let s = Oe();
|
|
668
|
-
|
|
669
|
-
if (
|
|
686
|
+
Ge((t) => e.availability(t)).then((e) => {
|
|
687
|
+
if (H = !1, j) return;
|
|
670
688
|
let r = e.available ? e.minutes ?? null : null;
|
|
671
|
-
|
|
689
|
+
G(je(s, r)), t === B && ((r?.balance?.availableMinutes ?? 0) > i || n) && X();
|
|
672
690
|
}, (e) => {
|
|
673
|
-
|
|
691
|
+
H = !1, !j && (Le(e), t === B && n && X());
|
|
674
692
|
});
|
|
675
693
|
};
|
|
676
|
-
r > n ?
|
|
694
|
+
r > n ? V = l.setTimeout(o, r - n) : o();
|
|
677
695
|
},
|
|
678
696
|
setTabOpen(e) {
|
|
679
|
-
if (
|
|
680
|
-
if (
|
|
681
|
-
if (
|
|
682
|
-
|
|
697
|
+
if (j || e === T) return;
|
|
698
|
+
if (T = e, e) {
|
|
699
|
+
if (G({ tabOpen: !0 }), h.phase === "checking") {
|
|
700
|
+
x += 1, G({ phase: "off" }), $.requestOn({ start: !1 });
|
|
683
701
|
return;
|
|
684
702
|
}
|
|
685
|
-
|
|
703
|
+
Z(!0);
|
|
686
704
|
return;
|
|
687
705
|
}
|
|
688
|
-
|
|
706
|
+
D = null;
|
|
689
707
|
let t = h.phase;
|
|
690
708
|
if (t === "checking" || t === "choosing") {
|
|
691
|
-
|
|
709
|
+
x += 1, G({
|
|
692
710
|
tabOpen: !1,
|
|
693
711
|
phase: "off"
|
|
694
712
|
});
|
|
695
713
|
return;
|
|
696
714
|
}
|
|
697
|
-
(
|
|
715
|
+
(S !== null || t !== "off") && !h.heldByVoice && J("user", {}), G({ tabOpen: !1 });
|
|
698
716
|
},
|
|
699
717
|
selectAvatar(e) {
|
|
700
|
-
h.avatars.includes(e) &&
|
|
718
|
+
h.avatars.includes(e) && G({ selectedAvatarId: e });
|
|
701
719
|
},
|
|
702
720
|
switchOff() {
|
|
703
721
|
let { phase: e } = h;
|
|
704
|
-
if (!(
|
|
722
|
+
if (!(T && D !== null && (e === "checking" || e === "starting" || e === "connecting") && l.now() - D < 1e3)) {
|
|
705
723
|
if (e === "checking" || e === "choosing") {
|
|
706
|
-
|
|
724
|
+
x += 1, D = null, G({ phase: "off" });
|
|
707
725
|
return;
|
|
708
726
|
}
|
|
709
|
-
if (e === "off" && !
|
|
710
|
-
|
|
727
|
+
if (e === "off" && !y) {
|
|
728
|
+
K();
|
|
711
729
|
return;
|
|
712
730
|
}
|
|
713
|
-
|
|
731
|
+
J(ve(), {});
|
|
714
732
|
}
|
|
715
733
|
},
|
|
716
734
|
resumeAudio() {
|
|
717
|
-
let e =
|
|
718
|
-
e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0));
|
|
735
|
+
let e = C;
|
|
736
|
+
e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0), h.videoBlocked && e.transport.resumeVideo().catch(() => void 0));
|
|
719
737
|
},
|
|
720
738
|
setStageMounted(e) {
|
|
721
739
|
de = Math.max(0, de + (e ? 1 : -1));
|
|
722
740
|
},
|
|
723
741
|
attachVideo(e) {
|
|
724
742
|
if (e === null) {
|
|
725
|
-
let e =
|
|
726
|
-
e !== null &&
|
|
743
|
+
let e = qe();
|
|
744
|
+
e !== null && Je(e);
|
|
727
745
|
return;
|
|
728
746
|
}
|
|
729
|
-
let t =
|
|
730
|
-
t !== -1 &&
|
|
731
|
-
let n =
|
|
732
|
-
return n !== null && (n.detach(), n.attach(e)), () =>
|
|
747
|
+
let t = w.indexOf(e);
|
|
748
|
+
t !== -1 && w.splice(t, 1), w.push(e);
|
|
749
|
+
let n = C?.videoTrack ?? null;
|
|
750
|
+
return n !== null && (n.detach(), n.attach(e)), () => Je(e);
|
|
733
751
|
},
|
|
734
752
|
route(e, t) {
|
|
735
|
-
if (h.phase !== "ready" ||
|
|
753
|
+
if (h.phase !== "ready" || b || !y || de === 0 || C === null || C.port.isAudioBlocked() || e.fallback === !1) return "speakers";
|
|
736
754
|
let n = e.voice;
|
|
737
|
-
return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (
|
|
755
|
+
return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (U({
|
|
738
756
|
event: "notice",
|
|
739
757
|
notice: { kind: "needs-hosted-voice" }
|
|
740
|
-
}),
|
|
758
|
+
}), G({ problem: "needs-hosted-voice" }), "speakers") : (h.problem === "needs-hosted-voice" && G({ problem: null }), "avatar");
|
|
741
759
|
},
|
|
742
|
-
createOutput: () =>
|
|
760
|
+
createOutput: () => q.createOutput(),
|
|
743
761
|
dispose() {
|
|
744
|
-
if (!
|
|
745
|
-
|
|
762
|
+
if (!j) {
|
|
763
|
+
j = !0, (S !== null || h.phase !== "off") && J("user", {}), A?.(), A = null, Ne(), B += 1, V?.(), V = null;
|
|
746
764
|
for (let e of Q.splice(0)) e();
|
|
747
|
-
g.clear();
|
|
765
|
+
Be(), g.clear();
|
|
748
766
|
}
|
|
749
767
|
}
|
|
750
768
|
};
|