@alliance-droid/chat-widget 0.1.0 → 0.1.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.
|
@@ -46,10 +46,34 @@
|
|
|
46
46
|
return theme;
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
let hasConnected = $state(false);
|
|
50
|
+
|
|
49
51
|
function toggleOpen() {
|
|
50
52
|
isOpen = !isOpen;
|
|
51
53
|
if (isOpen) {
|
|
52
54
|
unreadCount = 0;
|
|
55
|
+
// Connect on first open
|
|
56
|
+
if (!hasConnected) {
|
|
57
|
+
hasConnected = true;
|
|
58
|
+
connect({
|
|
59
|
+
serverUrl,
|
|
60
|
+
apiKey,
|
|
61
|
+
reconnect,
|
|
62
|
+
reconnectInterval,
|
|
63
|
+
userId,
|
|
64
|
+
userMeta
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Add greeting message if provided
|
|
68
|
+
if (greeting) {
|
|
69
|
+
chatStore.addMessage({
|
|
70
|
+
id: 'greeting',
|
|
71
|
+
content: greeting,
|
|
72
|
+
sender: 'system',
|
|
73
|
+
timestamp: Date.now()
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
53
77
|
}
|
|
54
78
|
}
|
|
55
79
|
|
|
@@ -66,24 +90,7 @@
|
|
|
66
90
|
}
|
|
67
91
|
|
|
68
92
|
onMount(() => {
|
|
69
|
-
|
|
70
|
-
serverUrl,
|
|
71
|
-
apiKey,
|
|
72
|
-
reconnect,
|
|
73
|
-
reconnectInterval,
|
|
74
|
-
userId,
|
|
75
|
-
userMeta
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Add greeting message if provided
|
|
79
|
-
if (greeting) {
|
|
80
|
-
chatStore.addMessage({
|
|
81
|
-
id: 'greeting',
|
|
82
|
-
content: greeting,
|
|
83
|
-
sender: 'system',
|
|
84
|
-
timestamp: Date.now()
|
|
85
|
-
});
|
|
86
|
-
}
|
|
93
|
+
// Connection is now deferred until widget is opened
|
|
87
94
|
});
|
|
88
95
|
|
|
89
96
|
onDestroy(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alliance-droid/chat-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Svelte chat widget with AI support and human escalation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"vitest": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@alliance-droid/svelte-component-library": "^0.1.
|
|
54
|
+
"@alliance-droid/svelte-component-library": "^0.1.9",
|
|
55
55
|
"ws": "^8.18.0"
|
|
56
56
|
},
|
|
57
57
|
"keywords": [
|