@burdenoff/fe-libs 2026.1003.1 → 2026.1003.2

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.
Files changed (27) hide show
  1. package/dist/shared/assistant/index.d.ts +1 -0
  2. package/dist/shared/assistant/index.d.ts.map +1 -1
  3. package/dist/shared/assistant/prewarm.d.ts +71 -0
  4. package/dist/shared/assistant/prewarm.d.ts.map +1 -1
  5. package/dist/shared/assistant/prewarm.js +49 -2
  6. package/dist/shared/assistant/speech/speechFeed.d.ts +63 -0
  7. package/dist/shared/assistant/speech/speechFeed.d.ts.map +1 -0
  8. package/dist/shared/assistant/speech/speechFeed.js +40 -0
  9. package/dist/shared/assistant/turnTimeline.d.ts +22 -2
  10. package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
  11. package/dist/shared/assistant/turnTimeline.js +18 -1
  12. package/dist/shared/assistant/turnTimingReport.d.ts.map +1 -1
  13. package/dist/shared/assistant/turnTimingReport.js +5 -4
  14. package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
  15. package/dist/shared/assistant/ui/AssistantChatArea.js +981 -931
  16. package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts.map +1 -1
  17. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +198 -169
  18. package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
  19. package/dist/shared/assistant/ui/useVoiceSession.js +165 -153
  20. package/dist/shared/assistant/voice/speakableText.d.ts +16 -1
  21. package/dist/shared/assistant/voice/speakableText.d.ts.map +1 -1
  22. package/dist/shared/assistant/voice/speakableText.js +116 -102
  23. package/dist/shared/assistant/voice/voiceSession.d.ts +12 -0
  24. package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
  25. package/dist/shared/assistant/voice/voiceSession.js +6 -0
  26. package/dist/shared-assistant.js +151 -150
  27. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantSpeechProvider.d.ts","sourceRoot":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IAAI,CAAC;IAC3E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;;;;;;;;;;;;OAaG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C;;;;;;;;;;;;;OAaG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C;;;;;;;OAOG;IACH,kBAAkB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,kFAAkF;IAClF,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AA6BD,wBAAgB,kBAAkB,IAAI,2BAA2B,CAEhE;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,KAAK,CAw9B7C,CAAC"}
1
+ {"version":3,"file":"AssistantSpeechProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/ui/AssistantSpeechProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAUL,KAAK,EAAE,EACP,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AA6B/D,OAAO,EAQL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAoB/B,MAAM,WAAW,2BAA2B;IAC1C,gFAAgF;IAChF,WAAW,EAAE,OAAO,CAAC;IACrB,YA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kB,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,kFAAkF;IAClF,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AA6BD,wBAAgB,kBAAkB,IAAI,2BAA2B,CAEhE;AAED,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,KAAK,CAilC7C,CAAC"}
@@ -2,23 +2,24 @@ import { useI18n as e } from "../../providers/shell/I18nProvider.js";
2
2
  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
- import { VOICE_LIST_TIMEOUT_MS as i, languageDisplayName as a, selectVoiceForLocale as o, speechGate as s, speechLangForLocale as c, voiceAvailability as ee, voicesForLocale as l } from "../voice/speechVoices.js";
6
- import { getSpeechEngine as u, subscribeSpeechEngine as d } from "../speech/createSpeechEngine.js";
7
- import { chunkForSpeech as te, toSpeakableText as f } from "../voice/speakableText.js";
8
- import { voicePreviewText as ne } from "../voice/voicePreview.js";
9
- import { findAssistantLanguage as re } from "../voice/languages.js";
10
- import { resolveLanguagePair as ie } from "../voice/languagePair.js";
11
- import { speechLabelsFor as ae } from "../voice/speechLabels.js";
12
- import { resolveSpeechLocale as oe } from "../voice/replyLanguage.js";
13
- import { IDLE_PLAYBACK as se, isSpeakingMessage as p, publishedChunks as ce, speechPlaybackReducer as le } from "../voice/speechPlayback.js";
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 f } from "../speech/createSpeechEngine.js";
7
+ import { speechFeed as p } from "../speech/speechFeed.js";
8
+ import { chunkForSpeech as ee, toSpeakableText as m } from "../voice/speakableText.js";
9
+ import { voicePreviewText as te } from "../voice/voicePreview.js";
10
+ import { findAssistantLanguage as ne } from "../voice/languages.js";
11
+ import { resolveLanguagePair as re } from "../voice/languagePair.js";
12
+ import { speechLabelsFor as ie } from "../voice/speechLabels.js";
13
+ import { resolveSpeechLocale as ae } from "../voice/replyLanguage.js";
14
+ import { IDLE_PLAYBACK as oe, isSpeakingMessage as se, publishedChunks as ce, speechPlaybackReducer as le } from "../voice/speechPlayback.js";
14
15
  import { isTurnInFlight as ue } from "../turnState.js";
15
16
  import { parseToolActivity as de } from "./AssistantToolActivity.js";
16
17
  import "../speech/index.js";
17
- import { markTurn as fe } from "../turnTimeline.js";
18
- import { createContext as pe, useCallback as m, useContext as h, useEffect as g, useMemo as _, useReducer as me, useRef as v, useState as y, useSyncExternalStore as he } from "react";
19
- import { jsx as ge } from "react/jsx-runtime";
18
+ import { markTurn as h } from "../turnTimeline.js";
19
+ import { createContext as fe, useCallback as g, useContext as _, useEffect as v, useMemo as y, useReducer as pe, useRef as b, useState as x, useSyncExternalStore as me } from "react";
20
+ import { jsx as he } from "react/jsx-runtime";
20
21
  //#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
21
- var _e = {
22
+ var ge = {
22
23
  codeBlock: "",
23
24
  image: "",
24
25
  link: "",
@@ -27,7 +28,7 @@ var _e = {
27
28
  emailAt: "at",
28
29
  emailDot: "dot",
29
30
  nestedItem: ""
30
- }, ve = 4e3, b = pe({
31
+ }, _e = 4e3, ve = fe({
31
32
  isSupported: !1,
32
33
  availability: "unsupported",
33
34
  isBlocked: !0,
@@ -50,36 +51,36 @@ var _e = {
50
51
  speakFinishedReply: () => {},
51
52
  previewVoice: () => {}
52
53
  });
53
- function x() {
54
- return h(b);
54
+ function ye() {
55
+ return _(ve);
55
56
  }
56
- var ye = ({ children: pe, visible: h = !0, engine: x }) => {
57
- let ye = he(d, u, u), S = x ?? ye, C = t(), { locale: w } = e(), [T, E] = me(le, se), [D, O] = y(() => S.listVoices()), [k, be] = y(!1), [A, j] = y(() => /* @__PURE__ */ new Map()), M = v(0), N = v(null), P = v(null);
58
- g(() => () => {
57
+ var be = ({ children: fe, visible: _ = !0, engine: ye }) => {
58
+ let be = me(f, d, d), S = ye ?? be, C = t(), { locale: w } = e(), [T, E] = pe(le, oe), [D, O] = x(() => S.listVoices()), [k, xe] = x(!1), [Se, A] = x(() => /* @__PURE__ */ new Map()), j = b(0), M = b(null), N = b(null), P = b(null);
59
+ v(() => () => {
59
60
  P.current !== null && clearTimeout(P.current);
60
61
  }, []);
61
- let [F, I] = y(null), L = v(null), xe = v(() => {}), R = m(() => {
62
- L.current?.(), L.current = null;
63
- }, []), z = n((e) => e.autoSpeakEnabled), Se = n((e) => e.setAutoSpeak), [B, Ce] = y(!1), we = v(!1), Te = m((e) => {
64
- we.current = e;
65
- }, []), V = n((e) => e.activeConversationId), H = _(() => S.isSupported(), [S]);
66
- g(() => {
62
+ let [Ce, F] = x(null), I = b(null), we = b(() => {}), L = g(() => {
63
+ I.current?.(), I.current = null;
64
+ }, []), R = n((e) => e.autoSpeakEnabled), Te = n((e) => e.setAutoSpeak), [z, Ee] = x(!1), B = b(!1), De = g((e) => {
65
+ B.current = e;
66
+ }, []), V = n((e) => e.activeConversationId), H = y(() => S.isSupported(), [S]);
67
+ v(() => {
67
68
  if (!H) return;
68
69
  let e = () => {
69
- O(S.listVoices()), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
70
+ O(S.listVoices()), A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
70
71
  };
71
72
  return e(), S.subscribeVoices(e);
72
73
  }, [S, H]);
73
- let Ee = n((e) => e.assistantLanguage), De = n((e) => e.replyLanguage), U = n((e) => e.preferredVoices), Oe = n((e) => e.setPreferredVoice), W = _(() => ie(Ee, De, w).reply, [
74
- Ee,
75
- De,
74
+ let Oe = n((e) => e.assistantLanguage), ke = n((e) => e.replyLanguage), U = n((e) => e.preferredVoices), Ae = n((e) => e.setPreferredVoice), W = y(() => re(Oe, ke, w).reply, [
75
+ Oe,
76
+ ke,
76
77
  w
77
- ]), G = W.code, K = m((e) => re(e)?.tag ?? c(e), []), ke = m((e) => re(e)?.rate ?? .9, []), q = _(() => ee(H, D, W.tag, k), [
78
+ ]), G = W.code, K = g((e) => ne(e)?.tag ?? c(e), []), je = g((e) => ne(e)?.rate ?? .9, []), q = y(() => l(H, D, W.tag, k), [
78
79
  H,
79
80
  D,
80
81
  W,
81
82
  k
82
- ]), Ae = _(() => ({
83
+ ]), Me = y(() => ({
83
84
  codeBlock: C("speech.codeBlock", "Code block"),
84
85
  image: C("speech.image", "image"),
85
86
  link: C("speech.link", "link"),
@@ -88,14 +89,14 @@ var ye = ({ children: pe, visible: h = !0, engine: x }) => {
88
89
  nestedItem: C("speech.nestedItem", "Sub-item {{ordinal}}"),
89
90
  emailAt: C("speech.emailAt", "at"),
90
91
  emailDot: C("speech.emailDot", "dot")
91
- }), [C]), J = m(() => {
92
- R(), N.current = null, S.cancel(), E({ type: "stop" });
93
- }, [R, S]), je = m((e) => {
92
+ }), [C]), J = g(() => {
93
+ L(), M.current = null, S.cancel(), E({ type: "stop" });
94
+ }, [L, S]), Ne = g((e) => {
94
95
  let t = S.listVoices().find((t) => t.name === e) ?? null;
95
96
  if (t) {
96
97
  J();
97
98
  try {
98
- S.speak([ne(G)], {
99
+ S.speak([te(G)], {
99
100
  voice: t,
100
101
  lang: K(G),
101
102
  fallback: !1
@@ -107,118 +108,120 @@ var ye = ({ children: pe, visible: h = !0, engine: x }) => {
107
108
  G,
108
109
  J,
109
110
  K
110
- ]), Me = m((e) => A.get(e) ?? null, [A]), Ne = m((e, t, n, r) => {
111
- R();
112
- let a = !1, o = () => {}, s = (i) => {
113
- if (!a) {
114
- if (a = !0, L.current = null, clearTimeout(c), o(), i.length === 0) {
115
- be(!0);
111
+ ]), Pe = g((e) => Se.get(e) ?? null, [Se]), Fe = g((e, t, n, r, a) => {
112
+ L();
113
+ let o = !1, s = () => {}, c = (i) => {
114
+ if (!o) {
115
+ if (o = !0, I.current = null, clearTimeout(l), s(), i.length === 0) {
116
+ xe(!0);
116
117
  return;
117
118
  }
118
- O(i), xe.current(e, t, i, n, r);
119
+ O(i), we.current(e, t, i, n, r, a);
119
120
  }
120
- }, c = setTimeout(() => s(S.listVoices()), i);
121
- o = S.subscribeVoices(() => s(S.listVoices())), L.current = () => {
122
- a || (a = !0, clearTimeout(c), o(), L.current = null);
121
+ }, l = setTimeout(() => c(S.listVoices()), i);
122
+ s = S.subscribeVoices(() => c(S.listVoices())), I.current = () => {
123
+ o || (o = !0, clearTimeout(l), s(), I.current = null);
123
124
  };
124
- }, [R, S]), Y = m((e, t, n, r, i = !1) => {
125
- let c = n;
126
- if (c.length === 0) {
125
+ }, [L, S]), Y = g((e, t, n, r, i = !1, c) => {
126
+ let u = n;
127
+ if (u.length === 0) {
127
128
  let e = S.listVoices();
128
- e.length > 0 && (c = e, O(e));
129
+ e.length > 0 && (u = e, O(e));
129
130
  }
130
- let l = K(r), u = s(ee(!0, c, r, k));
131
- if (u === "block") {
132
- let t = C("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(l, w) });
133
- j((n) => new Map(n).set(e, t));
131
+ let d = K(r), f = s(l(!0, u, r, k));
132
+ if (f === "block") {
133
+ let t = C("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, w) });
134
+ A((n) => new Map(n).set(e, t));
134
135
  return;
135
136
  }
136
- if (u === "wait-for-voices") {
137
- Ne(e, t, r, i);
137
+ if (f === "wait-for-voices") {
138
+ Fe(e, t, r, i, c);
138
139
  return;
139
140
  }
140
- j((t) => {
141
+ A((t) => {
141
142
  if (!t.has(e)) return t;
142
143
  let n = new Map(t);
143
144
  return n.delete(e), n;
144
- }), R();
145
- let d = M.current + 1;
146
- M.current = d, E({
145
+ }), L();
146
+ let p = j.current + 1;
147
+ j.current = p, E({
147
148
  type: "start",
148
149
  messageId: e,
149
- requestId: d
150
- }), N.current = i ? d : null, i && fe(e, "ttsStarted");
151
- let f = te(t);
152
- I({
153
- requestId: d,
154
- chunks: f,
150
+ requestId: p
151
+ }), M.current = i ? p : null, i && h(e, "ttsStarted");
152
+ let m = c === void 0 ? ee(t) : ee(t, void 0, void 0, { firstChunkMaxChars: c });
153
+ F({
154
+ requestId: p,
155
+ chunks: m,
155
156
  index: -1
156
157
  }), P.current !== null && clearTimeout(P.current), P.current = setTimeout(() => {
157
- I((e) => e?.requestId === d && e.index < 0 ? null : e);
158
- }, ve);
159
- let ne = () => {
160
- M.current === d && P.current !== null && (clearTimeout(P.current), P.current = null), E({
158
+ F((e) => e?.requestId === p && e.index < 0 ? null : e);
159
+ }, _e);
160
+ let te = () => {
161
+ j.current === p && P.current !== null && (clearTimeout(P.current), P.current = null), E({
161
162
  type: "failed",
162
- requestId: d
163
+ requestId: p
163
164
  });
164
165
  };
165
166
  try {
166
- S.speak(f, {
167
- voice: o(c, l, U[r]),
168
- lang: l,
169
- rate: ke(r)
167
+ S.speak(m, {
168
+ voice: o(u, d, U[r]),
169
+ lang: d,
170
+ rate: je(r)
170
171
  }, {
171
172
  onStart: () => {
172
- M.current === d && N.current === d && fe(e, "firstAudio");
173
+ j.current === p && M.current === p && h(e, "firstAudio");
173
174
  },
174
175
  onChunkStart: (e) => {
175
- M.current === d && P.current !== null && (clearTimeout(P.current), P.current = null), I((t) => t?.requestId === d ? {
176
+ j.current === p && P.current !== null && (clearTimeout(P.current), P.current = null), F((t) => t?.requestId === p ? {
176
177
  ...t,
177
178
  index: e
178
- } : M.current === d ? {
179
- requestId: d,
180
- chunks: f,
179
+ } : j.current === p ? {
180
+ requestId: p,
181
+ chunks: m,
181
182
  index: e
182
183
  } : t);
183
184
  },
184
- onEnd: () => E({
185
- type: "finished",
186
- requestId: d
187
- }),
185
+ onEnd: () => {
186
+ j.current === p && M.current === p && h(e, "audioEnded"), E({
187
+ type: "finished",
188
+ requestId: p
189
+ });
190
+ },
188
191
  onError: () => E({
189
192
  type: "failed",
190
- requestId: d
193
+ requestId: p
191
194
  })
192
195
  });
193
196
  } catch {
194
- ne();
197
+ te();
195
198
  }
196
199
  }, [
197
- R,
200
+ L,
198
201
  S,
199
202
  w,
200
203
  U,
201
- ke,
204
+ je,
202
205
  K,
203
206
  C,
204
207
  k,
205
- Ne
208
+ Fe
206
209
  ]);
207
- g(() => {
208
- xe.current = Y;
210
+ v(() => {
211
+ we.current = Y;
209
212
  }, [Y]);
210
- let X = m((e, t, n, r) => {
213
+ let X = g((e, t, n, r) => {
211
214
  if (!H) return;
212
- let i = oe(f(t, { labels: _e }), n ?? G), a = f(t, { labels: ae(i, Ae) });
213
- a && Y(e, a, D, i, r?.auto === !0);
215
+ let i = ae(m(t, { labels: ge }), n ?? G), a = m(t, { labels: ie(i, Me) });
216
+ a && Y(e, a, D, i, r?.auto === !0, r?.firstChunkMaxChars);
214
217
  }, [
215
218
  H,
216
- Ae,
219
+ Me,
217
220
  G,
218
221
  Y,
219
222
  D
220
- ]), Pe = m((e, t, n) => {
221
- if (p(T, e)) {
223
+ ]), Ie = g((e, t, n) => {
224
+ if (se(T, e)) {
222
225
  J();
223
226
  return;
224
227
  }
@@ -228,85 +231,85 @@ var ye = ({ children: pe, visible: h = !0, engine: x }) => {
228
231
  X,
229
232
  J
230
233
  ]);
231
- g(() => {
232
- h || J();
233
- }, [h, J]);
234
- let Fe = v({
235
- autoSpeakEnabled: z,
236
- sessionSpeaking: B,
237
- visible: h,
234
+ v(() => {
235
+ _ || J();
236
+ }, [_, J]);
237
+ let Le = b({
238
+ autoSpeakEnabled: R,
239
+ sessionSpeaking: z,
240
+ visible: _,
238
241
  isSupported: H
239
242
  });
240
- g(() => {
241
- Fe.current = {
242
- autoSpeakEnabled: z,
243
- sessionSpeaking: B,
244
- visible: h,
243
+ v(() => {
244
+ Le.current = {
245
+ autoSpeakEnabled: R,
246
+ sessionSpeaking: z,
247
+ visible: _,
245
248
  isSupported: H
246
249
  };
247
250
  }, [
251
+ R,
248
252
  z,
249
- B,
250
- h,
253
+ _,
251
254
  H
252
255
  ]);
253
- let Ie = v(null), Z = v(null), Le = v(() => {});
254
- g(() => {
255
- J(), j(/* @__PURE__ */ new Map()), Ie.current = V;
256
- let e = Z.current;
257
- Z.current = null, e && e.conversationId === V && Le.current(e.conversationId, e.messageId);
258
- }, [V, J]), g(() => {
259
- j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), J();
260
- }, [G, J]), g(() => () => {
261
- L.current?.(), L.current = null, S.cancel();
262
- }, [S]), g(() => {
256
+ let Re = b(null), ze = b(null), Be = b(() => {});
257
+ v(() => {
258
+ J(), A(/* @__PURE__ */ new Map()), Re.current = V;
259
+ let e = ze.current;
260
+ ze.current = null, e && e.conversationId === V && Be.current(e.conversationId, e.messageId);
261
+ }, [V, J]), v(() => {
262
+ A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), J();
263
+ }, [G, J]), v(() => () => {
264
+ I.current?.(), I.current = null, S.cancel();
265
+ }, [S]), v(() => {
263
266
  if (typeof window > "u") return;
264
267
  let e = () => S.cancel();
265
268
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
266
- }, [S]), g(() => {
269
+ }, [S]), v(() => {
267
270
  if (typeof document > "u" || !H) return;
268
271
  let e = () => {
269
272
  if (document.visibilityState !== "visible") return;
270
273
  let e = S.listVoices();
271
- e.length > 0 && R(), O(e), be(!1), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
274
+ e.length > 0 && L(), O(e), xe(!1), A((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
272
275
  };
273
276
  return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
274
277
  document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
275
278
  };
276
279
  }, [
277
- R,
280
+ L,
278
281
  S,
279
282
  H
280
283
  ]);
281
- let Re = v(X);
282
- g(() => {
283
- Re.current = X;
284
+ let Z = b(X);
285
+ v(() => {
286
+ Z.current = X;
284
287
  }, [X]);
285
- let Q = m((e, t) => {
286
- if (r(e) !== t || we.current) return;
288
+ let Q = g((e, t) => {
289
+ if (r(e) !== t || N.current?.messageId === e.id || B.current) return;
287
290
  let { text: n } = de(e.content);
288
291
  if (n.trim()) try {
289
- Re.current(e.id, n, e.metadata?.lang, { auto: !0 });
292
+ Z.current(e.id, n, e.metadata?.lang, { auto: !0 });
290
293
  } catch {}
291
- }, []), $ = m((e, t) => {
292
- if (e !== Ie.current) {
293
- n.getState().activeConversationId === e && (Z.current = {
294
+ }, []), $ = g((e, t) => {
295
+ if (e !== Re.current) {
296
+ n.getState().activeConversationId === e && (ze.current = {
294
297
  conversationId: e,
295
298
  messageId: t
296
299
  });
297
300
  return;
298
301
  }
299
- let r = Fe.current;
302
+ let r = Le.current;
300
303
  if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
301
304
  let i = n.getState();
302
305
  if (i.activeConversationId !== e) return;
303
306
  let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === t);
304
307
  !a || a.role !== "assistant" || Q(a, r.sessionSpeaking);
305
308
  }, [Q]);
306
- g(() => {
307
- Le.current = $;
308
- }, [$]), g(() => {
309
- if (!(!z && !B || !h || !H)) return n.subscribe((e, t) => {
309
+ v(() => {
310
+ Be.current = $;
311
+ }, [$]), v(() => {
312
+ if (!(!R && !z || !_ || !H)) return n.subscribe((e, t) => {
310
313
  let n = e.activeConversationId;
311
314
  if (!n || n !== t.activeConversationId) return;
312
315
  let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
@@ -314,67 +317,93 @@ var ye = ({ children: pe, visible: h = !0, engine: x }) => {
314
317
  let a = r.messageId ?? i?.messageId ?? null;
315
318
  if (!a) return;
316
319
  let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
317
- !o || o.role !== "assistant" || Q(o, B);
320
+ !o || o.role !== "assistant" || Q(o, z);
318
321
  });
319
322
  }, [
323
+ R,
320
324
  z,
321
- B,
322
325
  H,
323
- h,
326
+ _,
324
327
  Q
325
328
  ]);
326
- let ze = _(() => l(D, W.tag), [D, W]), Be = _(() => o(D, W.tag, U[G]), [
329
+ let Ve = g((e) => {
330
+ if (e.type === "abort") {
331
+ let t = N.current;
332
+ if (!t || t.messageId !== e.messageId) return;
333
+ N.current = null, (t.requestId === null ? t.waiting && I.current !== null : j.current === t.requestId) && J();
334
+ return;
335
+ }
336
+ let { messageId: t, item: r } = e, i = Le.current;
337
+ if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || B.current || N.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Re.current !== r.conversationId) return;
338
+ let { text: a } = de(r.text);
339
+ if (!a.trim()) return;
340
+ let o = j.current;
341
+ try {
342
+ Z.current(t, a, r.lang, {
343
+ auto: !0,
344
+ firstChunkMaxChars: 110
345
+ });
346
+ } catch {}
347
+ let s = j.current !== o;
348
+ N.current = {
349
+ messageId: t,
350
+ requestId: s ? j.current : null,
351
+ waiting: !s && I.current !== null
352
+ };
353
+ }, [J]);
354
+ v(() => p.subscribe(Ve), [Ve]);
355
+ let He = y(() => u(D, W.tag), [D, W]), Ue = y(() => o(D, W.tag, U[G]), [
327
356
  D,
328
357
  W,
329
358
  U,
330
359
  G
331
- ]), Ve = _(() => ({
360
+ ]), We = y(() => ({
332
361
  isSupported: H,
333
362
  availability: q,
334
363
  isBlocked: q === "no-voices",
335
364
  disabledReason: q === "no-voices" ? C("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
336
- blockedFor: Me,
337
- voiceChoices: ze,
338
- spokenChunks: ce(T, F),
339
- activeVoiceName: Be?.name ?? null,
365
+ blockedFor: Pe,
366
+ voiceChoices: He,
367
+ spokenChunks: ce(T, Ce),
368
+ activeVoiceName: Ue?.name ?? null,
340
369
  preferredVoiceName: U[G] ?? null,
341
- setVoice: (e) => Oe(G, e),
370
+ setVoice: (e) => Ae(G, e),
342
371
  speakingMessageId: T.status === "speaking" ? T.messageId : null,
343
- isSpeaking: (e) => p(T, e),
344
- toggle: Pe,
372
+ isSpeaking: (e) => se(T, e),
373
+ toggle: Ie,
345
374
  stop: J,
346
- autoSpeakEnabled: z,
347
- setAutoSpeak: Se,
348
- sessionSpeaking: B,
349
- setSessionSpeaking: Ce,
350
- setSessionMicOpen: Te,
375
+ autoSpeakEnabled: R,
376
+ setAutoSpeak: Te,
377
+ sessionSpeaking: z,
378
+ setSessionSpeaking: Ee,
379
+ setSessionMicOpen: De,
351
380
  speakFinishedReply: $,
352
- previewVoice: je
381
+ previewVoice: Ne
353
382
  }), [
354
383
  H,
355
384
  q,
356
- Me,
357
- ze,
358
- Be,
385
+ Pe,
386
+ He,
387
+ Ue,
359
388
  U,
360
- Oe,
389
+ Ae,
361
390
  G,
362
391
  T,
363
- Pe,
392
+ Ie,
364
393
  J,
365
- z,
366
- Se,
367
- B,
394
+ R,
368
395
  Te,
396
+ z,
397
+ De,
369
398
  $,
370
- je,
399
+ Ne,
371
400
  C,
372
- F
401
+ Ce
373
402
  ]);
374
- return /* @__PURE__ */ ge(b.Provider, {
375
- value: Ve,
376
- children: pe
403
+ return /* @__PURE__ */ he(ve.Provider, {
404
+ value: We,
405
+ children: fe
377
406
  });
378
407
  };
379
408
  //#endregion
380
- export { ye as AssistantSpeechProvider, x as useAssistantSpeech };
409
+ export { be as AssistantSpeechProvider, ye as useAssistantSpeech };
@@ -1 +1 @@
1
- {"version":3,"file":"useVoiceSession.d.ts","sourceRoot":"","sources":["../../../../src/shared/assistant/ui/useVoiceSession.ts"],"names":[],"mappings":"AAUA,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAgBL,KAAK,oBAAoB,EAE1B,MAAM,uBAAuB,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