@noverachat/sdk-web 0.2.0 → 0.4.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/src/index.ts CHANGED
@@ -1,5 +1,23 @@
1
1
  export { NoveraChat } from "./client.js";
2
2
  export { Room, type RoomEvents } from "./features/room.js";
3
+
4
+ // 스냅샷 캐시 — 앱 주입 저장소 인터페이스 + 정책 + 키 규칙
5
+ export { CacheKeys, type CachePolicy, type CacheStore } from "./cache.js";
6
+
7
+ // 코어 소유 메시지 상태 + 뷰모델 (sdk-react에서 이동)
8
+ export {
9
+ MessageCollection,
10
+ type CollectionChange,
11
+ type CollectionChangeKind,
12
+ } from "./features/message-collection.js";
13
+ export {
14
+ chatMessageFromHistory,
15
+ chatMessageFromLive,
16
+ pendingChatMessage,
17
+ pendingFileChatMessage,
18
+ type ChatMessage,
19
+ type ChatMessageStatus,
20
+ } from "./chat-message.js";
3
21
  export {
4
22
  ErrorCode,
5
23
  NoveraChatError,
@@ -20,6 +38,7 @@ export type {
20
38
  MessageType,
21
39
  ReactionEntry,
22
40
  RoomMemberOut,
41
+ RoomOut,
23
42
  RoomUnread,
24
43
  SendParams,
25
44
  SenderMini,
@@ -29,3 +48,28 @@ export type {
29
48
  WsInbound,
30
49
  WsOutbound,
31
50
  } from "./types.js";
51
+
52
+ // WS 이벤트 프레임 + 파일 메타 타입 — sdk-react 같은 상위 바인딩이 이벤트
53
+ // 페이로드를 직접 타이핑할 수 있도록 공개 (타입 전용, 런타임 영향 없음).
54
+ export type { ClientEvents } from "./client.js";
55
+ export type {
56
+ FileInline,
57
+ FileKind,
58
+ FileMeta,
59
+ FileThumbnailStatus,
60
+ MemberPreview,
61
+ MemberRole,
62
+ MessageIdStr,
63
+ PushTrigger,
64
+ SendFileOptions,
65
+ WsChatReceive,
66
+ WsMessageDeleted,
67
+ WsMessagesCleared,
68
+ WsMessageUpdated,
69
+ WsPresence,
70
+ WsReactionAdded,
71
+ WsReactionRemoved,
72
+ WsRoomEvent,
73
+ WsSyncTick,
74
+ WsTypingBroadcast,
75
+ } from "./types.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Snowflake id 비교 — 63비트 정수가 문자열로 오므로 BigInt로 비교한다
3
+ * (길이가 다르면 사전순 `>`는 틀린다: "9" > "10"). null/빈 문자열/"0"은
4
+ * "id 없음 = -∞"로 취급.
5
+ */
6
+ export function idGreater(
7
+ a: string | null | undefined,
8
+ b: string | null | undefined,
9
+ ): boolean {
10
+ if (!a || a === "0") return false;
11
+ if (!b || b === "0") return true;
12
+ try {
13
+ return BigInt(a) > BigInt(b);
14
+ } catch {
15
+ return a > b;
16
+ }
17
+ }
package/src/types.ts CHANGED
@@ -48,6 +48,8 @@ export type {
48
48
  SenderMini,
49
49
  ReactionEntry,
50
50
  MemberPreview,
51
+ MemberRole,
52
+ PushTrigger,
51
53
  RoomUnread,
52
54
  UnreadRoomItem,
53
55
  UnreadSummary,
@@ -150,8 +152,7 @@ export interface SendParams {
150
152
  forwardBlocked?: boolean;
151
153
  replyToId?: MessageIdStr;
152
154
  /** Set when this send is forwarding an existing message. The server
153
- * uses it to enforce the source file's ``forwardBlocked`` flag (Phase
154
- * C #7): if the source's file is no-forward AND the destination room
155
+ * uses it to enforce the source file's ``forwardBlocked`` flag: if the source's file is no-forward AND the destination room
155
156
  * differs from the source room, the send is rejected with
156
157
  * ``NC-FILE-014``. Pass the ORIGINAL message's ``messageId``. */
157
158
  forwardOfMessageId?: MessageIdStr;
@@ -236,11 +237,22 @@ export interface FilePresignResponse {
236
237
 
237
238
  // (wire frame types are generated — see re-export block near the top)
238
239
 
240
+ import type { CachePolicy, CacheStore } from "./cache.js";
241
+
239
242
  export interface ClientOptions {
240
243
  appId: string;
241
244
  endpoint: string; // e.g. "https://chat.example.com"
242
245
  wsEndpoint?: string; // defaults to endpoint with ws(s)://
243
246
  tokenProvider: () => Promise<string>;
247
+ /**
248
+ * 스냅샷 캐시 저장소 — 생략(기본)하면 캐시 기능이 전부 꺼진다.
249
+ * 주입하면 방 목록·방 히스토리 최신 페이지가 REST 원문 그대로 저장되고,
250
+ * `cachedUnreadSummary()` / `room.cachedRecent()` 로 콜드 스타트 즉시
251
+ * 렌더에 쓸 수 있다. 자세한 건 `CacheStore` 문서 참조.
252
+ */
253
+ cacheStore?: CacheStore;
254
+ /** 캐시 스냅샷과 API 응답의 합성 방식. 현재 `"replaceByApi"`만 지원. */
255
+ cachePolicy?: CachePolicy;
244
256
  autoReconnect?: boolean; // default true
245
257
  pingIntervalMs?: number; // default 20_000
246
258
  readWatermarkDebounceMs?: number;// default 1500