@noverachat/sdk-web 0.5.2 → 0.5.3

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/dist/index.cjs CHANGED
@@ -2066,6 +2066,16 @@ var Room = class _Room {
2066
2066
  this.pendingAcks.delete(tempId2);
2067
2067
  this.mySentTempIds.delete(tempId2);
2068
2068
  }
2069
+ /**
2070
+ * ack 를 기다리던 전송을 전부 실패 처리한다 — `chat.disconnect()` 처럼
2071
+ * 응답이 올 길이 사라졌을 때. 메시지 컬렉션은 건드리지 않는다(낙관적
2072
+ * 버블은 `failed` 로 바뀌어 재전송 UI 를 띄울 수 있다).
2073
+ */
2074
+ _failPendingSends(reason) {
2075
+ for (const tempId2 of [...this.pendingAcks.keys()]) {
2076
+ this._rejectPending(tempId2, new Error(reason));
2077
+ }
2078
+ }
2069
2079
  /**
2070
2080
  * Try to re-send a pending frame after a transient server reject
2071
2081
  * (currently only NC-RATE-001 — the tenant's per-second token bucket
@@ -2226,9 +2236,22 @@ var NoveraChat = class {
2226
2236
  async connect() {
2227
2237
  await this.ws.connect();
2228
2238
  }
2239
+ /**
2240
+ * 소켓을 닫는다. **Room 파사드와 그 메시지 상태는 유지한다** — `connect()`
2241
+ * 로 다시 붙으면 같은 파사드가 그대로 이어서 프레임을 받는다.
2242
+ *
2243
+ * 예전엔 여기서 `rooms.clear()` 를 했는데, 그러면 UI 가 들고 있던 컬렉션이
2244
+ * 다음 접근 때 빈 컬렉션으로 교체돼 이미 로드한 히스토리가 사라졌다
2245
+ * (React StrictMode 의 connect → disconnect → connect 에서 채팅방이 빈
2246
+ * 화면으로 뜨는 증상). 소켓은 재사용되는 `ReconnectingWs` 인스턴스라
2247
+ * 파사드가 참조를 유지해도 문제가 없다.
2248
+ *
2249
+ * 다만 ack 를 기다리던 전송은 응답 받을 길이 없으므로 여기서 실패로
2250
+ * 정리한다(낙관적 버블이 영원히 `sending` 으로 남지 않도록).
2251
+ */
2229
2252
  disconnect() {
2230
2253
  this.ws.close();
2231
- this.rooms.clear();
2254
+ for (const room of this.rooms.values()) room._failPendingSends("disconnected");
2232
2255
  }
2233
2256
  room(roomId) {
2234
2257
  let r = this.rooms.get(roomId);
package/dist/index.d.cts CHANGED
@@ -1348,6 +1348,12 @@ declare class Room {
1348
1348
  * fail the matching outbound promise immediately instead of waiting
1349
1349
  * for the 15s ack timeout. */
1350
1350
  _rejectPending(tempId: string, err: Error): void;
1351
+ /**
1352
+ * ack 를 기다리던 전송을 전부 실패 처리한다 — `chat.disconnect()` 처럼
1353
+ * 응답이 올 길이 사라졌을 때. 메시지 컬렉션은 건드리지 않는다(낙관적
1354
+ * 버블은 `failed` 로 바뀌어 재전송 UI 를 띄울 수 있다).
1355
+ */
1356
+ _failPendingSends(reason: string): void;
1351
1357
  /**
1352
1358
  * Try to re-send a pending frame after a transient server reject
1353
1359
  * (currently only NC-RATE-001 — the tenant's per-second token bucket
@@ -1426,6 +1432,19 @@ declare class NoveraChat {
1426
1432
  private lastPresenceKey;
1427
1433
  constructor(opts: ClientOptions);
1428
1434
  connect(): Promise<void>;
1435
+ /**
1436
+ * 소켓을 닫는다. **Room 파사드와 그 메시지 상태는 유지한다** — `connect()`
1437
+ * 로 다시 붙으면 같은 파사드가 그대로 이어서 프레임을 받는다.
1438
+ *
1439
+ * 예전엔 여기서 `rooms.clear()` 를 했는데, 그러면 UI 가 들고 있던 컬렉션이
1440
+ * 다음 접근 때 빈 컬렉션으로 교체돼 이미 로드한 히스토리가 사라졌다
1441
+ * (React StrictMode 의 connect → disconnect → connect 에서 채팅방이 빈
1442
+ * 화면으로 뜨는 증상). 소켓은 재사용되는 `ReconnectingWs` 인스턴스라
1443
+ * 파사드가 참조를 유지해도 문제가 없다.
1444
+ *
1445
+ * 다만 ack 를 기다리던 전송은 응답 받을 길이 없으므로 여기서 실패로
1446
+ * 정리한다(낙관적 버블이 영원히 `sending` 으로 남지 않도록).
1447
+ */
1429
1448
  disconnect(): void;
1430
1449
  room(roomId: string): Room;
1431
1450
  /** Subscribe to client-level events. Currently `roomEvent` — membership /
package/dist/index.d.ts CHANGED
@@ -1348,6 +1348,12 @@ declare class Room {
1348
1348
  * fail the matching outbound promise immediately instead of waiting
1349
1349
  * for the 15s ack timeout. */
1350
1350
  _rejectPending(tempId: string, err: Error): void;
1351
+ /**
1352
+ * ack 를 기다리던 전송을 전부 실패 처리한다 — `chat.disconnect()` 처럼
1353
+ * 응답이 올 길이 사라졌을 때. 메시지 컬렉션은 건드리지 않는다(낙관적
1354
+ * 버블은 `failed` 로 바뀌어 재전송 UI 를 띄울 수 있다).
1355
+ */
1356
+ _failPendingSends(reason: string): void;
1351
1357
  /**
1352
1358
  * Try to re-send a pending frame after a transient server reject
1353
1359
  * (currently only NC-RATE-001 — the tenant's per-second token bucket
@@ -1426,6 +1432,19 @@ declare class NoveraChat {
1426
1432
  private lastPresenceKey;
1427
1433
  constructor(opts: ClientOptions);
1428
1434
  connect(): Promise<void>;
1435
+ /**
1436
+ * 소켓을 닫는다. **Room 파사드와 그 메시지 상태는 유지한다** — `connect()`
1437
+ * 로 다시 붙으면 같은 파사드가 그대로 이어서 프레임을 받는다.
1438
+ *
1439
+ * 예전엔 여기서 `rooms.clear()` 를 했는데, 그러면 UI 가 들고 있던 컬렉션이
1440
+ * 다음 접근 때 빈 컬렉션으로 교체돼 이미 로드한 히스토리가 사라졌다
1441
+ * (React StrictMode 의 connect → disconnect → connect 에서 채팅방이 빈
1442
+ * 화면으로 뜨는 증상). 소켓은 재사용되는 `ReconnectingWs` 인스턴스라
1443
+ * 파사드가 참조를 유지해도 문제가 없다.
1444
+ *
1445
+ * 다만 ack 를 기다리던 전송은 응답 받을 길이 없으므로 여기서 실패로
1446
+ * 정리한다(낙관적 버블이 영원히 `sending` 으로 남지 않도록).
1447
+ */
1429
1448
  disconnect(): void;
1430
1449
  room(roomId: string): Room;
1431
1450
  /** Subscribe to client-level events. Currently `roomEvent` — membership /
package/dist/index.js CHANGED
@@ -2031,6 +2031,16 @@ var Room = class _Room {
2031
2031
  this.pendingAcks.delete(tempId2);
2032
2032
  this.mySentTempIds.delete(tempId2);
2033
2033
  }
2034
+ /**
2035
+ * ack 를 기다리던 전송을 전부 실패 처리한다 — `chat.disconnect()` 처럼
2036
+ * 응답이 올 길이 사라졌을 때. 메시지 컬렉션은 건드리지 않는다(낙관적
2037
+ * 버블은 `failed` 로 바뀌어 재전송 UI 를 띄울 수 있다).
2038
+ */
2039
+ _failPendingSends(reason) {
2040
+ for (const tempId2 of [...this.pendingAcks.keys()]) {
2041
+ this._rejectPending(tempId2, new Error(reason));
2042
+ }
2043
+ }
2034
2044
  /**
2035
2045
  * Try to re-send a pending frame after a transient server reject
2036
2046
  * (currently only NC-RATE-001 — the tenant's per-second token bucket
@@ -2191,9 +2201,22 @@ var NoveraChat = class {
2191
2201
  async connect() {
2192
2202
  await this.ws.connect();
2193
2203
  }
2204
+ /**
2205
+ * 소켓을 닫는다. **Room 파사드와 그 메시지 상태는 유지한다** — `connect()`
2206
+ * 로 다시 붙으면 같은 파사드가 그대로 이어서 프레임을 받는다.
2207
+ *
2208
+ * 예전엔 여기서 `rooms.clear()` 를 했는데, 그러면 UI 가 들고 있던 컬렉션이
2209
+ * 다음 접근 때 빈 컬렉션으로 교체돼 이미 로드한 히스토리가 사라졌다
2210
+ * (React StrictMode 의 connect → disconnect → connect 에서 채팅방이 빈
2211
+ * 화면으로 뜨는 증상). 소켓은 재사용되는 `ReconnectingWs` 인스턴스라
2212
+ * 파사드가 참조를 유지해도 문제가 없다.
2213
+ *
2214
+ * 다만 ack 를 기다리던 전송은 응답 받을 길이 없으므로 여기서 실패로
2215
+ * 정리한다(낙관적 버블이 영원히 `sending` 으로 남지 않도록).
2216
+ */
2194
2217
  disconnect() {
2195
2218
  this.ws.close();
2196
- this.rooms.clear();
2219
+ for (const room of this.rooms.values()) room._failPendingSends("disconnected");
2197
2220
  }
2198
2221
  room(roomId) {
2199
2222
  let r = this.rooms.get(roomId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noverachat/sdk-web",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "NoveraChat browser/Node SDK — WebSocket + REST client with optimistic UI, reconnection and gap-fill",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/client.ts CHANGED
@@ -149,9 +149,22 @@ export class NoveraChat {
149
149
  await this.ws.connect();
150
150
  }
151
151
 
152
+ /**
153
+ * 소켓을 닫는다. **Room 파사드와 그 메시지 상태는 유지한다** — `connect()`
154
+ * 로 다시 붙으면 같은 파사드가 그대로 이어서 프레임을 받는다.
155
+ *
156
+ * 예전엔 여기서 `rooms.clear()` 를 했는데, 그러면 UI 가 들고 있던 컬렉션이
157
+ * 다음 접근 때 빈 컬렉션으로 교체돼 이미 로드한 히스토리가 사라졌다
158
+ * (React StrictMode 의 connect → disconnect → connect 에서 채팅방이 빈
159
+ * 화면으로 뜨는 증상). 소켓은 재사용되는 `ReconnectingWs` 인스턴스라
160
+ * 파사드가 참조를 유지해도 문제가 없다.
161
+ *
162
+ * 다만 ack 를 기다리던 전송은 응답 받을 길이 없으므로 여기서 실패로
163
+ * 정리한다(낙관적 버블이 영원히 `sending` 으로 남지 않도록).
164
+ */
152
165
  disconnect(): void {
153
166
  this.ws.close();
154
- this.rooms.clear();
167
+ for (const room of this.rooms.values()) room._failPendingSends("disconnected");
155
168
  }
156
169
 
157
170
  room(roomId: string): Room {
@@ -1246,6 +1246,17 @@ export class Room {
1246
1246
  this.mySentTempIds.delete(tempId);
1247
1247
  }
1248
1248
 
1249
+ /**
1250
+ * ack 를 기다리던 전송을 전부 실패 처리한다 — `chat.disconnect()` 처럼
1251
+ * 응답이 올 길이 사라졌을 때. 메시지 컬렉션은 건드리지 않는다(낙관적
1252
+ * 버블은 `failed` 로 바뀌어 재전송 UI 를 띄울 수 있다).
1253
+ */
1254
+ _failPendingSends(reason: string): void {
1255
+ for (const tempId of [...this.pendingAcks.keys()]) {
1256
+ this._rejectPending(tempId, new Error(reason));
1257
+ }
1258
+ }
1259
+
1249
1260
  /**
1250
1261
  * Try to re-send a pending frame after a transient server reject
1251
1262
  * (currently only NC-RATE-001 — the tenant's per-second token bucket