@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.
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/index.d.ts.map +1 -1
- package/dist/shared/assistant/prewarm.d.ts +71 -0
- package/dist/shared/assistant/prewarm.d.ts.map +1 -1
- package/dist/shared/assistant/prewarm.js +49 -2
- package/dist/shared/assistant/speech/speechFeed.d.ts +63 -0
- package/dist/shared/assistant/speech/speechFeed.d.ts.map +1 -0
- package/dist/shared/assistant/speech/speechFeed.js +40 -0
- package/dist/shared/assistant/turnTimeline.d.ts +22 -2
- package/dist/shared/assistant/turnTimeline.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimeline.js +18 -1
- package/dist/shared/assistant/turnTimingReport.d.ts.map +1 -1
- package/dist/shared/assistant/turnTimingReport.js +5 -4
- package/dist/shared/assistant/ui/AssistantChatArea.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantChatArea.js +981 -931
- package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts.map +1 -1
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +198 -169
- package/dist/shared/assistant/ui/useVoiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/ui/useVoiceSession.js +165 -153
- package/dist/shared/assistant/voice/speakableText.d.ts +16 -1
- package/dist/shared/assistant/voice/speakableText.d.ts.map +1 -1
- package/dist/shared/assistant/voice/speakableText.js +116 -102
- package/dist/shared/assistant/voice/voiceSession.d.ts +12 -0
- package/dist/shared/assistant/voice/voiceSession.d.ts.map +1 -1
- package/dist/shared/assistant/voice/voiceSession.js +6 -0
- package/dist/shared-assistant.js +151 -150
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,YAAY,EAAE,iBAAiB,CAAC;IAChC;;;;OAIG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,6EAA6E;IAC7E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;;OAMG;IACH,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACjD;;;;OAIG;IACH,YAAY,EAAE,SAAS,eAAe,EAAE,CAAC;IACzC,8EAA8E;IAC9E;;;;;;OAMG;IACH,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACzD,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;;;;;OAQG;IACH,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,mEAAmE;IACnE,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,kDAAkD;IAClD,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C;;;;;;;OAOG;IACH,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,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,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
|
|
6
|
-
import { getSpeechEngine as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
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
|
|
18
|
-
import { createContext as
|
|
19
|
-
import { jsx as
|
|
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
|
|
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
|
-
},
|
|
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
|
|
54
|
-
return
|
|
54
|
+
function ye() {
|
|
55
|
+
return _(ve);
|
|
55
56
|
}
|
|
56
|
-
var
|
|
57
|
-
let
|
|
58
|
-
|
|
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 [
|
|
62
|
-
|
|
63
|
-
}, []),
|
|
64
|
-
|
|
65
|
-
}, []), V = n((e) => e.activeConversationId), H =
|
|
66
|
-
|
|
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()),
|
|
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
|
|
74
|
-
|
|
75
|
-
|
|
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 =
|
|
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
|
-
]),
|
|
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 =
|
|
92
|
-
|
|
93
|
-
}, [
|
|
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([
|
|
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
|
-
]),
|
|
111
|
-
|
|
112
|
-
let
|
|
113
|
-
if (!
|
|
114
|
-
if (
|
|
115
|
-
|
|
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),
|
|
119
|
+
O(i), we.current(e, t, i, n, r, a);
|
|
119
120
|
}
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
}, [
|
|
125
|
-
let
|
|
126
|
-
if (
|
|
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 && (
|
|
129
|
+
e.length > 0 && (u = e, O(e));
|
|
129
130
|
}
|
|
130
|
-
let
|
|
131
|
-
if (
|
|
132
|
-
let t = C("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(
|
|
133
|
-
|
|
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 (
|
|
137
|
-
|
|
137
|
+
if (f === "wait-for-voices") {
|
|
138
|
+
Fe(e, t, r, i, c);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
|
|
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
|
-
}),
|
|
145
|
-
let
|
|
146
|
-
|
|
145
|
+
}), L();
|
|
146
|
+
let p = j.current + 1;
|
|
147
|
+
j.current = p, E({
|
|
147
148
|
type: "start",
|
|
148
149
|
messageId: e,
|
|
149
|
-
requestId:
|
|
150
|
-
}),
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
requestId:
|
|
154
|
-
chunks:
|
|
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
|
-
|
|
158
|
-
},
|
|
159
|
-
let
|
|
160
|
-
|
|
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:
|
|
163
|
+
requestId: p
|
|
163
164
|
});
|
|
164
165
|
};
|
|
165
166
|
try {
|
|
166
|
-
S.speak(
|
|
167
|
-
voice: o(
|
|
168
|
-
lang:
|
|
169
|
-
rate:
|
|
167
|
+
S.speak(m, {
|
|
168
|
+
voice: o(u, d, U[r]),
|
|
169
|
+
lang: d,
|
|
170
|
+
rate: je(r)
|
|
170
171
|
}, {
|
|
171
172
|
onStart: () => {
|
|
172
|
-
|
|
173
|
+
j.current === p && M.current === p && h(e, "firstAudio");
|
|
173
174
|
},
|
|
174
175
|
onChunkStart: (e) => {
|
|
175
|
-
|
|
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
|
-
} :
|
|
179
|
-
requestId:
|
|
180
|
-
chunks:
|
|
179
|
+
} : j.current === p ? {
|
|
180
|
+
requestId: p,
|
|
181
|
+
chunks: m,
|
|
181
182
|
index: e
|
|
182
183
|
} : t);
|
|
183
184
|
},
|
|
184
|
-
onEnd: () =>
|
|
185
|
-
|
|
186
|
-
|
|
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:
|
|
193
|
+
requestId: p
|
|
191
194
|
})
|
|
192
195
|
});
|
|
193
196
|
} catch {
|
|
194
|
-
|
|
197
|
+
te();
|
|
195
198
|
}
|
|
196
199
|
}, [
|
|
197
|
-
|
|
200
|
+
L,
|
|
198
201
|
S,
|
|
199
202
|
w,
|
|
200
203
|
U,
|
|
201
|
-
|
|
204
|
+
je,
|
|
202
205
|
K,
|
|
203
206
|
C,
|
|
204
207
|
k,
|
|
205
|
-
|
|
208
|
+
Fe
|
|
206
209
|
]);
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
v(() => {
|
|
211
|
+
we.current = Y;
|
|
209
212
|
}, [Y]);
|
|
210
|
-
let X =
|
|
213
|
+
let X = g((e, t, n, r) => {
|
|
211
214
|
if (!H) return;
|
|
212
|
-
let i =
|
|
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
|
-
|
|
219
|
+
Me,
|
|
217
220
|
G,
|
|
218
221
|
Y,
|
|
219
222
|
D
|
|
220
|
-
]),
|
|
221
|
-
if (
|
|
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
|
-
|
|
232
|
-
|
|
233
|
-
}, [
|
|
234
|
-
let
|
|
235
|
-
autoSpeakEnabled:
|
|
236
|
-
sessionSpeaking:
|
|
237
|
-
visible:
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
autoSpeakEnabled:
|
|
243
|
-
sessionSpeaking:
|
|
244
|
-
visible:
|
|
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
|
-
|
|
250
|
-
h,
|
|
253
|
+
_,
|
|
251
254
|
H
|
|
252
255
|
]);
|
|
253
|
-
let
|
|
254
|
-
|
|
255
|
-
J(),
|
|
256
|
-
let e =
|
|
257
|
-
|
|
258
|
-
}, [V, J]),
|
|
259
|
-
|
|
260
|
-
}, [G, J]),
|
|
261
|
-
|
|
262
|
-
}, [S]),
|
|
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]),
|
|
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 &&
|
|
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
|
-
|
|
280
|
+
L,
|
|
278
281
|
S,
|
|
279
282
|
H
|
|
280
283
|
]);
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
let Z = b(X);
|
|
285
|
+
v(() => {
|
|
286
|
+
Z.current = X;
|
|
284
287
|
}, [X]);
|
|
285
|
-
let Q =
|
|
286
|
-
if (r(e) !== t ||
|
|
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
|
-
|
|
292
|
+
Z.current(e.id, n, e.metadata?.lang, { auto: !0 });
|
|
290
293
|
} catch {}
|
|
291
|
-
}, []), $ =
|
|
292
|
-
if (e !==
|
|
293
|
-
n.getState().activeConversationId === e && (
|
|
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 =
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
}, [$]),
|
|
309
|
-
if (!(!
|
|
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,
|
|
320
|
+
!o || o.role !== "assistant" || Q(o, z);
|
|
318
321
|
});
|
|
319
322
|
}, [
|
|
323
|
+
R,
|
|
320
324
|
z,
|
|
321
|
-
B,
|
|
322
325
|
H,
|
|
323
|
-
|
|
326
|
+
_,
|
|
324
327
|
Q
|
|
325
328
|
]);
|
|
326
|
-
let
|
|
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
|
-
]),
|
|
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:
|
|
337
|
-
voiceChoices:
|
|
338
|
-
spokenChunks: ce(T,
|
|
339
|
-
activeVoiceName:
|
|
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) =>
|
|
370
|
+
setVoice: (e) => Ae(G, e),
|
|
342
371
|
speakingMessageId: T.status === "speaking" ? T.messageId : null,
|
|
343
|
-
isSpeaking: (e) =>
|
|
344
|
-
toggle:
|
|
372
|
+
isSpeaking: (e) => se(T, e),
|
|
373
|
+
toggle: Ie,
|
|
345
374
|
stop: J,
|
|
346
|
-
autoSpeakEnabled:
|
|
347
|
-
setAutoSpeak:
|
|
348
|
-
sessionSpeaking:
|
|
349
|
-
setSessionSpeaking:
|
|
350
|
-
setSessionMicOpen:
|
|
375
|
+
autoSpeakEnabled: R,
|
|
376
|
+
setAutoSpeak: Te,
|
|
377
|
+
sessionSpeaking: z,
|
|
378
|
+
setSessionSpeaking: Ee,
|
|
379
|
+
setSessionMicOpen: De,
|
|
351
380
|
speakFinishedReply: $,
|
|
352
|
-
previewVoice:
|
|
381
|
+
previewVoice: Ne
|
|
353
382
|
}), [
|
|
354
383
|
H,
|
|
355
384
|
q,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
385
|
+
Pe,
|
|
386
|
+
He,
|
|
387
|
+
Ue,
|
|
359
388
|
U,
|
|
360
|
-
|
|
389
|
+
Ae,
|
|
361
390
|
G,
|
|
362
391
|
T,
|
|
363
|
-
|
|
392
|
+
Ie,
|
|
364
393
|
J,
|
|
365
|
-
|
|
366
|
-
Se,
|
|
367
|
-
B,
|
|
394
|
+
R,
|
|
368
395
|
Te,
|
|
396
|
+
z,
|
|
397
|
+
De,
|
|
369
398
|
$,
|
|
370
|
-
|
|
399
|
+
Ne,
|
|
371
400
|
C,
|
|
372
|
-
|
|
401
|
+
Ce
|
|
373
402
|
]);
|
|
374
|
-
return /* @__PURE__ */
|
|
375
|
-
value:
|
|
376
|
-
children:
|
|
403
|
+
return /* @__PURE__ */ he(ve.Provider, {
|
|
404
|
+
value: We,
|
|
405
|
+
children: fe
|
|
377
406
|
});
|
|
378
407
|
};
|
|
379
408
|
//#endregion
|
|
380
|
-
export {
|
|
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;
|
|
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;AAIpE,OAAO,EAgBL,KAAK,oBAAoB,EAE1B,MAAM,uBAAuB,CAAC;AAsC/B;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAC5B,SAAS,GAAG,eAAe,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAEvE;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;CAC7B;AAMD,UAAU,OAAO;IACf,+EAA+E;IAC/E;;;;;;;OAOG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM;IACtB;;;OAGG;IACH,MAAM,EAAE,eAAe,KACpB,IAAI,CAAC;IACV;;;;OAIG;IACH,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,OAAO;;IA4xBtE,qEAAqE;;IAErE;;;;;;;OAOG;;IAEH,+DAA+D;;IAE/D;;;;;;;OAOG;;IAIH,0EAA0E;;IAE1E,6DAA6D;;IAE7D,sDAAsD;;;;uCApEvC,MAAM;;;IA2ErB,0EAA0E;qBAtsB1C,iBAAiB;IAwsBjD;;;OAGG;+BAttBuC,OAAO;IAwtBjD;;;OAGG;0BArrBE,iBAAiB;EAitB3B"}
|