@chatwidgetai/chat-widget 0.1.7 → 0.1.8
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/ai-chat-widget.umd.js +268 -39
- package/dist/ai-chat-widget.umd.js.map +1 -1
- package/dist/components/ChatWidget.d.ts.map +1 -1
- package/dist/components/ChatWindow.d.ts +6 -0
- package/dist/components/ChatWindow.d.ts.map +1 -1
- package/dist/hooks/useChat.d.ts +11 -0
- package/dist/hooks/useChat.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +268 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +268 -39
- package/dist/index.js.map +1 -1
- package/dist/utils/storage.d.ts +31 -3
- package/dist/utils/storage.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/utils/storage.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Local Storage Utilities
|
|
3
3
|
* Handles conversation persistence in browser localStorage
|
|
4
|
+
* Supports multiple conversations per widget with history
|
|
4
5
|
*/
|
|
5
6
|
import { ConversationMessage } from '../types';
|
|
6
7
|
export interface StoredConversation {
|
|
@@ -9,18 +10,45 @@ export interface StoredConversation {
|
|
|
9
10
|
messages: ConversationMessage[];
|
|
10
11
|
lastUpdated: string;
|
|
11
12
|
}
|
|
13
|
+
export interface ConversationHistoryEntry {
|
|
14
|
+
id: string;
|
|
15
|
+
preview: string;
|
|
16
|
+
lastUpdated: string;
|
|
17
|
+
messageCount: number;
|
|
18
|
+
}
|
|
19
|
+
export interface WidgetStorage {
|
|
20
|
+
activeConversationId: string | null;
|
|
21
|
+
conversations: Record<string, StoredConversation>;
|
|
22
|
+
history: ConversationHistoryEntry[];
|
|
23
|
+
}
|
|
12
24
|
/**
|
|
13
|
-
* Save conversation to localStorage
|
|
25
|
+
* Save conversation to localStorage (updates both conversation and history)
|
|
14
26
|
*/
|
|
15
27
|
export declare function saveConversation(widgetId: string, conversationId: string, messages: ConversationMessage[]): void;
|
|
16
28
|
/**
|
|
17
|
-
* Load conversation from localStorage
|
|
29
|
+
* Load active conversation from localStorage (legacy compatibility)
|
|
18
30
|
*/
|
|
19
31
|
export declare function loadConversation(widgetId: string): StoredConversation | null;
|
|
20
32
|
/**
|
|
21
|
-
*
|
|
33
|
+
* Load a specific conversation by ID
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadConversationById(widgetId: string, conversationId: string): StoredConversation | null;
|
|
36
|
+
/**
|
|
37
|
+
* Get conversation history list
|
|
38
|
+
*/
|
|
39
|
+
export declare function getConversationHistory(widgetId: string): ConversationHistoryEntry[];
|
|
40
|
+
/**
|
|
41
|
+
* Set active conversation
|
|
42
|
+
*/
|
|
43
|
+
export declare function setActiveConversation(widgetId: string, conversationId: string | null): void;
|
|
44
|
+
/**
|
|
45
|
+
* Clear current conversation (start fresh, but keep history)
|
|
22
46
|
*/
|
|
23
47
|
export declare function clearConversation(widgetId: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clear all conversations for a widget
|
|
50
|
+
*/
|
|
51
|
+
export declare function clearAllConversations(widgetId: string): void;
|
|
24
52
|
/**
|
|
25
53
|
* Check if localStorage is available
|
|
26
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/utils/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAK/C,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBA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