@noverachat/sdk-web 0.3.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,
@@ -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
@@ -152,8 +152,7 @@ export interface SendParams {
152
152
  forwardBlocked?: boolean;
153
153
  replyToId?: MessageIdStr;
154
154
  /** Set when this send is forwarding an existing message. The server
155
- * uses it to enforce the source file's ``forwardBlocked`` flag (Phase
156
- * 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
157
156
  * differs from the source room, the send is rejected with
158
157
  * ``NC-FILE-014``. Pass the ORIGINAL message's ``messageId``. */
159
158
  forwardOfMessageId?: MessageIdStr;
@@ -238,11 +237,22 @@ export interface FilePresignResponse {
238
237
 
239
238
  // (wire frame types are generated — see re-export block near the top)
240
239
 
240
+ import type { CachePolicy, CacheStore } from "./cache.js";
241
+
241
242
  export interface ClientOptions {
242
243
  appId: string;
243
244
  endpoint: string; // e.g. "https://chat.example.com"
244
245
  wsEndpoint?: string; // defaults to endpoint with ws(s)://
245
246
  tokenProvider: () => Promise<string>;
247
+ /**
248
+ * 스냅샷 캐시 저장소 — 생략(기본)하면 캐시 기능이 전부 꺼진다.
249
+ * 주입하면 방 목록·방 히스토리 최신 페이지가 REST 원문 그대로 저장되고,
250
+ * `cachedUnreadSummary()` / `room.cachedRecent()` 로 콜드 스타트 즉시
251
+ * 렌더에 쓸 수 있다. 자세한 건 `CacheStore` 문서 참조.
252
+ */
253
+ cacheStore?: CacheStore;
254
+ /** 캐시 스냅샷과 API 응답의 합성 방식. 현재 `"replaceByApi"`만 지원. */
255
+ cachePolicy?: CachePolicy;
246
256
  autoReconnect?: boolean; // default true
247
257
  pingIntervalMs?: number; // default 20_000
248
258
  readWatermarkDebounceMs?: number;// default 1500