You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@salesforcedevs/docs-components

Package Overview
Dependencies
Maintainers
17
Versions
795
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforcedevs/docs-components - npm Package Compare versions

Comparing version

to
0.0.33-chat

2

package.json
{
"name": "@salesforcedevs/docs-components",
"version": "0.0.32-chat",
"version": "0.0.33-chat",
"description": "Docs Lightning web components for DSC",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -19,3 +19,3 @@ import { LightningElement, api, track } from "lwc";

@api maxHeight: string = "400px";
@api

@@ -51,3 +51,3 @@ get disabled() {

@track isAssistantTyping: boolean = false;
private _disabled: boolean = false;

@@ -57,6 +57,6 @@ private _showTimestamp: boolean = false;

private messageIdCounter: number = 0;
// localStorage keys for persisting messages and open state
private static readonly STORAGE_KEY = 'doc-chat-messages';
private static readonly OPEN_STATE_KEY = 'doc-chat-should-open';
private static readonly STORAGE_KEY = "doc-chat-messages";
private static readonly OPEN_STATE_KEY = "doc-chat-should-open";

@@ -66,3 +66,3 @@ connectedCallback() {

this.loadMessages();
// Add welcome message only if no existing messages

@@ -72,6 +72,6 @@ if (this.messages.length === 0) {

}
// Check if chat should be opened after reload
this.checkAndOpenAfterReload();
// Ensure body has proper class state

@@ -83,3 +83,3 @@ this.updateBodyClass();

// Clean up body classes when component is destroyed
document.body.classList.remove('chat-open', 'chat-closed');
document.body.classList.remove("chat-open", "chat-closed");
}

@@ -90,4 +90,4 @@

"chat-container",
this.disabled && "chat-container--disabled",
this.isOpen && "chat-container--open"
this.disabled && "chat-container_disabled",
this.isOpen && "chat-container_open"
);

@@ -133,3 +133,4 @@ }

setTimeout(() => {
const messagesContainer = this.template.querySelector('.chat-messages');
const messagesContainer =
this.template.querySelector(".chat-messages");
if (messagesContainer) {

@@ -144,7 +145,7 @@ messagesContainer.scrollTop = messagesContainer.scrollHeight;

if (this.isOpen) {
document.body.classList.remove('chat-closed');
document.body.classList.add('chat-open');
document.body.classList.remove("chat-closed");
document.body.classList.add("chat-open");
} else {
document.body.classList.remove('chat-open');
document.body.classList.add('chat-closed');
document.body.classList.remove("chat-open");
document.body.classList.add("chat-closed");
}

@@ -155,3 +156,3 @@ }

try {
const messagesToSave = this.messages.map(msg => ({
const messagesToSave = this.messages.map((msg) => ({
id: msg.id,

@@ -163,5 +164,8 @@ text: msg.text,

}));
localStorage.setItem(Chat.STORAGE_KEY, JSON.stringify(messagesToSave));
localStorage.setItem(
Chat.STORAGE_KEY,
JSON.stringify(messagesToSave)
);
} catch (error) {
console.warn('Failed to save messages to localStorage:', error);
console.warn("Failed to save messages to localStorage:", error);
}

@@ -182,10 +186,18 @@ }

}));
// Update message counter to avoid ID conflicts
const lastId = this.messages.length > 0 ?
Math.max(...this.messages.map(m => parseInt(m.id.replace('msg-', '')) || 0)) : 0;
const lastId =
this.messages.length > 0
? Math.max(
...this.messages.map(
(m) =>
parseInt(m.id.replace("msg-", ""), 10) ||
0
)
)
: 0;
this.messageIdCounter = lastId + 1;
}
} catch (error) {
console.warn('Failed to load messages from localStorage:', error);
console.warn("Failed to load messages from localStorage:", error);
this.messages = [];

@@ -203,3 +215,3 @@ }

} catch (error) {
console.warn('Failed to clear messages from localStorage:', error);
console.warn("Failed to clear messages from localStorage:", error);
}

@@ -211,16 +223,21 @@ }

const shouldOpen = localStorage.getItem(Chat.OPEN_STATE_KEY);
if (shouldOpen === 'true') {
if (shouldOpen === "true") {
// Clear the flag
localStorage.removeItem(Chat.OPEN_STATE_KEY);
// Open the chat
this.isOpen = true;
this._isOpen = true;
this.updateBodyClass();
// Dispatch custom event to notify parent components
this.dispatchEvent(new CustomEvent('chatopened', {
detail: { opened: true }
}));
this.dispatchEvent(
new CustomEvent("chatopened", {
detail: { opened: true }
})
);
}
} catch (error) {
console.warn('Failed to check open state from localStorage:', error);
console.warn(
"Failed to check open state from localStorage:",
error
);
}

@@ -235,3 +252,3 @@ }

handleKeyDown(event: KeyboardEvent) {
if (event.key === 'Enter' && !event.shiftKey) {
if (event.key === "Enter" && !event.shiftKey) {
event.preventDefault();

@@ -257,3 +274,5 @@ this.sendMessage();

// Clear input
const input = this.template.querySelector('.chat-input') as HTMLInputElement;
const input = this.template.querySelector(
".chat-input"
) as HTMLInputElement;
if (input) {

@@ -265,3 +284,3 @@ input.value = "";

this.isAssistantTyping = true;
// Simulate assistant response after a delay

@@ -277,11 +296,20 @@ setTimeout(() => {

let response = `I received your message: "${userMessage}". `;
if (userMessage.toLowerCase().includes("hello") || userMessage.toLowerCase().includes("hi")) {
if (
userMessage.toLowerCase().includes("hello") ||
userMessage.toLowerCase().includes("hi")
) {
response = "Hello! Nice to meet you. How can I assist you today?";
} else if (userMessage.toLowerCase().includes("help")) {
response = "I'm here to help! Feel free to ask me any questions about the documentation or topics you're interested in.";
} else if (userMessage.toLowerCase().includes("documentation") || userMessage.toLowerCase().includes("docs")) {
response = "I can help you navigate the documentation. What specific topic are you looking for?";
response =
"I'm here to help! Feel free to ask me any questions about the documentation or topics you're interested in.";
} else if (
userMessage.toLowerCase().includes("documentation") ||
userMessage.toLowerCase().includes("docs")
) {
response =
"I can help you navigate the documentation. What specific topic are you looking for?";
} else {
response = "That's an interesting question. Let me help you with that. Could you provide more details about what you're looking for?";
response =
"That's an interesting question. Let me help you with that. Could you provide more details about what you're looking for?";
}

@@ -293,3 +321,6 @@

formatTimestamp(timestamp: Date) {
return timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
return timestamp.toLocaleTimeString([], {
hour: "2-digit",
minute: "2-digit"
});
}

@@ -302,9 +333,11 @@

handleCloseClick() {
this.isOpen = false;
this._isOpen = false;
this.updateBodyClass();
// Dispatch custom event to notify parent components
this.dispatchEvent(new CustomEvent('chatclosed', {
detail: { closed: true }
}));
this.dispatchEvent(
new CustomEvent("chatclosed", {
detail: { closed: true }
})
);
}

@@ -314,7 +347,9 @@

this.clearMessages();
// Dispatch custom event to notify parent components
this.dispatchEvent(new CustomEvent('chatcleared', {
detail: { cleared: true }
}));
this.dispatchEvent(
new CustomEvent("chatcleared", {
detail: { cleared: true }
})
);
}

@@ -325,7 +360,6 @@

// Set flag to open chat after reload
localStorage.setItem(Chat.OPEN_STATE_KEY, 'true');
localStorage.setItem(Chat.OPEN_STATE_KEY, "true");
} catch (error) {
console.warn('Failed to set open state in localStorage:', error);
console.warn("Failed to set open state in localStorage:", error);
}
// Hard reload the page to clear cache when opening chat

@@ -338,7 +372,7 @@ window.location.reload();

// Set flag to open chat after reload
localStorage.setItem(Chat.OPEN_STATE_KEY, 'true');
localStorage.setItem(Chat.OPEN_STATE_KEY, "true");
} catch (error) {
console.warn('Failed to set open state in localStorage:', error);
console.warn("Failed to set open state in localStorage:", error);
}
// Hard reload the page to clear cache when opening chat

@@ -349,10 +383,12 @@ window.location.reload();

closeChat() {
this.isOpen = false;
this._isOpen = false;
this.updateBodyClass();
// Dispatch custom event to notify parent components
this.dispatchEvent(new CustomEvent('chatclosed', {
detail: { closed: true }
}));
this.dispatchEvent(
new CustomEvent("chatclosed", {
detail: { closed: true }
})
);
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet