@uniai-fe/uds-templates 0.6.14 → 0.6.15

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.6.14",
3
+ "version": "0.6.15",
4
4
  "description": "UNIAI Design System; UI Templates Package",
5
5
  "type": "module",
6
6
  "private": false,
@@ -138,7 +138,7 @@ const canUseTokenForNewConnection = ({
138
138
  * @desc
139
139
  * return {
140
140
  * videoRef, // WebRTC MediaStream을 연결할 video 요소 ref
141
- * connectionState, // RTCPeerConnectionState 상태값
141
+ * connectionState, // UI 표시 기준 RTCPeerConnectionState 상태값
142
142
  * streamError, // 스트림 시도 중 발생한 오류 메시지
143
143
  * isStreaming, // UI 표시 기준 스트림 연결 절차 진행 여부
144
144
  * isTokenLoading, // UI 표시 기준 토큰 발급 요청 진행 여부
@@ -328,6 +328,13 @@ export function useCctvRtcStream({
328
328
  streamIdentityKey,
329
329
  ]);
330
330
 
331
+ const isPostConnectedRecoverableState =
332
+ hasConnected &&
333
+ Boolean(streamIdentityKey) &&
334
+ !isTokenError &&
335
+ !streamError &&
336
+ DISPLAY_CONNECTED_DURING_RECOVERY_STATES.has(connectionState);
337
+
331
338
  const isPostConnectedReplacementLoading =
332
339
  hasConnected &&
333
340
  Boolean(streamIdentityKey) &&
@@ -336,13 +343,10 @@ export function useCctvRtcStream({
336
343
  (isTokenLoading || isStreaming);
337
344
 
338
345
  const shouldPreserveConnectedDisplay =
339
- isPostConnectedReplacementLoading ||
340
- (hasConnected &&
341
- !isPostConnectedReconnectReady &&
342
- DISPLAY_CONNECTED_DURING_RECOVERY_STATES.has(connectionState));
346
+ isPostConnectedReplacementLoading || isPostConnectedRecoverableState;
343
347
 
344
348
  // 반환 state는 CamList/Viewer/overlay의 live/error/message 계산에 직접 쓰인다.
345
- // post-connected recovery/replacement 중에는 기존 화면을 유지해 UI reset 파동을 막는다.
349
+ // post-connected recovery/replacement 중에는 canReconnect만 열고, 기존 화면은 유지해 UI reset 파동을 막는다.
346
350
  const displayConnectionState = shouldPreserveConnectedDisplay
347
351
  ? "connected"
348
352
  : connectionState;
@@ -738,6 +742,7 @@ export function useCctvRtcStream({
738
742
  displayConnectionState,
739
743
  hasConnected,
740
744
  isPostConnectedReplacementLoading,
745
+ isPostConnectedRecoverableState,
741
746
  isPostConnectedReconnectReady,
742
747
  displayIsStreaming,
743
748
  displayIsTokenLoading,
@@ -759,6 +764,7 @@ export function useCctvRtcStream({
759
764
  displayIsTokenLoading,
760
765
  hasConnected,
761
766
  isPostConnectedReplacementLoading,
767
+ isPostConnectedRecoverableState,
762
768
  isPostConnectedReconnectReady,
763
769
  isStreaming,
764
770
  isTokenError,
@@ -59,7 +59,7 @@ export interface UseCctvRtcStreamError {
59
59
 
60
60
  /**
61
61
  * CCTV; useCctvRtcStream 연결 상태
62
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
62
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
63
63
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
64
64
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
65
65
  * @property {boolean} isTokenError 토큰 발급 실패 여부
@@ -67,7 +67,11 @@ export interface UseCctvRtcStreamError {
67
67
  */
68
68
  export interface UseCctvRtcStreamState extends UseCctvRtcStreamError {
69
69
  /**
70
- * WebRTC 연결 상태
70
+ * UI 표시 기준 WebRTC 연결 상태
71
+ * @desc
72
+ * 최초 연결 전에는 실제 PeerConnection 상태를 나타낸다. 이미 한 번 연결된 stream이
73
+ * recoverable `disconnected`/`failed` 상태에 들어가면 기존 화면과 live count 유지를 위해
74
+ * `connected`로 smoothing될 수 있다.
71
75
  */
72
76
  connectionState: RTCPeerConnectionState;
73
77
  /**
@@ -89,7 +93,7 @@ export interface UseCctvRtcStreamState extends UseCctvRtcStreamError {
89
93
  /**
90
94
  * CCTV; useCctvRtcStream return
91
95
  * @property {React.RefObject<HTMLVideoElement>} videoRef <video /> ref
92
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
96
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
93
97
  * @property {string | null} streamError 스트림 오류 메시지
94
98
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
95
99
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
@@ -110,6 +114,7 @@ export interface UseCctvRtcStreamReturn extends UseCctvRtcStreamState {
110
114
  * 서비스 overlay가 reconnectStream()을 호출해도 되는 시점에 true가 된다.
111
115
  * post-connected `disconnected`는 자동 재연결 사유가 아니며,
112
116
  * token/stream 오류 또는 `failed`처럼 명확한 복구 사유만 true 전환 후보가 된다.
117
+ * recoverable `failed`에서는 화면이 live로 유지되는 동안에도 true가 될 수 있다.
113
118
  */
114
119
  canReconnect: boolean;
115
120
  /**
@@ -6,12 +6,13 @@ import type { UseCctvRtcStreamError, UseCctvRtcStreamState } from "./hook";
6
6
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
7
7
  * @property {boolean} [hasCamProp] 직접 cam prop을 받은 경우 true
8
8
  * @property {boolean} [isFetching] 서버에서 cam 리스트를 가져오는 중인지 여부
9
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
9
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
10
10
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
11
11
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
12
12
  * @property {boolean} isTokenError 토큰 발급 실패 여부
13
13
  * @property {string | null} streamError 스트림 오류 메시지
14
- * @property {boolean} [canReconnect] UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부
14
+ * @property {boolean} [canReconnect] UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부.
15
+ * 오류 스타일 판정에는 직접 사용하지 않는다.
15
16
  */
16
17
  export interface CctvVideoOverlayMessageParams extends UseCctvRtcStreamState {
17
18
  /**
@@ -28,6 +29,8 @@ export interface CctvVideoOverlayMessageParams extends UseCctvRtcStreamState {
28
29
  isFetching?: boolean;
29
30
  /**
30
31
  * UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부
32
+ * @desc
33
+ * 재연결 trigger gate이며, 기본 error style 판정에는 직접 사용하지 않는다.
31
34
  */
32
35
  canReconnect?: boolean;
33
36
  }
@@ -35,7 +38,7 @@ export interface CctvVideoOverlayMessageParams extends UseCctvRtcStreamState {
35
38
  /**
36
39
  * CCTV; getIsLive() params
37
40
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
38
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
41
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
39
42
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
40
43
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
41
44
  * @property {boolean} isTokenError 토큰 발급 실패 여부
@@ -53,7 +56,8 @@ export interface CctvVideoLiveParams extends UseCctvRtcStreamState {
53
56
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
54
57
  * @property {boolean} isTokenError 토큰 발급 실패 여부
55
58
  * @property {string | null} streamError 스트림 오류 메시지
56
- * @property {boolean} [canReconnect] UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부
59
+ * @property {boolean} [canReconnect] UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부.
60
+ * 오류 스타일 판정에는 직접 사용하지 않는다.
57
61
  */
58
62
  export interface CctvVideoErrorParams extends UseCctvRtcStreamError {
59
63
  /**
@@ -62,6 +66,8 @@ export interface CctvVideoErrorParams extends UseCctvRtcStreamError {
62
66
  cam?: CctvCompanyCameraData;
63
67
  /**
64
68
  * UDS 내부 허용 사유와 grace/stagger를 통과해 재연결 호출이 가능한지 여부
69
+ * @desc
70
+ * 재연결 trigger gate이며, 기본 error style 판정에는 직접 사용하지 않는다.
65
71
  */
66
72
  canReconnect?: boolean;
67
73
  }
@@ -31,7 +31,7 @@ const RTC_SESSION_ENDED_RECONNECT_STATES = new Set<RTCPeerConnectionState>([
31
31
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
32
32
  * @property {boolean} [hasCamProp] 직접 cam prop을 받은 경우 true
33
33
  * @property {boolean} [isFetching] 서버에서 cam 리스트를 가져오는 중인지 여부
34
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
34
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
35
35
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
36
36
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
37
37
  * @property {boolean} isTokenError 토큰 발급 실패 여부
@@ -72,7 +72,7 @@ export function getOverlayMessage({
72
72
  * CCTV; 스트리밍 라이브 상태 판단
73
73
  * @param {CctvVideoLiveParams} params 상태 파라미터
74
74
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
75
- * @property {RTCPeerConnectionState} connectionState WebRTC 연결 상태
75
+ * @property {RTCPeerConnectionState} connectionState UI 표시 기준 WebRTC 연결 상태
76
76
  * @property {boolean} isStreaming UI 표시 기준 startWhepStream 진행 여부
77
77
  * @property {boolean} isTokenLoading UI 표시 기준 토큰 발급 요청 진행 여부
78
78
  * @property {boolean} isTokenError 토큰 발급 실패 여부
@@ -102,17 +102,16 @@ export function getIsLive({
102
102
  * @property {CctvCompanyCameraData} [cam] 카메라 데이터
103
103
  * @property {boolean} isTokenError 토큰 발급 실패 여부
104
104
  * @property {string | null} streamError 스트림 오류 메시지
105
+ * @property {boolean} [canReconnect] 재연결 trigger 가능 여부. 오류 표시 여부에는 직접 사용하지 않는다.
105
106
  * @returns {boolean} 에러 상태 여부 반환
106
107
  */
107
108
  export function getIsError({
108
109
  cam,
109
- canReconnect,
110
110
  isTokenError,
111
111
  streamError,
112
112
  }: CctvVideoErrorParams): boolean {
113
113
  if (!cam) return true;
114
114
  if (!cam.cam_online) return true;
115
- if (canReconnect) return true;
116
115
  if (isTokenError) return true;
117
116
  if (streamError) return true;
118
117
  return false;