@w0nna_dev/lina-widget 1.1.1 → 1.2.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/lina-widget.es.js +91 -53
- package/dist/lina-widget.umd.js +9 -9
- package/dist/sounds/pop-connect.mp3 +0 -0
- package/dist/sounds/pop-disconnect.mp3 +0 -0
- package/dist/src/components/orb-widget.d.ts +14 -1
- package/dist/src/core/orb/SoundManager.d.ts +25 -7
- package/dist/src/orb/core/LiveKitManager.d.ts +9 -0
- package/package.json +5 -5
package/dist/lina-widget.es.js
CHANGED
|
@@ -8746,7 +8746,7 @@ function Ky(i) {
|
|
|
8746
8746
|
value: i.value
|
|
8747
8747
|
});
|
|
8748
8748
|
}
|
|
8749
|
-
class
|
|
8749
|
+
class mw extends hi.EventEmitter {
|
|
8750
8750
|
constructor() {
|
|
8751
8751
|
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
8752
8752
|
super(), this.onKeyRatcheted = (t, n, s) => {
|
|
@@ -17878,7 +17878,7 @@ class h_ extends os {
|
|
|
17878
17878
|
});
|
|
17879
17879
|
}
|
|
17880
17880
|
}
|
|
17881
|
-
class
|
|
17881
|
+
class gw extends hi.EventEmitter {
|
|
17882
17882
|
constructor(e, t) {
|
|
17883
17883
|
let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
17884
17884
|
super(), this.options = {}, this.checkResults = /* @__PURE__ */ new Map(), this.url = e, this.token = t, this.options = n;
|
|
@@ -39693,13 +39693,28 @@ class bu {
|
|
|
39693
39693
|
return this.analyser;
|
|
39694
39694
|
}
|
|
39695
39695
|
}
|
|
39696
|
+
const JM = "/sounds/pop-connect.mp3", ZM = "/sounds/pop-disconnect.mp3";
|
|
39696
39697
|
class _u {
|
|
39697
39698
|
constructor(e = {}) {
|
|
39698
|
-
this.audioContext = null, this.config = {
|
|
39699
|
+
this.audioContext = null, this.connectAudio = null, this.disconnectAudio = null, this.config = {
|
|
39699
39700
|
enabled: !0,
|
|
39700
|
-
volume: 0.
|
|
39701
|
+
volume: 0.5,
|
|
39701
39702
|
...e
|
|
39702
|
-
};
|
|
39703
|
+
}, this.preloadAudio();
|
|
39704
|
+
}
|
|
39705
|
+
/**
|
|
39706
|
+
* Preload audio files for instant playback
|
|
39707
|
+
*/
|
|
39708
|
+
preloadAudio() {
|
|
39709
|
+
try {
|
|
39710
|
+
this.connectAudio = new Audio(this.config.connectSoundUrl || JM), this.connectAudio.preload = "auto", this.connectAudio.volume = this.config.volume, this.disconnectAudio = new Audio(this.config.disconnectSoundUrl || ZM), this.disconnectAudio.preload = "auto", this.disconnectAudio.volume = this.config.volume, this.connectAudio.addEventListener("error", () => {
|
|
39711
|
+
console.warn("Failed to load connect sound, will use synthesized fallback");
|
|
39712
|
+
}), this.disconnectAudio.addEventListener("error", () => {
|
|
39713
|
+
console.warn("Failed to load disconnect sound, will use synthesized fallback");
|
|
39714
|
+
});
|
|
39715
|
+
} catch (e) {
|
|
39716
|
+
console.warn("Failed to preload audio:", e);
|
|
39717
|
+
}
|
|
39703
39718
|
}
|
|
39704
39719
|
/**
|
|
39705
39720
|
* Initialize audio context (must be called from user interaction)
|
|
@@ -39722,7 +39737,18 @@ class _u {
|
|
|
39722
39737
|
await this.ensureContext();
|
|
39723
39738
|
}
|
|
39724
39739
|
/**
|
|
39725
|
-
*
|
|
39740
|
+
* Play MP3 audio element
|
|
39741
|
+
*/
|
|
39742
|
+
async playAudioElement(e) {
|
|
39743
|
+
if (!e || !this.config.enabled) return !1;
|
|
39744
|
+
try {
|
|
39745
|
+
return e.currentTime = 0, e.volume = this.config.volume, await e.play(), !0;
|
|
39746
|
+
} catch (t) {
|
|
39747
|
+
return console.warn("Failed to play audio:", t), !1;
|
|
39748
|
+
}
|
|
39749
|
+
}
|
|
39750
|
+
/**
|
|
39751
|
+
* Create a synthesized tone (fallback)
|
|
39726
39752
|
*/
|
|
39727
39753
|
createTone(e, t, n, s, r = "sine") {
|
|
39728
39754
|
const o = e.createOscillator(), a = e.createGain();
|
|
@@ -39731,10 +39757,9 @@ class _u {
|
|
|
39731
39757
|
return a.gain.setValueAtTime(0, n), a.gain.linearRampToValueAtTime(this.config.volume, n + c), a.gain.linearRampToValueAtTime(this.config.volume * d, n + c + l), a.gain.setValueAtTime(this.config.volume * d, n + s - u), a.gain.linearRampToValueAtTime(0, n + s), o.connect(a), { oscillator: o, gain: a };
|
|
39732
39758
|
}
|
|
39733
39759
|
/**
|
|
39734
|
-
*
|
|
39735
|
-
* Two-tone ascending melody like messenger notifications
|
|
39760
|
+
* Synthesized fallback for call start sound
|
|
39736
39761
|
*/
|
|
39737
|
-
async
|
|
39762
|
+
async playSynthesizedStartSound() {
|
|
39738
39763
|
const e = await this.ensureContext();
|
|
39739
39764
|
if (!e || typeof e.createGain != "function") return;
|
|
39740
39765
|
const t = e.currentTime, n = e.createGain();
|
|
@@ -39754,10 +39779,9 @@ class _u {
|
|
|
39754
39779
|
}, 300);
|
|
39755
39780
|
}
|
|
39756
39781
|
/**
|
|
39757
|
-
*
|
|
39758
|
-
* Single soft tone
|
|
39782
|
+
* Synthesized fallback for call end sound
|
|
39759
39783
|
*/
|
|
39760
|
-
async
|
|
39784
|
+
async playSynthesizedEndSound() {
|
|
39761
39785
|
const e = await this.ensureContext();
|
|
39762
39786
|
if (!e || typeof e.createGain != "function") return;
|
|
39763
39787
|
const t = e.currentTime, n = e.createGain();
|
|
@@ -39770,11 +39794,25 @@ class _u {
|
|
|
39770
39794
|
}
|
|
39771
39795
|
}, 250);
|
|
39772
39796
|
}
|
|
39797
|
+
/**
|
|
39798
|
+
* Play call start sound (MP3 with synthesized fallback)
|
|
39799
|
+
*/
|
|
39800
|
+
async playCallStartSound() {
|
|
39801
|
+
if (!this.config.enabled) return;
|
|
39802
|
+
await this.playAudioElement(this.connectAudio) || await this.playSynthesizedStartSound();
|
|
39803
|
+
}
|
|
39804
|
+
/**
|
|
39805
|
+
* Play call end sound (MP3 with synthesized fallback)
|
|
39806
|
+
*/
|
|
39807
|
+
async playCallEndSound() {
|
|
39808
|
+
if (!this.config.enabled) return;
|
|
39809
|
+
await this.playAudioElement(this.disconnectAudio) || await this.playSynthesizedEndSound();
|
|
39810
|
+
}
|
|
39773
39811
|
/**
|
|
39774
39812
|
* Update configuration
|
|
39775
39813
|
*/
|
|
39776
39814
|
setConfig(e) {
|
|
39777
|
-
this.config = { ...this.config, ...e };
|
|
39815
|
+
this.config = { ...this.config, ...e }, this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
|
|
39778
39816
|
}
|
|
39779
39817
|
/**
|
|
39780
39818
|
* Enable or disable sounds
|
|
@@ -39786,7 +39824,7 @@ class _u {
|
|
|
39786
39824
|
* Set volume (0.0 - 1.0)
|
|
39787
39825
|
*/
|
|
39788
39826
|
setVolume(e) {
|
|
39789
|
-
this.config.volume = Math.max(0, Math.min(1, e));
|
|
39827
|
+
this.config.volume = Math.max(0, Math.min(1, e)), this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
|
|
39790
39828
|
}
|
|
39791
39829
|
/**
|
|
39792
39830
|
* Get current config
|
|
@@ -39804,7 +39842,7 @@ class _u {
|
|
|
39804
39842
|
* Cleanup
|
|
39805
39843
|
*/
|
|
39806
39844
|
destroy() {
|
|
39807
|
-
this.audioContext && (this.audioContext.close(), this.audioContext = null);
|
|
39845
|
+
this.audioContext && (this.audioContext.close(), this.audioContext = null), this.connectAudio && (this.connectAudio.pause(), this.connectAudio.src = "", this.connectAudio = null), this.disconnectAudio && (this.disconnectAudio.pause(), this.disconnectAudio.src = "", this.disconnectAudio = null);
|
|
39808
39846
|
}
|
|
39809
39847
|
}
|
|
39810
39848
|
const Si = {
|
|
@@ -39953,11 +39991,11 @@ const Si = {
|
|
|
39953
39991
|
// Light pink
|
|
39954
39992
|
}
|
|
39955
39993
|
};
|
|
39956
|
-
function
|
|
39994
|
+
function vw(i, e = "dark") {
|
|
39957
39995
|
const t = e === "dark" ? Si : xi;
|
|
39958
39996
|
return t[i] || t[Object.keys(t)[0]];
|
|
39959
39997
|
}
|
|
39960
|
-
function
|
|
39998
|
+
function yw(i = "dark") {
|
|
39961
39999
|
return Object.keys(i === "dark" ? Si : xi);
|
|
39962
40000
|
}
|
|
39963
40001
|
const da = {
|
|
@@ -40045,41 +40083,41 @@ const da = {
|
|
|
40045
40083
|
idleGlowMultiplier: 1.2
|
|
40046
40084
|
}
|
|
40047
40085
|
}
|
|
40048
|
-
},
|
|
40086
|
+
}, bw = Object.fromEntries(
|
|
40049
40087
|
Object.entries(da).map(([i, e]) => [i, e.dark])
|
|
40050
|
-
),
|
|
40088
|
+
), _w = Object.fromEntries(
|
|
40051
40089
|
Object.entries(da).map(([i, e]) => [i, e.light])
|
|
40052
40090
|
);
|
|
40053
|
-
function
|
|
40091
|
+
function QM() {
|
|
40054
40092
|
return typeof window > "u" || window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
40055
40093
|
}
|
|
40056
40094
|
function Jo(i, e = "auto") {
|
|
40057
|
-
const t = da[i] || da.default, n = e === "auto" ?
|
|
40095
|
+
const t = da[i] || da.default, n = e === "auto" ? QM() : e;
|
|
40058
40096
|
return t[n];
|
|
40059
40097
|
}
|
|
40060
|
-
function
|
|
40098
|
+
function Sw() {
|
|
40061
40099
|
return Object.keys(da);
|
|
40062
40100
|
}
|
|
40063
|
-
function
|
|
40101
|
+
function ew(i, e, t = "auto") {
|
|
40064
40102
|
const n = Jo(e, t);
|
|
40065
40103
|
i.orbColors = n.colors, i.glowIntensity = n.glowIntensity, i.idleGlowMultiplier = n.idleGlowMultiplier;
|
|
40066
40104
|
}
|
|
40067
|
-
function
|
|
40105
|
+
function xw(i, e) {
|
|
40068
40106
|
if (typeof window > "u")
|
|
40069
40107
|
return () => {
|
|
40070
40108
|
};
|
|
40071
40109
|
const t = window.matchMedia("(prefers-color-scheme: dark)"), n = () => {
|
|
40072
40110
|
const s = t.matches ? "dark" : "light";
|
|
40073
|
-
|
|
40111
|
+
ew(i, e, s);
|
|
40074
40112
|
};
|
|
40075
40113
|
return n(), t.addEventListener("change", n), () => {
|
|
40076
40114
|
t.removeEventListener("change", n);
|
|
40077
40115
|
};
|
|
40078
40116
|
}
|
|
40079
|
-
var
|
|
40080
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
40117
|
+
var tw = Object.defineProperty, nw = Object.getOwnPropertyDescriptor, Mt = (i, e, t, n) => {
|
|
40118
|
+
for (var s = n > 1 ? void 0 : n ? nw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
|
|
40081
40119
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
40082
|
-
return n && s &&
|
|
40120
|
+
return n && s && tw(e, t, s), s;
|
|
40083
40121
|
};
|
|
40084
40122
|
let bt = class extends es {
|
|
40085
40123
|
constructor() {
|
|
@@ -40590,10 +40628,10 @@ Mt([
|
|
|
40590
40628
|
bt = Mt([
|
|
40591
40629
|
Lo("hanc-ai-inline-call")
|
|
40592
40630
|
], bt);
|
|
40593
|
-
var
|
|
40594
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
40631
|
+
var iw = Object.defineProperty, sw = Object.getOwnPropertyDescriptor, wt = (i, e, t, n) => {
|
|
40632
|
+
for (var s = n > 1 ? void 0 : n ? sw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
|
|
40595
40633
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
40596
|
-
return n && s &&
|
|
40634
|
+
return n && s && iw(e, t, s), s;
|
|
40597
40635
|
};
|
|
40598
40636
|
let _t = class extends es {
|
|
40599
40637
|
constructor() {
|
|
@@ -41088,10 +41126,10 @@ wt([
|
|
|
41088
41126
|
_t = wt([
|
|
41089
41127
|
Lo("hanc-ai-floating-call")
|
|
41090
41128
|
], _t);
|
|
41091
|
-
var
|
|
41092
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
41129
|
+
var rw = Object.defineProperty, aw = Object.getOwnPropertyDescriptor, At = (i, e, t, n) => {
|
|
41130
|
+
for (var s = n > 1 ? void 0 : n ? aw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
|
|
41093
41131
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
41094
|
-
return n && s &&
|
|
41132
|
+
return n && s && rw(e, t, s), s;
|
|
41095
41133
|
};
|
|
41096
41134
|
let St = class extends es {
|
|
41097
41135
|
constructor() {
|
|
@@ -41508,7 +41546,7 @@ At([
|
|
|
41508
41546
|
St = At([
|
|
41509
41547
|
Lo("hanc-ai-pill-call")
|
|
41510
41548
|
], St);
|
|
41511
|
-
const
|
|
41549
|
+
const ow = {
|
|
41512
41550
|
core: "#ffffff",
|
|
41513
41551
|
coreGlow: "#a855f7",
|
|
41514
41552
|
lightning: "#c084fc",
|
|
@@ -41527,8 +41565,8 @@ const rw = {
|
|
|
41527
41565
|
// State-based colors (used automatically)
|
|
41528
41566
|
stateIdle: "#a855f7",
|
|
41529
41567
|
// Purple - same as main orb color
|
|
41530
|
-
stateListening: "#
|
|
41531
|
-
//
|
|
41568
|
+
stateListening: "#facc15",
|
|
41569
|
+
// Yellow - user is speaking, agent listening
|
|
41532
41570
|
stateThinking: "#facc15",
|
|
41533
41571
|
// Yellow - thinking/processing
|
|
41534
41572
|
stateSpeaking: "#10b981"
|
|
@@ -41567,7 +41605,7 @@ const rw = {
|
|
|
41567
41605
|
coreScale: 1
|
|
41568
41606
|
}
|
|
41569
41607
|
};
|
|
41570
|
-
class
|
|
41608
|
+
class cw {
|
|
41571
41609
|
constructor(e, t = {}) {
|
|
41572
41610
|
this.shellSegments = [], this.coreInner = null, this.coreOuter = null, this.coreGlow = null, this.pulseRings = [], this.particles = null, this.particlePositions = null, this.particleVelocities = null, this.animationId = null, this._currentState = "idle", this._currentEmotion = "neutral", this.targetConfig = { ...rl.idle }, this.currentConfig = { ...rl.idle }, this.targetAudioLevel = 0, this.currentAudioLevel = 0, this.audioVelocity = 0, this.targetPulseColor = new Ue("#a855f7"), this.currentPulseColor = new Ue("#a855f7"), this.targetRotation = { x: 0, y: 0 }, this.currentRotation = { x: 0, y: 0 }, this.time = 0, this.animate = () => {
|
|
41573
41611
|
this.animationId = requestAnimationFrame(this.animate);
|
|
@@ -41617,7 +41655,7 @@ class aw {
|
|
|
41617
41655
|
shellSegments: t.shellSegments ?? 6,
|
|
41618
41656
|
colors: t.colors ?? {},
|
|
41619
41657
|
canvasPadding: t.canvasPadding ?? 2
|
|
41620
|
-
}, this.colors = { ...
|
|
41658
|
+
}, this.colors = { ...ow, ...t.colors }, this.clock = new vg(), this.initScene(), this.createShell(), this.createCore(), this.createParticles(), window.addEventListener("resize", this.handleResize), e.addEventListener("mousemove", this.handleMouseMove), e.addEventListener("mouseleave", this.handleMouseLeave);
|
|
41621
41659
|
}
|
|
41622
41660
|
initScene() {
|
|
41623
41661
|
this.scene = new pg();
|
|
@@ -42173,14 +42211,14 @@ class aw {
|
|
|
42173
42211
|
this.pulseRings = [], this.particles && (this.particles.geometry.dispose(), this.particles.material.dispose()), this.renderer.dispose(), this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
|
|
42174
42212
|
}
|
|
42175
42213
|
}
|
|
42176
|
-
var
|
|
42177
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
42214
|
+
var lw = Object.defineProperty, dw = Object.getOwnPropertyDescriptor, jt = (i, e, t, n) => {
|
|
42215
|
+
for (var s = n > 1 ? void 0 : n ? dw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
|
|
42178
42216
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
42179
|
-
return n && s &&
|
|
42217
|
+
return n && s && lw(e, t, s), s;
|
|
42180
42218
|
};
|
|
42181
42219
|
let Ft = class extends es {
|
|
42182
42220
|
constructor() {
|
|
42183
|
-
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.1.
|
|
42221
|
+
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.1.2", this.agentId = "", this.voiceServiceUrl = "", this.btnStartText = "Start", this.btnEndText = "End", this.colors = {}, this.brandingLogoColor = "rgba(255, 255, 255, 0.9)", this.brandingTitleColor = "rgba(255, 255, 255, 0.6)", this.brandingDividerColor = "rgba(255, 255, 255, 0.3)", this.versionColor = "rgba(255, 255, 255, 0.3)", this.buttonBackground = "linear-gradient(135deg, rgba(139, 92, 246, 0.95) 0%, rgba(124, 58, 237, 0.95) 100%)", this.buttonTextColor = "rgba(255, 255, 255, 0.95)", this.currentState = "idle", this.callStatus = "idle", this.isLoading = !0, this._hasMicPermission = null, this._localAudioContext = null, this._localAudioAnalyser = null, this._localAudioMonitorId = null, this._agentAudioContext = null, this._agentAudioAnalyser = null, this._agentAudioMonitorId = null, this._agentIsSpeaking = !1, this._interruptionTimeout = null, this._lastInterruptionTime = 0, this.handleCallClick = async () => {
|
|
42184
42222
|
if (this.callStatus === "mic-denied")
|
|
42185
42223
|
try {
|
|
42186
42224
|
(await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), this._hasMicPermission = !0, this.callStatus = "idle";
|
|
@@ -42211,7 +42249,7 @@ let Ft = class extends es {
|
|
|
42211
42249
|
}
|
|
42212
42250
|
initializeOrb() {
|
|
42213
42251
|
const i = this.orbContainerRef.value;
|
|
42214
|
-
i && (this.orbRenderer = new
|
|
42252
|
+
i && (this.orbRenderer = new cw(i, {
|
|
42215
42253
|
size: 1,
|
|
42216
42254
|
colors: this.colors
|
|
42217
42255
|
}), this.orbRenderer.start(), this.startIdleAnimation(), requestAnimationFrame(() => {
|
|
@@ -42849,20 +42887,20 @@ Ft = jt([
|
|
|
42849
42887
|
export {
|
|
42850
42888
|
_t as FloatingCall,
|
|
42851
42889
|
bt as InlineCall,
|
|
42852
|
-
|
|
42890
|
+
cw as LinaOrbRenderer,
|
|
42853
42891
|
Ft as LinaWidget,
|
|
42854
42892
|
St as PillCall,
|
|
42855
42893
|
_u as SoundManager,
|
|
42856
|
-
|
|
42894
|
+
ew as applyTheme,
|
|
42857
42895
|
Si as darkPresets,
|
|
42858
|
-
|
|
42859
|
-
|
|
42860
|
-
|
|
42861
|
-
|
|
42896
|
+
bw as darkThemes,
|
|
42897
|
+
QM as detectSystemTheme,
|
|
42898
|
+
vw as getColorPreset,
|
|
42899
|
+
yw as getPresetNames,
|
|
42862
42900
|
Jo as getTheme,
|
|
42863
|
-
|
|
42901
|
+
Sw as getThemeNames,
|
|
42864
42902
|
xi as lightPresets,
|
|
42865
|
-
|
|
42903
|
+
_w as lightThemes,
|
|
42866
42904
|
da as themes,
|
|
42867
|
-
|
|
42905
|
+
xw as watchSystemTheme
|
|
42868
42906
|
};
|