@daeryun/dr_components 0.8.20 → 0.8.21

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.
Files changed (30) hide show
  1. package/dist/components/Daeryuntalk/ChatConversation.jsx +25 -23
  2. package/dist/components/Daeryuntalk/ChatConversation.tsx +24 -27
  3. package/dist/components/Daeryuntalk/ChatHomeView.d.ts +1 -0
  4. package/dist/components/Daeryuntalk/ChatHomeView.jsx +8 -7
  5. package/dist/components/Daeryuntalk/ChatHomeView.tsx +18 -6
  6. package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -4
  7. package/dist/components/Daeryuntalk/ChatMessage.tsx +1 -3
  8. package/dist/components/Daeryuntalk/ChatWidget.jsx +2 -2
  9. package/dist/components/Daeryuntalk/ChatWidget.tsx +7 -2
  10. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +2 -1
  11. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +3 -1
  12. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +6 -2
  13. package/dist/components/Daeryuntalk/NavigationFooter.d.ts +3 -0
  14. package/dist/components/Daeryuntalk/NavigationFooter.jsx +9 -2
  15. package/dist/components/Daeryuntalk/NavigationFooter.tsx +24 -2
  16. package/dist/components/Daeryuntalk/_enums/socket_type.js +2 -2
  17. package/dist/components/Daeryuntalk/_enums/socket_type.ts +2 -2
  18. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +2 -5
  19. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +2 -4
  20. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -1
  21. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +18 -13
  22. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +24 -16
  23. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +2 -1
  24. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +15 -2
  25. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +18 -2
  26. package/dist/components/Daeryuntalk/index.jsx +1 -1
  27. package/dist/components/Daeryuntalk/index.tsx +1 -1
  28. package/dist/styles/globals.css +8 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +1 -1
@@ -1,22 +1,27 @@
1
1
  import { useEffect } from 'react';
2
- export const useChatSocketState = (chatInquiryNumber, viewState, sendHeartbeat, sendInquiryLeft) => {
2
+ export const useChatSocketState = (chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryJoined, sendHeartbeat, sendInquiryLeft) => {
3
+ // 1. 공통 하트비트 (항상 실행)
3
4
  useEffect(() => {
4
- if (!chatInquiryNumber) {
5
+ sendHeartbeat();
6
+ const heartbeatInterval = setInterval(() => {
7
+ sendHeartbeat();
8
+ }, 5000);
9
+ return () => clearInterval(heartbeatInterval);
10
+ }, [sendHeartbeat]);
11
+ // 2. 뷰 상태에 따른 watch / leave
12
+ useEffect(() => {
13
+ if (!chatInquiryNumber)
5
14
  return;
6
- }
7
15
  if (viewState === 'conversation') {
8
- // 점유 하트비트 실행
9
- sendHeartbeat(chatInquiryNumber);
10
- const interval = setInterval(() => {
11
- sendHeartbeat(chatInquiryNumber);
16
+ sendInquiryJoined(chatInquiryNumber);
17
+ sendInquiryWatching(chatInquiryNumber);
18
+ const watchingInterval = setInterval(() => {
19
+ sendInquiryWatching(chatInquiryNumber);
12
20
  }, 5000);
13
- return () => clearInterval(interval);
21
+ return () => clearInterval(watchingInterval);
14
22
  }
15
- // 접속 채팅이 있다면 떠나감 처리
16
23
  else {
17
- if (chatInquiryNumber) {
18
- sendInquiryLeft(chatInquiryNumber);
19
- }
24
+ sendInquiryLeft(chatInquiryNumber);
20
25
  }
21
- }, [chatInquiryNumber, viewState, sendHeartbeat]);
26
+ }, [chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryLeft]);
22
27
  };
@@ -3,28 +3,36 @@ import { useEffect } from 'react';
3
3
  export const useChatSocketState = (
4
4
  chatInquiryNumber: string | null,
5
5
  viewState: 'home' | 'conversation' | 'history',
6
- sendHeartbeat: (chatInquiryNumber: string) => void,
6
+ sendInquiryWatching: (chatInquiryNumber: string) => void,
7
+ sendInquiryJoined: (chatInquiryNumber: string) => void,
8
+ sendHeartbeat: () => void,
7
9
  sendInquiryLeft: (chatInquiryNumber: string) => void
8
10
  ) => {
11
+ // 1. 공통 하트비트 (항상 실행)
9
12
  useEffect(() => {
10
- if (!chatInquiryNumber) {
11
- return;
12
- }
13
+ sendHeartbeat();
14
+ const heartbeatInterval = setInterval(() => {
15
+ sendHeartbeat();
16
+ }, 5000);
17
+
18
+ return () => clearInterval(heartbeatInterval);
19
+ }, [sendHeartbeat]);
20
+
21
+ // 2. 뷰 상태에 따른 watch / leave
22
+ useEffect(() => {
23
+ if (!chatInquiryNumber) return;
13
24
 
14
25
  if (viewState === 'conversation') {
15
- // 점유 하트비트 실행
16
- sendHeartbeat(chatInquiryNumber);
26
+ sendInquiryJoined(chatInquiryNumber);
27
+ sendInquiryWatching(chatInquiryNumber);
17
28
 
18
- const interval = setInterval(() => {
19
- sendHeartbeat(chatInquiryNumber);
29
+ const watchingInterval = setInterval(() => {
30
+ sendInquiryWatching(chatInquiryNumber);
20
31
  }, 5000);
21
- return () => clearInterval(interval);
22
- }
23
- // 접속 채팅이 있다면 떠나감 처리
24
- else {
25
- if (chatInquiryNumber) {
26
- sendInquiryLeft(chatInquiryNumber);
27
- }
32
+
33
+ return () => clearInterval(watchingInterval);
34
+ } else {
35
+ sendInquiryLeft(chatInquiryNumber);
28
36
  }
29
- }, [chatInquiryNumber, viewState, sendHeartbeat]);
37
+ }, [chatInquiryNumber, viewState, sendInquiryWatching, sendInquiryLeft]);
30
38
  };
@@ -16,10 +16,11 @@ interface props {
16
16
  }
17
17
  export declare const useSocketEventHandler: ({ setIsConnected, setIsLoading, setMessages, setInquiryMainData, socketRef, setWorkFlowStack, setMessageObject, setInquiryStatus, setHistoryList, historyList }: props) => {
18
18
  initializeDaeryuntalk: (hashValue: string | null, version?: string) => Promise<void>;
19
- sendHeartbeat: (chatInquiryNumber: string) => void;
19
+ sendHeartbeat: () => void;
20
20
  sendInquiryJoined: (chatInquiryNumber: string) => void;
21
21
  sendInquiryLeft: (chatInquiryNumber: string) => void;
22
22
  sendHistoryEntered: (chatInquiryNumbers: string[]) => void;
23
23
  sendHistoryLeft: (chatInquiryNumbers: string[]) => void;
24
+ sendInquiryWatching: (chatInquiryNumber: string) => void;
24
25
  };
25
26
  export {};
@@ -27,11 +27,21 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
27
27
  * }
28
28
  * }
29
29
  */
30
- const sendHeartbeat = useCallback((chatInquiryNumber) => {
30
+ const sendHeartbeat = useCallback(() => {
31
31
  const socket = socketRef.current;
32
32
  if (socket && socket.readyState === WebSocket.OPEN) {
33
33
  socket.send(JSON.stringify({
34
34
  type: 'heartbeat',
35
+ payload: {}
36
+ }));
37
+ console.log('[WebSocket] heartbeat 전송');
38
+ }
39
+ }, []);
40
+ const sendInquiryWatching = useCallback((chatInquiryNumber) => {
41
+ const socket = socketRef.current;
42
+ if (socket && socket.readyState === WebSocket.OPEN) {
43
+ socket.send(JSON.stringify({
44
+ type: 'inquiry.watching',
35
45
  payload: { chat_inquiry_number: chatInquiryNumber }
36
46
  }));
37
47
  console.log('[WebSocket] heartbeat 전송');
@@ -205,8 +215,10 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
205
215
  console.error('[DaeryuntalkContext] 웹소켓 메시지 처리 오류:', error);
206
216
  }
207
217
  });
218
+ console.log('hashValue', hashValue);
208
219
  if (hashValue) {
209
220
  if (((_a = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _a === void 0 ? void 0 : _a.result_cd) === 'OK' || ((_b = hashAuth === null || hashAuth === void 0 ? void 0 : hashAuth.result_info) === null || _b === void 0 ? void 0 : _b.result_type_cd) === 'OK') {
221
+ console.log('해쉬 인증 완료');
210
222
  }
211
223
  else {
212
224
  toast.error('인증에 실패했습니다.');
@@ -234,6 +246,7 @@ export const useSocketEventHandler = ({ setIsConnected, setIsLoading, setMessage
234
246
  sendInquiryJoined,
235
247
  sendInquiryLeft,
236
248
  sendHistoryEntered,
237
- sendHistoryLeft
249
+ sendHistoryLeft,
250
+ sendInquiryWatching
238
251
  };
239
252
  };
@@ -47,12 +47,25 @@ export const useSocketEventHandler = ({
47
47
  * }
48
48
  * }
49
49
  */
50
- const sendHeartbeat = useCallback((chatInquiryNumber: string) => {
50
+ const sendHeartbeat = useCallback(() => {
51
51
  const socket = socketRef.current;
52
52
  if (socket && socket.readyState === WebSocket.OPEN) {
53
53
  socket.send(
54
54
  JSON.stringify({
55
55
  type: 'heartbeat',
56
+ payload: {}
57
+ })
58
+ );
59
+ console.log('[WebSocket] heartbeat 전송');
60
+ }
61
+ }, []);
62
+
63
+ const sendInquiryWatching = useCallback((chatInquiryNumber: string) => {
64
+ const socket = socketRef.current;
65
+ if (socket && socket.readyState === WebSocket.OPEN) {
66
+ socket.send(
67
+ JSON.stringify({
68
+ type: 'inquiry.watching',
56
69
  payload: { chat_inquiry_number: chatInquiryNumber }
57
70
  })
58
71
  );
@@ -266,8 +279,10 @@ export const useSocketEventHandler = ({
266
279
  }
267
280
  }
268
281
  );
282
+ console.log('hashValue', hashValue);
269
283
  if (hashValue) {
270
284
  if (hashAuth?.result_info?.result_cd === 'OK' || hashAuth?.result_info?.result_type_cd === 'OK') {
285
+ console.log('해쉬 인증 완료');
271
286
  } else {
272
287
  toast.error('인증에 실패했습니다.');
273
288
  window.location.hash = '/';
@@ -296,6 +311,7 @@ export const useSocketEventHandler = ({
296
311
  sendInquiryJoined,
297
312
  sendInquiryLeft,
298
313
  sendHistoryEntered,
299
- sendHistoryLeft
314
+ sendHistoryLeft,
315
+ sendInquiryWatching
300
316
  };
301
317
  };
@@ -33,7 +33,7 @@ const Daeryuntalk = ({ tel = '1800-7905' }) => {
33
33
  }
34
34
  }
35
35
  }, []);
36
- return (<div className={`border-4`}>
36
+ return (<div className={``}>
37
37
  <DaeryuntalkToastProvider>
38
38
  <ViewportHandler />
39
39
  <DaeryuntalkProvider propsTel={tel}>
@@ -48,7 +48,7 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
48
48
  }, []);
49
49
 
50
50
  return (
51
- <div className={`border-4`}>
51
+ <div className={``}>
52
52
  <DaeryuntalkToastProvider>
53
53
  <ViewportHandler />
54
54
  <DaeryuntalkProvider propsTel={tel}>
@@ -990,6 +990,10 @@ video {
990
990
  right: -0.125rem;
991
991
  }
992
992
 
993
+ .-right-1 {
994
+ right: -0.25rem;
995
+ }
996
+
993
997
  .-right-\[20px\] {
994
998
  right: -20px;
995
999
  }
@@ -998,6 +1002,10 @@ video {
998
1002
  right: -50px;
999
1003
  }
1000
1004
 
1005
+ .-top-1 {
1006
+ top: -0.25rem;
1007
+ }
1008
+
1001
1009
  .-top-10 {
1002
1010
  top: -2.5rem;
1003
1011
  }