@myned-ai/avatar-chat-widget 0.8.0 → 0.10.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.
|
@@ -5423,6 +5423,21 @@ class DrawerController {
|
|
|
5423
5423
|
log$3.debug("DrawerController destroyed");
|
|
5424
5424
|
}
|
|
5425
5425
|
}
|
|
5426
|
+
function getAvatarGifUrl() {
|
|
5427
|
+
const scripts = document.getElementsByTagName("script");
|
|
5428
|
+
for (let i = 0; i < scripts.length; i++) {
|
|
5429
|
+
const src = scripts[i].src;
|
|
5430
|
+
if (src.includes("jsdelivr.net") && src.includes("avatar-chat-widget")) {
|
|
5431
|
+
const baseUrl = src.substring(0, src.lastIndexOf("/"));
|
|
5432
|
+
return `${baseUrl}/avatar-chat-widget/public/asset/avatar.gif`;
|
|
5433
|
+
}
|
|
5434
|
+
if (src.includes("unpkg.com") && src.includes("avatar-chat-widget")) {
|
|
5435
|
+
const baseUrl = src.substring(0, src.lastIndexOf("/"));
|
|
5436
|
+
return `${baseUrl}/avatar-chat-widget/public/asset/avatar.gif`;
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
return "./asset/avatar.gif";
|
|
5440
|
+
}
|
|
5426
5441
|
const WIDGET_TEMPLATE = `
|
|
5427
5442
|
<div class="widget-root" data-drawer-state="avatar-focus">
|
|
5428
5443
|
<!-- Header (fixed height, always visible) -->
|
|
@@ -5532,7 +5547,9 @@ const WIDGET_TEMPLATE = `
|
|
|
5532
5547
|
</div>
|
|
5533
5548
|
</div>
|
|
5534
5549
|
`;
|
|
5535
|
-
|
|
5550
|
+
function getBubbleTemplate() {
|
|
5551
|
+
const avatarGifUrl = getAvatarGifUrl();
|
|
5552
|
+
return `
|
|
5536
5553
|
<div class="bubble-container">
|
|
5537
5554
|
<div class="bubble-tooltip-wrapper">
|
|
5538
5555
|
<div class="bubble-tooltip" id="bubbleTooltip">
|
|
@@ -5542,7 +5559,7 @@ const BUBBLE_TEMPLATE = `
|
|
|
5542
5559
|
</div>
|
|
5543
5560
|
<div class="chat-bubble" id="chatBubble" role="button" aria-label="Open chat" tabindex="0">
|
|
5544
5561
|
<div class="bubble-avatar-preview">
|
|
5545
|
-
<img src="
|
|
5562
|
+
<img src="${avatarGifUrl}" class="avatar-face-img" alt="Nyx Avatar" onerror="this.style.display='none';this.nextElementSibling.style.display='flex';" />
|
|
5546
5563
|
<div class="avatar-fallback-icon" style="display:none;">
|
|
5547
5564
|
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
|
5548
5565
|
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
|
|
@@ -5554,6 +5571,7 @@ const BUBBLE_TEMPLATE = `
|
|
|
5554
5571
|
</div>
|
|
5555
5572
|
</div>
|
|
5556
5573
|
`;
|
|
5574
|
+
}
|
|
5557
5575
|
const DEFAULT_CONFIG$1 = {
|
|
5558
5576
|
position: "bottom-right",
|
|
5559
5577
|
startCollapsed: true,
|
|
@@ -5622,7 +5640,8 @@ class AvatarChatElement extends HTMLElement {
|
|
|
5622
5640
|
};
|
|
5623
5641
|
logger.setLevel(logLevels[this.config.logLevel || "error"]);
|
|
5624
5642
|
setConfig({
|
|
5625
|
-
websocket: { url: this.config.serverUrl }
|
|
5643
|
+
websocket: { url: this.config.serverUrl },
|
|
5644
|
+
auth: { enabled: this.config.authEnabled ?? false }
|
|
5626
5645
|
});
|
|
5627
5646
|
}
|
|
5628
5647
|
/**
|
|
@@ -5690,7 +5709,7 @@ class AvatarChatElement extends HTMLElement {
|
|
|
5690
5709
|
this.shadow.innerHTML = "";
|
|
5691
5710
|
if (style) this.shadow.appendChild(style);
|
|
5692
5711
|
const container = document.createElement("div");
|
|
5693
|
-
container.innerHTML =
|
|
5712
|
+
container.innerHTML = getBubbleTemplate();
|
|
5694
5713
|
const wrapper = container.firstElementChild;
|
|
5695
5714
|
if (!wrapper) {
|
|
5696
5715
|
log$2.error("Failed to create bubble wrapper from template");
|