ajaxter-chat 3.0.8 → 3.0.10
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/components/ChatScreen/index.d.ts +2 -0
- package/dist/components/ChatScreen/index.js +283 -34
- package/dist/components/ChatWidget.js +111 -15
- package/dist/components/HomeScreen/index.d.ts +2 -0
- package/dist/components/HomeScreen/index.js +2 -2
- package/dist/components/Tabs/BottomTabs.d.ts +0 -1
- package/dist/components/Tabs/BottomTabs.js +13 -20
- package/dist/components/TicketDetailScreen/index.d.ts +9 -0
- package/dist/components/TicketDetailScreen/index.js +46 -0
- package/dist/components/TicketFormScreen/index.d.ts +9 -0
- package/dist/components/TicketFormScreen/index.js +76 -0
- package/dist/components/TicketScreen/index.d.ts +2 -1
- package/dist/components/TicketScreen/index.js +8 -35
- package/dist/components/UserListScreen/index.d.ts +4 -0
- package/dist/components/UserListScreen/index.js +21 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/fileName.d.ts +2 -0
- package/dist/utils/fileName.js +7 -0
- package/dist/utils/messageSound.d.ts +4 -0
- package/dist/utils/messageSound.js +51 -0
- package/dist/utils/widgetSession.d.ts +13 -0
- package/dist/utils/widgetSession.js +24 -0
- package/package.json +1 -1
- package/src/components/ChatScreen/index.tsx +415 -58
- package/src/components/ChatWidget.tsx +140 -17
- package/src/components/HomeScreen/index.tsx +4 -2
- package/src/components/Tabs/BottomTabs.tsx +2 -22
- package/src/components/TicketDetailScreen/index.tsx +111 -0
- package/src/components/TicketFormScreen/index.tsx +151 -0
- package/src/components/TicketScreen/index.tsx +18 -58
- package/src/components/UserListScreen/index.tsx +51 -5
- package/src/types/index.ts +4 -0
- package/src/utils/fileName.ts +6 -0
- package/src/utils/messageSound.ts +47 -0
- package/src/utils/widgetSession.ts +34 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export type ChatType = 'SUPPORT' | 'CHAT' | 'BOTH';
|
|
|
55
55
|
export type UserType = 'developer' | 'user';
|
|
56
56
|
export type OnlineStatus = 'online' | 'away' | 'offline';
|
|
57
57
|
export type BottomTab = 'home' | 'chats' | 'tickets';
|
|
58
|
-
export type Screen = 'home' | 'user-list' | 'chat' | 'recent-chats' | 'tickets' | 'block-list' | 'call';
|
|
58
|
+
export type Screen = 'home' | 'user-list' | 'chat' | 'recent-chats' | 'tickets' | 'ticket-new' | 'ticket-detail' | 'block-list' | 'call';
|
|
59
59
|
export type UserListContext = 'support' | 'conversation';
|
|
60
60
|
export type MessageType = 'text' | 'voice' | 'attachment' | 'emoji';
|
|
61
61
|
export interface ChatUser {
|
|
@@ -81,6 +81,8 @@ export interface ChatMessage {
|
|
|
81
81
|
attachmentSize?: string;
|
|
82
82
|
/** Blob URL for attachment download (local send) */
|
|
83
83
|
attachmentUrl?: string;
|
|
84
|
+
/** e.g. image/png — used for inline image preview in bubbles */
|
|
85
|
+
attachmentMime?: string;
|
|
84
86
|
voiceDuration?: number;
|
|
85
87
|
/** Blob URL for in-bubble audio playback (local recording) */
|
|
86
88
|
voiceUrl?: string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Short notification tone for incoming chat messages */
|
|
2
|
+
export declare function playMessageSound(): void;
|
|
3
|
+
export declare function getMessageSoundEnabled(widgetId: string): boolean;
|
|
4
|
+
export declare function setMessageSoundEnabled(widgetId: string, enabled: boolean): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Short notification tone for incoming chat messages */
|
|
2
|
+
export function playMessageSound() {
|
|
3
|
+
try {
|
|
4
|
+
const AC = window.AudioContext || window.webkitAudioContext;
|
|
5
|
+
if (!AC)
|
|
6
|
+
return;
|
|
7
|
+
const ctx = new AC();
|
|
8
|
+
const o = ctx.createOscillator();
|
|
9
|
+
const g = ctx.createGain();
|
|
10
|
+
o.connect(g);
|
|
11
|
+
g.connect(ctx.destination);
|
|
12
|
+
o.type = 'sine';
|
|
13
|
+
o.frequency.value = 880;
|
|
14
|
+
g.gain.value = 0.07;
|
|
15
|
+
o.start();
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
try {
|
|
18
|
+
o.stop();
|
|
19
|
+
void ctx.close();
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
/* ignore */
|
|
23
|
+
}
|
|
24
|
+
}, 100);
|
|
25
|
+
}
|
|
26
|
+
catch (_a) {
|
|
27
|
+
/* ignore */
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const soundPrefKey = (widgetId) => `ajaxter_sound_${widgetId}`;
|
|
31
|
+
export function getMessageSoundEnabled(widgetId) {
|
|
32
|
+
if (typeof window === 'undefined')
|
|
33
|
+
return true;
|
|
34
|
+
try {
|
|
35
|
+
const v = localStorage.getItem(soundPrefKey(widgetId));
|
|
36
|
+
if (v === null)
|
|
37
|
+
return true;
|
|
38
|
+
return v === '1';
|
|
39
|
+
}
|
|
40
|
+
catch (_a) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function setMessageSoundEnabled(widgetId, enabled) {
|
|
45
|
+
try {
|
|
46
|
+
localStorage.setItem(soundPrefKey(widgetId), enabled ? '1' : '0');
|
|
47
|
+
}
|
|
48
|
+
catch (_a) {
|
|
49
|
+
/* ignore */
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Screen, BottomTab, UserListContext, ChatMessage } from '../types';
|
|
2
|
+
export interface PersistedWidgetSession {
|
|
3
|
+
screen: Screen;
|
|
4
|
+
activeTab: BottomTab;
|
|
5
|
+
userListCtx: UserListContext;
|
|
6
|
+
activeUserUid: string | null;
|
|
7
|
+
messages: ChatMessage[];
|
|
8
|
+
viewingTicketId: string | null;
|
|
9
|
+
chatReturnCtx: UserListContext;
|
|
10
|
+
}
|
|
11
|
+
export declare function sessionKey(widgetId: string): string;
|
|
12
|
+
export declare function loadSession(widgetId: string): PersistedWidgetSession | null;
|
|
13
|
+
export declare function saveSession(widgetId: string, state: PersistedWidgetSession): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function sessionKey(widgetId) {
|
|
2
|
+
return `ajaxter_widget_session_${widgetId}`;
|
|
3
|
+
}
|
|
4
|
+
export function loadSession(widgetId) {
|
|
5
|
+
if (typeof window === 'undefined')
|
|
6
|
+
return null;
|
|
7
|
+
try {
|
|
8
|
+
const raw = sessionStorage.getItem(sessionKey(widgetId));
|
|
9
|
+
if (!raw)
|
|
10
|
+
return null;
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
}
|
|
13
|
+
catch (_a) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function saveSession(widgetId, state) {
|
|
18
|
+
try {
|
|
19
|
+
sessionStorage.setItem(sessionKey(widgetId), JSON.stringify(state));
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
/* quota */
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ajaxter-chat",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "Drawer-based chat widget with support chat, tickets, WebRTC calling, voice messages, block list, and transcript download.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|