@w0nna_dev/lina-widget 1.2.1 → 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 +47 -127
- package/dist/lina-widget.umd.js +4 -4
- package/dist/src/orb/core/SoundManager.d.ts +7 -13
- package/package.json +1 -1
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;
|
|
@@ -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,132 +42211,52 @@ 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
|
-
|
|
42214
|
+
const lw = "/sounds/pop-connect.mp3", dw = "/sounds/pop-disconnect.mp3";
|
|
42215
|
+
class uw {
|
|
42215
42216
|
constructor(e = {}) {
|
|
42216
|
-
this.
|
|
42217
|
+
this.connectAudio = null, this.disconnectAudio = null, this.config = {
|
|
42217
42218
|
enabled: !0,
|
|
42218
|
-
volume: 0.
|
|
42219
|
+
volume: 0.5,
|
|
42219
42220
|
...e
|
|
42220
|
-
};
|
|
42221
|
-
}
|
|
42222
|
-
/**
|
|
42223
|
-
* Initialize audio context (must be called from user interaction)
|
|
42224
|
-
*/
|
|
42225
|
-
async ensureContext() {
|
|
42226
|
-
if (!this.config.enabled) return null;
|
|
42227
|
-
if (!this.audioContext)
|
|
42228
|
-
try {
|
|
42229
|
-
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
42230
|
-
} catch {
|
|
42231
|
-
return console.warn("Web Audio API not supported"), null;
|
|
42232
|
-
}
|
|
42233
|
-
return this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioContext;
|
|
42221
|
+
}, this.preloadSounds();
|
|
42234
42222
|
}
|
|
42235
42223
|
/**
|
|
42236
|
-
*
|
|
42224
|
+
* Preload audio files for instant playback
|
|
42237
42225
|
*/
|
|
42238
|
-
|
|
42239
|
-
|
|
42240
|
-
|
|
42241
|
-
|
|
42242
|
-
|
|
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
|
+
}
|
|
42243
42232
|
}
|
|
42244
42233
|
/**
|
|
42245
|
-
* Play
|
|
42246
|
-
* C4 → E4 → G4 (C major chord arpeggio)
|
|
42234
|
+
* Play connect sound
|
|
42247
42235
|
*/
|
|
42248
42236
|
async playCallStartSound() {
|
|
42249
|
-
|
|
42250
|
-
|
|
42251
|
-
|
|
42252
|
-
|
|
42253
|
-
|
|
42254
|
-
|
|
42255
|
-
// C4
|
|
42256
|
-
{ freq: 329.63, start: 0.15, duration: 0.5 },
|
|
42257
|
-
// E4
|
|
42258
|
-
{ freq: 392, start: 0.3, duration: 0.6 },
|
|
42259
|
-
// G4
|
|
42260
|
-
{ freq: 523.25, start: 0.5, duration: 0.8 }
|
|
42261
|
-
// C5 (octave up)
|
|
42262
|
-
], r = [];
|
|
42263
|
-
s.forEach((o) => {
|
|
42264
|
-
const { oscillator: a, gain: c } = this.createTone(
|
|
42265
|
-
e,
|
|
42266
|
-
o.freq,
|
|
42267
|
-
t + o.start,
|
|
42268
|
-
o.duration,
|
|
42269
|
-
"sine"
|
|
42270
|
-
);
|
|
42271
|
-
c.connect(n), a.start(t + o.start), a.stop(t + o.start + o.duration), r.push(a);
|
|
42272
|
-
const { oscillator: l, gain: d } = this.createTone(
|
|
42273
|
-
e,
|
|
42274
|
-
o.freq * 2,
|
|
42275
|
-
// Octave up
|
|
42276
|
-
t + o.start,
|
|
42277
|
-
o.duration,
|
|
42278
|
-
"triangle"
|
|
42279
|
-
);
|
|
42280
|
-
d.gain.setValueAtTime(d.gain.value * 0.3, t), d.connect(n), l.start(t + o.start), l.stop(t + o.start + o.duration), r.push(l);
|
|
42281
|
-
}), setTimeout(() => {
|
|
42282
|
-
r.forEach((o) => {
|
|
42283
|
-
try {
|
|
42284
|
-
o.disconnect();
|
|
42285
|
-
} catch {
|
|
42286
|
-
}
|
|
42287
|
-
});
|
|
42288
|
-
}, 2e3);
|
|
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
|
+
}
|
|
42289
42243
|
}
|
|
42290
42244
|
/**
|
|
42291
|
-
* Play
|
|
42292
|
-
* G4 → E4 → C4 (descending C major arpeggio)
|
|
42245
|
+
* Play disconnect sound
|
|
42293
42246
|
*/
|
|
42294
42247
|
async playCallEndSound() {
|
|
42295
|
-
|
|
42296
|
-
|
|
42297
|
-
|
|
42298
|
-
|
|
42299
|
-
|
|
42300
|
-
|
|
42301
|
-
// C5
|
|
42302
|
-
{ freq: 392, start: 0.12, duration: 0.4 },
|
|
42303
|
-
// G4
|
|
42304
|
-
{ freq: 329.63, start: 0.24, duration: 0.5 },
|
|
42305
|
-
// E4
|
|
42306
|
-
{ freq: 261.63, start: 0.4, duration: 0.7 }
|
|
42307
|
-
// C4
|
|
42308
|
-
], r = [];
|
|
42309
|
-
s.forEach((o) => {
|
|
42310
|
-
const { oscillator: a, gain: c } = this.createTone(
|
|
42311
|
-
e,
|
|
42312
|
-
o.freq,
|
|
42313
|
-
t + o.start,
|
|
42314
|
-
o.duration,
|
|
42315
|
-
"sine"
|
|
42316
|
-
);
|
|
42317
|
-
c.connect(n), a.start(t + o.start), a.stop(t + o.start + o.duration), r.push(a);
|
|
42318
|
-
const { oscillator: l, gain: d } = this.createTone(
|
|
42319
|
-
e,
|
|
42320
|
-
o.freq * 2,
|
|
42321
|
-
t + o.start,
|
|
42322
|
-
o.duration,
|
|
42323
|
-
"triangle"
|
|
42324
|
-
);
|
|
42325
|
-
d.gain.setValueAtTime(d.gain.value * 0.25, t), d.connect(n), l.start(t + o.start), l.stop(t + o.start + o.duration), r.push(l);
|
|
42326
|
-
}), setTimeout(() => {
|
|
42327
|
-
r.forEach((o) => {
|
|
42328
|
-
try {
|
|
42329
|
-
o.disconnect();
|
|
42330
|
-
} catch {
|
|
42331
|
-
}
|
|
42332
|
-
});
|
|
42333
|
-
}, 1500);
|
|
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
|
+
}
|
|
42334
42254
|
}
|
|
42335
42255
|
/**
|
|
42336
42256
|
* Update configuration
|
|
42337
42257
|
*/
|
|
42338
42258
|
setConfig(e) {
|
|
42339
|
-
this.config = { ...this.config, ...e };
|
|
42259
|
+
this.config = { ...this.config, ...e }, this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
|
|
42340
42260
|
}
|
|
42341
42261
|
/**
|
|
42342
42262
|
* Enable or disable sounds
|
|
@@ -42348,7 +42268,7 @@ class lw {
|
|
|
42348
42268
|
* Set volume (0.0 - 1.0)
|
|
42349
42269
|
*/
|
|
42350
42270
|
setVolume(e) {
|
|
42351
|
-
this.config.volume = Math.max(0, Math.min(1, 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);
|
|
42352
42272
|
}
|
|
42353
42273
|
/**
|
|
42354
42274
|
* Get current config
|
|
@@ -42366,17 +42286,17 @@ class lw {
|
|
|
42366
42286
|
* Cleanup
|
|
42367
42287
|
*/
|
|
42368
42288
|
destroy() {
|
|
42369
|
-
this.
|
|
42289
|
+
this.connectAudio = null, this.disconnectAudio = null;
|
|
42370
42290
|
}
|
|
42371
42291
|
}
|
|
42372
|
-
var
|
|
42373
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
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--)
|
|
42374
42294
|
(o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
|
|
42375
|
-
return n && s &&
|
|
42295
|
+
return n && s && hw(e, t, s), s;
|
|
42376
42296
|
};
|
|
42377
42297
|
let Ft = class extends es {
|
|
42378
42298
|
constructor() {
|
|
42379
|
-
super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.soundManager = new
|
|
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 () => {
|
|
42380
42300
|
if (this.callStatus === "mic-denied")
|
|
42381
42301
|
try {
|
|
42382
42302
|
(await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), this._hasMicPermission = !0, this.callStatus = "idle";
|
|
@@ -43054,14 +42974,14 @@ export {
|
|
|
43054
42974
|
_u as SoundManager,
|
|
43055
42975
|
ew as applyTheme,
|
|
43056
42976
|
Si as darkPresets,
|
|
43057
|
-
|
|
42977
|
+
Tw as darkThemes,
|
|
43058
42978
|
QM as detectSystemTheme,
|
|
43059
|
-
|
|
43060
|
-
|
|
42979
|
+
Sw as getColorPreset,
|
|
42980
|
+
xw as getPresetNames,
|
|
43061
42981
|
Jo as getTheme,
|
|
43062
|
-
|
|
42982
|
+
Ew as getThemeNames,
|
|
43063
42983
|
xi as lightPresets,
|
|
43064
|
-
|
|
42984
|
+
Cw as lightThemes,
|
|
43065
42985
|
da as themes,
|
|
43066
|
-
|
|
42986
|
+
Mw as watchSystemTheme
|
|
43067
42987
|
};
|