@neta-art/cohub 5.4.2 → 5.4.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.
@@ -4081,6 +4081,7 @@ declare class WebsocketClient {
4081
4081
  private authenticate;
4082
4082
  private flushRoomSubscriptions;
4083
4083
  private restoreRoomSubscriptions;
4084
+ private resetRoomSubscriptions;
4084
4085
  private createAuthWaiter;
4085
4086
  private resolveAuthWaiter;
4086
4087
  private rejectAuthWaiter;
@@ -226,6 +226,7 @@ var WebsocketClient = class {
226
226
  this.startPingLoop();
227
227
  await this.authenticate();
228
228
  this.state = "open";
229
+ this.restoreRoomSubscriptions();
229
230
  this.reconnectAttempt = 0;
230
231
  this.emit("open", { connectionId: this.connectionId });
231
232
  resolveOnce();
@@ -261,6 +262,7 @@ var WebsocketClient = class {
261
262
  this.ws = null;
262
263
  this.compactStreamContexts.clear();
263
264
  this.patchStreamBuffers.clear();
265
+ this.resetRoomSubscriptions();
264
266
  const closeError = new Error(formatCloseMessage(event.code, event.reason));
265
267
  this.rejectAuthWaiter(closeError);
266
268
  const retryAuthClose = event.code === AUTH_CLOSE_CODE && this.retryAuthClose;
@@ -297,10 +299,7 @@ var WebsocketClient = class {
297
299
  this.retryAuthClose = false;
298
300
  this.compactStreamContexts.clear();
299
301
  this.patchStreamBuffers.clear();
300
- for (const state of this.roomSubscriptions.values()) {
301
- state.subscribed = false;
302
- state.pending = false;
303
- }
302
+ this.resetRoomSubscriptions();
304
303
  }
305
304
  async updatePresence(input) {
306
305
  await this.ensureOpen();
@@ -477,11 +476,10 @@ var WebsocketClient = class {
477
476
  }
478
477
  });
479
478
  await waiter.promise;
480
- await this.restoreRoomSubscriptions();
481
479
  this.authReconnectAttempted = false;
482
480
  }
483
481
  flushRoomSubscriptions() {
484
- if (this.ws?.readyState !== WebSocket.OPEN) return;
482
+ if (this.state !== "open" || this.ws?.readyState !== WebSocket.OPEN) return;
485
483
  const rooms = [...this.roomSubscriptions.entries()].filter(([, state]) => state.refCount > 0 && !state.subscribed && !state.pending).map(([room]) => room);
486
484
  if (rooms.length === 0) return;
487
485
  this.send({
@@ -493,10 +491,16 @@ var WebsocketClient = class {
493
491
  if (state) state.pending = true;
494
492
  }
495
493
  }
496
- async restoreRoomSubscriptions() {
497
- for (const state of this.roomSubscriptions.values()) state.subscribed = false;
494
+ restoreRoomSubscriptions() {
495
+ this.resetRoomSubscriptions();
498
496
  this.flushRoomSubscriptions();
499
497
  }
498
+ resetRoomSubscriptions() {
499
+ for (const state of this.roomSubscriptions.values()) {
500
+ state.subscribed = false;
501
+ state.pending = false;
502
+ }
503
+ }
500
504
  createAuthWaiter() {
501
505
  this.rejectAuthWaiter(/* @__PURE__ */ new Error("superseded auth waiter"));
502
506
  let resolve;
package/dist/index.js CHANGED
@@ -1624,6 +1624,7 @@ const RESERVED_PLATFORM_PATH_SEGMENTS = Object.freeze([
1624
1624
  "docs",
1625
1625
  "explore",
1626
1626
  "invite",
1627
+ "landing",
1627
1628
  "login",
1628
1629
  "logout",
1629
1630
  "new",
@@ -13,6 +13,7 @@ const RESERVED_PLATFORM_PATH_SEGMENTS = Object.freeze([
13
13
  "docs",
14
14
  "explore",
15
15
  "invite",
16
+ "landing",
16
17
  "login",
17
18
  "logout",
18
19
  "new",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub",
3
- "version": "5.4.2",
3
+ "version": "5.4.3",
4
4
  "description": "Cohub SDK for spaces, sessions, boards, and realtime agent collaboration.",
5
5
  "license": "Apache-2.0",
6
6
  "private": false,