urasoft-live-support 1.1.17 → 1.1.19
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/core/ChatWidget.d.ts +5 -0
- package/dist/core/ChatWidget.d.ts.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.esm.js +85 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +85 -37
- package/dist/index.js.map +1 -1
- package/dist/styles.css +23 -0
- package/package.json +1 -1
|
@@ -10,6 +10,8 @@ export declare class ChatWidget {
|
|
|
10
10
|
private resizeObserver;
|
|
11
11
|
private typingDebounceTimer;
|
|
12
12
|
private typingDisplayTimer;
|
|
13
|
+
private _isLoading;
|
|
14
|
+
private _isSending;
|
|
13
15
|
constructor(config?: ChatConfig);
|
|
14
16
|
private init;
|
|
15
17
|
private createContainer;
|
|
@@ -26,6 +28,7 @@ export declare class ChatWidget {
|
|
|
26
28
|
private attachEventListeners;
|
|
27
29
|
private connectSignalR;
|
|
28
30
|
private disconnectSignalR;
|
|
31
|
+
private setSendingState;
|
|
29
32
|
private sendMessage;
|
|
30
33
|
private sendMessageViaHttp;
|
|
31
34
|
private addMessage;
|
|
@@ -34,6 +37,8 @@ export declare class ChatWidget {
|
|
|
34
37
|
open(): void;
|
|
35
38
|
close(): void;
|
|
36
39
|
destroy(): Promise<void>;
|
|
40
|
+
showLoading(): void;
|
|
41
|
+
hideLoading(): void;
|
|
37
42
|
addChatMessage(message: string, sender: 'agent' | 'user', avatar?: string): void;
|
|
38
43
|
private showAgentTyping;
|
|
39
44
|
private clearAgentTyping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWidget.d.ts","sourceRoot":"","sources":["../../src/core/ChatWidget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkE,MAAM,UAAU,CAAC;AAKtG,qBAAa,UAAU;IACnB,OAAO,CAAC,MAAM,CAcZ;IACF,OAAO,CAAC,KAAK,C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;YAgCT,WAAW;YAmEX,kBAAkB;IAuEhC,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,MAAM;IAKP,IAAI,IAAI,IAAI;IAMZ,KAAK,IAAI,IAAI;IAKP,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,WAAW,IAAI,IAAI;IAcnB,WAAW,IAAI,IAAI;IAYnB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAYvF,OAAO,CAAC,eAAe;IAmCvB,OAAO,CAAC,gBAAgB;YAeV,mBAAmB;IA0DjC,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,UAAU;YAIJ,gBAAgB;IA2D9B,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,iBAAiB;IAgCzB,OAAO,CAAC,cAAc;YAQR,eAAe;YAwCf,iBAAiB;IAqB/B,OAAO,CAAC,kBAAkB,CAWzB;CACJ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -139,6 +139,8 @@ declare class ChatWidget {
|
|
|
139
139
|
private resizeObserver;
|
|
140
140
|
private typingDebounceTimer;
|
|
141
141
|
private typingDisplayTimer;
|
|
142
|
+
private _isLoading;
|
|
143
|
+
private _isSending;
|
|
142
144
|
constructor(config?: ChatConfig);
|
|
143
145
|
private init;
|
|
144
146
|
private createContainer;
|
|
@@ -155,6 +157,7 @@ declare class ChatWidget {
|
|
|
155
157
|
private attachEventListeners;
|
|
156
158
|
private connectSignalR;
|
|
157
159
|
private disconnectSignalR;
|
|
160
|
+
private setSendingState;
|
|
158
161
|
private sendMessage;
|
|
159
162
|
private sendMessageViaHttp;
|
|
160
163
|
private addMessage;
|
|
@@ -163,6 +166,8 @@ declare class ChatWidget {
|
|
|
163
166
|
open(): void;
|
|
164
167
|
close(): void;
|
|
165
168
|
destroy(): Promise<void>;
|
|
169
|
+
showLoading(): void;
|
|
170
|
+
hideLoading(): void;
|
|
166
171
|
addChatMessage(message: string, sender: 'agent' | 'user', avatar?: string): void;
|
|
167
172
|
private showAgentTyping;
|
|
168
173
|
private clearAgentTyping;
|
package/dist/index.esm.js
CHANGED
|
@@ -3678,6 +3678,8 @@ class ChatWidget {
|
|
|
3678
3678
|
this.resizeObserver = null;
|
|
3679
3679
|
this.typingDebounceTimer = null;
|
|
3680
3680
|
this.typingDisplayTimer = null;
|
|
3681
|
+
this._isLoading = false;
|
|
3682
|
+
this._isSending = false;
|
|
3681
3683
|
this.handleOutsideClick = (event) => {
|
|
3682
3684
|
const pickerContainer = document.getElementById('chat-emoji-picker-container');
|
|
3683
3685
|
const emojiButton = document.getElementById('chat-emoji-button');
|
|
@@ -4152,11 +4154,42 @@ class ChatWidget {
|
|
|
4152
4154
|
this.render();
|
|
4153
4155
|
}
|
|
4154
4156
|
}
|
|
4157
|
+
setSendingState(sending) {
|
|
4158
|
+
this._isSending = sending;
|
|
4159
|
+
const sendButton = document.getElementById('chat-send-button');
|
|
4160
|
+
const input = document.getElementById('chat-input');
|
|
4161
|
+
const disconnectButton = document.getElementById('chat-disconnect-button');
|
|
4162
|
+
if (sendButton) {
|
|
4163
|
+
if (sending) {
|
|
4164
|
+
sendButton.setAttribute('disabled', 'true');
|
|
4165
|
+
sendButton.innerHTML = '<span class="chat-send-spinner"></span>';
|
|
4166
|
+
}
|
|
4167
|
+
else {
|
|
4168
|
+
sendButton.removeAttribute('disabled');
|
|
4169
|
+
sendButton.innerHTML = '➤';
|
|
4170
|
+
}
|
|
4171
|
+
}
|
|
4172
|
+
if (input) {
|
|
4173
|
+
input.disabled = sending;
|
|
4174
|
+
}
|
|
4175
|
+
if (disconnectButton) {
|
|
4176
|
+
if (sending) {
|
|
4177
|
+
disconnectButton.setAttribute('disabled', 'true');
|
|
4178
|
+
disconnectButton.classList.add('chat-button-disabled');
|
|
4179
|
+
}
|
|
4180
|
+
else {
|
|
4181
|
+
disconnectButton.removeAttribute('disabled');
|
|
4182
|
+
disconnectButton.classList.remove('chat-button-disabled');
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4155
4186
|
async sendMessage() {
|
|
4156
4187
|
const input = document.getElementById('chat-input');
|
|
4157
4188
|
const message = input?.value.trim();
|
|
4158
4189
|
if (!message && this.state.selectedFiles.length === 0)
|
|
4159
4190
|
return;
|
|
4191
|
+
if (this._isSending)
|
|
4192
|
+
return;
|
|
4160
4193
|
// Eğer SignalR varsa ve HTTP yoksa, bağlantı kontrolü yap
|
|
4161
4194
|
if (this.config.signalR && !this.config.http && !this.state.isConnected)
|
|
4162
4195
|
return;
|
|
@@ -4176,49 +4209,41 @@ class ChatWidget {
|
|
|
4176
4209
|
filePreview.remove();
|
|
4177
4210
|
}
|
|
4178
4211
|
}
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
// HTTP
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4212
|
+
this.setSendingState(true);
|
|
4213
|
+
try {
|
|
4214
|
+
// HTTP endpoint ile gönder (öncelikli)
|
|
4215
|
+
if (this.config.http) {
|
|
4216
|
+
// HTTP + SignalR kombinasyonunda mesajı ekleme, SignalR'dan gelecektir
|
|
4217
|
+
// Sadece HTTP kullanılıyorsa (SignalR yoksa) mesajı hemen ekle
|
|
4218
|
+
if (!this.config.signalR) {
|
|
4219
|
+
this.addMessage(chatMessage);
|
|
4220
|
+
}
|
|
4187
4221
|
await this.sendMessageViaHttp(message, chatMessage.attachments);
|
|
4188
4222
|
}
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
id: Date.now().toString(),
|
|
4193
|
-
message: 'Mesaj gönderilemedi. Lütfen bağlantınızı kontrol edin.',
|
|
4194
|
-
sender: 'agent',
|
|
4195
|
-
timestamp: new Date(),
|
|
4196
|
-
avatar: this.config.agentAvatar,
|
|
4197
|
-
});
|
|
4198
|
-
}
|
|
4199
|
-
}
|
|
4200
|
-
// SignalR ile gönder (HTTP yoksa)
|
|
4201
|
-
else if (this.signalRClient && this.state.isConnected) {
|
|
4202
|
-
// SignalR kullanılıyorsa mesajı ekleme, SignalR'dan gelince eklenecek
|
|
4203
|
-
try {
|
|
4223
|
+
// SignalR ile gönder (HTTP yoksa)
|
|
4224
|
+
else if (this.signalRClient && this.state.isConnected) {
|
|
4225
|
+
// SignalR kullanılıyorsa mesajı ekleme, SignalR'dan gelince eklenecek
|
|
4204
4226
|
await this.signalRClient.send(message);
|
|
4205
4227
|
}
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
sender: 'agent',
|
|
4212
|
-
timestamp: new Date(),
|
|
4213
|
-
avatar: this.config.agentAvatar,
|
|
4214
|
-
});
|
|
4228
|
+
// Fallback: onSendMessage callback
|
|
4229
|
+
else if (this.config.onSendMessage) {
|
|
4230
|
+
// Callback kullanılıyorsa mesajı ekle
|
|
4231
|
+
this.addMessage(chatMessage);
|
|
4232
|
+
this.config.onSendMessage(message, chatMessage.attachments);
|
|
4215
4233
|
}
|
|
4216
4234
|
}
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4235
|
+
catch (error) {
|
|
4236
|
+
console.error('Message send failed:', error);
|
|
4237
|
+
this.addMessage({
|
|
4238
|
+
id: Date.now().toString(),
|
|
4239
|
+
message: 'Mesaj gönderilemedi. Lütfen bağlantınızı kontrol edin.',
|
|
4240
|
+
sender: 'agent',
|
|
4241
|
+
timestamp: new Date(),
|
|
4242
|
+
avatar: this.config.agentAvatar,
|
|
4243
|
+
});
|
|
4244
|
+
}
|
|
4245
|
+
finally {
|
|
4246
|
+
this.setSendingState(false);
|
|
4222
4247
|
}
|
|
4223
4248
|
}
|
|
4224
4249
|
async sendMessageViaHttp(message, attachments) {
|
|
@@ -4286,6 +4311,8 @@ class ChatWidget {
|
|
|
4286
4311
|
}
|
|
4287
4312
|
addMessage(message) {
|
|
4288
4313
|
this.state.messages.push(message);
|
|
4314
|
+
if (this._isLoading)
|
|
4315
|
+
return;
|
|
4289
4316
|
// Mesaj container'ı varsa direkt DOM'a ekle (tüm widget'ı render etmek yerine)
|
|
4290
4317
|
const messagesContainer = document.getElementById('chat-messages');
|
|
4291
4318
|
if (messagesContainer && this.state.isConnected) {
|
|
@@ -4330,6 +4357,27 @@ class ChatWidget {
|
|
|
4330
4357
|
}
|
|
4331
4358
|
this.container?.remove();
|
|
4332
4359
|
}
|
|
4360
|
+
showLoading() {
|
|
4361
|
+
this._isLoading = true;
|
|
4362
|
+
this.state.messages = [];
|
|
4363
|
+
const messagesContainer = document.getElementById('chat-messages');
|
|
4364
|
+
if (messagesContainer) {
|
|
4365
|
+
messagesContainer.innerHTML = `
|
|
4366
|
+
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:12px;">
|
|
4367
|
+
<div class="chat-typing-indicator"><span></span><span></span><span></span></div>
|
|
4368
|
+
</div>
|
|
4369
|
+
`;
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
hideLoading() {
|
|
4373
|
+
this._isLoading = false;
|
|
4374
|
+
const messagesContainer = document.getElementById('chat-messages');
|
|
4375
|
+
if (messagesContainer) {
|
|
4376
|
+
messagesContainer.innerHTML = this.state.messages
|
|
4377
|
+
.map((msg) => this.renderMessage(msg)).join('');
|
|
4378
|
+
this.scrollToBottom();
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4333
4381
|
// Public method to add messages programmatically (for SignalR integration)
|
|
4334
4382
|
addChatMessage(message, sender, avatar) {
|
|
4335
4383
|
this.addMessage({
|