@kispi/chat 0.7.5 → 0.8.1

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/README.en.md CHANGED
@@ -62,6 +62,7 @@ is in the browser, the whole app is open.
62
62
  | `state` | The four values above |
63
63
  | `error` | The client stopped at `closed` on its own, and why (a `ChatError`): an authentication refusal, or a `ChatError` from `token()`. Not emitted for `close()` |
64
64
  | `notification` | A new message arrived in a room I'm a member of, but I'm not viewing that room |
65
+ | `notification.typing` | `{roomId, userId, threadId?}` — someone is typing in a room I'm a member of but **have not subscribed** (a room list's "typing…"). It comes **only for small rooms** (about ten members or fewer; the engine may change it) — a bigger room sends nothing. Never for my own typing; for a subscribed room use `typists()` / `typing.changed`. Show it for five seconds or more, and clear it when that user's message arrives |
65
66
  | `resumed` | `{reconnected}` — back after a reconnect (`true`), or a tab/app return, network return or back/forward-cache restore (`pageshow`) found the socket alive and resubscribed every room (`false`). Rooms and `roomList()` catch themselves up; use it to refetch **what the SDK does not hold** (an activity feed, search results) |
66
67
  | `user.presence` | Presence changes of my other connections |
67
68
  | `frame` | Every received frame. For debugging |
@@ -86,11 +87,11 @@ off()
86
87
 
87
88
  | Method | |
88
89
  |---|---|
89
- | `subscribe()` | Turns on the live feed and reads the latest 100. Does nothing if already caught up. **Fine to call before connecting** — it waits until connected (rejects with `closed` on `close()`) |
90
+ | `subscribe()` | Turns on the live feed and reads the latest page (sends no `limit`, so it is **the engine's client default, 20 messages**; if the first screen is not full, keep calling `loadOlder()` while `hasOlder`). Does nothing if already caught up. **Fine to call before connecting** — it waits until connected (rejects with `closed` on `close()`) |
90
91
  | `unsubscribe()` | Stops viewing this room. It is not resubscribed on reconnect |
91
92
  | `send({text, attachments?, entities?, replyTo?, threadId?, meta?}, {clientMessageId?})` | Publish. Acked with `{messageId, seq}`. If a subscription is in progress, it waits for it. **While reconnecting it waits for the connection, then sends** (below) |
92
93
  | `loadOlder({limit?})` | Reads the page before the oldest message (default 100) and **prepends it to `messages`.** Returns `{messages, hasMore}`. Use it when scrolling up. If the list is empty (before subscribing), it reads nothing |
93
- | `history({before?, after?, limit?, view?})` | Reads the past directly. **Independent of `messages`.** `view` is `'main'`, `'all'`, or `{thread: id}` |
94
+ | `history({before?, after?, limit?, view?})` | Reads the past directly (no `limit` means the engine default of 20, at most 100). **Independent of `messages`.** `view` is `'main'`, `'all'`, or `{thread: id}` |
94
95
  | `thread(rootId, {root?})` | **Thread handle** (`Thread`, below). One per root id, cached until `close()` |
95
96
  | `edit(messageId, {text?, entities?, attachments?})` | Edits your own message. **Replaces the body** — pass back the `attachments`/`entities` to keep. Sender only, within the app's edit window (`forbidden` otherwise). The returned row is applied to `messages` and open threads at once |
96
97
  | `delete(messageId)` | Deletes a message: your own, or anyone's for owners and admins. Idempotent. The row becomes a tombstone at once |
@@ -185,9 +186,24 @@ room.on('messages', m => (messages.value = m))
185
186
  showTyping(userId, name ?? 'Someone') // clearing it after ~5 seconds is yours to do
186
187
  })
187
188
  ```
189
+ - **Draw a room list's "typing…" from `notification.typing`.** A room you have not subscribed gets no
190
+ `typing`, so this event stands in -- for small rooms only (once you subscribe the room, the same person's
191
+ typing arrives as `typing.changed` and this event stops). There is no "stopped" event: show it for
192
+ **five seconds or more** and clear it when that user's message arrives (`notification`'s `preview.sender.id`).
193
+
194
+ ```ts
195
+ const typingIn = new Map<string, Map<string, number>>() // roomId -> userId -> expiry
196
+ chat.on('notification.typing', ({ roomId, userId, threadId }) => {
197
+ if (threadId !== undefined) return // main timeline only
198
+ const room = typingIn.get(roomId) ?? new Map()
199
+ room.set(userId, Date.now() + 5_000)
200
+ typingIn.set(roomId, room)
201
+ renderRoomRow(roomId) // drop expired entries on a timer or the next render
202
+ })
203
+ ```
188
204
  - **The connection comes back on its own.** It reconnects with exponential backoff, so don't
189
205
  write your own retry loop.
190
- - **A reconnect also brings the rows you already hold up to date.** The catch-up (`since`) only fills *new* messages; a reaction, a thread count (`thread.updated`), an edit or a delete on a message you already had rides on no event while you were away. So after a real reconnect (including a tab or app returning from the background, same user) and once the catch-up is done, the SDK **reads the newest 100 messages once (one GET per room) and merges them into the rows it holds.** The list is not replaced (no `reset`, pages loaded with `loadOlder()` stay); each row that actually changed becomes a new object with a `message.updated`, a row that is now deleted becomes a tombstone with `message.deleted` (`messages` fires once). A row that a live event, or a reaction this client pressed, touched while the read was in flight is left alone because that value is newer. **Rows older than the newest 100 are not re-read** — use `reload()` for those. Thread replies live in the same timeline, so they are refreshed along with their roots. If the read fails only `error` is emitted and the room stays subscribed. You do not need to call `reload()` yourself.
206
+ - **A reconnect also brings the rows you already hold up to date.** The catch-up (`since`) only fills *new* messages; a reaction, a thread count (`thread.updated`), an edit or a delete on a message you already had rides on no event while you were away. So after a real reconnect (including a tab or app returning from the background, same user) and once the catch-up is done, the SDK **reads the newest page once (the engine's default, 20 messages; one GET per room) and merges them into the rows it holds.** The list is not replaced (no `reset`, pages loaded with `loadOlder()` stay); each row that actually changed becomes a new object with a `message.updated`, a row that is now deleted becomes a tombstone with `message.deleted` (`messages` fires once). A row that a live event, or a reaction this client pressed, touched while the read was in flight is left alone because that value is newer. **Rows older than that page are not re-read** — use `reload()` for those. Thread replies live in the same timeline, so they are refreshed along with their roots. If the read fails only `error` is emitted and the room stays subscribed. You do not need to call `reload()` yourself.
191
207
  - **What you send while reconnecting waits, then goes out.** `send`, `react`, `unreact` and
192
208
  `markRead` skip the backoff when the state is `connecting`/`reconnecting`, wait for the
193
209
  connection, and send. If the socket drops before the ack, **the same frame is sent once more**
package/README.md CHANGED
@@ -62,6 +62,7 @@ npm install @kispi/chat
62
62
  | `state` | 위 네 값 |
63
63
  | `error` | 클라이언트가 스스로 `closed`로 멈췄고 그 이유(`ChatError`). 인증 거절이나 `token()`의 `ChatError`. `close()`로 닫을 때는 없다 |
64
64
  | `notification` | 멤버인 방에 새 메시지가 왔는데 그 방을 보고 있지 않을 때 |
65
+ | `notification.typing` | `{roomId, userId, threadId?}` — 내가 멤버인데 **구독하지 않은 방**에서 누가 입력 중이다(방 목록의 "입력 중…"). **작은 방(멤버 10명 안팎 이하, 엔진이 바꿀 수 있다)에만** 오고 큰 방은 아무것도 안 온다. 내 입력은 안 오고, 구독한 방의 입력은 `typists()`·`typing.changed`로 온다. 5초 이상 보여 주고 그 사람의 글이 오면 지운다 |
65
66
  | `resumed` | `{reconnected}` — 다시 붙었거나(`true`), 탭·앱 복귀·온라인 복귀·bfcache 복원(`pageshow`)에서 소켓이 살아 있어 방들을 다시 구독했다(`false`). 방과 `roomList()`는 스스로 맞추니, **SDK가 들고 있지 않은 것**(활동 피드·검색 결과처럼 앱이 REST로 받은 목록)을 다시 받을 때 쓴다 |
66
67
  | `user.presence` | 내 다른 접속의 presence 변화 |
67
68
  | `frame` | 받은 프레임 전부. 디버깅용 |
@@ -85,11 +86,11 @@ off()
85
86
 
86
87
  | 메서드 | |
87
88
  |---|---|
88
- | `subscribe()` | 라이브 피드를 켜고 최근 100건을 읽는다. 이미 따라잡혔으면 아무것도 안 한다. **연결 전에 불러도 된다** — 붙을 때까지 기다린다(`close()`면 `closed`로 거절) |
89
+ | `subscribe()` | 라이브 피드를 켜고 최근 한 페이지를 읽는다(`limit`을 보내지 않아 **엔진의 클라이언트 기본, 20건**이다. 첫 화면이 모자라면 `hasOlder`인 동안 `loadOlder()`로 이어 읽는다). 이미 따라잡혔으면 아무것도 안 한다. **연결 전에 불러도 된다** — 붙을 때까지 기다린다(`close()`면 `closed`로 거절) |
89
90
  | `unsubscribe()` | 이 방 보기를 그만둔다. 재접속해도 다시 구독하지 않는다 |
90
91
  | `send({text, attachments?, entities?, replyTo?, threadId?, meta?}, {clientMessageId?})` | 발행. ack로 `{messageId, seq}`. 구독이 진행 중이면 그것을 기다린다. **재접속 중이면 붙을 때까지 기다렸다가 보낸다**(아래) |
91
92
  | `loadOlder({limit?})` | 가장 오래된 메시지 앞 페이지(기본 100)를 읽어 **`messages` 앞에 붙인다.** `{messages, hasMore}`. 스크롤을 올릴 때 쓴다. 목록이 비어 있으면(구독 전) 아무것도 읽지 않는다 |
92
- | `history({before?, after?, limit?, view?})` | 과거를 직접 읽는다. **`messages`와 따로 논다.** `view`는 `'main'`, `'all'`, `{thread: id}`. 스레드 패널은 `thread()`를 쓴다 |
93
+ | `history({before?, after?, limit?, view?})` | 과거를 직접 읽는다(`limit`을 안 주면 엔진 기본 20건, 최대 100). **`messages`와 따로 논다.** `view`는 `'main'`, `'all'`, `{thread: id}`. 스레드 패널은 `thread()`를 쓴다 |
93
94
  | `thread(rootId, {root?})` | **스레드 핸들**(`Thread`, 아래). 루트 id마다 하나, `close()`까지 캐시된다 |
94
95
  | `edit(messageId, {text?, entities?, attachments?})` | 내 글 고치기. **본문을 통째로 바꾼다** — 남길 `attachments`·`entities`도 다시 넘긴다. 본인만·앱의 수정 가능 시간 안(아니면 `forbidden`). 응답 행(`Message`)을 `messages`와 열린 스레드에 바로 반영한다 |
95
96
  | `delete(messageId)` | 글 지우기. 본인 글, 방장·관리자는 남의 글도. 멱등. 그 행을 바로 tombstone으로 |
@@ -172,10 +173,24 @@ room.on('messages', m => (messages.value = m))
172
173
  showTyping(names) // 빈 배열이면 지운다
173
174
  })
174
175
  ```
176
+ - **방 목록의 "입력 중…"은 `notification.typing`으로 그린다.** 열려 있지 않은(구독하지 않은) 방은 `typing`이 오지 않으니
177
+ 이 이벤트가 대신한다 — 작은 방만(그 방을 구독하면 같은 사람의 입력이 `typing.changed`로 오고 이 이벤트는 안 온다). "멈춤" 이벤트가 없으므로
178
+ 5초 이상 보여 주고, 그 사람의 글이 오면(`notification`의 `preview.sender.id`) 지운다.
179
+
180
+ ```ts
181
+ const typingIn = new Map<string, Map<string, number>>() // roomId -> userId -> 만료 시각
182
+ chat.on('notification.typing', ({ roomId, userId, threadId }) => {
183
+ if (threadId !== undefined) return // 본 타임라인만
184
+ const room = typingIn.get(roomId) ?? new Map()
185
+ room.set(userId, Date.now() + 5_000)
186
+ typingIn.set(roomId, room)
187
+ renderRoomRow(roomId) // 만료는 타이머나 다음 렌더에서 걸러 낸다
188
+ })
189
+ ```
175
190
  - **연결은 알아서 돌아온다.** 끊기면 지수 백오프로 다시 붙으니 재시도 루프를 짜지 않는다.
176
- - **재접속하면 이미 들고 있는 행도 최신으로 맞춘다.** 따라잡기(`since`)는 새 메시지만 채우고, 끊긴 사이 이미 있던 메시지에 붙은 리액션·스레드 수(`thread.updated`)·수정·삭제는 어느 이벤트로도 오지 않는다. 그래서 진짜 재접속(탭·앱 복귀의 재구독 포함, 같은 사람일 때) 뒤 따라잡기가 끝나면 SDK가 **가장 최근 100건을 한 번 읽어(방마다 GET 1번) 들고 있는 행에 합친다.** 목록을 바꾸지 않고(`reset` 없음, `loadOlder()`로 불러 둔 윗부분 그대로) 바뀐 행만 새 객체로 `message.updated`, 지워진 행은 tombstone으로 `message.deleted`를 낸다(`messages`는 한 번). 읽는 사이 도착한 라이브 이벤트나 이 클라이언트가 누른 리액션이 더 새 값이라 그 행은 건드리지 않는다. **최근 100건보다 오래된 행은 다시 읽지 않는다** — 필요하면 `reload()`. 스레드 답글은 같은 타임라인이라 루트와 함께 맞춰진다. 이 읽기가 실패하면 `error`만 나가고 방은 구독된 채다. 소비자가 따로 `reload()`를 부를 필요가 없다.
191
+ - **재접속하면 이미 들고 있는 행도 최신으로 맞춘다.** 따라잡기(`since`)는 새 메시지만 채우고, 끊긴 사이 이미 있던 메시지에 붙은 리액션·스레드 수(`thread.updated`)·수정·삭제는 어느 이벤트로도 오지 않는다. 그래서 진짜 재접속(탭·앱 복귀의 재구독 포함, 같은 사람일 때) 뒤 따라잡기가 끝나면 SDK가 **가장 최근 한 페이지(엔진 기본 20건)를 한 번 읽어(방마다 GET 1번) 들고 있는 행에 합친다.** 목록을 바꾸지 않고(`reset` 없음, `loadOlder()`로 불러 둔 윗부분 그대로) 바뀐 행만 새 객체로 `message.updated`, 지워진 행은 tombstone으로 `message.deleted`를 낸다(`messages`는 한 번). 읽는 사이 도착한 라이브 이벤트나 이 클라이언트가 누른 리액션이 더 새 값이라 그 행은 건드리지 않는다. **그 페이지보다 오래된 행은 다시 읽지 않는다** — 필요하면 `reload()`. 스레드 답글은 같은 타임라인이라 루트와 함께 맞춰진다. 이 읽기가 실패하면 `error`만 나가고 방은 구독된 채다. 소비자가 따로 `reload()`를 부를 필요가 없다.
177
192
  - **떠났던 방을 다시 구독할 때도 같다.** 핸들은 캐시되므로 `unsubscribe()` 뒤 `subscribe()`한 방은 들고 있던
178
- 행을 그대로 받는다. 그래서 다시 구독하면 재접속 때처럼 따라잡은 뒤 최근 100건을 읽어 합친다 — 떠나 있던
193
+ 행을 그대로 받는다. 그래서 다시 구독하면 재접속 때처럼 따라잡은 뒤 최근 한 페이지를 읽어 합친다 — 떠나 있던
179
194
  사이의 리액션·스레드 수가 새로 고침 없이 보인다. 열린 스레드 핸들도 최근 답글 100개를 다시 읽어 합친다.
180
195
  - **재접속 중에 보낸 것은 기다렸다가 나간다.** `send`·`react`·`unreact`·`markRead`는 상태가
181
196
  `connecting`/`reconnecting`이면 백오프를 건너뛰고 붙기를 기다려 보낸다. ack 전에 소켓이
package/dist/index.cjs CHANGED
@@ -945,7 +945,6 @@ var Thread = class extends Emitter {
945
945
  };
946
946
 
947
947
  // src/room.ts
948
- var HistoryPageSize = 100;
949
948
  var TypingSendIntervalMs = 1e3;
950
949
  var TypingTtlMs = 5e3;
951
950
  var MaxRepairs = 5;
@@ -1137,7 +1136,7 @@ var Room = class extends Emitter {
1137
1136
  *
1138
1137
  * A reconnect already brings the held rows up to date by itself: after
1139
1138
  * the catch-up it re-reads the newest page (one `GET .../messages`,
1140
- * `limit=100`) and **merges** it into the rows it holds -- reactions,
1139
+ * no `limit`, so the engine's default page for a client, 20) and **merges** it into the rows it holds -- reactions,
1141
1140
  * `myReactions`, thread counts, edits and deletes that happened while
1142
1141
  * the socket was away -- see `refreshHeld`. Reactions, thread counts and
1143
1142
  * the like ride on history rows only, and no event replays them, so
@@ -1228,7 +1227,7 @@ var Room = class extends Emitter {
1228
1227
  * What a reconnect's catch-up cannot bring: it fetches rows this client
1229
1228
  * does not have, and a reaction, a thread count, an edit or a delete that
1230
1229
  * happened to a row it **does** have rides on no event it will see. One
1231
- * `GET .../messages?limit=100` per reconnect, so the newest 100 rows of
1230
+ * `GET .../messages` per reconnect (no `limit`: the engine's default page, 20), so the newest rows of
1232
1231
  * the room are refreshed and anything older is not -- that is the bound
1233
1232
  * on the cost, and it is the part of the room people are looking at.
1234
1233
  * Thread replies live in the same timeline, so they and their roots come
@@ -1250,9 +1249,7 @@ var Room = class extends Emitter {
1250
1249
  if (this.timeline.messages.length === 0) return;
1251
1250
  const handle = this.timeline.beginRefresh();
1252
1251
  try {
1253
- const page = await this.rest.get(`/v1/rooms/${this.requireId("refreshing history")}/messages`, {
1254
- limit: HistoryPageSize
1255
- });
1252
+ const page = await this.rest.get(`/v1/rooms/${this.requireId("refreshing history")}/messages`);
1256
1253
  if (!stillCurrent()) return;
1257
1254
  const { updated, deleted } = this.timeline.applyRefresh(handle, page.messages);
1258
1255
  for (const m of updated) this.emit("message.updated", m);
@@ -1679,6 +1676,10 @@ var Room = class extends Emitter {
1679
1676
  /**
1680
1677
  * Replaces the timeline with the most recent page.
1681
1678
  *
1679
+ * No `limit` is sent: the page size is the engine's default for a client
1680
+ * (20), so it can be tuned in one place. A caller that wants more says so
1681
+ * with `loadOlder({ limit })`.
1682
+ *
1682
1683
  * `stillCurrent` guards the write, not the read. This is a replacement
1683
1684
  * -- the whole point of it -- so a page fetched for a socket that has
1684
1685
  * since died would throw away everything the socket that replaced it
@@ -1687,9 +1688,7 @@ var Room = class extends Emitter {
1687
1688
  * has to cover the part that touches shared state.
1688
1689
  */
1689
1690
  async loadRecent(stillCurrent) {
1690
- const page = await this.rest.get(`/v1/rooms/${this.requireId("reading history")}/messages`, {
1691
- limit: HistoryPageSize
1692
- });
1691
+ const page = await this.rest.get(`/v1/rooms/${this.requireId("reading history")}/messages`);
1693
1692
  if (!stillCurrent()) return;
1694
1693
  this.timeline.reset(page.messages);
1695
1694
  }
@@ -2535,6 +2534,10 @@ var ChatClient = class extends Emitter {
2535
2534
  this.emit("notification", push?.data);
2536
2535
  return;
2537
2536
  }
2537
+ if (event === "notification.typing") {
2538
+ this.emit("notification.typing", push?.data);
2539
+ return;
2540
+ }
2538
2541
  if (event === "user.presence") {
2539
2542
  this.emit("user.presence", push?.data);
2540
2543
  return;
package/dist/index.d.cts CHANGED
@@ -93,6 +93,18 @@ type UnreadCounts = {
93
93
  /** 총계가 일부만 센 값이다(방이 너무 많아 상한에서 잘렸다). */
94
94
  roomsCapped?: boolean;
95
95
  };
96
+ /**
97
+ * `notification.typing`의 data. 방 `typing`과 같은 뜻에 방 id를 붙인 것이다
98
+ * (유저 채널의 프레임에는 방 봉투가 없다).
99
+ *
100
+ * `userId`는 입력 중인 사람의 외부 id이고, `threadId`는 **루트** id다 —
101
+ * 본 타임라인이면 없다(`typing.changed`의 `threadId`와 같다).
102
+ */
103
+ type NotificationTyping = {
104
+ roomId: string;
105
+ userId: string;
106
+ threadId?: string;
107
+ };
96
108
  type Hello = {
97
109
  connectionId: string;
98
110
  user: AuthUser;
@@ -610,7 +622,7 @@ declare class Room extends Emitter<RoomEvents> {
610
622
  *
611
623
  * A reconnect already brings the held rows up to date by itself: after
612
624
  * the catch-up it re-reads the newest page (one `GET .../messages`,
613
- * `limit=100`) and **merges** it into the rows it holds -- reactions,
625
+ * no `limit`, so the engine's default page for a client, 20) and **merges** it into the rows it holds -- reactions,
614
626
  * `myReactions`, thread counts, edits and deletes that happened while
615
627
  * the socket was away -- see `refreshHeld`. Reactions, thread counts and
616
628
  * the like ride on history rows only, and no event replays them, so
@@ -640,7 +652,7 @@ declare class Room extends Emitter<RoomEvents> {
640
652
  * What a reconnect's catch-up cannot bring: it fetches rows this client
641
653
  * does not have, and a reaction, a thread count, an edit or a delete that
642
654
  * happened to a row it **does** have rides on no event it will see. One
643
- * `GET .../messages?limit=100` per reconnect, so the newest 100 rows of
655
+ * `GET .../messages` per reconnect (no `limit`: the engine's default page, 20), so the newest rows of
644
656
  * the room are refreshed and anything older is not -- that is the bound
645
657
  * on the cost, and it is the part of the room people are looking at.
646
658
  * Thread replies live in the same timeline, so they and their roots come
@@ -857,6 +869,10 @@ declare class Room extends Emitter<RoomEvents> {
857
869
  /**
858
870
  * Replaces the timeline with the most recent page.
859
871
  *
872
+ * No `limit` is sent: the page size is the engine's default for a client
873
+ * (20), so it can be tuned in one place. A caller that wants more says so
874
+ * with `loadOlder({ limit })`.
875
+ *
860
876
  * `stillCurrent` guards the write, not the read. This is a replacement
861
877
  * -- the whole point of it -- so a page fetched for a socket that has
862
878
  * since died would throw away everything the socket that replaced it
@@ -1025,6 +1041,24 @@ type ChatClientOptions = {
1025
1041
  type ChatClientEvents = {
1026
1042
  state: ConnectionState;
1027
1043
  notification: unknown;
1044
+ /**
1045
+ * Someone is typing in a room you are a member of but have not subscribed,
1046
+ * for a chat list's "typing..." beside that conversation.
1047
+ *
1048
+ * It comes only for small rooms (the engine sends it to rooms of about ten
1049
+ * members or fewer -- a bigger room never gets one, so do not read silence
1050
+ * as "nobody is typing"), never for your own typing, and never for a room
1051
+ * you have subscribed: that room's typing arrives through `room.typists()`
1052
+ * and `typing.changed`, so a screen that shows both reads the open room
1053
+ * from the room and every other row from here.
1054
+ *
1055
+ * There is no "stopped typing" event. Show it for **five seconds or
1056
+ * more** after the last one (the sender's signal comes about every three
1057
+ * seconds) and let it lapse, and clear it when that user's message
1058
+ * arrives -- `notification`'s `preview.sender.id`, or the room's
1059
+ * `message.created`. Not replayed after a reconnect.
1060
+ */
1061
+ 'notification.typing': NotificationTyping;
1028
1062
  'user.presence': unknown;
1029
1063
  /**
1030
1064
  * The client came back: a reconnect reached `hello` again, or `resume()`
@@ -1400,4 +1434,4 @@ declare function buildMentions(text: string, people: readonly {
1400
1434
  */
1401
1435
  declare function mentionSpans(text: string, entities: unknown): MentionSpan[];
1402
1436
 
1403
- export { type AuthUser, ChatClient, type ChatClientEvents, type ChatClientOptions, ChatEndpoint, ChatError, type ChatErrorCode, type ConnectionState, type EditInput, type Frame, type Hello, type MemberRow, type MentionEntity, type MentionSpan, type Message, type MyRoom, type PresenceEvent, type PresenceUser, type PublishAck, type ReactionEvent, type ReactionUser, type ReactionsPage, Room, type RoomEvents, type RoomInfo, RoomList, type RoomListEvents, type RoomSummary, type SendInput, type SendOptions, Thread, type ThreadEvents, type UnreadCounts, type WebSocketFactory, type WebSocketLike, buildMentions, createChatClient, mentionSpans };
1437
+ export { type AuthUser, ChatClient, type ChatClientEvents, type ChatClientOptions, ChatEndpoint, ChatError, type ChatErrorCode, type ConnectionState, type EditInput, type Frame, type Hello, type MemberRow, type MentionEntity, type MentionSpan, type Message, type MyRoom, type NotificationTyping, type PresenceEvent, type PresenceUser, type PublishAck, type ReactionEvent, type ReactionUser, type ReactionsPage, Room, type RoomEvents, type RoomInfo, RoomList, type RoomListEvents, type RoomSummary, type SendInput, type SendOptions, Thread, type ThreadEvents, type UnreadCounts, type WebSocketFactory, type WebSocketLike, buildMentions, createChatClient, mentionSpans };
package/dist/index.d.ts CHANGED
@@ -93,6 +93,18 @@ type UnreadCounts = {
93
93
  /** 총계가 일부만 센 값이다(방이 너무 많아 상한에서 잘렸다). */
94
94
  roomsCapped?: boolean;
95
95
  };
96
+ /**
97
+ * `notification.typing`의 data. 방 `typing`과 같은 뜻에 방 id를 붙인 것이다
98
+ * (유저 채널의 프레임에는 방 봉투가 없다).
99
+ *
100
+ * `userId`는 입력 중인 사람의 외부 id이고, `threadId`는 **루트** id다 —
101
+ * 본 타임라인이면 없다(`typing.changed`의 `threadId`와 같다).
102
+ */
103
+ type NotificationTyping = {
104
+ roomId: string;
105
+ userId: string;
106
+ threadId?: string;
107
+ };
96
108
  type Hello = {
97
109
  connectionId: string;
98
110
  user: AuthUser;
@@ -610,7 +622,7 @@ declare class Room extends Emitter<RoomEvents> {
610
622
  *
611
623
  * A reconnect already brings the held rows up to date by itself: after
612
624
  * the catch-up it re-reads the newest page (one `GET .../messages`,
613
- * `limit=100`) and **merges** it into the rows it holds -- reactions,
625
+ * no `limit`, so the engine's default page for a client, 20) and **merges** it into the rows it holds -- reactions,
614
626
  * `myReactions`, thread counts, edits and deletes that happened while
615
627
  * the socket was away -- see `refreshHeld`. Reactions, thread counts and
616
628
  * the like ride on history rows only, and no event replays them, so
@@ -640,7 +652,7 @@ declare class Room extends Emitter<RoomEvents> {
640
652
  * What a reconnect's catch-up cannot bring: it fetches rows this client
641
653
  * does not have, and a reaction, a thread count, an edit or a delete that
642
654
  * happened to a row it **does** have rides on no event it will see. One
643
- * `GET .../messages?limit=100` per reconnect, so the newest 100 rows of
655
+ * `GET .../messages` per reconnect (no `limit`: the engine's default page, 20), so the newest rows of
644
656
  * the room are refreshed and anything older is not -- that is the bound
645
657
  * on the cost, and it is the part of the room people are looking at.
646
658
  * Thread replies live in the same timeline, so they and their roots come
@@ -857,6 +869,10 @@ declare class Room extends Emitter<RoomEvents> {
857
869
  /**
858
870
  * Replaces the timeline with the most recent page.
859
871
  *
872
+ * No `limit` is sent: the page size is the engine's default for a client
873
+ * (20), so it can be tuned in one place. A caller that wants more says so
874
+ * with `loadOlder({ limit })`.
875
+ *
860
876
  * `stillCurrent` guards the write, not the read. This is a replacement
861
877
  * -- the whole point of it -- so a page fetched for a socket that has
862
878
  * since died would throw away everything the socket that replaced it
@@ -1025,6 +1041,24 @@ type ChatClientOptions = {
1025
1041
  type ChatClientEvents = {
1026
1042
  state: ConnectionState;
1027
1043
  notification: unknown;
1044
+ /**
1045
+ * Someone is typing in a room you are a member of but have not subscribed,
1046
+ * for a chat list's "typing..." beside that conversation.
1047
+ *
1048
+ * It comes only for small rooms (the engine sends it to rooms of about ten
1049
+ * members or fewer -- a bigger room never gets one, so do not read silence
1050
+ * as "nobody is typing"), never for your own typing, and never for a room
1051
+ * you have subscribed: that room's typing arrives through `room.typists()`
1052
+ * and `typing.changed`, so a screen that shows both reads the open room
1053
+ * from the room and every other row from here.
1054
+ *
1055
+ * There is no "stopped typing" event. Show it for **five seconds or
1056
+ * more** after the last one (the sender's signal comes about every three
1057
+ * seconds) and let it lapse, and clear it when that user's message
1058
+ * arrives -- `notification`'s `preview.sender.id`, or the room's
1059
+ * `message.created`. Not replayed after a reconnect.
1060
+ */
1061
+ 'notification.typing': NotificationTyping;
1028
1062
  'user.presence': unknown;
1029
1063
  /**
1030
1064
  * The client came back: a reconnect reached `hello` again, or `resume()`
@@ -1400,4 +1434,4 @@ declare function buildMentions(text: string, people: readonly {
1400
1434
  */
1401
1435
  declare function mentionSpans(text: string, entities: unknown): MentionSpan[];
1402
1436
 
1403
- export { type AuthUser, ChatClient, type ChatClientEvents, type ChatClientOptions, ChatEndpoint, ChatError, type ChatErrorCode, type ConnectionState, type EditInput, type Frame, type Hello, type MemberRow, type MentionEntity, type MentionSpan, type Message, type MyRoom, type PresenceEvent, type PresenceUser, type PublishAck, type ReactionEvent, type ReactionUser, type ReactionsPage, Room, type RoomEvents, type RoomInfo, RoomList, type RoomListEvents, type RoomSummary, type SendInput, type SendOptions, Thread, type ThreadEvents, type UnreadCounts, type WebSocketFactory, type WebSocketLike, buildMentions, createChatClient, mentionSpans };
1437
+ export { type AuthUser, ChatClient, type ChatClientEvents, type ChatClientOptions, ChatEndpoint, ChatError, type ChatErrorCode, type ConnectionState, type EditInput, type Frame, type Hello, type MemberRow, type MentionEntity, type MentionSpan, type Message, type MyRoom, type NotificationTyping, type PresenceEvent, type PresenceUser, type PublishAck, type ReactionEvent, type ReactionUser, type ReactionsPage, Room, type RoomEvents, type RoomInfo, RoomList, type RoomListEvents, type RoomSummary, type SendInput, type SendOptions, Thread, type ThreadEvents, type UnreadCounts, type WebSocketFactory, type WebSocketLike, buildMentions, createChatClient, mentionSpans };
package/dist/index.js CHANGED
@@ -871,7 +871,6 @@ var Thread = class extends Emitter {
871
871
  };
872
872
 
873
873
  // src/room.ts
874
- var HistoryPageSize = 100;
875
874
  var TypingSendIntervalMs = 1e3;
876
875
  var TypingTtlMs = 5e3;
877
876
  var MaxRepairs = 5;
@@ -1063,7 +1062,7 @@ var Room = class extends Emitter {
1063
1062
  *
1064
1063
  * A reconnect already brings the held rows up to date by itself: after
1065
1064
  * the catch-up it re-reads the newest page (one `GET .../messages`,
1066
- * `limit=100`) and **merges** it into the rows it holds -- reactions,
1065
+ * no `limit`, so the engine's default page for a client, 20) and **merges** it into the rows it holds -- reactions,
1067
1066
  * `myReactions`, thread counts, edits and deletes that happened while
1068
1067
  * the socket was away -- see `refreshHeld`. Reactions, thread counts and
1069
1068
  * the like ride on history rows only, and no event replays them, so
@@ -1154,7 +1153,7 @@ var Room = class extends Emitter {
1154
1153
  * What a reconnect's catch-up cannot bring: it fetches rows this client
1155
1154
  * does not have, and a reaction, a thread count, an edit or a delete that
1156
1155
  * happened to a row it **does** have rides on no event it will see. One
1157
- * `GET .../messages?limit=100` per reconnect, so the newest 100 rows of
1156
+ * `GET .../messages` per reconnect (no `limit`: the engine's default page, 20), so the newest rows of
1158
1157
  * the room are refreshed and anything older is not -- that is the bound
1159
1158
  * on the cost, and it is the part of the room people are looking at.
1160
1159
  * Thread replies live in the same timeline, so they and their roots come
@@ -1176,9 +1175,7 @@ var Room = class extends Emitter {
1176
1175
  if (this.timeline.messages.length === 0) return;
1177
1176
  const handle = this.timeline.beginRefresh();
1178
1177
  try {
1179
- const page = await this.rest.get(`/v1/rooms/${this.requireId("refreshing history")}/messages`, {
1180
- limit: HistoryPageSize
1181
- });
1178
+ const page = await this.rest.get(`/v1/rooms/${this.requireId("refreshing history")}/messages`);
1182
1179
  if (!stillCurrent()) return;
1183
1180
  const { updated, deleted } = this.timeline.applyRefresh(handle, page.messages);
1184
1181
  for (const m of updated) this.emit("message.updated", m);
@@ -1605,6 +1602,10 @@ var Room = class extends Emitter {
1605
1602
  /**
1606
1603
  * Replaces the timeline with the most recent page.
1607
1604
  *
1605
+ * No `limit` is sent: the page size is the engine's default for a client
1606
+ * (20), so it can be tuned in one place. A caller that wants more says so
1607
+ * with `loadOlder({ limit })`.
1608
+ *
1608
1609
  * `stillCurrent` guards the write, not the read. This is a replacement
1609
1610
  * -- the whole point of it -- so a page fetched for a socket that has
1610
1611
  * since died would throw away everything the socket that replaced it
@@ -1613,9 +1614,7 @@ var Room = class extends Emitter {
1613
1614
  * has to cover the part that touches shared state.
1614
1615
  */
1615
1616
  async loadRecent(stillCurrent) {
1616
- const page = await this.rest.get(`/v1/rooms/${this.requireId("reading history")}/messages`, {
1617
- limit: HistoryPageSize
1618
- });
1617
+ const page = await this.rest.get(`/v1/rooms/${this.requireId("reading history")}/messages`);
1619
1618
  if (!stillCurrent()) return;
1620
1619
  this.timeline.reset(page.messages);
1621
1620
  }
@@ -2461,6 +2460,10 @@ var ChatClient = class extends Emitter {
2461
2460
  this.emit("notification", push?.data);
2462
2461
  return;
2463
2462
  }
2463
+ if (event === "notification.typing") {
2464
+ this.emit("notification.typing", push?.data);
2465
+ return;
2466
+ }
2464
2467
  if (event === "user.presence") {
2465
2468
  this.emit("user.presence", push?.data);
2466
2469
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kispi/chat",
3
- "version": "0.7.5",
3
+ "version": "0.8.1",
4
4
  "description": "GravEx Chat SDK: managed realtime chat API. One WebSocket, many rooms, ordered history. Get an API key at chat.gravex.app.",
5
5
  "homepage": "https://chat.gravex.app/?utm_source=npm&utm_medium=referral&utm_campaign=sdk_readme",
6
6
  "keywords": [