@burdenoff/fe-libs 2026.1016.1 → 2026.1016.3
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/AvatarFace.d.ts +13 -0
- package/dist/shared/assistant/avatar/live/AvatarFace.js +46 -0
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.d.ts +2 -0
- package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +172 -145
- package/dist/shared/assistant/avatar/live/avatarFaces.d.ts +31 -0
- package/dist/shared/assistant/avatar/live/avatarFaces.js +33 -0
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +12 -0
- package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +142 -75
- package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +5 -0
- package/dist/shared/assistant/avatar/live/liveAvatarController.js +3 -1
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.d.ts +14 -0
- package/dist/shared/assistant/avatar/live/liveAvatarStatus.js +11 -2
- package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +42 -0
- package/dist/shared/assistant/avatar/useAvatarCopy.js +113 -75
- package/dist/shared/assistant/i18nManifest.d.ts +28 -0
- package/dist/shared/assistant/i18nManifest.js +28 -0
- package/dist/shared/assistant/index.d.ts +8 -0
- package/dist/shared/assistant/speech/replySpeechRequests.d.ts +84 -0
- package/dist/shared/assistant/speech/replySpeechRequests.js +70 -0
- package/dist/shared/assistant/speech/routingSpeechEngine.js +2 -1
- package/dist/shared/assistant/speech/types.d.ts +28 -1
- package/dist/shared/assistant/ui/AIAssistantPanel.js +128 -119
- package/dist/shared/assistant/ui/AssistantChatArea.js +1572 -1430
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +235 -191
- package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +40 -0
- package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.d.ts +6 -0
- package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.js +99 -52
- package/dist/shared/assistant/ui/avatar/AvatarTabAskBox.d.ts +8 -0
- package/dist/shared/assistant/ui/avatar/AvatarTabAskBox.js +87 -0
- package/dist/shared/assistant/ui/avatar/AvatarTabLastExchange.d.ts +13 -0
- package/dist/shared/assistant/ui/avatar/AvatarTabLastExchange.js +97 -0
- package/dist/shared/assistant/ui/avatar/avatarAskGate.d.ts +104 -0
- package/dist/shared/assistant/ui/avatar/avatarAskGate.js +39 -0
- package/dist/shared/assistant/ui/avatar/avatarTabDraft.d.ts +17 -0
- package/dist/shared/assistant/ui/avatar/avatarTabDraft.js +22 -0
- package/dist/shared/assistant/ui/avatar/avatarTabExchange.d.ts +47 -0
- package/dist/shared/assistant/ui/avatar/avatarTabExchange.js +50 -0
- package/dist/shared/assistant/ui/panelOverlays.d.ts +8 -1
- package/dist/shared/assistant/ui/panelOverlays.js +1 -1
- package/dist/shared/providers/shell/I18nProvider.js +3 -3
- package/dist/shared-assistant.js +260 -252
- package/package.json +1 -1
|
@@ -3,24 +3,25 @@ import { useAssistantTr as t } from "../i18n.js";
|
|
|
3
3
|
import { useAssistantStore as n } from "../store.js";
|
|
4
4
|
import { isVoiceTurn as r } from "../voice/turnVisibility.js";
|
|
5
5
|
import { VOICE_LIST_TIMEOUT_MS as i, languageDisplayName as a, selectVoiceForLocale as o, speechGate as s, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../voice/speechVoices.js";
|
|
6
|
-
import { getSpeechEngine as d, subscribeSpeechEngine as
|
|
7
|
-
import { speechFeed as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
6
|
+
import { getSpeechEngine as d, subscribeSpeechEngine as ee } from "../speech/createSpeechEngine.js";
|
|
7
|
+
import { speechFeed as f } from "../speech/speechFeed.js";
|
|
8
|
+
import { hasPendingReplyRequests as p, releaseReplyRequestsOutside as m, replyWantsAvatar as te, settleReplyRequest as h, subscribeReplyRequests as g } from "../speech/replySpeechRequests.js";
|
|
9
|
+
import { isTurnSuperseded as ne } from "../voice/supersededTurns.js";
|
|
10
|
+
import { chunkForSpeech as re, toSpeakableText as _ } from "../voice/speakableText.js";
|
|
11
|
+
import { voicePreviewText as ie } from "../voice/voicePreview.js";
|
|
12
|
+
import { findAssistantLanguage as ae } from "../voice/languages.js";
|
|
13
|
+
import { resolveLanguagePair as oe } from "../voice/languagePair.js";
|
|
14
|
+
import { speechLabelsFor as se } from "../voice/speechLabels.js";
|
|
15
|
+
import { resolveSpeechLocale as ce } from "../voice/replyLanguage.js";
|
|
16
|
+
import { IDLE_PLAYBACK as le, isSpeakingMessage as ue, publishedChunks as de, speechPlaybackReducer as fe } from "../voice/speechPlayback.js";
|
|
17
|
+
import { isTurnInFlight as pe } from "../turnState.js";
|
|
18
|
+
import { parseToolActivity as me } from "./AssistantToolActivity.js";
|
|
18
19
|
import "../speech/index.js";
|
|
19
|
-
import { markTurn as
|
|
20
|
-
import { createContext as
|
|
21
|
-
import { jsx as
|
|
20
|
+
import { markTurn as he } from "../turnTimeline.js";
|
|
21
|
+
import { createContext as ge, useCallback as v, useContext as _e, useEffect as y, useMemo as b, useReducer as ve, useRef as x, useState as S, useSyncExternalStore as ye } from "react";
|
|
22
|
+
import { jsx as be } from "react/jsx-runtime";
|
|
22
23
|
//#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
|
|
23
|
-
var
|
|
24
|
+
var xe = {
|
|
24
25
|
codeBlock: "",
|
|
25
26
|
image: "",
|
|
26
27
|
link: "",
|
|
@@ -29,7 +30,30 @@ var ge = {
|
|
|
29
30
|
emailAt: "at",
|
|
30
31
|
emailDot: "dot",
|
|
31
32
|
nestedItem: ""
|
|
32
|
-
},
|
|
33
|
+
}, Se = 4e3, C = () => {}, Ce = {
|
|
34
|
+
subscribe: () => C,
|
|
35
|
+
getSnapshot: () => !1
|
|
36
|
+
}, we = {
|
|
37
|
+
subscribe: g,
|
|
38
|
+
getSnapshot: p
|
|
39
|
+
};
|
|
40
|
+
function Te(e, t) {
|
|
41
|
+
return te(t) ? {
|
|
42
|
+
...e,
|
|
43
|
+
autoSpeakEnabled: !0
|
|
44
|
+
} : e;
|
|
45
|
+
}
|
|
46
|
+
function Ee(e, t) {
|
|
47
|
+
let n = e.activeConversationId;
|
|
48
|
+
if (!n || n !== t.activeConversationId) return null;
|
|
49
|
+
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
50
|
+
if (r?.status !== "complete" || !pe(i?.status)) return null;
|
|
51
|
+
let a = r.messageId ?? i?.messageId ?? null;
|
|
52
|
+
if (!a) return null;
|
|
53
|
+
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
54
|
+
return o && o.role === "assistant" ? o : null;
|
|
55
|
+
}
|
|
56
|
+
var De = ge({
|
|
33
57
|
isSupported: !1,
|
|
34
58
|
availability: "unsupported",
|
|
35
59
|
isBlocked: !0,
|
|
@@ -53,36 +77,36 @@ var ge = {
|
|
|
53
77
|
speakFinishedReply: () => {},
|
|
54
78
|
previewVoice: () => {}
|
|
55
79
|
});
|
|
56
|
-
function
|
|
57
|
-
return
|
|
80
|
+
function w() {
|
|
81
|
+
return _e(De);
|
|
58
82
|
}
|
|
59
|
-
var
|
|
60
|
-
let
|
|
83
|
+
var T = ({ children: p, visible: g = !0, engine: ge }) => {
|
|
84
|
+
let _e = ye(ee, d, d), C = ge ?? _e, w = t(), { locale: T } = e(), [E, D] = ve(fe, le), [O, k] = S(() => C.listVoices()), [A, Oe] = S(!1), [ke, j] = S(() => /* @__PURE__ */ new Map()), [Ae, je] = S(null), M = x(0), N = x(null), P = x(null), F = x(null), I = x(null);
|
|
61
85
|
y(() => () => {
|
|
62
|
-
|
|
86
|
+
I.current !== null && clearTimeout(I.current);
|
|
63
87
|
}, []);
|
|
64
|
-
let [
|
|
88
|
+
let [Me, Ne] = S(null), L = x(null), Pe = x(() => {}), R = v(() => {
|
|
65
89
|
L.current?.(), L.current = null;
|
|
66
|
-
}, []), z = n((e) => e.autoSpeakEnabled),
|
|
67
|
-
|
|
68
|
-
}, []),
|
|
90
|
+
}, []), z = n((e) => e.autoSpeakEnabled), Fe = n((e) => e.setAutoSpeak), [B, Ie] = S(!1), Le = x(!1), Re = v((e) => {
|
|
91
|
+
Le.current = e;
|
|
92
|
+
}, []), ze = n((e) => e.activeConversationId), V = b(() => C.isSupported(), [C]), Be = C.wouldSpeakOnAvatar === void 0 ? Ce : we, Ve = ye(Be.subscribe, Be.getSnapshot, Be.getSnapshot);
|
|
69
93
|
y(() => {
|
|
70
|
-
if (!
|
|
94
|
+
if (!V) return;
|
|
71
95
|
let e = () => {
|
|
72
96
|
k(C.listVoices()), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
73
97
|
};
|
|
74
98
|
return e(), C.subscribeVoices(e);
|
|
75
|
-
}, [C,
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
|
|
99
|
+
}, [C, V]);
|
|
100
|
+
let He = n((e) => e.assistantLanguage), Ue = n((e) => e.replyLanguage), H = n((e) => e.preferredVoices), We = n((e) => e.setPreferredVoice), U = b(() => oe(He, Ue, T).reply, [
|
|
101
|
+
He,
|
|
102
|
+
Ue,
|
|
79
103
|
T
|
|
80
|
-
]),
|
|
81
|
-
|
|
104
|
+
]), W = U.code, G = v((e) => ae(e)?.tag ?? c(e), []), Ge = v((e) => ae(e)?.rate ?? .9, []), K = b(() => l(V, O, U.tag, A), [
|
|
105
|
+
V,
|
|
82
106
|
O,
|
|
83
|
-
|
|
107
|
+
U,
|
|
84
108
|
A
|
|
85
|
-
]),
|
|
109
|
+
]), Ke = b(() => ({
|
|
86
110
|
codeBlock: w("speech.codeBlock", "Code block"),
|
|
87
111
|
image: w("speech.image", "image"),
|
|
88
112
|
link: w("speech.link", "link"),
|
|
@@ -91,191 +115,199 @@ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
|
|
|
91
115
|
nestedItem: w("speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
92
116
|
emailAt: w("speech.emailAt", "at"),
|
|
93
117
|
emailDot: w("speech.emailDot", "dot")
|
|
94
|
-
}), [w]),
|
|
95
|
-
R(),
|
|
96
|
-
}, [R, C]),
|
|
118
|
+
}), [w]), q = v(() => {
|
|
119
|
+
R(), P.current = null, C.cancel(), h(N.current, "stopped"), D({ type: "stop" });
|
|
120
|
+
}, [R, C]), qe = v((e) => {
|
|
97
121
|
let t = C.listVoices().find((t) => t.name === e) ?? null;
|
|
98
122
|
if (t) {
|
|
99
|
-
|
|
123
|
+
q();
|
|
100
124
|
try {
|
|
101
|
-
C.speak([
|
|
125
|
+
C.speak([ie(W)], {
|
|
102
126
|
voice: t,
|
|
103
|
-
lang:
|
|
127
|
+
lang: G(W),
|
|
104
128
|
fallback: !1
|
|
105
129
|
});
|
|
106
130
|
} catch {}
|
|
107
131
|
}
|
|
108
132
|
}, [
|
|
109
133
|
C,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
]),
|
|
134
|
+
W,
|
|
135
|
+
q,
|
|
136
|
+
G
|
|
137
|
+
]), Je = v((e) => ke.get(e) ?? null, [ke]), Ye = v((e, t, n, r, a) => {
|
|
114
138
|
R();
|
|
115
139
|
let o = !1, s = () => {}, c = (i) => {
|
|
116
140
|
if (!o) {
|
|
117
141
|
if (o = !0, L.current = null, clearTimeout(l), s(), i.length === 0) {
|
|
118
|
-
|
|
142
|
+
Oe(!0), h(e, "declined");
|
|
119
143
|
return;
|
|
120
144
|
}
|
|
121
|
-
k(i),
|
|
145
|
+
k(i), Pe.current(e, t, i, n, r, a);
|
|
122
146
|
}
|
|
123
147
|
}, l = setTimeout(() => c(C.listVoices()), i);
|
|
124
148
|
s = C.subscribeVoices(() => c(C.listVoices())), L.current = () => {
|
|
125
|
-
o || (o = !0, clearTimeout(l), s(), L.current = null);
|
|
149
|
+
o || (o = !0, clearTimeout(l), s(), L.current = null, h(e, "stopped"));
|
|
126
150
|
};
|
|
127
|
-
}, [R, C]),
|
|
151
|
+
}, [R, C]), J = v((e, t, n, r, i = !1, c) => {
|
|
128
152
|
let u = n;
|
|
129
153
|
if (u.length === 0) {
|
|
130
154
|
let e = C.listVoices();
|
|
131
155
|
e.length > 0 && (u = e, k(e));
|
|
132
156
|
}
|
|
133
|
-
let d =
|
|
134
|
-
if (
|
|
157
|
+
let d = G(r), ee = s(l(!0, u, r, A));
|
|
158
|
+
if (ee === "block") {
|
|
135
159
|
let t = w("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, T) });
|
|
136
|
-
j((n) => new Map(n).set(e, t));
|
|
160
|
+
j((n) => new Map(n).set(e, t)), h(e, "declined");
|
|
137
161
|
return;
|
|
138
162
|
}
|
|
139
|
-
if (
|
|
140
|
-
|
|
163
|
+
if (ee === "wait-for-voices") {
|
|
164
|
+
Ye(e, t, r, i, c);
|
|
141
165
|
return;
|
|
142
166
|
}
|
|
167
|
+
let f = {
|
|
168
|
+
voice: o(u, d, H[r]),
|
|
169
|
+
lang: d,
|
|
170
|
+
rate: Ge(r)
|
|
171
|
+
}, p = X.current;
|
|
172
|
+
if (i && !p.autoSpeakEnabled && !p.sessionSpeaking && te(e)) {
|
|
173
|
+
if (C.wouldSpeakOnAvatar?.(f) !== !0) {
|
|
174
|
+
h(e, "declined");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
f.avatarOnly = !0;
|
|
178
|
+
}
|
|
143
179
|
j((t) => {
|
|
144
180
|
if (!t.has(e)) return t;
|
|
145
181
|
let n = new Map(t);
|
|
146
182
|
return n.delete(e), n;
|
|
147
183
|
}), R();
|
|
148
|
-
let
|
|
149
|
-
M.current =
|
|
184
|
+
let m = M.current + 1;
|
|
185
|
+
M.current = m, N.current !== e && h(N.current, "stopped"), N.current = e, h(e, "speaking"), D({
|
|
150
186
|
type: "start",
|
|
151
187
|
messageId: e,
|
|
152
|
-
requestId:
|
|
153
|
-
}),
|
|
154
|
-
let
|
|
155
|
-
|
|
156
|
-
requestId:
|
|
157
|
-
chunks:
|
|
188
|
+
requestId: m
|
|
189
|
+
}), P.current = i ? m : null, i && he(e, "ttsStarted");
|
|
190
|
+
let g = c === void 0 ? re(t) : re(t, void 0, void 0, { firstChunkMaxChars: c });
|
|
191
|
+
Ne({
|
|
192
|
+
requestId: m,
|
|
193
|
+
chunks: g,
|
|
158
194
|
index: -1
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
let
|
|
163
|
-
M.current ===
|
|
195
|
+
}), I.current !== null && clearTimeout(I.current), I.current = setTimeout(() => {
|
|
196
|
+
Ne((e) => e?.requestId === m && e.index < 0 ? null : e);
|
|
197
|
+
}, Se);
|
|
198
|
+
let ne = () => {
|
|
199
|
+
M.current === m && I.current !== null && (clearTimeout(I.current), I.current = null), h(e, "failed"), D({
|
|
164
200
|
type: "failed",
|
|
165
|
-
requestId:
|
|
201
|
+
requestId: m
|
|
166
202
|
});
|
|
167
|
-
};
|
|
203
|
+
}, _ = !1;
|
|
168
204
|
try {
|
|
169
|
-
C.speak(
|
|
170
|
-
voice: o(u, d, W[r]),
|
|
171
|
-
lang: d,
|
|
172
|
-
rate: Ne(r)
|
|
173
|
-
}, {
|
|
205
|
+
C.speak(g, f, {
|
|
174
206
|
onStart: () => {
|
|
175
|
-
M.current ===
|
|
207
|
+
M.current === m && P.current === m && he(e, "firstAudio");
|
|
176
208
|
},
|
|
177
209
|
onChunkStart: (e) => {
|
|
178
|
-
M.current ===
|
|
210
|
+
_ = !0, M.current === m && I.current !== null && (clearTimeout(I.current), I.current = null), Ne((t) => t?.requestId === m ? {
|
|
179
211
|
...t,
|
|
180
212
|
index: e
|
|
181
|
-
} : M.current ===
|
|
182
|
-
requestId:
|
|
183
|
-
chunks:
|
|
213
|
+
} : M.current === m ? {
|
|
214
|
+
requestId: m,
|
|
215
|
+
chunks: g,
|
|
184
216
|
index: e
|
|
185
217
|
} : t);
|
|
186
218
|
},
|
|
187
219
|
onEnd: () => {
|
|
188
|
-
M.current ===
|
|
220
|
+
M.current === m && P.current === m && he(e, "audioEnded"), h(e, "spoken"), D({
|
|
189
221
|
type: "finished",
|
|
190
|
-
requestId:
|
|
222
|
+
requestId: m
|
|
191
223
|
});
|
|
192
224
|
},
|
|
193
225
|
onError: (t) => {
|
|
194
|
-
t === "output-not-cleared" && M.current ===
|
|
226
|
+
t === "output-not-cleared" && M.current === m && je({ messageId: e }), h(e, t === "output-not-cleared" ? "not-cleared" : t === "output-left" ? _ ? "cut" : "declined" : t === "cancelled" ? "stopped" : "failed"), D({
|
|
195
227
|
type: "failed",
|
|
196
|
-
requestId:
|
|
228
|
+
requestId: m
|
|
197
229
|
});
|
|
198
230
|
}
|
|
199
231
|
});
|
|
200
232
|
} catch {
|
|
201
|
-
|
|
233
|
+
ne();
|
|
202
234
|
}
|
|
203
235
|
}, [
|
|
204
236
|
R,
|
|
205
237
|
C,
|
|
206
238
|
T,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
239
|
+
H,
|
|
240
|
+
Ge,
|
|
241
|
+
G,
|
|
210
242
|
w,
|
|
211
243
|
A,
|
|
212
|
-
|
|
244
|
+
Ye
|
|
213
245
|
]);
|
|
214
246
|
y(() => {
|
|
215
|
-
|
|
216
|
-
}, [
|
|
217
|
-
let
|
|
218
|
-
if (!
|
|
219
|
-
let i =
|
|
220
|
-
a &&
|
|
247
|
+
Pe.current = J;
|
|
248
|
+
}, [J]);
|
|
249
|
+
let Y = v((e, t, n, r) => {
|
|
250
|
+
if (!V) return;
|
|
251
|
+
let i = ce(_(t, { labels: xe }), n ?? W), a = _(t, { labels: se(i, Ke) });
|
|
252
|
+
a && J(e, a, O, i, r?.auto === !0, r?.firstChunkMaxChars);
|
|
221
253
|
}, [
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
254
|
+
V,
|
|
255
|
+
Ke,
|
|
256
|
+
W,
|
|
257
|
+
J,
|
|
226
258
|
O
|
|
227
|
-
]),
|
|
228
|
-
if (
|
|
229
|
-
|
|
259
|
+
]), Xe = v((e, t, n) => {
|
|
260
|
+
if (ue(E, e)) {
|
|
261
|
+
q();
|
|
230
262
|
return;
|
|
231
263
|
}
|
|
232
|
-
|
|
264
|
+
Y(e, t, n);
|
|
233
265
|
}, [
|
|
234
266
|
E,
|
|
235
|
-
|
|
236
|
-
|
|
267
|
+
Y,
|
|
268
|
+
q
|
|
237
269
|
]);
|
|
238
270
|
y(() => {
|
|
239
|
-
|
|
240
|
-
}, [
|
|
241
|
-
let
|
|
271
|
+
g || q();
|
|
272
|
+
}, [g, q]);
|
|
273
|
+
let X = x({
|
|
242
274
|
autoSpeakEnabled: z,
|
|
243
275
|
sessionSpeaking: B,
|
|
244
|
-
visible:
|
|
245
|
-
isSupported:
|
|
276
|
+
visible: g,
|
|
277
|
+
isSupported: V
|
|
246
278
|
});
|
|
247
279
|
y(() => {
|
|
248
|
-
|
|
280
|
+
X.current = {
|
|
249
281
|
autoSpeakEnabled: z,
|
|
250
282
|
sessionSpeaking: B,
|
|
251
|
-
visible:
|
|
252
|
-
isSupported:
|
|
283
|
+
visible: g,
|
|
284
|
+
isSupported: V
|
|
253
285
|
};
|
|
254
286
|
}, [
|
|
255
287
|
z,
|
|
256
288
|
B,
|
|
257
|
-
|
|
258
|
-
|
|
289
|
+
g,
|
|
290
|
+
V
|
|
259
291
|
]);
|
|
260
|
-
let
|
|
292
|
+
let Ze = x(null), Qe = x(null), $e = x(() => {});
|
|
261
293
|
y(() => {
|
|
262
|
-
|
|
263
|
-
let e =
|
|
264
|
-
|
|
265
|
-
}, [
|
|
266
|
-
j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()),
|
|
267
|
-
}, [
|
|
294
|
+
q(), j(/* @__PURE__ */ new Map()), m(n.getState().activeConversationId), Ze.current = ze;
|
|
295
|
+
let e = Qe.current;
|
|
296
|
+
Qe.current = null, e && e.conversationId === ze && $e.current(e.conversationId, e.messageId);
|
|
297
|
+
}, [ze, q]), y(() => {
|
|
298
|
+
j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), q();
|
|
299
|
+
}, [W, q]), y(() => () => {
|
|
268
300
|
L.current?.(), L.current = null, C.cancel();
|
|
269
301
|
}, [C]), y(() => {
|
|
270
302
|
if (typeof window > "u") return;
|
|
271
303
|
let e = () => C.cancel();
|
|
272
304
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
273
305
|
}, [C]), y(() => {
|
|
274
|
-
if (typeof document > "u" || !
|
|
306
|
+
if (typeof document > "u" || !V) return;
|
|
275
307
|
let e = () => {
|
|
276
308
|
if (document.visibilityState !== "visible") return;
|
|
277
309
|
let e = C.listVoices();
|
|
278
|
-
e.length > 0 && R(), k(e),
|
|
310
|
+
e.length > 0 && R(), k(e), Oe(!1), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
279
311
|
};
|
|
280
312
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
281
313
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
@@ -283,27 +315,27 @@ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
|
|
|
283
315
|
}, [
|
|
284
316
|
R,
|
|
285
317
|
C,
|
|
286
|
-
|
|
318
|
+
V
|
|
287
319
|
]);
|
|
288
|
-
let
|
|
320
|
+
let Z = x(Y);
|
|
289
321
|
y(() => {
|
|
290
|
-
|
|
291
|
-
}, [
|
|
292
|
-
let Q =
|
|
293
|
-
if (r(e) !== t ||
|
|
294
|
-
let { text: n } =
|
|
322
|
+
Z.current = Y;
|
|
323
|
+
}, [Y]);
|
|
324
|
+
let Q = v((e, t) => {
|
|
325
|
+
if (r(e) !== t || ne(e.id) || F.current?.messageId === e.id || Le.current) return;
|
|
326
|
+
let { text: n } = me(e.content);
|
|
295
327
|
if (n.trim()) try {
|
|
296
|
-
|
|
328
|
+
Z.current(e.id, n, e.metadata?.lang, { auto: !0 });
|
|
297
329
|
} catch {}
|
|
298
|
-
}, []), $ =
|
|
299
|
-
if (e !==
|
|
300
|
-
n.getState().activeConversationId === e && (
|
|
330
|
+
}, []), $ = v((e, t) => {
|
|
331
|
+
if (e !== Ze.current) {
|
|
332
|
+
n.getState().activeConversationId === e && (Qe.current = {
|
|
301
333
|
conversationId: e,
|
|
302
334
|
messageId: t
|
|
303
335
|
});
|
|
304
336
|
return;
|
|
305
337
|
}
|
|
306
|
-
let r =
|
|
338
|
+
let r = Te(X.current, t);
|
|
307
339
|
if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
|
|
308
340
|
let i = n.getState();
|
|
309
341
|
if (i.activeConversationId !== e) return;
|
|
@@ -311,13 +343,13 @@ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
|
|
|
311
343
|
!a || a.role !== "assistant" || Q(a, r.sessionSpeaking);
|
|
312
344
|
}, [Q]);
|
|
313
345
|
y(() => {
|
|
314
|
-
|
|
346
|
+
$e.current = $;
|
|
315
347
|
}, [$]), y(() => {
|
|
316
|
-
if (!(!z && !B || !
|
|
348
|
+
if (!(!z && !B || !g || !V)) return n.subscribe((e, t) => {
|
|
317
349
|
let n = e.activeConversationId;
|
|
318
350
|
if (!n || n !== t.activeConversationId) return;
|
|
319
351
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
320
|
-
if (r?.status !== "complete" || !
|
|
352
|
+
if (r?.status !== "complete" || !pe(i?.status)) return;
|
|
321
353
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
322
354
|
if (!a) return;
|
|
323
355
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
@@ -326,90 +358,102 @@ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
|
|
|
326
358
|
}, [
|
|
327
359
|
z,
|
|
328
360
|
B,
|
|
329
|
-
|
|
330
|
-
|
|
361
|
+
V,
|
|
362
|
+
g,
|
|
363
|
+
Q
|
|
364
|
+
]), y(() => {
|
|
365
|
+
if (!(z || B || !Ve || !g || !V)) return n.subscribe((e, t) => {
|
|
366
|
+
let n = Ee(e, t);
|
|
367
|
+
!n || !te(n.id) || Q(n, !1);
|
|
368
|
+
});
|
|
369
|
+
}, [
|
|
370
|
+
z,
|
|
371
|
+
B,
|
|
372
|
+
Ve,
|
|
373
|
+
V,
|
|
374
|
+
g,
|
|
331
375
|
Q
|
|
332
376
|
]);
|
|
333
|
-
let
|
|
377
|
+
let et = v((e) => {
|
|
334
378
|
if (e.type === "abort") {
|
|
335
|
-
let t =
|
|
379
|
+
let t = F.current;
|
|
336
380
|
if (!t || t.messageId !== e.messageId) return;
|
|
337
|
-
|
|
381
|
+
F.current = null, (t.requestId === null ? t.waiting && L.current !== null : M.current === t.requestId) && q();
|
|
338
382
|
return;
|
|
339
383
|
}
|
|
340
|
-
let { messageId: t, item: r } = e, i =
|
|
341
|
-
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking ||
|
|
342
|
-
let { text: a } =
|
|
384
|
+
let { messageId: t, item: r } = e, i = Te(X.current, t);
|
|
385
|
+
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || ne(t) || Le.current || F.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Ze.current !== r.conversationId) return;
|
|
386
|
+
let { text: a } = me(r.text);
|
|
343
387
|
if (!a.trim()) return;
|
|
344
388
|
let o = M.current;
|
|
345
389
|
try {
|
|
346
|
-
|
|
390
|
+
Z.current(t, a, r.lang, {
|
|
347
391
|
auto: !0,
|
|
348
392
|
firstChunkMaxChars: 110
|
|
349
393
|
});
|
|
350
394
|
} catch {}
|
|
351
395
|
let s = M.current !== o;
|
|
352
|
-
|
|
396
|
+
F.current = {
|
|
353
397
|
messageId: t,
|
|
354
398
|
requestId: s ? M.current : null,
|
|
355
399
|
waiting: !s && L.current !== null
|
|
356
400
|
};
|
|
357
|
-
}, [
|
|
358
|
-
y(() =>
|
|
359
|
-
let
|
|
401
|
+
}, [q]);
|
|
402
|
+
y(() => f.subscribe(et), [et]);
|
|
403
|
+
let tt = b(() => u(O, U.tag), [O, U]), nt = b(() => o(O, U.tag, H[W]), [
|
|
360
404
|
O,
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
]),
|
|
365
|
-
isSupported:
|
|
366
|
-
availability:
|
|
367
|
-
isBlocked:
|
|
368
|
-
disabledReason:
|
|
369
|
-
blockedFor:
|
|
370
|
-
voiceChoices:
|
|
371
|
-
spokenChunks:
|
|
372
|
-
activeVoiceName:
|
|
373
|
-
preferredVoiceName: W
|
|
374
|
-
setVoice: (e) =>
|
|
405
|
+
U,
|
|
406
|
+
H,
|
|
407
|
+
W
|
|
408
|
+
]), rt = b(() => ({
|
|
409
|
+
isSupported: V,
|
|
410
|
+
availability: K,
|
|
411
|
+
isBlocked: K === "no-voices",
|
|
412
|
+
disabledReason: K === "no-voices" ? w("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
413
|
+
blockedFor: Je,
|
|
414
|
+
voiceChoices: tt,
|
|
415
|
+
spokenChunks: de(E, Me),
|
|
416
|
+
activeVoiceName: nt?.name ?? null,
|
|
417
|
+
preferredVoiceName: H[W] ?? null,
|
|
418
|
+
setVoice: (e) => We(W, e),
|
|
375
419
|
speakingMessageId: E.status === "speaking" ? E.messageId : null,
|
|
376
|
-
outputNotCleared:
|
|
377
|
-
isSpeaking: (e) =>
|
|
378
|
-
toggle:
|
|
379
|
-
stop:
|
|
420
|
+
outputNotCleared: Ae,
|
|
421
|
+
isSpeaking: (e) => ue(E, e),
|
|
422
|
+
toggle: Xe,
|
|
423
|
+
stop: q,
|
|
380
424
|
autoSpeakEnabled: z,
|
|
381
|
-
setAutoSpeak:
|
|
425
|
+
setAutoSpeak: Fe,
|
|
382
426
|
sessionSpeaking: B,
|
|
383
|
-
setSessionSpeaking:
|
|
384
|
-
setSessionMicOpen:
|
|
427
|
+
setSessionSpeaking: Ie,
|
|
428
|
+
setSessionMicOpen: Re,
|
|
385
429
|
speakFinishedReply: $,
|
|
386
|
-
previewVoice:
|
|
430
|
+
previewVoice: qe
|
|
387
431
|
}), [
|
|
388
|
-
|
|
389
|
-
J,
|
|
390
|
-
Ie,
|
|
391
|
-
Ge,
|
|
392
|
-
Ke,
|
|
393
|
-
W,
|
|
394
|
-
Me,
|
|
432
|
+
V,
|
|
395
433
|
K,
|
|
434
|
+
Je,
|
|
435
|
+
tt,
|
|
436
|
+
nt,
|
|
437
|
+
H,
|
|
438
|
+
We,
|
|
439
|
+
W,
|
|
396
440
|
E,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
441
|
+
Ae,
|
|
442
|
+
Xe,
|
|
443
|
+
q,
|
|
400
444
|
z,
|
|
401
|
-
|
|
445
|
+
Fe,
|
|
402
446
|
B,
|
|
403
|
-
|
|
447
|
+
Re,
|
|
404
448
|
$,
|
|
405
|
-
|
|
449
|
+
qe,
|
|
406
450
|
w,
|
|
407
|
-
|
|
451
|
+
Me
|
|
408
452
|
]);
|
|
409
|
-
return /* @__PURE__ */
|
|
410
|
-
value:
|
|
411
|
-
children:
|
|
453
|
+
return /* @__PURE__ */ be(De.Provider, {
|
|
454
|
+
value: rt,
|
|
455
|
+
children: p
|
|
412
456
|
});
|
|
413
457
|
};
|
|
414
458
|
//#endregion
|
|
415
|
-
export {
|
|
459
|
+
export { T as AssistantSpeechProvider, w as useAssistantSpeech };
|