cry-synced-db-client 0.1.54 → 0.1.55

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.js CHANGED
@@ -626,7 +626,6 @@ class ConnectionManager {
626
626
  } else {
627
627
  this.online = online;
628
628
  this.stopAutoSync();
629
- this.deps.releaseLeaderLock();
630
629
  }
631
630
  }
632
631
  forceOffline(forced) {
@@ -647,7 +646,6 @@ class ConnectionManager {
647
646
  const wasOnline = this.online;
648
647
  this.online = false;
649
648
  this.stopAutoSync();
650
- this.deps.releaseLeaderLock();
651
649
  if (wasOnline) {
652
650
  this.callbacks.onOnlineStatusChange?.(false);
653
651
  }
@@ -2697,7 +2695,7 @@ class SyncedDb {
2697
2695
  this.serverUpdateNotifier = config.serverUpdateNotifier;
2698
2696
  this.updaterId = Math.random().toString(36).substring(2, 15);
2699
2697
  this.syncedDbInstanceId = `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
2700
- const windowId = this.getOrCreateWindowId();
2698
+ const windowId = config._testWindowId ?? this.getOrCreateWindowId();
2701
2699
  this.onSync = config.onSync;
2702
2700
  this.onConflictResolved = config.onConflictResolved;
2703
2701
  this.onWsNotification = config.onWsNotification;
@@ -37,6 +37,9 @@ export declare class ConnectionManager implements I_ConnectionManager {
37
37
  canReceiveServerUpdates(): boolean;
38
38
  /**
39
39
  * Set online status.
40
+ * Note: Going offline does NOT release leadership. With window-scoped locks,
41
+ * a tab should remain leader within its window to process WebSocket notifications
42
+ * even while offline.
40
43
  */
41
44
  setOnline(online: boolean): Promise<void>;
42
45
  /**
@@ -45,6 +48,9 @@ export declare class ConnectionManager implements I_ConnectionManager {
45
48
  forceOffline(forced: boolean): void;
46
49
  /**
47
50
  * Go offline with reason.
51
+ * Note: This does NOT release leadership. With window-scoped locks,
52
+ * a tab should remain leader within its window to process WebSocket notifications
53
+ * even while offline due to network issues.
48
54
  */
49
55
  goOffline(reason: string): void;
50
56
  /**
@@ -284,6 +284,13 @@ export interface SyncedDbConfig {
284
284
  onBecameLeader?: () => void;
285
285
  /** Callback when this instance loses leadership (e.g., another tab took over) */
286
286
  onLostLeadership?: () => void;
287
+ /**
288
+ * Override the window ID for testing purposes.
289
+ * In production, window ID is auto-generated and stored in sessionStorage.
290
+ * In tests, you can provide unique IDs to simulate multiple browser windows.
291
+ * @internal
292
+ */
293
+ _testWindowId?: string;
287
294
  /**
288
295
  * Callback when an infrastructure error occurs (missing browser APIs, connection failures, etc.)
289
296
  * This is called for non-fatal infrastructure issues that may degrade functionality.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",