@inupedia/spotlight-vue 0.8.6 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/assets/spotlight-vue.css +1 -1
  2. package/dist/avatar/speech/live2dTtsPlayback.d.ts +15 -2
  3. package/dist/avatar/speech/live2dTtsPlayback.d.ts.map +1 -1
  4. package/dist/avatar/speech/live2dTtsPlayback.js +77 -15
  5. package/dist/avatar/speech/spotlightSpeech.d.ts.map +1 -1
  6. package/dist/avatar/speech/spotlightSpeech.js +40 -43
  7. package/dist/avatar/spine/live2dApp.d.ts +3 -0
  8. package/dist/avatar/spine/live2dApp.d.ts.map +1 -1
  9. package/dist/avatar/spine/live2dApp.js +30 -18
  10. package/dist/avatar/spine/spineAvatar.d.ts +4 -0
  11. package/dist/avatar/spine/spineAvatar.d.ts.map +1 -1
  12. package/dist/avatar/spine/spineAvatar.js +114 -83
  13. package/dist/avatar/spine/spineLipSync.d.ts +1 -0
  14. package/dist/avatar/spine/spineLipSync.d.ts.map +1 -1
  15. package/dist/avatar/spine/spineLipSync.js +41 -36
  16. package/dist/avatar/voice/avatarDirector.d.ts +8 -0
  17. package/dist/avatar/voice/avatarDirector.d.ts.map +1 -0
  18. package/dist/avatar/voice/avatarDirector.js +6 -0
  19. package/dist/avatar/voice/config.d.ts +5 -0
  20. package/dist/avatar/voice/config.d.ts.map +1 -0
  21. package/dist/avatar/voice/config.js +5 -0
  22. package/dist/avatar/voice/micAccess.d.ts +4 -0
  23. package/dist/avatar/voice/micAccess.d.ts.map +1 -0
  24. package/dist/avatar/voice/micAccess.js +26 -0
  25. package/dist/avatar/voice/panelHidePolicy.d.ts +6 -0
  26. package/dist/avatar/voice/panelHidePolicy.d.ts.map +1 -0
  27. package/dist/avatar/voice/panelHidePolicy.js +6 -0
  28. package/dist/avatar/voice/phonePairing.d.ts +14 -0
  29. package/dist/avatar/voice/phonePairing.d.ts.map +1 -0
  30. package/dist/avatar/voice/phonePairing.js +30 -0
  31. package/dist/avatar/voice/usePhoneVoicePairing.d.ts +17 -0
  32. package/dist/avatar/voice/usePhoneVoicePairing.d.ts.map +1 -0
  33. package/dist/avatar/voice/usePhoneVoicePairing.js +88 -0
  34. package/dist/avatar/voice/voiceSession.d.ts +5 -0
  35. package/dist/avatar/voice/voiceSession.d.ts.map +1 -0
  36. package/dist/avatar/voice/voiceSession.js +14 -0
  37. package/dist/components/Live2dPanel.vue.d.ts +20 -0
  38. package/dist/components/Live2dPanel.vue.d.ts.map +1 -1
  39. package/dist/components/Live2dPanel.vue.js +2 -2
  40. package/dist/components/Live2dPanel2.vue.js +167 -62
  41. package/dist/components/SpotlightShell.vue.d.ts.map +1 -1
  42. package/dist/components/SpotlightShell.vue.js +2 -2
  43. package/dist/components/SpotlightShell2.vue.js +320 -217
  44. package/dist/config.d.ts +3 -0
  45. package/dist/config.d.ts.map +1 -1
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +24 -22
  49. package/dist/mountShell.d.ts.map +1 -1
  50. package/dist/mountShell.js +13 -10
  51. package/dist/node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.js +504 -0
  52. package/dist/plugin.js +1 -1
  53. package/dist/remote/audio.d.ts.map +1 -1
  54. package/dist/remote/audio.js +19 -18
  55. package/dist/remote/runPipeline.d.ts +1 -0
  56. package/dist/remote/runPipeline.d.ts.map +1 -1
  57. package/dist/remote/runPipeline.js +83 -96
  58. package/dist/store/live2dSpeechStore.d.ts +2 -2
  59. package/dist/store/memoryPreferenceStore.d.ts +1 -1
  60. package/dist/store/runtime/types.d.ts +1 -1
  61. package/dist/store/runtime/types.d.ts.map +1 -1
  62. package/dist/store/spotlightStore.d.ts +10 -10
  63. package/package.json +4 -3
@@ -1,100 +1,131 @@
1
- import { Application as k, Assets as w } from "pixi.js";
2
- import { Spine as I } from "@pixi-spine/all-3.8";
3
- import { buildWavEnvelope as U, envelopeLevelAt as E, mouthAttachmentForLevel as O, MOUTH_SLOT as _ } from "./spineLipSync.js";
4
- import { resolveAvatarSkeletonUrl as x } from "../config.js";
5
- const p = "idle", h = "hello", v = "mouth_smile";
6
- let T;
7
- function q(e) {
8
- T = e;
9
- }
10
- let d = !1, u = null;
11
- function g() {
12
- u != null && (window.clearTimeout(u), u = null);
13
- }
14
- let l = null, t = null, o = null, f = null, A = !1, m = !1, c = null, s = null;
15
- function H(e, n) {
16
- if (!t) return;
17
- const i = t.skeleton, a = i.findSlot(e);
18
- if (!a) return;
19
- const r = i.getAttachment(a.data.index, n);
20
- a.setAttachment(r ?? null);
21
- }
22
- function C() {
23
- if (!t || !c || !s || s.ended) return;
24
- const e = s.currentTime * 1e3, n = E(c, e);
25
- H(_, O(n));
1
+ import { Application as _, Assets as E } from "pixi.js";
2
+ import { Spine as C } from "@pixi-spine/all-3.8";
3
+ import { buildWavEnvelope as D, envelopeLevelAt as H, mouthAttachmentForLevel as M, MOUTH_SLOT as b } from "./spineLipSync.js";
4
+ import { resolveAvatarSkeletonUrl as z } from "../config.js";
5
+ const h = "idle", v = "hello", k = "mouth_smile";
6
+ let I;
7
+ function V(t) {
8
+ I = t;
9
+ }
10
+ let S = !1, p = null;
11
+ function O() {
12
+ p != null && (window.clearTimeout(p), p = null);
13
+ }
14
+ let o = null, e = null, a = null, A = null, w = !1, f = !1, c = null, d = null, r = null, u = null;
15
+ function U(t, n) {
16
+ if (!e) return;
17
+ const i = e.skeleton, l = i.findSlot(t);
18
+ if (!l) return;
19
+ const s = i.getAttachment(l.data.index, n);
20
+ l.setAttachment(s ?? null);
26
21
  }
27
- function S() {
28
- t?.state.hasAnimation(v) && t.state.setAnimation(1, v, !0);
22
+ function N() {
23
+ if (!e) return;
24
+ if (r) {
25
+ const i = new Uint8Array(r.fftSize);
26
+ r.getByteTimeDomainData(i);
27
+ let l = 0;
28
+ for (const y of i) {
29
+ const m = (y - 128) / 128;
30
+ l += m * m;
31
+ }
32
+ const s = Math.min(1, Math.sqrt(l / i.length) * 4);
33
+ U(b, M(s));
34
+ return;
35
+ }
36
+ if (!c || !d) return;
37
+ const t = d(), n = H(c, t);
38
+ U(b, M(n));
39
+ }
40
+ function T() {
41
+ e?.state.hasAnimation(k) && e.state.setAnimation(1, k, !0);
29
42
  }
30
43
  function L() {
31
- t && t.state.setEmptyAnimation(1, 0);
32
- }
33
- function D() {
34
- t && (t.state.hasAnimation(p) && t.state.setAnimation(0, p, !0), S());
35
- }
36
- function J() {
37
- if (!t?.state.hasAnimation(h) || d) return;
38
- g(), d = !0;
39
- const e = t.state;
40
- e.setAnimation(0, h, !1), e.hasAnimation(p) && e.addAnimation(0, p, !0, 0), m ? L() : S(), t.update(0);
41
- const n = e.data.skeletonData.findAnimation(h), i = n ? (n.duration + 0.15) * 1e3 : 2500;
42
- u = window.setTimeout(() => {
43
- d = !1, u = null;
44
+ e && e.state.setEmptyAnimation(1, 0);
45
+ }
46
+ function R() {
47
+ e && (e.state.hasAnimation(h) && e.state.setAnimation(0, h, !0), T());
48
+ }
49
+ function X() {
50
+ if (!e?.state.hasAnimation(v) || S) return;
51
+ O(), S = !0;
52
+ const t = e.state;
53
+ t.setAnimation(0, v, !1), t.hasAnimation(h) && t.addAnimation(0, h, !0, 0), f ? L() : T(), e.update(0);
54
+ const n = t.data.skeletonData.findAnimation(v), i = n ? (n.duration + 0.15) * 1e3 : 2500;
55
+ p = window.setTimeout(() => {
56
+ S = !1, p = null;
44
57
  }, i);
45
58
  }
46
- function N() {
47
- if (!t || A) return;
48
- const e = t.update.bind(t);
49
- t.update = (n) => {
50
- e(n), !(!m || !c || !s) && (C(), e(0));
51
- }, A = !0;
52
- }
53
- const R = "shuidi_17";
54
59
  function W() {
55
- if (!t) return;
56
- const e = t.skeleton.findSlot(R);
57
- e && e.setAttachment(null);
58
- }
59
- function y() {
60
- if (!t || !o) return;
61
- const { clientWidth: e, clientHeight: n } = o;
62
- if (e <= 0 || n <= 0) return;
63
- t.scale.set(1), t.position.set(0, 0), t.update(0);
64
- const i = t.getLocalBounds();
60
+ if (!e || w) return;
61
+ const t = e.update.bind(e);
62
+ e.update = (n) => {
63
+ t(n), f && (!r && (!c || !d) || (N(), t(0)));
64
+ }, w = !0;
65
+ }
66
+ const B = "shuidi_17";
67
+ function G() {
68
+ if (!e) return;
69
+ const t = e.skeleton.findSlot(B);
70
+ t && t.setAttachment(null);
71
+ }
72
+ function x() {
73
+ if (!e || !a) return;
74
+ const { clientWidth: t, clientHeight: n } = a;
75
+ if (t <= 0 || n <= 0) return;
76
+ e.scale.set(1), e.position.set(0, 0), e.update(0);
77
+ const i = e.getLocalBounds();
65
78
  if (i.width <= 0 || i.height <= 0) return;
66
- const a = 0.9, r = Math.min(e * a / i.width, n * a / i.height), b = i.x + i.width / 2, M = i.y + i.height / 2;
67
- t.scale.set(r), t.position.set(e / 2 - b * r, n / 2 - M * r);
79
+ const l = 0.9, s = Math.min(t * l / i.width, n * l / i.height), y = i.x + i.width / 2, m = i.y + i.height / 2;
80
+ e.scale.set(s), e.position.set(t / 2 - y * s, n / 2 - m * s);
68
81
  }
69
- async function K() {
70
- if (o = document.getElementById("live2d-container"), !o || l) return;
71
- l = new k({
82
+ async function Y() {
83
+ if (a = document.getElementById("live2d-container"), !a || o) return;
84
+ o = new _({
72
85
  backgroundAlpha: 0,
73
86
  antialias: !0,
74
- resizeTo: o
75
- }), o.appendChild(l.view);
76
- const e = await w.load(x(T));
77
- t = new I(e.spineData), t.autoUpdate = !0, N(), l.stage.addChild(t), W(), D(), t.update(0), y(), f = new ResizeObserver(() => y()), f.observe(o);
87
+ resizeTo: a
88
+ }), a.appendChild(o.view);
89
+ const t = await E.load(z(I));
90
+ e = new C(t.spineData), e.autoUpdate = !0, W(), o.stage.addChild(e), G(), R(), e.update(0), x(), A = new ResizeObserver(() => x()), A.observe(a);
78
91
  }
79
- function Q() {
80
- B(), g(), d = !1, f?.disconnect(), f = null, A = !1, t && l && (l.stage.removeChild(t), t.destroy({ children: !0 }), t = null), l && (l.destroy(!0, { children: !0, texture: !0, baseTexture: !0 }), l = null), o = null, w.reset();
92
+ function Z() {
93
+ P(), O(), S = !1, A?.disconnect(), A = null, w = !1, e && o && (o.stage.removeChild(e), e.destroy({ children: !0 }), e = null), o && (o.destroy(!0, { children: !0, texture: !0, baseTexture: !0 }), o = null), a = null, E.reset();
81
94
  }
82
- function z(e, n) {
83
- t && (s = e, c = n, L(), m = !0, t.update(0));
95
+ function q(t, n) {
96
+ e && (g(), d = t, c = n, L(), f = !0, e.update(0));
97
+ }
98
+ function F(t, n) {
99
+ q(() => t.currentTime * 1e3, n);
100
+ }
101
+ function $(t) {
102
+ if (!e) return;
103
+ g(), d = null, c = null;
104
+ const n = new AudioContext(), i = n.createMediaStreamSource(t), l = n.createAnalyser();
105
+ l.fftSize = 1024, i.connect(l), u = n, r = l, n.resume(), L(), f = !0, e.update(0);
106
+ }
107
+ async function ee() {
108
+ u?.state === "suspended" && await u.resume();
109
+ }
110
+ function g() {
111
+ r = null, u && (u.close(), u = null);
84
112
  }
85
- async function V(e, n) {
86
- const i = await U(n);
87
- z(e, i);
113
+ async function te(t, n) {
114
+ const i = await D(n);
115
+ F(t, i);
88
116
  }
89
- function B() {
90
- m = !1, c = null, s = null, S(), t?.update(0);
117
+ function P() {
118
+ f = !1, c = null, d = null, g(), T(), e?.update(0);
91
119
  }
92
120
  export {
93
- z as bindSpineLipSyncToAudio,
94
- V as bindSpineLipSyncToAudioUrl,
95
- q as configureSpineAvatar,
96
- J as playSpineHello,
97
- K as startSpineAvatar,
98
- Q as stopSpineAvatar,
99
- B as stopSpineLipSync
121
+ F as bindSpineLipSyncToAudio,
122
+ te as bindSpineLipSyncToAudioUrl,
123
+ q as bindSpineLipSyncToClock,
124
+ $ as bindSpineLipSyncToMediaStream,
125
+ V as configureSpineAvatar,
126
+ X as playSpineHello,
127
+ ee as resumeSpineLipSyncAudio,
128
+ Y as startSpineAvatar,
129
+ Z as stopSpineAvatar,
130
+ P as stopSpineLipSync
100
131
  };
@@ -7,6 +7,7 @@ export type WavEnvelope = {
7
7
  levels: number[];
8
8
  };
9
9
  export declare function buildWavEnvelope(wavUrl: string): Promise<WavEnvelope>;
10
+ export declare function wavEnvelopeFromAudioBuffer(audioBuffer: AudioBuffer): WavEnvelope;
10
11
  export declare function buildWavEnvelopeFromBlob(blob: Blob): Promise<WavEnvelope>;
11
12
  export declare function envelopeLevelAt(envelope: WavEnvelope, elapsedMs: number): number;
12
13
  export declare function mouthAttachmentForLevel(level: number): string;
@@ -1 +1 @@
1
- {"version":3,"file":"spineLipSync.d.ts","sourceRoot":"","sources":["../../../src/avatar/spine/spineLipSync.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,eAAO,MAAM,UAAU,aAAa,CAAC;AACrC,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,iBAAiB,2DAA4D,CAAC;AAI3F,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3E;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CA4B/E;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO7D"}
1
+ {"version":3,"file":"spineLipSync.d.ts","sourceRoot":"","sources":["../../../src/avatar/spine/spineLipSync.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,eAAO,MAAM,UAAU,aAAa,CAAC;AACrC,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,iBAAiB,2DAA4D,CAAC;AAI3F,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAG3E;AAED,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,WAAW,GAAG,WAAW,CAqBhF;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAS/E;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO7D"}
@@ -1,47 +1,52 @@
1
- const M = "shuidi_0", c = ["shuidi_3", "shuidi_2", "shuidi_1", "shuidi_0"];
2
- async function S(t) {
3
- const e = await fetch(t);
4
- return m(await e.blob());
1
+ const m = "shuidi_0", l = ["shuidi_3", "shuidi_2", "shuidi_1", "shuidi_0"];
2
+ async function _(t) {
3
+ const n = await fetch(t);
4
+ return d(await n.blob());
5
5
  }
6
- async function m(t) {
7
- const e = await t.arrayBuffer(), n = new AudioContext();
8
- try {
9
- const a = await n.decodeAudioData(e.slice(0)), s = a.getChannelData(0), d = a.sampleRate, r = Math.max(1, Math.floor(d * 50 / 1e3)), i = [];
10
- for (let o = 0; o < s.length; o += r) {
11
- const u = Math.min(o + r, s.length);
12
- let h = 0;
13
- for (let l = o; l < u; l += 1) {
14
- const f = s[l];
15
- h += f * f;
16
- }
17
- i.push(Math.sqrt(h / (u - o)));
6
+ function f(t) {
7
+ const n = t.getChannelData(0), e = t.sampleRate, a = Math.max(1, Math.floor(e * 50 / 1e3)), s = [];
8
+ for (let o = 0; o < n.length; o += a) {
9
+ const c = Math.min(o + a, n.length);
10
+ let r = 0;
11
+ for (let i = o; i < c; i += 1) {
12
+ const u = n[i];
13
+ r += u * u;
18
14
  }
19
- const _ = Math.max(...i, 1e-4);
20
- return {
21
- durationMs: a.duration * 1e3,
22
- levels: i.map((o) => Math.min(1, o / _))
23
- };
15
+ s.push(Math.sqrt(r / (c - o)));
16
+ }
17
+ const h = Math.max(...s, 1e-4);
18
+ return {
19
+ durationMs: t.duration * 1e3,
20
+ levels: s.map((o) => Math.min(1, o / h))
21
+ };
22
+ }
23
+ async function d(t) {
24
+ const n = await t.arrayBuffer(), e = new AudioContext();
25
+ try {
26
+ const a = await e.decodeAudioData(n.slice(0));
27
+ return f(a);
24
28
  } finally {
25
- n.close();
29
+ e.close();
26
30
  }
27
31
  }
28
- function p(t, e) {
29
- if (e < 0) return 0;
30
- const n = Math.floor(e / 50);
31
- return n >= t.levels.length ? 0 : t.levels[n] ?? 0;
32
+ function M(t, n) {
33
+ if (n < 0) return 0;
34
+ const e = Math.floor(n / 50);
35
+ return e >= t.levels.length ? 0 : t.levels[e] ?? 0;
32
36
  }
33
37
  function v(t) {
34
- const e = Math.max(0, Math.min(1, t)), n = Math.min(
35
- c.length - 1,
36
- Math.floor(e * c.length)
38
+ const n = Math.max(0, Math.min(1, t)), e = Math.min(
39
+ l.length - 1,
40
+ Math.floor(n * l.length)
37
41
  );
38
- return c[n];
42
+ return l[e];
39
43
  }
40
44
  export {
41
- c as MOUTH_OPEN_LEVELS,
42
- M as MOUTH_SLOT,
43
- S as buildWavEnvelope,
44
- m as buildWavEnvelopeFromBlob,
45
- p as envelopeLevelAt,
46
- v as mouthAttachmentForLevel
45
+ l as MOUTH_OPEN_LEVELS,
46
+ m as MOUTH_SLOT,
47
+ _ as buildWavEnvelope,
48
+ d as buildWavEnvelopeFromBlob,
49
+ M as envelopeLevelAt,
50
+ v as mouthAttachmentForLevel,
51
+ f as wavEnvelopeFromAudioBuffer
47
52
  };
@@ -0,0 +1,8 @@
1
+ import type { SpotlightVoicePhase } from "@inupedia/spotlight-protocol";
2
+ export declare function directorPhaseFromTurn(input: {
3
+ loading: boolean;
4
+ speaking: boolean;
5
+ toolRunning: boolean;
6
+ interrupted?: boolean;
7
+ }): SpotlightVoicePhase;
8
+ //# sourceMappingURL=avatarDirector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatarDirector.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/avatarDirector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,mBAAmB,CAMtB"}
@@ -0,0 +1,6 @@
1
+ function r(n) {
2
+ return n.interrupted ? "interrupted" : n.speaking ? "speaking" : n.toolRunning ? "tool-running" : n.loading ? "thinking" : "listening";
3
+ }
4
+ export {
5
+ r as directorPhaseFromTurn
6
+ };
@@ -0,0 +1,5 @@
1
+ import { type InjectionKey } from "vue";
2
+ import type { SpotlightVoiceConfig } from "@inupedia/spotlight-protocol";
3
+ export declare const SPOTLIGHT_VOICE_CONFIG_KEY: InjectionKey<SpotlightVoiceConfig>;
4
+ export declare function useSpotlightVoiceConfig(): SpotlightVoiceConfig;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,eAAO,MAAM,0BAA0B,EAAE,YAAY,CAAC,oBAAoB,CACxC,CAAC;AAEnC,wBAAgB,uBAAuB,IAAI,oBAAoB,CAE9D"}
@@ -0,0 +1,5 @@
1
+ import "vue";
2
+ const t = /* @__PURE__ */ Symbol("spotlight-voice-config");
3
+ export {
4
+ t as SPOTLIGHT_VOICE_CONFIG_KEY
5
+ };
@@ -0,0 +1,4 @@
1
+ export declare function microphoneAccessMessage(err?: unknown): string;
2
+ export declare function assertMicrophoneAvailable(): void;
3
+ export declare function getMicrophoneStream(): Promise<MediaStream>;
4
+ //# sourceMappingURL=micAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"micAccess.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/micAccess.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAuB7D;AAED,wBAAgB,yBAAyB,IAAI,IAAI,CAahD;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,WAAW,CAAC,CAOhE"}
@@ -0,0 +1,26 @@
1
+ function r(e) {
2
+ const i = e instanceof Error ? e.message : "", t = typeof window < "u" && window.isSecureContext === !1, n = typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia;
3
+ return t ? "当前不是安全连接,浏览器不允许使用麦克风。请通过 HTTPS 打开本页,或改用打字发送。" : n ? "当前浏览器没有开放麦克风。请允许本站点使用麦克风后重试。" : /NotAllowed|Permission|NotReadable/i.test(i) ? "麦克风权限被拒绝。请在浏览器地址栏允许麦克风后重试。" : /NotFound/i.test(i) ? "没有检测到麦克风设备。" : /getUserMedia|mediaDevices/i.test(i) ? "无法打开麦克风。请允许浏览器使用麦克风,或改用打字发送。" : i || "无法启动语音录制。";
4
+ }
5
+ function o() {
6
+ const e = r(), i = typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia;
7
+ if (typeof window < "u" && window.isSecureContext === !1)
8
+ throw new Error(e);
9
+ if (i)
10
+ throw new Error(e);
11
+ if (typeof MediaRecorder > "u")
12
+ throw new Error("当前浏览器不支持录音。");
13
+ }
14
+ async function s() {
15
+ o();
16
+ try {
17
+ return await navigator.mediaDevices.getUserMedia({ audio: !0 });
18
+ } catch (e) {
19
+ throw new Error(r(e));
20
+ }
21
+ }
22
+ export {
23
+ o as assertMicrophoneAvailable,
24
+ s as getMicrophoneStream,
25
+ r as microphoneAccessMessage
26
+ };
@@ -0,0 +1,6 @@
1
+ /** Text submit hides the command panel to show thinking. That is not a user cancel. */
2
+ export declare function shouldAbortVoiceOnPanelHide(state: {
3
+ loading: boolean;
4
+ pipelinePhase: string;
5
+ }): boolean;
6
+ //# sourceMappingURL=panelHidePolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panelHidePolicy.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/panelHidePolicy.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAEV"}
@@ -0,0 +1,6 @@
1
+ function e(n) {
2
+ return !n.loading && n.pipelinePhase !== "running";
3
+ }
4
+ export {
5
+ e as shouldAbortVoiceOnPanelHide
6
+ };
@@ -0,0 +1,14 @@
1
+ export declare function isWeChatInAppBrowser(userAgent?: string): boolean;
2
+ /** Host app directory. Library builds freeze import.meta.env.BASE_URL as "/". */
3
+ export declare function voiceRemotePageDirectory(pathname: string): string;
4
+ /** Phone remote URL on the same public origin as the GIS page. */
5
+ export declare function voiceRemotePageUrl(token: string, location?: Pick<Location, "origin" | "pathname">): string;
6
+ export declare function createVoiceRemoteSession(postJson: <T>(path: string, body: unknown) => Promise<T>): Promise<{
7
+ token: string;
8
+ expiresAt: number;
9
+ }>;
10
+ export declare function pullVoiceRemoteUtterances(token: string, getJson: <T>(path: string) => Promise<T>): Promise<Array<{
11
+ id: string;
12
+ text: string;
13
+ }>>;
14
+ //# sourceMappingURL=phonePairing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phonePairing.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/phonePairing.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,SAAS,SAAK,GAAG,OAAO,CAE5D;AAED,iFAAiF;AACjF,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CASjE;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAmB,GAChE,MAAM,CAOR;AAED,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GACvD,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAE/C;AAED,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACvC,OAAO,CAAC,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAK9C"}
@@ -0,0 +1,30 @@
1
+ function s(t) {
2
+ const e = t.replace(/\/index\.html$/i, "/");
3
+ if (e.endsWith("/")) return e || "/";
4
+ if ((e.split("/").pop() ?? "").includes(".")) {
5
+ const o = e.lastIndexOf("/");
6
+ return o >= 0 ? e.slice(0, o + 1) : "/";
7
+ }
8
+ return `${e}/`;
9
+ }
10
+ function i(t, e = window.location) {
11
+ const n = new URL(
12
+ `${s(e.pathname)}voice-remote.html`,
13
+ e.origin
14
+ );
15
+ return n.searchParams.set("p", t), n.toString();
16
+ }
17
+ async function r(t) {
18
+ return t("/v1/voice-remote/sessions", {});
19
+ }
20
+ async function c(t, e) {
21
+ return (await e(
22
+ `/v1/voice-remote/sessions/${encodeURIComponent(t)}/pending`
23
+ )).utterances ?? [];
24
+ }
25
+ export {
26
+ r as createVoiceRemoteSession,
27
+ c as pullVoiceRemoteUtterances,
28
+ s as voiceRemotePageDirectory,
29
+ i as voiceRemotePageUrl
30
+ };
@@ -0,0 +1,17 @@
1
+ export declare function usePhoneVoicePairing(options: {
2
+ enabled: boolean;
3
+ onUtterance: (text: string) => Promise<void>;
4
+ }): {
5
+ canShow: import("vue").ComputedRef<boolean>;
6
+ pairUrl: import("vue").Ref<string, string>;
7
+ qrSvg: import("vue").Ref<string, string>;
8
+ phoneConnected: import("vue").Ref<boolean, boolean>;
9
+ pairError: import("vue").Ref<string, string>;
10
+ panelOpen: import("vue").Ref<boolean, boolean>;
11
+ openPanel: () => void;
12
+ closePanel: () => void;
13
+ clearPairError: () => void;
14
+ startPolling: () => void;
15
+ ensureSession: () => Promise<void>;
16
+ };
17
+ //# sourceMappingURL=usePhoneVoicePairing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePhoneVoicePairing.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/usePhoneVoicePairing.ts"],"names":[],"mappings":"AASA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;;;;;;;;;;;;EA2HA"}
@@ -0,0 +1,88 @@
1
+ import { ref as o, computed as R, onUnmounted as U } from "vue";
2
+ import { renderSVG as I } from "../../node_modules/.pnpm/uqr@0.1.3/node_modules/uqr/dist/index.js";
3
+ import { postSpotlightJson as V, getSpotlightJson as g } from "../../remote/serverJson.js";
4
+ import { createVoiceRemoteSession as b, voiceRemotePageUrl as x, pullVoiceRemoteUtterances as k } from "./phonePairing.js";
5
+ function _(f) {
6
+ const e = o(""), l = o(""), v = o(""), p = o(!1), t = o(""), c = o(!1);
7
+ let r = null, u = !1;
8
+ const P = R(() => f.enabled);
9
+ function d() {
10
+ r != null && (window.clearInterval(r), r = null);
11
+ }
12
+ function E() {
13
+ e.value && (l.value = x(e.value), v.value = I(l.value, {
14
+ border: 2,
15
+ ecc: "M",
16
+ pixelSize: 4,
17
+ blackColor: "#0f172a",
18
+ whiteColor: "#ffffff"
19
+ }));
20
+ }
21
+ async function i() {
22
+ if (!(typeof window > "u") && !window.location.pathname.includes("voice-remote") && !e.value)
23
+ try {
24
+ const n = await b(V);
25
+ e.value = n.token, E(), t.value = "";
26
+ } catch (n) {
27
+ t.value = n instanceof Error ? n.message : "无法创建手机配对。";
28
+ }
29
+ }
30
+ async function m() {
31
+ if (!u && !(!e.value && (await i(), !e.value)))
32
+ try {
33
+ const [n, s] = await Promise.all([
34
+ k(e.value, g),
35
+ g(
36
+ `/v1/voice-remote/sessions/${encodeURIComponent(e.value)}`
37
+ ).catch((a) => ((a.code === "VOICE_REMOTE_EXPIRED" || a.status === 404) && (e.value = "", i()), null))
38
+ ]);
39
+ s && "phoneConnected" in s && (p.value = !!s.phoneConnected);
40
+ for (const a of n) {
41
+ const h = a.text?.trim();
42
+ if (h) {
43
+ u = !0;
44
+ try {
45
+ await f.onUtterance(h);
46
+ } finally {
47
+ u = !1;
48
+ }
49
+ }
50
+ }
51
+ } catch {
52
+ }
53
+ }
54
+ function w() {
55
+ d(), i().then(() => {
56
+ m(), r = window.setInterval(() => {
57
+ m();
58
+ }, 1200);
59
+ });
60
+ }
61
+ function S() {
62
+ c.value = !0, w();
63
+ }
64
+ function y() {
65
+ c.value = !1;
66
+ }
67
+ function C() {
68
+ t.value = "";
69
+ }
70
+ return U(() => {
71
+ d();
72
+ }), {
73
+ canShow: P,
74
+ pairUrl: l,
75
+ qrSvg: v,
76
+ phoneConnected: p,
77
+ pairError: t,
78
+ panelOpen: c,
79
+ openPanel: S,
80
+ closePanel: y,
81
+ clearPairError: C,
82
+ startPolling: w,
83
+ ensureSession: i
84
+ };
85
+ }
86
+ export {
87
+ _ as usePhoneVoicePairing
88
+ };
@@ -0,0 +1,5 @@
1
+ import type { SpotlightVoiceConfig } from "@inupedia/spotlight-protocol";
2
+ export declare function unlockVoicePlayback(): Promise<void>;
3
+ export declare function describeMicrophoneError(error: unknown): string;
4
+ export declare function voiceConfigEnabled(config?: SpotlightVoiceConfig): boolean;
5
+ //# sourceMappingURL=voiceSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"voiceSession.d.ts","sourceRoot":"","sources":["../../../src/avatar/voice/voiceSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWzD;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAgB9D;AAED,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAEzE"}
@@ -0,0 +1,14 @@
1
+ async function e() {
2
+ const o = globalThis.AudioContext ?? globalThis.webkitAudioContext;
3
+ if (!o) return;
4
+ const t = new o();
5
+ try {
6
+ t.state === "suspended" && await t.resume();
7
+ } finally {
8
+ await t.close().catch(() => {
9
+ });
10
+ }
11
+ }
12
+ export {
13
+ e as unlockVoicePlayback
14
+ };
@@ -1,18 +1,38 @@
1
1
  type __VLS_Props = {
2
2
  voiceDisabled?: boolean;
3
3
  voiceError?: string;
4
+ phonePairAvailable?: boolean;
5
+ phonePairOpen?: boolean;
6
+ phonePairQr?: string;
7
+ phonePairUrl?: string;
8
+ phonePairError?: string;
9
+ phoneConnected?: boolean;
4
10
  };
5
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
12
  close: () => any;
7
13
  voiceStart: () => any;
8
14
  voiceStop: () => any;
15
+ phonePair: () => any;
16
+ phonePairClose: () => any;
17
+ dismissError: () => any;
18
+ dismissPairError: () => any;
9
19
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
20
  onClose?: (() => any) | undefined;
11
21
  onVoiceStart?: (() => any) | undefined;
12
22
  onVoiceStop?: (() => any) | undefined;
23
+ onPhonePair?: (() => any) | undefined;
24
+ onPhonePairClose?: (() => any) | undefined;
25
+ onDismissError?: (() => any) | undefined;
26
+ onDismissPairError?: (() => any) | undefined;
13
27
  }>, {
28
+ phoneConnected: boolean;
14
29
  voiceDisabled: boolean;
15
30
  voiceError: string;
31
+ phonePairAvailable: boolean;
32
+ phonePairOpen: boolean;
33
+ phonePairQr: string;
34
+ phonePairUrl: string;
35
+ phonePairError: string;
16
36
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
37
  declare const _default: typeof __VLS_export;
18
38
  export default _default;