@uniai-fe/uds-templates 0.5.11 → 0.5.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/uds-templates",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "UNIAI Design System; UI Templates Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -218,6 +218,7 @@ export function useCctvRtcStream({
218
218
  useEffect(() => {
219
219
  const camId = cam?.cam_id;
220
220
  if (!camId) return;
221
+
221
222
  const instanceKey = instanceKeyRef.current as string;
222
223
  setLiveRegistry(prev => {
223
224
  const next = { ...prev };
@@ -226,7 +227,13 @@ export function useCctvRtcStream({
226
227
  next[camId] = perCam;
227
228
  return next;
228
229
  });
230
+ }, [cam?.cam_id, liveState, setLiveRegistry]);
231
+
232
+ useEffect(() => {
233
+ const camId = cam?.cam_id;
234
+ if (!camId) return;
229
235
 
236
+ const instanceKey = instanceKeyRef.current as string;
230
237
  return () => {
231
238
  setLiveRegistry(prev => {
232
239
  const next = { ...prev };
@@ -240,7 +247,7 @@ export function useCctvRtcStream({
240
247
  return next;
241
248
  });
242
249
  };
243
- }, [cam?.cam_id, liveState, setLiveRegistry]);
250
+ }, [cam?.cam_id, setLiveRegistry]);
244
251
 
245
252
  // 호출자에게 video ref와 상태값, 토큰 쿼리 상태를 전달한다.
246
253
  return {
@@ -12,6 +12,13 @@ export const CCTV_MESSAGE = {
12
12
  offline: "CCTV 연결 오류",
13
13
  } as const;
14
14
 
15
+ const RTC_PREPARING_STATES = new Set<RTCPeerConnectionState>([
16
+ "new",
17
+ "connecting",
18
+ "disconnected",
19
+ "closed",
20
+ ]);
21
+
15
22
  /**
16
23
  * CCTV; 스트리밍 상태에 따른 메시지 추출
17
24
  * @param {CctvVideoOverlayMessageParams} params 상태 파라미터
@@ -27,6 +34,7 @@ export const CCTV_MESSAGE = {
27
34
  */
28
35
  export function getOverlayMessage({
29
36
  cam,
37
+ connectionState,
30
38
  hasCamProp = false,
31
39
  isFetching = false,
32
40
  isTokenLoading,
@@ -44,6 +52,8 @@ export function getOverlayMessage({
44
52
  if (isTokenError) return CCTV_MESSAGE.tokenError;
45
53
  if (streamError) return streamError;
46
54
  if (isTokenLoading || isStreaming) return CCTV_MESSAGE.preparing;
55
+ if (connectionState === "failed") return CCTV_MESSAGE.offline;
56
+ if (RTC_PREPARING_STATES.has(connectionState)) return CCTV_MESSAGE.preparing;
47
57
  return null;
48
58
  }
49
59
 
@@ -60,6 +70,7 @@ export function getOverlayMessage({
60
70
  */
61
71
  export function getIsLive({
62
72
  cam,
73
+ connectionState,
63
74
  isTokenLoading,
64
75
  isTokenError,
65
76
  isStreaming,
@@ -70,6 +81,7 @@ export function getIsLive({
70
81
  if (isTokenLoading || isTokenError) return false;
71
82
  if (isStreaming) return false;
72
83
  if (streamError) return false;
84
+ if (connectionState !== "connected") return false;
73
85
  return true;
74
86
  }
75
87