@w0nna_dev/lina-widget 1.2.0 → 1.2.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/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 yw 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 bw 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;
|
|
@@ -39694,7 +39694,7 @@ class bu {
|
|
|
39694
39694
|
}
|
|
39695
39695
|
}
|
|
39696
39696
|
const JM = "/sounds/pop-connect.mp3", ZM = "/sounds/pop-disconnect.mp3";
|
|
39697
|
-
|
|
39697
|
+
let _u = class {
|
|
39698
39698
|
constructor(e = {}) {
|
|
39699
39699
|
this.audioContext = null, this.connectAudio = null, this.disconnectAudio = null, this.config = {
|
|
39700
39700
|
enabled: !0,
|
|
@@ -39844,7 +39844,7 @@ class _u {
|
|
|
39844
39844
|
destroy() {
|
|
39845
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);
|
|
39846
39846
|
}
|
|
39847
|
-
}
|
|
39847
|
+
};
|
|
39848
39848
|
const Si = {
|
|
39849
39849
|
default: {
|
|
39850
39850
|
primary: "#6366f1",
|
|
@@ -39991,11 +39991,11 @@ const Si = {
|
|
|
39991
39991
|
// Light pink
|
|
39992
39992
|
}
|
|
39993
39993
|
};
|
|
39994
|
-
function
|
|
39994
|
+
function Sw(i, e = "dark") {
|
|
39995
39995
|
const t = e === "dark" ? Si : xi;
|
|
39996
39996
|
return t[i] || t[Object.keys(t)[0]];
|
|
39997
39997
|
}
|
|
39998
|
-
function
|
|
39998
|
+
function xw(i = "dark") {
|
|
39999
39999
|
return Object.keys(i === "dark" ? Si : xi);
|
|
40000
40000
|
}
|
|
40001
40001
|
const da = {
|
|
@@ -40083,9 +40083,9 @@ const da = {
|
|
|
40083
40083
|
idleGlowMultiplier: 1.2
|
|
40084
40084
|
}
|
|
40085
40085
|
}
|
|
40086
|
-
},
|
|
40086
|
+
}, Tw = Object.fromEntries(
|
|
40087
40087
|
Object.entries(da).map(([i, e]) => [i, e.dark])
|
|
40088
|
-
),
|
|
40088
|
+
), Cw = Object.fromEntries(
|
|
40089
40089
|
Object.entries(da).map(([i, e]) => [i, e.light])
|
|
40090
40090
|
);
|
|
40091
40091
|
function QM() {
|
|
@@ -40095,14 +40095,14 @@ function Jo(i, e = "auto") {
|
|
|
40095
40095
|
const t = da[i] || da.default, n = e === "auto" ? QM() : e;
|
|
40096
40096
|
return t[n];
|
|
40097
40097
|
}
|
|
40098
|
-
function
|
|
40098
|
+
function Ew() {
|
|
40099
40099
|
return Object.keys(da);
|
|
40100
40100
|
}
|
|
40101
40101
|
function ew(i, e, t = "auto") {
|
|
40102
40102
|
const n = Jo(e, t);
|
|
40103
40103
|
i.orbColors = n.colors, i.glowIntensity = n.glowIntensity, i.idleGlowMultiplier = n.idleGlowMultiplier;
|
|
40104
40104
|
}
|
|
40105
|
-
function
|
|
40105
|
+
function Mw(i, e) {
|
|
40106
40106
|
if (typeof window > "u")
|
|
40107
40107
|
return () => {
|
|
40108
40108
|
};
|
|
@@ -42211,14 +42211,92 @@ class cw {
|
|
|
42211
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);
|
|
42212
42212
|
}
|
|
42213
42213
|
}
|
|
42214
|
-
|
|
42215
|
-
|
|
42214
|
+
const lw = "/sounds/pop-connect.mp3", dw = "/sounds/pop-disconnect.mp3";
|
|
42215
|
+
class uw {
|
|
42216
|
+
constructor(e = {}) {
|
|
42217
|
+
this.connectAudio = null, this.disconnectAudio = null, this.config = {
|
|
42218
|
+
enabled: !0,
|
|
42219
|
+
volume: 0.5,
|
|
42220
|
+
...e
|
|
42221
|
+
}, this.preloadSounds();
|
|
42222
|
+
}
|
|
42223
|
+
/**
|
|
42224
|
+
* Preload audio files for instant playback
|
|
42225
|
+
*/
|
|
42226
|
+
preloadSounds() {
|
|
42227
|
+
try {
|
|
42228
|
+
this.connectAudio = new Audio(lw), this.connectAudio.preload = "auto", this.connectAudio.volume = this.config.volume, this.disconnectAudio = new Audio(dw), this.disconnectAudio.preload = "auto", this.disconnectAudio.volume = this.config.volume;
|
|
42229
|
+
} catch (e) {
|
|
42230
|
+
console.warn("Failed to preload sounds:", e);
|
|
42231
|
+
}
|
|
42232
|
+
}
|
|
42233
|
+
/**
|
|
42234
|
+
* Play connect sound
|
|
42235
|
+
*/
|
|
42236
|
+
async playCallStartSound() {
|
|
42237
|
+
if (!(!this.config.enabled || !this.connectAudio))
|
|
42238
|
+
try {
|
|
42239
|
+
this.connectAudio.currentTime = 0, this.connectAudio.volume = this.config.volume, await this.connectAudio.play();
|
|
42240
|
+
} catch (e) {
|
|
42241
|
+
console.warn("Failed to play connect sound:", e);
|
|
42242
|
+
}
|
|
42243
|
+
}
|
|
42244
|
+
/**
|
|
42245
|
+
* Play disconnect sound
|
|
42246
|
+
*/
|
|
42247
|
+
async playCallEndSound() {
|
|
42248
|
+
if (!(!this.config.enabled || !this.disconnectAudio))
|
|
42249
|
+
try {
|
|
42250
|
+
this.disconnectAudio.currentTime = 0, this.disconnectAudio.volume = this.config.volume, await this.disconnectAudio.play();
|
|
42251
|
+
} catch (e) {
|
|
42252
|
+
console.warn("Failed to play disconnect sound:", e);
|
|
42253
|
+
}
|
|
42254
|
+
}
|
|
42255
|
+
/**
|
|
42256
|
+
* Update configuration
|
|
42257
|
+
*/
|
|
42258
|
+
setConfig(e) {
|
|
42259
|
+
this.config = { ...this.config, ...e }, this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
|
|
42260
|
+
}
|
|
42261
|
+
/**
|
|
42262
|
+
* Enable or disable sounds
|
|
42263
|
+
*/
|
|
42264
|
+
setEnabled(e) {
|
|
42265
|
+
this.config.enabled = e;
|
|
42266
|
+
}
|
|
42267
|
+
/**
|
|
42268
|
+
* Set volume (0.0 - 1.0)
|
|
42269
|
+
*/
|
|
42270
|
+
setVolume(e) {
|
|
42271
|
+
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);
|
|
42272
|
+
}
|
|
42273
|
+
/**
|
|
42274
|
+
* Get current config
|
|
42275
|
+
*/
|
|
42276
|
+
getConfig() {
|
|
42277
|
+
return { ...this.config };
|
|
42278
|
+
}
|
|
42279
|
+
/**
|
|
42280
|
+
* Check if sounds are enabled
|
|
42281
|
+
*/
|
|
42282
|
+
isEnabled() {
|
|
42283
|
+
return this.config.enabled;
|
|
42284
|
+
}
|
|
42285
|
+
/**
|
|
42286
|
+
* Cleanup
|
|
42287
|
+
*/
|
|
42288
|
+
destroy() {
|
|
42289
|
+
this.connectAudio = null, this.disconnectAudio = null;
|
|
42290
|
+
}
|
|
42291
|
+
}
|
|
42292
|
+
var hw = Object.defineProperty, fw = Object.getOwnPropertyDescriptor, jt = (i, e, t, n) => {
|
|
42293
|
+
for (var s = n > 1 ? void 0 : n ? fw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
|
|
42216
42294
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
42217
|
-
return n && s &&
|
|
42295
|
+
return n && s && hw(e, t, s), s;
|
|
42218
42296
|
};
|
|
42219
42297
|
let Ft = class extends es {
|
|
42220
42298
|
constructor() {
|
|
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 () => {
|
|
42299
|
+
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.soundManager = new uw({ enabled: !0, volume: 0.4 }), 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 () => {
|
|
42222
42300
|
if (this.callStatus === "mic-denied")
|
|
42223
42301
|
try {
|
|
42224
42302
|
(await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), this._hasMicPermission = !0, this.callStatus = "idle";
|
|
@@ -42364,6 +42442,9 @@ let Ft = class extends es {
|
|
|
42364
42442
|
case "agent_state":
|
|
42365
42443
|
(n = i.payload) != null && n.state && (this.setState(i.payload.state), this._agentIsSpeaking = i.payload.state === "speaking");
|
|
42366
42444
|
break;
|
|
42445
|
+
case "end_call":
|
|
42446
|
+
console.log("[LinaWidget] Agent requested to end call"), this.endCall();
|
|
42447
|
+
break;
|
|
42367
42448
|
}
|
|
42368
42449
|
}
|
|
42369
42450
|
/**
|
|
@@ -42384,13 +42465,13 @@ let Ft = class extends es {
|
|
|
42384
42465
|
break;
|
|
42385
42466
|
case "connected":
|
|
42386
42467
|
case "agent-connected":
|
|
42387
|
-
this.callStatus = "active", this.currentState = "speaking", (t = this.orbRenderer) == null || t.setState("speaking"), this.startActiveAnimation();
|
|
42468
|
+
this.callStatus = "active", this.currentState = "speaking", (t = this.orbRenderer) == null || t.setState("speaking"), this.startActiveAnimation(), this.soundManager.playCallStartSound();
|
|
42388
42469
|
break;
|
|
42389
42470
|
case "disconnecting":
|
|
42390
42471
|
this.callStatus = "ending";
|
|
42391
42472
|
break;
|
|
42392
42473
|
case "disconnected":
|
|
42393
|
-
this.callStatus = "idle", this.currentState = "idle", (n = this.orbRenderer) == null || n.setState("idle"), this.startIdleAnimation();
|
|
42474
|
+
this.callStatus = "idle", this.currentState = "idle", (n = this.orbRenderer) == null || n.setState("idle"), this.startIdleAnimation(), this.soundManager.playCallEndSound();
|
|
42394
42475
|
break;
|
|
42395
42476
|
case "error":
|
|
42396
42477
|
this.callStatus = "error", this.currentState = "idle", (s = this.orbRenderer) == null || s.setState("idle");
|
|
@@ -42398,8 +42479,8 @@ let Ft = class extends es {
|
|
|
42398
42479
|
}
|
|
42399
42480
|
}
|
|
42400
42481
|
cleanup() {
|
|
42401
|
-
var i, e;
|
|
42402
|
-
this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null), this.stopLocalAudioMonitoring(), this.stopAgentAudioMonitoring(), this._interruptionTimeout && (clearTimeout(this._interruptionTimeout), this._interruptionTimeout = null), (i = this.callManager) == null || i.hangUp(), (e = this.orbRenderer) == null || e.destroy(), this.orbRenderer = null;
|
|
42482
|
+
var i, e, t;
|
|
42483
|
+
this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null), this.stopLocalAudioMonitoring(), this.stopAgentAudioMonitoring(), this._interruptionTimeout && (clearTimeout(this._interruptionTimeout), this._interruptionTimeout = null), (i = this.callManager) == null || i.hangUp(), (e = this.orbRenderer) == null || e.destroy(), this.orbRenderer = null, (t = this.soundManager) == null || t.destroy();
|
|
42403
42484
|
}
|
|
42404
42485
|
startIdleAnimation() {
|
|
42405
42486
|
this.animationId !== null && cancelAnimationFrame(this.animationId);
|
|
@@ -42471,7 +42552,7 @@ let Ft = class extends es {
|
|
|
42471
42552
|
}, 3e3);
|
|
42472
42553
|
}
|
|
42473
42554
|
} else
|
|
42474
|
-
this.callStatus = "connecting", this.currentState = "listening", (t = this.orbRenderer) == null || t.setState("listening"), await new Promise((s) => setTimeout(s, 1500)), this.callStatus = "active", this.currentState = "speaking", (n = this.orbRenderer) == null || n.setState("speaking"), this.startActiveAnimation(), this.dispatchEvent(new CustomEvent("call-start", {
|
|
42555
|
+
this.callStatus = "connecting", this.currentState = "listening", (t = this.orbRenderer) == null || t.setState("listening"), await new Promise((s) => setTimeout(s, 1500)), this.callStatus = "active", this.currentState = "speaking", (n = this.orbRenderer) == null || n.setState("speaking"), this.startActiveAnimation(), this.soundManager.playCallStartSound(), this.dispatchEvent(new CustomEvent("call-start", {
|
|
42475
42556
|
detail: { agentId: "demo", timestamp: Date.now() },
|
|
42476
42557
|
bubbles: !0,
|
|
42477
42558
|
composed: !0
|
|
@@ -42482,7 +42563,7 @@ let Ft = class extends es {
|
|
|
42482
42563
|
*/
|
|
42483
42564
|
async endCall() {
|
|
42484
42565
|
var i;
|
|
42485
|
-
this.callStatus = "ending", this.callManager
|
|
42566
|
+
this.callStatus = "ending", this.callManager ? await this.callManager.hangUp() : (this.soundManager.playCallEndSound(), this.callStatus = "idle", this.currentState = "idle", (i = this.orbRenderer) == null || i.setState("idle"), this.startIdleAnimation()), this.dispatchEvent(new CustomEvent("call-end", {
|
|
42486
42567
|
detail: { timestamp: Date.now() },
|
|
42487
42568
|
bubbles: !0,
|
|
42488
42569
|
composed: !0
|
|
@@ -42893,14 +42974,14 @@ export {
|
|
|
42893
42974
|
_u as SoundManager,
|
|
42894
42975
|
ew as applyTheme,
|
|
42895
42976
|
Si as darkPresets,
|
|
42896
|
-
|
|
42977
|
+
Tw as darkThemes,
|
|
42897
42978
|
QM as detectSystemTheme,
|
|
42898
|
-
|
|
42899
|
-
|
|
42979
|
+
Sw as getColorPreset,
|
|
42980
|
+
xw as getPresetNames,
|
|
42900
42981
|
Jo as getTheme,
|
|
42901
|
-
|
|
42982
|
+
Ew as getThemeNames,
|
|
42902
42983
|
xi as lightPresets,
|
|
42903
|
-
|
|
42984
|
+
Cw as lightThemes,
|
|
42904
42985
|
da as themes,
|
|
42905
|
-
|
|
42986
|
+
Mw as watchSystemTheme
|
|
42906
42987
|
};
|