@inupedia/spotlight-vue 0.8.6 → 0.9.0
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/assets/spotlight-vue.css +1 -1
- package/dist/avatar/speech/live2dTtsPlayback.d.ts +15 -2
- package/dist/avatar/speech/live2dTtsPlayback.d.ts.map +1 -1
- package/dist/avatar/speech/live2dTtsPlayback.js +77 -15
- package/dist/avatar/speech/spotlightSpeech.d.ts.map +1 -1
- package/dist/avatar/speech/spotlightSpeech.js +44 -36
- package/dist/avatar/spine/live2dApp.d.ts +3 -0
- package/dist/avatar/spine/live2dApp.d.ts.map +1 -1
- package/dist/avatar/spine/live2dApp.js +30 -18
- package/dist/avatar/spine/spineAvatar.d.ts +4 -0
- package/dist/avatar/spine/spineAvatar.d.ts.map +1 -1
- package/dist/avatar/spine/spineAvatar.js +114 -83
- package/dist/avatar/spine/spineLipSync.d.ts +1 -0
- package/dist/avatar/spine/spineLipSync.d.ts.map +1 -1
- package/dist/avatar/spine/spineLipSync.js +41 -36
- package/dist/avatar/voice/avatarDirector.d.ts +8 -0
- package/dist/avatar/voice/avatarDirector.d.ts.map +1 -0
- package/dist/avatar/voice/avatarDirector.js +6 -0
- package/dist/avatar/voice/config.d.ts +5 -0
- package/dist/avatar/voice/config.d.ts.map +1 -0
- package/dist/avatar/voice/config.js +5 -0
- package/dist/avatar/voice/panelHidePolicy.d.ts +6 -0
- package/dist/avatar/voice/panelHidePolicy.d.ts.map +1 -0
- package/dist/avatar/voice/panelHidePolicy.js +6 -0
- package/dist/avatar/voice/voiceSession.d.ts +5 -0
- package/dist/avatar/voice/voiceSession.d.ts.map +1 -0
- package/dist/avatar/voice/voiceSession.js +14 -0
- package/dist/components/Live2dPanel.vue.d.ts.map +1 -1
- package/dist/components/Live2dPanel.vue.js +2 -2
- package/dist/components/SpotlightShell.vue.d.ts.map +1 -1
- package/dist/components/SpotlightShell.vue.js +1 -1
- package/dist/components/SpotlightShell2.vue.js +290 -200
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -22
- package/dist/mountShell.d.ts.map +1 -1
- package/dist/mountShell.js +13 -10
- package/dist/plugin.js +1 -1
- package/dist/remote/audio.d.ts.map +1 -1
- package/dist/remote/audio.js +19 -18
- package/dist/remote/runPipeline.d.ts +1 -0
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +83 -96
- package/dist/store/live2dSpeechStore.d.ts +2 -2
- package/dist/store/memoryPreferenceStore.d.ts +1 -1
- package/dist/store/runtime/types.d.ts +1 -1
- package/dist/store/runtime/types.d.ts.map +1 -1
- package/dist/store/spotlightStore.d.ts +10 -10
- package/package.json +3 -3
|
@@ -1,317 +1,407 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
1
|
+
import { defineComponent as Ae, computed as _, ref as d, watch as Z, onMounted as Be, onUnmounted as xe, openBlock as U, createElementBlock as ee, Fragment as He, createVNode as _e, unref as M, createBlock as Ke, createElementVNode as te, createCommentVNode as Re, nextTick as ne } from "vue";
|
|
2
|
+
import { VoiceTurnController as Fe, sanitizeSpokenText as Ie, drainSpokenClips as ie, packSpokenSentences as Me } from "@inupedia/spotlight-protocol";
|
|
3
|
+
import { stopTtsBufferPlayback as Oe, decodeTtsAudioFromBlob as De, getTtsPlaybackContext as Ne, appendSilenceToAudioBuffer as Ue, playTtsAudioBuffer as qe, TTS_CLIP_SILENCE_MS as re } from "../avatar/speech/live2dTtsPlayback.js";
|
|
4
|
+
import { SpotlightSpeechService as ze, hasSpotlightSpeechConfig as $e } from "../avatar/speech/spotlightSpeech.js";
|
|
5
|
+
import { storeToRefs as Ge } from "pinia";
|
|
6
|
+
import { useSpotlightStore as We } from "../store/spotlightStore.js";
|
|
7
|
+
import { useSpotlightAvatarConfig as Ye } from "../avatar/config.js";
|
|
8
|
+
import { unlockVoicePlayback as Qe } from "../avatar/voice/voiceSession.js";
|
|
9
|
+
import { shouldAbortVoiceOnPanelHide as je } from "../avatar/voice/panelHidePolicy.js";
|
|
10
|
+
import { directorPhaseFromTurn as Je } from "../avatar/voice/avatarDirector.js";
|
|
11
|
+
import { useAgentSessionStore as Xe } from "../session/agentSession.js";
|
|
12
|
+
import Ze from "./SpotlightRoot.vue.js";
|
|
13
|
+
import et from "./Live2dPanel.vue.js";
|
|
14
|
+
import { useLive2dOverlayStore as tt } from "../store/live2dOverlayStore.js";
|
|
15
|
+
import { useLive2dSpeechStore as nt } from "../store/live2dSpeechStore.js";
|
|
16
|
+
import { useLive2dVoiceChannelStore as it } from "../store/live2dVoiceChannelStore.js";
|
|
17
|
+
import { devWarn as rt } from "../utils/devConsole.js";
|
|
18
|
+
const oe = "Backquote", ot = "`", Tt = /* @__PURE__ */ Ae({
|
|
14
19
|
__name: "SpotlightShell",
|
|
15
20
|
props: {
|
|
16
21
|
avatarEnabled: { type: Boolean, default: !1 }
|
|
17
22
|
},
|
|
18
|
-
setup(
|
|
19
|
-
const
|
|
23
|
+
setup(O) {
|
|
24
|
+
const V = O, K = Ye(), ae = _(
|
|
20
25
|
() => K.deckKicker?.trim() || "SPOTLIGHT"
|
|
21
|
-
),
|
|
26
|
+
), R = _(
|
|
22
27
|
() => K.greetingText?.trim() || "您好,我是 Spotlight 助手"
|
|
23
|
-
), n =
|
|
28
|
+
), n = We(), E = tt(), { visible: h } = Ge(E), s = nt(), c = it(), b = new ze(), T = d(null), u = d(!1), y = d(!1), C = d(!1), A = d(null), p = d(null), g = d(0), S = d(!1), q = _(
|
|
24
29
|
() => Math.max(
|
|
25
30
|
0,
|
|
26
31
|
K.briefingKeepLastMs ?? 0
|
|
27
32
|
)
|
|
28
33
|
);
|
|
29
|
-
let
|
|
30
|
-
const
|
|
31
|
-
let
|
|
32
|
-
const
|
|
34
|
+
let k = null;
|
|
35
|
+
const m = d(!1);
|
|
36
|
+
let B = Promise.resolve(), F = 0;
|
|
37
|
+
const l = new Fe(), x = d(!1);
|
|
38
|
+
let D = 0, f = "", L = 0;
|
|
39
|
+
l.onAbort(async () => {
|
|
40
|
+
n.cancelPipeline(), x.value = !1, f = "", L = 0, w(), H(), s.reset(), import("../avatar/spine/live2dApp.js").then(
|
|
41
|
+
(e) => e.stopLive2dLipSync()
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
const le = _(() => n.showThinkingBar ? !V.avatarEnabled || !h.value || n.pipelinePhase === "running" || S.value ? !0 : n.pipelinePhase === "done" : !1), se = _(() => {
|
|
33
45
|
const e = n.agentSteps.length === 1 && n.agentSteps[0]?.label === "回答";
|
|
34
|
-
return n.pipelinePhase === "running" || e ||
|
|
46
|
+
return n.pipelinePhase === "running" || e || S.value;
|
|
35
47
|
});
|
|
36
|
-
function
|
|
37
|
-
|
|
48
|
+
function ce() {
|
|
49
|
+
S.value = !1, h.value && (n.showThinkingBar = !1);
|
|
38
50
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
51
|
+
function z() {
|
|
52
|
+
T.value != null && (window.clearTimeout(T.value), T.value = null);
|
|
41
53
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
54
|
+
function H() {
|
|
55
|
+
z(), A.value && (A.value.abort(), A.value = null), y.value = !1, C.value = !1, u.value = !1, m.value = !1, c.reset(), b.cancel();
|
|
44
56
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
57
|
+
function w() {
|
|
58
|
+
k && (k.abort(), k = null), p.value && (p.value.abort(), p.value = null), I(), s.reset(), import("../avatar/spine/live2dApp.js").then(
|
|
47
59
|
(e) => e.stopLive2dLipSync()
|
|
48
60
|
);
|
|
49
61
|
}
|
|
50
|
-
function
|
|
51
|
-
return e <= 0 ? Promise.resolve() : new Promise((i,
|
|
52
|
-
const
|
|
53
|
-
t?.removeEventListener("abort",
|
|
54
|
-
}, e),
|
|
55
|
-
window.clearTimeout(
|
|
62
|
+
function ue(e, t) {
|
|
63
|
+
return e <= 0 ? Promise.resolve() : new Promise((i, r) => {
|
|
64
|
+
const a = window.setTimeout(() => {
|
|
65
|
+
t?.removeEventListener("abort", o), i();
|
|
66
|
+
}, e), o = () => {
|
|
67
|
+
window.clearTimeout(a), r(new DOMException("Aborted", "AbortError"));
|
|
56
68
|
};
|
|
57
69
|
if (t?.aborted) {
|
|
58
|
-
|
|
70
|
+
o();
|
|
59
71
|
return;
|
|
60
72
|
}
|
|
61
|
-
t?.addEventListener("abort",
|
|
73
|
+
t?.addEventListener("abort", o, { once: !0 });
|
|
62
74
|
});
|
|
63
75
|
}
|
|
64
|
-
async function
|
|
65
|
-
if (!
|
|
66
|
-
|
|
67
|
-
const e =
|
|
68
|
-
if (
|
|
69
|
-
|
|
76
|
+
async function fe() {
|
|
77
|
+
if (!h.value || n.pipelinePhase === "running") return;
|
|
78
|
+
w(), g.value += 1;
|
|
79
|
+
const e = g.value, t = new AbortController();
|
|
80
|
+
if (k = t, !$e()) {
|
|
81
|
+
k = null, await ne(), (await import("../avatar/spine/live2dApp.js")).playLive2dHello(), s.start(R.value, { instant: !0 }), s.reset();
|
|
70
82
|
return;
|
|
71
83
|
}
|
|
72
|
-
const i =
|
|
73
|
-
|
|
84
|
+
const i = b.synthesize(
|
|
85
|
+
R.value,
|
|
74
86
|
t.signal
|
|
75
87
|
);
|
|
76
|
-
if (await
|
|
77
|
-
requestAnimationFrame(() =>
|
|
78
|
-
}), !!
|
|
88
|
+
if (await ne(), await new Promise((r) => {
|
|
89
|
+
requestAnimationFrame(() => r());
|
|
90
|
+
}), !!v(t, e))
|
|
79
91
|
try {
|
|
80
|
-
const { blob:
|
|
81
|
-
if (!
|
|
82
|
-
await
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
const { blob: r } = await i;
|
|
93
|
+
if (!v(t, e)) return;
|
|
94
|
+
await Q(
|
|
95
|
+
R.value,
|
|
96
|
+
r,
|
|
85
97
|
t,
|
|
86
98
|
e,
|
|
87
99
|
{ instantText: !0, playHelloWithSpeech: !0 }
|
|
88
100
|
);
|
|
89
|
-
} catch (
|
|
101
|
+
} catch (r) {
|
|
90
102
|
if (t.signal.aborted) return;
|
|
91
|
-
const
|
|
92
|
-
|
|
103
|
+
const a = r instanceof Error ? r.message : "数字人招呼语音失败,请稍后重试。";
|
|
104
|
+
rt("[live2d-greeting]", a), v(t, e) && ((await import("../avatar/spine/live2dApp.js")).playLive2dHello(), s.start(R.value, { instant: !0 }), s.reset());
|
|
93
105
|
} finally {
|
|
94
|
-
|
|
106
|
+
k === t && (k = null);
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
109
|
+
function I() {
|
|
110
|
+
Oe();
|
|
111
|
+
}
|
|
112
|
+
function $() {
|
|
113
|
+
return globalThis.crypto?.randomUUID?.() ?? `turn-${Date.now()}-${Math.random()}`;
|
|
114
|
+
}
|
|
115
|
+
function ve() {
|
|
116
|
+
const e = Xe();
|
|
117
|
+
for (let t = e.conversationHistory.length - 1; t >= 0; t -= 1) {
|
|
118
|
+
const i = e.conversationHistory[t];
|
|
119
|
+
if (i?.role === "assistant" && i.content.trim())
|
|
120
|
+
return i.content.trim();
|
|
121
|
+
}
|
|
122
|
+
return "";
|
|
99
123
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
124
|
+
function de(e) {
|
|
125
|
+
const t = Me(e);
|
|
126
|
+
t.length !== 0 && (l.setPhase("speaking"), t.forEach((i, r) => {
|
|
127
|
+
Y({ text: i });
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
function pe() {
|
|
131
|
+
w(), g.value += 1;
|
|
102
132
|
const e = new AbortController();
|
|
103
|
-
|
|
133
|
+
p.value = e, B = Promise.resolve(), F = 0, f = "", L = 0, S.value = !0, x.value = !0, $(), D = 0;
|
|
104
134
|
}
|
|
105
|
-
function
|
|
106
|
-
const t =
|
|
107
|
-
if (!t || t.signal.aborted || !e
|
|
108
|
-
const i =
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
function G(e) {
|
|
136
|
+
const t = p.value;
|
|
137
|
+
if (!t || t.signal.aborted || !e) return;
|
|
138
|
+
const i = g.value, r = L;
|
|
139
|
+
L += 1;
|
|
140
|
+
const a = b.synthesize(e, t.signal).then(
|
|
141
|
+
(o) => ({ blob: o.blob, error: null }),
|
|
142
|
+
(o) => ({ blob: null, error: o })
|
|
111
143
|
);
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
144
|
+
F += 1, B = B.then(async () => {
|
|
145
|
+
const o = await a;
|
|
146
|
+
if (o.error) throw o.error;
|
|
147
|
+
if (!o.blob || !v(t, i)) return;
|
|
148
|
+
r === 0 && ce();
|
|
149
|
+
const P = L > r + 1 || f.length > 0 || n.pipelinePhase === "running" || n.loading;
|
|
150
|
+
await Q(
|
|
151
|
+
e,
|
|
152
|
+
o.blob,
|
|
118
153
|
t,
|
|
119
154
|
i,
|
|
120
155
|
{
|
|
121
156
|
instantText: !0,
|
|
122
|
-
hasFollowingClip:
|
|
157
|
+
hasFollowingClip: P
|
|
123
158
|
}
|
|
124
|
-
)
|
|
125
|
-
}).catch((
|
|
126
|
-
t.signal.aborted || (n.error =
|
|
159
|
+
);
|
|
160
|
+
}).catch((o) => {
|
|
161
|
+
t.signal.aborted || (n.error = o instanceof Error ? o.message : "数字人语音播放失败,请稍后重试。");
|
|
127
162
|
});
|
|
128
163
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
164
|
+
function W() {
|
|
165
|
+
if (!f) return;
|
|
166
|
+
const e = ie(f, { force: !0 });
|
|
167
|
+
f = "";
|
|
168
|
+
for (const t of e.ready) G(t);
|
|
169
|
+
}
|
|
170
|
+
function Y(e) {
|
|
171
|
+
e.generation != null && e.generation !== D && (D = e.generation, $(), B = Promise.resolve(), f = "", L = 0);
|
|
172
|
+
const t = Ie(e.text);
|
|
173
|
+
if (!t) return;
|
|
174
|
+
f += t;
|
|
175
|
+
const i = ie(f);
|
|
176
|
+
f = i.rest;
|
|
177
|
+
for (const r of i.ready) G(r);
|
|
178
|
+
}
|
|
179
|
+
async function he() {
|
|
180
|
+
const e = p.value;
|
|
181
|
+
if (!e) {
|
|
182
|
+
x.value = !1;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const t = g.value;
|
|
186
|
+
if (await B, S.value = !1, (await import("../avatar/spine/live2dApp.js")).stopLive2dLipSync(), v(e, t)) {
|
|
187
|
+
if (q.value > 0 && F > 0)
|
|
135
188
|
try {
|
|
136
|
-
await
|
|
189
|
+
await ue(q.value, e.signal);
|
|
137
190
|
} catch {
|
|
138
191
|
}
|
|
139
|
-
|
|
192
|
+
v(e, t) && s.reset();
|
|
140
193
|
}
|
|
141
|
-
|
|
194
|
+
p.value === e && (p.value = null), x.value = !1;
|
|
142
195
|
}
|
|
143
|
-
function
|
|
144
|
-
return !e.signal.aborted &&
|
|
196
|
+
function v(e, t) {
|
|
197
|
+
return !e.signal.aborted && g.value === t;
|
|
145
198
|
}
|
|
146
|
-
async function
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (await Te(A, i.signal), R.stopLive2dLipSync(), V(), !!c(i, a)) {
|
|
163
|
-
if (L) {
|
|
164
|
-
o.finish();
|
|
165
|
-
return;
|
|
199
|
+
async function Q(e, t, i, r, a) {
|
|
200
|
+
if (!v(i, r)) return;
|
|
201
|
+
const o = a?.hasFollowingClip ?? !1;
|
|
202
|
+
I();
|
|
203
|
+
const P = await import("../avatar/spine/live2dApp.js"), { audioBuffer: Le, envelope: Pe } = await De(t);
|
|
204
|
+
if (!v(i, r)) return;
|
|
205
|
+
a?.playHelloWithSpeech && P.playLive2dHello(), s.start(e, { instant: a?.instantText ?? !0 });
|
|
206
|
+
const Ve = Ne(), Ee = Ue(
|
|
207
|
+
Ve,
|
|
208
|
+
Le,
|
|
209
|
+
o ? re : Math.round(re / 2)
|
|
210
|
+
);
|
|
211
|
+
try {
|
|
212
|
+
await qe(Ee, i.signal, {
|
|
213
|
+
onStart: (N) => {
|
|
214
|
+
P.bindLive2dLipSyncToClock(N, Pe);
|
|
166
215
|
}
|
|
167
|
-
|
|
168
|
-
|
|
216
|
+
});
|
|
217
|
+
} catch (N) {
|
|
218
|
+
throw P.stopLive2dLipSync(), I(), N;
|
|
169
219
|
}
|
|
220
|
+
o || P.stopLive2dLipSync(), I(), v(i, r) && (o || s.reset());
|
|
221
|
+
}
|
|
222
|
+
function j() {
|
|
223
|
+
return !V.avatarEnabled || !h.value ? !1 : !n.loading && !C.value && !y.value;
|
|
224
|
+
}
|
|
225
|
+
function J() {
|
|
226
|
+
return j() && !n.visible;
|
|
170
227
|
}
|
|
171
|
-
function
|
|
172
|
-
|
|
228
|
+
async function ge(e) {
|
|
229
|
+
const t = e.trim();
|
|
230
|
+
if (!t) return;
|
|
231
|
+
n.prompt = t, l.setPhase("thinking"), pe();
|
|
232
|
+
const i = p.value, r = g.value;
|
|
233
|
+
try {
|
|
234
|
+
await n.submit({
|
|
235
|
+
interactionMode: "voice",
|
|
236
|
+
onVoiceSentence: Y
|
|
237
|
+
});
|
|
238
|
+
} finally {
|
|
239
|
+
const a = !!i && v(i, r);
|
|
240
|
+
if (W(), a && F === 0) {
|
|
241
|
+
const o = ve();
|
|
242
|
+
o && de(o), W();
|
|
243
|
+
}
|
|
244
|
+
await he(), a && (l.resetTo("idle"), c.reset());
|
|
245
|
+
}
|
|
173
246
|
}
|
|
174
|
-
async function
|
|
175
|
-
if (
|
|
176
|
-
const e =
|
|
177
|
-
|
|
247
|
+
async function X() {
|
|
248
|
+
if (y.value) return;
|
|
249
|
+
const e = m.value;
|
|
250
|
+
u.value = !1, e && c.setTranscribing(!0), y.value = !0;
|
|
178
251
|
const t = new AbortController();
|
|
179
|
-
|
|
252
|
+
A.value = t;
|
|
180
253
|
try {
|
|
181
|
-
const { text: i } = await
|
|
254
|
+
const { text: i } = await b.stopAndTranscribe(t.signal), r = i.trim();
|
|
182
255
|
if (e) {
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
await n.submit({
|
|
187
|
-
interactionMode: "voice",
|
|
188
|
-
onVoiceSentence: ie
|
|
189
|
-
});
|
|
190
|
-
} finally {
|
|
191
|
-
await re();
|
|
256
|
+
if (m.value = !1, c.setTranscribing(!1), !r) {
|
|
257
|
+
n.error = "没识别到内容,请靠近麦克风再说一次。";
|
|
258
|
+
return;
|
|
192
259
|
}
|
|
260
|
+
await ge(r);
|
|
193
261
|
return;
|
|
194
262
|
}
|
|
195
|
-
const
|
|
196
|
-
n.prompt =
|
|
263
|
+
const a = n.prompt.trim();
|
|
264
|
+
n.prompt = a ? `${a} ${i}` : i;
|
|
197
265
|
} catch (i) {
|
|
198
266
|
if (t.signal.aborted) return;
|
|
199
|
-
const
|
|
200
|
-
n.error =
|
|
267
|
+
const r = i instanceof Error ? i.message : "语音识别失败,请重试。";
|
|
268
|
+
n.error = r;
|
|
201
269
|
} finally {
|
|
202
|
-
|
|
270
|
+
A.value = null, y.value = !1, u.value = !1, m.value = !1, c.reset();
|
|
203
271
|
}
|
|
204
272
|
}
|
|
205
|
-
function
|
|
273
|
+
function me(e) {
|
|
206
274
|
if (e.repeat || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) return;
|
|
207
|
-
const t =
|
|
208
|
-
!n.visible && !t || n.visible && n.loading || (e.preventDefault(), !(
|
|
209
|
-
|
|
210
|
-
const i =
|
|
275
|
+
const t = J();
|
|
276
|
+
!n.visible && !t || n.visible && n.loading || (e.preventDefault(), !(T.value != null || u.value) && (T.value = window.setTimeout(async () => {
|
|
277
|
+
T.value = null;
|
|
278
|
+
const i = J();
|
|
211
279
|
if (!(!n.visible && !i) && !(n.visible && n.loading))
|
|
212
280
|
try {
|
|
213
|
-
await
|
|
214
|
-
} catch (
|
|
215
|
-
const
|
|
216
|
-
n.error =
|
|
281
|
+
await b.startRecording(), u.value = !0, m.value = i, i ? c.setRecording(!0) : c.reset(), n.error = "";
|
|
282
|
+
} catch (r) {
|
|
283
|
+
const a = r instanceof Error ? r.message : "无法启动语音录制。";
|
|
284
|
+
n.error = a, u.value = !1, m.value = !1, c.reset();
|
|
217
285
|
}
|
|
218
286
|
}, 450)));
|
|
219
287
|
}
|
|
220
|
-
async function
|
|
221
|
-
if (!(!
|
|
222
|
-
|
|
288
|
+
async function be() {
|
|
289
|
+
if (!(!j() || C.value)) {
|
|
290
|
+
C.value = !0;
|
|
223
291
|
try {
|
|
224
|
-
if (
|
|
225
|
-
|
|
292
|
+
if (w(), await b.startRecording(), !h.value) {
|
|
293
|
+
b.cancel();
|
|
226
294
|
return;
|
|
227
295
|
}
|
|
228
|
-
|
|
296
|
+
u.value = !0, m.value = !0, c.setRecording(!0), n.error = "";
|
|
229
297
|
} catch (e) {
|
|
230
298
|
const t = e instanceof Error ? e.message : "无法启动语音录制。";
|
|
231
|
-
n.error = t,
|
|
299
|
+
n.error = t, u.value = !1, m.value = !1, c.reset();
|
|
232
300
|
} finally {
|
|
233
|
-
|
|
301
|
+
C.value = !1;
|
|
234
302
|
}
|
|
235
303
|
}
|
|
236
304
|
}
|
|
237
|
-
function
|
|
238
|
-
|
|
305
|
+
function ye() {
|
|
306
|
+
u.value && X();
|
|
239
307
|
}
|
|
240
|
-
function
|
|
241
|
-
if (e.code !==
|
|
308
|
+
function Se(e) {
|
|
309
|
+
if (e.code !== oe || !n.visible && !u.value) return;
|
|
242
310
|
e.preventDefault();
|
|
243
|
-
const t =
|
|
244
|
-
|
|
311
|
+
const t = u.value;
|
|
312
|
+
z(), t && X();
|
|
245
313
|
}
|
|
246
|
-
function
|
|
247
|
-
if (e.code ===
|
|
248
|
-
|
|
314
|
+
function ke(e) {
|
|
315
|
+
if (e.code === oe) {
|
|
316
|
+
me(e);
|
|
249
317
|
return;
|
|
250
318
|
}
|
|
251
319
|
const t = e.key.toLowerCase(), i = e.metaKey || e.ctrlKey;
|
|
252
|
-
|
|
320
|
+
V.avatarEnabled && i && t === "l" && (e.preventDefault(), E.toggle());
|
|
253
321
|
}
|
|
254
|
-
function
|
|
255
|
-
|
|
322
|
+
function we() {
|
|
323
|
+
E.show();
|
|
256
324
|
}
|
|
257
|
-
function
|
|
258
|
-
|
|
325
|
+
function Te() {
|
|
326
|
+
l.abort("escape").then(() => {
|
|
327
|
+
S.value = !1, g.value += 1, w(), s.reset(), n.showThinkingBar ? n.closeThinking() : n.visible && n.close();
|
|
328
|
+
});
|
|
259
329
|
}
|
|
260
|
-
function
|
|
330
|
+
function Ce(e) {
|
|
261
331
|
if (!e) {
|
|
262
|
-
|
|
263
|
-
|
|
332
|
+
if (!je({
|
|
333
|
+
loading: n.loading,
|
|
334
|
+
pipelinePhase: n.pipelinePhase
|
|
335
|
+
})) {
|
|
336
|
+
H();
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
l.abort("panel_close"), H(), h.value && n.prepareLive2dVoiceChannel();
|
|
264
340
|
}
|
|
265
341
|
}
|
|
266
|
-
return
|
|
267
|
-
if (
|
|
342
|
+
return Z(h, (e) => {
|
|
343
|
+
if (V.avatarEnabled) {
|
|
268
344
|
if (!e) {
|
|
269
|
-
|
|
345
|
+
S.value = !1, l.abort("avatar_close"), H(), w(), s.reset(), c.reset();
|
|
270
346
|
return;
|
|
271
347
|
}
|
|
272
|
-
n.visible || n.prepareLive2dVoiceChannel(),
|
|
348
|
+
n.visible || n.prepareLive2dVoiceChannel(), Qe(), fe();
|
|
349
|
+
}
|
|
350
|
+
}), Z(
|
|
351
|
+
() => Je({
|
|
352
|
+
loading: n.loading,
|
|
353
|
+
speaking: l.phase === "speaking" || x.value,
|
|
354
|
+
toolRunning: n.agentSteps.some(
|
|
355
|
+
(e) => e.toolCalls?.some(
|
|
356
|
+
(t) => t.status === "running" || t.status === "pending"
|
|
357
|
+
)
|
|
358
|
+
),
|
|
359
|
+
interrupted: l.phase === "interrupted"
|
|
360
|
+
}),
|
|
361
|
+
(e) => {
|
|
362
|
+
l.phase === "interrupted" || l.phase === "error" || l.setPhase(e);
|
|
273
363
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}),
|
|
277
|
-
|
|
278
|
-
}), (e, t) => (
|
|
279
|
-
|
|
280
|
-
"deck-kicker":
|
|
281
|
-
"voice-hold-active":
|
|
282
|
-
"speech-pending":
|
|
283
|
-
"voice-key-label":
|
|
284
|
-
"show-thinking":
|
|
285
|
-
"thinking-centered":
|
|
286
|
-
"on-escape":
|
|
287
|
-
"on-keydown":
|
|
288
|
-
"on-keyup":
|
|
289
|
-
onVisibleChange:
|
|
364
|
+
), Be(() => {
|
|
365
|
+
V.avatarEnabled && K.initiallyVisible && E.show();
|
|
366
|
+
}), xe(() => {
|
|
367
|
+
l.abort("session_end"), H(), w(), s.reset(), c.reset();
|
|
368
|
+
}), (e, t) => (U(), ee(He, null, [
|
|
369
|
+
_e(Ze, {
|
|
370
|
+
"deck-kicker": ae.value,
|
|
371
|
+
"voice-hold-active": u.value,
|
|
372
|
+
"speech-pending": y.value,
|
|
373
|
+
"voice-key-label": ot,
|
|
374
|
+
"show-thinking": le.value,
|
|
375
|
+
"thinking-centered": se.value,
|
|
376
|
+
"on-escape": Te,
|
|
377
|
+
"on-keydown": ke,
|
|
378
|
+
"on-keyup": Se,
|
|
379
|
+
onVisibleChange: Ce
|
|
290
380
|
}, null, 8, ["deck-kicker", "voice-hold-active", "speech-pending", "show-thinking", "thinking-centered"]),
|
|
291
|
-
|
|
381
|
+
O.avatarEnabled && M(h) ? (U(), Ke(et, {
|
|
292
382
|
key: 0,
|
|
293
|
-
"voice-disabled":
|
|
294
|
-
"voice-error":
|
|
295
|
-
onVoiceStart:
|
|
296
|
-
onVoiceStop:
|
|
297
|
-
onClose:
|
|
298
|
-
}, null, 8, ["voice-disabled", "voice-error", "onClose"])) :
|
|
383
|
+
"voice-disabled": M(n).loading || y.value || C.value,
|
|
384
|
+
"voice-error": M(n).error,
|
|
385
|
+
onVoiceStart: be,
|
|
386
|
+
onVoiceStop: ye,
|
|
387
|
+
onClose: M(E).hide
|
|
388
|
+
}, null, 8, ["voice-disabled", "voice-error", "onClose"])) : O.avatarEnabled ? (U(), ee("button", {
|
|
299
389
|
key: 1,
|
|
300
390
|
type: "button",
|
|
301
391
|
class: "spotlight-avatar-reopen",
|
|
302
392
|
"aria-label": "再次打开数字人小滴",
|
|
303
393
|
title: "再次打开小滴(Ctrl/Command + L)",
|
|
304
|
-
onClick:
|
|
394
|
+
onClick: we
|
|
305
395
|
}, [...t[0] || (t[0] = [
|
|
306
|
-
|
|
396
|
+
te("span", {
|
|
307
397
|
class: "spotlight-avatar-reopen__drop",
|
|
308
398
|
"aria-hidden": "true"
|
|
309
399
|
}, null, -1),
|
|
310
|
-
|
|
311
|
-
])])) :
|
|
400
|
+
te("span", { class: "spotlight-avatar-reopen__label" }, "小滴", -1)
|
|
401
|
+
])])) : Re("", !0)
|
|
312
402
|
], 64));
|
|
313
403
|
}
|
|
314
404
|
});
|
|
315
405
|
export {
|
|
316
|
-
|
|
406
|
+
Tt as default
|
|
317
407
|
};
|
package/dist/config.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export type SpotlightQuickPanelActions = {
|
|
|
49
49
|
export declare function defineSpotlightConfig(input: SpotlightConfig): SpotlightConfig;
|
|
50
50
|
export declare const SPOTLIGHT_CONFIG_KEY: unique symbol;
|
|
51
51
|
import type { SpotlightAvatarConfig } from "./avatar/config.js";
|
|
52
|
+
import type { SpotlightVoiceConfig } from "@inupedia/spotlight-protocol";
|
|
52
53
|
export type SpotlightVueUiOptions = {
|
|
53
54
|
/** Mount command panel + thinking UI (default: true). */
|
|
54
55
|
enabled?: boolean;
|
|
@@ -56,6 +57,8 @@ export type SpotlightVueUiOptions = {
|
|
|
56
57
|
avatarEnabled?: boolean;
|
|
57
58
|
/** Avatar copy + Spine asset paths (when avatarEnabled). */
|
|
58
59
|
avatar?: SpotlightAvatarConfig;
|
|
60
|
+
/** HTTP speech (STT/TTS). Independent of the LLM provider. */
|
|
61
|
+
voice?: SpotlightVoiceConfig;
|
|
59
62
|
};
|
|
60
63
|
/** `app.use(SpotlightVue, config)` is preferred; nested config remains source-compatible. */
|
|
61
64
|
export type SpotlightVuePluginOptions = (SpotlightVueUiOptions & {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,mCAAmC,EACnC,cAAc,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,eAAe,GAAG,qBAAqB,GAAG;IACpD,wDAAwD;IACxD,KAAK,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,UAAU,EAAE,CAAC,CAAC;IAC5C,gFAAgF;IAChF,SAAS,CAAC,EAAE,yBAAyB,EAAE,GAAG,CAAC,MAAM,yBAAyB,EAAE,CAAC,CAAC;IAC9E,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,MAAM,CAAC,EAAE,cAAc,EAAE,GAAG,CA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