ajaxter-chat 3.0.17 → 3.2.0
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/BlockList/index.d.ts +1 -0
- package/dist/components/BlockList/index.d.ts.map +1 -0
- package/dist/components/BlockList/index.js +55 -28
- package/dist/components/BlockList/index.js.map +1 -0
- package/dist/components/CallScreen/index.d.ts +1 -0
- package/dist/components/CallScreen/index.d.ts.map +1 -0
- package/dist/components/CallScreen/index.js +107 -39
- package/dist/components/CallScreen/index.js.map +1 -0
- package/dist/components/ChatScreen/index.d.ts +1 -0
- package/dist/components/ChatScreen/index.d.ts.map +1 -0
- package/dist/components/ChatScreen/index.js +493 -294
- package/dist/components/ChatScreen/index.js.map +1 -0
- package/dist/components/ChatWidget.d.ts +1 -0
- package/dist/components/ChatWidget.d.ts.map +1 -0
- package/dist/components/ChatWidget.js +499 -367
- package/dist/components/ChatWidget.js.map +1 -0
- package/dist/components/EmojiPicker/index.d.ts +1 -0
- package/dist/components/EmojiPicker/index.d.ts.map +1 -0
- package/dist/components/EmojiPicker/index.js +19 -7
- package/dist/components/EmojiPicker/index.js.map +1 -0
- package/dist/components/ErrorBoundary/index.d.ts +20 -0
- package/dist/components/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/components/ErrorBoundary/index.js +76 -0
- package/dist/components/ErrorBoundary/index.js.map +1 -0
- package/dist/components/HomeScreen/index.d.ts +1 -0
- package/dist/components/HomeScreen/index.d.ts.map +1 -0
- package/dist/components/HomeScreen/index.js +236 -158
- package/dist/components/HomeScreen/index.js.map +1 -0
- package/dist/components/MaintenanceView/index.d.ts +1 -0
- package/dist/components/MaintenanceView/index.d.ts.map +1 -0
- package/dist/components/MaintenanceView/index.js +28 -12
- package/dist/components/MaintenanceView/index.js.map +1 -0
- package/dist/components/MiniCallBar/index.d.ts +1 -0
- package/dist/components/MiniCallBar/index.d.ts.map +1 -0
- package/dist/components/MiniCallBar/index.js +85 -37
- package/dist/components/MiniCallBar/index.js.map +1 -0
- package/dist/components/PermissionsGateScreen/index.d.ts +1 -0
- package/dist/components/PermissionsGateScreen/index.d.ts.map +1 -0
- package/dist/components/PermissionsGateScreen/index.js +82 -28
- package/dist/components/PermissionsGateScreen/index.js.map +1 -0
- package/dist/components/RecentChatsScreen/index.d.ts +1 -0
- package/dist/components/RecentChatsScreen/index.d.ts.map +1 -0
- package/dist/components/RecentChatsScreen/index.js +79 -19
- package/dist/components/RecentChatsScreen/index.js.map +1 -0
- package/dist/components/SlideNavMenu.d.ts +1 -0
- package/dist/components/SlideNavMenu.d.ts.map +1 -0
- package/dist/components/SlideNavMenu.js +82 -63
- package/dist/components/SlideNavMenu.js.map +1 -0
- package/dist/components/Tabs/BottomTabs.d.ts +1 -0
- package/dist/components/Tabs/BottomTabs.d.ts.map +1 -0
- package/dist/components/Tabs/BottomTabs.js +34 -19
- package/dist/components/Tabs/BottomTabs.js.map +1 -0
- package/dist/components/TicketDetailScreen/index.d.ts +1 -0
- package/dist/components/TicketDetailScreen/index.d.ts.map +1 -0
- package/dist/components/TicketDetailScreen/index.js +66 -27
- package/dist/components/TicketDetailScreen/index.js.map +1 -0
- package/dist/components/TicketFormScreen/index.d.ts +1 -0
- package/dist/components/TicketFormScreen/index.d.ts.map +1 -0
- package/dist/components/TicketFormScreen/index.js +99 -49
- package/dist/components/TicketFormScreen/index.js.map +1 -0
- package/dist/components/TicketScreen/index.d.ts +1 -0
- package/dist/components/TicketScreen/index.d.ts.map +1 -0
- package/dist/components/TicketScreen/index.js +95 -26
- package/dist/components/TicketScreen/index.js.map +1 -0
- package/dist/components/UserListScreen/index.d.ts +1 -0
- package/dist/components/UserListScreen/index.d.ts.map +1 -0
- package/dist/components/UserListScreen/index.js +127 -53
- package/dist/components/UserListScreen/index.js.map +1 -0
- package/dist/components/ViewerBlockedScreen/index.d.ts +1 -0
- package/dist/components/ViewerBlockedScreen/index.d.ts.map +1 -0
- package/dist/components/ViewerBlockedScreen/index.js +113 -61
- package/dist/components/ViewerBlockedScreen/index.js.map +1 -0
- package/dist/config/index.d.ts +7 -3
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +73 -22
- package/dist/config/index.js.map +1 -0
- package/dist/hooks/useChat.d.ts +9 -1
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useChat.js +60 -18
- package/dist/hooks/useChat.js.map +1 -0
- package/dist/hooks/useRemoteConfig.d.ts +1 -0
- package/dist/hooks/useRemoteConfig.d.ts.map +1 -0
- package/dist/hooks/useRemoteConfig.js +22 -15
- package/dist/hooks/useRemoteConfig.js.map +1 -0
- package/dist/hooks/useSocket.d.ts +59 -0
- package/dist/hooks/useSocket.d.ts.map +1 -0
- package/dist/hooks/useSocket.js +203 -0
- package/dist/hooks/useSocket.js.map +1 -0
- package/dist/hooks/useWebRTC.d.ts +10 -2
- package/dist/hooks/useWebRTC.d.ts.map +1 -0
- package/dist/hooks/useWebRTC.js +101 -69
- package/dist/hooks/useWebRTC.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -21
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +129 -48
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -1
- package/dist/types/index.js.map +1 -0
- package/dist/utils/chat.d.ts +1 -0
- package/dist/utils/chat.d.ts.map +1 -0
- package/dist/utils/chat.js +17 -7
- package/dist/utils/chat.js.map +1 -0
- package/dist/utils/fileName.d.ts +1 -0
- package/dist/utils/fileName.d.ts.map +1 -0
- package/dist/utils/fileName.js +5 -1
- package/dist/utils/fileName.js.map +1 -0
- package/dist/utils/messageSound.d.ts +1 -0
- package/dist/utils/messageSound.d.ts.map +1 -0
- package/dist/utils/messageSound.js +9 -3
- package/dist/utils/messageSound.js.map +1 -0
- package/dist/utils/presenceStatus.d.ts +1 -0
- package/dist/utils/presenceStatus.d.ts.map +1 -0
- package/dist/utils/presenceStatus.js +11 -4
- package/dist/utils/presenceStatus.js.map +1 -0
- package/dist/utils/privacyConsent.d.ts +1 -0
- package/dist/utils/privacyConsent.d.ts.map +1 -0
- package/dist/utils/privacyConsent.js +9 -3
- package/dist/utils/privacyConsent.js.map +1 -0
- package/dist/utils/reenableRequest.d.ts +1 -0
- package/dist/utils/reenableRequest.d.ts.map +1 -0
- package/dist/utils/reenableRequest.js +5 -1
- package/dist/utils/reenableRequest.js.map +1 -0
- package/dist/utils/theme.d.ts +1 -0
- package/dist/utils/theme.d.ts.map +1 -0
- package/dist/utils/theme.js +10 -4
- package/dist/utils/theme.js.map +1 -0
- package/dist/utils/widgetPermissions.d.ts +1 -0
- package/dist/utils/widgetPermissions.d.ts.map +1 -0
- package/dist/utils/widgetPermissions.js +13 -5
- package/dist/utils/widgetPermissions.js.map +1 -0
- package/dist/utils/widgetSession.d.ts +1 -0
- package/dist/utils/widgetSession.d.ts.map +1 -0
- package/dist/utils/widgetSession.js +9 -3
- package/dist/utils/widgetSession.js.map +1 -0
- package/package.json +8 -4
- package/src/components/ChatWidget.tsx +643 -622
- package/src/components/ErrorBoundary/index.tsx +62 -0
- package/src/config/index.ts +87 -26
- package/src/hooks/useChat.ts +59 -12
- package/src/hooks/useRemoteConfig.ts +8 -3
- package/src/hooks/useSocket.ts +249 -0
- package/src/hooks/useWebRTC.ts +99 -64
- package/src/index.ts +14 -3
- package/src/types/index.ts +177 -143
|
@@ -1,13 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.ViewerBlockedScreen = void 0;
|
|
38
|
+
const react_1 = __importStar(require("react"));
|
|
39
|
+
const reenableRequest_1 = require("../../utils/reenableRequest");
|
|
5
40
|
const DEFAULT_MESSAGE = 'You have been marked as Blocked user due to spam';
|
|
6
|
-
|
|
41
|
+
const ViewerBlockedScreen = ({ config, apiKey, onClose }) => {
|
|
7
42
|
var _a, _b;
|
|
8
|
-
const [text, setText] = useState('');
|
|
9
|
-
const [status, setStatus] = useState('idle');
|
|
10
|
-
const [error, setError] = useState(null);
|
|
43
|
+
const [text, setText] = (0, react_1.useState)('');
|
|
44
|
+
const [status, setStatus] = (0, react_1.useState)('idle');
|
|
45
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
11
46
|
const primary = config.primaryColor;
|
|
12
47
|
const body = (((_a = config.blockedViewerMessage) === null || _a === void 0 ? void 0 : _a.trim()) || DEFAULT_MESSAGE);
|
|
13
48
|
const url = (_b = config.reenableRequestUrl) === null || _b === void 0 ? void 0 : _b.trim();
|
|
@@ -26,7 +61,7 @@ export const ViewerBlockedScreen = ({ config, apiKey, onClose }) => {
|
|
|
26
61
|
setError(null);
|
|
27
62
|
setStatus('sending');
|
|
28
63
|
try {
|
|
29
|
-
await submitReenableRequest(url, {
|
|
64
|
+
await (0, reenableRequest_1.submitReenableRequest)(url, {
|
|
30
65
|
widgetId: config.id,
|
|
31
66
|
apiKey,
|
|
32
67
|
viewerUid: ((_a = config.viewerUid) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
|
|
@@ -40,7 +75,7 @@ export const ViewerBlockedScreen = ({ config, apiKey, onClose }) => {
|
|
|
40
75
|
setError(e instanceof Error ? e.message : 'Request failed');
|
|
41
76
|
}
|
|
42
77
|
};
|
|
43
|
-
return (
|
|
78
|
+
return (react_1.default.createElement("div", { className: "cw-scroll", style: {
|
|
44
79
|
flex: 1,
|
|
45
80
|
display: 'flex',
|
|
46
81
|
flexDirection: 'column',
|
|
@@ -50,58 +85,75 @@ export const ViewerBlockedScreen = ({ config, apiKey, onClose }) => {
|
|
|
50
85
|
textAlign: 'center',
|
|
51
86
|
overflowY: 'auto',
|
|
52
87
|
minHeight: 0,
|
|
53
|
-
}
|
|
54
|
-
|
|
88
|
+
} },
|
|
89
|
+
react_1.default.createElement("div", { style: { maxWidth: 380, width: '100%' } },
|
|
90
|
+
react_1.default.createElement("div", { style: { fontSize: 44, marginBottom: 16 } }, "\uD83D\uDEAB"),
|
|
91
|
+
react_1.default.createElement("p", { style: {
|
|
92
|
+
margin: '0 0 28px',
|
|
93
|
+
fontSize: 15,
|
|
94
|
+
fontWeight: 600,
|
|
95
|
+
color: '#1e293b',
|
|
96
|
+
lineHeight: 1.55,
|
|
97
|
+
} }, body),
|
|
98
|
+
status === 'sent' ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
99
|
+
react_1.default.createElement("p", { style: { margin: '0 0 16px', fontSize: 14, color: '#16a34a', fontWeight: 600 } }, "Your request was sent. We will review it shortly."),
|
|
100
|
+
react_1.default.createElement("button", { type: "button", onClick: onClose, style: {
|
|
101
|
+
width: '100%',
|
|
102
|
+
padding: '12px 16px',
|
|
103
|
+
borderRadius: 12,
|
|
104
|
+
border: '2px solid #ef4444',
|
|
105
|
+
background: '#fff',
|
|
106
|
+
color: '#ef4444',
|
|
107
|
+
fontWeight: 700,
|
|
55
108
|
fontSize: 15,
|
|
56
|
-
|
|
109
|
+
cursor: 'pointer',
|
|
110
|
+
fontFamily: 'inherit',
|
|
111
|
+
} }, "Close"))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
112
|
+
react_1.default.createElement("label", { htmlFor: "cw-reenable-msg", style: { display: 'block', textAlign: 'left', fontSize: 13, fontWeight: 600, color: '#475569', marginBottom: 8 } }, "Request access restoration"),
|
|
113
|
+
react_1.default.createElement("textarea", { id: "cw-reenable-msg", value: text, onChange: e => { setText(e.target.value); setError(null); setStatus('idle'); }, placeholder: "Explain briefly why your access should be restored\u2026", rows: 4, maxLength: 500, minLength: 50, disabled: status === 'sending', style: {
|
|
114
|
+
width: '100%',
|
|
115
|
+
boxSizing: 'border-box',
|
|
116
|
+
padding: '12px 14px',
|
|
117
|
+
borderRadius: 12,
|
|
118
|
+
border: '1.5px solid #e2e8f0',
|
|
119
|
+
fontSize: 14,
|
|
120
|
+
fontFamily: 'inherit',
|
|
57
121
|
color: '#1e293b',
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
cursor: text.trim() && status !== 'sending' ? 'pointer' : 'default',
|
|
94
|
-
}, children: status === 'sending' ? 'Sending…' : 'Submit request' }), _jsx("button", { type: "button", onClick: onClose, style: {
|
|
95
|
-
width: '100%',
|
|
96
|
-
marginTop: 12,
|
|
97
|
-
padding: '12px 16px',
|
|
98
|
-
borderRadius: 12,
|
|
99
|
-
border: '2px solid #ef4444',
|
|
100
|
-
background: '#fff',
|
|
101
|
-
color: '#ef4444',
|
|
102
|
-
fontWeight: 700,
|
|
103
|
-
fontSize: 15,
|
|
104
|
-
cursor: 'pointer',
|
|
105
|
-
fontFamily: 'inherit',
|
|
106
|
-
}, children: "Close" }), error && (_jsx("p", { style: { margin: '12px 0 0', fontSize: 13, color: '#dc2626', lineHeight: 1.45 }, children: error })), !url && (_jsxs("p", { style: { margin: '14px 0 0', fontSize: 12, color: '#94a3b8', lineHeight: 1.5 }, children: ["Your administrator must set ", _jsx("code", { style: { fontSize: 11 }, children: "reenableRequestUrl" }), " in widget config for online requests."] }))] }))] }) }));
|
|
122
|
+
resize: 'none',
|
|
123
|
+
minHeight: 100,
|
|
124
|
+
maxHeight: 250,
|
|
125
|
+
marginBottom: 14,
|
|
126
|
+
outline: 'none',
|
|
127
|
+
} }),
|
|
128
|
+
react_1.default.createElement("button", { type: "button", onClick: handleSubmit, disabled: status === 'sending' || !text.trim(), style: {
|
|
129
|
+
width: '100%',
|
|
130
|
+
padding: '12px 16px',
|
|
131
|
+
borderRadius: 12,
|
|
132
|
+
border: 'none',
|
|
133
|
+
background: text.trim() && status !== 'sending' ? primary : '#e2e8f0',
|
|
134
|
+
color: text.trim() && status !== 'sending' ? '#fff' : '#94a3b8',
|
|
135
|
+
fontWeight: 700,
|
|
136
|
+
fontSize: 15,
|
|
137
|
+
cursor: text.trim() && status !== 'sending' ? 'pointer' : 'default',
|
|
138
|
+
} }, status === 'sending' ? 'Sending…' : 'Submit request'),
|
|
139
|
+
react_1.default.createElement("button", { type: "button", onClick: onClose, style: {
|
|
140
|
+
width: '100%',
|
|
141
|
+
marginTop: 12,
|
|
142
|
+
padding: '12px 16px',
|
|
143
|
+
borderRadius: 12,
|
|
144
|
+
border: '2px solid #ef4444',
|
|
145
|
+
background: '#fff',
|
|
146
|
+
color: '#ef4444',
|
|
147
|
+
fontWeight: 700,
|
|
148
|
+
fontSize: 15,
|
|
149
|
+
cursor: 'pointer',
|
|
150
|
+
fontFamily: 'inherit',
|
|
151
|
+
} }, "Close"),
|
|
152
|
+
error && (react_1.default.createElement("p", { style: { margin: '12px 0 0', fontSize: 13, color: '#dc2626', lineHeight: 1.45 } }, error)),
|
|
153
|
+
!url && (react_1.default.createElement("p", { style: { margin: '14px 0 0', fontSize: 12, color: '#94a3b8', lineHeight: 1.5 } },
|
|
154
|
+
"Your administrator must set ",
|
|
155
|
+
react_1.default.createElement("code", { style: { fontSize: 11 } }, "reenableRequestUrl"),
|
|
156
|
+
" in widget config for online requests.")))))));
|
|
107
157
|
};
|
|
158
|
+
exports.ViewerBlockedScreen = ViewerBlockedScreen;
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ViewerBlockedScreen/index.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,+CAAwC;AAExC,iEAAoE;AAEpE,MAAM,eAAe,GACnB,kDAAkD,CAAC;AAQ9C,MAAM,mBAAmB,GAAuC,CAAC,EAAE,MAAM,EAAE,MAAM,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EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE;;oBACnD,wCAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,yBAA2B;6DAClF,CACL,CACA,CACJ,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AA/KW,QAAA,mBAAmB,uBA+K9B"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { LocalEnvConfig, RemoteChatData } from '../types';
|
|
2
|
+
export declare function loadLocalConfig(): LocalEnvConfig;
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
4
|
+
* Fetches widget config ONCE from the server.
|
|
5
|
+
* URL: GET /api/chat-config?key=<apiKey>&widget=<widgetId>
|
|
6
|
+
*
|
|
7
|
+
* Returns RemoteChatData (the shape the widget components expect),
|
|
8
|
+
* translated from the Ajaxter server response format.
|
|
5
9
|
*/
|
|
6
10
|
export declare function fetchRemoteChatData(apiKey: string, widgetId: string): Promise<RemoteChatData>;
|
|
7
|
-
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAuC,MAAM,UAAU,CAAC;AAmB/F,wBAAgB,eAAe,IAAI,cAAc,CAMhD;AAMD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CA2EzB"}
|
package/dist/config/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadLocalConfig = loadLocalConfig;
|
|
4
|
+
exports.fetchRemoteChatData = fetchRemoteChatData;
|
|
5
|
+
const DEFAULT_SOCKET_URL = 'http://localhost:3005';
|
|
6
|
+
const DEFAULT_CONFIG_URL = 'http://localhost:5000/api/chat-config';
|
|
7
7
|
const DEMO_API_KEY = 'demo1234';
|
|
8
8
|
const DEMO_WIDGET_ID = 'demo';
|
|
9
9
|
function getEnv(key) {
|
|
@@ -13,33 +13,84 @@ function getEnv(key) {
|
|
|
13
13
|
}
|
|
14
14
|
return undefined;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
var _a;
|
|
18
|
-
return
|
|
16
|
+
function loadLocalConfig() {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
return {
|
|
19
|
+
apiKey: (_a = getEnv('CHAT_API_KEY')) !== null && _a !== void 0 ? _a : DEMO_API_KEY,
|
|
20
|
+
widgetId: (_b = getEnv('CHAT_WIDGET_ID')) !== null && _b !== void 0 ? _b : DEMO_WIDGET_ID,
|
|
21
|
+
socketUrl: (_c = getEnv('SOCKET_URL')) !== null && _c !== void 0 ? _c : DEFAULT_SOCKET_URL,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function getConfigUrl() {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
return (_b = (_a = getEnv('CHAT_CONFIG_URL')) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : DEFAULT_CONFIG_URL;
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
29
|
+
* Fetches widget config ONCE from the server.
|
|
30
|
+
* URL: GET /api/chat-config?key=<apiKey>&widget=<widgetId>
|
|
31
|
+
*
|
|
32
|
+
* Returns RemoteChatData (the shape the widget components expect),
|
|
33
|
+
* translated from the Ajaxter server response format.
|
|
23
34
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
35
|
+
async function fetchRemoteChatData(apiKey, widgetId) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
37
|
+
const base = getConfigUrl();
|
|
38
|
+
const url = new URL(base, typeof window !== 'undefined' ? window.location.origin : 'http://localhost');
|
|
27
39
|
url.searchParams.set('key', apiKey);
|
|
28
40
|
url.searchParams.set('widget', widgetId);
|
|
29
41
|
const res = await fetch(url.toString(), {
|
|
30
42
|
method: 'GET',
|
|
43
|
+
headers: { Accept: 'application/json' },
|
|
31
44
|
credentials: 'omit',
|
|
32
45
|
mode: 'cors',
|
|
33
|
-
headers: { Accept: 'application/json' },
|
|
34
46
|
});
|
|
35
47
|
if (!res.ok)
|
|
36
|
-
throw new Error(`
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
throw new Error(`Chat config fetch failed: ${res.status}`);
|
|
49
|
+
const json = await res.json();
|
|
50
|
+
if (!json.ok || !json.data) {
|
|
51
|
+
throw new Error('Invalid config response from server');
|
|
52
|
+
}
|
|
53
|
+
const { data } = json;
|
|
54
|
+
const internal = data._internal;
|
|
55
|
+
const ws = data.widget;
|
|
56
|
+
// Map Ajaxter server response → WidgetConfig used by components
|
|
57
|
+
const widgetConfig = {
|
|
58
|
+
id: internal.id,
|
|
59
|
+
apiKey: internal.apiKey,
|
|
60
|
+
status: internal.status,
|
|
61
|
+
chatType: internal.chatType,
|
|
62
|
+
displayMode: internal.displayMode,
|
|
63
|
+
primaryColor: internal.primaryColor,
|
|
64
|
+
buttonLabel: internal.buttonLabel,
|
|
65
|
+
// Button position from visibility config
|
|
66
|
+
buttonPosition: (((_b = (_a = ws.visibility) === null || _a === void 0 ? void 0 : _a.mobile) === null || _b === void 0 ? void 0 : _b.position) === 'bottom-left'
|
|
67
|
+
? 'bottom-left'
|
|
68
|
+
: 'bottom-right'),
|
|
69
|
+
// Welcome text from states.online header
|
|
70
|
+
welcomeTitle: (_e = (_d = (_c = data.branding) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : internal.brandName) !== null && _e !== void 0 ? _e : 'Hello there 👋',
|
|
71
|
+
welcomeSubtitle: (_l = (_k = (_j = (_h = (_g = (_f = ws.states) === null || _f === void 0 ? void 0 : _f.online) === null || _g === void 0 ? void 0 : _g.header) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 'How can we help you today?',
|
|
72
|
+
brandName: (_m = internal.brandName) !== null && _m !== void 0 ? _m : undefined,
|
|
73
|
+
supportPhone: (_o = internal.supportPhone) !== null && _o !== void 0 ? _o : undefined,
|
|
74
|
+
privacyPolicyUrl: (_p = internal.privacyPolicyUrl) !== null && _p !== void 0 ? _p : undefined,
|
|
75
|
+
showPrivacyNotice: internal.showPrivacyNotice,
|
|
76
|
+
allowVoiceMessage: internal.allowVoiceMessage,
|
|
77
|
+
allowAttachment: internal.allowAttachment,
|
|
78
|
+
allowEmoji: internal.allowEmoji,
|
|
79
|
+
allowWebCall: internal.allowWebCall,
|
|
80
|
+
maxEmojiCount: internal.maxEmojiCount,
|
|
81
|
+
allowTranscriptDownload: internal.allowTranscript,
|
|
82
|
+
allowReport: internal.allowReport,
|
|
83
|
+
allowBlock: internal.allowBlock,
|
|
84
|
+
// Full Ajaxter settings stored for display-mode rendering
|
|
85
|
+
ajaxterSettings: ws,
|
|
86
|
+
};
|
|
41
87
|
return {
|
|
42
|
-
|
|
43
|
-
|
|
88
|
+
widget: widgetConfig,
|
|
89
|
+
developers: (_q = data.developers) !== null && _q !== void 0 ? _q : [],
|
|
90
|
+
users: (_r = data.users) !== null && _r !== void 0 ? _r : [],
|
|
91
|
+
sampleChats: (_s = data.sampleChats) !== null && _s !== void 0 ? _s : {},
|
|
92
|
+
sampleTickets: (_t = data.sampleTickets) !== null && _t !== void 0 ? _t : [],
|
|
93
|
+
blockedUsers: (_u = data.blockedUsers) !== null && _u !== void 0 ? _u : [],
|
|
44
94
|
};
|
|
45
95
|
}
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;AAmBA,0CAMC;AAaD,kDA8EC;AAlHD,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AACnD,MAAM,kBAAkB,GAAG,uCAAuC,CAAC;AACnE,MAAM,YAAY,GAAS,UAAU,CAAC;AACtC,MAAM,cAAc,GAAO,MAAM,CAAC;AAElC,SAAS,MAAM,CAAC,GAAW;;IACzB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAClD,OAAO,CACL,MAAA,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,EAAE,CAAC,mCACjC,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,EAAE,CAAC,mCAC/B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,mCAChB,SAAS,CACV,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,eAAe;;IAC7B,OAAO;QACL,MAAM,EAAK,MAAA,MAAM,CAAC,cAAc,CAAC,mCAAO,YAAY;QACpD,QAAQ,EAAG,MAAA,MAAM,CAAC,gBAAgB,CAAC,mCAAI,cAAc;QACrD,SAAS,EAAE,MAAA,MAAM,CAAC,YAAY,CAAC,mCAAQ,kBAAkB;KAC1D,CAAC;AACJ,CAAC;AAED,SAAS,YAAY;;IACnB,OAAO,MAAA,MAAA,MAAM,CAAC,iBAAiB,CAAC,0CAAE,IAAI,EAAE,mCAAI,kBAAkB,CAAC;AACjE,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAc,EACd,QAAgB;;IAEhB,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,MAAM,GAAG,GAAI,IAAI,GAAG,CAClB,I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AI,CAAC,WAAW,mCAAK,EAAE;QACrC,aAAa,EAAE,MAAA,IAAI,CAAC,aAAa,mCAAI,EAAE;QACvC,YAAY,EAAE,MAAA,IAAI,CAAC,YAAY,mCAAI,EAAE;KACtC,CAAC;AACJ,CAAC"}
|
package/dist/hooks/useChat.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { ChatMessage, ChatUser } from '../types';
|
|
2
|
-
export
|
|
2
|
+
export interface UseChatOptions {
|
|
3
|
+
onEmitMessage?: (msg: ChatMessage) => void;
|
|
4
|
+
onEmitPause?: (roomId: string, targetUid: string, paused: boolean) => void;
|
|
5
|
+
onEmitReport?: (roomId: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function useChat(initialMessages?: ChatMessage[], opts?: UseChatOptions): {
|
|
3
8
|
messages: ChatMessage[];
|
|
4
9
|
activeUser: ChatUser | null;
|
|
5
10
|
isPaused: boolean;
|
|
6
11
|
isReported: boolean;
|
|
7
12
|
selectUser: (user: ChatUser, history?: ChatMessage[]) => void;
|
|
8
13
|
sendMessage: (text: string, type?: ChatMessage["type"], extra?: Partial<ChatMessage>) => void;
|
|
14
|
+
receiveMessage: (msg: ChatMessage) => void;
|
|
15
|
+
updateMessageStatus: (messageId: string, status: ChatMessage["status"]) => void;
|
|
9
16
|
togglePause: () => void;
|
|
10
17
|
reportChat: () => void;
|
|
11
18
|
clearChat: () => void;
|
|
12
19
|
setMessages: import("react").Dispatch<import("react").SetStateAction<ChatMessage[]>>;
|
|
13
20
|
};
|
|
21
|
+
//# sourceMappingURL=useChat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useChat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,WAAW,cAAc;IAC7B,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3E,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,wBAAgB,OAAO,CAAC,eAAe,GAAE,WAAW,EAAO,EAAE,IAAI,GAAE,cAAmB;;;;;uBAU9C,QAAQ,YAAW,WAAW,EAAE;wBAU9D,MAAM,SACN,WAAW,CAAC,MAAM,CAAC,UAClB,OAAO,CAAC,WAAW,CAAC;0BAkBY,WAAW;qCAOA,MAAM,UAAU,WAAW,CAAC,QAAQ,CAAC;;;;;EAsC1F"}
|
package/dist/hooks/useChat.js
CHANGED
|
@@ -1,30 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const [
|
|
7
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useChat = useChat;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useChat(initialMessages = [], opts = {}) {
|
|
6
|
+
const [messages, setMessages] = (0, react_1.useState)(initialMessages);
|
|
7
|
+
const [activeUser, setActiveUser] = (0, react_1.useState)(null);
|
|
8
|
+
const [isPaused, setIsPaused] = (0, react_1.useState)(false);
|
|
9
|
+
const [isReported, setIsReported] = (0, react_1.useState)(false);
|
|
10
|
+
const activeUserRef = (0, react_1.useRef)(null);
|
|
11
|
+
const isPausedRef = (0, react_1.useRef)(false);
|
|
12
|
+
const { onEmitMessage, onEmitPause, onEmitReport } = opts;
|
|
13
|
+
const selectUser = (0, react_1.useCallback)((user, history = []) => {
|
|
8
14
|
setActiveUser(user);
|
|
15
|
+
activeUserRef.current = user;
|
|
9
16
|
setMessages(history);
|
|
10
17
|
setIsPaused(false);
|
|
18
|
+
isPausedRef.current = false;
|
|
11
19
|
setIsReported(false);
|
|
12
|
-
// TODO: socket.emit('join', { roomId: user.uid });
|
|
13
|
-
// TODO: socket.on('message', msg => setMessages(prev => [...prev, msg]));
|
|
14
20
|
}, []);
|
|
15
|
-
const sendMessage = useCallback((text, type = 'text', extra = {}) => {
|
|
16
|
-
|
|
21
|
+
const sendMessage = (0, react_1.useCallback)((text, type = 'text', extra = {}) => {
|
|
22
|
+
const user = activeUserRef.current;
|
|
23
|
+
if (!user || isPausedRef.current)
|
|
17
24
|
return;
|
|
18
|
-
const msg = Object.assign({ id: `msg_${Date.now()}_${Math.random().toString(36).slice(2)}`, senderId: 'me', receiverId:
|
|
25
|
+
const msg = Object.assign({ id: `msg_${Date.now()}_${Math.random().toString(36).slice(2)}`, senderId: 'me', receiverId: user.uid, text, timestamp: new Date().toISOString(), type, status: 'sent' }, extra);
|
|
19
26
|
setMessages(prev => [...prev, msg]);
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
onEmitMessage === null || onEmitMessage === void 0 ? void 0 : onEmitMessage(msg);
|
|
28
|
+
}, [onEmitMessage]);
|
|
29
|
+
const receiveMessage = (0, react_1.useCallback)((msg) => {
|
|
30
|
+
setMessages(prev => {
|
|
31
|
+
if (prev.some(m => m.id === msg.id))
|
|
32
|
+
return prev;
|
|
33
|
+
return [...prev, msg];
|
|
34
|
+
});
|
|
35
|
+
}, []);
|
|
36
|
+
const updateMessageStatus = (0, react_1.useCallback)((messageId, status) => {
|
|
37
|
+
setMessages(prev => prev.map(m => m.id === messageId ? Object.assign(Object.assign({}, m), { status }) : m));
|
|
38
|
+
}, []);
|
|
39
|
+
const togglePause = (0, react_1.useCallback)(() => {
|
|
40
|
+
const user = activeUserRef.current;
|
|
41
|
+
if (!user)
|
|
42
|
+
return;
|
|
43
|
+
const next = !isPausedRef.current;
|
|
44
|
+
setIsPaused(next);
|
|
45
|
+
isPausedRef.current = next;
|
|
46
|
+
const roomId = [user.uid, 'me'].sort().join('_');
|
|
47
|
+
onEmitPause === null || onEmitPause === void 0 ? void 0 : onEmitPause(roomId, user.uid, next);
|
|
48
|
+
}, [onEmitPause]);
|
|
49
|
+
const reportChat = (0, react_1.useCallback)(() => {
|
|
50
|
+
const user = activeUserRef.current;
|
|
51
|
+
setIsReported(true);
|
|
52
|
+
if (user) {
|
|
53
|
+
const roomId = [user.uid, 'me'].sort().join('_');
|
|
54
|
+
onEmitReport === null || onEmitReport === void 0 ? void 0 : onEmitReport(roomId);
|
|
55
|
+
}
|
|
56
|
+
}, [onEmitReport]);
|
|
57
|
+
const clearChat = (0, react_1.useCallback)(() => {
|
|
58
|
+
setMessages([]);
|
|
59
|
+
setActiveUser(null);
|
|
60
|
+
activeUserRef.current = null;
|
|
61
|
+
setIsPaused(false);
|
|
62
|
+
isPausedRef.current = false;
|
|
63
|
+
setIsReported(false);
|
|
64
|
+
}, []);
|
|
25
65
|
return {
|
|
26
66
|
messages, activeUser, isPaused, isReported,
|
|
27
|
-
selectUser, sendMessage,
|
|
67
|
+
selectUser, sendMessage, receiveMessage, updateMessageStatus,
|
|
68
|
+
togglePause, reportChat, clearChat,
|
|
28
69
|
setMessages,
|
|
29
70
|
};
|
|
30
71
|
}
|
|
72
|
+
//# sourceMappingURL=useChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChat.js","sourceRoot":"","sources":["../../src/hooks/useChat.ts"],"names":[],"mappings":";;AASA,0BAqFC;AA9FD,iCAAsD;AAStD,SAAgB,OAAO,CAAC,kBAAiC,EAAE,EAAE,OAAuB,EAAE;IACpF,MAAM,CAAC,QAAQ,EAAI,WAAW,CAAC,GAAK,IAAA,gBAAQ,EAAgB,eAAe,CAAC,CAAC;IAC7E,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAkB,IAAI,CAAC,CAAC;IACpE,MAAM,CAAC,QAAQ,EAAI,WAAW,CAAC,GAAK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ACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;EA0B/D"}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRemoteConfig = useRemoteConfig;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
function useRemoteConfig(apiKey, widgetId) {
|
|
7
|
+
const [data, setData] = (0, react_1.useState)(null);
|
|
8
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
9
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!apiKey || !widgetId)
|
|
12
|
+
return;
|
|
8
13
|
let cancelled = false;
|
|
9
14
|
setLoading(true);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
setError(null);
|
|
16
|
+
(0, config_1.fetchRemoteChatData)(apiKey, widgetId)
|
|
17
|
+
.then(d => {
|
|
18
|
+
if (!cancelled) {
|
|
19
|
+
setData(d);
|
|
20
|
+
setLoading(false);
|
|
21
|
+
}
|
|
22
|
+
})
|
|
16
23
|
.catch(e => {
|
|
17
24
|
if (!cancelled) {
|
|
18
|
-
|
|
19
|
-
setError(msg || 'Network error while loading configuration');
|
|
25
|
+
setError(e instanceof Error ? e.message : 'Failed to load config');
|
|
20
26
|
setLoading(false);
|
|
21
27
|
}
|
|
22
28
|
});
|
|
@@ -24,3 +30,4 @@ export function useRemoteConfig(apiKey, widgetId) {
|
|
|
24
30
|
}, [apiKey, widgetId]);
|
|
25
31
|
return { data, loading, error };
|
|
26
32
|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SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ChatMessage } from '../types';
|
|
2
|
+
export type SocketStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
3
|
+
export interface SocketMessageAck {
|
|
4
|
+
messageId: string;
|
|
5
|
+
status: 'delivered' | 'read';
|
|
6
|
+
}
|
|
7
|
+
export interface UseSocketOptions {
|
|
8
|
+
widgetId: string;
|
|
9
|
+
viewerUid: string;
|
|
10
|
+
/** Socket.IO server URL — defaults to http://localhost:3005 */
|
|
11
|
+
serverUrl?: string;
|
|
12
|
+
onMessage?: (msg: ChatMessage) => void;
|
|
13
|
+
onMessageAck?: (ack: SocketMessageAck) => void;
|
|
14
|
+
onChatPaused?: (roomId: string, paused: boolean) => void;
|
|
15
|
+
onCallOffer?: (offer: RTCSessionDescriptionInit, fromUid: string, callId: string) => void;
|
|
16
|
+
onCallAnswer?: (answer: RTCSessionDescriptionInit, fromUid: string, callId: string) => void;
|
|
17
|
+
onIceCandidate?: (candidate: RTCIceCandidateInit, fromUid: string) => void;
|
|
18
|
+
onCallEnd?: (callId: string) => void;
|
|
19
|
+
onTypingStart?: (roomId: string, userId: string) => void;
|
|
20
|
+
onTypingStop?: (roomId: string, userId: string) => void;
|
|
21
|
+
onUserStatus?: (uid: string, status: 'online' | 'away' | 'offline') => void;
|
|
22
|
+
onTicketCreated?: (ticket: unknown) => void;
|
|
23
|
+
onTicketUpdated?: (ticket: unknown) => void;
|
|
24
|
+
onTransferAssigned?: (payload: unknown) => void;
|
|
25
|
+
onError?: (code: string, message: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function useSocket(opts: UseSocketOptions): {
|
|
28
|
+
status: SocketStatus;
|
|
29
|
+
joinRoom: (roomId: string) => void;
|
|
30
|
+
leaveRoom: (roomId: string) => void;
|
|
31
|
+
emitMessage: (msg: ChatMessage) => void;
|
|
32
|
+
emitTypingStart: (roomId: string) => void;
|
|
33
|
+
emitTypingStop: (roomId: string) => void;
|
|
34
|
+
emitMessageRead: (roomId: string, messageId: string) => void;
|
|
35
|
+
emitPauseToggle: (roomId: string, targetUserId: string, paused: boolean) => void;
|
|
36
|
+
emitReport: (roomId: string, reason?: string) => void;
|
|
37
|
+
emitBlock: (blockedUid: string) => void;
|
|
38
|
+
emitUnblock: (blockedUid: string) => void;
|
|
39
|
+
emitTransfer: (fromRoomId: string, toUserId: string, note?: string) => void;
|
|
40
|
+
emitAddParticipant: (roomId: string, uid: string) => void;
|
|
41
|
+
emitCallOffer: (offer: RTCSessionDescriptionInit, toUid: string, callId: string, hasVideo?: boolean) => void;
|
|
42
|
+
emitCallAnswer: (answer: RTCSessionDescriptionInit, toUid: string, callId: string) => void;
|
|
43
|
+
emitIceCandidate: (candidate: RTCIceCandidateInit, toUid: string) => void;
|
|
44
|
+
emitCallEnd: (callId: string, toUid?: string) => void;
|
|
45
|
+
emitPresence: (presenceStatus: "ACTIVE" | "AWAY" | "DND") => void;
|
|
46
|
+
emitTicketCreate: (payload: {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
priority: string;
|
|
50
|
+
createdBy?: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
emitTicketUpdate: (payload: {
|
|
53
|
+
ticketId: string;
|
|
54
|
+
status?: string;
|
|
55
|
+
priority?: string;
|
|
56
|
+
assignedTo?: string;
|
|
57
|
+
}) => void;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=useSocket.d.ts.map
|